weml-monaco 0.4.4 → 0.5.1
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 +37 -0
- package/README.md +15 -1
- package/dist/index.cjs +10 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.global.js +39 -39
- package/dist/index.mjs +10 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,43 @@ 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.5.1] — 2026-09-26
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Updated the shared V2 normalizer: lowercase tag names, keep the first
|
|
15
|
+
duplicate attribute value and unify inline sentence whitespace handling.
|
|
16
|
+
- Retained compatibility with node-html-parser 6.x and browser bundles.
|
|
17
|
+
|
|
18
|
+
## [0.5.0] — 2026-09-09
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- **Breaking:** the Monaco type surface is imported from
|
|
22
|
+
`monaco-editor/editor/editor.api.js` instead of the `monaco-editor` root.
|
|
23
|
+
The root re-exports the TypeScript, CSS, JSON and HTML language
|
|
24
|
+
contributions, so its type forced every consumer to import Monaco whole and
|
|
25
|
+
ship all four language workers — around 11 MB of bundle nobody used. The
|
|
26
|
+
editor core carries everything this package actually touches. Passing the
|
|
27
|
+
full `monaco-editor` namespace still type-checks, since it is a superset.
|
|
28
|
+
- **Breaking:** `peerDependencies.monaco-editor` raised from `>=0.34.0` to
|
|
29
|
+
`>=0.56.0`. The subpath resolves through the `exports` map introduced in
|
|
30
|
+
0.56 (`"./*": "./esm/vs/*.js"`) and needs `moduleResolution` `node16` or
|
|
31
|
+
`bundler`; on 0.55 and older the equivalent path was
|
|
32
|
+
`monaco-editor/esm/vs/editor/editor.api`.
|
|
33
|
+
- Development and the CDN demo build against monaco-editor 0.56.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
- The bundles no longer register themselves with an AMD loader. `he` (via
|
|
37
|
+
node-html-parser) ends in a UMD footer whose `define()` call is anonymous, so
|
|
38
|
+
loading `dist/index.global.js` from a `<script>` tag on a page that also runs
|
|
39
|
+
Monaco's AMD loader made the loader attribute that module to whatever it was
|
|
40
|
+
resolving, warning `Duplicate definition of module 'vs/editor/editor.main'`.
|
|
41
|
+
The build now folds `define.amd` to `false`, dropping the branch.
|
|
42
|
+
|
|
43
|
+
The type-path change itself does not touch the runtime output: every Monaco
|
|
44
|
+
import in `src/` is an `import type`, and only the first line of the emitted
|
|
45
|
+
declarations changes. `dist/index.mjs`, `index.cjs` and `index.global.js`
|
|
46
|
+
differ solely by the removed AMD footer above.
|
|
47
|
+
|
|
11
48
|
## [0.4.4] — 2026-09-07
|
|
12
49
|
|
|
13
50
|
Synced with VS Code extension `0.7.12`.
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ Monaco is **passed in** at registration time, so this works no matter how
|
|
|
58
58
|
Monaco itself is loaded (AMD/CDN, ESM bundle, or a global):
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
import * as monaco from 'monaco-editor';
|
|
61
|
+
import * as monaco from 'monaco-editor/editor/editor.api.js';
|
|
62
62
|
import { registerWeml } from 'weml-monaco';
|
|
63
63
|
|
|
64
64
|
const disposable = registerWeml(monaco);
|
|
@@ -69,6 +69,20 @@ monaco.editor.create(document.getElementById('container'), { model });
|
|
|
69
69
|
// disposable.dispose(); // tears down every provider + diagnostics listener
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
The import path is the editor core rather than the `monaco-editor` root on
|
|
73
|
+
purpose. The root re-exports the TypeScript, CSS, JSON and HTML language
|
|
74
|
+
contributions, so importing it pulls all four — and their workers — into the
|
|
75
|
+
application bundle. `weml-monaco` never touches them: it only needs
|
|
76
|
+
`editor`, `languages`, `Position`, `MarkerSeverity` and a handful of
|
|
77
|
+
interfaces, all of which live in `editor/editor.api.js`. Passing the full
|
|
78
|
+
`monaco-editor` namespace still type-checks (it is a superset), so this is a
|
|
79
|
+
choice the consumer makes, not a restriction.
|
|
80
|
+
|
|
81
|
+
The subpath resolves through the package's `exports` map, which requires
|
|
82
|
+
**monaco-editor 0.56 or newer** and `moduleResolution` `node16`/`bundler`.
|
|
83
|
+
On 0.55 and older the equivalent path was
|
|
84
|
+
`monaco-editor/esm/vs/editor/editor.api`.
|
|
85
|
+
|
|
72
86
|
`registerWeml(monaco, options?)` accepts:
|
|
73
87
|
|
|
74
88
|
| option | default | meaning |
|
package/dist/index.cjs
CHANGED
|
@@ -267,7 +267,7 @@ var require_he = __commonJS({
|
|
|
267
267
|
"escape": escape,
|
|
268
268
|
"unescape": decode
|
|
269
269
|
};
|
|
270
|
-
if (typeof define == "function" &&
|
|
270
|
+
if (typeof define == "function" && false) {
|
|
271
271
|
define(function() {
|
|
272
272
|
return he;
|
|
273
273
|
});
|
|
@@ -6306,7 +6306,7 @@ var require_wemlContentNormalizeV2 = __commonJS({
|
|
|
6306
6306
|
}
|
|
6307
6307
|
result.push(`<${name.toLowerCase()}${attrs} />`);
|
|
6308
6308
|
} else {
|
|
6309
|
-
result.push(
|
|
6309
|
+
result.push(closing ? "</" : "<", name.toLowerCase(), attrs, ">");
|
|
6310
6310
|
}
|
|
6311
6311
|
index = end + 1;
|
|
6312
6312
|
}
|
|
@@ -6356,62 +6356,14 @@ var require_wemlContentNormalizeV2 = __commonJS({
|
|
|
6356
6356
|
}
|
|
6357
6357
|
}
|
|
6358
6358
|
function processInlineContainer(node) {
|
|
6359
|
-
|
|
6360
|
-
else processInlineContent(node, true);
|
|
6361
|
-
}
|
|
6362
|
-
function processSentContainer(node, trimEdges) {
|
|
6363
|
-
for (const child of [...node.childNodes]) {
|
|
6364
|
-
if (child.nodeType !== 1) continue;
|
|
6365
|
-
const name = child.rawTagName.toLowerCase();
|
|
6366
|
-
if (isInlineTextElement(child)) {
|
|
6367
|
-
if (hasDirectSentChildren(child)) processSentContainer(child, false);
|
|
6368
|
-
else processInlineContent(child, false);
|
|
6369
|
-
} else if (BLOCK_ELEMENTS.has(name)) {
|
|
6370
|
-
processBlockElement(child);
|
|
6371
|
-
} else if (INLINE_CONTAINERS.has(name)) {
|
|
6372
|
-
processInlineContainer(child);
|
|
6373
|
-
}
|
|
6374
|
-
}
|
|
6375
|
-
for (const child of [...node.childNodes]) {
|
|
6376
|
-
if (child.nodeType === 1 && isInlineTextElement(child)) {
|
|
6377
|
-
bleedEdgeSpaces(child);
|
|
6378
|
-
}
|
|
6379
|
-
}
|
|
6380
|
-
for (const child of [...node.childNodes]) {
|
|
6381
|
-
if (child.nodeType === 3) child.rawText = collapseWhitespace(child.rawText);
|
|
6382
|
-
}
|
|
6383
|
-
for (const child of [...node.childNodes]) {
|
|
6384
|
-
if (child.nodeType === 1 && child.rawTagName.toLowerCase() === "br") {
|
|
6385
|
-
const prev = child.previousSibling;
|
|
6386
|
-
if (prev && prev.nodeType === 3) prev.rawText = trimEndWhitespace(prev.rawText);
|
|
6387
|
-
const next = child.nextSibling;
|
|
6388
|
-
if (next && next.nodeType === 3) next.rawText = trimStartWhitespace(next.rawText);
|
|
6389
|
-
}
|
|
6390
|
-
}
|
|
6391
|
-
if (trimEdges) trimContainerEdges(node);
|
|
6392
|
-
for (const child of [...node.childNodes]) {
|
|
6393
|
-
if (child.nodeType === 3 && child.rawText === "") child.remove();
|
|
6394
|
-
}
|
|
6395
|
-
}
|
|
6396
|
-
function trimContainerEdges(node) {
|
|
6397
|
-
const children = [...node.childNodes];
|
|
6398
|
-
if (children.length === 0) return;
|
|
6399
|
-
const first = children[0];
|
|
6400
|
-
const last = children[children.length - 1];
|
|
6401
|
-
if (children.length === 1) {
|
|
6402
|
-
if (first.nodeType === 3) first.rawText = trimWhitespace(first.rawText);
|
|
6403
|
-
} else {
|
|
6404
|
-
if (first.nodeType === 3) first.rawText = trimStartWhitespace(first.rawText);
|
|
6405
|
-
if (last.nodeType === 3) last.rawText = trimEndWhitespace(last.rawText);
|
|
6406
|
-
}
|
|
6359
|
+
processInlineContent(node, true);
|
|
6407
6360
|
}
|
|
6408
6361
|
function processInlineContent(node, trimEdges) {
|
|
6409
6362
|
for (const child of [...node.childNodes]) {
|
|
6410
6363
|
if (child.nodeType !== 1) continue;
|
|
6411
6364
|
const name = child.rawTagName.toLowerCase();
|
|
6412
6365
|
if (isInlineTextElement(child)) {
|
|
6413
|
-
|
|
6414
|
-
else processInlineContent(child, false);
|
|
6366
|
+
processInlineContent(child, false);
|
|
6415
6367
|
} else if (BLOCK_ELEMENTS.has(name)) {
|
|
6416
6368
|
processBlockElement(child);
|
|
6417
6369
|
} else if (INLINE_CONTAINERS.has(name)) {
|
|
@@ -6521,11 +6473,6 @@ var require_wemlContentNormalizeV2 = __commonJS({
|
|
|
6521
6473
|
if (last.nodeType === 3) last.rawText = trimEndWhitespace(last.rawText);
|
|
6522
6474
|
}
|
|
6523
6475
|
}
|
|
6524
|
-
function hasDirectSentChildren(node) {
|
|
6525
|
-
return [...node.childNodes].some(
|
|
6526
|
-
(child) => child.nodeType === 1 && child.rawTagName.toLowerCase() === "w-sent"
|
|
6527
|
-
);
|
|
6528
|
-
}
|
|
6529
6476
|
function isInlineTextElement(node) {
|
|
6530
6477
|
if (node.nodeType !== 1) return false;
|
|
6531
6478
|
const name = node.rawTagName.toLowerCase();
|
|
@@ -6599,10 +6546,12 @@ var require_wemlContentNormalizeV2 = __commonJS({
|
|
|
6599
6546
|
value = rawAttrs.slice(valueStart, index);
|
|
6600
6547
|
}
|
|
6601
6548
|
}
|
|
6602
|
-
canonical.
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6549
|
+
if (!canonical.has(name)) {
|
|
6550
|
+
canonical.set(
|
|
6551
|
+
name,
|
|
6552
|
+
SPACE_SEPARATED_ATTRIBUTES.has(name) ? normalizeTokenList(value, entities2, marker) : trimWhitespace(value)
|
|
6553
|
+
);
|
|
6554
|
+
}
|
|
6606
6555
|
}
|
|
6607
6556
|
return [...canonical.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([name, value]) => ` ${name}="${encodeAttr(String(value))}"`).join("");
|
|
6608
6557
|
}
|