svelte-highlight 7.23.2 → 7.25.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.
Files changed (157) hide show
  1. package/AnsiOutput.svelte +33 -6
  2. package/AnsiOutput.svelte.d.ts +8 -0
  3. package/CodeToolbar.svelte +144 -0
  4. package/CodeToolbar.svelte.d.ts +125 -0
  5. package/CodeWindow.svelte +19 -0
  6. package/CodeWindow.svelte.d.ts +10 -0
  7. package/CopyButton.svelte +107 -3
  8. package/CopyButton.svelte.d.ts +17 -1
  9. package/DiffFileList.svelte +523 -0
  10. package/DiffFileList.svelte.d.ts +94 -0
  11. package/DiffFileListItem.svelte +44 -0
  12. package/DiffMinimap.svelte +99 -0
  13. package/DiffMinimap.svelte.d.ts +17 -0
  14. package/DiffStats.svelte +43 -0
  15. package/DiffStats.svelte.d.ts +17 -0
  16. package/DiffView.svelte +1213 -0
  17. package/DiffView.svelte.d.ts +76 -0
  18. package/FileTabs.svelte +2 -5
  19. package/Highlight.svelte +158 -2
  20. package/Highlight.svelte.d.ts +50 -2
  21. package/HighlightAuto.svelte.d.ts +3 -2
  22. package/HighlightAutoLazy.svelte +112 -0
  23. package/HighlightAutoLazy.svelte.d.ts +66 -0
  24. package/HighlightDiff.svelte +162 -0
  25. package/HighlightDiff.svelte.d.ts +102 -0
  26. package/HighlightEditable.svelte +65 -756
  27. package/HighlightEditable.svelte.d.ts +15 -5
  28. package/HighlightStream.svelte +117 -218
  29. package/HighlightStream.svelte.d.ts +8 -0
  30. package/HighlightSvelte.svelte.d.ts +3 -2
  31. package/HighlightVirtual.svelte +41 -8
  32. package/HighlightVirtual.svelte.d.ts +8 -0
  33. package/LangTag.svelte +33 -4
  34. package/LangTag.svelte.d.ts +6 -2
  35. package/LineNumbers.svelte +25 -4
  36. package/LineNumbers.svelte.d.ts +8 -0
  37. package/MarkdownStream.svelte +1 -0
  38. package/README.md +735 -18
  39. package/ToolbarButton.svelte +90 -0
  40. package/ToolbarButton.svelte.d.ts +106 -0
  41. package/Typewriter.svelte +59 -10
  42. package/Typewriter.svelte.d.ts +7 -0
  43. package/WrapToggle.svelte +34 -0
  44. package/WrapToggle.svelte.d.ts +39 -0
  45. package/action.js +7 -3
  46. package/ansi.d.ts +1 -3
  47. package/auto-detect.d.ts +52 -0
  48. package/auto-detect.js +208 -0
  49. package/code-region.d.ts +7 -0
  50. package/code-region.js +20 -0
  51. package/css-highlights.js +115 -0
  52. package/css-walk.js +50 -0
  53. package/diff-controller.d.ts +120 -0
  54. package/diff-controller.js +721 -0
  55. package/diff-edits.d.ts +101 -0
  56. package/diff-edits.js +890 -0
  57. package/diff-html.d.ts +8 -0
  58. package/diff-html.js +60 -0
  59. package/diff-languages.d.ts +4 -0
  60. package/diff-languages.js +73 -0
  61. package/diff.d.ts +161 -0
  62. package/diff.js +1111 -0
  63. package/editable-commands.js +81 -0
  64. package/editable-css-paint.js +5 -3
  65. package/editable-dom-paint.js +1 -1
  66. package/editable-history.js +199 -0
  67. package/editable-line-dom.js +176 -1
  68. package/editable-painter.js +356 -0
  69. package/editable.d.ts +118 -0
  70. package/editable.js +513 -0
  71. package/engine.d.ts +1 -1
  72. package/fence.js +1 -1
  73. package/highlight-cascade.js +679 -0
  74. package/highlight-theme.js +6 -47
  75. package/incremental-tokenize.js +1 -1
  76. package/index.d.ts +39 -6
  77. package/index.js +30 -0
  78. package/languages/abap.d.ts +2 -0
  79. package/languages/abap.js +2 -0
  80. package/languages/aliases.js +1 -1
  81. package/languages/all.js +18 -1
  82. package/languages/angular.js +1 -1
  83. package/languages/antlr.d.ts +2 -0
  84. package/languages/antlr.js +2 -0
  85. package/languages/apex.d.ts +2 -0
  86. package/languages/apex.js +2 -0
  87. package/languages/bash.js +1 -1
  88. package/languages/cobol.d.ts +2 -0
  89. package/languages/cobol.js +2 -0
  90. package/languages/coq.js +1 -1
  91. package/languages/cpp.js +1 -1
  92. package/languages/csharp.js +1 -1
  93. package/languages/css.js +1 -1
  94. package/languages/cython.d.ts +2 -0
  95. package/languages/cython.js +2 -0
  96. package/languages/dart.js +1 -1
  97. package/languages/detect-index.d.ts +16 -0
  98. package/languages/detect-index.js +6 -0
  99. package/languages/fluent.d.ts +2 -0
  100. package/languages/fluent.js +2 -0
  101. package/languages/freemarker.d.ts +2 -0
  102. package/languages/freemarker.js +3 -0
  103. package/languages/handlebars.js +1 -1
  104. package/languages/httpfile.d.ts +2 -0
  105. package/languages/httpfile.js +3 -0
  106. package/languages/index.d.ts +34 -0
  107. package/languages/index.js +17 -0
  108. package/languages/jinja.js +1 -1
  109. package/languages/json.js +1 -1
  110. package/languages/kotlin.js +1 -1
  111. package/languages/lex.d.ts +2 -0
  112. package/languages/lex.js +3 -0
  113. package/languages/lisp.js +1 -1
  114. package/languages/loaders.d.ts +8 -0
  115. package/languages/loaders.js +387 -0
  116. package/languages/mathematica.js +1 -1
  117. package/languages/meson.d.ts +2 -0
  118. package/languages/meson.js +2 -0
  119. package/languages/metal.d.ts +2 -0
  120. package/languages/metal.js +2 -0
  121. package/languages/mlir.d.ts +2 -0
  122. package/languages/mlir.js +2 -0
  123. package/languages/mojo.js +1 -1
  124. package/languages/nextflow.js +1 -1
  125. package/languages/objectivec.js +1 -1
  126. package/languages/pgsql.js +1 -1
  127. package/languages/php.js +1 -1
  128. package/languages/po.d.ts +2 -0
  129. package/languages/po.js +2 -0
  130. package/languages/riscv.d.ts +2 -0
  131. package/languages/riscv.js +2 -0
  132. package/languages/robotframework.d.ts +2 -0
  133. package/languages/robotframework.js +2 -0
  134. package/languages/roc.js +1 -1
  135. package/languages/solidity.js +1 -1
  136. package/languages/sshconfig.d.ts +2 -0
  137. package/languages/sshconfig.js +2 -0
  138. package/languages/svelte.js +1 -1
  139. package/languages/uiua.js +1 -1
  140. package/languages/verilog.js +1 -1
  141. package/languages/vim.js +1 -1
  142. package/languages/yacc.d.ts +2 -0
  143. package/languages/yacc.js +3 -0
  144. package/languages/zig.js +1 -1
  145. package/package.json +50 -2
  146. package/preprocessor.js +20 -5
  147. package/search.js +2 -2
  148. package/stream-highlighter.js +198 -0
  149. package/stream.css +16 -0
  150. package/stream.d.ts +60 -0
  151. package/stream.js +283 -0
  152. package/style-registry.js +34 -3
  153. package/themes/_base-css.d.ts +1 -0
  154. package/themes/_base-css.js +1 -0
  155. package/typewriter-units.d.ts +3 -0
  156. package/typewriter-units.js +43 -0
  157. package/virtual-window.js +9 -4
package/editable.js ADDED
@@ -0,0 +1,513 @@
1
+ /**
2
+ * A highlighted code editor on any element, with no framework. This is the
3
+ * logic behind HighlightEditable: input handling, undo history, painting and
4
+ * caret restore. The element should be a `<code>` with `contenteditable`,
5
+ * inside a `<pre>` (or anything with `white-space: pre`).
6
+ */
7
+
8
+ import { resolveEngine } from "./css-highlights.js";
9
+ import {
10
+ indentSelection,
11
+ replaceSelection,
12
+ shiftLines,
13
+ } from "./editable-commands.js";
14
+ import { createEditHistory } from "./editable-history.js";
15
+ import {
16
+ createLineView,
17
+ lineStartOffset,
18
+ readSelection,
19
+ writeSelection,
20
+ } from "./editable-line-dom.js";
21
+ import { createEditorPainter } from "./editable-painter.js";
22
+ import { ensureRegistered, registry } from "./registry.js";
23
+
24
+ export { instanceHighlightStyle } from "./highlight-theme.js";
25
+
26
+ const TRAILING_NEWLINE = /\n$/;
27
+
28
+ let instanceCount = 0;
29
+
30
+ /**
31
+ * @typedef {{
32
+ * language: import("./languages").LanguageType<string>,
33
+ * tabSize: number,
34
+ * historyLimit: number,
35
+ * readonly: boolean,
36
+ * engine: import("./css-highlights.js").PaintEngine,
37
+ * theme: string | import("./theme.d.ts").ThemePalette | undefined,
38
+ * }} EditorSettings
39
+ */
40
+
41
+ /**
42
+ * @typedef {Partial<EditorSettings> & {
43
+ * language: import("./languages").LanguageType<string>,
44
+ * code?: string,
45
+ * instanceId?: string | number,
46
+ * onChange?: (code: string) => void,
47
+ * onHistory?: (snapshot: import("./editable-history.js").HistorySnapshot) => void,
48
+ * onBlur?: (code: string) => void,
49
+ * }} EditorOptions
50
+ */
51
+
52
+ /**
53
+ * @param {HTMLElement} element
54
+ * @param {EditorOptions} options
55
+ */
56
+ export function createEditor(element, options) {
57
+ const doc = /** @type {Document} */ (element.ownerDocument);
58
+ const instanceId = options.instanceId ?? `editor-${++instanceCount}`;
59
+ const { onChange, onHistory, onBlur } = options;
60
+ /** @type {EditorSettings} */
61
+ const settings = {
62
+ language: options.language,
63
+ tabSize: options.tabSize ?? 2,
64
+ historyLimit: options.historyLimit ?? 200,
65
+ readonly: options.readonly ?? false,
66
+ engine: options.engine ?? "dom",
67
+ theme: options.theme,
68
+ };
69
+
70
+ let code = options.code ?? "";
71
+ let languageName = settings.language.name;
72
+ let engine = resolveEngine(settings.engine);
73
+ ensureRegistered(settings.language);
74
+
75
+ // Don't re-highlight during IME composition.
76
+ let composing = false;
77
+ let restoringSelection = false;
78
+ // Set by Escape so the next Tab moves focus instead of indenting.
79
+ let tabTrapReleased = false;
80
+ // WebKit fires historyUndo/historyRedo twice per execCommand; ignore the
81
+ // repeat until the next task.
82
+ let handlingNativeHistory = false;
83
+
84
+ const view = createLineView();
85
+ const painter = createEditorPainter({
86
+ editor: () => element,
87
+ view,
88
+ registry,
89
+ highlightPrefix: `hljs-${instanceId}`,
90
+ // The first themed "css-highlights" paint drew "dom" spans while the
91
+ // resolver loaded. Redraw with the latest settings.
92
+ onCascadeLoad: () => {
93
+ if (engine === "css-highlights") repaintForLanguageChange();
94
+ },
95
+ });
96
+ painter.setTheme(settings.theme);
97
+ const history = createEditHistory({ limit: () => settings.historyLimit });
98
+
99
+ function getSelectionRange() {
100
+ return readSelection(element, view, doc.getSelection());
101
+ }
102
+
103
+ function getCaretOffset() {
104
+ const sel = getSelectionRange();
105
+ return sel ? sel.end : null;
106
+ }
107
+
108
+ /**
109
+ * @param {number} start
110
+ * @param {number | null} [end]
111
+ * @param {Node} [root]
112
+ */
113
+ function setSelection(start, end, root = element) {
114
+ writeSelection(element, view, doc.getSelection(), start, end, root);
115
+ }
116
+
117
+ function paint() {
118
+ return painter.paint(code, languageName, engine);
119
+ }
120
+
121
+ /**
122
+ * Paints, then puts the caret back. When only one line changed, the
123
+ * selection is set inside that line so the rest of the DOM isn't walked.
124
+ * @param {number | null} [start]
125
+ * @param {number | null} [end]
126
+ */
127
+ function renderAt(start, end) {
128
+ const changedIndex = paint();
129
+ if (start == null) return;
130
+ restoringSelection = true;
131
+ if (changedIndex != null) {
132
+ const lineStart = lineStartOffset(view, changedIndex);
133
+ const lineEnd =
134
+ lineStart + /** @type {number} */ (view.lineLengths[changedIndex]);
135
+ /** @param {number | null | undefined} offset */
136
+ const inLine = (offset) =>
137
+ offset == null || (offset >= lineStart && offset <= lineEnd);
138
+ if (start >= lineStart && start <= lineEnd && inLine(end)) {
139
+ setSelection(
140
+ start - lineStart,
141
+ end == null ? end : end - lineStart,
142
+ view.lineEls[changedIndex],
143
+ );
144
+ restoringSelection = false;
145
+ return;
146
+ }
147
+ }
148
+ setSelection(start, end);
149
+ restoringSelection = false;
150
+ }
151
+
152
+ function repaintForLanguageChange() {
153
+ painter.reset();
154
+ const caret = doc.activeElement === element ? getCaretOffset() : null;
155
+ if (caret == null) paint();
156
+ else renderAt(caret, caret);
157
+ }
158
+
159
+ function syncCaretToHistory() {
160
+ if (!element.contains(doc.activeElement)) return;
161
+ if (restoringSelection || composing || history.isEmpty) return;
162
+ const sel = getSelectionRange();
163
+ if (sel) history.moveCaret(code.length, sel);
164
+ }
165
+
166
+ function emitHistory() {
167
+ onHistory?.(history.snapshot());
168
+ }
169
+
170
+ /**
171
+ * @param {string} previousCode
172
+ * @param {import("./editable-history.js").SelectionRange} selectionAfter
173
+ * @param {boolean} coalesce
174
+ */
175
+ function pushHistory(previousCode, selectionAfter, coalesce) {
176
+ history.record(previousCode, code, selectionAfter, coalesce);
177
+ emitHistory();
178
+ }
179
+
180
+ /** @param {import("./editable-history.js").HistoryMove | null} move */
181
+ function applyHistoryMove(move) {
182
+ if (!move) return;
183
+ code = move.code;
184
+ onChange?.(code);
185
+ emitHistory();
186
+ renderAt(move.selection.start, move.selection.end);
187
+ }
188
+
189
+ /**
190
+ * @param {string} value
191
+ * @param {number} start
192
+ * @param {number} end
193
+ * @param {boolean} coalesce
194
+ */
195
+ function commit(value, start, end, coalesce) {
196
+ if (settings.readonly) return;
197
+ const previousCode = code;
198
+ code = value;
199
+ onChange?.(code);
200
+ pushHistory(previousCode, { start, end }, coalesce);
201
+ renderAt(start, end);
202
+ }
203
+
204
+ /**
205
+ * Applies a command from editable-commands.js to the current selection.
206
+ * @param {(code: string, sel: import("./editable-history.js").SelectionRange) => { code: string, selection: import("./editable-history.js").SelectionRange } | null} command
207
+ */
208
+ function runCommand(command) {
209
+ const sel = getSelectionRange();
210
+ if (!sel) return;
211
+ const edit = command(code, sel);
212
+ if (edit) {
213
+ commit(edit.code, edit.selection.start, edit.selection.end, false);
214
+ }
215
+ }
216
+
217
+ /** @param {string} text */
218
+ function insertText(text) {
219
+ runCommand((value, sel) => replaceSelection(value, sel, text));
220
+ }
221
+
222
+ /** @param {boolean} outdent */
223
+ function shiftIndent(outdent) {
224
+ runCommand((value, sel) =>
225
+ shiftLines(value, sel, settings.tabSize, outdent),
226
+ );
227
+ }
228
+
229
+ function indentCommand() {
230
+ runCommand((value, sel) => indentSelection(value, sel, settings.tabSize));
231
+ }
232
+
233
+ function ensureFocus() {
234
+ if (doc.activeElement === element) return;
235
+ const prior = getSelectionRange();
236
+ element.focus();
237
+ if (prior) setSelection(prior.start, prior.end);
238
+ else setSelection(code.length);
239
+ syncCaretToHistory();
240
+ }
241
+
242
+ /**
243
+ * Replaces the whole document as one undo step.
244
+ * @param {string} value
245
+ */
246
+ function setCode(value) {
247
+ if (settings.readonly || value === code) return;
248
+ const previousCode = code;
249
+ code = value;
250
+ onChange?.(code);
251
+ pushHistory(
252
+ previousCode,
253
+ { start: value.length, end: value.length },
254
+ false,
255
+ );
256
+ paint();
257
+ }
258
+
259
+ function undo() {
260
+ applyHistoryMove(history.undo(code));
261
+ }
262
+
263
+ function redo() {
264
+ applyHistoryMove(history.redo(code));
265
+ }
266
+
267
+ /** @param {() => void} action */
268
+ function runNativeHistory(action) {
269
+ if (handlingNativeHistory) return;
270
+ handlingNativeHistory = true;
271
+ action();
272
+ setTimeout(() => {
273
+ handlingNativeHistory = false;
274
+ }, 0);
275
+ }
276
+
277
+ /** @param {InputEvent} [event] */
278
+ function onInput(event) {
279
+ if (composing) return;
280
+ // Chromium's execCommand undo/redo skips cancelable beforeinput:
281
+ // re-render from our history instead of recording the mutation.
282
+ if (event?.inputType === "historyUndo") {
283
+ runNativeHistory(undo);
284
+ return;
285
+ }
286
+ if (event?.inputType === "historyRedo") {
287
+ runNativeHistory(redo);
288
+ return;
289
+ }
290
+ const previousCode = code;
291
+ // Not innerText: it forces layout and Firefox can return a stale value
292
+ // after editing a node written via textContent. `white-space: pre`
293
+ // means native inserts use "\n", not <br>.
294
+ code = (element.textContent ?? "").replace(TRAILING_NEWLINE, "");
295
+ const caret = getCaretOffset() ?? code.length;
296
+ onChange?.(code);
297
+ pushHistory(previousCode, { start: caret, end: caret }, true);
298
+ renderAt(caret);
299
+ }
300
+
301
+ /** @param {KeyboardEvent} event */
302
+ function onKeydown(event) {
303
+ const mod = event.metaKey || event.ctrlKey;
304
+
305
+ if (event.key === "Escape") {
306
+ tabTrapReleased = true;
307
+ return;
308
+ }
309
+ if (tabTrapReleased) {
310
+ tabTrapReleased = false;
311
+ if (event.key === "Tab") return;
312
+ }
313
+
314
+ if (mod && event.key === "z" && !event.shiftKey) {
315
+ event.preventDefault();
316
+ if (!settings.readonly) undo();
317
+ return;
318
+ }
319
+ if (mod && (event.key === "y" || (event.key === "z" && event.shiftKey))) {
320
+ event.preventDefault();
321
+ if (!settings.readonly) redo();
322
+ return;
323
+ }
324
+ if (event.key === "Enter") {
325
+ event.preventDefault();
326
+ insertText("\n");
327
+ return;
328
+ }
329
+ if (event.key === "Tab") {
330
+ event.preventDefault();
331
+ if (event.shiftKey) shiftIndent(true);
332
+ else indentCommand();
333
+ }
334
+ }
335
+
336
+ /** @param {ClipboardEvent} event */
337
+ function onPaste(event) {
338
+ event.preventDefault();
339
+ insertText(event.clipboardData?.getData("text/plain") ?? "");
340
+ }
341
+
342
+ /** @param {DragEvent} event */
343
+ function onDrop(event) {
344
+ event.preventDefault();
345
+ insertText(event.dataTransfer?.getData("text/plain") ?? "");
346
+ }
347
+
348
+ // Edit-menu / execCommand undo-redo bypass onKeydown.
349
+ /** @param {InputEvent} event */
350
+ function onBeforeInput(event) {
351
+ if (event.inputType === "historyUndo") {
352
+ event.preventDefault();
353
+ runNativeHistory(undo);
354
+ } else if (event.inputType === "historyRedo") {
355
+ event.preventDefault();
356
+ runNativeHistory(redo);
357
+ }
358
+ }
359
+
360
+ function onBlurEvent() {
361
+ tabTrapReleased = false;
362
+ onBlur?.(code);
363
+ }
364
+
365
+ // Only listen to document-wide selectionchange while focused.
366
+ function onFocusIn() {
367
+ doc.addEventListener("selectionchange", syncCaretToHistory);
368
+ }
369
+
370
+ function onFocusOut() {
371
+ doc.removeEventListener("selectionchange", syncCaretToHistory);
372
+ }
373
+
374
+ function onCompositionStart() {
375
+ composing = true;
376
+ }
377
+
378
+ function onCompositionEnd() {
379
+ composing = false;
380
+ onInput();
381
+ }
382
+
383
+ /** @type {[string, (event: any) => void][]} */
384
+ const listeners = [
385
+ ["input", onInput],
386
+ ["keydown", onKeydown],
387
+ ["beforeinput", onBeforeInput],
388
+ ["paste", onPaste],
389
+ ["drop", onDrop],
390
+ ["mouseup", syncCaretToHistory],
391
+ ["keyup", syncCaretToHistory],
392
+ ["focusin", onFocusIn],
393
+ ["focusout", onFocusOut],
394
+ ["blur", onBlurEvent],
395
+ ["compositionstart", onCompositionStart],
396
+ ["compositionend", onCompositionEnd],
397
+ ];
398
+
399
+ paint();
400
+ history.reset(code);
401
+ emitHistory();
402
+ for (const [type, listener] of listeners) {
403
+ element.addEventListener(type, listener);
404
+ }
405
+
406
+ return {
407
+ /** Prefix of this editor's `CSS.highlights` names, for `instanceHighlightStyle`. */
408
+ instanceId,
409
+
410
+ /**
411
+ * Applies changed settings. A new language, engine or theme repaints.
412
+ * @param {Partial<EditorSettings>} next
413
+ */
414
+ update(next) {
415
+ Object.assign(settings, next);
416
+ ensureRegistered(settings.language);
417
+ const nextEngine = resolveEngine(settings.engine);
418
+ const themeChanged = painter.setTheme(settings.theme);
419
+ if (settings.language.name === languageName && nextEngine === engine) {
420
+ if (themeChanged && engine === "css-highlights") {
421
+ repaintForLanguageChange();
422
+ }
423
+ return;
424
+ }
425
+ if (engine === "css-highlights") painter.clearHighlights();
426
+ languageName = settings.language.name;
427
+ engine = nextEngine;
428
+ repaintForLanguageChange();
429
+ },
430
+
431
+ /**
432
+ * Takes code changed outside the editor (e.g. a bound prop). Records an
433
+ * undo step but, unlike `setCode`, ignores `readonly` and doesn't call
434
+ * `onChange`.
435
+ * @param {string} value
436
+ */
437
+ syncCode(value) {
438
+ if (value === code) return;
439
+ const previousCode = code;
440
+ code = value;
441
+ pushHistory(
442
+ previousCode,
443
+ { start: code.length, end: code.length },
444
+ false,
445
+ );
446
+ paint();
447
+ },
448
+
449
+ undo,
450
+ redo,
451
+
452
+ focus() {
453
+ element.focus();
454
+ },
455
+
456
+ selectAll() {
457
+ element.focus();
458
+ setSelection(0, code.length);
459
+ },
460
+
461
+ /** @param {string} text */
462
+ insert(text) {
463
+ ensureFocus();
464
+ insertText(text);
465
+ },
466
+
467
+ indent() {
468
+ ensureFocus();
469
+ indentCommand();
470
+ },
471
+
472
+ outdent() {
473
+ ensureFocus();
474
+ shiftIndent(true);
475
+ },
476
+
477
+ setCode,
478
+
479
+ clear() {
480
+ setCode("");
481
+ },
482
+
483
+ getCode() {
484
+ return code;
485
+ },
486
+
487
+ canUndo() {
488
+ return history.canUndo();
489
+ },
490
+
491
+ canRedo() {
492
+ return history.canRedo();
493
+ },
494
+
495
+ /**
496
+ * The engine on screen. `"css-highlights"` once it paints. `"dom"`
497
+ * where `CSS.highlights` is missing, while a theme's color resolver
498
+ * loads, and while that load has failed.
499
+ */
500
+ resolvedEngine() {
501
+ return painter.paintedEngine();
502
+ },
503
+
504
+ /** Removes listeners and this editor's CSS highlights. */
505
+ destroy() {
506
+ for (const [type, listener] of listeners) {
507
+ element.removeEventListener(type, listener);
508
+ }
509
+ doc.removeEventListener("selectionchange", syncCaretToHistory);
510
+ painter.destroy();
511
+ },
512
+ };
513
+ }
package/engine.d.ts CHANGED
@@ -44,7 +44,7 @@ export interface GrammarState {
44
44
  }
45
45
 
46
46
  /** Generated data; see `GrammarState`. */
47
- // biome-ignore lint/style/useNamingConvention: "IR" (intermediate representation) is an established term throughout this codebase's docs
47
+ // "IR" (intermediate representation) is an established term throughout this codebase's docs.
48
48
  export interface GrammarIR {
49
49
  name: string;
50
50
  caseInsensitive?: boolean;
package/fence.js CHANGED
@@ -149,7 +149,7 @@ function mayBeFence(text, lineStart, lineEnd) {
149
149
  let p = lineStart;
150
150
  while (p < maxIndent && text.charCodeAt(p) === 32 /* " " */) p += 1;
151
151
  const code = text.charCodeAt(p);
152
- return code === 96 /* "`" */ || code === 126 /* "~" */;
152
+ return code === 96 /* "`" */ || code === 126; /* "~" */
153
153
  }
154
154
 
155
155
  /**