Commit Graph

18 Commits

Author SHA1 Message Date
Matt Godbolt
03d20c5fde Move assert.ts and rison.ts to shared/ directory (#8246)
## Summary
Moves `static/assert.ts` and `static/rison.ts` to `shared/` directory to
make them available to both frontend and backend code without browser
dependencies. Updates all import paths across the codebase (~47 files).

## Motivation
This refactoring eliminates browser dependencies in these utilities,
allowing them to be imported by Node.js contexts (like Cypress test
files) without causing module load failures. This is a prerequisite for
upcoming Cypress test improvements.

## Changes
- Move `static/assert.ts` → `shared/assert.ts`
- Move `static/rison.ts` → `shared/rison.ts`  
- Update `biome.json` to allow `hasOwnProperty` in `shared/` directory
- Update all imports across `static/`, `lib/`, and `test/` directories
(47 files changed)

## Benefits
- No functional changes, purely a code reorganization
- Makes these utilities accessible to both frontend and backend without
circular dependencies
- Enables future Cypress improvements that require these utilities in
Node.js context
- All tests pass ✓ (699 tests)

## Test Plan
- [x] TypeScript compilation passes
- [x] Linting passes
- [x] All unit tests pass (699 tests)
- [x] Pre-commit hooks pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-04 10:58:11 -06:00
narpfel
c9c8f35677 Add cursor: pointer to some clickable texts (#7863)
Before #7797, elements such as “Toggle full version output” in the
compiler version popup or the share buttons (“Short Link” etc.) would
change the cursor to a pointer on hover (like normal links do), but this
was lost when they were switched to use `link-primary`.

This PR restores the previous behaviour.
2025-06-25 10:54:12 +09:00
Matt Godbolt
4ef43a86e5 Improve GoldenLayout type safety (Phase 1) (#7801)
## Summary

This PR significantly improves type safety for GoldenLayout
configurations, continuing work from issue #4490 "The War of The Types".
This is an **incremental improvement** that establishes a solid
foundation for future work.

##  What We've Accomplished

### Core Type Infrastructure
- **Created comprehensive type system** in
`static/components.interfaces.ts`
- **Added `ComponentConfig<K>`** with proper generic constraints for
type-safe component configurations
- **Added `GoldenLayoutConfig`** to replace unsafe `any[]` content with
strongly-typed `ItemConfig[]`
- **Created `ComponentStateMap`** mapping component names to their
expected state types
- **Added proper TypeScript component name constants** with `as const`
for literal type inference

### Component Configuration Type Safety  
- **All component factory functions** now return strongly-typed
configurations
- **Clean type syntax**: `ComponentConfig<'compiler'>` using the
exported constants
- **Eliminated unsafe casts** in component creation and drag source
setup
- **Fixed hub method signatures** that incorrectly expected
`ContentItem` instead of `ItemConfig`

### Bug Fixes and Code Quality
- **Fixed Jeremy's TODO**: Improved `fixBugsInConfig` function typing 
- **Discovered and fixed hub type bug**:
`addAtRoot`/`addInEditorStackIfPossible` now accept correct types
- **Removed legacy conversion functions** that were no longer needed
- **Replaced verbose TODO comments** with GitHub issue references for
better organization

### Documentation and Planning
- **Created GitHub issues**
[#7807](https://github.com/compiler-explorer/compiler-explorer/issues/7807)
and
[#7808](https://github.com/compiler-explorer/compiler-explorer/issues/7808)
for remaining work
- **Documented type safety approach** with clear explanations of design
decisions
- **Added comprehensive implementation notes** for future contributors

## 🚧 What's Next (GitHub Issues)

- **Issue #7807**: [Type-safe
serialization/deserialization](https://github.com/compiler-explorer/compiler-explorer/issues/7807)
  - localStorage persistence and URL sharing 
  - SerializedLayoutState implementation
  - Version migration support

- **Issue #7808**: [Configuration validation and remaining type
gaps](https://github.com/compiler-explorer/compiler-explorer/issues/7808)
  - Enable `fromGoldenLayoutConfig` validation
  - Fix upstream GoldenLayout TypeScript definitions
  - State type normalization (addresses #4490)

## 📊 Impact

### Type Safety Improvements
- **No more `any` casts** in component configuration creation
- **Compile-time validation** of component names and state types
- **Better IDE support** with autocomplete and type checking
- **Runtime safety** through proper TypeScript interfaces

### Code Quality
- **~100 lines of verbose TODO comments** replaced with concise GitHub
issue references
- **Technical debt reduction** through elimination of unsafe casting
patterns
- **Improved maintainability** with centralized type definitions
- **Better error messages** when component configurations are incorrect

### Files Modified
- `static/components.interfaces.ts` - Core type definitions
- `static/components.ts` - Component factory functions and utilities  
- `static/main.ts` - Layout initialization and configuration handling
- `static/hub.ts` - Fixed method signatures
- `static/panes/*.ts` - Updated component creation patterns

##  Testing & Validation

- **All existing tests pass** - no runtime regressions
- **TypeScript compilation succeeds** with strict type checking
- **Linting passes** with no new warnings
- **Pre-commit hooks validated** all changes
- **Manual testing confirmed** layout functionality works correctly

## 🎯 Ready to Merge

This PR represents a **significant incremental improvement** that:
-  **Provides immediate value** through better type safety
-  **Maintains full backward compatibility** 
-  **Establishes solid foundation** for future improvements
-  **Centralizes remaining work** in well-documented GitHub issues
-  **Ready for production use** with no runtime changes

The remaining work is clearly tracked in the linked GitHub issues and
can be tackled incrementally in future PRs.

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-18 09:22:24 -05:00
Matt Godbolt
9e9e035b28 Rephrase frontend imports (#7824)
- Removes `rootDirs` so all imports will be relative in the frontend
- Updates (and unifies) imports to be `../types/...` etc instead of
relying on "types" being in the rootDir for the frontend.
- Fixes one type that was being picked up from `lib` in the frontend.
- Adds a precommit hook to check in future

Paves the way to writing _unit_ tests for the frontend for the subset of
the frontend code we can import from `node` (which might be a lot of
it!)
2025-06-18 09:04:23 -05:00
Mats Jun Larsen
47e8e6d3a7 Replace href=javascript:; with bootstrap link class (#7797)
Fixes #7792

Bootstrap styles `a:has([href])` as a link so the attribute had been
used in the past for things that aren't actually links, yet we want the
style for. It's better to just use `.link-primary` so it doesn't affect
the contents as discovered in #7792
2025-06-13 02:43:14 +09:00
Matt Godbolt
d2b46a7825 Handle case when the tool goes away 2025-05-21 20:12:12 -05:00
Mats Jun Larsen
5eea63328f Migrate to Biome for linting and formatting (#7033) 2025-02-02 17:54:31 +00:00
Ofek
4e5348ab77 Tsify tools (mostly) (#7018)
This includes among others:
 - Proper tsification of various tools code,
 - Elimination of the `CompilationInfo2` type,
 - Use of `CompilationInfo` instead of `Record<any, any>` in some places
 - These lines in CompilationResult:
```
    // Temp hack until we get all code to agree on type of asm
    asm?: ResultLine[] | string;
```

The next task would be to get all code to agree on the type of
CompilationResult.asm, thereby enabling fixing of most the remaining
TSification.
2024-10-26 10:58:30 +03:00
Ofek
93133510c2 Move ToolState to component.interfaces, to avoid duplicate tool.interface.ts 2024-10-25 22:02:30 +03:00
Ofek
c1985d64a1 Tsification binge #7 (#6974) 2024-10-25 12:19:04 +03:00
Ofek
2df8d32758 Tsify #6 (#6941)
Another tsification batch. 347 to go and I'm running out of easy fixes
:(
2024-10-22 21:41:44 +03:00
Ofek
caca3ea6c7 Eliminate all google-analytics dead code (#6954)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE
IT
Thanks for taking the time to improve CE. We really appreciate it.
Before opening the PR, please make sure that the tests & linter pass
their checks,
  by running `make check`.
In the best case scenario, you are also adding tests to back up your
changes,
  but don't sweat it if you don't. We can discuss them at a later date.
Feel free to append your name to the CONTRIBUTORS.md file
Thanks again, we really appreciate this!
-->
2024-10-10 21:21:43 +03:00
Ofek
d2ee6e18a5 Replace the deprecated monaco.editor.ICodeEditor.deltaDecorations (#6078)
Replace the deprecated `monaco.editor.ICodeEditor.deltaDecorations` with `monaco.editor.IEditorDecorationsCollection`

Seems that today the official way of colouring monaco editors is having
them `createDecorationsCollection`, keep the resulting
decorations-collection and call `set` on it with new decorations
whenever needed.
There are many possible design choices on where to put it, I opted to
put `editorDecorations` in `MonacoPane`, and have
`MonacoPane.createEditor` initialize it only in panes where decorations
are actually used.
Also some signatures changed which had a broad (but non-interesting)
impact.
2024-02-04 18:12:53 +02:00
Jeremy Rifkin
72e6b34d55 Improve pane typing (#5191)
Resolves #4365
2023-06-21 21:40:35 -04:00
Jeremy Rifkin
c779507000 Create a print view (#5161)
This PR adds a print view for CE

Closes #4617


![image](https://github.com/compiler-explorer/compiler-explorer/assets/51220084/92e5ceab-10cc-4289-a742-592e379627ef)

At the moment syntax highlighting isn't working. I think we need a way
to get style definitions from monaco. I've opened an issue at
https://github.com/microsoft/monaco-editor/issues/4031. For the CFG
pane, using the monaco classes "just works", but for some reason when
@media print is applied those definitions go away. We'd want to always
use light mode colors anyway.
2023-06-19 22:13:45 -04:00
Mats Jun Larsen
633eb82d18 Transition to ECMAScript Modules (#4780)
Makes the Compiler Explorer app, and all the tooling ESM compatible.
Things that have been done:

1. The package.json has `type: module` now
2. All relative imports have a .js ending
3. All directory imports are now directory/index.js to comply with ESM
standards
4. Dependency node-graceful is now imported into tree, because the
package is broken under esm
5. Dependency p-queue has been bumped to 7.x with ESM support
6. Dependency profanities has been bumped to 3.x with ESM support
7. Webpack config is now both ESM and CommonJS compatible
8. Non-ESM compatible imports have been rewritten
9. ESLint configuration has been tweaked to not fail on .js imports
10. Mocha is now hacked together and ran with ts-node-esm
11. Webpack is now hacked together and ran with ts-node-esm
12. Webpack config is now ESM compatible, so that it can be used in the
dev server
13. Cypress code still runs commonjs, and has been excluded from the
tsconfig
14. All sinon mock tests have been commented out, because sinon module
mocks do not work with ESModules (because ESModules are immutable)

A lot of tests are now giving warnings/errors to stdout, yet still pass.
Docenizer codegenerator scripts have been updated, but I did not re-run
them, and instead just changed their code.

---------

Co-authored-by: Matt Godbolt <matt@godbolt.org>
2023-02-27 18:06:38 -06:00
Jeremy Rifkin
384c297906 Fix trailing comma issue (#4775)
Make trailing commas more consistent throughout the project, fixes
config conflict between eslint and prettier. Resolves an oversight in
#4766.
2023-02-26 12:21:35 -05:00
Matt Godbolt
fb47642ff7 Convert tool.js to typescript (based off #4166) (#4474)
Signed-off-by: Markus <28785953+MarkusJx@users.noreply.github.com>
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: MarkusJx <28785953+markusjx@users.noreply.github.com>
Co-authored-by: Rubén Rincón Blanco <ruben@rinconblanco.es>
Co-authored-by: partouf <partouf@gmail.com>
Co-authored-by: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com>
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
Co-authored-by: Paul Taylor <paul.e.taylor@me.com>
Co-authored-by: Mats Larsen <me@supergrecko.com>
Co-authored-by: David Spickett <DavidSpickett@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Compiler Explorer Bot <mattgodbolt@users.noreply.github.com>
Co-authored-by: Enrico Seiler <eseiler@users.noreply.github.com>
Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
Co-authored-by: James Murphy <72399781+mCodingLLC@users.noreply.github.com>
Co-authored-by: Miguel Ojeda <ojeda@users.noreply.github.com>
Co-authored-by: Ofek <ofekshilon@gmail.com>
Co-authored-by: J. Ryan Stinnett <jryans@gmail.com>
Co-authored-by: Sebastian Büttner <mail@bueddl.de>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Daniel Thornburgh <mysterymath@gmail.com>
Co-authored-by: Cory Bloor <Cordell.Bloor@amd.com>
Co-authored-by: marcosmartinezfco <marcosmartinezfco@gmail.com>
Co-authored-by: amyspark <amy@amyspark.me>
Co-authored-by: Robert Cohn <robert.s.cohn@intel.com>
Co-authored-by: Steve <hez2010@outlook.com>
Co-authored-by: Ofek <ofek@istraresearch.com>
Co-authored-by: kasperk81 <83082615+kasperk81@users.noreply.github.com>
Co-authored-by: Samuel Bronson <naesten@gmail.com>
Co-authored-by: Alfredo Correa <alfredo.correa+work@gmail.com>
Co-authored-by: Anastasia Stulova <38433336+AnastasiaStulova@users.noreply.github.com>
Co-authored-by: Michael Debertol <michael.debertol@gmail.com>
Co-authored-by: Madhur Chauhan <madhur4127@gmail.com>
Co-authored-by: Jessica Clarke <jrtc27@jrtc27.com>
Co-authored-by: Tobias Hieta <tobias@hieta.se>
2023-02-08 11:22:02 -05:00