- 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!)
## Summary
Fixes COMPILER-EXPLORER-3W3: Prevents "Can't remove child item. Unknown
content item" errors (4830 occurrences) when attempting to close
containers that have already been destroyed or removed from the layout
hierarchy.
- Uses modern TypeScript optional chaining to check container validity
before close operations
- Prevents race conditions between compiler close events and
GoldenLayout's destruction process
- Addresses issue where deferred `container.close()` calls were
executing on already-destroyed containers
## Root Cause
The error occurred when:
1. A compiler close event triggers `onCompilerClose()` which defers
`container.close()`
2. Meanwhile, GoldenLayout destroys the container through its own
process
3. The deferred close attempt executes on an already-destroyed
container, causing the GoldenLayout error
## Test plan
- [ ] Open multiple compiler panes with associated tool/output panes
- [ ] Quickly close compilers while panes are still loading/updating
- [ ] Verify no "Can't remove child item" errors appear in console
- [ ] Verify panes still close properly in normal scenarios
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- 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!
-->
When each `Pane` (and others) create their own `PaneRenaming`, which
extends `EventEmitter.EventEmitter`, when one actor emits `renamePane`
no other actor can hear it.
This PR makes `PaneRenaming` stop using its own event emission, and
instead use the central `Hub` it now receives at its ctor.
Make MonacoPane calls `createDecorationsCollection` in a single place
instead of forcing many subclasses to remember to call
`initDecorations`. Some subclasses never use DecorationsCollection and
call init for no reason now, but it still seems healthier - this avoids
the possibility of a MonacoPane subclass trying to use an uninitialized
decoration collection.
Also remove the depracated `deltaDecorations` from stack-usage-view.
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.
This PR refactors some common utilities out of lib/ and into shared/ and
eliminates some use of underscore.js, as well as general type
improvements done along the way.
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>
* Fix Editor not being able to load full links
* Better type for this.filename in compiler.ts
* Updates editor.ts and improves compilation types
* Fix some of the type issues, lots still remain
* fixes to language selection & refactoring of hub and some inits
* fix flow of events
* Fix llvm opt handling (cc @jeremy-rifkin)
Co-authored-by: partouf <partouf@gmail.com>
Co-authored-by: Matt Godbolt <matt@godbolt.org>
* Two quick code cleanups while I'm here
* Added default font size user setting
* Better addSelector solution
* Fix and clarification, thanks Ruben
* Updated typing
* Added font scale broadcast
* Extract a Pane base separate from a MonacoPane.
* Make it clearer that editor and tree id are truthy-ish non-zero numbers, or else not present. Thanks @partouf; CC @jeremy-rifkin
Paves the way to move the (few) tools that don't have an editor to also share the base class.
* Group some files to their own folders
In etc/scripts/, added disasms/, docenizers/, and util/ folders
In lib/, added mapfiles/, and parsers/ folders (+moved google.js to
shortener)
In static/, added widgets/ folder
Added cypress folder to .gitignore
* Address Matt's PR reviews
* Move new Pane renaming to folder
* Renaming works for compiler with local storage saving
* Remove closed panes from local storage
* Feature working for almost every pane
* Working except for editor and tool-input-view
* Save pane name into its state instead of local storage
* Remove unnecessary local storage code
* Apply Ruben's suggestions
* Check for CMakeLists.txt always on default name
* Change pane renaming's modal placeholder's text, code cleanup
This is a refactor for core methods of the Pane API. In this patch:
1. Rename initializeDOMRoot to getInitialHTML() - This logic is common for all of the panes. Returning the HTML is more type-safe and makes the method pure.
2. Make createEditor return the monaco editor - Allows us to set the editor in the constructor. Returning the editor is more type-safe and makes the method pure.
3. Rename id parameters to compilerId in onCompileResult, onCompiler and onCompilerClose - It's not easy to tell what these ids were, this makes it easier to understand what we're using here.
4. Type compiler, options and result as unkown in onCompiler, onCompileResult - These parameters don't have types at the moment, so it's safer for implementors to manually override and type as any/whichever type they wish.
5. Add plenty of code documentation to onCompiler and onCompileResult
Decouples the individual initial pane states for each pane from the BasePaneState type.
This will allow easier re-use of the state the various constructors receive
Non-functional change.
* Implement generic pane skeleton
* Implement abstract Pane class
* Port RustMirView to typescript
* Fix nits in code
* Adjust method names and add override modifiers
* Add remaining settings keys (and fix a bug)
* Use this-binding in registerStandardCallbacks
* Address review comments
* Use utils.updateAndCalcTopBarHeight in base pane
* Add notice about adding an entry in interfaces.ts
* Use .bind instead of context parameter
GoldenLayout has moved away from the context parameter, so .bind is a safer for the future
* [200~Check for editor presence + fix typo~
* Remove trailing comma
Co-authored-by: Patrick Quist <partouf@gmail.com>