@ngrok/mantle-server-syntax-highlighter 1.1.18 → 1.1.20
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/dist/index.d.ts +1 -13
- package/dist/index.js +62 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { FoldLine, FoldableRange, Indentation, LineRange, SupportedLanguage } from "@ngrok/mantle/highlight-utils";
|
|
2
2
|
import { createHighlighter } from "shiki";
|
|
3
3
|
import "oxc-parser";
|
|
4
|
-
//#region src/engine.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Shiki grammar IDs preloaded by Mantle's highlighting engine.
|
|
7
6
|
* This list is shared by both Vite plugins and server-side highlighting routes.
|
|
8
7
|
*/
|
|
9
|
-
declare const mantleShikiLanguageGrammarIds: ["bash", "csharp", "css", "go", "html", "java", "javascript", "json", "jsx", "python", "ruby", "rust", "shell", "terraform", "tsx", "typescript", "xml", "yaml"];
|
|
8
|
+
declare const mantleShikiLanguageGrammarIds: ["bash", "csharp", "css", "dotenv", "go", "html", "java", "javascript", "json", "jsx", "python", "ruby", "rust", "shell", "terraform", "tsx", "typescript", "xml", "yaml"];
|
|
10
9
|
/**
|
|
11
10
|
* Shared Shiki theme name used across Mantle highlighting.
|
|
12
11
|
*/
|
|
@@ -86,8 +85,6 @@ declare function highlightWithMantleShiki(input: MantleHighlightInput): Promise<
|
|
|
86
85
|
* Creates a reusable Mantle server highlighter facade for API routes.
|
|
87
86
|
*/
|
|
88
87
|
declare function createMantleServerSyntaxHighlighter(): MantleServerHighlighter;
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/server-fold-ranges.d.ts
|
|
91
88
|
/**
|
|
92
89
|
* Server-side folding strategy applied to a language. This is a richer
|
|
93
90
|
* dispatch than `@ngrok/mantle/highlight-utils`'s `foldStrategyFor`:
|
|
@@ -144,8 +141,6 @@ declare function computeServerFoldRanges({ code, language, tokens }: {
|
|
|
144
141
|
/** Shiki-tokenized lines, when the strategy needs them. */
|
|
145
142
|
tokens: FoldLine[] | undefined;
|
|
146
143
|
}): FoldableRange[];
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/compute-jsx-fold-ranges.d.ts
|
|
149
144
|
/**
|
|
150
145
|
* AST-based fold computer for the JS/TS/JSX/TSX language family.
|
|
151
146
|
*
|
|
@@ -179,8 +174,6 @@ declare function computeJsxFoldRanges({ code, language }: {
|
|
|
179
174
|
/** Resolved Mantle language; controls grammar selection (TS vs JS, JSX vs plain). */
|
|
180
175
|
language: JsxFoldLanguage;
|
|
181
176
|
}): FoldableRange[];
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/compute-html-fold-ranges.d.ts
|
|
184
177
|
/**
|
|
185
178
|
* AST-based fold computer for HTML and XML.
|
|
186
179
|
*
|
|
@@ -220,8 +213,6 @@ declare function computeHtmlFoldRanges({ code, language }: {
|
|
|
220
213
|
/** Resolved Mantle language; selects HTML vs. XML parsing rules. */
|
|
221
214
|
language: HtmlFoldLanguage;
|
|
222
215
|
}): FoldableRange[];
|
|
223
|
-
//#endregion
|
|
224
|
-
//#region src/compute-css-fold-ranges.d.ts
|
|
225
216
|
/**
|
|
226
217
|
* Raw-source fold computer for CSS — single-pass, parser-quality without a
|
|
227
218
|
* parser dependency.
|
|
@@ -259,8 +250,6 @@ declare function computeCssFoldRanges({ code }: {
|
|
|
259
250
|
/** Raw CSS source code to scan. */
|
|
260
251
|
code: string;
|
|
261
252
|
}): FoldableRange[];
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/compute-keyword-fold-ranges.d.ts
|
|
264
253
|
/**
|
|
265
254
|
* Keyword-pair fold computer for languages whose blocks are delimited by
|
|
266
255
|
* keywords rather than punctuation.
|
|
@@ -301,6 +290,5 @@ declare function computeKeywordFoldRanges({ language, tokens }: {
|
|
|
301
290
|
/** Shiki-tokenized lines, with scope explanations populated. */
|
|
302
291
|
tokens: FoldLine[];
|
|
303
292
|
}): FoldableRange[];
|
|
304
|
-
//#endregion
|
|
305
293
|
export { type HtmlFoldLanguage, type JsxFoldLanguage, type KeywordFoldLanguage, type MantleHighlightInput, type MantleHighlightResult, type MantleServerHighlighter, type ServerFoldStrategy, computeCssFoldRanges, computeHtmlFoldRanges, computeJsxFoldRanges, computeKeywordFoldRanges, computeServerFoldRanges, createMantleServerSyntaxHighlighter, getMantleShikiHighlighter, highlightWithMantleShiki, mantleHighlightCacheMaxEntries, mantleShikiLanguageGrammarIds, mantleShikiThemeName, serverFoldNeedsTokens, serverFoldStrategyFor };
|
|
306
294
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { computeFoldRanges, computeJsonFoldRanges, decorateHighlightedHtml, finalizeFoldRanges, inferIndentation, isSupportedLanguage, normalizeIndentation, parseLanguage } from "@ngrok/mantle/highlight-utils";
|
|
4
4
|
import { html, parse, parseFragment } from "parse5";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/lru-cache.ts
|
|
7
7
|
/** Creates an LRU cache that evicts the least-recently-used entry when `maxEntries` is exceeded. */
|
|
8
8
|
function createLruCache(maxEntries) {
|
|
9
9
|
if (!Number.isInteger(maxEntries) || maxEntries <= 0) throw new Error("LRU cache maxEntries must be a positive integer.");
|
|
@@ -32,8 +32,7 @@ function createLruCache(maxEntries) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
//#region src/compute-css-fold-ranges.ts
|
|
35
|
+
// src/compute-css-fold-ranges.ts
|
|
37
36
|
/**
|
|
38
37
|
* Raw-source fold computer for CSS — single-pass, parser-quality without a
|
|
39
38
|
* parser dependency.
|
|
@@ -156,8 +155,7 @@ function computeCssFoldRanges({ code }) {
|
|
|
156
155
|
return finalizeFoldRanges(ranges);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
|
|
160
|
-
//#region src/compute-html-fold-ranges.ts
|
|
158
|
+
// src/compute-html-fold-ranges.ts
|
|
161
159
|
/**
|
|
162
160
|
* Synthetic SVG fragment context shared across XML parses. Only the namespace
|
|
163
161
|
* matters for the foreign-content tokenizer mode; the rest of the fields
|
|
@@ -267,8 +265,7 @@ function computeHtmlFoldRanges({ code, language }) {
|
|
|
267
265
|
return finalizeFoldRanges(ranges);
|
|
268
266
|
}
|
|
269
267
|
|
|
270
|
-
|
|
271
|
-
//#region src/line-offsets.ts
|
|
268
|
+
// src/line-offsets.ts
|
|
272
269
|
/**
|
|
273
270
|
* Helpers for converting parser byte offsets into 1-indexed line numbers.
|
|
274
271
|
*
|
|
@@ -321,8 +318,7 @@ function offsetToLine(lineOffsets, offset) {
|
|
|
321
318
|
return low + 1;
|
|
322
319
|
}
|
|
323
320
|
|
|
324
|
-
|
|
325
|
-
//#region src/compute-jsx-fold-ranges.ts
|
|
321
|
+
// src/compute-jsx-fold-ranges.ts
|
|
326
322
|
const requireOxc = createRequire(import.meta.url);
|
|
327
323
|
/** Creates a memoized parser loader that caches both success and load failure. */
|
|
328
324
|
function createOxcParserLoader(load) {
|
|
@@ -434,7 +430,7 @@ const SYNTHETIC_FILENAME = "__mantle_fold__";
|
|
|
434
430
|
* (inclusive) when it crosses a line boundary. Single-line spans contribute
|
|
435
431
|
* nothing — there's nothing to fold.
|
|
436
432
|
*/
|
|
437
|
-
function pushRange(ranges, lineOffsets, startOffset, endOffset) {
|
|
433
|
+
function pushRange({ ranges, lineOffsets, startOffset, endOffset }) {
|
|
438
434
|
const startLine = offsetToLine(lineOffsets, startOffset);
|
|
439
435
|
const endLine = offsetToLine(lineOffsets, endOffset);
|
|
440
436
|
if (endLine > startLine) ranges.push({
|
|
@@ -468,21 +464,40 @@ function computeJsxFoldRanges({ code, language }) {
|
|
|
468
464
|
if (node.type === "JSXElement") {
|
|
469
465
|
const opening = jsxOpeningElement(node);
|
|
470
466
|
if (opening != null && isSelfClosingOpening(opening)) {
|
|
471
|
-
if (opening != null) pushRange(
|
|
467
|
+
if (opening != null) pushRange({
|
|
468
|
+
ranges,
|
|
469
|
+
lineOffsets,
|
|
470
|
+
startOffset: opening.start,
|
|
471
|
+
endOffset: opening.end - 1
|
|
472
|
+
});
|
|
472
473
|
return;
|
|
473
474
|
}
|
|
474
|
-
pushRange(
|
|
475
|
-
|
|
475
|
+
pushRange({
|
|
476
|
+
ranges,
|
|
477
|
+
lineOffsets,
|
|
478
|
+
startOffset: node.start,
|
|
479
|
+
endOffset: node.end - 1
|
|
480
|
+
});
|
|
481
|
+
if (opening != null) pushRange({
|
|
482
|
+
ranges,
|
|
483
|
+
lineOffsets,
|
|
484
|
+
startOffset: opening.start,
|
|
485
|
+
endOffset: opening.end - 1
|
|
486
|
+
});
|
|
476
487
|
return;
|
|
477
488
|
}
|
|
478
489
|
if (!FOLDABLE_NODE_TYPES.has(node.type)) return;
|
|
479
|
-
pushRange(
|
|
490
|
+
pushRange({
|
|
491
|
+
ranges,
|
|
492
|
+
lineOffsets,
|
|
493
|
+
startOffset: node.start,
|
|
494
|
+
endOffset: node.end - 1
|
|
495
|
+
});
|
|
480
496
|
});
|
|
481
497
|
return finalizeFoldRanges(ranges);
|
|
482
498
|
}
|
|
483
499
|
|
|
484
|
-
|
|
485
|
-
//#region src/compute-keyword-fold-ranges.ts
|
|
500
|
+
// src/compute-keyword-fold-ranges.ts
|
|
486
501
|
const RUBY_START_KEYWORDS = [
|
|
487
502
|
"def",
|
|
488
503
|
"class",
|
|
@@ -561,7 +576,7 @@ function endTrimmedIndex(text) {
|
|
|
561
576
|
return index;
|
|
562
577
|
}
|
|
563
578
|
/** Returns true if `word` appears at `index` with word boundaries. */
|
|
564
|
-
function isWordAt(text, index, word, end = text.length) {
|
|
579
|
+
function isWordAt({ text, index, word, end = text.length }) {
|
|
565
580
|
if (index < 0 || index + word.length > end) return false;
|
|
566
581
|
if (text.slice(index, index + word.length) !== word) return false;
|
|
567
582
|
const beforeIsBoundary = index === 0 || !isWordChar(text.charCodeAt(index - 1));
|
|
@@ -572,7 +587,11 @@ function isWordAt(text, index, word, end = text.length) {
|
|
|
572
587
|
/** Returns true when a line begins with one of the given keywords. */
|
|
573
588
|
function startsWithAnyWordAfterWhitespace(text, words) {
|
|
574
589
|
const index = firstNonWhitespaceIndex(text);
|
|
575
|
-
for (const word of words) if (isWordAt(
|
|
590
|
+
for (const word of words) if (isWordAt({
|
|
591
|
+
text,
|
|
592
|
+
index,
|
|
593
|
+
word
|
|
594
|
+
})) return true;
|
|
576
595
|
return false;
|
|
577
596
|
}
|
|
578
597
|
/**
|
|
@@ -596,7 +615,11 @@ function isShellCommandBoundary(text, index) {
|
|
|
596
615
|
function hasShellSameLineEndKeyword(text) {
|
|
597
616
|
for (let index = 0; index < text.length; index += 1) {
|
|
598
617
|
if (!isWordChar(text.charCodeAt(index))) continue;
|
|
599
|
-
for (const word of BASH_END_KEYWORDS) if (isWordAt(
|
|
618
|
+
for (const word of BASH_END_KEYWORDS) if (isWordAt({
|
|
619
|
+
text,
|
|
620
|
+
index,
|
|
621
|
+
word
|
|
622
|
+
}) && isShellCommandBoundary(text, index)) return true;
|
|
600
623
|
while (index + 1 < text.length && isWordChar(text.charCodeAt(index + 1))) index += 1;
|
|
601
624
|
}
|
|
602
625
|
return false;
|
|
@@ -609,7 +632,11 @@ function hasShellSameLineEndKeyword(text) {
|
|
|
609
632
|
function startsWithShellEndKeyword(text) {
|
|
610
633
|
const index = firstNonWhitespaceIndex(text);
|
|
611
634
|
for (const word of BASH_END_KEYWORDS) {
|
|
612
|
-
if (!isWordAt(
|
|
635
|
+
if (!isWordAt({
|
|
636
|
+
text,
|
|
637
|
+
index,
|
|
638
|
+
word
|
|
639
|
+
})) continue;
|
|
613
640
|
const next = text.charCodeAt(index + word.length);
|
|
614
641
|
return Number.isNaN(next) || isWhitespaceChar(next) || next === 38 || next === 59 || next === 124;
|
|
615
642
|
}
|
|
@@ -618,7 +645,12 @@ function startsWithShellEndKeyword(text) {
|
|
|
618
645
|
/** Returns true when a line ends with `word`, ignoring trailing whitespace. */
|
|
619
646
|
function endsWithWord(text, word) {
|
|
620
647
|
const end = endTrimmedIndex(text);
|
|
621
|
-
return isWordAt(
|
|
648
|
+
return isWordAt({
|
|
649
|
+
text,
|
|
650
|
+
index: end - word.length,
|
|
651
|
+
word,
|
|
652
|
+
end
|
|
653
|
+
});
|
|
622
654
|
}
|
|
623
655
|
/** Returns true for trailing Ruby `do` / `do |args|` block openers. */
|
|
624
656
|
function endsWithRubyDoBlock(text) {
|
|
@@ -630,7 +662,12 @@ function endsWithRubyDoBlock(text) {
|
|
|
630
662
|
end = paramsStart;
|
|
631
663
|
while (end > 0 && isWhitespaceChar(text.charCodeAt(end - 1))) end -= 1;
|
|
632
664
|
}
|
|
633
|
-
return isWordAt(
|
|
665
|
+
return isWordAt({
|
|
666
|
+
text,
|
|
667
|
+
index: end - 2,
|
|
668
|
+
word: "do",
|
|
669
|
+
end
|
|
670
|
+
});
|
|
634
671
|
}
|
|
635
672
|
/** Returns true when a Ruby line opens a keyword-paired block. */
|
|
636
673
|
function rubyStartsFold(visible) {
|
|
@@ -751,8 +788,7 @@ function computeKeywordFoldRanges({ language, tokens }) {
|
|
|
751
788
|
return finalizeFoldRanges(ranges);
|
|
752
789
|
}
|
|
753
790
|
|
|
754
|
-
|
|
755
|
-
//#region src/server-fold-ranges.ts
|
|
791
|
+
// src/server-fold-ranges.ts
|
|
756
792
|
/** Returns the server fold strategy for the given supported language. */
|
|
757
793
|
function serverFoldStrategyFor(language) {
|
|
758
794
|
switch (language) {
|
|
@@ -877,8 +913,7 @@ function computeServerFoldRanges({ code, language, tokens }) {
|
|
|
877
913
|
}
|
|
878
914
|
}
|
|
879
915
|
|
|
880
|
-
|
|
881
|
-
//#region src/engine.ts
|
|
916
|
+
// src/engine.ts
|
|
882
917
|
/**
|
|
883
918
|
* Shiki grammar IDs preloaded by Mantle's highlighting engine.
|
|
884
919
|
* This list is shared by both Vite plugins and server-side highlighting routes.
|
|
@@ -887,6 +922,7 @@ const mantleShikiLanguageGrammarIds = [
|
|
|
887
922
|
"bash",
|
|
888
923
|
"csharp",
|
|
889
924
|
"css",
|
|
925
|
+
"dotenv",
|
|
890
926
|
"go",
|
|
891
927
|
"html",
|
|
892
928
|
"java",
|
|
@@ -1050,6 +1086,5 @@ function createMantleServerSyntaxHighlighter() {
|
|
|
1050
1086
|
return { highlight: highlightWithMantleShiki };
|
|
1051
1087
|
}
|
|
1052
1088
|
|
|
1053
|
-
//#endregion
|
|
1054
1089
|
export { computeCssFoldRanges, computeHtmlFoldRanges, computeJsxFoldRanges, computeKeywordFoldRanges, computeServerFoldRanges, createMantleServerSyntaxHighlighter, getMantleShikiHighlighter, highlightWithMantleShiki, mantleHighlightCacheMaxEntries, mantleShikiLanguageGrammarIds, mantleShikiThemeName, serverFoldNeedsTokens, serverFoldStrategyFor };
|
|
1055
1090
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/lru-cache.ts","../src/compute-css-fold-ranges.ts","../src/compute-html-fold-ranges.ts","../src/line-offsets.ts","../src/compute-jsx-fold-ranges.ts","../src/compute-keyword-fold-ranges.ts","../src/server-fold-ranges.ts","../src/engine.ts"],"sourcesContent":["/** A simple least-recently-used cache backed by insertion-order `Map` semantics. */\ntype LruCache<K, V> = {\n\tdelete: (key: K) => boolean;\n\tget: (key: K) => V | undefined;\n\tset: (key: K, value: V) => void;\n\tsize: () => number;\n};\n\n/** Creates an LRU cache that evicts the least-recently-used entry when `maxEntries` is exceeded. */\nfunction createLruCache<K, V>(maxEntries: number): LruCache<K, V> {\n\tif (!Number.isInteger(maxEntries) || maxEntries <= 0) {\n\t\tthrow new Error(\"LRU cache maxEntries must be a positive integer.\");\n\t}\n\n\t// Why the `{ value }` box: `get` can tell a stored `undefined` from a missing key.\n\tconst map = new Map<K, { value: V }>();\n\n\treturn {\n\t\tdelete(key) {\n\t\t\treturn map.delete(key);\n\t\t},\n\t\tget(key) {\n\t\t\tconst entry = map.get(key);\n\t\t\tif (entry == null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tmap.delete(key);\n\t\t\tmap.set(key, entry);\n\t\t\treturn entry.value;\n\t\t},\n\t\tset(key, value) {\n\t\t\tif (map.has(key)) {\n\t\t\t\tmap.delete(key);\n\t\t\t}\n\n\t\t\tmap.set(key, { value });\n\t\t\tif (map.size <= maxEntries) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldestKey = map.keys().next().value;\n\t\t\tif (oldestKey != null) {\n\t\t\t\tmap.delete(oldestKey);\n\t\t\t}\n\t\t},\n\t\tsize() {\n\t\t\treturn map.size;\n\t\t},\n\t};\n}\n\nexport { createLruCache };\nexport type { LruCache };\n","import { finalizeFoldRanges, type FoldableRange } from \"@ngrok/mantle/highlight-utils\";\n\n/**\n * Raw-source fold computer for CSS — single-pass, parser-quality without a\n * parser dependency.\n *\n * Mirrors `computeJsonFoldRanges` but adds CSS-specific lexical features:\n *\n * - `/* … */` block comments are skipped wholesale.\n * - `\"…\"` and `'…'` string literals (including `\\\\` and `\\` escapes) are\n * skipped so braces inside `content: \"{ }\"` don't open folds.\n * - Backslash escapes outside of strings (CSS identifiers can use them) are\n * transparent — we just consume the next character.\n *\n * lightningcss is the project's preferred CSS parser, but its public visitor\n * API only surfaces *start* locations (`Location { line, column }`), not end\n * locations, which is what `FoldableRange.endLine` requires. Until upstream\n * exposes end spans we get the same correctness from a single-pass brace\n * matcher with a tiny CSS lexer — and skip the ~5MB native dep.\n *\n * @see https://github.com/parcel-bundler/lightningcss/issues/512\n */\n\n/**\n * Computes foldable ranges for a CSS source string. Each multi-line `{ … }`\n * (style rule, at-rule body, nested rule, keyframe selector) emits one range\n * with the opener and closer lines staying visible.\n *\n * Tolerant of malformed CSS — unmatched braces are dropped silently rather\n * than throwing, so a partial snippet still gets every fold it can. This\n * matches the behavior of `computeJsonFoldRanges` for JSON.\n *\n * @example\n * computeCssFoldRanges({ code: \".a {\\n color: red;\\n}\" });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeCssFoldRanges({\n\tcode,\n}: {\n\t/** Raw CSS source code to scan. */\n\tcode: string;\n}): FoldableRange[] {\n\tconst length = code.length;\n\tif (length === 0) {\n\t\treturn [];\n\t}\n\n\tconst stack: number[] = [];\n\tconst ranges: FoldableRange[] = [];\n\n\tlet line = 1;\n\tlet index = 0;\n\n\twhile (index < length) {\n\t\tconst character = code.charCodeAt(index);\n\n\t\tif (character === 10) {\n\t\t\tline += 1;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (character === 13) {\n\t\t\tline += 1;\n\t\t\tindex += 1;\n\t\t\tif (index < length && code.charCodeAt(index) === 10) {\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// `/* … */` block comment — CSS has no line comments in standard CSS.\n\t\tif (character === 47 && index + 1 < length && code.charCodeAt(index + 1) === 42) {\n\t\t\tindex += 2;\n\t\t\twhile (index < length) {\n\t\t\t\tconst commentChar = code.charCodeAt(index);\n\t\t\t\tif (commentChar === 10) {\n\t\t\t\t\tline += 1;\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (commentChar === 13) {\n\t\t\t\t\tline += 1;\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tif (index < length && code.charCodeAt(index) === 10) {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (commentChar === 42 && index + 1 < length && code.charCodeAt(index + 1) === 47) {\n\t\t\t\t\tindex += 2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// `\"…\"` or `'…'` string literal. CSS allows escaped newlines (`\\` followed\n\t\t// by a newline) which continue the string; treat any backslash as\n\t\t// \"skip the next char\" without bumping the line counter past it.\n\t\tif (character === 34 || character === 39) {\n\t\t\tconst quote = character;\n\t\t\tindex += 1;\n\t\t\twhile (index < length) {\n\t\t\t\tconst stringChar = code.charCodeAt(index);\n\t\t\t\tif (stringChar === 92) {\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tif (index >= length) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst escaped = code.charCodeAt(index);\n\t\t\t\t\tif (escaped === 10) {\n\t\t\t\t\t\tline += 1;\n\t\t\t\t\t} else if (escaped === 13) {\n\t\t\t\t\t\tline += 1;\n\t\t\t\t\t\tif (index + 1 < length && code.charCodeAt(index + 1) === 10) {\n\t\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (stringChar === quote) {\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (stringChar === 10) {\n\t\t\t\t\t// CSS strings normally can't span unescaped newlines; bail to\n\t\t\t\t\t// avoid swallowing the rest of the file when the quote is\n\t\t\t\t\t// stranded.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (character === 123) {\n\t\t\tstack.push(line);\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (character === 125) {\n\t\t\tconst startLine = stack.pop();\n\t\t\tif (startLine != null && startLine !== line) {\n\t\t\t\tranges.push({ id: String(startLine), startLine, endLine: line });\n\t\t\t}\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tindex += 1;\n\t}\n\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeCssFoldRanges };\n","import { finalizeFoldRanges, type FoldableRange } from \"@ngrok/mantle/highlight-utils\";\nimport { html, parse, parseFragment } from \"parse5\";\nimport type { DefaultTreeAdapterMap } from \"parse5\";\n\n/**\n * AST-based fold computer for HTML and XML.\n *\n * Uses `parse5` with `sourceCodeLocationInfo: true` so each element node carries\n * the line numbers of its open and close tags. Walking the tree gives us:\n *\n * - One fold per multi-line element (`<div>…</div>`).\n * - One fold per multi-line opening tag (`<div\\n class=\"x\"\\n>` — the\n * attribute list collapses).\n * - Correct void-element handling — parse5 already knows that `<br>`, `<img>`,\n * etc. don't open folds.\n * - Template content traversal — parse5 stores `<template>` descendants on a\n * separate `content` fragment, not on `childNodes`.\n * - String/comment scope filtering — angle brackets in `<!-- … -->` or\n * inside `\"…\"` attribute values aren't mistaken for tag openings.\n *\n * @see https://parse5.js.org/\n */\n\ntype HtmlFoldLanguage = \"html\" | \"xml\";\n\ntype Element = DefaultTreeAdapterMap[\"element\"];\ntype Node = DefaultTreeAdapterMap[\"node\"];\n\n/**\n * SVG-namespace URI used as a fragment context when parsing XML.\n *\n * In SVG context, `parse5` switches its tokenizer into \"foreign content\"\n * mode, which is much closer to XML semantics:\n *\n * - Self-closing `<foo/>` is honored.\n * - Element names are case-preserved.\n * - HTML-only void elements (`<br>`, `<img>`) are not auto-closed.\n *\n * That makes it acceptable as a stand-in XML parser for code blocks. The\n * caveat is that a few SVG-recognized names (`<title>`, `<desc>`, `<script>`,\n * `<style>`, `<foreignObject>`) revert to HTML rules inside their bodies; in\n * practice that's rare in user XML and yields conservative folding (still\n * correct, just sometimes more flat than VS Code's XML folder).\n */\nconst SVG_NAMESPACE = html.NS.SVG;\n\n/**\n * Synthetic SVG fragment context shared across XML parses. Only the namespace\n * matters for the foreign-content tokenizer mode; the rest of the fields\n * satisfy parse5's tree-adapter shape.\n */\nconst xmlFragmentContext: Element = {\n\tnodeName: \"svg\",\n\ttagName: \"svg\",\n\tnamespaceURI: SVG_NAMESPACE,\n\tattrs: [],\n\tchildNodes: [],\n\tparentNode: null,\n};\n\n/**\n * Returns true when a parse5 tree node has element-style `tagName` and child\n * nodes — i.e. it's an `Element` we should consider folding. Comments,\n * doctypes, text nodes, and the document root all fail this check.\n */\nfunction isElement(node: Node): node is Element {\n\treturn (\n\t\t\"tagName\" in node &&\n\t\ttypeof (node as { tagName?: unknown }).tagName === \"string\" &&\n\t\t\"childNodes\" in node\n\t);\n}\n\n/**\n * Traverses `root` depth-first and pushes a {@link FoldableRange} for every\n * element whose source span covers more than one line.\n *\n * Multi-line *elements* fold from the opening tag's start line to the closing\n * tag's end line (or to the element end when `endTag` info is unavailable —\n * parse5 sometimes synthesizes elements without a real closer when handling\n * malformed input).\n *\n * Multi-line *opening tags* (e.g. `<div\\n class=\"x\">`) fold from the start\n * of the tag to its `>` so the attribute list collapses into the tag name.\n * VS Code emits this as a separate \"tag\" fold marker; we mirror that.\n */\nfunction collectRanges(root: Node, ranges: FoldableRange[]): void {\n\tconst stack: Node[] = [root];\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop();\n\t\tif (node == null) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (isElement(node)) {\n\t\t\tpushRangesForElement(node, ranges);\n\t\t}\n\t\tpushChildNodes(node, stack);\n\n\t\t// parse5 models `<template>` descendants inside `node.content`, a\n\t\t// DocumentFragment, while `node.childNodes` stays empty. Include that\n\t\t// fragment so nested HTML in templates gets the same folds as normal\n\t\t// element children without recursing or re-walking the tree.\n\t\tif (\"content\" in node && typeof node.content === \"object\" && node.content != null) {\n\t\t\tpushChildNodes(node.content, stack);\n\t\t}\n\t}\n}\n\n/** Pushes parse5 child nodes onto the DFS stack in source order. */\nfunction pushChildNodes(parent: Node, stack: Node[]): void {\n\tif (!(\"childNodes\" in parent)) {\n\t\treturn;\n\t}\n\tconst childNodes = parent.childNodes;\n\tfor (let index = childNodes.length - 1; index >= 0; index -= 1) {\n\t\tconst child = childNodes[index];\n\t\tif (child != null) {\n\t\t\tstack.push(child);\n\t\t}\n\t}\n}\n\n/**\n * Emits up to two fold ranges for a single element: one for the element's\n * full body and one for its multi-line opening tag.\n */\nfunction pushRangesForElement(element: Element, ranges: FoldableRange[]): void {\n\tconst location = element.sourceCodeLocation;\n\tif (location == null) {\n\t\t// Implicit/synthetic elements (e.g. `<html>`/`<body>` parse5 fabricates\n\t\t// for fragment input) don't appear in the source. Skip them so we\n\t\t// don't emit folds without a real opener.\n\t\treturn;\n\t}\n\n\tconst startTag = location.startTag;\n\tconst endTag = location.endTag;\n\n\t// The element is a self-closing or void tag (no close tag in the source).\n\t// `<br>` HTML void elements and `<foo/>` XML self-closing tags both land\n\t// here; neither opens a fold.\n\tif (endTag == null) {\n\t\t// A multi-line single-tag element (`<input\\n type=\"text\"\\n/>`) still\n\t\t// gets the attribute-list fold below.\n\t\tpushTagFoldIfMultiline(startTag, ranges);\n\t\treturn;\n\t}\n\n\tconst startLine = location.startLine;\n\tconst endLine = location.endLine;\n\tif (endLine > startLine) {\n\t\tranges.push({ id: String(startLine), startLine, endLine });\n\t}\n\tpushTagFoldIfMultiline(startTag, ranges);\n}\n\n/**\n * Pushes a fold range for an opening tag (`startTag`) when its `<` and `>`\n * sit on different lines. Conservative: contributes nothing for single-line\n * tags so we don't fight `pushRangesForElement` for the same opener.\n */\nfunction pushTagFoldIfMultiline(\n\tstartTag: { startLine: number; endLine: number } | undefined,\n\tranges: FoldableRange[],\n): void {\n\tif (startTag == null) {\n\t\treturn;\n\t}\n\tif (startTag.endLine > startTag.startLine) {\n\t\tranges.push({\n\t\t\tid: String(startTag.startLine),\n\t\t\tstartLine: startTag.startLine,\n\t\t\tendLine: startTag.endLine,\n\t\t});\n\t}\n}\n\n/**\n * Computes foldable ranges for an HTML or XML source string.\n *\n * - HTML: uses `parse5.parse` so explicit `<html>`/`<head>`/`<body>` are\n * honored as foldable openers. Implicit wrappers parse5 fabricates for\n * fragment input have no `sourceCodeLocation` and are skipped.\n * - XML: uses `parse5.parseFragment` rooted in an SVG fragment context so the\n * tokenizer applies foreign-content (XML-like) rules — self-closing `<foo/>`\n * is respected, void HTML elements aren't special-cased.\n *\n * @example\n * computeHtmlFoldRanges({ code: \"<div>\\n <p>hi</p>\\n</div>\", language: \"html\" });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeHtmlFoldRanges({\n\tcode,\n\tlanguage,\n}: {\n\t/** Raw source code to parse. */\n\tcode: string;\n\t/** Resolved Mantle language; selects HTML vs. XML parsing rules. */\n\tlanguage: HtmlFoldLanguage;\n}): FoldableRange[] {\n\tif (code.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst document =\n\t\tlanguage === \"xml\"\n\t\t\t? parseFragment(xmlFragmentContext, code, { sourceCodeLocationInfo: true })\n\t\t\t: parse(code, { sourceCodeLocationInfo: true });\n\n\tconst ranges: FoldableRange[] = [];\n\tcollectRanges(document, ranges);\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeHtmlFoldRanges };\nexport type { HtmlFoldLanguage };\n","/**\n * Helpers for converting parser byte offsets into 1-indexed line numbers.\n *\n * Every AST-based fold strategy in this package speaks line numbers (because\n * `FoldableRange.startLine` / `endLine` are line-anchored), but parsers like\n * `oxc-parser` and `postcss` report offsets / line+col tuples derived from\n * byte positions. Building a single sorted `lineOffsets` array up front keeps\n * the per-node lookup `O(log n)` instead of rescanning the source each call.\n */\n\n/**\n * Returns an array where index `i` holds the byte offset of the start of\n * the `i + 1`-th line of `source`. The first entry is always `0`.\n *\n * Treats `\\n`, `\\r\\n`, and bare `\\r` as line breaks so it agrees with how\n * Shiki, oxc, parse5, and postcss split lines (they all match the JS\n * runtime's `String.prototype.split(/\\r\\n|\\r|\\n/)` behavior in practice).\n */\nfunction buildLineOffsets(source: string): number[] {\n\tconst offsets: number[] = [0];\n\tconst length = source.length;\n\tfor (let index = 0; index < length; index += 1) {\n\t\tconst character = source.charCodeAt(index);\n\t\tif (character === 10) {\n\t\t\toffsets.push(index + 1);\n\t\t\tcontinue;\n\t\t}\n\t\tif (character === 13) {\n\t\t\t// `\\r\\n` and bare `\\r` both start a new line at index + 1 (or + 2 when\n\t\t\t// followed by `\\n`); skip the `\\n` to avoid pushing a duplicate offset.\n\t\t\tconst isCrLf = index + 1 < length && source.charCodeAt(index + 1) === 10;\n\t\t\toffsets.push(isCrLf ? index + 2 : index + 1);\n\t\t\tif (isCrLf) {\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn offsets;\n}\n\n/**\n * Returns the 1-indexed line number that contains `offset` in the source\n * scanned by {@link buildLineOffsets}. Out-of-range offsets clamp to the\n * first or last line.\n */\nfunction offsetToLine(lineOffsets: readonly number[], offset: number): number {\n\tif (lineOffsets.length === 0) {\n\t\treturn 1;\n\t}\n\tif (offset <= 0) {\n\t\treturn 1;\n\t}\n\tlet low = 0;\n\tlet high = lineOffsets.length - 1;\n\twhile (low < high) {\n\t\t// Bias the midpoint toward `high` so the loop terminates when\n\t\t// `lineOffsets[mid] <= offset` repeatedly succeeds with `low === mid`.\n\t\tconst mid = (low + high + 1) >>> 1;\n\t\tconst start = lineOffsets[mid] ?? 0;\n\t\tif (start <= offset) {\n\t\t\tlow = mid;\n\t\t} else {\n\t\t\thigh = mid - 1;\n\t\t}\n\t}\n\treturn low + 1;\n}\n\nexport { buildLineOffsets, offsetToLine };\n","import { finalizeFoldRanges, type FoldableRange } from \"@ngrok/mantle/highlight-utils\";\nimport { createRequire } from \"node:module\";\nimport type * as OxcParserModule from \"oxc-parser\";\nimport type { ParserOptions } from \"oxc-parser\";\nimport { buildLineOffsets, offsetToLine } from \"./line-offsets.js\";\n\n/**\n * Loads `oxc-parser` lazily on first use. Eager `import` of oxc-parser runs\n * its napi-rs bootstrap (`bindings.js`), which `throw`s synchronously when the\n * platform-specific native binding (`@oxc-parser/binding-*`) isn't resolvable\n * — common on serverless hosts that ship the bundled JS without the binding\n * package alongside it. A throw at module-eval time would propagate through\n * the entire server bundle's import graph and 500 every route, not just\n * JSX/TSX folding. Deferring the load until folding runs lets this strategy\n * convert the failure into a cached \"no folds\" fallback while keeping every\n * other strategy working.\n */\ntype OxcParser = typeof OxcParserModule;\nconst requireOxc = createRequire(import.meta.url);\n\n/** Creates a memoized parser loader that caches both success and load failure. */\nfunction createOxcParserLoader(load: () => OxcParser): () => OxcParser | undefined {\n\tlet cachedOxcParser: OxcParser | undefined;\n\tlet didFailToLoadOxcParser = false;\n\n\treturn () => {\n\t\tif (cachedOxcParser != null) {\n\t\t\treturn cachedOxcParser;\n\t\t}\n\t\tif (didFailToLoadOxcParser) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet oxcParser: OxcParser;\n\t\ttry {\n\t\t\toxcParser = load();\n\t\t} catch {\n\t\t\tdidFailToLoadOxcParser = true;\n\t\t\treturn undefined;\n\t\t}\n\t\tcachedOxcParser = oxcParser;\n\t\treturn oxcParser;\n\t};\n}\n\n/** Returns the lazily-resolved `oxc-parser` module, or undefined after a cached load failure. */\n// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- Why: `require` returns `any`, and the type-only import names its shape.\nconst loadOxcParser = createOxcParserLoader(() => requireOxc(\"oxc-parser\") as OxcParser);\n\n/**\n * AST-based fold computer for the JS/TS/JSX/TSX language family.\n *\n * Mirrors VS Code's TypeScript language service folder by walking the parsed\n * AST instead of pairing brackets in the token stream. This lets us fold\n * constructs that bracket-pairing can't see:\n *\n * - JSX elements (`<Foo>…</Foo>`, fragments, members like `<obj.Foo>`).\n * - Template literals that span multiple lines (including tagged templates).\n *\n * It also keeps every fold the bracket strategy used to give us — block\n * statements, object literals, array literals, class/interface bodies, switch\n * statements — without the per-character scope-walk cost.\n *\n * @see https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/folding.ts\n */\n\n/** Subset of supported languages handled by this computer. */\ntype JsxFoldLanguage = \"javascript\" | \"js\" | \"typescript\" | \"ts\" | \"jsx\" | \"tsx\";\n\n/**\n * Maps a Mantle language to the oxc-parser `lang` option. JavaScript keeps\n * JSX enabled so JSX-in-JS examples still fold, but TypeScript must stay in\n * plain `ts` mode: TSX parses generic arrow functions (`<T>(x: T) => ...`) as\n * JSX and drops the AST folds for otherwise-valid TypeScript snippets.\n */\nfunction oxcLangFor(language: JsxFoldLanguage): \"jsx\" | \"ts\" | \"tsx\" {\n\tswitch (language) {\n\t\tcase \"tsx\":\n\t\t\treturn \"tsx\";\n\t\tcase \"typescript\":\n\t\tcase \"ts\":\n\t\t\treturn \"ts\";\n\t\tcase \"jsx\":\n\t\tcase \"javascript\":\n\t\tcase \"js\":\n\t\t\treturn \"jsx\";\n\t}\n}\n\n/** Minimal AST node shape — every oxc node carries `type`, `start`, `end`. */\ntype AstNode = {\n\ttype: string;\n\tstart: number;\n\tend: number;\n\t[key: string]: unknown;\n};\n\n/** Type guard for an arbitrary value being an AST node. */\nfunction isAstNode(value: unknown): value is AstNode {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue != null &&\n\t\t\"type\" in value &&\n\t\ttypeof (value as { type?: unknown }).type === \"string\" &&\n\t\t\"start\" in value &&\n\t\ttypeof (value as { start?: unknown }).start === \"number\" &&\n\t\t\"end\" in value &&\n\t\ttypeof (value as { end?: unknown }).end === \"number\"\n\t);\n}\n\n/**\n * AST node types whose `start`/`end` positions delimit a foldable region\n * when they span multiple lines.\n *\n * Curated to match VS Code's TypeScript folder:\n * - Block-like statement bodies — covers function/method bodies, class bodies,\n * `if`/`for`/`while` blocks, modules, namespaces.\n * - Object & array literals — covers JSON-shaped data and JSX style props.\n * - JSX elements & fragments — open/close tags fold like HTML.\n * - Template literals — fold multi-line backtick strings (including tagged).\n * - Switch statements — VS Code folds the whole `switch (…) { … }`, not each case.\n */\nconst FOLDABLE_NODE_TYPES = new Set<string>([\n\t\"BlockStatement\",\n\t\"ClassBody\",\n\t\"ObjectExpression\",\n\t\"ObjectPattern\",\n\t\"ArrayExpression\",\n\t\"ArrayPattern\",\n\t\"JSXElement\",\n\t\"JSXFragment\",\n\t\"TemplateLiteral\",\n\t\"SwitchStatement\",\n\t// TypeScript-only:\n\t\"TSInterfaceBody\",\n\t\"TSTypeLiteral\",\n\t\"TSEnumBody\",\n\t\"TSEnumDeclaration\",\n\t\"TSModuleBlock\",\n\t\"TSMappedType\",\n]);\n\n/** Returns the `openingElement` of a `JSXElement` if present (the `<Foo …>` span). */\nfunction jsxOpeningElement(node: AstNode): AstNode | undefined {\n\tif (node.type !== \"JSXElement\") {\n\t\treturn undefined;\n\t}\n\tconst opening = node.openingElement;\n\treturn isAstNode(opening) ? opening : undefined;\n}\n\n/** Returns true when a `JSXOpeningElement` is self-closing (`<Foo/>`). */\nfunction isSelfClosingOpening(opening: AstNode): boolean {\n\treturn opening.selfClosing === true;\n}\n\n/**\n * Recursively walks every AST node reachable from `root`, calling `visit`\n * with each one. Mirrors the helper used in the Vite plugin but stays local\n * so this module has no extra cross-package dependency.\n */\nfunction walk(root: unknown, visit: (node: AstNode) => void): void {\n\tif (Array.isArray(root)) {\n\t\tfor (const item of root) {\n\t\t\twalk(item, visit);\n\t\t}\n\t\treturn;\n\t}\n\tif (!isAstNode(root)) {\n\t\treturn;\n\t}\n\tvisit(root);\n\tfor (const value of Object.values(root)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const item of value) {\n\t\t\t\twalk(item, visit);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (isAstNode(value)) {\n\t\t\twalk(value, visit);\n\t\t}\n\t}\n}\n\n/**\n * Filename passed to `oxc-parser` purely for diagnostic strings; the actual\n * grammar comes from the `lang` option on the parser options object.\n */\nconst SYNTHETIC_FILENAME = \"__mantle_fold__\";\n\n/**\n * Pushes a {@link FoldableRange} for the source span `[startOffset, endOffset]`\n * (inclusive) when it crosses a line boundary. Single-line spans contribute\n * nothing — there's nothing to fold.\n */\nfunction pushRange(\n\tranges: FoldableRange[],\n\tlineOffsets: readonly number[],\n\tstartOffset: number,\n\tendOffset: number,\n): void {\n\tconst startLine = offsetToLine(lineOffsets, startOffset);\n\tconst endLine = offsetToLine(lineOffsets, endOffset);\n\tif (endLine > startLine) {\n\t\tranges.push({ id: String(startLine), startLine, endLine });\n\t}\n}\n\n/**\n * Computes foldable ranges for a JS/TS/JSX/TSX source string by parsing it\n * with `oxc-parser` and walking the AST. Errors are tolerated — a partial AST\n * still produces useful folds.\n *\n * @example\n * computeJsxFoldRanges({ code: \"<Foo>\\n <Bar/>\\n</Foo>\", language: \"tsx\" });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeJsxFoldRanges({\n\tcode,\n\tlanguage,\n}: {\n\t/** Raw source code to parse and fold. */\n\tcode: string;\n\t/** Resolved Mantle language; controls grammar selection (TS vs JS, JSX vs plain). */\n\tlanguage: JsxFoldLanguage;\n}): FoldableRange[] {\n\tif (code.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst options: ParserOptions = {\n\t\t// `unambiguous` lets the parser accept both `script` and `module` code,\n\t\t// matching how a code block is rendered without `import`/`export` context.\n\t\tsourceType: \"unambiguous\",\n\t\tlang: oxcLangFor(language),\n\t};\n\tconst oxcParser = loadOxcParser();\n\tif (oxcParser == null) {\n\t\treturn [];\n\t}\n\tconst { parseSync } = oxcParser;\n\tconst parsed = parseSync(SYNTHETIC_FILENAME, code, options);\n\tconst lineOffsets = buildLineOffsets(code);\n\tconst ranges: FoldableRange[] = [];\n\n\twalk(parsed.program, (node) => {\n\t\t// JSX elements get split treatment so multi-line attribute lists fold\n\t\t// even on self-closing tags (which have no separate body to fold).\n\t\tif (node.type === \"JSXElement\") {\n\t\t\tconst opening = jsxOpeningElement(node);\n\t\t\tconst isSelfClosing = opening != null && isSelfClosingOpening(opening);\n\t\t\tif (isSelfClosing) {\n\t\t\t\t// Self-closing tags fold the open-tag span only — there's no\n\t\t\t\t// body. Diverges from VS Code's stock TS folder, which doesn't\n\t\t\t\t// fold these at all, but matches what JSX authors actually want\n\t\t\t\t// for long attribute lists across multiple lines.\n\t\t\t\tif (opening != null) {\n\t\t\t\t\tpushRange(ranges, lineOffsets, opening.start, opening.end - 1);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Non-self-closing: fold the whole element AND any multi-line\n\t\t\t// opening tag's attribute list. After dedup, when both share an\n\t\t\t// opener line, the larger element fold wins — but the open-tag\n\t\t\t// fold survives when it has its own opener line offset.\n\t\t\tpushRange(ranges, lineOffsets, node.start, node.end - 1);\n\t\t\tif (opening != null) {\n\t\t\t\tpushRange(ranges, lineOffsets, opening.start, opening.end - 1);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!FOLDABLE_NODE_TYPES.has(node.type)) {\n\t\t\treturn;\n\t\t}\n\t\tpushRange(ranges, lineOffsets, node.start, node.end - 1);\n\t});\n\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeJsxFoldRanges, createOxcParserLoader };\nexport type { JsxFoldLanguage };\n","import {\n\tfinalizeFoldRanges,\n\ttype FoldableRange,\n\ttype FoldLine,\n} from \"@ngrok/mantle/highlight-utils\";\n\n/**\n * Keyword-pair fold computer for languages whose blocks are delimited by\n * keywords rather than punctuation.\n *\n * VS Code models this with `foldingStartMarker` / `foldingStopMarker`\n * declarations in each language's `language-configuration.json`. We mirror\n * that behavior with linear marker predicates, evaluated against the\n * *visible* (non-string, non-comment) portion of each line — the Shiki tokens\n * carry scope information that lets us strip those out reliably.\n *\n * The stack is untyped — every closer pops the most recent opener, regardless\n * of which keyword opened it. Real source code nests properly, so this stays\n * correct without per-keyword tracking, and matches VS Code's marker-based\n * behavior.\n *\n * @see https://github.com/microsoft/vscode/blob/main/extensions/ruby/language-configuration.json\n * @see https://github.com/microsoft/vscode/blob/main/extensions/shellscript/language-configuration.json\n */\n\n/** Languages this computer knows how to fold. */\ntype KeywordFoldLanguage = \"ruby\" | \"rb\" | \"bash\" | \"sh\" | \"shell\";\n\n/**\n * Per-line opener/closer marker pair. The predicates intentionally match the\n * *visible* line content (after string and comment scopes are filtered out)\n * — interpolated `do … end` markers inside a string don't trigger folds.\n */\ntype KeywordPattern = {\n\t/** Returns true when this line opens a foldable block. */\n\tstartsFold: (visible: string) => boolean;\n\t/** Returns true when this line closes a foldable block. */\n\tendsFold: (visible: string) => boolean;\n};\n\nconst RUBY_START_KEYWORDS: readonly string[] = [\n\t\"def\",\n\t\"class\",\n\t\"module\",\n\t\"begin\",\n\t\"if\",\n\t\"unless\",\n\t\"while\",\n\t\"until\",\n\t\"for\",\n\t\"case\",\n];\nconst BASH_START_KEYWORDS: readonly string[] = [\"if\", \"while\", \"for\", \"case\", \"until\", \"select\"];\nconst BASH_END_KEYWORDS: readonly string[] = [\"fi\", \"esac\", \"done\"];\n\n/**\n * Ruby keyword folds modeled after VS Code's grammar. Covers:\n *\n * - Definition keywords at the start of a line: `def`, `class`, `module`, `begin`.\n * - Control-flow openers at the start of a line: `if`, `unless`, `while`,\n * `until`, `for`, `case` — Ruby's flagship multi-line constructs.\n * - Trailing `do` / `do |args|` for blocks attached to a method call.\n *\n * `end` always closes; mid-block keywords (`else`, `elsif`, `when`, `rescue`,\n * `ensure`) deliberately don't, so a single `if … else … end` becomes one\n * fold, not three.\n */\nconst RUBY_PATTERN: KeywordPattern = {\n\tstartsFold: rubyStartsFold,\n\tendsFold: (visible) => startsWithAnyWordAfterWhitespace(visible, [\"end\"]),\n};\n\n/**\n * Bash / Shell keyword folds modeled after VS Code's grammar.\n *\n * - Opener keywords at the start of a line — `if`, `while`, `for`, `case`,\n * `until`, `select` — that aren't closed by a same-line command marker.\n * - Lines ending with an unmatched `{` (function bodies, brace groups).\n * - Lines ending with `do` (the `for x in y; do` / `while cond; do` form).\n *\n * The end predicate matches `}` only when it leads its line — that lets us\n * close brace groups while ignoring `${VAR}` parameter expansions, which\n * are never line-leading.\n */\nconst BASH_PATTERN: KeywordPattern = {\n\tstartsFold: bashStartsFold,\n\tendsFold: bashEndsFold,\n};\n\n/** Returns true for ASCII identifier characters used by shell/Ruby keywords. */\nfunction isWordChar(character: number): boolean {\n\treturn (\n\t\t(character >= 48 && character <= 57) ||\n\t\t(character >= 65 && character <= 90) ||\n\t\t(character >= 97 && character <= 122) ||\n\t\tcharacter === 95\n\t);\n}\n\n/** Returns true for whitespace characters accepted around language markers. */\nfunction isWhitespaceChar(character: number): boolean {\n\treturn (\n\t\tcharacter === 9 ||\n\t\tcharacter === 10 ||\n\t\tcharacter === 11 ||\n\t\tcharacter === 12 ||\n\t\tcharacter === 13 ||\n\t\tcharacter === 32\n\t);\n}\n\n/** Returns the index of the first non-whitespace character in `text`. */\nfunction firstNonWhitespaceIndex(text: string): number {\n\tlet index = 0;\n\twhile (index < text.length && isWhitespaceChar(text.charCodeAt(index))) {\n\t\tindex += 1;\n\t}\n\treturn index;\n}\n\n/** Returns the exclusive index after the last non-whitespace character. */\nfunction endTrimmedIndex(text: string): number {\n\tlet index = text.length;\n\twhile (index > 0 && isWhitespaceChar(text.charCodeAt(index - 1))) {\n\t\tindex -= 1;\n\t}\n\treturn index;\n}\n\n/** Returns true if `word` appears at `index` with word boundaries. */\nfunction isWordAt(text: string, index: number, word: string, end = text.length): boolean {\n\tif (index < 0 || index + word.length > end) {\n\t\treturn false;\n\t}\n\tif (text.slice(index, index + word.length) !== word) {\n\t\treturn false;\n\t}\n\tconst beforeIsBoundary = index === 0 || !isWordChar(text.charCodeAt(index - 1));\n\tconst afterIndex = index + word.length;\n\tconst afterIsBoundary = afterIndex >= end || !isWordChar(text.charCodeAt(afterIndex));\n\treturn beforeIsBoundary && afterIsBoundary;\n}\n\n/** Returns true when a line begins with one of the given keywords. */\nfunction startsWithAnyWordAfterWhitespace(text: string, words: readonly string[]): boolean {\n\tconst index = firstNonWhitespaceIndex(text);\n\tfor (const word of words) {\n\t\tif (isWordAt(text, index, word)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Returns true when `index` is positioned where the shell can begin another\n * command word on the same physical line. This intentionally ignores ordinary\n * arguments and variables like `$done`, so `case $done in` still opens a fold.\n */\nfunction isShellCommandBoundary(text: string, index: number): boolean {\n\tlet cursor = index - 1;\n\twhile (cursor >= 0 && isWhitespaceChar(text.charCodeAt(cursor))) {\n\t\tcursor -= 1;\n\t}\n\tif (cursor < 0) {\n\t\treturn true;\n\t}\n\tconst previous = text.charCodeAt(cursor);\n\treturn previous === 38 || previous === 40 || previous === 59 || previous === 124;\n}\n\n/**\n * Returns true when a Bash closer appears as a same-line command marker, e.g.\n * `if ok; then echo hi; fi`. A single linear scan is cheaper than running one\n * regex per marker and keeps shell variables / arguments named `done`, `fi`,\n * or `esac` from suppressing valid opener folds.\n */\nfunction hasShellSameLineEndKeyword(text: string): boolean {\n\tfor (let index = 0; index < text.length; index += 1) {\n\t\tconst character = text.charCodeAt(index);\n\t\tif (!isWordChar(character)) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const word of BASH_END_KEYWORDS) {\n\t\t\tif (isWordAt(text, index, word) && isShellCommandBoundary(text, index)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\twhile (index + 1 < text.length && isWordChar(text.charCodeAt(index + 1))) {\n\t\t\tindex += 1;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Returns true when a line starts with a shell closer command. `done)` and\n * similar case labels are deliberately excluded; `)` is not a command\n * separator, so those labels should not pop the fold stack.\n */\nfunction startsWithShellEndKeyword(text: string): boolean {\n\tconst index = firstNonWhitespaceIndex(text);\n\tfor (const word of BASH_END_KEYWORDS) {\n\t\tif (!isWordAt(text, index, word)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst next = text.charCodeAt(index + word.length);\n\t\treturn (\n\t\t\tNumber.isNaN(next) || isWhitespaceChar(next) || next === 38 || next === 59 || next === 124\n\t\t);\n\t}\n\treturn false;\n}\n\n/** Returns true when a line ends with `word`, ignoring trailing whitespace. */\nfunction endsWithWord(text: string, word: string): boolean {\n\tconst end = endTrimmedIndex(text);\n\treturn isWordAt(text, end - word.length, word, end);\n}\n\n/** Returns true for trailing Ruby `do` / `do |args|` block openers. */\nfunction endsWithRubyDoBlock(text: string): boolean {\n\tlet end = endTrimmedIndex(text);\n\tif (end <= 0) {\n\t\treturn false;\n\t}\n\tif (text.charCodeAt(end - 1) === 124) {\n\t\tconst paramsStart = text.lastIndexOf(\"|\", end - 2);\n\t\tif (paramsStart === -1) {\n\t\t\treturn false;\n\t\t}\n\t\tend = paramsStart;\n\t\twhile (end > 0 && isWhitespaceChar(text.charCodeAt(end - 1))) {\n\t\t\tend -= 1;\n\t\t}\n\t}\n\treturn isWordAt(text, end - 2, \"do\", end);\n}\n\n/** Returns true when a Ruby line opens a keyword-paired block. */\nfunction rubyStartsFold(visible: string): boolean {\n\treturn (\n\t\tstartsWithAnyWordAfterWhitespace(visible, RUBY_START_KEYWORDS) || endsWithRubyDoBlock(visible)\n\t);\n}\n\n/** Returns true when a shell line has a `{` with no later `}` on the same line. */\nfunction endsWithOpenBrace(visible: string): boolean {\n\treturn visible.lastIndexOf(\"{\") > visible.lastIndexOf(\"}\");\n}\n\n/** Returns true when a Bash/Shell line opens a keyword-paired block. */\nfunction bashStartsFold(visible: string): boolean {\n\tif (\n\t\tstartsWithAnyWordAfterWhitespace(visible, BASH_START_KEYWORDS) &&\n\t\t!hasShellSameLineEndKeyword(visible)\n\t) {\n\t\treturn true;\n\t}\n\treturn endsWithOpenBrace(visible) || endsWithWord(visible, \"do\");\n}\n\n/** Returns true when a Bash/Shell line closes a keyword-paired block. */\nfunction bashEndsFold(visible: string): boolean {\n\tconst firstContent = firstNonWhitespaceIndex(visible);\n\treturn visible.charCodeAt(firstContent) === 125 || startsWithShellEndKeyword(visible);\n}\n\n/** Resolves the keyword pattern for a given language. */\nfunction patternFor(language: KeywordFoldLanguage): KeywordPattern {\n\tswitch (language) {\n\t\tcase \"ruby\":\n\t\tcase \"rb\":\n\t\t\treturn RUBY_PATTERN;\n\t\tcase \"bash\":\n\t\tcase \"sh\":\n\t\tcase \"shell\":\n\t\t\treturn BASH_PATTERN;\n\t}\n}\n\n/**\n * TextMate scope prefixes that mark a token as inert content (string body,\n * comment body, character escape). Mirrors the filter used by\n * `computeFoldRanges` for the bracket strategy so behaviors stay consistent.\n */\nconst INERT_SCOPE_PREFIXES: readonly string[] = [\n\t\"string.\",\n\t\"comment.\",\n\t\"constant.character.escape\",\n];\n\n/** Returns true when the innermost scope of a token marks it inert. */\nfunction isInertScope(scopes: readonly { scopeName: string }[]): boolean {\n\tif (scopes.length === 0) {\n\t\treturn false;\n\t}\n\tconst innermost = scopes[scopes.length - 1]?.scopeName ?? \"\";\n\tif (innermost === \"string\" || innermost === \"comment\") {\n\t\treturn true;\n\t}\n\tfor (const prefix of INERT_SCOPE_PREFIXES) {\n\t\tif (innermost.startsWith(prefix)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Reconstructs the visible (non-string, non-comment) text of a single\n * tokenized line.\n *\n * Subtlety: Shiki keeps leading whitespace inside `token.content` but strips\n * it from every `explanation.content` piece — so `\" HttpListener\"` (token)\n * decomposes into `[{ content: \"HttpListener\", scopes: […] }]`. Iterating\n * explanations alone collapses adjacent identifiers (`class HttpListener`\n * becomes `classHttpListener`), which breaks every word-boundary keyword\n * regex. We use `token.content` whenever no explanation piece is inert and\n * only fall back to per-explanation iteration for mixed-scope tokens.\n */\nfunction visibleTextForLine(line: FoldLine): string {\n\tlet visible = \"\";\n\tfor (const token of line) {\n\t\tconst explanations = token.explanation;\n\t\tif (explanations == null || explanations.length === 0) {\n\t\t\tvisible += token.content;\n\t\t\tcontinue;\n\t\t}\n\t\tlet hasInert = false;\n\t\tfor (const explanation of explanations) {\n\t\t\tif (isInertScope(explanation.scopes)) {\n\t\t\t\thasInert = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!hasInert) {\n\t\t\tvisible += token.content;\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const explanation of explanations) {\n\t\t\tif (isInertScope(explanation.scopes)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvisible += explanation.content;\n\t\t}\n\t}\n\treturn visible;\n}\n\n/**\n * Computes foldable ranges from tokenized source lines using the language's\n * keyword opener/closer regex pair.\n *\n * The same line can both open and close a block (`if foo; end` in Ruby).\n * Such lines push and pop on the stack but their start/end coincide, so the\n * range gets discarded by the `endLine > startLine` filter — matching how\n * the bracket strategy treats single-line `{}` constructs.\n *\n * @example\n * // tokens: [[\"def f\"], [\" pass\"], [\"end\"]]\n * computeKeywordFoldRanges({ language: \"ruby\", tokens });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeKeywordFoldRanges({\n\tlanguage,\n\ttokens,\n}: {\n\t/** Resolved Mantle language; controls which keyword pattern to use. */\n\tlanguage: KeywordFoldLanguage;\n\t/** Shiki-tokenized lines, with scope explanations populated. */\n\ttokens: FoldLine[];\n}): FoldableRange[] {\n\tconst pattern = patternFor(language);\n\tconst stack: number[] = [];\n\tconst ranges: FoldableRange[] = [];\n\n\tfor (let lineIndex = 0; lineIndex < tokens.length; lineIndex += 1) {\n\t\tconst line = tokens[lineIndex];\n\t\tif (line == null) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst visible = visibleTextForLine(line);\n\t\tif (visible.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst lineNumber = lineIndex + 1;\n\n\t\t// Closers come first: `end` on the same line as a `do` (e.g. `loop do\n\t\t// end` written across two lines but both `do` and `end` are on different\n\t\t// lines) shouldn't first push then pop on the same iteration.\n\t\tif (pattern.endsFold(visible)) {\n\t\t\tconst startLine = stack.pop();\n\t\t\tif (startLine != null && startLine < lineNumber) {\n\t\t\t\tranges.push({ id: String(startLine), startLine, endLine: lineNumber });\n\t\t\t}\n\t\t}\n\t\tif (pattern.startsFold(visible)) {\n\t\t\tstack.push(lineNumber);\n\t\t}\n\t}\n\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeKeywordFoldRanges };\nexport type { KeywordFoldLanguage };\n","import {\n\tcomputeFoldRanges,\n\tcomputeJsonFoldRanges,\n\tfinalizeFoldRanges,\n\ttype FoldableRange,\n\ttype FoldLine,\n\ttype SupportedLanguage,\n} from \"@ngrok/mantle/highlight-utils\";\nimport { computeCssFoldRanges } from \"./compute-css-fold-ranges.js\";\nimport { computeHtmlFoldRanges, type HtmlFoldLanguage } from \"./compute-html-fold-ranges.js\";\nimport { computeJsxFoldRanges, type JsxFoldLanguage } from \"./compute-jsx-fold-ranges.js\";\nimport {\n\tcomputeKeywordFoldRanges,\n\ttype KeywordFoldLanguage,\n} from \"./compute-keyword-fold-ranges.js\";\n\n/**\n * Server-side folding strategy applied to a language. This is a richer\n * dispatch than `@ngrok/mantle/highlight-utils`'s `foldStrategyFor`:\n *\n * - `jsx-ast` parses JS / TS / JSX / TSX with `oxc-parser`.\n * - `html-ast` parses HTML / XML with `parse5`.\n * - `css-raw` runs a CSS-aware single-pass brace matcher.\n * - `json-raw` reuses the existing `computeJsonFoldRanges` (raw, scope-free).\n * - `token-bracket` / `token-indentation` are the existing token-based\n * strategies for languages without a heavier parser (Go, Rust, Java, C#,\n * Python, YAML).\n * - `token-keyword` matches keyword openers / closers against tokenized line\n * text (Bash / Shell).\n * - `token-bracket-and-keyword` runs the bracket pass *and* the keyword pass\n * and merges them — Ruby uses brace-style blocks (`{ |x| … }`) plus\n * keyword blocks (`def … end`).\n * - `none` opts out for plain text and unknown languages.\n *\n * Strategies suffixed `-ast` or `-raw` need only the raw source string;\n * `token-*` strategies need Shiki-tokenized lines with scope explanations.\n */\ntype ServerFoldStrategy =\n\t| \"jsx-ast\"\n\t| \"html-ast\"\n\t| \"css-raw\"\n\t| \"json-raw\"\n\t| \"token-bracket\"\n\t| \"token-indentation\"\n\t| \"token-keyword\"\n\t| \"token-bracket-and-keyword\"\n\t| \"none\";\n\n/** Returns the server fold strategy for the given supported language. */\nfunction serverFoldStrategyFor(language: SupportedLanguage): ServerFoldStrategy {\n\tswitch (language) {\n\t\tcase \"javascript\":\n\t\tcase \"js\":\n\t\tcase \"typescript\":\n\t\tcase \"ts\":\n\t\tcase \"jsx\":\n\t\tcase \"tsx\":\n\t\t\treturn \"jsx-ast\";\n\t\tcase \"html\":\n\t\tcase \"xml\":\n\t\t\treturn \"html-ast\";\n\t\tcase \"css\":\n\t\t\treturn \"css-raw\";\n\t\tcase \"json\":\n\t\t\treturn \"json-raw\";\n\t\tcase \"python\":\n\t\tcase \"py\":\n\t\tcase \"yaml\":\n\t\tcase \"yml\":\n\t\t\treturn \"token-indentation\";\n\t\tcase \"ruby\":\n\t\tcase \"rb\":\n\t\t\treturn \"token-bracket-and-keyword\";\n\t\tcase \"bash\":\n\t\tcase \"sh\":\n\t\tcase \"shell\":\n\t\t\treturn \"token-keyword\";\n\t\tcase \"plain\":\n\t\tcase \"plaintext\":\n\t\tcase \"text\":\n\t\tcase \"txt\":\n\t\t\treturn \"none\";\n\t\tdefault:\n\t\t\treturn \"token-bracket\";\n\t}\n}\n\n/**\n * Returns true when the strategy needs Shiki-tokenized lines (with scope\n * explanations) to run. AST and raw-source strategies operate on the source\n * string directly and let us skip the `includeExplanation: 'scopeName'`\n * Shiki option, saving meaningful work on JS/TS/HTML/CSS hot paths.\n */\nfunction serverFoldNeedsTokens(strategy: ServerFoldStrategy): boolean {\n\tswitch (strategy) {\n\t\tcase \"token-bracket\":\n\t\tcase \"token-indentation\":\n\t\tcase \"token-keyword\":\n\t\tcase \"token-bracket-and-keyword\":\n\t\t\treturn true;\n\t\tcase \"jsx-ast\":\n\t\tcase \"html-ast\":\n\t\tcase \"css-raw\":\n\t\tcase \"json-raw\":\n\t\tcase \"none\":\n\t\t\treturn false;\n\t}\n}\n\n/** Type guard: narrows `SupportedLanguage` to languages handled by the JSX strategy. */\nfunction isJsxFoldLanguage(language: SupportedLanguage): language is JsxFoldLanguage {\n\treturn (\n\t\tlanguage === \"javascript\" ||\n\t\tlanguage === \"js\" ||\n\t\tlanguage === \"typescript\" ||\n\t\tlanguage === \"ts\" ||\n\t\tlanguage === \"jsx\" ||\n\t\tlanguage === \"tsx\"\n\t);\n}\n\n/** Type guard: narrows `SupportedLanguage` to languages handled by the HTML strategy. */\nfunction isHtmlFoldLanguage(language: SupportedLanguage): language is HtmlFoldLanguage {\n\treturn language === \"html\" || language === \"xml\";\n}\n\n/** Type guard: narrows `SupportedLanguage` to languages handled by the keyword strategy. */\nfunction isKeywordFoldLanguage(language: SupportedLanguage): language is KeywordFoldLanguage {\n\treturn (\n\t\tlanguage === \"ruby\" ||\n\t\tlanguage === \"rb\" ||\n\t\tlanguage === \"bash\" ||\n\t\tlanguage === \"sh\" ||\n\t\tlanguage === \"shell\"\n\t);\n}\n\n/**\n * Computes foldable ranges for a single highlighted code block, dispatching\n * to the appropriate strategy. Every supported language flows through here,\n * including the legacy token-based ones, so the engine has a single decision\n * point.\n *\n * Caller contract:\n * - For token-needing strategies, `tokens` must be the lines produced by\n * Shiki with `includeExplanation: 'scopeName'`. Pass `undefined` and the\n * strategy returns `[]`.\n * - For raw / AST strategies, `tokens` is ignored; only `code` matters.\n *\n * Errors raised by underlying parsers are caught and converted into \"no\n * folds\" — Shiki still gets to render the highlighted code, the gutter just\n * skips the toggle. We log nothing here because the engine is the wrong\n * layer to surface diagnostics.\n */\nfunction computeServerFoldRanges({\n\tcode,\n\tlanguage,\n\ttokens,\n}: {\n\t/** Normalized source code (post-`normalizeIndentation`). */\n\tcode: string;\n\t/** Resolved Mantle supported language. */\n\tlanguage: SupportedLanguage;\n\t/** Shiki-tokenized lines, when the strategy needs them. */\n\ttokens: FoldLine[] | undefined;\n}): FoldableRange[] {\n\tconst strategy = serverFoldStrategyFor(language);\n\ttry {\n\t\tswitch (strategy) {\n\t\t\tcase \"jsx-ast\":\n\t\t\t\tif (!isJsxFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeJsxFoldRanges({ code, language });\n\t\t\tcase \"html-ast\":\n\t\t\t\tif (!isHtmlFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeHtmlFoldRanges({ code, language });\n\t\t\tcase \"css-raw\":\n\t\t\t\treturn computeCssFoldRanges({ code });\n\t\t\tcase \"json-raw\":\n\t\t\t\treturn computeJsonFoldRanges(code);\n\t\t\tcase \"token-bracket\":\n\t\t\tcase \"token-indentation\":\n\t\t\t\tif (tokens == null) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeFoldRanges({ language, tokens });\n\t\t\tcase \"token-keyword\":\n\t\t\t\tif (tokens == null || !isKeywordFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeKeywordFoldRanges({ language, tokens });\n\t\t\tcase \"token-bracket-and-keyword\":\n\t\t\t\tif (tokens == null || !isKeywordFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn finalizeFoldRanges([\n\t\t\t\t\t...computeFoldRanges({ language, tokens }),\n\t\t\t\t\t...computeKeywordFoldRanges({ language, tokens }),\n\t\t\t\t]);\n\t\t\tcase \"none\":\n\t\t\t\treturn [];\n\t\t}\n\t} catch {\n\t\t// AST parsers throw on malformed input; falling back to no folds keeps\n\t\t// the rest of the highlight pipeline alive.\n\t\treturn [];\n\t}\n}\n\nexport {\n\t//,\n\tcomputeServerFoldRanges,\n\tserverFoldNeedsTokens,\n\tserverFoldStrategyFor,\n};\nexport type { ServerFoldStrategy };\n","import { createHash } from \"node:crypto\";\nimport type { createHighlighter } from \"shiki\";\nimport {\n\tdecorateHighlightedHtml,\n\tinferIndentation,\n\tisSupportedLanguage,\n\tnormalizeIndentation,\n\tparseLanguage,\n\ttype FoldLine,\n\ttype Indentation,\n\ttype LineRange,\n\ttype SupportedLanguage,\n} from \"@ngrok/mantle/highlight-utils\";\nimport { createLruCache } from \"./lru-cache.js\";\nimport {\n\tcomputeServerFoldRanges,\n\tserverFoldNeedsTokens,\n\tserverFoldStrategyFor,\n} from \"./server-fold-ranges.js\";\n\n/**\n * Shiki grammar IDs preloaded by Mantle's highlighting engine.\n * This list is shared by both Vite plugins and server-side highlighting routes.\n */\nconst mantleShikiLanguageGrammarIds = [\n\t\"bash\",\n\t\"csharp\",\n\t\"css\",\n\t\"go\",\n\t\"html\",\n\t\"java\",\n\t\"javascript\",\n\t\"json\",\n\t\"jsx\",\n\t\"python\",\n\t\"ruby\",\n\t\"rust\",\n\t\"shell\",\n\t\"terraform\",\n\t\"tsx\",\n\t\"typescript\",\n\t\"xml\",\n\t\"yaml\",\n] as const satisfies SupportedLanguage[];\n\n/**\n * Shared Shiki theme name used across Mantle highlighting.\n */\nconst mantleShikiThemeName = \"mantle-css-variables\" as const;\nconst mantleHighlightCacheMaxEntries = 1000;\n\ntype ShikiHighlighter = Awaited<ReturnType<typeof createHighlighter>>;\n\ntype MantleHighlightInput = {\n\t/**\n\t * Raw code string to highlight.\n\t */\n\tcode: string;\n\t/**\n\t * Language hint. Accepts supported language aliases and markdown-style values.\n\t */\n\tlanguage: SupportedLanguage | (string & {});\n\t/**\n\t * Optional indentation preference. Defaults to language-inferred indentation.\n\t */\n\tindentation?: Indentation;\n\t/**\n\t * Whether to render line numbers into the returned HTML.\n\t * @default true\n\t */\n\tshowLineNumbers?: boolean;\n\t/**\n\t * Optional list of highlighted line numbers/ranges to render into the returned HTML.\n\t * @default []\n\t */\n\thighlightLines?: (LineRange | number)[];\n\t/**\n\t * Start line number for rendered line numbers.\n\t * @default 1\n\t */\n\tlineNumberStart?: number;\n};\n\ntype MantleHighlightResult = {\n\t/**\n\t * Normalized source code used as the highlight input.\n\t */\n\tcode: string;\n\t/**\n\t * Highlighted HTML extracted from Shiki's `<code>...</code>`.\n\t */\n\thtml: string;\n\t/**\n\t * Resolved supported language used for highlighting.\n\t */\n\tlanguage: SupportedLanguage;\n\t/**\n\t * Whether returned HTML includes line numbers.\n\t */\n\tshowLineNumbers: boolean;\n\t/**\n\t * Highlighted line numbers/ranges applied to the returned HTML.\n\t */\n\thighlightLines: (LineRange | number)[];\n\t/**\n\t * Start line number used for rendered line numbers.\n\t */\n\tlineNumberStart: number;\n};\n\ntype MantleServerHighlighter = {\n\t/**\n\t * Highlight a code snippet and return normalized code + highlighted HTML.\n\t */\n\thighlight: (input: MantleHighlightInput) => Promise<MantleHighlightResult>;\n};\n\nlet highlighterPromise: Promise<ShikiHighlighter> | undefined;\nconst mantleHighlightCache = createLruCache<string, Promise<MantleHighlightResult>>(\n\tmantleHighlightCacheMaxEntries,\n);\n\n/**\n * Creates (and caches) Mantle's shared Shiki highlighter instance.\n */\nfunction getMantleShikiHighlighter(): Promise<ShikiHighlighter> {\n\tif (highlighterPromise != null) {\n\t\treturn highlighterPromise;\n\t}\n\n\thighlighterPromise = (async () => {\n\t\tconst { createCssVariablesTheme, createHighlighter } = await import(\"shiki\");\n\t\tconst cssVarsTheme = createCssVariablesTheme({ name: mantleShikiThemeName });\n\n\t\t// Append more granular token scope → CSS variable mappings.\n\t\t// More specific scopes override the defaults from createCssVariablesTheme.\n\t\t// Each uses a fallback to the original grouping variable for backwards compat.\n\t\tcssVarsTheme.tokenColors = [\n\t\t\t...(cssVarsTheme.tokenColors ?? []),\n\t\t\t{\n\t\t\t\tscope: [\"entity.name.type\", \"entity.name.class\", \"support.type\", \"support.class\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-type, var(--shiki-token-function))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"variable\", \"variable.parameter\", \"variable.other\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-variable, var(--shiki-foreground))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"keyword.operator\", \"keyword.operator.assignment\", \"keyword.operator.comparison\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-operator, var(--shiki-token-keyword))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"entity.other.attribute-name\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-attribute, var(--shiki-token-constant))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"meta.object-literal.key\", \"support.type.property-name\", \"entity.name.tag.yaml\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-property, var(--shiki-token-function))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"constant.character.escape\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-escape, var(--shiki-token-constant))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"string.unquoted.plain.out.yaml\", \"string.unquoted.plain.in.yaml\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-variable, var(--shiki-foreground))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"punctuation.definition.block.sequence.item.yaml\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-variable, var(--shiki-foreground))\" },\n\t\t\t},\n\t\t];\n\n\t\treturn createHighlighter({\n\t\t\tthemes: [cssVarsTheme],\n\t\t\tlangs: [...mantleShikiLanguageGrammarIds],\n\t\t});\n\t})().catch((error) => {\n\t\thighlighterPromise = undefined;\n\t\tthrow error;\n\t});\n\n\treturn highlighterPromise;\n}\n\n/**\n * Extracts the inner HTML from a Shiki `<code>...</code>` wrapper.\n */\nfunction extractHighlightedCodeInnerHtml(fullHtml: string): string | undefined {\n\treturn fullHtml.match(/<code[^>]*>([\\s\\S]*?)<\\/code>/)?.[1];\n}\n\n/**\n * Highlights code with Mantle's shared Shiki engine and normalization defaults.\n */\nasync function highlightWithMantleShiki(\n\tinput: MantleHighlightInput,\n): Promise<MantleHighlightResult> {\n\tconst resolvedLanguage = isSupportedLanguage(input.language)\n\t\t? input.language\n\t\t: parseLanguage(input.language);\n\tconst indentation = input.indentation ?? inferIndentation(resolvedLanguage, undefined);\n\tconst normalizedCode = normalizeIndentation(input.code, {\n\t\tindentation,\n\t});\n\tconst showLineNumbers = input.showLineNumbers ?? true;\n\tconst highlightLines = input.highlightLines ?? [];\n\tconst lineNumberStart = input.lineNumberStart ?? 1;\n\tconst cacheKey = createHash(\"sha1\")\n\t\t.update(normalizedCode)\n\t\t.update(\n\t\t\t`\\0${resolvedLanguage}\\0${showLineNumbers}\\0${lineNumberStart}\\0${JSON.stringify(highlightLines)}`,\n\t\t)\n\t\t.digest(\"hex\");\n\tconst cached = mantleHighlightCache.get(cacheKey);\n\tif (cached != null) {\n\t\treturn cached;\n\t}\n\n\tconst promise = (async () => {\n\t\tconst highlighter = await getMantleShikiHighlighter();\n\t\t// AST and raw-source fold strategies don't need token explanations, so\n\t\t// we skip the `includeExplanation` cost on the JS/TS/HTML/CSS hot path.\n\t\t// Token-based strategies (Python, Ruby, Go, …) still pay for it.\n\t\tconst foldStrategy = serverFoldStrategyFor(resolvedLanguage);\n\t\tconst wantsTokens = serverFoldNeedsTokens(foldStrategy);\n\t\tlet capturedTokens: FoldLine[] | undefined;\n\t\tconst fullHtml = highlighter.codeToHtml(normalizedCode, {\n\t\t\tlang: resolvedLanguage,\n\t\t\ttheme: mantleShikiThemeName,\n\t\t\tincludeExplanation: wantsTokens ? \"scopeName\" : false,\n\t\t\ttransformers: wantsTokens\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"mantle:capture-tokens\",\n\t\t\t\t\t\t\ttokens(tokens) {\n\t\t\t\t\t\t\t\tcapturedTokens = tokens;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: undefined,\n\t\t});\n\t\tconst baseHtml = extractHighlightedCodeInnerHtml(fullHtml);\n\n\t\tif (baseHtml == null) {\n\t\t\tthrow new Error(\"Failed to extract highlighted HTML from Shiki output\");\n\t\t}\n\t\tconst foldableRanges =\n\t\t\tfoldStrategy === \"none\"\n\t\t\t\t? undefined\n\t\t\t\t: computeServerFoldRanges({\n\t\t\t\t\t\tcode: normalizedCode,\n\t\t\t\t\t\tlanguage: resolvedLanguage,\n\t\t\t\t\t\ttokens: capturedTokens,\n\t\t\t\t\t});\n\t\tconst html = decorateHighlightedHtml({\n\t\t\tfoldableRanges,\n\t\t\thighlightLines,\n\t\t\thtml: baseHtml,\n\t\t\tlineNumberStart,\n\t\t\tshowLineNumbers,\n\t\t});\n\n\t\treturn {\n\t\t\tcode: normalizedCode,\n\t\t\thtml,\n\t\t\tlanguage: resolvedLanguage,\n\t\t\tshowLineNumbers,\n\t\t\thighlightLines,\n\t\t\tlineNumberStart,\n\t\t};\n\t})().catch((error) => {\n\t\tmantleHighlightCache.delete(cacheKey);\n\t\tthrow error;\n\t});\n\n\tmantleHighlightCache.set(cacheKey, promise);\n\treturn promise;\n}\n\n/**\n * Creates a reusable Mantle server highlighter facade for API routes.\n */\nfunction createMantleServerSyntaxHighlighter(): MantleServerHighlighter {\n\treturn {\n\t\thighlight: highlightWithMantleShiki,\n\t};\n}\n\nexport {\n\tcreateMantleServerSyntaxHighlighter,\n\textractHighlightedCodeInnerHtml,\n\tgetMantleShikiHighlighter,\n\thighlightWithMantleShiki,\n\tmantleHighlightCacheMaxEntries,\n\tmantleShikiLanguageGrammarIds,\n\tmantleShikiThemeName,\n};\nexport type { MantleHighlightInput, MantleHighlightResult, MantleServerHighlighter };\n"],"mappings":";;;;;;;AASA,SAAS,eAAqB,YAAoC;CACjE,IAAI,CAAC,OAAO,UAAU,UAAU,KAAK,cAAc,GAClD,MAAM,IAAI,MAAM,kDAAkD;CAInE,MAAM,sBAAM,IAAI,IAAqB;CAErC,OAAO;EACN,OAAO,KAAK;GACX,OAAO,IAAI,OAAO,GAAG;EACtB;EACA,IAAI,KAAK;GACR,MAAM,QAAQ,IAAI,IAAI,GAAG;GACzB,IAAI,SAAS,MACZ;GAGD,IAAI,OAAO,GAAG;GACd,IAAI,IAAI,KAAK,KAAK;GAClB,OAAO,MAAM;EACd;EACA,IAAI,KAAK,OAAO;GACf,IAAI,IAAI,IAAI,GAAG,GACd,IAAI,OAAO,GAAG;GAGf,IAAI,IAAI,KAAK,EAAE,MAAM,CAAC;GACtB,IAAI,IAAI,QAAQ,YACf;GAGD,MAAM,YAAY,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GACpC,IAAI,aAA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],"sources":["../src/lru-cache.ts","../src/compute-css-fold-ranges.ts","../src/compute-html-fold-ranges.ts","../src/line-offsets.ts","../src/compute-jsx-fold-ranges.ts","../src/compute-keyword-fold-ranges.ts","../src/server-fold-ranges.ts","../src/engine.ts"],"sourcesContent":["/** A simple least-recently-used cache backed by insertion-order `Map` semantics. */\ntype LruCache<K, V> = {\n\tdelete: (key: K) => boolean;\n\tget: (key: K) => V | undefined;\n\tset: (key: K, value: V) => void;\n\tsize: () => number;\n};\n\n/** Creates an LRU cache that evicts the least-recently-used entry when `maxEntries` is exceeded. */\nfunction createLruCache<K, V>(maxEntries: number): LruCache<K, V> {\n\tif (!Number.isInteger(maxEntries) || maxEntries <= 0) {\n\t\tthrow new Error(\"LRU cache maxEntries must be a positive integer.\");\n\t}\n\n\t// Why the `{ value }` box: `get` can tell a stored `undefined` from a missing key.\n\tconst map = new Map<K, { value: V }>();\n\n\treturn {\n\t\tdelete(key) {\n\t\t\treturn map.delete(key);\n\t\t},\n\t\tget(key) {\n\t\t\tconst entry = map.get(key);\n\t\t\tif (entry == null) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tmap.delete(key);\n\t\t\tmap.set(key, entry);\n\t\t\treturn entry.value;\n\t\t},\n\t\tset(key, value) {\n\t\t\tif (map.has(key)) {\n\t\t\t\tmap.delete(key);\n\t\t\t}\n\n\t\t\tmap.set(key, { value });\n\t\t\tif (map.size <= maxEntries) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oldestKey = map.keys().next().value;\n\t\t\tif (oldestKey != null) {\n\t\t\t\tmap.delete(oldestKey);\n\t\t\t}\n\t\t},\n\t\tsize() {\n\t\t\treturn map.size;\n\t\t},\n\t};\n}\n\nexport { createLruCache };\nexport type { LruCache };\n","import { finalizeFoldRanges, type FoldableRange } from \"@ngrok/mantle/highlight-utils\";\n\n/**\n * Raw-source fold computer for CSS — single-pass, parser-quality without a\n * parser dependency.\n *\n * Mirrors `computeJsonFoldRanges` but adds CSS-specific lexical features:\n *\n * - `/* … */` block comments are skipped wholesale.\n * - `\"…\"` and `'…'` string literals (including `\\\\` and `\\` escapes) are\n * skipped so braces inside `content: \"{ }\"` don't open folds.\n * - Backslash escapes outside of strings (CSS identifiers can use them) are\n * transparent — we just consume the next character.\n *\n * lightningcss is the project's preferred CSS parser, but its public visitor\n * API only surfaces *start* locations (`Location { line, column }`), not end\n * locations, which is what `FoldableRange.endLine` requires. Until upstream\n * exposes end spans we get the same correctness from a single-pass brace\n * matcher with a tiny CSS lexer — and skip the ~5MB native dep.\n *\n * @see https://github.com/parcel-bundler/lightningcss/issues/512\n */\n\n/**\n * Computes foldable ranges for a CSS source string. Each multi-line `{ … }`\n * (style rule, at-rule body, nested rule, keyframe selector) emits one range\n * with the opener and closer lines staying visible.\n *\n * Tolerant of malformed CSS — unmatched braces are dropped silently rather\n * than throwing, so a partial snippet still gets every fold it can. This\n * matches the behavior of `computeJsonFoldRanges` for JSON.\n *\n * @example\n * computeCssFoldRanges({ code: \".a {\\n color: red;\\n}\" });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeCssFoldRanges({\n\tcode,\n}: {\n\t/** Raw CSS source code to scan. */\n\tcode: string;\n}): FoldableRange[] {\n\tconst length = code.length;\n\tif (length === 0) {\n\t\treturn [];\n\t}\n\n\tconst stack: number[] = [];\n\tconst ranges: FoldableRange[] = [];\n\n\tlet line = 1;\n\tlet index = 0;\n\n\twhile (index < length) {\n\t\tconst character = code.charCodeAt(index);\n\n\t\tif (character === 10) {\n\t\t\tline += 1;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (character === 13) {\n\t\t\tline += 1;\n\t\t\tindex += 1;\n\t\t\tif (index < length && code.charCodeAt(index) === 10) {\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// `/* … */` block comment — CSS has no line comments in standard CSS.\n\t\tif (character === 47 && index + 1 < length && code.charCodeAt(index + 1) === 42) {\n\t\t\tindex += 2;\n\t\t\twhile (index < length) {\n\t\t\t\tconst commentChar = code.charCodeAt(index);\n\t\t\t\tif (commentChar === 10) {\n\t\t\t\t\tline += 1;\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (commentChar === 13) {\n\t\t\t\t\tline += 1;\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tif (index < length && code.charCodeAt(index) === 10) {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (commentChar === 42 && index + 1 < length && code.charCodeAt(index + 1) === 47) {\n\t\t\t\t\tindex += 2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// `\"…\"` or `'…'` string literal. CSS allows escaped newlines (`\\` followed\n\t\t// by a newline) which continue the string; treat any backslash as\n\t\t// \"skip the next char\" without bumping the line counter past it.\n\t\tif (character === 34 || character === 39) {\n\t\t\tconst quote = character;\n\t\t\tindex += 1;\n\t\t\twhile (index < length) {\n\t\t\t\tconst stringChar = code.charCodeAt(index);\n\t\t\t\tif (stringChar === 92) {\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tif (index >= length) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst escaped = code.charCodeAt(index);\n\t\t\t\t\tif (escaped === 10) {\n\t\t\t\t\t\tline += 1;\n\t\t\t\t\t} else if (escaped === 13) {\n\t\t\t\t\t\tline += 1;\n\t\t\t\t\t\tif (index + 1 < length && code.charCodeAt(index + 1) === 10) {\n\t\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (stringChar === quote) {\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (stringChar === 10) {\n\t\t\t\t\t// CSS strings normally can't span unescaped newlines; bail to\n\t\t\t\t\t// avoid swallowing the rest of the file when the quote is\n\t\t\t\t\t// stranded.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (character === 123) {\n\t\t\tstack.push(line);\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (character === 125) {\n\t\t\tconst startLine = stack.pop();\n\t\t\tif (startLine != null && startLine !== line) {\n\t\t\t\tranges.push({ id: String(startLine), startLine, endLine: line });\n\t\t\t}\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tindex += 1;\n\t}\n\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeCssFoldRanges };\n","import { finalizeFoldRanges, type FoldableRange } from \"@ngrok/mantle/highlight-utils\";\nimport { html, parse, parseFragment } from \"parse5\";\nimport type { DefaultTreeAdapterMap } from \"parse5\";\n\n/**\n * AST-based fold computer for HTML and XML.\n *\n * Uses `parse5` with `sourceCodeLocationInfo: true` so each element node carries\n * the line numbers of its open and close tags. Walking the tree gives us:\n *\n * - One fold per multi-line element (`<div>…</div>`).\n * - One fold per multi-line opening tag (`<div\\n class=\"x\"\\n>` — the\n * attribute list collapses).\n * - Correct void-element handling — parse5 already knows that `<br>`, `<img>`,\n * etc. don't open folds.\n * - Template content traversal — parse5 stores `<template>` descendants on a\n * separate `content` fragment, not on `childNodes`.\n * - String/comment scope filtering — angle brackets in `<!-- … -->` or\n * inside `\"…\"` attribute values aren't mistaken for tag openings.\n *\n * @see https://parse5.js.org/\n */\n\ntype HtmlFoldLanguage = \"html\" | \"xml\";\n\ntype Element = DefaultTreeAdapterMap[\"element\"];\ntype Node = DefaultTreeAdapterMap[\"node\"];\n\n/**\n * SVG-namespace URI used as a fragment context when parsing XML.\n *\n * In SVG context, `parse5` switches its tokenizer into \"foreign content\"\n * mode, which is much closer to XML semantics:\n *\n * - Self-closing `<foo/>` is honored.\n * - Element names are case-preserved.\n * - HTML-only void elements (`<br>`, `<img>`) are not auto-closed.\n *\n * That makes it acceptable as a stand-in XML parser for code blocks. The\n * caveat is that a few SVG-recognized names (`<title>`, `<desc>`, `<script>`,\n * `<style>`, `<foreignObject>`) revert to HTML rules inside their bodies; in\n * practice that's rare in user XML and yields conservative folding (still\n * correct, just sometimes more flat than VS Code's XML folder).\n */\nconst SVG_NAMESPACE = html.NS.SVG;\n\n/**\n * Synthetic SVG fragment context shared across XML parses. Only the namespace\n * matters for the foreign-content tokenizer mode; the rest of the fields\n * satisfy parse5's tree-adapter shape.\n */\nconst xmlFragmentContext: Element = {\n\tnodeName: \"svg\",\n\ttagName: \"svg\",\n\tnamespaceURI: SVG_NAMESPACE,\n\tattrs: [],\n\tchildNodes: [],\n\tparentNode: null,\n};\n\n/**\n * Returns true when a parse5 tree node has element-style `tagName` and child\n * nodes — i.e. it's an `Element` we should consider folding. Comments,\n * doctypes, text nodes, and the document root all fail this check.\n */\nfunction isElement(node: Node): node is Element {\n\treturn (\n\t\t\"tagName\" in node &&\n\t\ttypeof (node as { tagName?: unknown }).tagName === \"string\" &&\n\t\t\"childNodes\" in node\n\t);\n}\n\n/**\n * Traverses `root` depth-first and pushes a {@link FoldableRange} for every\n * element whose source span covers more than one line.\n *\n * Multi-line *elements* fold from the opening tag's start line to the closing\n * tag's end line (or to the element end when `endTag` info is unavailable —\n * parse5 sometimes synthesizes elements without a real closer when handling\n * malformed input).\n *\n * Multi-line *opening tags* (e.g. `<div\\n class=\"x\">`) fold from the start\n * of the tag to its `>` so the attribute list collapses into the tag name.\n * VS Code emits this as a separate \"tag\" fold marker; we mirror that.\n */\nfunction collectRanges(root: Node, ranges: FoldableRange[]): void {\n\tconst stack: Node[] = [root];\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop();\n\t\tif (node == null) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (isElement(node)) {\n\t\t\tpushRangesForElement(node, ranges);\n\t\t}\n\t\tpushChildNodes(node, stack);\n\n\t\t// parse5 models `<template>` descendants inside `node.content`, a\n\t\t// DocumentFragment, while `node.childNodes` stays empty. Include that\n\t\t// fragment so nested HTML in templates gets the same folds as normal\n\t\t// element children without recursing or re-walking the tree.\n\t\tif (\"content\" in node && typeof node.content === \"object\" && node.content != null) {\n\t\t\tpushChildNodes(node.content, stack);\n\t\t}\n\t}\n}\n\n/** Pushes parse5 child nodes onto the DFS stack in source order. */\nfunction pushChildNodes(parent: Node, stack: Node[]): void {\n\tif (!(\"childNodes\" in parent)) {\n\t\treturn;\n\t}\n\tconst childNodes = parent.childNodes;\n\tfor (let index = childNodes.length - 1; index >= 0; index -= 1) {\n\t\tconst child = childNodes[index];\n\t\tif (child != null) {\n\t\t\tstack.push(child);\n\t\t}\n\t}\n}\n\n/**\n * Emits up to two fold ranges for a single element: one for the element's\n * full body and one for its multi-line opening tag.\n */\nfunction pushRangesForElement(element: Element, ranges: FoldableRange[]): void {\n\tconst location = element.sourceCodeLocation;\n\tif (location == null) {\n\t\t// Implicit/synthetic elements (e.g. `<html>`/`<body>` parse5 fabricates\n\t\t// for fragment input) don't appear in the source. Skip them so we\n\t\t// don't emit folds without a real opener.\n\t\treturn;\n\t}\n\n\tconst startTag = location.startTag;\n\tconst endTag = location.endTag;\n\n\t// The element is a self-closing or void tag (no close tag in the source).\n\t// `<br>` HTML void elements and `<foo/>` XML self-closing tags both land\n\t// here; neither opens a fold.\n\tif (endTag == null) {\n\t\t// A multi-line single-tag element (`<input\\n type=\"text\"\\n/>`) still\n\t\t// gets the attribute-list fold below.\n\t\tpushTagFoldIfMultiline(startTag, ranges);\n\t\treturn;\n\t}\n\n\tconst startLine = location.startLine;\n\tconst endLine = location.endLine;\n\tif (endLine > startLine) {\n\t\tranges.push({ id: String(startLine), startLine, endLine });\n\t}\n\tpushTagFoldIfMultiline(startTag, ranges);\n}\n\n/**\n * Pushes a fold range for an opening tag (`startTag`) when its `<` and `>`\n * sit on different lines. Conservative: contributes nothing for single-line\n * tags so we don't fight `pushRangesForElement` for the same opener.\n */\nfunction pushTagFoldIfMultiline(\n\tstartTag: { startLine: number; endLine: number } | undefined,\n\tranges: FoldableRange[],\n): void {\n\tif (startTag == null) {\n\t\treturn;\n\t}\n\tif (startTag.endLine > startTag.startLine) {\n\t\tranges.push({\n\t\t\tid: String(startTag.startLine),\n\t\t\tstartLine: startTag.startLine,\n\t\t\tendLine: startTag.endLine,\n\t\t});\n\t}\n}\n\n/**\n * Computes foldable ranges for an HTML or XML source string.\n *\n * - HTML: uses `parse5.parse` so explicit `<html>`/`<head>`/`<body>` are\n * honored as foldable openers. Implicit wrappers parse5 fabricates for\n * fragment input have no `sourceCodeLocation` and are skipped.\n * - XML: uses `parse5.parseFragment` rooted in an SVG fragment context so the\n * tokenizer applies foreign-content (XML-like) rules — self-closing `<foo/>`\n * is respected, void HTML elements aren't special-cased.\n *\n * @example\n * computeHtmlFoldRanges({ code: \"<div>\\n <p>hi</p>\\n</div>\", language: \"html\" });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeHtmlFoldRanges({\n\tcode,\n\tlanguage,\n}: {\n\t/** Raw source code to parse. */\n\tcode: string;\n\t/** Resolved Mantle language; selects HTML vs. XML parsing rules. */\n\tlanguage: HtmlFoldLanguage;\n}): FoldableRange[] {\n\tif (code.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst document =\n\t\tlanguage === \"xml\"\n\t\t\t? parseFragment(xmlFragmentContext, code, { sourceCodeLocationInfo: true })\n\t\t\t: parse(code, { sourceCodeLocationInfo: true });\n\n\tconst ranges: FoldableRange[] = [];\n\tcollectRanges(document, ranges);\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeHtmlFoldRanges };\nexport type { HtmlFoldLanguage };\n","/**\n * Helpers for converting parser byte offsets into 1-indexed line numbers.\n *\n * Every AST-based fold strategy in this package speaks line numbers (because\n * `FoldableRange.startLine` / `endLine` are line-anchored), but parsers like\n * `oxc-parser` and `postcss` report offsets / line+col tuples derived from\n * byte positions. Building a single sorted `lineOffsets` array up front keeps\n * the per-node lookup `O(log n)` instead of rescanning the source each call.\n */\n\n/**\n * Returns an array where index `i` holds the byte offset of the start of\n * the `i + 1`-th line of `source`. The first entry is always `0`.\n *\n * Treats `\\n`, `\\r\\n`, and bare `\\r` as line breaks so it agrees with how\n * Shiki, oxc, parse5, and postcss split lines (they all match the JS\n * runtime's `String.prototype.split(/\\r\\n|\\r|\\n/)` behavior in practice).\n */\nfunction buildLineOffsets(source: string): number[] {\n\tconst offsets: number[] = [0];\n\tconst length = source.length;\n\tfor (let index = 0; index < length; index += 1) {\n\t\tconst character = source.charCodeAt(index);\n\t\tif (character === 10) {\n\t\t\toffsets.push(index + 1);\n\t\t\tcontinue;\n\t\t}\n\t\tif (character === 13) {\n\t\t\t// `\\r\\n` and bare `\\r` both start a new line at index + 1 (or + 2 when\n\t\t\t// followed by `\\n`); skip the `\\n` to avoid pushing a duplicate offset.\n\t\t\tconst isCrLf = index + 1 < length && source.charCodeAt(index + 1) === 10;\n\t\t\toffsets.push(isCrLf ? index + 2 : index + 1);\n\t\t\tif (isCrLf) {\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn offsets;\n}\n\n/**\n * Returns the 1-indexed line number that contains `offset` in the source\n * scanned by {@link buildLineOffsets}. Out-of-range offsets clamp to the\n * first or last line.\n */\nfunction offsetToLine(lineOffsets: readonly number[], offset: number): number {\n\tif (lineOffsets.length === 0) {\n\t\treturn 1;\n\t}\n\tif (offset <= 0) {\n\t\treturn 1;\n\t}\n\tlet low = 0;\n\tlet high = lineOffsets.length - 1;\n\twhile (low < high) {\n\t\t// Bias the midpoint toward `high` so the loop terminates when\n\t\t// `lineOffsets[mid] <= offset` repeatedly succeeds with `low === mid`.\n\t\tconst mid = (low + high + 1) >>> 1;\n\t\tconst start = lineOffsets[mid] ?? 0;\n\t\tif (start <= offset) {\n\t\t\tlow = mid;\n\t\t} else {\n\t\t\thigh = mid - 1;\n\t\t}\n\t}\n\treturn low + 1;\n}\n\nexport {\n\t//,\n\tbuildLineOffsets,\n\toffsetToLine,\n};\n","import { finalizeFoldRanges, type FoldableRange } from \"@ngrok/mantle/highlight-utils\";\nimport { createRequire } from \"node:module\";\nimport type * as OxcParserModule from \"oxc-parser\";\nimport type { ParserOptions } from \"oxc-parser\";\nimport { buildLineOffsets, offsetToLine } from \"./line-offsets.js\";\n\n/**\n * Loads `oxc-parser` lazily on first use. Eager `import` of oxc-parser runs\n * its napi-rs bootstrap (`bindings.js`), which `throw`s synchronously when the\n * platform-specific native binding (`@oxc-parser/binding-*`) isn't resolvable\n * — common on serverless hosts that ship the bundled JS without the binding\n * package alongside it. A throw at module-eval time would propagate through\n * the entire server bundle's import graph and 500 every route, not just\n * JSX/TSX folding. Deferring the load until folding runs lets this strategy\n * convert the failure into a cached \"no folds\" fallback while keeping every\n * other strategy working.\n */\ntype OxcParser = typeof OxcParserModule;\nconst requireOxc = createRequire(import.meta.url);\n\n/** Creates a memoized parser loader that caches both success and load failure. */\nfunction createOxcParserLoader(load: () => OxcParser): () => OxcParser | undefined {\n\tlet cachedOxcParser: OxcParser | undefined;\n\tlet didFailToLoadOxcParser = false;\n\n\treturn () => {\n\t\tif (cachedOxcParser != null) {\n\t\t\treturn cachedOxcParser;\n\t\t}\n\t\tif (didFailToLoadOxcParser) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlet oxcParser: OxcParser;\n\t\ttry {\n\t\t\toxcParser = load();\n\t\t} catch {\n\t\t\tdidFailToLoadOxcParser = true;\n\t\t\treturn undefined;\n\t\t}\n\t\tcachedOxcParser = oxcParser;\n\t\treturn oxcParser;\n\t};\n}\n\n/** Returns the lazily-resolved `oxc-parser` module, or undefined after a cached load failure. */\n// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- Why: `require` returns `any`, and the type-only import names its shape.\nconst loadOxcParser = createOxcParserLoader(() => requireOxc(\"oxc-parser\") as OxcParser);\n\n/**\n * AST-based fold computer for the JS/TS/JSX/TSX language family.\n *\n * Mirrors VS Code's TypeScript language service folder by walking the parsed\n * AST instead of pairing brackets in the token stream. This lets us fold\n * constructs that bracket-pairing can't see:\n *\n * - JSX elements (`<Foo>…</Foo>`, fragments, members like `<obj.Foo>`).\n * - Template literals that span multiple lines (including tagged templates).\n *\n * It also keeps every fold the bracket strategy used to give us — block\n * statements, object literals, array literals, class/interface bodies, switch\n * statements — without the per-character scope-walk cost.\n *\n * @see https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/folding.ts\n */\n\n/** Subset of supported languages handled by this computer. */\ntype JsxFoldLanguage = \"javascript\" | \"js\" | \"typescript\" | \"ts\" | \"jsx\" | \"tsx\";\n\n/**\n * Maps a Mantle language to the oxc-parser `lang` option. JavaScript keeps\n * JSX enabled so JSX-in-JS examples still fold, but TypeScript must stay in\n * plain `ts` mode: TSX parses generic arrow functions (`<T>(x: T) => ...`) as\n * JSX and drops the AST folds for otherwise-valid TypeScript snippets.\n */\nfunction oxcLangFor(language: JsxFoldLanguage): \"jsx\" | \"ts\" | \"tsx\" {\n\tswitch (language) {\n\t\tcase \"tsx\":\n\t\t\treturn \"tsx\";\n\t\tcase \"typescript\":\n\t\tcase \"ts\":\n\t\t\treturn \"ts\";\n\t\tcase \"jsx\":\n\t\tcase \"javascript\":\n\t\tcase \"js\":\n\t\t\treturn \"jsx\";\n\t}\n}\n\n/** Minimal AST node shape — every oxc node carries `type`, `start`, `end`. */\ntype AstNode = {\n\ttype: string;\n\tstart: number;\n\tend: number;\n\t[key: string]: unknown;\n};\n\n/** Type guard for an arbitrary value being an AST node. */\nfunction isAstNode(value: unknown): value is AstNode {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue != null &&\n\t\t\"type\" in value &&\n\t\ttypeof (value as { type?: unknown }).type === \"string\" &&\n\t\t\"start\" in value &&\n\t\ttypeof (value as { start?: unknown }).start === \"number\" &&\n\t\t\"end\" in value &&\n\t\ttypeof (value as { end?: unknown }).end === \"number\"\n\t);\n}\n\n/**\n * AST node types whose `start`/`end` positions delimit a foldable region\n * when they span multiple lines.\n *\n * Curated to match VS Code's TypeScript folder:\n * - Block-like statement bodies — covers function/method bodies, class bodies,\n * `if`/`for`/`while` blocks, modules, namespaces.\n * - Object & array literals — covers JSON-shaped data and JSX style props.\n * - JSX elements & fragments — open/close tags fold like HTML.\n * - Template literals — fold multi-line backtick strings (including tagged).\n * - Switch statements — VS Code folds the whole `switch (…) { … }`, not each case.\n */\nconst FOLDABLE_NODE_TYPES = new Set<string>([\n\t\"BlockStatement\",\n\t\"ClassBody\",\n\t\"ObjectExpression\",\n\t\"ObjectPattern\",\n\t\"ArrayExpression\",\n\t\"ArrayPattern\",\n\t\"JSXElement\",\n\t\"JSXFragment\",\n\t\"TemplateLiteral\",\n\t\"SwitchStatement\",\n\t// TypeScript-only:\n\t\"TSInterfaceBody\",\n\t\"TSTypeLiteral\",\n\t\"TSEnumBody\",\n\t\"TSEnumDeclaration\",\n\t\"TSModuleBlock\",\n\t\"TSMappedType\",\n]);\n\n/** Returns the `openingElement` of a `JSXElement` if present (the `<Foo …>` span). */\nfunction jsxOpeningElement(node: AstNode): AstNode | undefined {\n\tif (node.type !== \"JSXElement\") {\n\t\treturn undefined;\n\t}\n\tconst opening = node.openingElement;\n\treturn isAstNode(opening) ? opening : undefined;\n}\n\n/** Returns true when a `JSXOpeningElement` is self-closing (`<Foo/>`). */\nfunction isSelfClosingOpening(opening: AstNode): boolean {\n\treturn opening.selfClosing === true;\n}\n\n/**\n * Recursively walks every AST node reachable from `root`, calling `visit`\n * with each one. Mirrors the helper used in the Vite plugin but stays local\n * so this module has no extra cross-package dependency.\n */\nfunction walk(root: unknown, visit: (node: AstNode) => void): void {\n\tif (Array.isArray(root)) {\n\t\tfor (const item of root) {\n\t\t\twalk(item, visit);\n\t\t}\n\t\treturn;\n\t}\n\tif (!isAstNode(root)) {\n\t\treturn;\n\t}\n\tvisit(root);\n\tfor (const value of Object.values(root)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const item of value) {\n\t\t\t\twalk(item, visit);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (isAstNode(value)) {\n\t\t\twalk(value, visit);\n\t\t}\n\t}\n}\n\n/**\n * Filename passed to `oxc-parser` purely for diagnostic strings; the actual\n * grammar comes from the `lang` option on the parser options object.\n */\nconst SYNTHETIC_FILENAME = \"__mantle_fold__\";\n\n/**\n * Pushes a {@link FoldableRange} for the source span `[startOffset, endOffset]`\n * (inclusive) when it crosses a line boundary. Single-line spans contribute\n * nothing — there's nothing to fold.\n */\nfunction pushRange({\n\tranges,\n\tlineOffsets,\n\tstartOffset,\n\tendOffset,\n}: {\n\tranges: FoldableRange[];\n\tlineOffsets: readonly number[];\n\tstartOffset: number;\n\tendOffset: number;\n}): void {\n\tconst startLine = offsetToLine(lineOffsets, startOffset);\n\tconst endLine = offsetToLine(lineOffsets, endOffset);\n\tif (endLine > startLine) {\n\t\tranges.push({ id: String(startLine), startLine, endLine });\n\t}\n}\n\n/**\n * Computes foldable ranges for a JS/TS/JSX/TSX source string by parsing it\n * with `oxc-parser` and walking the AST. Errors are tolerated — a partial AST\n * still produces useful folds.\n *\n * @example\n * computeJsxFoldRanges({ code: \"<Foo>\\n <Bar/>\\n</Foo>\", language: \"tsx\" });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeJsxFoldRanges({\n\tcode,\n\tlanguage,\n}: {\n\t/** Raw source code to parse and fold. */\n\tcode: string;\n\t/** Resolved Mantle language; controls grammar selection (TS vs JS, JSX vs plain). */\n\tlanguage: JsxFoldLanguage;\n}): FoldableRange[] {\n\tif (code.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst options: ParserOptions = {\n\t\t// `unambiguous` lets the parser accept both `script` and `module` code,\n\t\t// matching how a code block is rendered without `import`/`export` context.\n\t\tsourceType: \"unambiguous\",\n\t\tlang: oxcLangFor(language),\n\t};\n\tconst oxcParser = loadOxcParser();\n\tif (oxcParser == null) {\n\t\treturn [];\n\t}\n\tconst { parseSync } = oxcParser;\n\tconst parsed = parseSync(SYNTHETIC_FILENAME, code, options);\n\tconst lineOffsets = buildLineOffsets(code);\n\tconst ranges: FoldableRange[] = [];\n\n\twalk(parsed.program, (node) => {\n\t\t// JSX elements get split treatment so multi-line attribute lists fold\n\t\t// even on self-closing tags (which have no separate body to fold).\n\t\tif (node.type === \"JSXElement\") {\n\t\t\tconst opening = jsxOpeningElement(node);\n\t\t\tconst isSelfClosing = opening != null && isSelfClosingOpening(opening);\n\t\t\tif (isSelfClosing) {\n\t\t\t\t// Self-closing tags fold the open-tag span only — there's no\n\t\t\t\t// body. Diverges from VS Code's stock TS folder, which doesn't\n\t\t\t\t// fold these at all, but matches what JSX authors actually want\n\t\t\t\t// for long attribute lists across multiple lines.\n\t\t\t\tif (opening != null) {\n\t\t\t\t\tpushRange({\n\t\t\t\t\t\tranges,\n\t\t\t\t\t\tlineOffsets,\n\t\t\t\t\t\tstartOffset: opening.start,\n\t\t\t\t\t\tendOffset: opening.end - 1,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Non-self-closing: fold the whole element AND any multi-line\n\t\t\t// opening tag's attribute list. After dedup, when both share an\n\t\t\t// opener line, the larger element fold wins — but the open-tag\n\t\t\t// fold survives when it has its own opener line offset.\n\t\t\tpushRange({ ranges, lineOffsets, startOffset: node.start, endOffset: node.end - 1 });\n\t\t\tif (opening != null) {\n\t\t\t\tpushRange({ ranges, lineOffsets, startOffset: opening.start, endOffset: opening.end - 1 });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!FOLDABLE_NODE_TYPES.has(node.type)) {\n\t\t\treturn;\n\t\t}\n\t\tpushRange({ ranges, lineOffsets, startOffset: node.start, endOffset: node.end - 1 });\n\t});\n\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport {\n\t//,\n\tcomputeJsxFoldRanges,\n\tcreateOxcParserLoader,\n};\nexport type { JsxFoldLanguage };\n","import {\n\tfinalizeFoldRanges,\n\ttype FoldableRange,\n\ttype FoldLine,\n} from \"@ngrok/mantle/highlight-utils\";\n\n/**\n * Keyword-pair fold computer for languages whose blocks are delimited by\n * keywords rather than punctuation.\n *\n * VS Code models this with `foldingStartMarker` / `foldingStopMarker`\n * declarations in each language's `language-configuration.json`. We mirror\n * that behavior with linear marker predicates, evaluated against the\n * *visible* (non-string, non-comment) portion of each line — the Shiki tokens\n * carry scope information that lets us strip those out reliably.\n *\n * The stack is untyped — every closer pops the most recent opener, regardless\n * of which keyword opened it. Real source code nests properly, so this stays\n * correct without per-keyword tracking, and matches VS Code's marker-based\n * behavior.\n *\n * @see https://github.com/microsoft/vscode/blob/main/extensions/ruby/language-configuration.json\n * @see https://github.com/microsoft/vscode/blob/main/extensions/shellscript/language-configuration.json\n */\n\n/** Languages this computer knows how to fold. */\ntype KeywordFoldLanguage = \"ruby\" | \"rb\" | \"bash\" | \"sh\" | \"shell\";\n\n/**\n * Per-line opener/closer marker pair. The predicates intentionally match the\n * *visible* line content (after string and comment scopes are filtered out)\n * — interpolated `do … end` markers inside a string don't trigger folds.\n */\ntype KeywordPattern = {\n\t/** Returns true when this line opens a foldable block. */\n\tstartsFold: (visible: string) => boolean;\n\t/** Returns true when this line closes a foldable block. */\n\tendsFold: (visible: string) => boolean;\n};\n\nconst RUBY_START_KEYWORDS: readonly string[] = [\n\t\"def\",\n\t\"class\",\n\t\"module\",\n\t\"begin\",\n\t\"if\",\n\t\"unless\",\n\t\"while\",\n\t\"until\",\n\t\"for\",\n\t\"case\",\n];\nconst BASH_START_KEYWORDS: readonly string[] = [\"if\", \"while\", \"for\", \"case\", \"until\", \"select\"];\nconst BASH_END_KEYWORDS: readonly string[] = [\"fi\", \"esac\", \"done\"];\n\n/**\n * Ruby keyword folds modeled after VS Code's grammar. Covers:\n *\n * - Definition keywords at the start of a line: `def`, `class`, `module`, `begin`.\n * - Control-flow openers at the start of a line: `if`, `unless`, `while`,\n * `until`, `for`, `case` — Ruby's flagship multi-line constructs.\n * - Trailing `do` / `do |args|` for blocks attached to a method call.\n *\n * `end` always closes; mid-block keywords (`else`, `elsif`, `when`, `rescue`,\n * `ensure`) deliberately don't, so a single `if … else … end` becomes one\n * fold, not three.\n */\nconst RUBY_PATTERN: KeywordPattern = {\n\tstartsFold: rubyStartsFold,\n\tendsFold: (visible) => startsWithAnyWordAfterWhitespace(visible, [\"end\"]),\n};\n\n/**\n * Bash / Shell keyword folds modeled after VS Code's grammar.\n *\n * - Opener keywords at the start of a line — `if`, `while`, `for`, `case`,\n * `until`, `select` — that aren't closed by a same-line command marker.\n * - Lines ending with an unmatched `{` (function bodies, brace groups).\n * - Lines ending with `do` (the `for x in y; do` / `while cond; do` form).\n *\n * The end predicate matches `}` only when it leads its line — that lets us\n * close brace groups while ignoring `${VAR}` parameter expansions, which\n * are never line-leading.\n */\nconst BASH_PATTERN: KeywordPattern = {\n\tstartsFold: bashStartsFold,\n\tendsFold: bashEndsFold,\n};\n\n/** Returns true for ASCII identifier characters used by shell/Ruby keywords. */\nfunction isWordChar(character: number): boolean {\n\treturn (\n\t\t(character >= 48 && character <= 57) ||\n\t\t(character >= 65 && character <= 90) ||\n\t\t(character >= 97 && character <= 122) ||\n\t\tcharacter === 95\n\t);\n}\n\n/** Returns true for whitespace characters accepted around language markers. */\nfunction isWhitespaceChar(character: number): boolean {\n\treturn (\n\t\tcharacter === 9 ||\n\t\tcharacter === 10 ||\n\t\tcharacter === 11 ||\n\t\tcharacter === 12 ||\n\t\tcharacter === 13 ||\n\t\tcharacter === 32\n\t);\n}\n\n/** Returns the index of the first non-whitespace character in `text`. */\nfunction firstNonWhitespaceIndex(text: string): number {\n\tlet index = 0;\n\twhile (index < text.length && isWhitespaceChar(text.charCodeAt(index))) {\n\t\tindex += 1;\n\t}\n\treturn index;\n}\n\n/** Returns the exclusive index after the last non-whitespace character. */\nfunction endTrimmedIndex(text: string): number {\n\tlet index = text.length;\n\twhile (index > 0 && isWhitespaceChar(text.charCodeAt(index - 1))) {\n\t\tindex -= 1;\n\t}\n\treturn index;\n}\n\n/** Returns true if `word` appears at `index` with word boundaries. */\nfunction isWordAt({\n\ttext,\n\tindex,\n\tword,\n\tend = text.length,\n}: {\n\ttext: string;\n\tindex: number;\n\tword: string;\n\t/** The exclusive end of the text to match against. Defaults to `text.length`. */\n\tend?: number;\n}): boolean {\n\tif (index < 0 || index + word.length > end) {\n\t\treturn false;\n\t}\n\tif (text.slice(index, index + word.length) !== word) {\n\t\treturn false;\n\t}\n\tconst beforeIsBoundary = index === 0 || !isWordChar(text.charCodeAt(index - 1));\n\tconst afterIndex = index + word.length;\n\tconst afterIsBoundary = afterIndex >= end || !isWordChar(text.charCodeAt(afterIndex));\n\treturn beforeIsBoundary && afterIsBoundary;\n}\n\n/** Returns true when a line begins with one of the given keywords. */\nfunction startsWithAnyWordAfterWhitespace(text: string, words: readonly string[]): boolean {\n\tconst index = firstNonWhitespaceIndex(text);\n\tfor (const word of words) {\n\t\tif (isWordAt({ text, index, word })) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Returns true when `index` is positioned where the shell can begin another\n * command word on the same physical line. This intentionally ignores ordinary\n * arguments and variables like `$done`, so `case $done in` still opens a fold.\n */\nfunction isShellCommandBoundary(text: string, index: number): boolean {\n\tlet cursor = index - 1;\n\twhile (cursor >= 0 && isWhitespaceChar(text.charCodeAt(cursor))) {\n\t\tcursor -= 1;\n\t}\n\tif (cursor < 0) {\n\t\treturn true;\n\t}\n\tconst previous = text.charCodeAt(cursor);\n\treturn previous === 38 || previous === 40 || previous === 59 || previous === 124;\n}\n\n/**\n * Returns true when a Bash closer appears as a same-line command marker, e.g.\n * `if ok; then echo hi; fi`. A single linear scan is cheaper than running one\n * regex per marker and keeps shell variables / arguments named `done`, `fi`,\n * or `esac` from suppressing valid opener folds.\n */\nfunction hasShellSameLineEndKeyword(text: string): boolean {\n\tfor (let index = 0; index < text.length; index += 1) {\n\t\tconst character = text.charCodeAt(index);\n\t\tif (!isWordChar(character)) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const word of BASH_END_KEYWORDS) {\n\t\t\tif (isWordAt({ text, index, word }) && isShellCommandBoundary(text, index)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\twhile (index + 1 < text.length && isWordChar(text.charCodeAt(index + 1))) {\n\t\t\tindex += 1;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Returns true when a line starts with a shell closer command. `done)` and\n * similar case labels are deliberately excluded; `)` is not a command\n * separator, so those labels should not pop the fold stack.\n */\nfunction startsWithShellEndKeyword(text: string): boolean {\n\tconst index = firstNonWhitespaceIndex(text);\n\tfor (const word of BASH_END_KEYWORDS) {\n\t\tif (!isWordAt({ text, index, word })) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst next = text.charCodeAt(index + word.length);\n\t\treturn (\n\t\t\tNumber.isNaN(next) || isWhitespaceChar(next) || next === 38 || next === 59 || next === 124\n\t\t);\n\t}\n\treturn false;\n}\n\n/** Returns true when a line ends with `word`, ignoring trailing whitespace. */\nfunction endsWithWord(text: string, word: string): boolean {\n\tconst end = endTrimmedIndex(text);\n\treturn isWordAt({ text, index: end - word.length, word, end });\n}\n\n/** Returns true for trailing Ruby `do` / `do |args|` block openers. */\nfunction endsWithRubyDoBlock(text: string): boolean {\n\tlet end = endTrimmedIndex(text);\n\tif (end <= 0) {\n\t\treturn false;\n\t}\n\tif (text.charCodeAt(end - 1) === 124) {\n\t\tconst paramsStart = text.lastIndexOf(\"|\", end - 2);\n\t\tif (paramsStart === -1) {\n\t\t\treturn false;\n\t\t}\n\t\tend = paramsStart;\n\t\twhile (end > 0 && isWhitespaceChar(text.charCodeAt(end - 1))) {\n\t\t\tend -= 1;\n\t\t}\n\t}\n\treturn isWordAt({ text, index: end - 2, word: \"do\", end });\n}\n\n/** Returns true when a Ruby line opens a keyword-paired block. */\nfunction rubyStartsFold(visible: string): boolean {\n\treturn (\n\t\tstartsWithAnyWordAfterWhitespace(visible, RUBY_START_KEYWORDS) || endsWithRubyDoBlock(visible)\n\t);\n}\n\n/** Returns true when a shell line has a `{` with no later `}` on the same line. */\nfunction endsWithOpenBrace(visible: string): boolean {\n\treturn visible.lastIndexOf(\"{\") > visible.lastIndexOf(\"}\");\n}\n\n/** Returns true when a Bash/Shell line opens a keyword-paired block. */\nfunction bashStartsFold(visible: string): boolean {\n\tif (\n\t\tstartsWithAnyWordAfterWhitespace(visible, BASH_START_KEYWORDS) &&\n\t\t!hasShellSameLineEndKeyword(visible)\n\t) {\n\t\treturn true;\n\t}\n\treturn endsWithOpenBrace(visible) || endsWithWord(visible, \"do\");\n}\n\n/** Returns true when a Bash/Shell line closes a keyword-paired block. */\nfunction bashEndsFold(visible: string): boolean {\n\tconst firstContent = firstNonWhitespaceIndex(visible);\n\treturn visible.charCodeAt(firstContent) === 125 || startsWithShellEndKeyword(visible);\n}\n\n/** Resolves the keyword pattern for a given language. */\nfunction patternFor(language: KeywordFoldLanguage): KeywordPattern {\n\tswitch (language) {\n\t\tcase \"ruby\":\n\t\tcase \"rb\":\n\t\t\treturn RUBY_PATTERN;\n\t\tcase \"bash\":\n\t\tcase \"sh\":\n\t\tcase \"shell\":\n\t\t\treturn BASH_PATTERN;\n\t}\n}\n\n/**\n * TextMate scope prefixes that mark a token as inert content (string body,\n * comment body, character escape). Mirrors the filter used by\n * `computeFoldRanges` for the bracket strategy so behaviors stay consistent.\n */\nconst INERT_SCOPE_PREFIXES: readonly string[] = [\n\t\"string.\",\n\t\"comment.\",\n\t\"constant.character.escape\",\n];\n\n/** Returns true when the innermost scope of a token marks it inert. */\nfunction isInertScope(scopes: readonly { scopeName: string }[]): boolean {\n\tif (scopes.length === 0) {\n\t\treturn false;\n\t}\n\tconst innermost = scopes[scopes.length - 1]?.scopeName ?? \"\";\n\tif (innermost === \"string\" || innermost === \"comment\") {\n\t\treturn true;\n\t}\n\tfor (const prefix of INERT_SCOPE_PREFIXES) {\n\t\tif (innermost.startsWith(prefix)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Reconstructs the visible (non-string, non-comment) text of a single\n * tokenized line.\n *\n * Subtlety: Shiki keeps leading whitespace inside `token.content` but strips\n * it from every `explanation.content` piece — so `\" HttpListener\"` (token)\n * decomposes into `[{ content: \"HttpListener\", scopes: […] }]`. Iterating\n * explanations alone collapses adjacent identifiers (`class HttpListener`\n * becomes `classHttpListener`), which breaks every word-boundary keyword\n * regex. We use `token.content` whenever no explanation piece is inert and\n * only fall back to per-explanation iteration for mixed-scope tokens.\n */\nfunction visibleTextForLine(line: FoldLine): string {\n\tlet visible = \"\";\n\tfor (const token of line) {\n\t\tconst explanations = token.explanation;\n\t\tif (explanations == null || explanations.length === 0) {\n\t\t\tvisible += token.content;\n\t\t\tcontinue;\n\t\t}\n\t\tlet hasInert = false;\n\t\tfor (const explanation of explanations) {\n\t\t\tif (isInertScope(explanation.scopes)) {\n\t\t\t\thasInert = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!hasInert) {\n\t\t\tvisible += token.content;\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const explanation of explanations) {\n\t\t\tif (isInertScope(explanation.scopes)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvisible += explanation.content;\n\t\t}\n\t}\n\treturn visible;\n}\n\n/**\n * Computes foldable ranges from tokenized source lines using the language's\n * keyword opener/closer regex pair.\n *\n * The same line can both open and close a block (`if foo; end` in Ruby).\n * Such lines push and pop on the stack but their start/end coincide, so the\n * range gets discarded by the `endLine > startLine` filter — matching how\n * the bracket strategy treats single-line `{}` constructs.\n *\n * @example\n * // tokens: [[\"def f\"], [\" pass\"], [\"end\"]]\n * computeKeywordFoldRanges({ language: \"ruby\", tokens });\n * // => [{ id: \"1\", startLine: 1, endLine: 3 }]\n */\nfunction computeKeywordFoldRanges({\n\tlanguage,\n\ttokens,\n}: {\n\t/** Resolved Mantle language; controls which keyword pattern to use. */\n\tlanguage: KeywordFoldLanguage;\n\t/** Shiki-tokenized lines, with scope explanations populated. */\n\ttokens: FoldLine[];\n}): FoldableRange[] {\n\tconst pattern = patternFor(language);\n\tconst stack: number[] = [];\n\tconst ranges: FoldableRange[] = [];\n\n\tfor (let lineIndex = 0; lineIndex < tokens.length; lineIndex += 1) {\n\t\tconst line = tokens[lineIndex];\n\t\tif (line == null) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst visible = visibleTextForLine(line);\n\t\tif (visible.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst lineNumber = lineIndex + 1;\n\n\t\t// Closers come first: `end` on the same line as a `do` (e.g. `loop do\n\t\t// end` written across two lines but both `do` and `end` are on different\n\t\t// lines) shouldn't first push then pop on the same iteration.\n\t\tif (pattern.endsFold(visible)) {\n\t\t\tconst startLine = stack.pop();\n\t\t\tif (startLine != null && startLine < lineNumber) {\n\t\t\t\tranges.push({ id: String(startLine), startLine, endLine: lineNumber });\n\t\t\t}\n\t\t}\n\t\tif (pattern.startsFold(visible)) {\n\t\t\tstack.push(lineNumber);\n\t\t}\n\t}\n\n\treturn finalizeFoldRanges(ranges);\n}\n\nexport { computeKeywordFoldRanges };\nexport type { KeywordFoldLanguage };\n","import {\n\tcomputeFoldRanges,\n\tcomputeJsonFoldRanges,\n\tfinalizeFoldRanges,\n\ttype FoldableRange,\n\ttype FoldLine,\n\ttype SupportedLanguage,\n} from \"@ngrok/mantle/highlight-utils\";\nimport { computeCssFoldRanges } from \"./compute-css-fold-ranges.js\";\nimport { computeHtmlFoldRanges, type HtmlFoldLanguage } from \"./compute-html-fold-ranges.js\";\nimport { computeJsxFoldRanges, type JsxFoldLanguage } from \"./compute-jsx-fold-ranges.js\";\nimport {\n\tcomputeKeywordFoldRanges,\n\ttype KeywordFoldLanguage,\n} from \"./compute-keyword-fold-ranges.js\";\n\n/**\n * Server-side folding strategy applied to a language. This is a richer\n * dispatch than `@ngrok/mantle/highlight-utils`'s `foldStrategyFor`:\n *\n * - `jsx-ast` parses JS / TS / JSX / TSX with `oxc-parser`.\n * - `html-ast` parses HTML / XML with `parse5`.\n * - `css-raw` runs a CSS-aware single-pass brace matcher.\n * - `json-raw` reuses the existing `computeJsonFoldRanges` (raw, scope-free).\n * - `token-bracket` / `token-indentation` are the existing token-based\n * strategies for languages without a heavier parser (Go, Rust, Java, C#,\n * Python, YAML).\n * - `token-keyword` matches keyword openers / closers against tokenized line\n * text (Bash / Shell).\n * - `token-bracket-and-keyword` runs the bracket pass *and* the keyword pass\n * and merges them — Ruby uses brace-style blocks (`{ |x| … }`) plus\n * keyword blocks (`def … end`).\n * - `none` opts out for plain text and unknown languages.\n *\n * Strategies suffixed `-ast` or `-raw` need only the raw source string;\n * `token-*` strategies need Shiki-tokenized lines with scope explanations.\n */\ntype ServerFoldStrategy =\n\t| \"jsx-ast\"\n\t| \"html-ast\"\n\t| \"css-raw\"\n\t| \"json-raw\"\n\t| \"token-bracket\"\n\t| \"token-indentation\"\n\t| \"token-keyword\"\n\t| \"token-bracket-and-keyword\"\n\t| \"none\";\n\n/** Returns the server fold strategy for the given supported language. */\nfunction serverFoldStrategyFor(language: SupportedLanguage): ServerFoldStrategy {\n\tswitch (language) {\n\t\tcase \"javascript\":\n\t\tcase \"js\":\n\t\tcase \"typescript\":\n\t\tcase \"ts\":\n\t\tcase \"jsx\":\n\t\tcase \"tsx\":\n\t\t\treturn \"jsx-ast\";\n\t\tcase \"html\":\n\t\tcase \"xml\":\n\t\t\treturn \"html-ast\";\n\t\tcase \"css\":\n\t\t\treturn \"css-raw\";\n\t\tcase \"json\":\n\t\t\treturn \"json-raw\";\n\t\tcase \"python\":\n\t\tcase \"py\":\n\t\tcase \"yaml\":\n\t\tcase \"yml\":\n\t\t\treturn \"token-indentation\";\n\t\tcase \"ruby\":\n\t\tcase \"rb\":\n\t\t\treturn \"token-bracket-and-keyword\";\n\t\tcase \"bash\":\n\t\tcase \"sh\":\n\t\tcase \"shell\":\n\t\t\treturn \"token-keyword\";\n\t\tcase \"plain\":\n\t\tcase \"plaintext\":\n\t\tcase \"text\":\n\t\tcase \"txt\":\n\t\t\treturn \"none\";\n\t\tdefault:\n\t\t\treturn \"token-bracket\";\n\t}\n}\n\n/**\n * Returns true when the strategy needs Shiki-tokenized lines (with scope\n * explanations) to run. AST and raw-source strategies operate on the source\n * string directly and let us skip the `includeExplanation: 'scopeName'`\n * Shiki option, saving meaningful work on JS/TS/HTML/CSS hot paths.\n */\nfunction serverFoldNeedsTokens(strategy: ServerFoldStrategy): boolean {\n\tswitch (strategy) {\n\t\tcase \"token-bracket\":\n\t\tcase \"token-indentation\":\n\t\tcase \"token-keyword\":\n\t\tcase \"token-bracket-and-keyword\":\n\t\t\treturn true;\n\t\tcase \"jsx-ast\":\n\t\tcase \"html-ast\":\n\t\tcase \"css-raw\":\n\t\tcase \"json-raw\":\n\t\tcase \"none\":\n\t\t\treturn false;\n\t}\n}\n\n/** Type guard: narrows `SupportedLanguage` to languages handled by the JSX strategy. */\nfunction isJsxFoldLanguage(language: SupportedLanguage): language is JsxFoldLanguage {\n\treturn (\n\t\tlanguage === \"javascript\" ||\n\t\tlanguage === \"js\" ||\n\t\tlanguage === \"typescript\" ||\n\t\tlanguage === \"ts\" ||\n\t\tlanguage === \"jsx\" ||\n\t\tlanguage === \"tsx\"\n\t);\n}\n\n/** Type guard: narrows `SupportedLanguage` to languages handled by the HTML strategy. */\nfunction isHtmlFoldLanguage(language: SupportedLanguage): language is HtmlFoldLanguage {\n\treturn language === \"html\" || language === \"xml\";\n}\n\n/** Type guard: narrows `SupportedLanguage` to languages handled by the keyword strategy. */\nfunction isKeywordFoldLanguage(language: SupportedLanguage): language is KeywordFoldLanguage {\n\treturn (\n\t\tlanguage === \"ruby\" ||\n\t\tlanguage === \"rb\" ||\n\t\tlanguage === \"bash\" ||\n\t\tlanguage === \"sh\" ||\n\t\tlanguage === \"shell\"\n\t);\n}\n\n/**\n * Computes foldable ranges for a single highlighted code block, dispatching\n * to the appropriate strategy. Every supported language flows through here,\n * including the legacy token-based ones, so the engine has a single decision\n * point.\n *\n * Caller contract:\n * - For token-needing strategies, `tokens` must be the lines produced by\n * Shiki with `includeExplanation: 'scopeName'`. Pass `undefined` and the\n * strategy returns `[]`.\n * - For raw / AST strategies, `tokens` is ignored; only `code` matters.\n *\n * Errors raised by underlying parsers are caught and converted into \"no\n * folds\" — Shiki still gets to render the highlighted code, the gutter just\n * skips the toggle. We log nothing here because the engine is the wrong\n * layer to surface diagnostics.\n */\nfunction computeServerFoldRanges({\n\tcode,\n\tlanguage,\n\ttokens,\n}: {\n\t/** Normalized source code (post-`normalizeIndentation`). */\n\tcode: string;\n\t/** Resolved Mantle supported language. */\n\tlanguage: SupportedLanguage;\n\t/** Shiki-tokenized lines, when the strategy needs them. */\n\ttokens: FoldLine[] | undefined;\n}): FoldableRange[] {\n\tconst strategy = serverFoldStrategyFor(language);\n\ttry {\n\t\tswitch (strategy) {\n\t\t\tcase \"jsx-ast\":\n\t\t\t\tif (!isJsxFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeJsxFoldRanges({ code, language });\n\t\t\tcase \"html-ast\":\n\t\t\t\tif (!isHtmlFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeHtmlFoldRanges({ code, language });\n\t\t\tcase \"css-raw\":\n\t\t\t\treturn computeCssFoldRanges({ code });\n\t\t\tcase \"json-raw\":\n\t\t\t\treturn computeJsonFoldRanges(code);\n\t\t\tcase \"token-bracket\":\n\t\t\tcase \"token-indentation\":\n\t\t\t\tif (tokens == null) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeFoldRanges({ language, tokens });\n\t\t\tcase \"token-keyword\":\n\t\t\t\tif (tokens == null || !isKeywordFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn computeKeywordFoldRanges({ language, tokens });\n\t\t\tcase \"token-bracket-and-keyword\":\n\t\t\t\tif (tokens == null || !isKeywordFoldLanguage(language)) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn finalizeFoldRanges([\n\t\t\t\t\t...computeFoldRanges({ language, tokens }),\n\t\t\t\t\t...computeKeywordFoldRanges({ language, tokens }),\n\t\t\t\t]);\n\t\t\tcase \"none\":\n\t\t\t\treturn [];\n\t\t}\n\t} catch {\n\t\t// AST parsers throw on malformed input; falling back to no folds keeps\n\t\t// the rest of the highlight pipeline alive.\n\t\treturn [];\n\t}\n}\n\nexport {\n\t//,\n\tcomputeServerFoldRanges,\n\tserverFoldNeedsTokens,\n\tserverFoldStrategyFor,\n};\nexport type { ServerFoldStrategy };\n","import { createHash } from \"node:crypto\";\nimport type { createHighlighter } from \"shiki\";\nimport {\n\tdecorateHighlightedHtml,\n\tinferIndentation,\n\tisSupportedLanguage,\n\tnormalizeIndentation,\n\tparseLanguage,\n\ttype FoldLine,\n\ttype Indentation,\n\ttype LineRange,\n\ttype SupportedLanguage,\n} from \"@ngrok/mantle/highlight-utils\";\nimport { createLruCache } from \"./lru-cache.js\";\nimport {\n\tcomputeServerFoldRanges,\n\tserverFoldNeedsTokens,\n\tserverFoldStrategyFor,\n} from \"./server-fold-ranges.js\";\n\n/**\n * Shiki grammar IDs preloaded by Mantle's highlighting engine.\n * This list is shared by both Vite plugins and server-side highlighting routes.\n */\nconst mantleShikiLanguageGrammarIds = [\n\t\"bash\",\n\t\"csharp\",\n\t\"css\",\n\t\"dotenv\",\n\t\"go\",\n\t\"html\",\n\t\"java\",\n\t\"javascript\",\n\t\"json\",\n\t\"jsx\",\n\t\"python\",\n\t\"ruby\",\n\t\"rust\",\n\t\"shell\",\n\t\"terraform\",\n\t\"tsx\",\n\t\"typescript\",\n\t\"xml\",\n\t\"yaml\",\n] as const satisfies SupportedLanguage[];\n\n/**\n * Shared Shiki theme name used across Mantle highlighting.\n */\nconst mantleShikiThemeName = \"mantle-css-variables\" as const;\nconst mantleHighlightCacheMaxEntries = 1000;\n\ntype ShikiHighlighter = Awaited<ReturnType<typeof createHighlighter>>;\n\ntype MantleHighlightInput = {\n\t/**\n\t * Raw code string to highlight.\n\t */\n\tcode: string;\n\t/**\n\t * Language hint. Accepts supported language aliases and markdown-style values.\n\t */\n\tlanguage: SupportedLanguage | (string & {});\n\t/**\n\t * Optional indentation preference. Defaults to language-inferred indentation.\n\t */\n\tindentation?: Indentation;\n\t/**\n\t * Whether to render line numbers into the returned HTML.\n\t * @default true\n\t */\n\tshowLineNumbers?: boolean;\n\t/**\n\t * Optional list of highlighted line numbers/ranges to render into the returned HTML.\n\t * @default []\n\t */\n\thighlightLines?: (LineRange | number)[];\n\t/**\n\t * Start line number for rendered line numbers.\n\t * @default 1\n\t */\n\tlineNumberStart?: number;\n};\n\ntype MantleHighlightResult = {\n\t/**\n\t * Normalized source code used as the highlight input.\n\t */\n\tcode: string;\n\t/**\n\t * Highlighted HTML extracted from Shiki's `<code>...</code>`.\n\t */\n\thtml: string;\n\t/**\n\t * Resolved supported language used for highlighting.\n\t */\n\tlanguage: SupportedLanguage;\n\t/**\n\t * Whether returned HTML includes line numbers.\n\t */\n\tshowLineNumbers: boolean;\n\t/**\n\t * Highlighted line numbers/ranges applied to the returned HTML.\n\t */\n\thighlightLines: (LineRange | number)[];\n\t/**\n\t * Start line number used for rendered line numbers.\n\t */\n\tlineNumberStart: number;\n};\n\ntype MantleServerHighlighter = {\n\t/**\n\t * Highlight a code snippet and return normalized code + highlighted HTML.\n\t */\n\thighlight: (input: MantleHighlightInput) => Promise<MantleHighlightResult>;\n};\n\nlet highlighterPromise: Promise<ShikiHighlighter> | undefined;\nconst mantleHighlightCache = createLruCache<string, Promise<MantleHighlightResult>>(\n\tmantleHighlightCacheMaxEntries,\n);\n\n/**\n * Creates (and caches) Mantle's shared Shiki highlighter instance.\n */\nfunction getMantleShikiHighlighter(): Promise<ShikiHighlighter> {\n\tif (highlighterPromise != null) {\n\t\treturn highlighterPromise;\n\t}\n\n\thighlighterPromise = (async () => {\n\t\tconst { createCssVariablesTheme, createHighlighter } = await import(\"shiki\");\n\t\tconst cssVarsTheme = createCssVariablesTheme({ name: mantleShikiThemeName });\n\n\t\t// Append more granular token scope → CSS variable mappings.\n\t\t// More specific scopes override the defaults from createCssVariablesTheme.\n\t\t// Each uses a fallback to the original grouping variable for backwards compat.\n\t\tcssVarsTheme.tokenColors = [\n\t\t\t...(cssVarsTheme.tokenColors ?? []),\n\t\t\t{\n\t\t\t\tscope: [\"entity.name.type\", \"entity.name.class\", \"support.type\", \"support.class\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-type, var(--shiki-token-function))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"variable\", \"variable.parameter\", \"variable.other\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-variable, var(--shiki-foreground))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"keyword.operator\", \"keyword.operator.assignment\", \"keyword.operator.comparison\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-operator, var(--shiki-token-keyword))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"entity.other.attribute-name\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-attribute, var(--shiki-token-constant))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"meta.object-literal.key\", \"support.type.property-name\", \"entity.name.tag.yaml\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-property, var(--shiki-token-function))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"constant.character.escape\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-escape, var(--shiki-token-constant))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"string.unquoted.plain.out.yaml\", \"string.unquoted.plain.in.yaml\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-variable, var(--shiki-foreground))\" },\n\t\t\t},\n\t\t\t{\n\t\t\t\tscope: [\"punctuation.definition.block.sequence.item.yaml\"],\n\t\t\t\tsettings: { foreground: \"var(--shiki-token-variable, var(--shiki-foreground))\" },\n\t\t\t},\n\t\t];\n\n\t\treturn createHighlighter({\n\t\t\tthemes: [cssVarsTheme],\n\t\t\tlangs: [...mantleShikiLanguageGrammarIds],\n\t\t});\n\t})().catch((error: unknown) => {\n\t\thighlighterPromise = undefined;\n\t\tthrow error;\n\t});\n\n\treturn highlighterPromise;\n}\n\n/**\n * Extracts the inner HTML from a Shiki `<code>...</code>` wrapper.\n */\nfunction extractHighlightedCodeInnerHtml(fullHtml: string): string | undefined {\n\treturn fullHtml.match(/<code[^>]*>([\\s\\S]*?)<\\/code>/)?.[1];\n}\n\n/**\n * Highlights code with Mantle's shared Shiki engine and normalization defaults.\n */\nasync function highlightWithMantleShiki(\n\tinput: MantleHighlightInput,\n): Promise<MantleHighlightResult> {\n\tconst resolvedLanguage = isSupportedLanguage(input.language)\n\t\t? input.language\n\t\t: parseLanguage(input.language);\n\tconst indentation = input.indentation ?? inferIndentation(resolvedLanguage, undefined);\n\tconst normalizedCode = normalizeIndentation(input.code, {\n\t\tindentation,\n\t});\n\tconst showLineNumbers = input.showLineNumbers ?? true;\n\tconst highlightLines = input.highlightLines ?? [];\n\tconst lineNumberStart = input.lineNumberStart ?? 1;\n\tconst cacheKey = createHash(\"sha1\")\n\t\t.update(normalizedCode)\n\t\t.update(\n\t\t\t`\\0${resolvedLanguage}\\0${showLineNumbers}\\0${lineNumberStart}\\0${JSON.stringify(highlightLines)}`,\n\t\t)\n\t\t.digest(\"hex\");\n\tconst cached = mantleHighlightCache.get(cacheKey);\n\tif (cached != null) {\n\t\treturn cached;\n\t}\n\n\tconst promise = (async () => {\n\t\tconst highlighter = await getMantleShikiHighlighter();\n\t\t// AST and raw-source fold strategies don't need token explanations, so\n\t\t// we skip the `includeExplanation` cost on the JS/TS/HTML/CSS hot path.\n\t\t// Token-based strategies (Python, Ruby, Go, …) still pay for it.\n\t\tconst foldStrategy = serverFoldStrategyFor(resolvedLanguage);\n\t\tconst wantsTokens = serverFoldNeedsTokens(foldStrategy);\n\t\tlet capturedTokens: FoldLine[] | undefined;\n\t\tconst fullHtml = highlighter.codeToHtml(normalizedCode, {\n\t\t\tlang: resolvedLanguage,\n\t\t\ttheme: mantleShikiThemeName,\n\t\t\tincludeExplanation: wantsTokens ? \"scopeName\" : false,\n\t\t\ttransformers: wantsTokens\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"mantle:capture-tokens\",\n\t\t\t\t\t\t\ttokens(tokens) {\n\t\t\t\t\t\t\t\tcapturedTokens = tokens;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: undefined,\n\t\t});\n\t\tconst baseHtml = extractHighlightedCodeInnerHtml(fullHtml);\n\n\t\tif (baseHtml == null) {\n\t\t\tthrow new Error(\"Failed to extract highlighted HTML from Shiki output\");\n\t\t}\n\t\tconst foldableRanges =\n\t\t\tfoldStrategy === \"none\"\n\t\t\t\t? undefined\n\t\t\t\t: computeServerFoldRanges({\n\t\t\t\t\t\tcode: normalizedCode,\n\t\t\t\t\t\tlanguage: resolvedLanguage,\n\t\t\t\t\t\ttokens: capturedTokens,\n\t\t\t\t\t});\n\t\tconst html = decorateHighlightedHtml({\n\t\t\tfoldableRanges,\n\t\t\thighlightLines,\n\t\t\thtml: baseHtml,\n\t\t\tlineNumberStart,\n\t\t\tshowLineNumbers,\n\t\t});\n\n\t\treturn {\n\t\t\tcode: normalizedCode,\n\t\t\thtml,\n\t\t\tlanguage: resolvedLanguage,\n\t\t\tshowLineNumbers,\n\t\t\thighlightLines,\n\t\t\tlineNumberStart,\n\t\t};\n\t})().catch((error: unknown) => {\n\t\tmantleHighlightCache.delete(cacheKey);\n\t\tthrow error;\n\t});\n\n\tmantleHighlightCache.set(cacheKey, promise);\n\treturn promise;\n}\n\n/**\n * Creates a reusable Mantle server highlighter facade for API routes.\n */\nfunction createMantleServerSyntaxHighlighter(): MantleServerHighlighter {\n\treturn {\n\t\thighlight: highlightWithMantleShiki,\n\t};\n}\n\nexport {\n\tcreateMantleServerSyntaxHighlighter,\n\textractHighlightedCodeInnerHtml,\n\tgetMantleShikiHighlighter,\n\thighlightWithMantleShiki,\n\tmantleHighlightCacheMaxEntries,\n\tmantleShikiLanguageGrammarIds,\n\tmantleShikiThemeName,\n};\nexport type {\n\t//,\n\tMantleHighlightInput,\n\tMantleHighlightResult,\n\tMantleServerHighlighter,\n};\n"],"mappings":";;;;;;;AASA,SAAS,eAAqB,YAAoC;CACjE,IAAI,CAAC,OAAO,UAAU,UAAU,KAAK,cAAc,GAClD,MAAM,IAAI,MAAM,kDAAkD;CAInE,MAAM,sBAAM,IAAI,IAAqB;CAErC,OAAO;EACN,OAAO,KAAK;GACX,OAAO,IAAI,OAAO,GAAG;EACtB;EACA,IAAI,KAAK;GACR,MAAM,QAAQ,IAAI,IAAI,GAAG;GACzB,IAAI,SAAS,MACZ;GAGD,IAAI,OAAO,GAAG;GACd,IAAI,IAAI,KAAK,KAAK;GAClB,OAAO,MAAM;EACd;EACA,IAAI,KAAK,OAAO;GACf,IAAI,IAAI,IAAI,GAAG,GACd,IAAI,OAAO,GAAG;GAGf,IAAI,IAAI,KAAK,EAAE,MAAM,CAAC;GACtB,IAAI,IAAI,QAAQ,YACf;GAGD,MAAM,YAAY,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GACpC,IAAI,aAAa,MAChB,IAAI,OAAO,SAAS;EAEtB;EACA,OAAO;GACN,OAAO,IAAI;EACZ;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACdA,SAAS,qBAAqB,EAC7B,QAImB;CACnB,MAAM,SAAS,KAAK;CACpB,IAAI,WAAW,GACd,OAAO,CAAC;CAGT,MAAM,QAAkB,CAAC;CACzB,MAAM,SAA0B,CAAC;CAE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.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "Server-side syntax highlighting for @ngrok/mantle, powered by Shiki.",
|
|
5
5
|
"homepage": "https://mantle.ngrok.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"oxc-parser": "0.
|
|
22
|
+
"oxc-parser": "0.156.0",
|
|
23
23
|
"parse5": "8.0.1",
|
|
24
24
|
"shiki": "4.5.0"
|
|
25
25
|
},
|