likec4 1.48.0 → 1.49.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 (113) hide show
  1. package/README.md +11 -1
  2. package/__app__/src/likec4.js +5595 -4127
  3. package/__app__/src/routes/index.js +3 -153
  4. package/__app__/src/routes/projects.js +21 -1087
  5. package/__app__/src/routes/single.js +1221 -16
  6. package/__app__/src/style.css +1 -1
  7. package/__app__/src/vendors.js +3507 -894
  8. package/__app__/src/webcomponent.js +1 -1
  9. package/config/schema.json +155 -143
  10. package/dist/THIRD-PARTY-LICENSES.md +1739 -0
  11. package/dist/_chunks/GraphvizBinaryAdapter.mjs +72 -0
  12. package/dist/_chunks/filenames.mjs +14 -0
  13. package/dist/_chunks/index.d.mts +224 -129
  14. package/dist/_chunks/index2.d.mts +2033 -1908
  15. package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -3969
  16. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
  17. package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
  18. package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
  19. package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
  20. package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
  21. package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
  22. package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
  23. package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +14 -14
  24. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
  25. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
  26. package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
  27. package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
  28. package/dist/_chunks/libs/ajv.mjs +1 -777
  29. package/dist/_chunks/libs/atomically.mjs +1 -362
  30. package/dist/_chunks/libs/birpc.mjs +1 -201
  31. package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
  32. package/dist/_chunks/libs/chevrotain.mjs +55 -6229
  33. package/dist/_chunks/libs/conf.mjs +1 -2258
  34. package/dist/_chunks/libs/defu.mjs +1 -42
  35. package/dist/_chunks/libs/esm-env.mjs +1 -5
  36. package/dist/_chunks/libs/eventemitter3.mjs +1 -243
  37. package/dist/_chunks/libs/fast-equals.mjs +1 -446
  38. package/dist/_chunks/libs/find-up-simple.mjs +1 -24
  39. package/dist/_chunks/libs/get-port.mjs +1 -107
  40. package/dist/_chunks/libs/is-docker.mjs +1 -26
  41. package/dist/_chunks/libs/is-error-instance.mjs +1 -26
  42. package/dist/_chunks/libs/is-inside-container.mjs +1 -20
  43. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  44. package/dist/_chunks/libs/isexe.mjs +1 -127
  45. package/dist/_chunks/libs/json5.mjs +14 -959
  46. package/dist/_chunks/libs/khroma.mjs +1 -605
  47. package/dist/_chunks/libs/ky.mjs +2 -807
  48. package/dist/_chunks/libs/langium.d.mts +2880 -2844
  49. package/dist/_chunks/libs/langium.mjs +32 -20351
  50. package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
  51. package/dist/_chunks/libs/nanostores.mjs +1 -198
  52. package/dist/_chunks/libs/p-limit.mjs +1 -120
  53. package/dist/_chunks/libs/p-queue.mjs +1 -449
  54. package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
  55. package/dist/_chunks/libs/package-up.mjs +1 -10
  56. package/dist/_chunks/libs/parse-ms.mjs +1 -36
  57. package/dist/_chunks/libs/pathe.mjs +1 -0
  58. package/dist/_chunks/libs/picomatch.mjs +1 -1673
  59. package/dist/_chunks/libs/pretty-ms.mjs +1 -80
  60. package/dist/_chunks/libs/remeda.mjs +1 -690
  61. package/dist/_chunks/libs/safe-stringify.mjs +1 -21
  62. package/dist/_chunks/libs/strip-indent.mjs +1 -15
  63. package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
  64. package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
  65. package/dist/_chunks/libs/ufo.mjs +1 -240
  66. package/dist/_chunks/libs/which.mjs +1 -84
  67. package/dist/_chunks/libs/word-wrap.mjs +12 -43
  68. package/dist/_chunks/node.mjs +481 -0
  69. package/dist/_chunks/plugin.mjs +98 -772
  70. package/dist/_chunks/rolldown-runtime.mjs +1 -48
  71. package/dist/_chunks/sequence-view.mjs +1 -575
  72. package/dist/cli/index.mjs +127 -1846
  73. package/dist/config/index.d.mts +2 -2
  74. package/dist/config/index.mjs +1 -6
  75. package/dist/index.d.mts +148 -7
  76. package/dist/index.mjs +1 -21
  77. package/dist/model/builder.mjs +1 -3
  78. package/dist/model/index.d.mts +57 -3
  79. package/dist/model/index.mjs +1 -5
  80. package/dist/vite-plugin/index.d.mts +4 -3
  81. package/dist/vite-plugin/index.mjs +1 -22
  82. package/dist/vite-plugin/internal.d.mts +5 -5
  83. package/dist/vite-plugin/internal.mjs +1 -68
  84. package/package.json +60 -41
  85. package/react/{index.d.ts → index.d.mts} +112 -70
  86. package/react/{index.js → index.mjs} +21361 -22064
  87. package/react/package.json +2 -5
  88. package/vite-plugin-modules.d.ts +5 -5
  89. package/dist/_chunks/LikeC4.d.mts +0 -121
  90. package/dist/_chunks/LikeC4.mjs +0 -202
  91. package/dist/_chunks/config-app.prod.d.mts +0 -18
  92. package/dist/_chunks/config-app.prod.mjs +0 -188
  93. package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
  94. package/dist/_chunks/define-config.mjs +0 -409
  95. package/dist/_chunks/index3.d.mts +0 -60
  96. package/dist/_chunks/index4.d.mts +0 -1
  97. package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +0 -10
  98. package/dist/_chunks/libs/hono.mjs +0 -1829
  99. package/dist/_chunks/libs/nanoid.mjs +0 -29
  100. package/dist/_chunks/model.mjs +0 -12
  101. package/dist/_chunks/module.d.mts +0 -71
  102. package/dist/_chunks/module.mjs +0 -18657
  103. package/dist/_chunks/vite-build.mjs +0 -69
  104. package/dist/_chunks/vite-dev.mjs +0 -79
  105. package/dist/_chunks/vite-preview.mjs +0 -27
  106. package/dist/language/module.d.mts +0 -5
  107. package/dist/language/module.mjs +0 -20
  108. package/dist/vite/vite-build.d.mts +0 -26
  109. package/dist/vite/vite-build.mjs +0 -27
  110. package/dist/vite/vite-dev.d.mts +0 -34
  111. package/dist/vite/vite-dev.mjs +0 -29
  112. package/dist/vite/vite-preview.d.mts +0 -20
  113. package/dist/vite/vite-preview.mjs +0 -26
@@ -1,785 +1,9 @@
1
- //#region ../../node_modules/.pnpm/@chevrotain+regexp-to-ast@11.0.3/node_modules/@chevrotain/regexp-to-ast/lib/src/utils.js
2
- function cc(char) {
3
- return char.charCodeAt(0);
4
- }
5
- function insertToSet(item, set) {
6
- if (Array.isArray(item)) item.forEach(function(subItem) {
7
- set.push(subItem);
8
- });
9
- else set.push(item);
10
- }
11
- function addFlag(flagObj, flagKey) {
12
- if (flagObj[flagKey] === true) throw "duplicate flag " + flagKey;
13
- flagObj[flagKey];
14
- flagObj[flagKey] = true;
15
- }
16
- function ASSERT_EXISTS(obj) {
17
- // istanbul ignore next
18
- if (obj === void 0) throw Error("Internal Error - Should never get here!");
19
- return true;
20
- }
21
- // istanbul ignore next
22
- function ASSERT_NEVER_REACH_HERE() {
23
- throw Error("Internal Error - Should never get here!");
24
- }
25
- function isCharacter(obj) {
26
- return obj["type"] === "Character";
27
- }
28
-
29
- //#endregion
30
- //#region ../../node_modules/.pnpm/@chevrotain+regexp-to-ast@11.0.3/node_modules/@chevrotain/regexp-to-ast/lib/src/character-classes.js
31
- const digitsCharCodes = [];
32
- for (let i = cc("0"); i <= cc("9"); i++) digitsCharCodes.push(i);
33
- const wordCharCodes = [cc("_")].concat(digitsCharCodes);
34
- for (let i = cc("a"); i <= cc("z"); i++) wordCharCodes.push(i);
35
- for (let i = cc("A"); i <= cc("Z"); i++) wordCharCodes.push(i);
36
- const whitespaceCodes = [
37
- cc(" "),
38
- cc("\f"),
39
- cc("\n"),
40
- cc("\r"),
41
- cc(" "),
42
- cc("\v"),
43
- cc(" "),
44
- cc("\xA0"),
45
- cc(" "),
46
- cc(" "),
47
- cc(" "),
48
- cc(" "),
49
- cc(" "),
50
- cc(" "),
51
- cc(" "),
52
- cc(" "),
53
- cc(" "),
54
- cc(" "),
55
- cc(" "),
56
- cc(" "),
57
- cc("\u2028"),
58
- cc("\u2029"),
59
- cc(" "),
60
- cc(" "),
61
- cc(" "),
62
- cc("")
63
- ];
64
-
65
- //#endregion
66
- //#region ../../node_modules/.pnpm/@chevrotain+regexp-to-ast@11.0.3/node_modules/@chevrotain/regexp-to-ast/lib/src/regexp-parser.js
67
- const hexDigitPattern = /[0-9a-fA-F]/;
68
- const decimalPattern = /[0-9]/;
69
- const decimalPatternNoZero = /[1-9]/;
70
- var RegExpParser = class {
71
- constructor() {
72
- this.idx = 0;
73
- this.input = "";
74
- this.groupIdx = 0;
75
- }
76
- saveState() {
77
- return {
78
- idx: this.idx,
79
- input: this.input,
80
- groupIdx: this.groupIdx
81
- };
82
- }
83
- restoreState(newState) {
84
- this.idx = newState.idx;
85
- this.input = newState.input;
86
- this.groupIdx = newState.groupIdx;
87
- }
88
- pattern(input) {
89
- this.idx = 0;
90
- this.input = input;
91
- this.groupIdx = 0;
92
- this.consumeChar("/");
93
- const value = this.disjunction();
94
- this.consumeChar("/");
95
- const flags = {
96
- type: "Flags",
97
- loc: {
98
- begin: this.idx,
99
- end: input.length
100
- },
101
- global: false,
102
- ignoreCase: false,
103
- multiLine: false,
104
- unicode: false,
105
- sticky: false
106
- };
107
- while (this.isRegExpFlag()) switch (this.popChar()) {
108
- case "g":
109
- addFlag(flags, "global");
110
- break;
111
- case "i":
112
- addFlag(flags, "ignoreCase");
113
- break;
114
- case "m":
115
- addFlag(flags, "multiLine");
116
- break;
117
- case "u":
118
- addFlag(flags, "unicode");
119
- break;
120
- case "y":
121
- addFlag(flags, "sticky");
122
- break;
123
- }
124
- if (this.idx !== this.input.length) throw Error("Redundant input: " + this.input.substring(this.idx));
125
- return {
126
- type: "Pattern",
127
- flags,
128
- value,
129
- loc: this.loc(0)
130
- };
131
- }
132
- disjunction() {
133
- const alts = [];
134
- const begin = this.idx;
135
- alts.push(this.alternative());
136
- while (this.peekChar() === "|") {
137
- this.consumeChar("|");
138
- alts.push(this.alternative());
139
- }
140
- return {
141
- type: "Disjunction",
142
- value: alts,
143
- loc: this.loc(begin)
144
- };
145
- }
146
- alternative() {
147
- const terms = [];
148
- const begin = this.idx;
149
- while (this.isTerm()) terms.push(this.term());
150
- return {
151
- type: "Alternative",
152
- value: terms,
153
- loc: this.loc(begin)
154
- };
155
- }
156
- term() {
157
- if (this.isAssertion()) return this.assertion();
158
- else return this.atom();
159
- }
160
- assertion() {
161
- const begin = this.idx;
162
- switch (this.popChar()) {
163
- case "^": return {
164
- type: "StartAnchor",
165
- loc: this.loc(begin)
166
- };
167
- case "$": return {
168
- type: "EndAnchor",
169
- loc: this.loc(begin)
170
- };
171
- case "\\":
172
- switch (this.popChar()) {
173
- case "b": return {
174
- type: "WordBoundary",
175
- loc: this.loc(begin)
176
- };
177
- case "B": return {
178
- type: "NonWordBoundary",
179
- loc: this.loc(begin)
180
- };
181
- }
182
- // istanbul ignore next
183
- throw Error("Invalid Assertion Escape");
184
- case "(":
185
- this.consumeChar("?");
186
- let type;
187
- switch (this.popChar()) {
188
- case "=":
189
- type = "Lookahead";
190
- break;
191
- case "!":
192
- type = "NegativeLookahead";
193
- break;
194
- }
195
- ASSERT_EXISTS(type);
196
- const disjunction = this.disjunction();
197
- this.consumeChar(")");
198
- return {
199
- type,
200
- value: disjunction,
201
- loc: this.loc(begin)
202
- };
203
- }
204
- // istanbul ignore next
205
- return ASSERT_NEVER_REACH_HERE();
206
- }
207
- quantifier(isBacktracking = false) {
208
- let range = void 0;
209
- const begin = this.idx;
210
- switch (this.popChar()) {
211
- case "*":
212
- range = {
213
- atLeast: 0,
214
- atMost: Infinity
215
- };
216
- break;
217
- case "+":
218
- range = {
219
- atLeast: 1,
220
- atMost: Infinity
221
- };
222
- break;
223
- case "?":
224
- range = {
225
- atLeast: 0,
226
- atMost: 1
227
- };
228
- break;
229
- case "{":
230
- const atLeast = this.integerIncludingZero();
231
- switch (this.popChar()) {
232
- case "}":
233
- range = {
234
- atLeast,
235
- atMost: atLeast
236
- };
237
- break;
238
- case ",":
239
- let atMost;
240
- if (this.isDigit()) {
241
- atMost = this.integerIncludingZero();
242
- range = {
243
- atLeast,
244
- atMost
245
- };
246
- } else range = {
247
- atLeast,
248
- atMost: Infinity
249
- };
250
- this.consumeChar("}");
251
- break;
252
- }
253
- if (isBacktracking === true && range === void 0) return;
254
- ASSERT_EXISTS(range);
255
- break;
256
- }
257
- if (isBacktracking === true && range === void 0) return;
258
- // istanbul ignore else
259
- if (ASSERT_EXISTS(range)) {
260
- if (this.peekChar(0) === "?") {
261
- this.consumeChar("?");
262
- range.greedy = false;
263
- } else range.greedy = true;
264
- range.type = "Quantifier";
265
- range.loc = this.loc(begin);
266
- return range;
267
- }
268
- }
269
- atom() {
270
- let atom;
271
- const begin = this.idx;
272
- switch (this.peekChar()) {
273
- case ".":
274
- atom = this.dotAll();
275
- break;
276
- case "\\":
277
- atom = this.atomEscape();
278
- break;
279
- case "[":
280
- atom = this.characterClass();
281
- break;
282
- case "(":
283
- atom = this.group();
284
- break;
285
- }
286
- if (atom === void 0 && this.isPatternCharacter()) atom = this.patternCharacter();
287
- // istanbul ignore else
288
- if (ASSERT_EXISTS(atom)) {
289
- atom.loc = this.loc(begin);
290
- if (this.isQuantifier()) atom.quantifier = this.quantifier();
291
- return atom;
292
- }
293
- // istanbul ignore next
294
- return ASSERT_NEVER_REACH_HERE();
295
- }
296
- dotAll() {
297
- this.consumeChar(".");
298
- return {
299
- type: "Set",
300
- complement: true,
301
- value: [
302
- cc("\n"),
303
- cc("\r"),
304
- cc("\u2028"),
305
- cc("\u2029")
306
- ]
307
- };
308
- }
309
- atomEscape() {
310
- this.consumeChar("\\");
311
- switch (this.peekChar()) {
312
- case "1":
313
- case "2":
314
- case "3":
315
- case "4":
316
- case "5":
317
- case "6":
318
- case "7":
319
- case "8":
320
- case "9": return this.decimalEscapeAtom();
321
- case "d":
322
- case "D":
323
- case "s":
324
- case "S":
325
- case "w":
326
- case "W": return this.characterClassEscape();
327
- case "f":
328
- case "n":
329
- case "r":
330
- case "t":
331
- case "v": return this.controlEscapeAtom();
332
- case "c": return this.controlLetterEscapeAtom();
333
- case "0": return this.nulCharacterAtom();
334
- case "x": return this.hexEscapeSequenceAtom();
335
- case "u": return this.regExpUnicodeEscapeSequenceAtom();
336
- default: return this.identityEscapeAtom();
337
- }
338
- }
339
- decimalEscapeAtom() {
340
- return {
341
- type: "GroupBackReference",
342
- value: this.positiveInteger()
343
- };
344
- }
345
- characterClassEscape() {
346
- let set;
347
- let complement = false;
348
- switch (this.popChar()) {
349
- case "d":
350
- set = digitsCharCodes;
351
- break;
352
- case "D":
353
- set = digitsCharCodes;
354
- complement = true;
355
- break;
356
- case "s":
357
- set = whitespaceCodes;
358
- break;
359
- case "S":
360
- set = whitespaceCodes;
361
- complement = true;
362
- break;
363
- case "w":
364
- set = wordCharCodes;
365
- break;
366
- case "W":
367
- set = wordCharCodes;
368
- complement = true;
369
- break;
370
- }
371
- // istanbul ignore else
372
- if (ASSERT_EXISTS(set)) return {
373
- type: "Set",
374
- value: set,
375
- complement
376
- };
377
- // istanbul ignore next
378
- return ASSERT_NEVER_REACH_HERE();
379
- }
380
- controlEscapeAtom() {
381
- let escapeCode;
382
- switch (this.popChar()) {
383
- case "f":
384
- escapeCode = cc("\f");
385
- break;
386
- case "n":
387
- escapeCode = cc("\n");
388
- break;
389
- case "r":
390
- escapeCode = cc("\r");
391
- break;
392
- case "t":
393
- escapeCode = cc(" ");
394
- break;
395
- case "v":
396
- escapeCode = cc("\v");
397
- break;
398
- }
399
- // istanbul ignore else
400
- if (ASSERT_EXISTS(escapeCode)) return {
401
- type: "Character",
402
- value: escapeCode
403
- };
404
- // istanbul ignore next
405
- return ASSERT_NEVER_REACH_HERE();
406
- }
407
- controlLetterEscapeAtom() {
408
- this.consumeChar("c");
409
- const letter = this.popChar();
410
- if (/[a-zA-Z]/.test(letter) === false) throw Error("Invalid ");
411
- return {
412
- type: "Character",
413
- value: letter.toUpperCase().charCodeAt(0) - 64
414
- };
415
- }
416
- nulCharacterAtom() {
417
- this.consumeChar("0");
418
- return {
419
- type: "Character",
420
- value: cc("\0")
421
- };
422
- }
423
- hexEscapeSequenceAtom() {
424
- this.consumeChar("x");
425
- return this.parseHexDigits(2);
426
- }
427
- regExpUnicodeEscapeSequenceAtom() {
428
- this.consumeChar("u");
429
- return this.parseHexDigits(4);
430
- }
431
- identityEscapeAtom() {
432
- return {
433
- type: "Character",
434
- value: cc(this.popChar())
435
- };
436
- }
437
- classPatternCharacterAtom() {
438
- switch (this.peekChar()) {
439
- case "\n":
440
- case "\r":
441
- case "\u2028":
442
- case "\u2029":
443
- case "\\":
444
- case "]": throw Error("TBD");
445
- default: return {
446
- type: "Character",
447
- value: cc(this.popChar())
448
- };
449
- }
450
- }
451
- characterClass() {
452
- const set = [];
453
- let complement = false;
454
- this.consumeChar("[");
455
- if (this.peekChar(0) === "^") {
456
- this.consumeChar("^");
457
- complement = true;
458
- }
459
- while (this.isClassAtom()) {
460
- const from = this.classAtom();
461
- from.type;
462
- if (isCharacter(from) && this.isRangeDash()) {
463
- this.consumeChar("-");
464
- const to = this.classAtom();
465
- to.type;
466
- if (isCharacter(to)) {
467
- if (to.value < from.value) throw Error("Range out of order in character class");
468
- set.push({
469
- from: from.value,
470
- to: to.value
471
- });
472
- } else {
473
- insertToSet(from.value, set);
474
- set.push(cc("-"));
475
- insertToSet(to.value, set);
476
- }
477
- } else insertToSet(from.value, set);
478
- }
479
- this.consumeChar("]");
480
- return {
481
- type: "Set",
482
- complement,
483
- value: set
484
- };
485
- }
486
- classAtom() {
487
- switch (this.peekChar()) {
488
- case "]":
489
- case "\n":
490
- case "\r":
491
- case "\u2028":
492
- case "\u2029": throw Error("TBD");
493
- case "\\": return this.classEscape();
494
- default: return this.classPatternCharacterAtom();
495
- }
496
- }
497
- classEscape() {
498
- this.consumeChar("\\");
499
- switch (this.peekChar()) {
500
- case "b":
501
- this.consumeChar("b");
502
- return {
503
- type: "Character",
504
- value: cc("\b")
505
- };
506
- case "d":
507
- case "D":
508
- case "s":
509
- case "S":
510
- case "w":
511
- case "W": return this.characterClassEscape();
512
- case "f":
513
- case "n":
514
- case "r":
515
- case "t":
516
- case "v": return this.controlEscapeAtom();
517
- case "c": return this.controlLetterEscapeAtom();
518
- case "0": return this.nulCharacterAtom();
519
- case "x": return this.hexEscapeSequenceAtom();
520
- case "u": return this.regExpUnicodeEscapeSequenceAtom();
521
- default: return this.identityEscapeAtom();
522
- }
523
- }
524
- group() {
525
- let capturing = true;
526
- this.consumeChar("(");
527
- switch (this.peekChar(0)) {
528
- case "?":
529
- this.consumeChar("?");
530
- this.consumeChar(":");
531
- capturing = false;
532
- break;
533
- default:
534
- this.groupIdx++;
535
- break;
536
- }
537
- const value = this.disjunction();
538
- this.consumeChar(")");
539
- const groupAst = {
540
- type: "Group",
541
- capturing,
542
- value
543
- };
544
- if (capturing) groupAst["idx"] = this.groupIdx;
545
- return groupAst;
546
- }
547
- positiveInteger() {
548
- let number = this.popChar();
549
- // istanbul ignore next - can't ever get here due to previous lookahead checks
550
- if (decimalPatternNoZero.test(number) === false) throw Error("Expecting a positive integer");
551
- while (decimalPattern.test(this.peekChar(0))) number += this.popChar();
552
- return parseInt(number, 10);
553
- }
554
- integerIncludingZero() {
555
- let number = this.popChar();
556
- if (decimalPattern.test(number) === false) throw Error("Expecting an integer");
557
- while (decimalPattern.test(this.peekChar(0))) number += this.popChar();
558
- return parseInt(number, 10);
559
- }
560
- patternCharacter() {
561
- const nextChar = this.popChar();
562
- switch (nextChar) {
563
- case "\n":
564
- case "\r":
565
- case "\u2028":
566
- case "\u2029":
567
- case "^":
568
- case "$":
569
- case "\\":
570
- case ".":
571
- case "*":
572
- case "+":
573
- case "?":
574
- case "(":
575
- case ")":
576
- case "[":
577
- case "|":
578
- // istanbul ignore next
579
- throw Error("TBD");
580
- default: return {
581
- type: "Character",
582
- value: cc(nextChar)
583
- };
584
- }
585
- }
586
- isRegExpFlag() {
587
- switch (this.peekChar(0)) {
588
- case "g":
589
- case "i":
590
- case "m":
591
- case "u":
592
- case "y": return true;
593
- default: return false;
594
- }
595
- }
596
- isRangeDash() {
597
- return this.peekChar() === "-" && this.isClassAtom(1);
598
- }
599
- isDigit() {
600
- return decimalPattern.test(this.peekChar(0));
601
- }
602
- isClassAtom(howMuch = 0) {
603
- switch (this.peekChar(howMuch)) {
604
- case "]":
605
- case "\n":
606
- case "\r":
607
- case "\u2028":
608
- case "\u2029": return false;
609
- default: return true;
610
- }
611
- }
612
- isTerm() {
613
- return this.isAtom() || this.isAssertion();
614
- }
615
- isAtom() {
616
- if (this.isPatternCharacter()) return true;
617
- switch (this.peekChar(0)) {
618
- case ".":
619
- case "\\":
620
- case "[":
621
- case "(": return true;
622
- default: return false;
623
- }
624
- }
625
- isAssertion() {
626
- switch (this.peekChar(0)) {
627
- case "^":
628
- case "$": return true;
629
- case "\\": switch (this.peekChar(1)) {
630
- case "b":
631
- case "B": return true;
632
- default: return false;
633
- }
634
- case "(": return this.peekChar(1) === "?" && (this.peekChar(2) === "=" || this.peekChar(2) === "!");
635
- default: return false;
636
- }
637
- }
638
- isQuantifier() {
639
- const prevState = this.saveState();
640
- try {
641
- return this.quantifier(true) !== void 0;
642
- } catch (e) {
643
- return false;
644
- } finally {
645
- this.restoreState(prevState);
646
- }
647
- }
648
- isPatternCharacter() {
649
- switch (this.peekChar()) {
650
- case "^":
651
- case "$":
652
- case "\\":
653
- case ".":
654
- case "*":
655
- case "+":
656
- case "?":
657
- case "(":
658
- case ")":
659
- case "[":
660
- case "|":
661
- case "/":
662
- case "\n":
663
- case "\r":
664
- case "\u2028":
665
- case "\u2029": return false;
666
- default: return true;
667
- }
668
- }
669
- parseHexDigits(howMany) {
670
- let hexString = "";
671
- for (let i = 0; i < howMany; i++) {
672
- const hexChar = this.popChar();
673
- if (hexDigitPattern.test(hexChar) === false) throw Error("Expecting a HexDecimal digits");
674
- hexString += hexChar;
675
- }
676
- return {
677
- type: "Character",
678
- value: parseInt(hexString, 16)
679
- };
680
- }
681
- peekChar(howMuch = 0) {
682
- return this.input[this.idx + howMuch];
683
- }
684
- popChar() {
685
- const nextChar = this.peekChar(0);
686
- this.consumeChar(void 0);
687
- return nextChar;
688
- }
689
- consumeChar(char) {
690
- if (char !== void 0 && this.input[this.idx] !== char) throw Error("Expected: '" + char + "' but found: '" + this.input[this.idx] + "' at offset: " + this.idx);
691
- if (this.idx >= this.input.length) throw Error("Unexpected end of input");
692
- this.idx++;
693
- }
694
- loc(begin) {
695
- return {
696
- begin,
697
- end: this.idx
698
- };
699
- }
700
- };
701
-
702
- //#endregion
703
- //#region ../../node_modules/.pnpm/@chevrotain+regexp-to-ast@11.0.3/node_modules/@chevrotain/regexp-to-ast/lib/src/base-regexp-visitor.js
704
- var BaseRegExpVisitor = class {
705
- visitChildren(node) {
706
- for (const key in node) {
707
- const child = node[key];
708
- /* istanbul ignore else */
709
- if (node.hasOwnProperty(key)) {
710
- if (child.type !== void 0) this.visit(child);
711
- else if (Array.isArray(child)) child.forEach((subChild) => {
712
- this.visit(subChild);
713
- }, this);
714
- }
715
- }
716
- }
717
- visit(node) {
718
- switch (node.type) {
719
- case "Pattern":
720
- this.visitPattern(node);
721
- break;
722
- case "Flags":
723
- this.visitFlags(node);
724
- break;
725
- case "Disjunction":
726
- this.visitDisjunction(node);
727
- break;
728
- case "Alternative":
729
- this.visitAlternative(node);
730
- break;
731
- case "StartAnchor":
732
- this.visitStartAnchor(node);
733
- break;
734
- case "EndAnchor":
735
- this.visitEndAnchor(node);
736
- break;
737
- case "WordBoundary":
738
- this.visitWordBoundary(node);
739
- break;
740
- case "NonWordBoundary":
741
- this.visitNonWordBoundary(node);
742
- break;
743
- case "Lookahead":
744
- this.visitLookahead(node);
745
- break;
746
- case "NegativeLookahead":
747
- this.visitNegativeLookahead(node);
748
- break;
749
- case "Character":
750
- this.visitCharacter(node);
751
- break;
752
- case "Set":
753
- this.visitSet(node);
754
- break;
755
- case "Group":
756
- this.visitGroup(node);
757
- break;
758
- case "GroupBackReference":
759
- this.visitGroupBackReference(node);
760
- break;
761
- case "Quantifier":
762
- this.visitQuantifier(node);
763
- break;
764
- }
765
- this.visitChildren(node);
766
- }
767
- visitPattern(node) {}
768
- visitFlags(node) {}
769
- visitDisjunction(node) {}
770
- visitAlternative(node) {}
771
- visitStartAnchor(node) {}
772
- visitEndAnchor(node) {}
773
- visitWordBoundary(node) {}
774
- visitNonWordBoundary(node) {}
775
- visitLookahead(node) {}
776
- visitNegativeLookahead(node) {}
777
- visitCharacter(node) {}
778
- visitSet(node) {}
779
- visitGroup(node) {}
780
- visitGroupBackReference(node) {}
781
- visitQuantifier(node) {}
782
- };
783
-
784
- //#endregion
785
- export { RegExpParser as n, BaseRegExpVisitor as t };
1
+ function cc(e){return e.charCodeAt(0)}function insertToSet(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function addFlag(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function ASSERT_EXISTS(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function ASSERT_NEVER_REACH_HERE(){throw Error(`Internal Error - Should never get here!`)}function isCharacter(e){return e.type===`Character`}const digitsCharCodes=[];for(let t=cc(`0`);t<=cc(`9`);t++)digitsCharCodes.push(t);const wordCharCodes=[cc(`_`)].concat(digitsCharCodes);for(let t=cc(`a`);t<=cc(`z`);t++)wordCharCodes.push(t);for(let t=cc(`A`);t<=cc(`Z`);t++)wordCharCodes.push(t);const whitespaceCodes=[cc(` `),cc(`\f`),cc(`
2
+ `),cc(`\r`),cc(` `),cc(`\v`),cc(` `),cc(`\xA0`),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(`\u2028`),cc(`\u2029`),cc(` `),cc(` `),cc(` `),cc(``)],hexDigitPattern=/[0-9a-fA-F]/,decimalPattern=/[0-9]/,decimalPatternNoZero=/[1-9]/;var RegExpParser=class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let r={type:`Flags`,loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:addFlag(r,`global`);break;case`i`:addFlag(r,`ignoreCase`);break;case`m`:addFlag(r,`multiLine`);break;case`u`:addFlag(r,`unicode`);break;case`y`:addFlag(r,`sticky`);break}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break}ASSERT_EXISTS(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return ASSERT_NEVER_REACH_HERE()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`);break}if(e===!0&&t===void 0)return;ASSERT_EXISTS(t);break}if(!(e===!0&&t===void 0)&&ASSERT_EXISTS(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),ASSERT_EXISTS(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):ASSERT_NEVER_REACH_HERE()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[cc(`
3
+ `),cc(`\r`),cc(`\u2028`),cc(`\u2029`)]}}atomEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:return this.decimalEscapeAtom();case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:`GroupBackReference`,value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case`d`:e=digitsCharCodes;break;case`D`:e=digitsCharCodes,t=!0;break;case`s`:e=whitespaceCodes;break;case`S`:e=whitespaceCodes,t=!0;break;case`w`:e=wordCharCodes;break;case`W`:e=wordCharCodes,t=!0;break}return ASSERT_EXISTS(e)?{type:`Set`,value:e,complement:t}:ASSERT_NEVER_REACH_HERE()}controlEscapeAtom(){let t;switch(this.popChar()){case`f`:t=cc(`\f`);break;case`n`:t=cc(`
4
+ `);break;case`r`:t=cc(`\r`);break;case`t`:t=cc(` `);break;case`v`:t=cc(`\v`);break}return ASSERT_EXISTS(t)?{type:`Character`,value:t}:ASSERT_NEVER_REACH_HERE()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:cc(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:cc(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
+ `:case`\r`:case`\u2028`:case`\u2029`:case`\\`:case`]`:throw Error(`TBD`);default:return{type:`Character`,value:cc(this.popChar())}}}characterClass(){let n=[],r=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),r=!0);this.isClassAtom();){let r=this.classAtom();if(r.type,isCharacter(r)&&this.isRangeDash()){this.consumeChar(`-`);let i=this.classAtom();if(i.type,isCharacter(i)){if(i.value<r.value)throw Error(`Range out of order in character class`);n.push({from:r.value,to:i.value})}else insertToSet(r.value,n),n.push(cc(`-`)),insertToSet(i.value,n)}else insertToSet(r.value,n)}return this.consumeChar(`]`),{type:`Set`,complement:r,value:n}}classAtom(){switch(this.peekChar()){case`]`:case`
6
+ `:case`\r`:case`\u2028`:case`\u2029`:throw Error(`TBD`);case`\\`:return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`b`:return this.consumeChar(`b`),{type:`Character`,value:cc(`\b`)};case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar(`(`),this.peekChar(0)){case`?`:this.consumeChar(`?`),this.consumeChar(`:`),e=!1;break;default:this.groupIdx++;break}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(decimalPatternNoZero.test(e)===!1)throw Error(`Expecting a positive integer`);for(;decimalPattern.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(decimalPattern.test(e)===!1)throw Error(`Expecting an integer`);for(;decimalPattern.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let t=this.popChar();switch(t){case`
7
+ `:case`\r`:case`\u2028`:case`\u2029`:case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:throw Error(`TBD`);default:return{type:`Character`,value:cc(t)}}}isRegExpFlag(){switch(this.peekChar(0)){case`g`:case`i`:case`m`:case`u`:case`y`:return!0;default:return!1}}isRangeDash(){return this.peekChar()===`-`&&this.isClassAtom(1)}isDigit(){return decimalPattern.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
8
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case`.`:case`\\`:case`[`:case`(`:return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case`^`:case`$`:return!0;case`\\`:switch(this.peekChar(1)){case`b`:case`B`:return!0;default:return!1}case`(`:return this.peekChar(1)===`?`&&(this.peekChar(2)===`=`||this.peekChar(2)===`!`);default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
9
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(hexDigitPattern.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error(`Expected: '`+e+`' but found: '`+this.input[this.idx]+`' at offset: `+this.idx);if(this.idx>=this.input.length)throw Error(`Unexpected end of input`);this.idx++}loc(e){return{begin:e,end:this.idx}}},BaseRegExpVisitor=class{visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};export{RegExpParser as n,BaseRegExpVisitor as t};