markstream-vue2 0.0.44 → 0.0.46-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/chunks/cssMode-2f534f78.cjs +1 -0
  2. package/dist/chunks/cssMode-3f97e3da.js +206 -0
  3. package/dist/chunks/htmlMode-341fd8a0.cjs +1 -0
  4. package/dist/chunks/htmlMode-980b2a3d.js +222 -0
  5. package/dist/chunks/{index-b8d5777d.cjs → index-11432088.cjs} +1 -1
  6. package/dist/chunks/{index-87cdc60f.js → index-12ec401a.js} +1 -0
  7. package/dist/chunks/{index-292bb72c.js → index-40b64c02.js} +1 -0
  8. package/dist/chunks/index-6013a5b2.cjs +1 -0
  9. package/dist/chunks/{index-e0a22210.js → index-6ae3630b.js} +1 -0
  10. package/dist/chunks/{index-2a7bea2c.js → index-754b8598.js} +1 -0
  11. package/dist/chunks/{index-42252d16.js → index-8dc37342.js} +1 -0
  12. package/dist/chunks/{index-8693b3db.cjs → index-a4867ea2.cjs} +1 -1
  13. package/dist/chunks/index-e0125777.cjs +1 -0
  14. package/dist/chunks/{index-91325ae4.cjs → index-fb457079.cjs} +1 -1
  15. package/dist/chunks/{index.legacy-1c6de434.js → index.legacy-1f634d9d.js} +174442 -100665
  16. package/dist/chunks/index.legacy-b598deaf.cjs +1 -0
  17. package/dist/chunks/jsonMode-9ba44ad3.js +921 -0
  18. package/dist/chunks/jsonMode-d32122b2.cjs +1 -0
  19. package/dist/chunks/lspLanguageFeatures-7b72a0c0.cjs +1 -0
  20. package/dist/chunks/{cssMode-32774a06.js → lspLanguageFeatures-8d6ce48e.js} +84 -286
  21. package/dist/chunks/{tsMode-6444eb2b.js → tsMode-eb76a00c.js} +165 -143
  22. package/dist/chunks/tsMode-fbe6879d.cjs +1 -0
  23. package/dist/chunks/workers-ac3ab4dd.cjs +1 -0
  24. package/dist/chunks/workers-c9c93e2c.js +71 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.css +1 -1
  27. package/dist/index.d.ts +25 -7
  28. package/dist/index.js +4984 -3981
  29. package/dist/index.px.css +1 -1
  30. package/dist/index.tailwind.css +1 -1
  31. package/dist/tailwind.ts +1 -1
  32. package/dist/types/components/CodeBlockNode/CodeBlockNode.vue.d.ts +30 -11
  33. package/dist/types/components/CodeBlockNode/HtmlPreviewFrame.vue.d.ts +2 -0
  34. package/dist/types/components/D2BlockNode/D2BlockNode.vue.d.ts +3 -3
  35. package/dist/types/components/D2BlockNode/d2.d.ts +13 -2
  36. package/dist/types/components/HeadingNode/HeadingNode.vue.d.ts +1 -1
  37. package/dist/types/components/HtmlBlockNode/HtmlBlockNode.vue.d.ts +19 -1
  38. package/dist/types/components/HtmlInlineNode/HtmlInlineNode.vue.d.ts +2 -0
  39. package/dist/types/components/ImageNode/ImageNode.vue.d.ts +3 -16
  40. package/dist/types/components/InfographicBlockNode/InfographicBlockNode.vue.d.ts +4 -3
  41. package/dist/types/components/InfographicBlockNode/infographic.d.ts +13 -1
  42. package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.vue.d.ts +54 -14
  43. package/dist/types/components/MarkdownRenderCompat.vue.d.ts +13 -2
  44. package/dist/types/components/MathInlineNode/katex.d.ts +5 -2
  45. package/dist/types/components/MermaidBlockNode/MermaidBlockNode.vue.d.ts +8 -3
  46. package/dist/types/components/MermaidBlockNode/mermaid.d.ts +16 -2
  47. package/dist/types/components/NestedRenderer/NestedRenderer.vue.d.ts +1 -1
  48. package/dist/types/components/NodeRenderer/LegacyNodesRenderer.vue.d.ts +32 -9
  49. package/dist/types/components/NodeRenderer/NodeRenderer.vue.d.ts +53 -17
  50. package/dist/types/components/ParagraphNode/ParagraphNode.vue.d.ts +1 -0
  51. package/dist/types/components/TableNode/TableNode.vue.d.ts +3 -1
  52. package/dist/types/components/TextNode/streamingTextState.d.ts +2 -11
  53. package/dist/types/composables/useSafeI18n.d.ts +3 -3
  54. package/dist/types/composables/useSmoothMarkdownStream.d.ts +21 -0
  55. package/dist/types/composables/viewportPriority.d.ts +4 -3
  56. package/dist/types/exports.d.ts +25 -7
  57. package/dist/types/types/component-props.d.ts +35 -11
  58. package/dist/types/types/index.d.ts +2 -6
  59. package/dist/types/utils/codeBlockExtraProps.d.ts +4 -0
  60. package/dist/types/utils/devEnv.d.ts +1 -0
  61. package/dist/types/utils/diagramHeight.d.ts +11 -0
  62. package/dist/types/utils/htmlRenderer.d.ts +5 -27
  63. package/dist/types/utils/nestedHtml.d.ts +2 -1
  64. package/dist/types/utils/nestedNodes.d.ts +6 -1
  65. package/dist/types/utils/normalizeKaTeXRenderInput.d.ts +1 -0
  66. package/dist/workers/css.worker.js +1 -0
  67. package/dist/workers/html.worker.js +1 -0
  68. package/dist/workers/json.worker.js +1 -0
  69. package/dist/workers/mermaidParser.worker.js +1 -1
  70. package/dist/workers/ts.worker.js +6 -0
  71. package/package.json +9 -6
  72. package/dist/chunks/cssMode-86e8d6e4.cjs +0 -1
  73. package/dist/chunks/htmlMode-076e483c.js +0 -2060
  74. package/dist/chunks/htmlMode-f84c7583.cjs +0 -1
  75. package/dist/chunks/index-c6f74f2d.cjs +0 -1
  76. package/dist/chunks/index-e1315bc2.cjs +0 -1
  77. package/dist/chunks/index.legacy-70f0e155.cjs +0 -1
  78. package/dist/chunks/jsonMode-186d141c.js +0 -2759
  79. package/dist/chunks/jsonMode-e60229b9.cjs +0 -1
  80. package/dist/chunks/tsMode-5b9a0ba1.cjs +0 -1
  81. package/dist/types/components/SoftBreakNode/SoftBreakNode.vue.d.ts +0 -17
  82. package/dist/types/components/SoftBreakNode/index.d.ts +0 -2
@@ -0,0 +1,921 @@
1
+ import { c as createWebWorker } from "./workers-c9c93e2c.js";
2
+ import { D as DocumentFormattingEditProvider, a as DocumentRangeFormattingEditProvider, C as CompletionAdapter, H as HoverAdapter, b as DocumentSymbolAdapter, c as DocumentColorAdapter, F as FoldingRangeAdapter, S as SelectionRangeAdapter, d as DiagnosticsAdapter } from "./lspLanguageFeatures-8d6ce48e.js";
3
+ import { e, f, g, R, h, i, j, t, k } from "./lspLanguageFeatures-8d6ce48e.js";
4
+ import { l as languages, e as editor } from "./index.legacy-1f634d9d.js";
5
+ import "shiki";
6
+ const STOP_WHEN_IDLE_FOR = 2 * 60 * 1e3;
7
+ class WorkerManager {
8
+ constructor(defaults) {
9
+ this._defaults = defaults;
10
+ this._worker = null;
11
+ this._client = null;
12
+ this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1e3);
13
+ this._lastUsedTime = 0;
14
+ this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
15
+ }
16
+ _stopWorker() {
17
+ if (this._worker) {
18
+ this._worker.dispose();
19
+ this._worker = null;
20
+ }
21
+ this._client = null;
22
+ }
23
+ dispose() {
24
+ clearInterval(this._idleCheckInterval);
25
+ this._configChangeListener.dispose();
26
+ this._stopWorker();
27
+ }
28
+ _checkIfIdle() {
29
+ if (!this._worker) {
30
+ return;
31
+ }
32
+ let timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
33
+ if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
34
+ this._stopWorker();
35
+ }
36
+ }
37
+ _getClient() {
38
+ this._lastUsedTime = Date.now();
39
+ if (!this._client) {
40
+ this._worker = createWebWorker({
41
+ // module that exports the create() method and returns a `JSONWorker` instance
42
+ moduleId: "vs/language/json/jsonWorker",
43
+ createWorker: () => new Worker(new URL("/workers/json.worker.js", self.location), { type: "module" }),
44
+ label: this._defaults.languageId,
45
+ // passed in to the create() method
46
+ createData: {
47
+ languageSettings: this._defaults.diagnosticsOptions,
48
+ languageId: this._defaults.languageId,
49
+ enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest
50
+ }
51
+ });
52
+ this._client = this._worker.getProxy();
53
+ }
54
+ return this._client;
55
+ }
56
+ getLanguageServiceWorker(...resources) {
57
+ let _client;
58
+ return this._getClient().then((client) => {
59
+ _client = client;
60
+ }).then((_) => {
61
+ if (this._worker) {
62
+ return this._worker.withSyncedResources(resources);
63
+ }
64
+ }).then((_) => _client);
65
+ }
66
+ }
67
+ function createScanner$1(text, ignoreTrivia = false) {
68
+ const len = text.length;
69
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
70
+ function scanHexDigits(count, exact) {
71
+ let digits = 0;
72
+ let value2 = 0;
73
+ while (digits < count || false) {
74
+ let ch = text.charCodeAt(pos);
75
+ if (ch >= 48 && ch <= 57) {
76
+ value2 = value2 * 16 + ch - 48;
77
+ } else if (ch >= 65 && ch <= 70) {
78
+ value2 = value2 * 16 + ch - 65 + 10;
79
+ } else if (ch >= 97 && ch <= 102) {
80
+ value2 = value2 * 16 + ch - 97 + 10;
81
+ } else {
82
+ break;
83
+ }
84
+ pos++;
85
+ digits++;
86
+ }
87
+ if (digits < count) {
88
+ value2 = -1;
89
+ }
90
+ return value2;
91
+ }
92
+ function setPosition(newPosition) {
93
+ pos = newPosition;
94
+ value = "";
95
+ tokenOffset = 0;
96
+ token = 16;
97
+ scanError = 0;
98
+ }
99
+ function scanNumber() {
100
+ let start = pos;
101
+ if (text.charCodeAt(pos) === 48) {
102
+ pos++;
103
+ } else {
104
+ pos++;
105
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
106
+ pos++;
107
+ }
108
+ }
109
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
110
+ pos++;
111
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
112
+ pos++;
113
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
114
+ pos++;
115
+ }
116
+ } else {
117
+ scanError = 3;
118
+ return text.substring(start, pos);
119
+ }
120
+ }
121
+ let end = pos;
122
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
123
+ pos++;
124
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
125
+ pos++;
126
+ }
127
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
128
+ pos++;
129
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
130
+ pos++;
131
+ }
132
+ end = pos;
133
+ } else {
134
+ scanError = 3;
135
+ }
136
+ }
137
+ return text.substring(start, end);
138
+ }
139
+ function scanString() {
140
+ let result = "", start = pos;
141
+ while (true) {
142
+ if (pos >= len) {
143
+ result += text.substring(start, pos);
144
+ scanError = 2;
145
+ break;
146
+ }
147
+ const ch = text.charCodeAt(pos);
148
+ if (ch === 34) {
149
+ result += text.substring(start, pos);
150
+ pos++;
151
+ break;
152
+ }
153
+ if (ch === 92) {
154
+ result += text.substring(start, pos);
155
+ pos++;
156
+ if (pos >= len) {
157
+ scanError = 2;
158
+ break;
159
+ }
160
+ const ch2 = text.charCodeAt(pos++);
161
+ switch (ch2) {
162
+ case 34:
163
+ result += '"';
164
+ break;
165
+ case 92:
166
+ result += "\\";
167
+ break;
168
+ case 47:
169
+ result += "/";
170
+ break;
171
+ case 98:
172
+ result += "\b";
173
+ break;
174
+ case 102:
175
+ result += "\f";
176
+ break;
177
+ case 110:
178
+ result += "\n";
179
+ break;
180
+ case 114:
181
+ result += "\r";
182
+ break;
183
+ case 116:
184
+ result += " ";
185
+ break;
186
+ case 117:
187
+ const ch3 = scanHexDigits(4);
188
+ if (ch3 >= 0) {
189
+ result += String.fromCharCode(ch3);
190
+ } else {
191
+ scanError = 4;
192
+ }
193
+ break;
194
+ default:
195
+ scanError = 5;
196
+ }
197
+ start = pos;
198
+ continue;
199
+ }
200
+ if (ch >= 0 && ch <= 31) {
201
+ if (isLineBreak(ch)) {
202
+ result += text.substring(start, pos);
203
+ scanError = 2;
204
+ break;
205
+ } else {
206
+ scanError = 6;
207
+ }
208
+ }
209
+ pos++;
210
+ }
211
+ return result;
212
+ }
213
+ function scanNext() {
214
+ value = "";
215
+ scanError = 0;
216
+ tokenOffset = pos;
217
+ lineStartOffset = lineNumber;
218
+ prevTokenLineStartOffset = tokenLineStartOffset;
219
+ if (pos >= len) {
220
+ tokenOffset = len;
221
+ return token = 17;
222
+ }
223
+ let code = text.charCodeAt(pos);
224
+ if (isWhiteSpace(code)) {
225
+ do {
226
+ pos++;
227
+ value += String.fromCharCode(code);
228
+ code = text.charCodeAt(pos);
229
+ } while (isWhiteSpace(code));
230
+ return token = 15;
231
+ }
232
+ if (isLineBreak(code)) {
233
+ pos++;
234
+ value += String.fromCharCode(code);
235
+ if (code === 13 && text.charCodeAt(pos) === 10) {
236
+ pos++;
237
+ value += "\n";
238
+ }
239
+ lineNumber++;
240
+ tokenLineStartOffset = pos;
241
+ return token = 14;
242
+ }
243
+ switch (code) {
244
+ case 123:
245
+ pos++;
246
+ return token = 1;
247
+ case 125:
248
+ pos++;
249
+ return token = 2;
250
+ case 91:
251
+ pos++;
252
+ return token = 3;
253
+ case 93:
254
+ pos++;
255
+ return token = 4;
256
+ case 58:
257
+ pos++;
258
+ return token = 6;
259
+ case 44:
260
+ pos++;
261
+ return token = 5;
262
+ case 34:
263
+ pos++;
264
+ value = scanString();
265
+ return token = 10;
266
+ case 47:
267
+ const start = pos - 1;
268
+ if (text.charCodeAt(pos + 1) === 47) {
269
+ pos += 2;
270
+ while (pos < len) {
271
+ if (isLineBreak(text.charCodeAt(pos))) {
272
+ break;
273
+ }
274
+ pos++;
275
+ }
276
+ value = text.substring(start, pos);
277
+ return token = 12;
278
+ }
279
+ if (text.charCodeAt(pos + 1) === 42) {
280
+ pos += 2;
281
+ const safeLength = len - 1;
282
+ let commentClosed = false;
283
+ while (pos < safeLength) {
284
+ const ch = text.charCodeAt(pos);
285
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
286
+ pos += 2;
287
+ commentClosed = true;
288
+ break;
289
+ }
290
+ pos++;
291
+ if (isLineBreak(ch)) {
292
+ if (ch === 13 && text.charCodeAt(pos) === 10) {
293
+ pos++;
294
+ }
295
+ lineNumber++;
296
+ tokenLineStartOffset = pos;
297
+ }
298
+ }
299
+ if (!commentClosed) {
300
+ pos++;
301
+ scanError = 1;
302
+ }
303
+ value = text.substring(start, pos);
304
+ return token = 13;
305
+ }
306
+ value += String.fromCharCode(code);
307
+ pos++;
308
+ return token = 16;
309
+ case 45:
310
+ value += String.fromCharCode(code);
311
+ pos++;
312
+ if (pos === len || !isDigit(text.charCodeAt(pos))) {
313
+ return token = 16;
314
+ }
315
+ case 48:
316
+ case 49:
317
+ case 50:
318
+ case 51:
319
+ case 52:
320
+ case 53:
321
+ case 54:
322
+ case 55:
323
+ case 56:
324
+ case 57:
325
+ value += scanNumber();
326
+ return token = 11;
327
+ default:
328
+ while (pos < len && isUnknownContentCharacter(code)) {
329
+ pos++;
330
+ code = text.charCodeAt(pos);
331
+ }
332
+ if (tokenOffset !== pos) {
333
+ value = text.substring(tokenOffset, pos);
334
+ switch (value) {
335
+ case "true":
336
+ return token = 8;
337
+ case "false":
338
+ return token = 9;
339
+ case "null":
340
+ return token = 7;
341
+ }
342
+ return token = 16;
343
+ }
344
+ value += String.fromCharCode(code);
345
+ pos++;
346
+ return token = 16;
347
+ }
348
+ }
349
+ function isUnknownContentCharacter(code) {
350
+ if (isWhiteSpace(code) || isLineBreak(code)) {
351
+ return false;
352
+ }
353
+ switch (code) {
354
+ case 125:
355
+ case 93:
356
+ case 123:
357
+ case 91:
358
+ case 34:
359
+ case 58:
360
+ case 44:
361
+ case 47:
362
+ return false;
363
+ }
364
+ return true;
365
+ }
366
+ function scanNextNonTrivia() {
367
+ let result;
368
+ do {
369
+ result = scanNext();
370
+ } while (result >= 12 && result <= 15);
371
+ return result;
372
+ }
373
+ return {
374
+ setPosition,
375
+ getPosition: () => pos,
376
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
377
+ getToken: () => token,
378
+ getTokenValue: () => value,
379
+ getTokenOffset: () => tokenOffset,
380
+ getTokenLength: () => pos - tokenOffset,
381
+ getTokenStartLine: () => lineStartOffset,
382
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
383
+ getTokenError: () => scanError
384
+ };
385
+ }
386
+ function isWhiteSpace(ch) {
387
+ return ch === 32 || ch === 9;
388
+ }
389
+ function isLineBreak(ch) {
390
+ return ch === 10 || ch === 13;
391
+ }
392
+ function isDigit(ch) {
393
+ return ch >= 48 && ch <= 57;
394
+ }
395
+ var CharacterCodes;
396
+ (function(CharacterCodes2) {
397
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
398
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
399
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
400
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
401
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
402
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
403
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
404
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
405
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
406
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
407
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
408
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
409
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
410
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
411
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
412
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
413
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
414
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
415
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
416
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
417
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
418
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
419
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
420
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
421
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
422
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
423
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
424
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
425
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
426
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
427
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
428
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
429
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
430
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
431
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
432
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
433
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
434
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
435
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
436
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
437
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
438
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
439
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
440
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
441
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
442
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
443
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
444
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
445
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
446
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
447
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
448
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
449
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
450
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
451
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
452
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
453
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
454
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
455
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
456
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
457
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
458
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
459
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
460
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
461
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
462
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
463
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
464
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
465
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
466
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
467
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
468
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
469
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
470
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
471
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
472
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
473
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
474
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
475
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
476
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
477
+ })(CharacterCodes || (CharacterCodes = {}));
478
+ new Array(20).fill(0).map((_, index) => {
479
+ return " ".repeat(index);
480
+ });
481
+ const maxCachedValues = 200;
482
+ ({
483
+ " ": {
484
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
485
+ return "\n" + " ".repeat(index);
486
+ }),
487
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
488
+ return "\r" + " ".repeat(index);
489
+ }),
490
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
491
+ return "\r\n" + " ".repeat(index);
492
+ })
493
+ },
494
+ " ": {
495
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
496
+ return "\n" + " ".repeat(index);
497
+ }),
498
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
499
+ return "\r" + " ".repeat(index);
500
+ }),
501
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
502
+ return "\r\n" + " ".repeat(index);
503
+ })
504
+ }
505
+ });
506
+ var ParseOptions;
507
+ (function(ParseOptions2) {
508
+ ParseOptions2.DEFAULT = {
509
+ allowTrailingComma: false
510
+ };
511
+ })(ParseOptions || (ParseOptions = {}));
512
+ const createScanner = createScanner$1;
513
+ var ScanError;
514
+ (function(ScanError2) {
515
+ ScanError2[ScanError2["None"] = 0] = "None";
516
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
517
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
518
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
519
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
520
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
521
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
522
+ })(ScanError || (ScanError = {}));
523
+ var SyntaxKind;
524
+ (function(SyntaxKind2) {
525
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
526
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
527
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
528
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
529
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
530
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
531
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
532
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
533
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
534
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
535
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
536
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
537
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
538
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
539
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
540
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
541
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
542
+ })(SyntaxKind || (SyntaxKind = {}));
543
+ var ParseErrorCode;
544
+ (function(ParseErrorCode2) {
545
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
546
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
547
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
548
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
549
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
550
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
551
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
552
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
553
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
554
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
555
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
556
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
557
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
558
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
559
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
560
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
561
+ })(ParseErrorCode || (ParseErrorCode = {}));
562
+ function createTokenizationSupport(supportComments) {
563
+ return {
564
+ getInitialState: () => new JSONState(null, null, false, null),
565
+ tokenize: (line, state) => tokenize(supportComments, line, state)
566
+ };
567
+ }
568
+ const TOKEN_DELIM_OBJECT = "delimiter.bracket.json";
569
+ const TOKEN_DELIM_ARRAY = "delimiter.array.json";
570
+ const TOKEN_DELIM_COLON = "delimiter.colon.json";
571
+ const TOKEN_DELIM_COMMA = "delimiter.comma.json";
572
+ const TOKEN_VALUE_BOOLEAN = "keyword.json";
573
+ const TOKEN_VALUE_NULL = "keyword.json";
574
+ const TOKEN_VALUE_STRING = "string.value.json";
575
+ const TOKEN_VALUE_NUMBER = "number.json";
576
+ const TOKEN_PROPERTY_NAME = "string.key.json";
577
+ const TOKEN_COMMENT_BLOCK = "comment.block.json";
578
+ const TOKEN_COMMENT_LINE = "comment.line.json";
579
+ class ParentsStack {
580
+ constructor(parent, type) {
581
+ this.parent = parent;
582
+ this.type = type;
583
+ }
584
+ static pop(parents) {
585
+ if (parents) {
586
+ return parents.parent;
587
+ }
588
+ return null;
589
+ }
590
+ static push(parents, type) {
591
+ return new ParentsStack(parents, type);
592
+ }
593
+ static equals(a, b) {
594
+ if (!a && !b) {
595
+ return true;
596
+ }
597
+ if (!a || !b) {
598
+ return false;
599
+ }
600
+ while (a && b) {
601
+ if (a === b) {
602
+ return true;
603
+ }
604
+ if (a.type !== b.type) {
605
+ return false;
606
+ }
607
+ a = a.parent;
608
+ b = b.parent;
609
+ }
610
+ return true;
611
+ }
612
+ }
613
+ class JSONState {
614
+ constructor(state, scanError, lastWasColon, parents) {
615
+ this._state = state;
616
+ this.scanError = scanError;
617
+ this.lastWasColon = lastWasColon;
618
+ this.parents = parents;
619
+ }
620
+ clone() {
621
+ return new JSONState(this._state, this.scanError, this.lastWasColon, this.parents);
622
+ }
623
+ equals(other) {
624
+ if (other === this) {
625
+ return true;
626
+ }
627
+ if (!other || !(other instanceof JSONState)) {
628
+ return false;
629
+ }
630
+ return this.scanError === other.scanError && this.lastWasColon === other.lastWasColon && ParentsStack.equals(this.parents, other.parents);
631
+ }
632
+ getStateData() {
633
+ return this._state;
634
+ }
635
+ setStateData(state) {
636
+ this._state = state;
637
+ }
638
+ }
639
+ function tokenize(comments, line, state, offsetDelta = 0) {
640
+ let numberOfInsertedCharacters = 0;
641
+ let adjustOffset = false;
642
+ switch (state.scanError) {
643
+ case 2:
644
+ line = '"' + line;
645
+ numberOfInsertedCharacters = 1;
646
+ break;
647
+ case 1:
648
+ line = "/*" + line;
649
+ numberOfInsertedCharacters = 2;
650
+ break;
651
+ }
652
+ const scanner = createScanner(line);
653
+ let lastWasColon = state.lastWasColon;
654
+ let parents = state.parents;
655
+ const ret = {
656
+ tokens: [],
657
+ endState: state.clone()
658
+ };
659
+ while (true) {
660
+ let offset = offsetDelta + scanner.getPosition();
661
+ let type = "";
662
+ const kind = scanner.scan();
663
+ if (kind === 17) {
664
+ break;
665
+ }
666
+ if (offset === offsetDelta + scanner.getPosition()) {
667
+ throw new Error(
668
+ "Scanner did not advance, next 3 characters are: " + line.substr(scanner.getPosition(), 3)
669
+ );
670
+ }
671
+ if (adjustOffset) {
672
+ offset -= numberOfInsertedCharacters;
673
+ }
674
+ adjustOffset = numberOfInsertedCharacters > 0;
675
+ switch (kind) {
676
+ case 1:
677
+ parents = ParentsStack.push(
678
+ parents,
679
+ 0
680
+ /* Object */
681
+ );
682
+ type = TOKEN_DELIM_OBJECT;
683
+ lastWasColon = false;
684
+ break;
685
+ case 2:
686
+ parents = ParentsStack.pop(parents);
687
+ type = TOKEN_DELIM_OBJECT;
688
+ lastWasColon = false;
689
+ break;
690
+ case 3:
691
+ parents = ParentsStack.push(
692
+ parents,
693
+ 1
694
+ /* Array */
695
+ );
696
+ type = TOKEN_DELIM_ARRAY;
697
+ lastWasColon = false;
698
+ break;
699
+ case 4:
700
+ parents = ParentsStack.pop(parents);
701
+ type = TOKEN_DELIM_ARRAY;
702
+ lastWasColon = false;
703
+ break;
704
+ case 6:
705
+ type = TOKEN_DELIM_COLON;
706
+ lastWasColon = true;
707
+ break;
708
+ case 5:
709
+ type = TOKEN_DELIM_COMMA;
710
+ lastWasColon = false;
711
+ break;
712
+ case 8:
713
+ case 9:
714
+ type = TOKEN_VALUE_BOOLEAN;
715
+ lastWasColon = false;
716
+ break;
717
+ case 7:
718
+ type = TOKEN_VALUE_NULL;
719
+ lastWasColon = false;
720
+ break;
721
+ case 10:
722
+ const currentParent = parents ? parents.type : 0;
723
+ const inArray = currentParent === 1;
724
+ type = lastWasColon || inArray ? TOKEN_VALUE_STRING : TOKEN_PROPERTY_NAME;
725
+ lastWasColon = false;
726
+ break;
727
+ case 11:
728
+ type = TOKEN_VALUE_NUMBER;
729
+ lastWasColon = false;
730
+ break;
731
+ }
732
+ {
733
+ switch (kind) {
734
+ case 12:
735
+ type = TOKEN_COMMENT_LINE;
736
+ break;
737
+ case 13:
738
+ type = TOKEN_COMMENT_BLOCK;
739
+ break;
740
+ }
741
+ }
742
+ ret.endState = new JSONState(
743
+ state.getStateData(),
744
+ scanner.getTokenError(),
745
+ lastWasColon,
746
+ parents
747
+ );
748
+ ret.tokens.push({
749
+ startIndex: offset,
750
+ scopes: type
751
+ });
752
+ }
753
+ return ret;
754
+ }
755
+ let worker;
756
+ function getWorker() {
757
+ return new Promise((resolve, reject) => {
758
+ if (!worker) {
759
+ return reject("JSON not registered!");
760
+ }
761
+ resolve(worker);
762
+ });
763
+ }
764
+ class JSONDiagnosticsAdapter extends DiagnosticsAdapter {
765
+ constructor(languageId, worker2, defaults) {
766
+ super(languageId, worker2, defaults.onDidChange);
767
+ this._disposables.push(
768
+ editor.onWillDisposeModel((model) => {
769
+ this._resetSchema(model.uri);
770
+ })
771
+ );
772
+ this._disposables.push(
773
+ editor.onDidChangeModelLanguage((event) => {
774
+ this._resetSchema(event.model.uri);
775
+ })
776
+ );
777
+ }
778
+ _resetSchema(resource) {
779
+ this._worker().then((worker2) => {
780
+ worker2.resetSchema(resource.toString());
781
+ });
782
+ }
783
+ }
784
+ function setupMode(defaults) {
785
+ const disposables = [];
786
+ const providers = [];
787
+ const client = new WorkerManager(defaults);
788
+ disposables.push(client);
789
+ worker = (...uris) => {
790
+ return client.getLanguageServiceWorker(...uris);
791
+ };
792
+ function registerProviders() {
793
+ const { languageId, modeConfiguration: modeConfiguration2 } = defaults;
794
+ disposeAll(providers);
795
+ if (modeConfiguration2.documentFormattingEdits) {
796
+ providers.push(
797
+ languages.registerDocumentFormattingEditProvider(
798
+ languageId,
799
+ new DocumentFormattingEditProvider(worker)
800
+ )
801
+ );
802
+ }
803
+ if (modeConfiguration2.documentRangeFormattingEdits) {
804
+ providers.push(
805
+ languages.registerDocumentRangeFormattingEditProvider(
806
+ languageId,
807
+ new DocumentRangeFormattingEditProvider(worker)
808
+ )
809
+ );
810
+ }
811
+ if (modeConfiguration2.completionItems) {
812
+ providers.push(
813
+ languages.registerCompletionItemProvider(
814
+ languageId,
815
+ new CompletionAdapter(worker, [" ", ":", '"'])
816
+ )
817
+ );
818
+ }
819
+ if (modeConfiguration2.hovers) {
820
+ providers.push(
821
+ languages.registerHoverProvider(languageId, new HoverAdapter(worker))
822
+ );
823
+ }
824
+ if (modeConfiguration2.documentSymbols) {
825
+ providers.push(
826
+ languages.registerDocumentSymbolProvider(
827
+ languageId,
828
+ new DocumentSymbolAdapter(worker)
829
+ )
830
+ );
831
+ }
832
+ if (modeConfiguration2.tokens) {
833
+ providers.push(languages.setTokensProvider(languageId, createTokenizationSupport(true)));
834
+ }
835
+ if (modeConfiguration2.colors) {
836
+ providers.push(
837
+ languages.registerColorProvider(
838
+ languageId,
839
+ new DocumentColorAdapter(worker)
840
+ )
841
+ );
842
+ }
843
+ if (modeConfiguration2.foldingRanges) {
844
+ providers.push(
845
+ languages.registerFoldingRangeProvider(
846
+ languageId,
847
+ new FoldingRangeAdapter(worker)
848
+ )
849
+ );
850
+ }
851
+ if (modeConfiguration2.diagnostics) {
852
+ providers.push(new JSONDiagnosticsAdapter(languageId, worker, defaults));
853
+ }
854
+ if (modeConfiguration2.selectionRanges) {
855
+ providers.push(
856
+ languages.registerSelectionRangeProvider(
857
+ languageId,
858
+ new SelectionRangeAdapter(worker)
859
+ )
860
+ );
861
+ }
862
+ }
863
+ registerProviders();
864
+ disposables.push(languages.setLanguageConfiguration(defaults.languageId, richEditConfiguration));
865
+ let modeConfiguration = defaults.modeConfiguration;
866
+ defaults.onDidChange((newDefaults) => {
867
+ if (newDefaults.modeConfiguration !== modeConfiguration) {
868
+ modeConfiguration = newDefaults.modeConfiguration;
869
+ registerProviders();
870
+ }
871
+ });
872
+ disposables.push(asDisposable(providers));
873
+ return asDisposable(disposables);
874
+ }
875
+ function asDisposable(disposables) {
876
+ return { dispose: () => disposeAll(disposables) };
877
+ }
878
+ function disposeAll(disposables) {
879
+ while (disposables.length) {
880
+ disposables.pop().dispose();
881
+ }
882
+ }
883
+ const richEditConfiguration = {
884
+ wordPattern: /(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,
885
+ comments: {
886
+ lineComment: "//",
887
+ blockComment: ["/*", "*/"]
888
+ },
889
+ brackets: [
890
+ ["{", "}"],
891
+ ["[", "]"]
892
+ ],
893
+ autoClosingPairs: [
894
+ { open: "{", close: "}", notIn: ["string"] },
895
+ { open: "[", close: "]", notIn: ["string"] },
896
+ { open: '"', close: '"', notIn: ["string"] }
897
+ ]
898
+ };
899
+ export {
900
+ CompletionAdapter,
901
+ e as DefinitionAdapter,
902
+ DiagnosticsAdapter,
903
+ DocumentColorAdapter,
904
+ DocumentFormattingEditProvider,
905
+ f as DocumentHighlightAdapter,
906
+ g as DocumentLinkAdapter,
907
+ DocumentRangeFormattingEditProvider,
908
+ DocumentSymbolAdapter,
909
+ FoldingRangeAdapter,
910
+ HoverAdapter,
911
+ R as ReferenceAdapter,
912
+ h as RenameAdapter,
913
+ SelectionRangeAdapter,
914
+ WorkerManager,
915
+ i as fromPosition,
916
+ j as fromRange,
917
+ getWorker,
918
+ setupMode,
919
+ t as toRange,
920
+ k as toTextEdit
921
+ };