Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript worker extension to Monaco Editor for custom diagnostics #289

Closed
camargo opened this issue Dec 5, 2022 · 2 comments · Fixed by #625
Closed

Add TypeScript worker extension to Monaco Editor for custom diagnostics #289

camargo opened this issue Dec 5, 2022 · 2 comments · Fixed by #625
Assignees
Labels
clipper Requests from the Europa Clipper project feature New feature or request sequencing Anything related to the sequencing domain

Comments

@camargo
Copy link
Member

camargo commented Dec 5, 2022

Currently expansion rule authoring does not validate numeric ranges for commands because TypeScript type definitions do not support numeric range validation, or regex validation.

This issue is to add support for custom diagnostics (e.g. numeric range validation, regex string validation, etc.) via a custom TypeScript worker in Monaco. We previously attempted to solve this by forking the main TypeScript worker, and adding custom diagnostics. But this solution turned out to be too brittle. It is not easy to use the forked TypeScript worker in the client in an isolated manner. All TypeScript editors needed to use it which is overkill. Also we had worries of keeping the fork up to date with the latest TypeScript worker.

We later found there is a way to create a local custom worker. But there is a PR for a bug that needs to be merged.

We need to:

  • See about getting the PR merged
    • Are we still even blocked by this PR?
  • Add a custom inline worker with custom diagnostics to the UI for the command expansion editor
@camargo camargo added the feature New feature or request label Dec 5, 2022
@camargo camargo added this to Aerie Dec 5, 2022
@camargo camargo moved this to Todo in Aerie Dec 5, 2022
@camargo camargo changed the title Add custom TypeScript worker to Monaco Editor for custom diagnostics Add TypeScript worker extension to Monaco Editor for custom diagnostics Dec 5, 2022
@camargo camargo added the sequencing Anything related to the sequencing domain label Jan 6, 2023
@cohansen
Copy link
Contributor

Did some experimenting but this is still not working properly, loading the custom worker throws errors that I can't resolve until that PR is merged.

Uncaught (in promise) TypeError: Failed to execute 'importScripts' on 'WorkerGlobalScope': Module scripts don't support importScripts().
    at create (ts.worker.js?type=module&worker_file:161653:7)
    at EditorSimpleWorker._foreignModuleFactory (ts.worker.js?type=module&worker_file:161668:12)
    at EditorSimpleWorker.loadForeignModule (editorSimpleWorker.js?v=eebc8560:448:40)
    at SimpleWorkerServer._handleMessage (simpleWorker.js?v=eebc8560:357:65)
    at Object.handleMessage (simpleWorker.js?v=eebc8560:342:51)
    at SimpleWorkerProtocol._handleRequestMessage (simpleWorker.js?v=eebc8560:149:38)
    at SimpleWorkerProtocol._handleMessage (simpleWorker.js?v=eebc8560:118:29)
    at SimpleWorkerProtocol.handleMessage (simpleWorker.js?v=eebc8560:111:14)
    at SimpleWorkerServer.onmessage (simpleWorker.js?v=eebc8560:347:24)
    at self.onmessage (editor.worker.js?v=eebc8560:17:22)

@camargo camargo removed this from the 1.1.0 - UI Ad Hoc Improvements milestone Feb 3, 2023
@bashbash bashbash added the clipper Requests from the Europa Clipper project label Mar 21, 2023
@Cobular
Copy link
Contributor

Cobular commented May 8, 2023

Wooo!!! The core of this now works. It turns out, that PR is not relevant due to minutia with how the monaco build process works, and the above error was caused by a bad but intentional behavior of Vite in development mode. This has been fixed by directly using Esbuild to build our worker scripts and later loading them in! PR incoming.

@camargo camargo assigned Cobular and unassigned cohansen May 8, 2023
@camargo camargo moved this from Todo to In Review in Aerie May 8, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Aerie May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clipper Requests from the Europa Clipper project feature New feature or request sequencing Anything related to the sequencing domain
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants