@ai-ecoverse/slicc-spectrum 1.104.2 → 1.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +14 -21
  2. package/dist/{chunk-D2HYQOCH.js → chunk-2GER7OHY.js} +4 -4
  3. package/dist/{chunk-JPIG5BAD.js → chunk-2JLDRHGH.js} +2 -2
  4. package/dist/chunk-2PTCZ3HU.js +177 -0
  5. package/dist/chunk-2PTCZ3HU.js.map +7 -0
  6. package/dist/chunk-2QGVEUM3.js +218 -0
  7. package/dist/chunk-2QGVEUM3.js.map +7 -0
  8. package/dist/chunk-2QTNHBD6.js +236 -0
  9. package/dist/chunk-2QTNHBD6.js.map +7 -0
  10. package/dist/chunk-3HYCVQIZ.js +2135 -0
  11. package/dist/chunk-3HYCVQIZ.js.map +7 -0
  12. package/dist/chunk-3TKJZ3WO.js +211 -0
  13. package/dist/chunk-3TKJZ3WO.js.map +7 -0
  14. package/dist/chunk-45RRK5H7.js +218 -0
  15. package/dist/chunk-45RRK5H7.js.map +7 -0
  16. package/dist/chunk-4LHTT5CM.js +260 -0
  17. package/dist/chunk-4LHTT5CM.js.map +7 -0
  18. package/dist/chunk-4LNENAB3.js +84 -0
  19. package/dist/chunk-4LNENAB3.js.map +7 -0
  20. package/dist/chunk-4UVLBBK5.js +229 -0
  21. package/dist/chunk-4UVLBBK5.js.map +7 -0
  22. package/dist/chunk-4V2XWPVI.js +260 -0
  23. package/dist/chunk-4V2XWPVI.js.map +7 -0
  24. package/dist/chunk-4VL4W65X.js +218 -0
  25. package/dist/chunk-4VL4W65X.js.map +7 -0
  26. package/dist/{chunk-442GNVWR.js → chunk-57NDK5DC.js} +2805 -2630
  27. package/dist/chunk-57NDK5DC.js.map +7 -0
  28. package/dist/chunk-5DQGKJYU.js +231 -0
  29. package/dist/chunk-5DQGKJYU.js.map +7 -0
  30. package/dist/chunk-5PPA6KWN.js +166 -0
  31. package/dist/chunk-5PPA6KWN.js.map +7 -0
  32. package/dist/chunk-5RPMYYR5.js +9 -0
  33. package/dist/chunk-5RPMYYR5.js.map +7 -0
  34. package/dist/chunk-5TKCBABJ.js +169 -0
  35. package/dist/chunk-5TKCBABJ.js.map +7 -0
  36. package/dist/chunk-5YPJDKI6.js +170 -0
  37. package/dist/chunk-5YPJDKI6.js.map +7 -0
  38. package/dist/{chunk-GHS6XYSQ.js → chunk-6FZ7EIP5.js} +6 -6
  39. package/dist/{chunk-LMH4BAKD.js → chunk-6JS2SZJ5.js} +12 -10
  40. package/dist/{chunk-LMH4BAKD.js.map → chunk-6JS2SZJ5.js.map} +2 -2
  41. package/dist/chunk-6UISDSQ6.js +229 -0
  42. package/dist/chunk-6UISDSQ6.js.map +7 -0
  43. package/dist/chunk-AADI6MVB.js +245 -0
  44. package/dist/chunk-AADI6MVB.js.map +7 -0
  45. package/dist/{chunk-22NCU4NL.js → chunk-AL43JFHF.js} +2 -2
  46. package/dist/chunk-ALX3M6E3.js +368 -0
  47. package/dist/chunk-ALX3M6E3.js.map +7 -0
  48. package/dist/chunk-APWLBR4J.js +173 -0
  49. package/dist/chunk-APWLBR4J.js.map +7 -0
  50. package/dist/chunk-B26VSXYC.js +297 -0
  51. package/dist/chunk-B26VSXYC.js.map +7 -0
  52. package/dist/chunk-B3ZH3IZR.js +82 -0
  53. package/dist/chunk-B3ZH3IZR.js.map +7 -0
  54. package/dist/chunk-BA2ER7NA.js +169 -0
  55. package/dist/chunk-BA2ER7NA.js.map +7 -0
  56. package/dist/chunk-BAVPQSVQ.js +190 -0
  57. package/dist/chunk-BAVPQSVQ.js.map +7 -0
  58. package/dist/{chunk-44HPUTOU.js → chunk-CEAD4W2I.js} +6 -6
  59. package/dist/chunk-CTBCZ6QP.js +368 -0
  60. package/dist/chunk-CTBCZ6QP.js.map +7 -0
  61. package/dist/chunk-D2BSCPOZ.js +204 -0
  62. package/dist/chunk-D2BSCPOZ.js.map +7 -0
  63. package/dist/chunk-DBTSLS2U.js +171 -0
  64. package/dist/chunk-DBTSLS2U.js.map +7 -0
  65. package/dist/chunk-DUHSH5IA.js +392 -0
  66. package/dist/chunk-DUHSH5IA.js.map +7 -0
  67. package/dist/chunk-E3XF2JYD.js +175 -0
  68. package/dist/chunk-E3XF2JYD.js.map +7 -0
  69. package/dist/chunk-E6FGQYBA.js +2 -0
  70. package/dist/{chunk-Y7O6BIKA.js → chunk-EAVYCN2X.js} +3 -3
  71. package/dist/chunk-EG2LH2D6.js +368 -0
  72. package/dist/chunk-EG2LH2D6.js.map +7 -0
  73. package/dist/chunk-EJCS2A67.js +248 -0
  74. package/dist/chunk-EJCS2A67.js.map +7 -0
  75. package/dist/chunk-ENK72MDX.js +247 -0
  76. package/dist/chunk-ENK72MDX.js.map +7 -0
  77. package/dist/chunk-ETY2K3PP.js +185 -0
  78. package/dist/chunk-ETY2K3PP.js.map +7 -0
  79. package/dist/chunk-FVU5ETHN.js +244 -0
  80. package/dist/chunk-FVU5ETHN.js.map +7 -0
  81. package/dist/chunk-FWORTALJ.js +392 -0
  82. package/dist/chunk-FWORTALJ.js.map +7 -0
  83. package/dist/chunk-G3AQILQL.js +377 -0
  84. package/dist/chunk-G3AQILQL.js.map +7 -0
  85. package/dist/chunk-GFOHPOWP.js +8 -0
  86. package/dist/chunk-GG2YLBBY.js +211 -0
  87. package/dist/chunk-GG2YLBBY.js.map +7 -0
  88. package/dist/chunk-GULF27HF.js +204 -0
  89. package/dist/chunk-GULF27HF.js.map +7 -0
  90. package/dist/chunk-I54HXPPH.js +242 -0
  91. package/dist/chunk-I54HXPPH.js.map +7 -0
  92. package/dist/chunk-I67XBOU7.js +241 -0
  93. package/dist/chunk-I67XBOU7.js.map +7 -0
  94. package/dist/chunk-I7E74Y7Y.js +368 -0
  95. package/dist/chunk-I7E74Y7Y.js.map +7 -0
  96. package/dist/chunk-IGMG5I7K.js +204 -0
  97. package/dist/chunk-IGMG5I7K.js.map +7 -0
  98. package/dist/chunk-JSVDUJOF.js +418 -0
  99. package/dist/chunk-JSVDUJOF.js.map +7 -0
  100. package/dist/chunk-JWEDQMOH.js +204 -0
  101. package/dist/chunk-JWEDQMOH.js.map +7 -0
  102. package/dist/chunk-K7CQ2PRH.js +243 -0
  103. package/dist/chunk-K7CQ2PRH.js.map +7 -0
  104. package/dist/chunk-KIDTSHLT.js +3239 -0
  105. package/dist/chunk-KIDTSHLT.js.map +7 -0
  106. package/dist/chunk-KIKLCSNJ.js +3 -0
  107. package/dist/chunk-KIKLCSNJ.js.map +7 -0
  108. package/dist/chunk-KUTFS7K7.js +170 -0
  109. package/dist/chunk-KUTFS7K7.js.map +7 -0
  110. package/dist/chunk-L25HPU52.js +229 -0
  111. package/dist/chunk-L25HPU52.js.map +7 -0
  112. package/dist/{chunk-WXAII75O.js → chunk-LJ5HWLFA.js} +2 -2
  113. package/dist/{chunk-WXAII75O.js.map → chunk-LJ5HWLFA.js.map} +1 -1
  114. package/dist/chunk-LNZHKQQB.js +175 -0
  115. package/dist/chunk-LNZHKQQB.js.map +7 -0
  116. package/dist/{chunk-LVH4CKV3.js → chunk-LSXQD3LS.js} +3 -3
  117. package/dist/chunk-LW7FUR35.js +368 -0
  118. package/dist/chunk-LW7FUR35.js.map +7 -0
  119. package/dist/chunk-MCIHORAJ.js +229 -0
  120. package/dist/chunk-MCIHORAJ.js.map +7 -0
  121. package/dist/chunk-MD3SFR65.js +418 -0
  122. package/dist/chunk-MD3SFR65.js.map +7 -0
  123. package/dist/chunk-MGYKF4CA.js +175 -0
  124. package/dist/chunk-MGYKF4CA.js.map +7 -0
  125. package/dist/chunk-N7NGXLLM.js +368 -0
  126. package/dist/chunk-N7NGXLLM.js.map +7 -0
  127. package/dist/chunk-NEW2Q7FF.js +101 -0
  128. package/dist/chunk-NEW2Q7FF.js.map +7 -0
  129. package/dist/chunk-NQH6RQYV.js +250 -0
  130. package/dist/chunk-NQH6RQYV.js.map +7 -0
  131. package/dist/chunk-NSXLBNK4.js +238 -0
  132. package/dist/chunk-NSXLBNK4.js.map +7 -0
  133. package/dist/chunk-OIEY3JII.js +233 -0
  134. package/dist/chunk-OIEY3JII.js.map +7 -0
  135. package/dist/chunk-OKPKENUF.js +211 -0
  136. package/dist/chunk-OKPKENUF.js.map +7 -0
  137. package/dist/chunk-OY4ZZY7W.js +218 -0
  138. package/dist/chunk-OY4ZZY7W.js.map +7 -0
  139. package/dist/chunk-QQNGYZLJ.js +173 -0
  140. package/dist/chunk-QQNGYZLJ.js.map +7 -0
  141. package/dist/chunk-RE5FCGM4.js +233 -0
  142. package/dist/chunk-RE5FCGM4.js.map +7 -0
  143. package/dist/chunk-RTUIJYIL.js +368 -0
  144. package/dist/chunk-RTUIJYIL.js.map +7 -0
  145. package/dist/chunk-RVP4DE3X.js +368 -0
  146. package/dist/chunk-RVP4DE3X.js.map +7 -0
  147. package/dist/chunk-RZNHWRZX.js +175 -0
  148. package/dist/chunk-RZNHWRZX.js.map +7 -0
  149. package/dist/chunk-SI4KACA7.js +368 -0
  150. package/dist/chunk-SI4KACA7.js.map +7 -0
  151. package/dist/chunk-SIN26ESQ.js +392 -0
  152. package/dist/chunk-SIN26ESQ.js.map +7 -0
  153. package/dist/chunk-SXLM67S4.js +185 -0
  154. package/dist/chunk-SXLM67S4.js.map +7 -0
  155. package/dist/chunk-SZDSSMHM.js +218 -0
  156. package/dist/chunk-SZDSSMHM.js.map +7 -0
  157. package/dist/chunk-TIVNHKKC.js +418 -0
  158. package/dist/chunk-TIVNHKKC.js.map +7 -0
  159. package/dist/chunk-TXJNAXHT.js +418 -0
  160. package/dist/chunk-TXJNAXHT.js.map +7 -0
  161. package/dist/chunk-U2CRYG2Y.js +368 -0
  162. package/dist/chunk-U2CRYG2Y.js.map +7 -0
  163. package/dist/chunk-UAZ7ATZ5.js +770 -0
  164. package/dist/chunk-UAZ7ATZ5.js.map +7 -0
  165. package/dist/chunk-UFGJPRGL.js +104 -0
  166. package/dist/chunk-UFGJPRGL.js.map +7 -0
  167. package/dist/chunk-UI7G5S4O.js +211 -0
  168. package/dist/chunk-UI7G5S4O.js.map +7 -0
  169. package/dist/{chunk-MZMRYCS6.js → chunk-WQ7OXFOF.js} +2 -2
  170. package/dist/chunk-WVWSLJ4A.js +160 -0
  171. package/dist/chunk-WVWSLJ4A.js.map +7 -0
  172. package/dist/chunk-X2FGXM6T.js +657 -0
  173. package/dist/chunk-X2FGXM6T.js.map +7 -0
  174. package/dist/chunk-XJ4X6OZN.js +175 -0
  175. package/dist/chunk-XJ4X6OZN.js.map +7 -0
  176. package/dist/chunk-YCSUWIOE.js +218 -0
  177. package/dist/chunk-YCSUWIOE.js.map +7 -0
  178. package/dist/chunk-YG7YEPYG.js +238 -0
  179. package/dist/chunk-YG7YEPYG.js.map +7 -0
  180. package/dist/chunk-YMUYQTBG.js +170 -0
  181. package/dist/chunk-YMUYQTBG.js.map +7 -0
  182. package/dist/chunk-YYRMCQGB.js +347 -0
  183. package/dist/chunk-YYRMCQGB.js.map +7 -0
  184. package/dist/chunk-YYU64C2K.js +233 -0
  185. package/dist/chunk-YYU64C2K.js.map +7 -0
  186. package/dist/{chunk-OS3ZND7O.js → chunk-ZSLV7QHA.js} +2 -2
  187. package/dist/chunk-ZYWHNLZW.js +200 -0
  188. package/dist/chunk-ZYWHNLZW.js.map +7 -0
  189. package/dist/slicc-ui.js +4868 -18113
  190. package/dist/slicc-ui.js.map +4 -4
  191. package/dist/types/app/app.d.ts +0 -2
  192. package/dist/types/components/code-theme.d.ts +12 -0
  193. package/dist/types/components/code-view.d.ts +3 -2
  194. package/dist/types/ui.d.ts +0 -2
  195. package/package.json +23 -33
  196. package/dist/chunk-442GNVWR.js.map +0 -7
  197. package/dist/chunk-5G3X76IR.js +0 -8
  198. package/dist/chunk-64K5VONJ.js +0 -11
  199. package/dist/chunk-64K5VONJ.js.map +0 -7
  200. package/dist/chunk-6T3O5K6R.js +0 -8
  201. package/dist/chunk-BHAGWMDD.js +0 -8
  202. package/dist/chunk-BHAGWMDD.js.map +0 -7
  203. package/dist/chunk-CGS66GRP.js +0 -11
  204. package/dist/chunk-CGS66GRP.js.map +0 -7
  205. package/dist/chunk-CONYKGKV.js +0 -11
  206. package/dist/chunk-CONYKGKV.js.map +0 -7
  207. package/dist/chunk-CU7BC2RI.js +0 -11
  208. package/dist/chunk-CU7BC2RI.js.map +0 -7
  209. package/dist/chunk-FXM4K5WL.js +0 -19
  210. package/dist/chunk-FXM4K5WL.js.map +0 -7
  211. package/dist/chunk-I4OYHPAU.js +0 -11
  212. package/dist/chunk-I4OYHPAU.js.map +0 -7
  213. package/dist/chunk-KMP5HO3E.js +0 -11
  214. package/dist/chunk-KMP5HO3E.js.map +0 -7
  215. package/dist/chunk-KWPU2PY3.js +0 -14
  216. package/dist/chunk-KWPU2PY3.js.map +0 -7
  217. package/dist/chunk-LBXW6XNL.js +0 -18
  218. package/dist/chunk-LBXW6XNL.js.map +0 -7
  219. package/dist/chunk-LII3WY6Y.js +0 -11
  220. package/dist/chunk-LII3WY6Y.js.map +0 -7
  221. package/dist/chunk-LY7WVBCB.js +0 -10
  222. package/dist/chunk-LY7WVBCB.js.map +0 -7
  223. package/dist/chunk-NLDFGCIL.js +0 -11
  224. package/dist/chunk-NLDFGCIL.js.map +0 -7
  225. package/dist/chunk-S5EGO4NA.js +0 -11
  226. package/dist/chunk-S5EGO4NA.js.map +0 -7
  227. package/dist/chunk-TAZBKRHT.js +0 -10
  228. package/dist/chunk-TAZBKRHT.js.map +0 -7
  229. package/dist/chunk-UCIBH53C.js +0 -11
  230. package/dist/chunk-UCIBH53C.js.map +0 -7
  231. package/dist/chunk-XZM23TK4.js +0 -11
  232. package/dist/chunk-XZM23TK4.js.map +0 -7
  233. package/dist/chunk-YX6SI5VA.js +0 -11
  234. package/dist/chunk-YX6SI5VA.js.map +0 -7
  235. package/dist/types/app/grammars.d.ts +0 -6
  236. /package/dist/{chunk-D2HYQOCH.js.map → chunk-2GER7OHY.js.map} +0 -0
  237. /package/dist/{chunk-JPIG5BAD.js.map → chunk-2JLDRHGH.js.map} +0 -0
  238. /package/dist/{chunk-GHS6XYSQ.js.map → chunk-6FZ7EIP5.js.map} +0 -0
  239. /package/dist/{chunk-22NCU4NL.js.map → chunk-AL43JFHF.js.map} +0 -0
  240. /package/dist/{chunk-44HPUTOU.js.map → chunk-CEAD4W2I.js.map} +0 -0
  241. /package/dist/{chunk-5G3X76IR.js.map → chunk-E6FGQYBA.js.map} +0 -0
  242. /package/dist/{chunk-Y7O6BIKA.js.map → chunk-EAVYCN2X.js.map} +0 -0
  243. /package/dist/{chunk-6T3O5K6R.js.map → chunk-GFOHPOWP.js.map} +0 -0
  244. /package/dist/{chunk-LVH4CKV3.js.map → chunk-LSXQD3LS.js.map} +0 -0
  245. /package/dist/{chunk-MZMRYCS6.js.map → chunk-WQ7OXFOF.js.map} +0 -0
  246. /package/dist/{chunk-OS3ZND7O.js.map → chunk-ZSLV7QHA.js.map} +0 -0
@@ -0,0 +1,657 @@
1
+ import {
2
+ BaseStreamTokenizer,
3
+ DiffsHighlighter
4
+ } from "./chunk-UFGJPRGL.js";
5
+ import "./chunk-KIKLCSNJ.js";
6
+ import {
7
+ RegisteredCustomLanguages,
8
+ attachResolvedLanguages,
9
+ resolveLanguages
10
+ } from "./chunk-B3ZH3IZR.js";
11
+ import {
12
+ appendItems,
13
+ createDiffsThemeResolver
14
+ } from "./chunk-KIDTSHLT.js";
15
+ import "./chunk-NEW2Q7FF.js";
16
+ import "./chunk-AXQFWXYZ.js";
17
+
18
+ // node_modules/@pierre/diffs/dist/editor/utils.js
19
+ function debounce(func, wait) {
20
+ let timeout;
21
+ return function(...args) {
22
+ clearTimeout(timeout);
23
+ timeout = setTimeout(() => func.apply(this, args), wait);
24
+ };
25
+ }
26
+
27
+ // node_modules/@pierre/diffs/dist/highlighter/shiki-editor.js
28
+ var TOKENIZE_TIME_LIMIT = 0;
29
+ var nextTokenizerId = 0;
30
+ var ShikiEditorTokenizer = class {
31
+ backend;
32
+ #highlighter;
33
+ #grammar;
34
+ #themeName;
35
+ #colorMap;
36
+ #textDocument;
37
+ #tokenizeMaxLineLength;
38
+ #onDeferTokenize;
39
+ #matchBrackets;
40
+ #debug;
41
+ #isCleanedUp = false;
42
+ #stateStack = [void 0];
43
+ #comparisonStateStack = [];
44
+ #comparisonStateStackStart = 0;
45
+ #comparisonLineChanges = [];
46
+ #lastLine = -1;
47
+ #isStopped = true;
48
+ #isPaused = false;
49
+ #backgroundJobId = 0;
50
+ #tokenizerId = ++nextTokenizerId;
51
+ #backgroundPrebuildEndLine = -1;
52
+ #pendingPrebuildEndLine = -1;
53
+ #backgroundChangedLineRanges;
54
+ #backgroundChangedRangeIndex = 0;
55
+ #bracketIgnoredRanges = [];
56
+ #isMessageListenerAttached = false;
57
+ #prebuildStateStack = debounce(async (renderRange) => {
58
+ if (this.#isCleanedUp) return;
59
+ const { startingLine = 0, totalLines = Infinity } = renderRange ?? {};
60
+ const endLine = Math.min(totalLines === Infinity ? Infinity : startingLine + totalLines, this.#textDocument.lineCount);
61
+ if (this.#grammar == null && !isGrammarlessLanguage(this.#textDocument.languageId)) {
62
+ await this.backend?.loadLanguages([this.#textDocument.languageId]);
63
+ if (this.#isCleanedUp) return;
64
+ this.#grammar = this.#highlighter.getLanguage(this.#textDocument.languageId);
65
+ }
66
+ this.#ensureActiveTheme();
67
+ this.#scheduleStatePrebuild(endLine);
68
+ }, 500);
69
+ #onMessage = ({ data }) => {
70
+ if (typeof data !== "object" || data === null) return;
71
+ const { type, tokenizerId, jobId } = data;
72
+ if (type === "tokenize" && tokenizerId === this.#tokenizerId && typeof jobId === "number" && jobId === this.#backgroundJobId) {
73
+ if (this.#backgroundPrebuildEndLine >= 0) this.#backgroundPrebuild(jobId);
74
+ else this.#backgroundTokenize(jobId);
75
+ }
76
+ };
77
+ getStringCommentRegexpRangesInLine(lineIndex) {
78
+ if (!this.#matchBrackets || lineIndex < 0 || lineIndex >= this.#textDocument.lineCount) return null;
79
+ this.#ensureGrammar();
80
+ if (this.#grammar == null) return null;
81
+ if (this.#bracketIgnoredRanges[lineIndex] === void 0) {
82
+ this.#buildStateStack(lineIndex);
83
+ const state = this.#stateStack[lineIndex] ?? void 0;
84
+ const result = this.#tokenizeLineAt(lineIndex, state);
85
+ this.#stateStack[lineIndex + 1] = result.state;
86
+ }
87
+ return this.#bracketIgnoredRanges[lineIndex] ?? null;
88
+ }
89
+ constructor(highlighter, options, backend) {
90
+ this.backend = backend;
91
+ this.#highlighter = highlighter;
92
+ this.#textDocument = options.textDocument;
93
+ this.#themeName = options.theme;
94
+ this.#colorMap = [];
95
+ this.#tokenizeMaxLineLength = options.tokenizeMaxLineLength ?? 1e3;
96
+ this.#onDeferTokenize = options.onDeferTokenize;
97
+ this.#matchBrackets = options.matchBrackets !== false;
98
+ this.#debug = options.__debug ?? false;
99
+ this.#ensureGrammar();
100
+ this.#ensureActiveTheme();
101
+ }
102
+ setTheme(themeName) {
103
+ if (this.#themeName === themeName) return;
104
+ this.#themeName = themeName;
105
+ this.#ensureActiveTheme();
106
+ this.stopBackgroundTokenize();
107
+ this.#stateStack = [void 0];
108
+ this.#comparisonStateStack = [];
109
+ this.#comparisonStateStackStart = 0;
110
+ this.#comparisonLineChanges = [];
111
+ if (this.#grammar != null && this.#textDocument.lineCount > 0) this.#scheduleBackgroundTokenize(0);
112
+ }
113
+ #ensureActiveTheme() {
114
+ if (this.#themeName === "") return;
115
+ this.backend?.getTheme(this.#themeName);
116
+ const { colorMap } = this.#highlighter.setTheme(this.#themeName);
117
+ this.#colorMap = colorMap;
118
+ }
119
+ dispose() {
120
+ this.#isCleanedUp = true;
121
+ this.stopBackgroundTokenize();
122
+ this.#detachMessageListener();
123
+ }
124
+ tokenize(change, renderRange, hostRealignsRows = false) {
125
+ this.#ensureGrammar();
126
+ this.#ensureActiveTheme();
127
+ if (this.#grammar == null && !isGrammarlessLanguage(this.#textDocument.languageId)) throw new Error(`Grammar for language "${this.#textDocument.languageId}" not loaded`);
128
+ const { lineCount } = this.#textDocument;
129
+ const { startingLine = 0, totalLines = Infinity } = renderRange ?? {};
130
+ const renderRangeEndLine = totalLines === Infinity ? lineCount : Math.min(startingLine + totalLines, lineCount);
131
+ const dirtyStart = change.startLine;
132
+ const viewStart = Math.max(startingLine, dirtyStart);
133
+ const crossesRenderRangeEnd = renderRange != null && totalLines !== Infinity && change.lineDelta > 0 && dirtyStart < renderRangeEndLine && change.endLine >= renderRangeEndLine;
134
+ const canReuseCachedStates = change.lineDelta === 0 && (change.changedLineChanges?.every(([, , lineDelta]) => lineDelta === 0) ?? true);
135
+ if (this.#matchBrackets && !canReuseCachedStates) this.#bracketIgnoredRanges.length = Math.min(this.#bracketIgnoredRanges.length, change.startLine);
136
+ const canReuseShiftedStates = hostRealignsRows && change.lineDelta !== 0 && dirtyStart >= startingLine;
137
+ const canCacheTokenizedStates = canReuseCachedStates || renderRange == null || dirtyStart >= viewStart;
138
+ const changedLineRanges = change.changedLineRanges ?? [[dirtyStart, change.endLine]];
139
+ this.#comparisonStateStack = [];
140
+ this.#comparisonStateStackStart = 0;
141
+ this.#comparisonLineChanges = [];
142
+ let offscreenSyncEnd = -1;
143
+ if (dirtyStart < viewStart) {
144
+ for (const [rangeStart, rangeEnd] of changedLineRanges) if (rangeStart < viewStart) offscreenSyncEnd = Math.max(offscreenSyncEnd, Math.min(rangeEnd, viewStart - 1));
145
+ }
146
+ const shouldFlushOffscreenLines = offscreenSyncEnd >= dirtyStart && (canReuseCachedStates || change.lineDelta < 0);
147
+ if (canReuseCachedStates) this.#buildStateStack(dirtyStart);
148
+ else {
149
+ this.#shiftComparisonStateStack(change);
150
+ if (renderRange == null || dirtyStart >= viewStart) this.#buildStateStack(viewStart);
151
+ }
152
+ let changedRangeIndex = 0;
153
+ let currentChangedRangeEnd = changedLineRanges[changedRangeIndex][1];
154
+ let backgroundStartLine;
155
+ let backgroundChangedRangeIndex = 0;
156
+ let line = canReuseCachedStates ? changedLineRanges[changedRangeIndex][0] : viewStart;
157
+ let settled = false;
158
+ const dirtyLines = /* @__PURE__ */ new Map();
159
+ const offscreenDirtyLines = shouldFlushOffscreenLines ? /* @__PURE__ */ new Map() : void 0;
160
+ if (offscreenDirtyLines != null && !canReuseCachedStates) {
161
+ const offscreenEnd = Math.min(offscreenSyncEnd + 1, viewStart, renderRangeEndLine);
162
+ if (offscreenEnd > dirtyStart) {
163
+ this.#buildStateStack(offscreenEnd);
164
+ let offscreenLine = dirtyStart;
165
+ let offscreenState = this.#stateStack[offscreenLine] ?? void 0;
166
+ for (; offscreenLine < offscreenEnd; offscreenLine++) {
167
+ const resolved = this.#tokenizeLineAt(offscreenLine, offscreenState);
168
+ offscreenState = resolved.state;
169
+ offscreenDirtyLines.set(offscreenLine, resolved.resolvedTokens);
170
+ }
171
+ this.#stateStack[offscreenEnd] = offscreenState;
172
+ }
173
+ }
174
+ let state = this.#stateStack[line] ?? void 0;
175
+ for (; line < renderRangeEndLine; ) {
176
+ const previousNextState = canReuseCachedStates ? this.#stateStack[line + 1] : canReuseShiftedStates ? this.#getPreviousEndState(line + 1) : void 0;
177
+ if (canCacheTokenizedStates) this.#stateStack[line] = state;
178
+ const { resolvedTokens, state: nextState } = this.#tokenizeLineAt(line, state);
179
+ state = nextState;
180
+ if (line >= viewStart) dirtyLines.set(line, resolvedTokens);
181
+ else offscreenDirtyLines?.set(line, resolvedTokens);
182
+ if (canCacheTokenizedStates) this.#stateStack[line + 1] = state;
183
+ settled = line >= currentChangedRangeEnd && (canReuseCachedStates || canReuseShiftedStates) && previousNextState != null && state.equals(previousNextState);
184
+ if (settled) {
185
+ changedRangeIndex++;
186
+ const nextRange = changedLineRanges[changedRangeIndex];
187
+ if (nextRange == null) break;
188
+ if (nextRange[0] >= renderRangeEndLine) {
189
+ backgroundStartLine = nextRange[0];
190
+ backgroundChangedRangeIndex = changedRangeIndex;
191
+ break;
192
+ }
193
+ let nextState2 = this.#stateStack[nextRange[0]];
194
+ if (canReuseShiftedStates) for (let stateLine = line + 2; stateLine <= nextRange[0]; stateLine++) {
195
+ nextState2 = this.#getPreviousEndState(stateLine);
196
+ if (nextState2 == null) break;
197
+ this.#stateStack[stateLine] = nextState2;
198
+ }
199
+ if (nextState2 == null) {
200
+ currentChangedRangeEnd = nextRange[1];
201
+ line++;
202
+ } else {
203
+ line = nextRange[0];
204
+ state = nextState2;
205
+ currentChangedRangeEnd = nextRange[1];
206
+ }
207
+ settled = false;
208
+ continue;
209
+ }
210
+ line++;
211
+ }
212
+ if (canCacheTokenizedStates) {
213
+ if (line < renderRangeEndLine) this.#stateStack[line + 1] = state;
214
+ else this.#stateStack[line] = state;
215
+ }
216
+ if (settled && canReuseShiftedStates && backgroundStartLine == null) {
217
+ for (let stateLine = line + 2; stateLine <= lineCount; stateLine++) {
218
+ const previousState = this.#getPreviousEndState(stateLine);
219
+ if (previousState == null) break;
220
+ this.#stateStack[stateLine] = previousState;
221
+ }
222
+ this.#comparisonStateStack = [];
223
+ this.#comparisonStateStackStart = 0;
224
+ this.#comparisonLineChanges = [];
225
+ }
226
+ if (offscreenDirtyLines != null && offscreenDirtyLines.size > 0) this.#onDeferTokenize(offscreenDirtyLines);
227
+ if (backgroundStartLine != null) {
228
+ if (this.#matchBrackets && canReuseCachedStates) this.#bracketIgnoredRanges.length = Math.min(this.#bracketIgnoredRanges.length, backgroundStartLine);
229
+ this.#scheduleBackgroundTokenize(backgroundStartLine, changedLineRanges, backgroundChangedRangeIndex);
230
+ } else if (!settled && line < lineCount) {
231
+ const backgroundLine = crossesRenderRangeEnd && dirtyStart >= viewStart ? renderRangeEndLine : dirtyStart < viewStart && !canReuseCachedStates ? dirtyStart : line;
232
+ if (this.#matchBrackets && canReuseCachedStates) this.#bracketIgnoredRanges.length = Math.min(this.#bracketIgnoredRanges.length, backgroundLine);
233
+ this.#scheduleBackgroundTokenize(backgroundLine, changedLineRanges, changedRangeIndex);
234
+ }
235
+ return dirtyLines;
236
+ }
237
+ prebuildStateStack(renderRange) {
238
+ this.#ensureGrammar();
239
+ this.#prebuildStateStack(renderRange);
240
+ }
241
+ stopBackgroundTokenize() {
242
+ this.#pendingPrebuildEndLine = -1;
243
+ if (this.#isStopped) return;
244
+ this.#isStopped = true;
245
+ this.#isPaused = false;
246
+ this.#lastLine = -1;
247
+ this.#backgroundPrebuildEndLine = -1;
248
+ this.#backgroundChangedLineRanges = void 0;
249
+ this.#backgroundChangedRangeIndex = 0;
250
+ this.#comparisonStateStack = [];
251
+ this.#comparisonStateStackStart = 0;
252
+ this.#comparisonLineChanges = [];
253
+ this.#detachMessageListener();
254
+ }
255
+ pauseBackgroundTokenize() {
256
+ if (this.#isStopped || this.#isPaused) return;
257
+ if (this.#debug) console.log("[diffs/editor] background tokenization paused", { jobId: this.#backgroundJobId });
258
+ this.#isPaused = true;
259
+ }
260
+ resumeBackgroundTokenize() {
261
+ if (this.#isStopped || !this.#isPaused || this.#grammar == null || this.#lastLine < 0) return;
262
+ if (this.#debug) console.log("[diffs/editor] background tokenization resumed", { jobId: this.#backgroundJobId });
263
+ this.#isPaused = false;
264
+ this.#postTokenizeMessage(this.#backgroundJobId);
265
+ }
266
+ #ensureGrammar() {
267
+ if (this.#grammar == null && !isGrammarlessLanguage(this.#textDocument.languageId) && this.#highlighter.getLoadedLanguages().includes(this.#textDocument.languageId)) this.#grammar = this.#highlighter.getLanguage(this.#textDocument.languageId);
268
+ }
269
+ #attachMessageListener() {
270
+ if (this.#isMessageListenerAttached) return;
271
+ globalThis.addEventListener("message", this.#onMessage);
272
+ this.#isMessageListenerAttached = true;
273
+ }
274
+ #detachMessageListener() {
275
+ if (!this.#isMessageListenerAttached) return;
276
+ globalThis.removeEventListener("message", this.#onMessage);
277
+ this.#isMessageListenerAttached = false;
278
+ }
279
+ #postTokenizeMessage(jobId) {
280
+ globalThis.postMessage({
281
+ type: "tokenize",
282
+ tokenizerId: this.#tokenizerId,
283
+ jobId
284
+ });
285
+ }
286
+ #scheduleBackgroundTokenize(startLine, changedLineRanges, changedRangeIndex = 0) {
287
+ if (isGrammarlessLanguage(this.#textDocument.languageId)) return;
288
+ const jobId = ++this.#backgroundJobId;
289
+ if (this.#debug) console.log("[diffs/editor] background tokenization scheduled", {
290
+ jobId,
291
+ startLine,
292
+ changedLineRanges,
293
+ changedRangeIndex
294
+ });
295
+ this.#isStopped = false;
296
+ this.#isPaused = false;
297
+ this.#lastLine = startLine;
298
+ if (this.#backgroundPrebuildEndLine >= 0) this.#pendingPrebuildEndLine = Math.max(this.#pendingPrebuildEndLine, this.#backgroundPrebuildEndLine);
299
+ this.#backgroundPrebuildEndLine = -1;
300
+ this.#backgroundChangedLineRanges = changedLineRanges;
301
+ this.#backgroundChangedRangeIndex = changedRangeIndex;
302
+ this.#attachMessageListener();
303
+ this.#postTokenizeMessage(jobId);
304
+ }
305
+ #scheduleStatePrebuild(endLine) {
306
+ if (this.#grammar == null || this.#stateStack.length > endLine) return;
307
+ if (!this.#isStopped) {
308
+ if (this.#backgroundPrebuildEndLine >= 0) this.#backgroundPrebuildEndLine = Math.max(this.#backgroundPrebuildEndLine, endLine);
309
+ else this.#pendingPrebuildEndLine = Math.max(this.#pendingPrebuildEndLine, endLine);
310
+ return;
311
+ }
312
+ const jobId = ++this.#backgroundJobId;
313
+ this.#isStopped = false;
314
+ this.#isPaused = false;
315
+ this.#lastLine = this.#stateStack.length - 1;
316
+ this.#backgroundPrebuildEndLine = endLine;
317
+ this.#pendingPrebuildEndLine = -1;
318
+ this.#backgroundChangedLineRanges = void 0;
319
+ this.#backgroundChangedRangeIndex = 0;
320
+ this.#attachMessageListener();
321
+ this.#postTokenizeMessage(jobId);
322
+ }
323
+ #tokenizeLineAt(line, state) {
324
+ const lineText = this.#textDocument.getLineText(line);
325
+ if (lineText.length >= this.#tokenizeMaxLineLength) {
326
+ console.warn(`[diffs] Line(${line}) too long to tokenize: ${lineText.length}`);
327
+ this.#cacheBracketIgnoredRanges(line, null);
328
+ return {
329
+ resolvedTokens: [[
330
+ 0,
331
+ "",
332
+ lineText
333
+ ]],
334
+ state
335
+ };
336
+ }
337
+ if (this.#grammar == null || lineText === "" || lineText.trim() === "") {
338
+ this.#cacheBracketIgnoredRanges(line, null);
339
+ return {
340
+ resolvedTokens: [[
341
+ 0,
342
+ "",
343
+ lineText
344
+ ]],
345
+ state
346
+ };
347
+ }
348
+ const result = tokenizeLine(this.#grammar, this.#colorMap, lineText, state, TOKENIZE_TIME_LIMIT, this.#matchBrackets);
349
+ this.#cacheBracketIgnoredRanges(line, result.bracketIgnoredRanges);
350
+ return {
351
+ resolvedTokens: result.resolvedTokens,
352
+ state: result.ruleStack
353
+ };
354
+ }
355
+ #cacheBracketIgnoredRanges(line, ranges) {
356
+ if (this.#matchBrackets) this.#bracketIgnoredRanges[line] = ranges;
357
+ }
358
+ #shiftComparisonStateStack(change) {
359
+ const lineChanges = change.changedLineChanges ?? [[
360
+ change.startLine,
361
+ change.endLine,
362
+ change.lineDelta
363
+ ]];
364
+ const comparisonStart = change.startLine + 1;
365
+ if (comparisonStart <= this.#stateStack.length - comparisonStart) {
366
+ this.#comparisonStateStack = this.#stateStack;
367
+ this.#comparisonStateStackStart = 0;
368
+ this.#stateStack = this.#stateStack.slice(0, comparisonStart);
369
+ } else {
370
+ this.#comparisonStateStackStart = comparisonStart;
371
+ this.#comparisonStateStack = this.#stateStack.slice(comparisonStart);
372
+ this.#stateStack.length = Math.min(this.#stateStack.length, comparisonStart);
373
+ }
374
+ this.#comparisonLineChanges = lineChanges;
375
+ }
376
+ #getPreviousEndState(line) {
377
+ let previousLine = line;
378
+ for (let index = this.#comparisonLineChanges.length - 1; index >= 0; index--) {
379
+ const [startLine, endLine, lineDelta] = this.#comparisonLineChanges[index];
380
+ if (lineDelta === 0) continue;
381
+ if (previousLine > endLine) previousLine -= lineDelta;
382
+ else if (previousLine > startLine) return this.#stateStack[line];
383
+ }
384
+ return this.#comparisonStateStack[previousLine - this.#comparisonStateStackStart] ?? this.#stateStack[line];
385
+ }
386
+ #buildStateStack(endAt, timeBudget) {
387
+ const boundedEndAt = Math.min(Math.max(0, endAt), this.#textDocument.lineCount);
388
+ if (this.#stateStack.length > boundedEndAt || this.#grammar == null) return true;
389
+ const startedAt = timeBudget == null ? 0 : performance.now();
390
+ let line = this.#stateStack.length - 1;
391
+ let state = this.#stateStack[line] ?? void 0;
392
+ while (line < boundedEndAt) {
393
+ this.#stateStack[line] = state;
394
+ const lineText = this.#textDocument.getLineText(line);
395
+ if (lineText.length < this.#tokenizeMaxLineLength && lineText !== "" && lineText.trim() !== "") {
396
+ const result = tokenizeLine(this.#grammar, this.#colorMap, lineText, state, TOKENIZE_TIME_LIMIT, this.#matchBrackets, false);
397
+ this.#cacheBracketIgnoredRanges(line, result.bracketIgnoredRanges);
398
+ state = result.ruleStack;
399
+ } else this.#cacheBracketIgnoredRanges(line, null);
400
+ line++;
401
+ this.#stateStack[line] = state;
402
+ if (timeBudget != null && performance.now() - startedAt > timeBudget) break;
403
+ }
404
+ return line >= boundedEndAt;
405
+ }
406
+ #backgroundPrebuild(jobId) {
407
+ if (this.#isStopped || this.#isPaused || this.#grammar == null || jobId !== this.#backgroundJobId) return;
408
+ this.#ensureActiveTheme();
409
+ const complete = this.#buildStateStack(this.#backgroundPrebuildEndLine, 1);
410
+ if (this.#isStopped || this.#isPaused || jobId !== this.#backgroundJobId) return;
411
+ if (complete) {
412
+ this.stopBackgroundTokenize();
413
+ return;
414
+ }
415
+ this.#lastLine = this.#stateStack.length - 1;
416
+ this.#postTokenizeMessage(jobId);
417
+ }
418
+ #backgroundTokenize(jobId) {
419
+ if (this.#isStopped || this.#isPaused || this.#grammar == null || jobId !== this.#backgroundJobId) return;
420
+ this.#ensureActiveTheme();
421
+ const t = performance.now();
422
+ const lines = /* @__PURE__ */ new Map();
423
+ const totalLines = this.#textDocument.lineCount;
424
+ const changedLineRanges = this.#backgroundChangedLineRanges;
425
+ let line = this.#lastLine;
426
+ let state = this.#stateStack[line] ?? void 0;
427
+ let settled = false;
428
+ let changedRangeIndex = this.#backgroundChangedRangeIndex;
429
+ let currentChangedRangeEnd = changedLineRanges?.[changedRangeIndex]?.[1];
430
+ for (; line < totalLines; ) {
431
+ this.#stateStack[line] = state;
432
+ const previousNextState = currentChangedRangeEnd != null ? this.#getPreviousEndState(line + 1) : void 0;
433
+ const result = this.#tokenizeLineAt(line, state);
434
+ lines.set(line, result.resolvedTokens);
435
+ state = result.state;
436
+ this.#stateStack[line + 1] = state;
437
+ settled = currentChangedRangeEnd != null && line >= currentChangedRangeEnd && previousNextState != null && state.equals(previousNextState);
438
+ line++;
439
+ if (settled) {
440
+ changedRangeIndex++;
441
+ const nextRange = changedLineRanges?.[changedRangeIndex];
442
+ if (nextRange == null) break;
443
+ currentChangedRangeEnd = nextRange[1];
444
+ if (this.#stateStack[nextRange[0]] == null) settled = false;
445
+ else {
446
+ line = nextRange[0];
447
+ state = this.#stateStack[line] ?? state;
448
+ settled = false;
449
+ continue;
450
+ }
451
+ }
452
+ if (performance.now() - t > 1) break;
453
+ }
454
+ this.#onDeferTokenize(lines);
455
+ if (this.#isStopped || this.#isPaused || jobId !== this.#backgroundJobId) return;
456
+ if (settled || line >= totalLines) {
457
+ const pendingPrebuildEndLine = this.#pendingPrebuildEndLine;
458
+ this.stopBackgroundTokenize();
459
+ if (pendingPrebuildEndLine >= 0) this.#scheduleStatePrebuild(pendingPrebuildEndLine);
460
+ return;
461
+ }
462
+ this.#lastLine = line;
463
+ this.#backgroundChangedRangeIndex = changedRangeIndex;
464
+ this.#postTokenizeMessage(jobId);
465
+ }
466
+ };
467
+ function tokenizeLine(grammar, colorMap, lineText, stateStack, timeLimit, collectBracketIgnoredRanges = true, resolveTokens = true) {
468
+ const result = grammar.tokenizeLine2(lineText, stateStack, timeLimit);
469
+ if (result.stoppedEarly) console.warn(`[diffs] Time limit reached when tokenizing line: ${lineText.substring(0, 100)}`);
470
+ const rawTokens = result.tokens;
471
+ const tokensLength = rawTokens.length / 2;
472
+ const resolvedTokens = [];
473
+ const bracketIgnoredRanges = [];
474
+ if (!resolveTokens && !collectBracketIgnoredRanges) return {
475
+ ruleStack: result.ruleStack,
476
+ resolvedTokens,
477
+ bracketIgnoredRanges
478
+ };
479
+ for (let j = 0; j < tokensLength; j++) {
480
+ const offset = rawTokens[2 * j];
481
+ const nextOffset = j + 1 < tokensLength ? rawTokens[2 * j + 2] : lineText.length;
482
+ if (offset === nextOffset) continue;
483
+ const metadata = rawTokens[2 * j + 1];
484
+ if (resolveTokens) {
485
+ const fg = (void 0).getForeground(metadata);
486
+ resolvedTokens.push([
487
+ offset,
488
+ colorMap[fg],
489
+ lineText.slice(offset, nextOffset)
490
+ ]);
491
+ }
492
+ if (collectBracketIgnoredRanges && (void 0).getTokenType(metadata) > 0) bracketIgnoredRanges.push([offset, nextOffset]);
493
+ }
494
+ return {
495
+ ruleStack: result.ruleStack,
496
+ resolvedTokens,
497
+ bracketIgnoredRanges
498
+ };
499
+ }
500
+ function isGrammarlessLanguage(languageId) {
501
+ return languageId === "text" || languageId === "ansi";
502
+ }
503
+
504
+ // node_modules/@pierre/diffs/dist/highlighter/shiki-stream.js
505
+ var ShikiStreamTokenizer = class ShikiStreamTokenizer2 extends BaseStreamTokenizer {
506
+ highlighter;
507
+ options;
508
+ #tail = "";
509
+ #grammarState;
510
+ constructor(highlighter, options) {
511
+ super();
512
+ this.highlighter = highlighter;
513
+ this.options = options;
514
+ }
515
+ tokenizeChunk(chunk, stable) {
516
+ const chunkLines = (this.#tail + chunk).split(/(\r\n|\r|\n)/);
517
+ let unstable = [];
518
+ for (let i = 0; i < chunkLines.length; i += 2) {
519
+ const line = chunkLines[i];
520
+ const result = this.highlighter.codeToTokens(line, {
521
+ ...this.options,
522
+ grammarState: this.#grammarState
523
+ });
524
+ const tokens = result.tokens[0].map((token) => ({
525
+ ...token,
526
+ offset: token.offset + this.stableOffset
527
+ }));
528
+ if (i + 1 < chunkLines.length) {
529
+ appendItems(stable, tokens);
530
+ this.pushLineBreak(stable, line.length, chunkLines[i + 1]);
531
+ this.#grammarState = result.grammarState;
532
+ } else {
533
+ unstable = tokens;
534
+ this.#tail = line;
535
+ }
536
+ }
537
+ return {
538
+ unstable,
539
+ tailLength: this.#tail.length
540
+ };
541
+ }
542
+ clone() {
543
+ this.assertActive();
544
+ const clone = new ShikiStreamTokenizer2(this.highlighter, this.options);
545
+ this.copyStateTo(clone);
546
+ clone.#tail = this.#tail;
547
+ clone.#grammarState = this.#grammarState;
548
+ return clone;
549
+ }
550
+ resetSource() {
551
+ this.#tail = "";
552
+ this.#grammarState = void 0;
553
+ }
554
+ releaseSource() {
555
+ this.resetSource();
556
+ }
557
+ };
558
+
559
+ // node_modules/@pierre/diffs/dist/highlighter/backends/shiki.js
560
+ var ShikiHighlighter = class ShikiHighlighter2 extends DiffsHighlighter {
561
+ raw;
562
+ loadedThemes = /* @__PURE__ */ new Map();
563
+ attachedLanguages = /* @__PURE__ */ new Set(["text", "ansi"]);
564
+ static async create(name) {
565
+ const engine = name === "shiki-wasm" ? (await import("./chunk-E6FGQYBA.js")).createOnigurumaEngine(import("./chunk-E6FGQYBA.js")) : (await import("./chunk-E6FGQYBA.js")).createJavaScriptRegexEngine();
566
+ const raw = await (void 0)({
567
+ themes: [],
568
+ langs: [],
569
+ engine
570
+ });
571
+ return new ShikiHighlighter2(name, raw);
572
+ }
573
+ constructor(name, raw) {
574
+ super(name, createDiffsThemeResolver(name));
575
+ this.raw = raw;
576
+ }
577
+ getTheme(themeName) {
578
+ this.assertNotDisposed();
579
+ const loaded = this.loadedThemes.get(themeName);
580
+ const theme = this.themeResolver.getResolvedTheme(themeName) ?? loaded;
581
+ if (theme == null) throw new Error(`Theme "${themeName}" has not been resolved`);
582
+ if (loaded !== theme) {
583
+ const textmate = theme.textmate ?? (theme.cssVariables != null ? (void 0)(theme.cssVariables) : void 0);
584
+ if (textmate == null) throw new Error(`Theme "${themeName}" does not support Shiki`);
585
+ this.raw.setTheme({
586
+ ...textmate,
587
+ name: themeName
588
+ });
589
+ this.loadedThemes.set(themeName, theme);
590
+ }
591
+ return theme;
592
+ }
593
+ codeToTokens(code, options) {
594
+ return this.raw.codeToTokens(code, this.resolveOptions(options));
595
+ }
596
+ createEditorTokenizer(options) {
597
+ return new ShikiEditorTokenizer(this.raw, options, this);
598
+ }
599
+ createStreamTokenizer(options) {
600
+ return new ShikiStreamTokenizer(this.raw, this.resolveOptions(options));
601
+ }
602
+ async loadLanguages(languages) {
603
+ this.assertNotDisposed();
604
+ const missing = languages.filter((language) => !this.attachedLanguages.has(language));
605
+ attachResolvedLanguages(await resolveLanguages(missing), this);
606
+ }
607
+ hasLoadedLanguages(languages) {
608
+ if (this.disposed) return false;
609
+ let loaded;
610
+ return languages.every((lang) => {
611
+ if (this.attachedLanguages.has(lang)) return true;
612
+ if (RegisteredCustomLanguages.has(lang)) return false;
613
+ loaded ??= this.raw.getLoadedLanguages();
614
+ return loaded.includes(lang);
615
+ });
616
+ }
617
+ attachLanguages(languages) {
618
+ this.assertNotDisposed();
619
+ for (const lang of languages) {
620
+ if (this.attachedLanguages.has(lang.name)) continue;
621
+ const grammar = lang.data.find((grammar2) => grammar2.name === lang.name || grammar2.aliases?.includes(lang.name) === true);
622
+ if (grammar == null) throw new Error(`attachResolvedLanguages: No returned grammar declares "${lang.name}" as its name or an alias.`);
623
+ this.raw.loadLanguageSync(lang.data);
624
+ try {
625
+ this.raw.getLanguage(lang.name);
626
+ } catch {
627
+ throw new Error(`attachResolvedLanguages: "${grammar.name}" is already loaded without alias "${lang.name}". Load the alias first or give the grammar a unique name.`);
628
+ }
629
+ this.attachedLanguages.add(lang.name);
630
+ }
631
+ }
632
+ releaseResources() {
633
+ this.loadedThemes.clear();
634
+ this.attachedLanguages.clear();
635
+ this.raw.dispose();
636
+ }
637
+ resolveOptions({ theme, themes, ...options }) {
638
+ this.assertNotDisposed();
639
+ if (theme != null) {
640
+ this.getTheme(theme);
641
+ return {
642
+ ...options,
643
+ theme
644
+ };
645
+ }
646
+ if (themes == null) throw new Error("A theme or themes option is required");
647
+ for (const name of Object.values(themes)) this.getTheme(name);
648
+ return {
649
+ ...options,
650
+ themes
651
+ };
652
+ }
653
+ };
654
+ export {
655
+ ShikiHighlighter
656
+ };
657
+ //# sourceMappingURL=chunk-X2FGXM6T.js.map