@ngrok/mantle-server-syntax-highlighter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ngrok
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ import { Indentation, LineRange, SupportedLanguage } from "@ngrok/mantle/highlight-utils";
2
+ import * as shiki from "shiki";
3
+
4
+ //#region src/engine.d.ts
5
+ /**
6
+ * Shiki grammar IDs preloaded by Mantle's highlighting engine.
7
+ * This list is shared by both Vite plugins and server-side highlighting routes.
8
+ */
9
+ declare const mantleShikiLanguageGrammarIds: ["bash", "csharp", "css", "go", "html", "java", "javascript", "json", "jsx", "python", "ruby", "rust", "shell", "tsx", "typescript", "xml", "yaml"];
10
+ /**
11
+ * Shared Shiki theme name used across Mantle highlighting.
12
+ */
13
+ declare const mantleShikiThemeName: "mantle-css-variables";
14
+ declare const mantleHighlightCacheMaxEntries = 1000;
15
+ type ShikiHighlighter = Awaited<ReturnType<(typeof shiki)["createHighlighter"]>>;
16
+ type MantleHighlightInput = {
17
+ /**
18
+ * Raw code string to highlight.
19
+ */
20
+ code: string;
21
+ /**
22
+ * Language hint. Accepts supported language aliases and markdown-style values.
23
+ */
24
+ language: SupportedLanguage | (string & {});
25
+ /**
26
+ * Optional indentation preference. Defaults to language-inferred indentation.
27
+ */
28
+ indentation?: Indentation;
29
+ /**
30
+ * Whether to render line numbers into the returned HTML.
31
+ * @default false
32
+ */
33
+ showLineNumbers?: boolean;
34
+ /**
35
+ * Optional list of highlighted line numbers/ranges to render into the returned HTML.
36
+ * @default []
37
+ */
38
+ highlightLines?: (LineRange | number)[];
39
+ /**
40
+ * Start line number for rendered line numbers.
41
+ * @default 1
42
+ */
43
+ lineNumberStart?: number;
44
+ };
45
+ type MantleHighlightResult = {
46
+ /**
47
+ * Normalized source code used as the highlight input.
48
+ */
49
+ code: string;
50
+ /**
51
+ * Highlighted HTML extracted from Shiki's `<code>...</code>`.
52
+ */
53
+ html: string;
54
+ /**
55
+ * Resolved supported language used for highlighting.
56
+ */
57
+ language: SupportedLanguage;
58
+ /**
59
+ * Whether returned HTML includes line numbers.
60
+ */
61
+ showLineNumbers: boolean;
62
+ /**
63
+ * Highlighted line numbers/ranges applied to the returned HTML.
64
+ */
65
+ highlightLines: (LineRange | number)[];
66
+ /**
67
+ * Start line number used for rendered line numbers.
68
+ */
69
+ lineNumberStart: number;
70
+ };
71
+ type MantleServerHighlighter = {
72
+ /**
73
+ * Highlight a code snippet and return normalized code + highlighted HTML.
74
+ */
75
+ highlight: (input: MantleHighlightInput) => Promise<MantleHighlightResult>;
76
+ };
77
+ /**
78
+ * Creates (and caches) Mantle's shared Shiki highlighter instance.
79
+ */
80
+ declare function getMantleShikiHighlighter(): Promise<ShikiHighlighter>;
81
+ /**
82
+ * Extracts the inner HTML from a Shiki `<code>...</code>` wrapper.
83
+ */
84
+ /**
85
+ * Highlights code with Mantle's shared Shiki engine and normalization defaults.
86
+ */
87
+ declare function highlightWithMantleShiki(input: MantleHighlightInput): Promise<MantleHighlightResult>;
88
+ /**
89
+ * Creates a reusable Mantle server highlighter facade for API routes.
90
+ */
91
+ declare function createMantleServerSyntaxHighlighter(): MantleServerHighlighter;
92
+ //#endregion
93
+ export { type MantleHighlightInput, type MantleHighlightResult, type MantleServerHighlighter, createMantleServerSyntaxHighlighter, getMantleShikiHighlighter, highlightWithMantleShiki, mantleHighlightCacheMaxEntries, mantleShikiLanguageGrammarIds, mantleShikiThemeName };
94
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,136 @@
1
+ import { createHash } from "node:crypto";
2
+ import { decorateHighlightedHtml, inferIndentation, isSupportedLanguage, normalizeIndentation, parseLanguage } from "@ngrok/mantle/highlight-utils";
3
+
4
+ //#region src/lru-cache.ts
5
+ /** Creates an LRU cache that evicts the least-recently-used entry when `maxEntries` is exceeded. */
6
+ function createLruCache(maxEntries) {
7
+ if (!Number.isInteger(maxEntries) || maxEntries <= 0) throw new Error("LRU cache maxEntries must be a positive integer.");
8
+ const map = /* @__PURE__ */ new Map();
9
+ return {
10
+ delete(key) {
11
+ return map.delete(key);
12
+ },
13
+ get(key) {
14
+ if (!map.has(key)) return;
15
+ const value = map.get(key);
16
+ map.delete(key);
17
+ map.set(key, value);
18
+ return value;
19
+ },
20
+ set(key, value) {
21
+ if (map.has(key)) map.delete(key);
22
+ map.set(key, value);
23
+ if (map.size <= maxEntries) return;
24
+ const oldestKey = map.keys().next().value;
25
+ if (oldestKey != null) map.delete(oldestKey);
26
+ },
27
+ size() {
28
+ return map.size;
29
+ }
30
+ };
31
+ }
32
+
33
+ //#endregion
34
+ //#region src/engine.ts
35
+ /**
36
+ * Shiki grammar IDs preloaded by Mantle's highlighting engine.
37
+ * This list is shared by both Vite plugins and server-side highlighting routes.
38
+ */
39
+ const mantleShikiLanguageGrammarIds = [
40
+ "bash",
41
+ "csharp",
42
+ "css",
43
+ "go",
44
+ "html",
45
+ "java",
46
+ "javascript",
47
+ "json",
48
+ "jsx",
49
+ "python",
50
+ "ruby",
51
+ "rust",
52
+ "shell",
53
+ "tsx",
54
+ "typescript",
55
+ "xml",
56
+ "yaml"
57
+ ];
58
+ /**
59
+ * Shared Shiki theme name used across Mantle highlighting.
60
+ */
61
+ const mantleShikiThemeName = "mantle-css-variables";
62
+ const mantleHighlightCacheMaxEntries = 1e3;
63
+ let highlighterPromise;
64
+ const mantleHighlightCache = createLruCache(mantleHighlightCacheMaxEntries);
65
+ /**
66
+ * Creates (and caches) Mantle's shared Shiki highlighter instance.
67
+ */
68
+ function getMantleShikiHighlighter() {
69
+ if (highlighterPromise != null) return highlighterPromise;
70
+ highlighterPromise = (async () => {
71
+ const { createCssVariablesTheme, createHighlighter } = await import("shiki");
72
+ return createHighlighter({
73
+ themes: [createCssVariablesTheme({ name: mantleShikiThemeName })],
74
+ langs: [...mantleShikiLanguageGrammarIds]
75
+ });
76
+ })().catch((error) => {
77
+ highlighterPromise = void 0;
78
+ throw error;
79
+ });
80
+ return highlighterPromise;
81
+ }
82
+ /**
83
+ * Extracts the inner HTML from a Shiki `<code>...</code>` wrapper.
84
+ */
85
+ function extractHighlightedCodeInnerHtml(fullHtml) {
86
+ return fullHtml.match(/<code[^>]*>([\s\S]*?)<\/code>/)?.[1];
87
+ }
88
+ /**
89
+ * Highlights code with Mantle's shared Shiki engine and normalization defaults.
90
+ */
91
+ async function highlightWithMantleShiki(input) {
92
+ const resolvedLanguage = isSupportedLanguage(input.language) ? input.language : parseLanguage(input.language);
93
+ const indentation = input.indentation ?? inferIndentation(resolvedLanguage, void 0);
94
+ const normalizedCode = normalizeIndentation(input.code, { indentation });
95
+ const showLineNumbers = input.showLineNumbers ?? false;
96
+ const highlightLines = input.highlightLines ?? [];
97
+ const lineNumberStart = input.lineNumberStart ?? 1;
98
+ const cacheKey = createHash("sha1").update(normalizedCode).update(`\0${resolvedLanguage}\0${showLineNumbers}\0${lineNumberStart}\0${JSON.stringify(highlightLines)}`).digest("hex");
99
+ const cached = mantleHighlightCache.get(cacheKey);
100
+ if (cached != null) return cached;
101
+ const promise = (async () => {
102
+ const baseHtml = extractHighlightedCodeInnerHtml((await getMantleShikiHighlighter()).codeToHtml(normalizedCode, {
103
+ lang: resolvedLanguage,
104
+ theme: mantleShikiThemeName
105
+ }));
106
+ if (baseHtml == null) throw new Error("Failed to extract highlighted HTML from Shiki output");
107
+ return {
108
+ code: normalizedCode,
109
+ html: decorateHighlightedHtml({
110
+ highlightLines,
111
+ html: baseHtml,
112
+ lineNumberStart,
113
+ showLineNumbers
114
+ }),
115
+ language: resolvedLanguage,
116
+ showLineNumbers,
117
+ highlightLines,
118
+ lineNumberStart
119
+ };
120
+ })().catch((error) => {
121
+ mantleHighlightCache.delete(cacheKey);
122
+ throw error;
123
+ });
124
+ mantleHighlightCache.set(cacheKey, promise);
125
+ return promise;
126
+ }
127
+ /**
128
+ * Creates a reusable Mantle server highlighter facade for API routes.
129
+ */
130
+ function createMantleServerSyntaxHighlighter() {
131
+ return { highlight: highlightWithMantleShiki };
132
+ }
133
+
134
+ //#endregion
135
+ export { createMantleServerSyntaxHighlighter, getMantleShikiHighlighter, highlightWithMantleShiki, mantleHighlightCacheMaxEntries, mantleShikiLanguageGrammarIds, mantleShikiThemeName };
136
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lru-cache.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\tconst map = new Map<K, 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\tif (!map.has(key)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst value = map.get(key) as V;\n\t\t\tmap.delete(key);\n\t\t\tmap.set(key, value);\n\t\t\treturn 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 as K | undefined;\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 { createHash } from \"node:crypto\";\nimport {\n\tdecorateHighlightedHtml,\n\tinferIndentation,\n\tisSupportedLanguage,\n\tnormalizeIndentation,\n\tparseLanguage,\n\ttype Indentation,\n\ttype LineRange,\n\ttype SupportedLanguage,\n} from \"@ngrok/mantle/highlight-utils\";\nimport { createLruCache } from \"./lru-cache.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\"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 import(\"shiki\"))[\"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 false\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\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 ?? false;\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\tconst fullHtml = highlighter.codeToHtml(normalizedCode, {\n\t\t\tlang: resolvedLanguage,\n\t\t\ttheme: mantleShikiThemeName,\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 html = decorateHighlightedHtml({\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;AACjE,KAAI,CAAC,OAAO,UAAU,WAAW,IAAI,cAAc,EAClD,OAAM,IAAI,MAAM,mDAAmD;CAGpE,MAAM,sBAAM,IAAI,KAAW;AAE3B,QAAO;EACN,OAAO,KAAK;AACX,UAAO,IAAI,OAAO,IAAI;;EAEvB,IAAI,KAAK;AACR,OAAI,CAAC,IAAI,IAAI,IAAI,CAChB;GAGD,MAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,OAAI,OAAO,IAAI;AACf,OAAI,IAAI,KAAK,MAAM;AACnB,UAAO;;EAER,IAAI,KAAK,OAAO;AACf,OAAI,IAAI,IAAI,IAAI,CACf,KAAI,OAAO,IAAI;AAGhB,OAAI,IAAI,KAAK,MAAM;AACnB,OAAI,IAAI,QAAQ,WACf;GAGD,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC;AACpC,OAAI,aAAa,KAChB,KAAI,OAAO,UAAU;;EAGvB,OAAO;AACN,UAAO,IAAI;;EAEZ;;;;;;;;;AC/BF,MAAM,gCAAgC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;AAKD,MAAM,uBAAuB;AAC7B,MAAM,iCAAiC;AAoEvC,IAAI;AACJ,MAAM,uBAAuB,eAC5B,+BACA;;;;AAKD,SAAS,4BAAuD;AAC/D,KAAI,sBAAsB,KACzB,QAAO;AAGR,uBAAsB,YAAY;EACjC,MAAM,EAAE,yBAAyB,sBAAsB,MAAM,OAAO;AAEpE,SAAO,kBAAkB;GACxB,QAAQ,CAFY,wBAAwB,EAAE,MAAM,sBAAsB,CAAC,CAErD;GACtB,OAAO,CAAC,GAAG,8BAA8B;GACzC,CAAC;KACC,CAAC,OAAO,UAAU;AACrB,uBAAqB;AACrB,QAAM;GACL;AAEF,QAAO;;;;;AAMR,SAAS,gCAAgC,UAAsC;AAC9E,QAAO,SAAS,MAAM,gCAAgC,GAAG;;;;;AAM1D,eAAe,yBACd,OACiC;CACjC,MAAM,mBAAmB,oBAAoB,MAAM,SAAS,GACzD,MAAM,WACN,cAAc,MAAM,SAAS;CAChC,MAAM,cAAc,MAAM,eAAe,iBAAiB,kBAAkB,OAAU;CACtF,MAAM,iBAAiB,qBAAqB,MAAM,MAAM,EACvD,aACA,CAAC;CACF,MAAM,kBAAkB,MAAM,mBAAmB;CACjD,MAAM,iBAAiB,MAAM,kBAAkB,EAAE;CACjD,MAAM,kBAAkB,MAAM,mBAAmB;CACjD,MAAM,WAAW,WAAW,OAAO,CACjC,OAAO,eAAe,CACtB,OACA,KAAK,iBAAiB,IAAI,gBAAgB,IAAI,gBAAgB,IAAI,KAAK,UAAU,eAAe,GAChG,CACA,OAAO,MAAM;CACf,MAAM,SAAS,qBAAqB,IAAI,SAAS;AACjD,KAAI,UAAU,KACb,QAAO;CAGR,MAAM,WAAW,YAAY;EAM5B,MAAM,WAAW,iCALG,MAAM,2BAA2B,EACxB,WAAW,gBAAgB;GACvD,MAAM;GACN,OAAO;GACP,CAAC,CACwD;AAE1D,MAAI,YAAY,KACf,OAAM,IAAI,MAAM,uDAAuD;AASxE,SAAO;GACN,MAAM;GACN,MATY,wBAAwB;IACpC;IACA,MAAM;IACN;IACA;IACA,CAAC;GAKD,UAAU;GACV;GACA;GACA;GACA;KACE,CAAC,OAAO,UAAU;AACrB,uBAAqB,OAAO,SAAS;AACrC,QAAM;GACL;AAEF,sBAAqB,IAAI,UAAU,QAAQ;AAC3C,QAAO;;;;;AAMR,SAAS,sCAA+D;AACvE,QAAO,EACN,WAAW,0BACX"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@ngrok/mantle-server-syntax-highlighter",
3
+ "version": "1.0.0",
4
+ "description": "Server-side syntax highlighting for @ngrok/mantle, powered by Shiki.",
5
+ "homepage": "https://mantle.ngrok.com",
6
+ "license": "MIT",
7
+ "author": "ngrok",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/ngrok-oss/mantle"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "package.json"
15
+ ],
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "@ngrok/src-live-types": "./src/index.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "dependencies": {
26
+ "shiki": "4.0.1"
27
+ },
28
+ "devDependencies": {
29
+ "@testing-library/jest-dom": "6.9.1",
30
+ "@types/node": "24.12.0",
31
+ "tsdown": "0.21.3",
32
+ "typescript": "5.9.3",
33
+ "@cfg/tsconfig": "1.0.0",
34
+ "@ngrok/mantle": "0.67.0"
35
+ },
36
+ "peerDependencies": {
37
+ "@ngrok/mantle": "*"
38
+ },
39
+ "engines": {
40
+ "node": "^24.0.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsdown",
44
+ "test": "TZ=UTC vitest run",
45
+ "test:watch": "TZ=UTC vitest watch",
46
+ "typecheck": "tsgo"
47
+ }
48
+ }