weml-monaco 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +42 -0
- package/dist/weml.worker.d.mts +2 -0
- package/dist/weml.worker.mjs +24948 -0
- package/dist/weml.worker.mjs.map +1 -0
- package/dist/worker.cjs +8604 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.mts +21 -0
- package/dist/worker.d.ts +21 -0
- package/dist/worker.mjs +8605 -0
- package/dist/worker.mjs.map +1 -0
- package/package.json +17 -3
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,16 @@ This package mirrors the language logic of the VS Code extension; entries below
|
|
|
8
8
|
track the port catching up with the VS Code provider changes (see the root
|
|
9
9
|
`CHANGELOG.md` for the extension).
|
|
10
10
|
|
|
11
|
+
## [0.6.0] — 2026-10-06
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- `registerWemlWorker` (`weml-monaco/worker`) and the worker module
|
|
15
|
+
(`weml-monaco/weml.worker`): the same language with completion, hover, outline
|
|
16
|
+
and diagnostics computed in a Web Worker, so typing in a large document no
|
|
17
|
+
longer waits for a full parse per keystroke. The worker mirrors models from
|
|
18
|
+
their edits and answers only the current version of a model. `registerWeml`
|
|
19
|
+
and the global build are unchanged.
|
|
20
|
+
|
|
11
21
|
## [0.5.2] — 2026-09-26
|
|
12
22
|
|
|
13
23
|
### Added
|
package/README.md
CHANGED
|
@@ -99,6 +99,48 @@ formatter directly, call `formatWemlText(source)`.
|
|
|
99
99
|
Structural validation failures are also available through
|
|
100
100
|
`isWemlStructureValidationFailure(error)` and include a code, line and column.
|
|
101
101
|
|
|
102
|
+
## Analysis in a Web Worker
|
|
103
|
+
|
|
104
|
+
`registerWeml` runs completion, hover, outline and diagnostics on the main
|
|
105
|
+
thread, and each of them parses the whole document for every new model version.
|
|
106
|
+
On a large file — a whole book, a megabyte and more — that is tens of
|
|
107
|
+
milliseconds per keystroke on the thread that handles the keystrokes, and typing
|
|
108
|
+
falls behind. `registerWemlWorker` registers the same language with that work in
|
|
109
|
+
a Web Worker:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import * as monaco from 'monaco-editor/editor/editor.api.js';
|
|
113
|
+
import { registerWemlWorker } from 'weml-monaco/worker';
|
|
114
|
+
import WemlWorker from 'weml-monaco/weml.worker?worker'; // Vite
|
|
115
|
+
|
|
116
|
+
const disposable = registerWemlWorker(monaco, { worker: () => new WemlWorker() });
|
|
117
|
+
// Without Vite's `?worker`:
|
|
118
|
+
// registerWemlWorker(monaco, {
|
|
119
|
+
// worker: () => new Worker(new URL('weml-monaco/weml.worker', import.meta.url), { type: 'module' }),
|
|
120
|
+
// });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
It is an addition, not a replacement: `registerWeml` is unchanged, and an
|
|
124
|
+
application chooses one of the two (registering both doubles every provider).
|
|
125
|
+
The worker runs the very providers `registerWeml` registers, so suggestions,
|
|
126
|
+
hovers, outline and markers are the same; only where they are computed changes.
|
|
127
|
+
|
|
128
|
+
- The worker mirrors each `weml` model's text and keeps it current from the
|
|
129
|
+
edits Monaco reports — the main thread never sends the whole text again.
|
|
130
|
+
- A request is answered only for the model's current version: one overtaken by
|
|
131
|
+
further typing is answered empty without parsing, so holding a key down does
|
|
132
|
+
not build up a queue of parses.
|
|
133
|
+
- Markers computed for a version the model has since left are dropped.
|
|
134
|
+
- The tokenizer, language configuration and formatting stay on the main thread,
|
|
135
|
+
as with `registerWeml` — they are cheap or run on demand.
|
|
136
|
+
- `weml-monaco/weml.worker` imports nothing of Monaco at runtime; it needs a
|
|
137
|
+
bundler (or a module worker) to load, and is ESM only.
|
|
138
|
+
|
|
139
|
+
`registerWemlWorker(monaco, options)` takes the options of `registerWeml` plus
|
|
140
|
+
`worker`, a function that starts the worker (called once; the worker is
|
|
141
|
+
terminated on `dispose()`). The global `<script>` build (`index.global.js`) has
|
|
142
|
+
no worker variant.
|
|
143
|
+
|
|
102
144
|
## Toolbar & editor commands
|
|
103
145
|
|
|
104
146
|
Monaco has no webview panels, so the VS Code toolbar is ported as a **DOM top
|