@agentuity/cli 0.0.106 → 0.0.108

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 (74) hide show
  1. package/dist/cmd/build/entry-generator.d.ts.map +1 -1
  2. package/dist/cmd/build/entry-generator.js +43 -50
  3. package/dist/cmd/build/entry-generator.js.map +1 -1
  4. package/dist/cmd/build/index.d.ts.map +1 -1
  5. package/dist/cmd/build/index.js +9 -9
  6. package/dist/cmd/build/index.js.map +1 -1
  7. package/dist/cmd/build/typecheck.d.ts +23 -0
  8. package/dist/cmd/build/typecheck.d.ts.map +1 -0
  9. package/dist/cmd/build/typecheck.js +38 -0
  10. package/dist/cmd/build/typecheck.js.map +1 -0
  11. package/dist/cmd/build/vite/metadata-generator.d.ts +2 -1
  12. package/dist/cmd/build/vite/metadata-generator.d.ts.map +1 -1
  13. package/dist/cmd/build/vite/metadata-generator.js +14 -0
  14. package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
  15. package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
  16. package/dist/cmd/build/vite/vite-asset-server-config.js +15 -8
  17. package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
  18. package/dist/cmd/build/vite/vite-asset-server.d.ts.map +1 -1
  19. package/dist/cmd/build/vite/vite-asset-server.js +6 -2
  20. package/dist/cmd/build/vite/vite-asset-server.js.map +1 -1
  21. package/dist/cmd/build/vite/vite-builder.d.ts +2 -1
  22. package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
  23. package/dist/cmd/build/vite/vite-builder.js +15 -2
  24. package/dist/cmd/build/vite/vite-builder.js.map +1 -1
  25. package/dist/cmd/build/vite-bundler.d.ts +2 -1
  26. package/dist/cmd/build/vite-bundler.d.ts.map +1 -1
  27. package/dist/cmd/build/vite-bundler.js +2 -1
  28. package/dist/cmd/build/vite-bundler.js.map +1 -1
  29. package/dist/cmd/cloud/deploy.d.ts.map +1 -1
  30. package/dist/cmd/cloud/deploy.js +50 -24
  31. package/dist/cmd/cloud/deploy.js.map +1 -1
  32. package/dist/cmd/dev/index.d.ts.map +1 -1
  33. package/dist/cmd/dev/index.js +623 -578
  34. package/dist/cmd/dev/index.js.map +1 -1
  35. package/dist/schema-parser.d.ts.map +1 -1
  36. package/dist/schema-parser.js +17 -3
  37. package/dist/schema-parser.js.map +1 -1
  38. package/dist/tsc-output-parser.d.ts +54 -0
  39. package/dist/tsc-output-parser.d.ts.map +1 -0
  40. package/dist/tsc-output-parser.js +926 -0
  41. package/dist/tsc-output-parser.js.map +1 -0
  42. package/dist/tui.d.ts +77 -0
  43. package/dist/tui.d.ts.map +1 -1
  44. package/dist/tui.js +27 -2
  45. package/dist/tui.js.map +1 -1
  46. package/dist/types.d.ts +24 -0
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js +22 -0
  49. package/dist/types.js.map +1 -1
  50. package/dist/typescript-errors.d.ts +26 -0
  51. package/dist/typescript-errors.d.ts.map +1 -0
  52. package/dist/typescript-errors.js +249 -0
  53. package/dist/typescript-errors.js.map +1 -0
  54. package/package.json +4 -4
  55. package/src/cmd/build/entry-generator.ts +43 -51
  56. package/src/cmd/build/index.ts +13 -10
  57. package/src/cmd/build/typecheck.ts +55 -0
  58. package/src/cmd/build/vite/metadata-generator.ts +17 -1
  59. package/src/cmd/build/vite/vite-asset-server-config.ts +17 -8
  60. package/src/cmd/build/vite/vite-asset-server.ts +6 -2
  61. package/src/cmd/build/vite/vite-builder.ts +16 -3
  62. package/src/cmd/build/vite-bundler.ts +4 -1
  63. package/src/cmd/cloud/deploy.ts +68 -32
  64. package/src/cmd/dev/index.ts +713 -657
  65. package/src/schema-parser.ts +17 -3
  66. package/src/tsc-output-parser.ts +1115 -0
  67. package/src/tui.ts +40 -2
  68. package/src/types.ts +25 -0
  69. package/src/typescript-errors.ts +382 -0
  70. package/dist/schemas/deploy.d.ts +0 -24
  71. package/dist/schemas/deploy.d.ts.map +0 -1
  72. package/dist/schemas/deploy.js +0 -26
  73. package/dist/schemas/deploy.js.map +0 -1
  74. package/src/schemas/deploy.ts +0 -28
@@ -0,0 +1,1115 @@
1
+ /**
2
+ * TSC Output Parser
3
+ *
4
+ * Parses TypeScript compiler output into structured JSON format.
5
+ *
6
+ * This is an internalized version of @aivenio/tsc-output-parser.
7
+ * Original source: https://github.com/Aiven-Open/tsc-output-parser
8
+ *
9
+ * Copyright Aiven
10
+ * Licensed under the Apache License, Version 2.0
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Generated by PEG.js v. 0.10.0 (ts-pegjs plugin v. 0.2.7)
14
+ * https://pegjs.org/ https://github.com/metadevpro/ts-pegjs
15
+ */
16
+
17
+ export interface GrammarPath {
18
+ type: 'Path';
19
+ value: string;
20
+ }
21
+
22
+ export interface GrammarCursor {
23
+ type: 'Cursor';
24
+ value: {
25
+ line: number;
26
+ col: number;
27
+ };
28
+ }
29
+
30
+ export interface GrammarTsError {
31
+ type: 'TsError';
32
+ value: {
33
+ type: 'error' | 'warning';
34
+ errorString: string;
35
+ };
36
+ }
37
+
38
+ export interface GrammarMessage {
39
+ type: 'Message';
40
+ value: string;
41
+ }
42
+
43
+ export interface GrammarItem {
44
+ type: 'Item';
45
+ value: {
46
+ path: GrammarPath;
47
+ cursor: GrammarCursor;
48
+ tsError: GrammarTsError;
49
+ message: GrammarMessage;
50
+ };
51
+ }
52
+
53
+ interface IFilePosition {
54
+ offset: number;
55
+ line: number;
56
+ column: number;
57
+ }
58
+
59
+ interface IFileRange {
60
+ start: IFilePosition;
61
+ end: IFilePosition;
62
+ }
63
+
64
+ interface ILiteralExpectation {
65
+ type: 'literal';
66
+ text: string;
67
+ ignoreCase: boolean;
68
+ }
69
+
70
+ type IClassParts = Array<string | IClassParts>;
71
+
72
+ interface IClassExpectation {
73
+ type: 'class';
74
+ parts: IClassParts;
75
+ inverted: boolean;
76
+ ignoreCase: boolean;
77
+ }
78
+
79
+ interface IAnyExpectation {
80
+ type: 'any';
81
+ }
82
+
83
+ interface IEndExpectation {
84
+ type: 'end';
85
+ }
86
+
87
+ interface IOtherExpectation {
88
+ type: 'other';
89
+ description: string;
90
+ }
91
+
92
+ type Expectation =
93
+ | ILiteralExpectation
94
+ | IClassExpectation
95
+ | IAnyExpectation
96
+ | IEndExpectation
97
+ | IOtherExpectation;
98
+
99
+ class SyntaxError extends Error {
100
+ public static buildMessage(expected: Expectation[], found: string | null) {
101
+ function hex(ch: string): string {
102
+ return ch.charCodeAt(0).toString(16).toUpperCase();
103
+ }
104
+
105
+ function literalEscape(s: string): string {
106
+ return s
107
+ .replace(/\\/g, '\\\\')
108
+ .replace(/"/g, '\\"')
109
+ .replace(/\0/g, '\\0')
110
+ .replace(/\t/g, '\\t')
111
+ .replace(/\n/g, '\\n')
112
+ .replace(/\r/g, '\\r')
113
+ .replace(/[\x00-\x0F]/g, (ch) => '\\x0' + hex(ch))
114
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => '\\x' + hex(ch));
115
+ }
116
+
117
+ function classEscape(s: string): string {
118
+ return s
119
+ .replace(/\\/g, '\\\\')
120
+ .replace(/\]/g, '\\]')
121
+ .replace(/\^/g, '\\^')
122
+ .replace(/-/g, '\\-')
123
+ .replace(/\0/g, '\\0')
124
+ .replace(/\t/g, '\\t')
125
+ .replace(/\n/g, '\\n')
126
+ .replace(/\r/g, '\\r')
127
+ .replace(/[\x00-\x0F]/g, (ch) => '\\x0' + hex(ch))
128
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => '\\x' + hex(ch));
129
+ }
130
+
131
+ function describeExpectation(expectation: Expectation) {
132
+ switch (expectation.type) {
133
+ case 'literal':
134
+ return '"' + literalEscape(expectation.text) + '"';
135
+ case 'class': {
136
+ const escapedParts = expectation.parts.map((part) => {
137
+ return Array.isArray(part)
138
+ ? classEscape(part[0] as string) + '-' + classEscape(part[1] as string)
139
+ : classEscape(part);
140
+ });
141
+ return '[' + (expectation.inverted ? '^' : '') + escapedParts + ']';
142
+ }
143
+ case 'any':
144
+ return 'any character';
145
+ case 'end':
146
+ return 'end of input';
147
+ case 'other':
148
+ return expectation.description;
149
+ }
150
+ }
151
+
152
+ function describeExpected(expected1: Expectation[]) {
153
+ const descriptions = expected1.map(describeExpectation);
154
+ let i: number;
155
+ let j: number;
156
+
157
+ descriptions.sort();
158
+
159
+ if (descriptions.length > 0) {
160
+ for (i = 1, j = 1; i < descriptions.length; i++) {
161
+ if (descriptions[i - 1] !== descriptions[i]) {
162
+ descriptions[j] = descriptions[i];
163
+ j++;
164
+ }
165
+ }
166
+ descriptions.length = j;
167
+ }
168
+
169
+ switch (descriptions.length) {
170
+ case 1:
171
+ return descriptions[0];
172
+ case 2:
173
+ return descriptions[0] + ' or ' + descriptions[1];
174
+ default:
175
+ return (
176
+ descriptions.slice(0, -1).join(', ') +
177
+ ', or ' +
178
+ descriptions[descriptions.length - 1]
179
+ );
180
+ }
181
+ }
182
+
183
+ function describeFound(found1: string | null) {
184
+ return found1 ? '"' + literalEscape(found1) + '"' : 'end of input';
185
+ }
186
+
187
+ return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.';
188
+ }
189
+
190
+ public message: string;
191
+ public expected: Expectation[];
192
+ public found: string | null;
193
+ public location: IFileRange;
194
+ public name: string;
195
+
196
+ constructor(
197
+ message: string,
198
+ expected: Expectation[],
199
+ found: string | null,
200
+ location: IFileRange
201
+ ) {
202
+ super();
203
+ this.message = message;
204
+ this.expected = expected;
205
+ this.found = found;
206
+ this.location = location;
207
+ this.name = 'SyntaxError';
208
+
209
+ if (typeof (Error as { captureStackTrace?: unknown }).captureStackTrace === 'function') {
210
+ (Error as { captureStackTrace: (err: Error, ctor: unknown) => void }).captureStackTrace(
211
+ this,
212
+ SyntaxError
213
+ );
214
+ }
215
+ }
216
+ }
217
+
218
+ interface ICached {
219
+ nextPos: number;
220
+ result: unknown;
221
+ }
222
+
223
+ interface IParseOptions {
224
+ startRule?: string;
225
+ [key: string]: unknown;
226
+ }
227
+
228
+ function peg$parse(input: string, options?: IParseOptions): GrammarItem[] {
229
+ options = options !== undefined ? options : {};
230
+
231
+ const peg$FAILED: Readonly<object> = {};
232
+
233
+ const peg$startRuleFunctions: { [id: string]: () => unknown } = { Main: peg$parseMain };
234
+ let peg$startRuleFunction: () => unknown = peg$parseMain;
235
+
236
+ const peg$c0 = function (items: unknown): unknown {
237
+ return items;
238
+ };
239
+ const peg$c1 = ':';
240
+ const peg$c2 = peg$literalExpectation(':', false);
241
+ const peg$c3 = function (
242
+ path: unknown,
243
+ cursor: unknown,
244
+ tsError: unknown,
245
+ message: unknown
246
+ ): unknown {
247
+ return {
248
+ type: 'Item',
249
+ value: {
250
+ path,
251
+ cursor,
252
+ tsError,
253
+ message,
254
+ },
255
+ };
256
+ };
257
+ const peg$c4 = function (line: unknown, extraLines: string[]): unknown {
258
+ return {
259
+ type: 'Message',
260
+ value: `${line}${extraLines.join('')}`,
261
+ };
262
+ };
263
+ const peg$c5 = function (indent: unknown, tail: unknown): unknown {
264
+ return `${indent}${tail}`;
265
+ };
266
+ const peg$c6 = ' ';
267
+ const peg$c7 = peg$literalExpectation(' ', false);
268
+ const peg$c8 = function (indent: unknown): unknown {
269
+ return indent;
270
+ };
271
+ const peg$c9 = ' TS';
272
+ const peg$c10 = peg$literalExpectation(' TS', false);
273
+ const peg$c11 = function (type: unknown, num: unknown): unknown {
274
+ return {
275
+ type: 'TsError',
276
+ value: {
277
+ type,
278
+ errorString: `TS${num}`,
279
+ },
280
+ };
281
+ };
282
+ const peg$c12 = 'error';
283
+ const peg$c13 = peg$literalExpectation('error', false);
284
+ const peg$c14 = 'warning';
285
+ const peg$c15 = peg$literalExpectation('warning', false);
286
+ const peg$c16 = function (type: unknown): unknown {
287
+ return type;
288
+ };
289
+ const peg$c17 = '(';
290
+ const peg$c18 = peg$literalExpectation('(', false);
291
+ const peg$c19 = ',';
292
+ const peg$c20 = peg$literalExpectation(',', false);
293
+ const peg$c21 = ')';
294
+ const peg$c22 = peg$literalExpectation(')', false);
295
+ const peg$c23 = function (line: unknown, col: unknown): unknown {
296
+ return {
297
+ type: 'Cursor',
298
+ value: {
299
+ line,
300
+ col,
301
+ },
302
+ };
303
+ };
304
+ const peg$c24 = /^[^\n\r(]/;
305
+ const peg$c25 = peg$classExpectation(['\n', '\r', '('], true, false);
306
+ const peg$c26 = function (path: string[]): unknown {
307
+ return {
308
+ type: 'Path',
309
+ value: path.join(''),
310
+ };
311
+ };
312
+ const peg$c27 = '\n';
313
+ const peg$c28 = peg$literalExpectation('\n', false);
314
+ const peg$c29 = function (text: string[], newlines: string[]): unknown {
315
+ return `${text.join('')}${newlines.join('')}`;
316
+ };
317
+ const peg$c30 = /^[^\n\r]/;
318
+ const peg$c31 = peg$classExpectation(['\n', '\r'], true, false);
319
+ const peg$c32 = /^[0-9]/;
320
+ const peg$c33 = peg$classExpectation([['0', '9']], false, false);
321
+ const peg$c34 = function (digits: string[]): unknown {
322
+ return parseInt(digits.join(''), 10);
323
+ };
324
+ const peg$c35 = /^[ \t\r\n]/;
325
+ const peg$c36 = peg$classExpectation([' ', '\t', '\r', '\n'], false, false);
326
+ const peg$c37 = function (): unknown {
327
+ return null;
328
+ };
329
+
330
+ let peg$currPos = 0;
331
+ let peg$savedPos = 0;
332
+ const peg$posDetailsCache: { line: number; column: number }[] = [{ line: 1, column: 1 }];
333
+ let peg$maxFailPos = 0;
334
+ let peg$maxFailExpected: Expectation[] = [];
335
+ let peg$silentFails = 0;
336
+
337
+ const peg$resultsCache: { [id: number]: ICached } = {};
338
+
339
+ let peg$result: unknown;
340
+
341
+ if (options.startRule !== undefined) {
342
+ if (!(options.startRule in peg$startRuleFunctions)) {
343
+ throw new Error('Can\'t start parsing from rule "' + options.startRule + '".');
344
+ }
345
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
346
+ }
347
+
348
+ function peg$literalExpectation(text1: string, ignoreCase: boolean): ILiteralExpectation {
349
+ return { type: 'literal', text: text1, ignoreCase: ignoreCase };
350
+ }
351
+
352
+ function peg$classExpectation(
353
+ parts: IClassParts,
354
+ inverted: boolean,
355
+ ignoreCase: boolean
356
+ ): IClassExpectation {
357
+ return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase };
358
+ }
359
+
360
+ function peg$endExpectation(): IEndExpectation {
361
+ return { type: 'end' };
362
+ }
363
+
364
+ function peg$computePosDetails(pos: number) {
365
+ let details = peg$posDetailsCache[pos];
366
+ let p;
367
+
368
+ if (details) {
369
+ return details;
370
+ } else {
371
+ p = pos - 1;
372
+ while (!peg$posDetailsCache[p]) {
373
+ p--;
374
+ }
375
+
376
+ details = peg$posDetailsCache[p];
377
+ details = {
378
+ line: details.line,
379
+ column: details.column,
380
+ };
381
+
382
+ while (p < pos) {
383
+ if (input.charCodeAt(p) === 10) {
384
+ details.line++;
385
+ details.column = 1;
386
+ } else {
387
+ details.column++;
388
+ }
389
+ p++;
390
+ }
391
+
392
+ peg$posDetailsCache[pos] = details;
393
+
394
+ return details;
395
+ }
396
+ }
397
+
398
+ function peg$computeLocation(startPos: number, endPos: number): IFileRange {
399
+ const startPosDetails = peg$computePosDetails(startPos);
400
+ const endPosDetails = peg$computePosDetails(endPos);
401
+
402
+ return {
403
+ start: {
404
+ offset: startPos,
405
+ line: startPosDetails.line,
406
+ column: startPosDetails.column,
407
+ },
408
+ end: {
409
+ offset: endPos,
410
+ line: endPosDetails.line,
411
+ column: endPosDetails.column,
412
+ },
413
+ };
414
+ }
415
+
416
+ function peg$fail(expected1: Expectation) {
417
+ if (peg$currPos < peg$maxFailPos) {
418
+ return;
419
+ }
420
+
421
+ if (peg$currPos > peg$maxFailPos) {
422
+ peg$maxFailPos = peg$currPos;
423
+ peg$maxFailExpected = [];
424
+ }
425
+
426
+ peg$maxFailExpected.push(expected1);
427
+ }
428
+
429
+ function peg$buildStructuredError(
430
+ expected1: Expectation[],
431
+ found: string | null,
432
+ location1: IFileRange
433
+ ) {
434
+ return new SyntaxError(
435
+ SyntaxError.buildMessage(expected1, found),
436
+ expected1,
437
+ found,
438
+ location1
439
+ );
440
+ }
441
+
442
+ function peg$parseMain(): unknown {
443
+ let s0, s1, s2, s3;
444
+
445
+ const key = peg$currPos * 13 + 0;
446
+ const cached: ICached = peg$resultsCache[key];
447
+
448
+ if (cached) {
449
+ peg$currPos = cached.nextPos;
450
+ return cached.result;
451
+ }
452
+
453
+ s0 = peg$currPos;
454
+ s1 = peg$parse_();
455
+ if (s1 !== peg$FAILED) {
456
+ s2 = [];
457
+ s3 = peg$parseItem();
458
+ while (s3 !== peg$FAILED) {
459
+ s2.push(s3);
460
+ s3 = peg$parseItem();
461
+ }
462
+ if (s2 !== peg$FAILED) {
463
+ s3 = peg$parse_();
464
+ if (s3 !== peg$FAILED) {
465
+ peg$savedPos = s0;
466
+ s1 = peg$c0(s2);
467
+ s0 = s1;
468
+ } else {
469
+ peg$currPos = s0;
470
+ s0 = peg$FAILED;
471
+ }
472
+ } else {
473
+ peg$currPos = s0;
474
+ s0 = peg$FAILED;
475
+ }
476
+ } else {
477
+ peg$currPos = s0;
478
+ s0 = peg$FAILED;
479
+ }
480
+
481
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
482
+
483
+ return s0;
484
+ }
485
+
486
+ function peg$parseItem(): unknown {
487
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8;
488
+
489
+ const key = peg$currPos * 13 + 1;
490
+ const cached: ICached = peg$resultsCache[key];
491
+
492
+ if (cached) {
493
+ peg$currPos = cached.nextPos;
494
+ return cached.result;
495
+ }
496
+
497
+ s0 = peg$currPos;
498
+ s1 = peg$parsePath();
499
+ if (s1 !== peg$FAILED) {
500
+ s2 = peg$parseCursor();
501
+ if (s2 !== peg$FAILED) {
502
+ if (input.charCodeAt(peg$currPos) === 58) {
503
+ s3 = peg$c1;
504
+ peg$currPos++;
505
+ } else {
506
+ s3 = peg$FAILED;
507
+ if (peg$silentFails === 0) {
508
+ peg$fail(peg$c2);
509
+ }
510
+ }
511
+ if (s3 !== peg$FAILED) {
512
+ s4 = peg$parse_();
513
+ if (s4 !== peg$FAILED) {
514
+ s5 = peg$parseTsError();
515
+ if (s5 !== peg$FAILED) {
516
+ s6 = peg$parse_();
517
+ if (s6 !== peg$FAILED) {
518
+ if (input.charCodeAt(peg$currPos) === 58) {
519
+ s7 = peg$c1;
520
+ peg$currPos++;
521
+ } else {
522
+ s7 = peg$FAILED;
523
+ if (peg$silentFails === 0) {
524
+ peg$fail(peg$c2);
525
+ }
526
+ }
527
+ if (s7 !== peg$FAILED) {
528
+ s8 = peg$parseMessage();
529
+ if (s8 !== peg$FAILED) {
530
+ peg$savedPos = s0;
531
+ s1 = peg$c3(s1, s2, s5, s8);
532
+ s0 = s1;
533
+ } else {
534
+ peg$currPos = s0;
535
+ s0 = peg$FAILED;
536
+ }
537
+ } else {
538
+ peg$currPos = s0;
539
+ s0 = peg$FAILED;
540
+ }
541
+ } else {
542
+ peg$currPos = s0;
543
+ s0 = peg$FAILED;
544
+ }
545
+ } else {
546
+ peg$currPos = s0;
547
+ s0 = peg$FAILED;
548
+ }
549
+ } else {
550
+ peg$currPos = s0;
551
+ s0 = peg$FAILED;
552
+ }
553
+ } else {
554
+ peg$currPos = s0;
555
+ s0 = peg$FAILED;
556
+ }
557
+ } else {
558
+ peg$currPos = s0;
559
+ s0 = peg$FAILED;
560
+ }
561
+ } else {
562
+ peg$currPos = s0;
563
+ s0 = peg$FAILED;
564
+ }
565
+
566
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
567
+
568
+ return s0;
569
+ }
570
+
571
+ function peg$parseMessage(): unknown {
572
+ let s0, s1, s2, s3;
573
+
574
+ const key = peg$currPos * 13 + 2;
575
+ const cached: ICached = peg$resultsCache[key];
576
+
577
+ if (cached) {
578
+ peg$currPos = cached.nextPos;
579
+ return cached.result;
580
+ }
581
+
582
+ s0 = peg$currPos;
583
+ s1 = peg$parseTextLine();
584
+ if (s1 !== peg$FAILED) {
585
+ s2 = [];
586
+ s3 = peg$parseMessageExtraLine();
587
+ while (s3 !== peg$FAILED) {
588
+ s2.push(s3);
589
+ s3 = peg$parseMessageExtraLine();
590
+ }
591
+ if (s2 !== peg$FAILED) {
592
+ peg$savedPos = s0;
593
+ s1 = peg$c4(s1 as string, s2 as string[]);
594
+ s0 = s1;
595
+ } else {
596
+ peg$currPos = s0;
597
+ s0 = peg$FAILED;
598
+ }
599
+ } else {
600
+ peg$currPos = s0;
601
+ s0 = peg$FAILED;
602
+ }
603
+
604
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
605
+
606
+ return s0;
607
+ }
608
+
609
+ function peg$parseMessageExtraLine(): unknown {
610
+ let s0, s1, s2;
611
+
612
+ const key = peg$currPos * 13 + 3;
613
+ const cached: ICached = peg$resultsCache[key];
614
+
615
+ if (cached) {
616
+ peg$currPos = cached.nextPos;
617
+ return cached.result;
618
+ }
619
+
620
+ s0 = peg$currPos;
621
+ s1 = peg$parseMessageExtraLineStart();
622
+ if (s1 !== peg$FAILED) {
623
+ s2 = peg$parseTextLine();
624
+ if (s2 !== peg$FAILED) {
625
+ peg$savedPos = s0;
626
+ s1 = peg$c5(s1, s2);
627
+ s0 = s1;
628
+ } else {
629
+ peg$currPos = s0;
630
+ s0 = peg$FAILED;
631
+ }
632
+ } else {
633
+ peg$currPos = s0;
634
+ s0 = peg$FAILED;
635
+ }
636
+
637
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
638
+
639
+ return s0;
640
+ }
641
+
642
+ function peg$parseMessageExtraLineStart(): unknown {
643
+ let s0, s1;
644
+
645
+ const key = peg$currPos * 13 + 4;
646
+ const cached: ICached = peg$resultsCache[key];
647
+
648
+ if (cached) {
649
+ peg$currPos = cached.nextPos;
650
+ return cached.result;
651
+ }
652
+
653
+ s0 = peg$currPos;
654
+ if (input.substr(peg$currPos, 2) === peg$c6) {
655
+ s1 = peg$c6;
656
+ peg$currPos += 2;
657
+ } else {
658
+ s1 = peg$FAILED;
659
+ if (peg$silentFails === 0) {
660
+ peg$fail(peg$c7);
661
+ }
662
+ }
663
+ if (s1 !== peg$FAILED) {
664
+ peg$savedPos = s0;
665
+ s1 = peg$c8(s1);
666
+ }
667
+ s0 = s1;
668
+
669
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
670
+
671
+ return s0;
672
+ }
673
+
674
+ function peg$parseTsError(): unknown {
675
+ let s0, s1, s2, s3;
676
+
677
+ const key = peg$currPos * 13 + 5;
678
+ const cached: ICached = peg$resultsCache[key];
679
+
680
+ if (cached) {
681
+ peg$currPos = cached.nextPos;
682
+ return cached.result;
683
+ }
684
+
685
+ s0 = peg$currPos;
686
+ s1 = peg$parseTsErrorType();
687
+ if (s1 !== peg$FAILED) {
688
+ if (input.substr(peg$currPos, 3) === peg$c9) {
689
+ s2 = peg$c9;
690
+ peg$currPos += 3;
691
+ } else {
692
+ s2 = peg$FAILED;
693
+ if (peg$silentFails === 0) {
694
+ peg$fail(peg$c10);
695
+ }
696
+ }
697
+ if (s2 !== peg$FAILED) {
698
+ s3 = peg$parseInteger();
699
+ if (s3 !== peg$FAILED) {
700
+ peg$savedPos = s0;
701
+ s1 = peg$c11(s1, s3);
702
+ s0 = s1;
703
+ } else {
704
+ peg$currPos = s0;
705
+ s0 = peg$FAILED;
706
+ }
707
+ } else {
708
+ peg$currPos = s0;
709
+ s0 = peg$FAILED;
710
+ }
711
+ } else {
712
+ peg$currPos = s0;
713
+ s0 = peg$FAILED;
714
+ }
715
+
716
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
717
+
718
+ return s0;
719
+ }
720
+
721
+ function peg$parseTsErrorType(): unknown {
722
+ let s0, s1;
723
+
724
+ const key = peg$currPos * 13 + 6;
725
+ const cached: ICached = peg$resultsCache[key];
726
+
727
+ if (cached) {
728
+ peg$currPos = cached.nextPos;
729
+ return cached.result;
730
+ }
731
+
732
+ s0 = peg$currPos;
733
+ if (input.substr(peg$currPos, 5) === peg$c12) {
734
+ s1 = peg$c12;
735
+ peg$currPos += 5;
736
+ } else {
737
+ s1 = peg$FAILED;
738
+ if (peg$silentFails === 0) {
739
+ peg$fail(peg$c13);
740
+ }
741
+ }
742
+ if (s1 === peg$FAILED) {
743
+ if (input.substr(peg$currPos, 7) === peg$c14) {
744
+ s1 = peg$c14;
745
+ peg$currPos += 7;
746
+ } else {
747
+ s1 = peg$FAILED;
748
+ if (peg$silentFails === 0) {
749
+ peg$fail(peg$c15);
750
+ }
751
+ }
752
+ }
753
+ if (s1 !== peg$FAILED) {
754
+ peg$savedPos = s0;
755
+ s1 = peg$c16(s1);
756
+ }
757
+ s0 = s1;
758
+
759
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
760
+
761
+ return s0;
762
+ }
763
+
764
+ function peg$parseCursor(): unknown {
765
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
766
+
767
+ const key = peg$currPos * 13 + 7;
768
+ const cached: ICached = peg$resultsCache[key];
769
+
770
+ if (cached) {
771
+ peg$currPos = cached.nextPos;
772
+ return cached.result;
773
+ }
774
+
775
+ s0 = peg$currPos;
776
+ if (input.charCodeAt(peg$currPos) === 40) {
777
+ s1 = peg$c17;
778
+ peg$currPos++;
779
+ } else {
780
+ s1 = peg$FAILED;
781
+ if (peg$silentFails === 0) {
782
+ peg$fail(peg$c18);
783
+ }
784
+ }
785
+ if (s1 !== peg$FAILED) {
786
+ s2 = peg$parse_();
787
+ if (s2 !== peg$FAILED) {
788
+ s3 = peg$parseInteger();
789
+ if (s3 !== peg$FAILED) {
790
+ s4 = peg$parse_();
791
+ if (s4 !== peg$FAILED) {
792
+ if (input.charCodeAt(peg$currPos) === 44) {
793
+ s5 = peg$c19;
794
+ peg$currPos++;
795
+ } else {
796
+ s5 = peg$FAILED;
797
+ if (peg$silentFails === 0) {
798
+ peg$fail(peg$c20);
799
+ }
800
+ }
801
+ if (s5 !== peg$FAILED) {
802
+ s6 = peg$parse_();
803
+ if (s6 !== peg$FAILED) {
804
+ s7 = peg$parseInteger();
805
+ if (s7 !== peg$FAILED) {
806
+ s8 = peg$parse_();
807
+ if (s8 !== peg$FAILED) {
808
+ if (input.charCodeAt(peg$currPos) === 41) {
809
+ s9 = peg$c21;
810
+ peg$currPos++;
811
+ } else {
812
+ s9 = peg$FAILED;
813
+ if (peg$silentFails === 0) {
814
+ peg$fail(peg$c22);
815
+ }
816
+ }
817
+ if (s9 !== peg$FAILED) {
818
+ peg$savedPos = s0;
819
+ s1 = peg$c23(s3, s7);
820
+ s0 = s1;
821
+ } else {
822
+ peg$currPos = s0;
823
+ s0 = peg$FAILED;
824
+ }
825
+ } else {
826
+ peg$currPos = s0;
827
+ s0 = peg$FAILED;
828
+ }
829
+ } else {
830
+ peg$currPos = s0;
831
+ s0 = peg$FAILED;
832
+ }
833
+ } else {
834
+ peg$currPos = s0;
835
+ s0 = peg$FAILED;
836
+ }
837
+ } else {
838
+ peg$currPos = s0;
839
+ s0 = peg$FAILED;
840
+ }
841
+ } else {
842
+ peg$currPos = s0;
843
+ s0 = peg$FAILED;
844
+ }
845
+ } else {
846
+ peg$currPos = s0;
847
+ s0 = peg$FAILED;
848
+ }
849
+ } else {
850
+ peg$currPos = s0;
851
+ s0 = peg$FAILED;
852
+ }
853
+ } else {
854
+ peg$currPos = s0;
855
+ s0 = peg$FAILED;
856
+ }
857
+
858
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
859
+
860
+ return s0;
861
+ }
862
+
863
+ function peg$parsePath(): unknown {
864
+ let s0, s1, s2;
865
+
866
+ const key = peg$currPos * 13 + 8;
867
+ const cached: ICached = peg$resultsCache[key];
868
+
869
+ if (cached) {
870
+ peg$currPos = cached.nextPos;
871
+ return cached.result;
872
+ }
873
+
874
+ s0 = peg$currPos;
875
+ s1 = [];
876
+ if (peg$c24.test(input.charAt(peg$currPos))) {
877
+ s2 = input.charAt(peg$currPos);
878
+ peg$currPos++;
879
+ } else {
880
+ s2 = peg$FAILED;
881
+ if (peg$silentFails === 0) {
882
+ peg$fail(peg$c25);
883
+ }
884
+ }
885
+ if (s2 !== peg$FAILED) {
886
+ while (s2 !== peg$FAILED) {
887
+ s1.push(s2);
888
+ if (peg$c24.test(input.charAt(peg$currPos))) {
889
+ s2 = input.charAt(peg$currPos);
890
+ peg$currPos++;
891
+ } else {
892
+ s2 = peg$FAILED;
893
+ if (peg$silentFails === 0) {
894
+ peg$fail(peg$c25);
895
+ }
896
+ }
897
+ }
898
+ } else {
899
+ s1 = peg$FAILED;
900
+ }
901
+ if (s1 !== peg$FAILED) {
902
+ peg$savedPos = s0;
903
+ s1 = peg$c26(s1 as string[]);
904
+ }
905
+ s0 = s1;
906
+
907
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
908
+
909
+ return s0;
910
+ }
911
+
912
+ function peg$parseTextLine(): unknown {
913
+ let s0, s1, s2, s3;
914
+
915
+ const key = peg$currPos * 13 + 9;
916
+ const cached: ICached = peg$resultsCache[key];
917
+
918
+ if (cached) {
919
+ peg$currPos = cached.nextPos;
920
+ return cached.result;
921
+ }
922
+
923
+ s0 = peg$currPos;
924
+ s1 = [];
925
+ s2 = peg$parseAnyCharExceptNewLine();
926
+ if (s2 !== peg$FAILED) {
927
+ while (s2 !== peg$FAILED) {
928
+ s1.push(s2);
929
+ s2 = peg$parseAnyCharExceptNewLine();
930
+ }
931
+ } else {
932
+ s1 = peg$FAILED;
933
+ }
934
+ if (s1 !== peg$FAILED) {
935
+ s2 = [];
936
+ if (input.charCodeAt(peg$currPos) === 10) {
937
+ s3 = peg$c27;
938
+ peg$currPos++;
939
+ } else {
940
+ s3 = peg$FAILED;
941
+ if (peg$silentFails === 0) {
942
+ peg$fail(peg$c28);
943
+ }
944
+ }
945
+ while (s3 !== peg$FAILED) {
946
+ s2.push(s3);
947
+ if (input.charCodeAt(peg$currPos) === 10) {
948
+ s3 = peg$c27;
949
+ peg$currPos++;
950
+ } else {
951
+ s3 = peg$FAILED;
952
+ if (peg$silentFails === 0) {
953
+ peg$fail(peg$c28);
954
+ }
955
+ }
956
+ }
957
+ if (s2 !== peg$FAILED) {
958
+ peg$savedPos = s0;
959
+ s1 = peg$c29(s1 as string[], s2 as string[]);
960
+ s0 = s1;
961
+ } else {
962
+ peg$currPos = s0;
963
+ s0 = peg$FAILED;
964
+ }
965
+ } else {
966
+ peg$currPos = s0;
967
+ s0 = peg$FAILED;
968
+ }
969
+
970
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
971
+
972
+ return s0;
973
+ }
974
+
975
+ function peg$parseAnyCharExceptNewLine(): unknown {
976
+ let s0;
977
+
978
+ const key = peg$currPos * 13 + 10;
979
+ const cached: ICached = peg$resultsCache[key];
980
+
981
+ if (cached) {
982
+ peg$currPos = cached.nextPos;
983
+ return cached.result;
984
+ }
985
+
986
+ if (peg$c30.test(input.charAt(peg$currPos))) {
987
+ s0 = input.charAt(peg$currPos);
988
+ peg$currPos++;
989
+ } else {
990
+ s0 = peg$FAILED;
991
+ if (peg$silentFails === 0) {
992
+ peg$fail(peg$c31);
993
+ }
994
+ }
995
+
996
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
997
+
998
+ return s0;
999
+ }
1000
+
1001
+ function peg$parseInteger(): unknown {
1002
+ let s0, s1, s2;
1003
+
1004
+ const key = peg$currPos * 13 + 11;
1005
+ const cached: ICached = peg$resultsCache[key];
1006
+
1007
+ if (cached) {
1008
+ peg$currPos = cached.nextPos;
1009
+ return cached.result;
1010
+ }
1011
+
1012
+ s0 = peg$currPos;
1013
+ s1 = [];
1014
+ if (peg$c32.test(input.charAt(peg$currPos))) {
1015
+ s2 = input.charAt(peg$currPos);
1016
+ peg$currPos++;
1017
+ } else {
1018
+ s2 = peg$FAILED;
1019
+ if (peg$silentFails === 0) {
1020
+ peg$fail(peg$c33);
1021
+ }
1022
+ }
1023
+ if (s2 !== peg$FAILED) {
1024
+ while (s2 !== peg$FAILED) {
1025
+ s1.push(s2);
1026
+ if (peg$c32.test(input.charAt(peg$currPos))) {
1027
+ s2 = input.charAt(peg$currPos);
1028
+ peg$currPos++;
1029
+ } else {
1030
+ s2 = peg$FAILED;
1031
+ if (peg$silentFails === 0) {
1032
+ peg$fail(peg$c33);
1033
+ }
1034
+ }
1035
+ }
1036
+ } else {
1037
+ s1 = peg$FAILED;
1038
+ }
1039
+ if (s1 !== peg$FAILED) {
1040
+ peg$savedPos = s0;
1041
+ s1 = peg$c34(s1 as string[]);
1042
+ }
1043
+ s0 = s1;
1044
+
1045
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1046
+
1047
+ return s0;
1048
+ }
1049
+
1050
+ function peg$parse_(): unknown {
1051
+ let s0, s1, s2;
1052
+
1053
+ const key = peg$currPos * 13 + 12;
1054
+ const cached: ICached = peg$resultsCache[key];
1055
+
1056
+ if (cached) {
1057
+ peg$currPos = cached.nextPos;
1058
+ return cached.result;
1059
+ }
1060
+
1061
+ s0 = peg$currPos;
1062
+ s1 = [];
1063
+ if (peg$c35.test(input.charAt(peg$currPos))) {
1064
+ s2 = input.charAt(peg$currPos);
1065
+ peg$currPos++;
1066
+ } else {
1067
+ s2 = peg$FAILED;
1068
+ if (peg$silentFails === 0) {
1069
+ peg$fail(peg$c36);
1070
+ }
1071
+ }
1072
+ while (s2 !== peg$FAILED) {
1073
+ s1.push(s2);
1074
+ if (peg$c35.test(input.charAt(peg$currPos))) {
1075
+ s2 = input.charAt(peg$currPos);
1076
+ peg$currPos++;
1077
+ } else {
1078
+ s2 = peg$FAILED;
1079
+ if (peg$silentFails === 0) {
1080
+ peg$fail(peg$c36);
1081
+ }
1082
+ }
1083
+ }
1084
+ if (s1 !== peg$FAILED) {
1085
+ peg$savedPos = s0;
1086
+ s1 = peg$c37();
1087
+ }
1088
+ s0 = s1;
1089
+
1090
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1091
+
1092
+ return s0;
1093
+ }
1094
+
1095
+ peg$result = peg$startRuleFunction();
1096
+
1097
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1098
+ return peg$result as GrammarItem[];
1099
+ } else {
1100
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1101
+ peg$fail(peg$endExpectation());
1102
+ }
1103
+
1104
+ throw peg$buildStructuredError(
1105
+ peg$maxFailExpected,
1106
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
1107
+ peg$maxFailPos < input.length
1108
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1109
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1110
+ );
1111
+ }
1112
+ }
1113
+
1114
+ export type ParseFunction = (input: string, options?: IParseOptions) => GrammarItem[];
1115
+ export const parse: ParseFunction = peg$parse;