@optique/core 1.1.0-dev.2096 → 1.1.0-dev.2146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotation-state.cjs +26 -26
- package/dist/annotation-state.d.cts +133 -1
- package/dist/annotation-state.d.ts +133 -1
- package/dist/annotations.cjs +2 -2
- package/dist/constructs.cjs +141 -73
- package/dist/constructs.js +70 -2
- package/dist/dependency-metadata.cjs +12 -12
- package/dist/dependency-metadata.d.cts +34 -3
- package/dist/dependency-metadata.d.ts +34 -3
- package/dist/dependency-runtime.cjs +37 -13
- package/dist/dependency-runtime.d.cts +197 -2
- package/dist/dependency-runtime.d.ts +197 -2
- package/dist/dependency-runtime.js +22 -1
- package/dist/dependency.cjs +7 -7
- package/dist/displaywidth.d.cts +12 -0
- package/dist/displaywidth.d.ts +12 -0
- package/dist/execution-context.d.cts +23 -0
- package/dist/execution-context.d.ts +23 -0
- package/dist/extension.cjs +14 -14
- package/dist/facade.cjs +46 -36
- package/dist/facade.js +31 -21
- package/dist/index.cjs +22 -21
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/input-trace.d.cts +2 -1
- package/dist/input-trace.d.ts +2 -1
- package/dist/internal/annotations.cjs +3 -0
- package/dist/internal/annotations.d.cts +47 -5
- package/dist/internal/annotations.d.ts +47 -5
- package/dist/internal/annotations.js +1 -1
- package/dist/internal/command-alias.cjs +16 -0
- package/dist/internal/command-alias.js +14 -0
- package/dist/internal/dependency.cjs +131 -0
- package/dist/internal/dependency.d.cts +311 -2
- package/dist/internal/dependency.d.ts +311 -2
- package/dist/internal/dependency.js +119 -1
- package/dist/internal/parser.cjs +35 -13
- package/dist/internal/parser.d.cts +44 -3
- package/dist/internal/parser.d.ts +44 -3
- package/dist/internal/parser.js +28 -6
- package/dist/modifiers.cjs +41 -41
- package/dist/parser.cjs +11 -11
- package/dist/phase2-seed.cjs +2 -2
- package/dist/phase2-seed.d.cts +50 -0
- package/dist/phase2-seed.d.ts +50 -0
- package/dist/primitives.cjs +74 -33
- package/dist/primitives.d.cts +10 -0
- package/dist/primitives.d.ts +10 -0
- package/dist/primitives.js +54 -13
- package/dist/suggestion.cjs +72 -2
- package/dist/suggestion.d.cts +188 -0
- package/dist/suggestion.d.ts +188 -0
- package/dist/suggestion.js +71 -3
- package/dist/usage-internals.cjs +5 -1
- package/dist/usage-internals.js +5 -1
- package/dist/usage.cjs +9 -1
- package/dist/usage.d.cts +14 -0
- package/dist/usage.d.ts +14 -0
- package/dist/usage.js +9 -1
- package/dist/validate.cjs +1 -0
- package/dist/validate.d.cts +99 -0
- package/dist/validate.d.ts +99 -0
- package/dist/validate.js +1 -1
- package/dist/valueparser.cjs +333 -79
- package/dist/valueparser.d.cts +197 -1
- package/dist/valueparser.d.ts +197 -1
- package/dist/valueparser.js +334 -81
- package/package.json +19 -4
package/dist/constructs.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_internal_annotations = require('./internal/annotations.cjs');
|
|
2
2
|
const require_message = require('./message.cjs');
|
|
3
3
|
const require_validate = require('./validate.cjs');
|
|
4
4
|
const require_usage = require('./usage.cjs');
|
|
5
5
|
const require_doc = require('./doc.cjs');
|
|
6
6
|
const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
7
|
-
const
|
|
7
|
+
const require_internal_dependency = require('./internal/dependency.cjs');
|
|
8
8
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
9
|
-
const
|
|
9
|
+
const require_internal_parser = require('./internal/parser.cjs');
|
|
10
10
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
11
|
+
const require_command_alias = require('./internal/command-alias.cjs');
|
|
11
12
|
const require_execution_context = require('./execution-context.cjs');
|
|
12
13
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
13
14
|
const require_suggestion = require('./suggestion.cjs');
|
|
@@ -20,7 +21,7 @@ const require_usage_internals = require('./usage-internals.cjs');
|
|
|
20
21
|
*/
|
|
21
22
|
const EMPTY_LEADING_NAMES = /* @__PURE__ */ new Set();
|
|
22
23
|
function isNonCliBoundSourceState(state, parser) {
|
|
23
|
-
return parser[
|
|
24
|
+
return parser[require_internal_parser.unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object" && Object.hasOwn(state, "hasCliValue") && state.hasCliValue === false;
|
|
24
25
|
}
|
|
25
26
|
function withDependencyRuntimeExec(usage, exec, runtime) {
|
|
26
27
|
if (exec == null) return {
|
|
@@ -43,8 +44,8 @@ function withChildContext$1(context, segment, state, parser, usage) {
|
|
|
43
44
|
}
|
|
44
45
|
function isUnmatchedDependencyState(state, parser) {
|
|
45
46
|
if (state === void 0) return true;
|
|
46
|
-
if (Array.isArray(state) && state.length === 1 &&
|
|
47
|
-
if (
|
|
47
|
+
if (Array.isArray(state) && state.length === 1 && require_internal_dependency.isPendingDependencySourceState(state[0])) return true;
|
|
48
|
+
if (require_internal_dependency.isPendingDependencySourceState(state)) return true;
|
|
48
49
|
if (isNonCliBoundSourceState(state, parser)) return true;
|
|
49
50
|
return state === parser.initialState;
|
|
50
51
|
}
|
|
@@ -61,7 +62,7 @@ function buildIndexedParserPairs(parsers) {
|
|
|
61
62
|
}
|
|
62
63
|
function createAnnotatedArrayStateRecord(stateArray) {
|
|
63
64
|
const stateRecord = Object.fromEntries(stateArray.map((state, index) => [String(index), state]));
|
|
64
|
-
return
|
|
65
|
+
return require_internal_annotations.inheritAnnotations(stateArray, stateRecord);
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Computes the union of `leadingNames` from all given parsers.
|
|
@@ -173,7 +174,7 @@ function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()
|
|
|
173
174
|
return clone;
|
|
174
175
|
}
|
|
175
176
|
function unwrapCompleteResult(result) {
|
|
176
|
-
const unwrappedResult =
|
|
177
|
+
const unwrappedResult = require_internal_dependency.isDependencySourceState(result) ? result.result : result;
|
|
177
178
|
if (!unwrappedResult.success || !containsAnnotationView(unwrappedResult.value)) return unwrappedResult;
|
|
178
179
|
const value = unwrapNestedAnnotationViews(unwrappedResult.value);
|
|
179
180
|
return value === unwrappedResult.value ? unwrappedResult : {
|
|
@@ -257,8 +258,8 @@ function combineTuplePhase2Seeds(first, second) {
|
|
|
257
258
|
*/
|
|
258
259
|
function prepareStateForCompletion(fieldState, parser) {
|
|
259
260
|
if (fieldState !== void 0) return fieldState;
|
|
260
|
-
if (
|
|
261
|
-
if (
|
|
261
|
+
if (require_internal_dependency.isPendingDependencySourceState(parser.initialState)) return [parser.initialState];
|
|
262
|
+
if (require_internal_dependency.isWrappedDependencySource(parser)) return [parser[require_internal_dependency.wrappedDependencySourceMarker]];
|
|
262
263
|
return fieldState;
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
@@ -281,7 +282,7 @@ function buildSuggestRuntimeNodesFromPairs(pairs, state, parentPath) {
|
|
|
281
282
|
const nodes = [];
|
|
282
283
|
for (const [field, parser] of pairs) {
|
|
283
284
|
const fieldState = Object.hasOwn(state, field) ? state[field] : parser.initialState;
|
|
284
|
-
nodes.push(...
|
|
285
|
+
nodes.push(...require_internal_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(state, fieldState, parser), [...prefix, field]));
|
|
285
286
|
}
|
|
286
287
|
return nodes;
|
|
287
288
|
}
|
|
@@ -291,7 +292,7 @@ function buildSuggestRuntimeNodesFromArray(parsers, stateArray, parentPath) {
|
|
|
291
292
|
for (let i = 0; i < parsers.length; i++) {
|
|
292
293
|
const parser = parsers[i];
|
|
293
294
|
const elementState = i < stateArray.length ? stateArray[i] : void 0;
|
|
294
|
-
nodes.push(...
|
|
295
|
+
nodes.push(...require_internal_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(stateArray, elementState, parser), [...prefix, i]));
|
|
295
296
|
}
|
|
296
297
|
return nodes;
|
|
297
298
|
}
|
|
@@ -301,7 +302,12 @@ function createUnexpectedInputErrorWithScopedSuggestions(baseError, invalidInput
|
|
|
301
302
|
for (const parser of parsers) require_usage_internals.collectLeadingCandidates(parser.usage, options, commands);
|
|
302
303
|
const candidates = new Set([...options, ...commands]);
|
|
303
304
|
const suggestions = require_suggestion.findSimilar(invalidInput, candidates, require_suggestion.DEFAULT_FIND_SIMILAR_OPTIONS);
|
|
304
|
-
const
|
|
305
|
+
const aliasUsage = [{
|
|
306
|
+
type: "exclusive",
|
|
307
|
+
terms: parsers.map((parser) => parser.usage)
|
|
308
|
+
}];
|
|
309
|
+
const displaySuggestions = require_suggestion.expandCommandAliasSuggestions(aliasUsage, suggestions);
|
|
310
|
+
const suggestionMsg = customFormatter ? customFormatter(displaySuggestions) : require_suggestion.createSuggestionMessage(displaySuggestions);
|
|
305
311
|
return suggestionMsg.length > 0 ? [
|
|
306
312
|
...baseError,
|
|
307
313
|
require_message.text("\n\n"),
|
|
@@ -457,6 +463,18 @@ var DuplicateOptionError = class extends Error {
|
|
|
457
463
|
}
|
|
458
464
|
};
|
|
459
465
|
/**
|
|
466
|
+
* Error class thrown when duplicate command names or aliases are detected
|
|
467
|
+
* during parser construction. This is a programmer error, not a user error.
|
|
468
|
+
*/
|
|
469
|
+
var DuplicateCommandNameError = class extends TypeError {
|
|
470
|
+
constructor(commandName, sources) {
|
|
471
|
+
const sourceNames = sources.map((s) => typeof s === "symbol" ? s.description ?? s.toString() : s);
|
|
472
|
+
super(`Duplicate command name "${commandName}" found in parsers: ${sourceNames.join(", ")}. Each command name or alias must be unique within active parser alternatives.`);
|
|
473
|
+
this.commandName = commandName;
|
|
474
|
+
this.sources = sources;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
460
478
|
* Checks for duplicate option names across parser sources and throws an error
|
|
461
479
|
* if duplicates are found. This should be called at construction time.
|
|
462
480
|
* @param parserSources Array of [source, usage] tuples
|
|
@@ -473,6 +491,48 @@ function checkDuplicateOptionNames(parserSources) {
|
|
|
473
491
|
}
|
|
474
492
|
for (const [name, sources] of optionNameSources) if (sources.length > 1) throw new DuplicateOptionError(name, sources);
|
|
475
493
|
}
|
|
494
|
+
function checkDuplicateLeadingCommandNames(parserSources) {
|
|
495
|
+
const commandNameSources = /* @__PURE__ */ new Map();
|
|
496
|
+
for (const [source, parser] of parserSources) {
|
|
497
|
+
const commandNames = require_usage.extractCommandNames(parser.usage, true);
|
|
498
|
+
for (const name of parser.leadingNames) {
|
|
499
|
+
if (!commandNames.has(name)) continue;
|
|
500
|
+
const sources = commandNameSources.get(name);
|
|
501
|
+
commandNameSources.set(name, sources == null ? [source] : [...sources, source]);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
for (const [name, sources] of commandNameSources) if (sources.length > 1) throw new DuplicateCommandNameError(name, sources);
|
|
505
|
+
}
|
|
506
|
+
function checkDuplicateReachableLeadingCommandNames(parserSources) {
|
|
507
|
+
const commandNameSources = /* @__PURE__ */ new Map();
|
|
508
|
+
const sortedSources = [...parserSources].sort(([, parserA], [, parserB]) => parserB.priority - parserA.priority);
|
|
509
|
+
const blockedNames = /* @__PURE__ */ new Set();
|
|
510
|
+
let positionalBlocked = false;
|
|
511
|
+
for (let i = 0; i < sortedSources.length;) {
|
|
512
|
+
const priority = sortedSources[i][1].priority;
|
|
513
|
+
const priorityGroup = [];
|
|
514
|
+
while (i < sortedSources.length && sortedSources[i][1].priority === priority) {
|
|
515
|
+
priorityGroup.push(sortedSources[i]);
|
|
516
|
+
i++;
|
|
517
|
+
}
|
|
518
|
+
const groupNames = /* @__PURE__ */ new Set();
|
|
519
|
+
let groupAcceptsAnyToken = false;
|
|
520
|
+
for (const [source, parser] of priorityGroup) {
|
|
521
|
+
if (parser.acceptingAnyToken) groupAcceptsAnyToken = true;
|
|
522
|
+
const commandNames = require_usage.extractCommandNames(parser.usage, true);
|
|
523
|
+
for (const name of parser.leadingNames) {
|
|
524
|
+
if (!commandNames.has(name)) continue;
|
|
525
|
+
if (positionalBlocked || blockedNames.has(name)) continue;
|
|
526
|
+
groupNames.add(name);
|
|
527
|
+
const sources = commandNameSources.get(name);
|
|
528
|
+
commandNameSources.set(name, sources == null ? [source] : [...sources, source]);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
for (const name of groupNames) blockedNames.add(name);
|
|
532
|
+
if (groupAcceptsAnyToken) positionalBlocked = true;
|
|
533
|
+
}
|
|
534
|
+
for (const [name, sources] of commandNameSources) if (sources.length > 1) throw new DuplicateCommandNameError(name, sources);
|
|
535
|
+
}
|
|
476
536
|
/**
|
|
477
537
|
* Extracts option names that participate in CLI syntax.
|
|
478
538
|
*
|
|
@@ -518,7 +578,7 @@ function annotateExclusiveParserResult(parentState, parser, result) {
|
|
|
518
578
|
}
|
|
519
579
|
function createExclusiveState(parentState, index, parser, result) {
|
|
520
580
|
const annotatedResult = annotateExclusiveParserResult(parentState, parser, result);
|
|
521
|
-
return
|
|
581
|
+
return require_internal_annotations.annotateFreshArray(parentState, [index, annotatedResult]);
|
|
522
582
|
}
|
|
523
583
|
/**
|
|
524
584
|
* Creates a complete() method shared by or() and longestMatch().
|
|
@@ -614,7 +674,7 @@ function getExclusiveSuggestRuntimeNodes(parsers, state, path) {
|
|
|
614
674
|
const [index, parserResult] = activeState;
|
|
615
675
|
if (!parserResult?.success || index < 0 || index >= parsers.length) return [];
|
|
616
676
|
const parser = parsers[index];
|
|
617
|
-
return
|
|
677
|
+
return require_internal_parser.getParserSuggestRuntimeNodes(parser, parserResult.next.state, [...path, index]);
|
|
618
678
|
}
|
|
619
679
|
function findExclusiveZeroInputCandidateSync(parsers, state, exec) {
|
|
620
680
|
const emptyCtx = {
|
|
@@ -737,6 +797,7 @@ function or(...args) {
|
|
|
737
797
|
}
|
|
738
798
|
if (parsers.length < 1) throw new TypeError("or() requires at least one parser argument.");
|
|
739
799
|
assertParsers(parsers, "or()");
|
|
800
|
+
checkDuplicateLeadingCommandNames(parsers.map((parser, index) => [String(index), parser]));
|
|
740
801
|
const noMatchContext = analyzeNoMatchContext(parsers);
|
|
741
802
|
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
742
803
|
const syncParsers = parsers;
|
|
@@ -1205,13 +1266,16 @@ function or(...args) {
|
|
|
1205
1266
|
};
|
|
1206
1267
|
const singleDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
1207
1268
|
if (singleDependencyMetadata != null) singleResult.dependencyMetadata = singleDependencyMetadata;
|
|
1208
|
-
|
|
1269
|
+
require_internal_parser.defineInheritedAnnotationParser(singleResult);
|
|
1209
1270
|
return singleResult;
|
|
1210
1271
|
}
|
|
1211
1272
|
/**
|
|
1212
1273
|
* @since 0.5.0
|
|
1213
1274
|
*/
|
|
1214
1275
|
function longestMatch(...args) {
|
|
1276
|
+
return createLongestMatch(...args);
|
|
1277
|
+
}
|
|
1278
|
+
function createLongestMatch(...args) {
|
|
1215
1279
|
let parsers;
|
|
1216
1280
|
let options;
|
|
1217
1281
|
if (args.length > 0 && args[args.length - 1] && typeof args[args.length - 1] === "object" && !("$valueType" in args[args.length - 1])) {
|
|
@@ -1223,6 +1287,8 @@ function longestMatch(...args) {
|
|
|
1223
1287
|
}
|
|
1224
1288
|
if (parsers.length < 1) throw new TypeError("longestMatch() requires at least one parser argument.");
|
|
1225
1289
|
assertParsers(parsers, "longestMatch()");
|
|
1290
|
+
const allowDuplicateLeadingCommandNames = options?.[require_command_alias.allowDuplicateLeadingCommandNamesKey] === true;
|
|
1291
|
+
if (!allowDuplicateLeadingCommandNames) checkDuplicateLeadingCommandNames(parsers.map((parser, index) => [String(index), parser]));
|
|
1226
1292
|
const noMatchContext = analyzeNoMatchContext(parsers);
|
|
1227
1293
|
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
1228
1294
|
const syncParsers = parsers;
|
|
@@ -1375,7 +1441,7 @@ function longestMatch(...args) {
|
|
|
1375
1441
|
};
|
|
1376
1442
|
const multiDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
1377
1443
|
if (multiDependencyMetadata != null) multiResult.dependencyMetadata = multiDependencyMetadata;
|
|
1378
|
-
|
|
1444
|
+
require_internal_parser.defineInheritedAnnotationParser(multiResult);
|
|
1379
1445
|
return multiResult;
|
|
1380
1446
|
}
|
|
1381
1447
|
/**
|
|
@@ -1458,7 +1524,7 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1458
1524
|
* @internal
|
|
1459
1525
|
*/
|
|
1460
1526
|
function registerCompletedDependency(completed, registry) {
|
|
1461
|
-
if (
|
|
1527
|
+
if (require_internal_dependency.isDependencySourceState(completed) && completed.result.success && !registry.has(completed[require_internal_dependency.dependencyId])) registry.set(completed[require_internal_dependency.dependencyId], completed.result.value);
|
|
1462
1528
|
}
|
|
1463
1529
|
/**
|
|
1464
1530
|
* Yields `(parser, state)` pairs for dependency source parsers whose field
|
|
@@ -1469,7 +1535,7 @@ function registerCompletedDependency(completed, registry) {
|
|
|
1469
1535
|
*/
|
|
1470
1536
|
function* pendingDependencyDefaults(context, parserPairs, registry) {
|
|
1471
1537
|
for (const [field, fieldParser] of parserPairs) {
|
|
1472
|
-
const sourceId = fieldParser.dependencyMetadata?.source?.sourceId ?? (
|
|
1538
|
+
const sourceId = fieldParser.dependencyMetadata?.source?.sourceId ?? (require_internal_dependency.isWrappedDependencySource(fieldParser) ? fieldParser[require_internal_dependency.wrappedDependencySourceMarker][require_internal_dependency.dependencyId] : require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState) ? fieldParser.initialState[require_internal_dependency.dependencyId] : void 0);
|
|
1473
1539
|
if (sourceId != null && registry?.has(sourceId)) continue;
|
|
1474
1540
|
const fieldState = context.state != null && typeof context.state === "object" && field in context.state ? context.state[field] : void 0;
|
|
1475
1541
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, fieldParser);
|
|
@@ -1488,19 +1554,19 @@ function* pendingDependencyDefaults(context, parserPairs, registry) {
|
|
|
1488
1554
|
continue;
|
|
1489
1555
|
}
|
|
1490
1556
|
if (fieldState != null) {
|
|
1491
|
-
if (!Array.isArray(fieldState) && !
|
|
1557
|
+
if (!Array.isArray(fieldState) && !require_internal_dependency.isDependencySourceState(fieldState) && (require_internal_dependency.isWrappedDependencySource(fieldParser) || require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState))) yield {
|
|
1492
1558
|
parser: fieldParser,
|
|
1493
1559
|
state: getAnnotatedFieldState(context.state, field, fieldParser)
|
|
1494
1560
|
};
|
|
1495
1561
|
continue;
|
|
1496
1562
|
}
|
|
1497
|
-
if (
|
|
1563
|
+
if (require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState)) yield {
|
|
1498
1564
|
parser: fieldParser,
|
|
1499
1565
|
state: fieldParser.initialState
|
|
1500
1566
|
};
|
|
1501
|
-
else if (
|
|
1567
|
+
else if (require_internal_dependency.isWrappedDependencySource(fieldParser)) yield {
|
|
1502
1568
|
parser: fieldParser,
|
|
1503
|
-
state: [fieldParser[
|
|
1569
|
+
state: [fieldParser[require_internal_dependency.wrappedDependencySourceMarker]]
|
|
1504
1570
|
};
|
|
1505
1571
|
}
|
|
1506
1572
|
}
|
|
@@ -1532,13 +1598,13 @@ function completeDependencySourceDefaults(context, parserPairs, registry, exec)
|
|
|
1532
1598
|
* @internal
|
|
1533
1599
|
*/
|
|
1534
1600
|
function wrapAsDependencySourceState(completed, parser) {
|
|
1535
|
-
if (
|
|
1601
|
+
if (require_internal_dependency.isDependencySourceState(completed)) return completed;
|
|
1536
1602
|
const metadataSource = parser.dependencyMetadata?.source;
|
|
1537
1603
|
if (metadataSource?.preservesSourceValue === false) return void 0;
|
|
1538
|
-
const hasDep = metadataSource != null ||
|
|
1604
|
+
const hasDep = metadataSource != null || require_internal_dependency.isWrappedDependencySource(parser) || require_internal_dependency.isPendingDependencySourceState(parser.initialState);
|
|
1539
1605
|
if (hasDep && typeof completed === "object" && completed !== null && "success" in completed && completed.success && "value" in completed && completed.value !== void 0) {
|
|
1540
|
-
const depId = metadataSource?.sourceId ?? (
|
|
1541
|
-
return
|
|
1606
|
+
const depId = metadataSource?.sourceId ?? (require_internal_dependency.isWrappedDependencySource(parser) ? parser[require_internal_dependency.wrappedDependencySourceMarker][require_internal_dependency.dependencyId] : parser.initialState[require_internal_dependency.dependencyId]);
|
|
1607
|
+
return require_internal_dependency.createDependencySourceState(completed, depId);
|
|
1542
1608
|
}
|
|
1543
1609
|
return void 0;
|
|
1544
1610
|
}
|
|
@@ -1648,20 +1714,20 @@ function preCompleteAndRegisterDependencies(state, fieldParserPairs, registry, e
|
|
|
1648
1714
|
if (depState) registerCompletedDependency(depState, registry);
|
|
1649
1715
|
continue;
|
|
1650
1716
|
}
|
|
1651
|
-
if (Array.isArray(fieldState) && fieldState.length === 1 &&
|
|
1717
|
+
if (Array.isArray(fieldState) && fieldState.length === 1 && require_internal_dependency.isPendingDependencySourceState(fieldState[0])) {
|
|
1652
1718
|
const completed = fieldParser.complete(fieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1653
1719
|
preCompleted.set(field, completed);
|
|
1654
|
-
if (
|
|
1655
|
-
} else if (fieldState === void 0 &&
|
|
1720
|
+
if (require_internal_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1721
|
+
} else if (fieldState === void 0 && require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState)) {
|
|
1656
1722
|
const completed = fieldParser.complete([fieldParser.initialState], require_execution_context.withChildExecPath(exec, field));
|
|
1657
1723
|
preCompleted.set(field, completed);
|
|
1658
|
-
if (
|
|
1659
|
-
} else if (fieldState === void 0 &&
|
|
1660
|
-
const pendingState = fieldParser[
|
|
1724
|
+
if (require_internal_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1725
|
+
} else if (fieldState === void 0 && require_internal_dependency.isWrappedDependencySource(fieldParser)) {
|
|
1726
|
+
const pendingState = fieldParser[require_internal_dependency.wrappedDependencySourceMarker];
|
|
1661
1727
|
const completed = fieldParser.complete([pendingState], require_execution_context.withChildExecPath(exec, field));
|
|
1662
1728
|
preCompleted.set(field, completed);
|
|
1663
|
-
if (
|
|
1664
|
-
} else if (fieldState != null && !Array.isArray(fieldState) && !
|
|
1729
|
+
if (require_internal_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1730
|
+
} else if (fieldState != null && !Array.isArray(fieldState) && !require_internal_dependency.isDependencySourceState(fieldState) && (require_internal_dependency.isWrappedDependencySource(fieldParser) || require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState))) {
|
|
1665
1731
|
const annotatedFieldState$1 = getAnnotatedFieldState(state, field, fieldParser);
|
|
1666
1732
|
const completed = fieldParser.complete(annotatedFieldState$1, require_execution_context.withChildExecPath(exec, field));
|
|
1667
1733
|
preCompleted.set(field, completed);
|
|
@@ -1701,20 +1767,20 @@ async function preCompleteAndRegisterDependenciesAsync(state, fieldParserPairs,
|
|
|
1701
1767
|
if (depState) registerCompletedDependency(depState, registry);
|
|
1702
1768
|
continue;
|
|
1703
1769
|
}
|
|
1704
|
-
if (Array.isArray(fieldState) && fieldState.length === 1 &&
|
|
1770
|
+
if (Array.isArray(fieldState) && fieldState.length === 1 && require_internal_dependency.isPendingDependencySourceState(fieldState[0])) {
|
|
1705
1771
|
const completed = await fieldParser.complete(fieldState, require_execution_context.withChildExecPath(exec, field));
|
|
1706
1772
|
preCompleted.set(field, completed);
|
|
1707
|
-
if (
|
|
1708
|
-
} else if (fieldState === void 0 &&
|
|
1773
|
+
if (require_internal_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1774
|
+
} else if (fieldState === void 0 && require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState)) {
|
|
1709
1775
|
const completed = await fieldParser.complete([fieldParser.initialState], require_execution_context.withChildExecPath(exec, field));
|
|
1710
1776
|
preCompleted.set(field, completed);
|
|
1711
|
-
if (
|
|
1712
|
-
} else if (fieldState === void 0 &&
|
|
1713
|
-
const pendingState = fieldParser[
|
|
1777
|
+
if (require_internal_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1778
|
+
} else if (fieldState === void 0 && require_internal_dependency.isWrappedDependencySource(fieldParser)) {
|
|
1779
|
+
const pendingState = fieldParser[require_internal_dependency.wrappedDependencySourceMarker];
|
|
1714
1780
|
const completed = await fieldParser.complete([pendingState], require_execution_context.withChildExecPath(exec, field));
|
|
1715
1781
|
preCompleted.set(field, completed);
|
|
1716
|
-
if (
|
|
1717
|
-
} else if (fieldState != null && !Array.isArray(fieldState) && !
|
|
1782
|
+
if (require_internal_dependency.isDependencySourceState(completed)) registerCompletedDependency(completed, registry);
|
|
1783
|
+
} else if (fieldState != null && !Array.isArray(fieldState) && !require_internal_dependency.isDependencySourceState(fieldState) && (require_internal_dependency.isWrappedDependencySource(fieldParser) || require_internal_dependency.isPendingDependencySourceState(fieldParser.initialState))) {
|
|
1718
1784
|
const annotatedFieldState$1 = getAnnotatedFieldState(state, field, fieldParser);
|
|
1719
1785
|
const completed = await fieldParser.complete(annotatedFieldState$1, require_execution_context.withChildExecPath(exec, field));
|
|
1720
1786
|
preCompleted.set(field, completed);
|
|
@@ -1768,6 +1834,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1768
1834
|
};
|
|
1769
1835
|
};
|
|
1770
1836
|
if (!options.allowDuplicates) checkDuplicateOptionNames(parserPairs.map(([field, parser]) => [field, parser.usage]));
|
|
1837
|
+
checkDuplicateReachableLeadingCommandNames(parserPairs.map(([field, parser]) => [field, parser]));
|
|
1771
1838
|
const noMatchContext = analyzeNoMatchContext(parserKeys.map((k) => parsers[k]));
|
|
1772
1839
|
const combinedMode = parserKeys.some((k) => parsers[k].mode === "async") ? "async" : "sync";
|
|
1773
1840
|
const getInitialError = (context) => ({
|
|
@@ -2301,7 +2368,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2301
2368
|
configurable: true,
|
|
2302
2369
|
enumerable: false
|
|
2303
2370
|
});
|
|
2304
|
-
|
|
2371
|
+
require_internal_parser.defineInheritedAnnotationParser(objectParser);
|
|
2305
2372
|
return objectParser;
|
|
2306
2373
|
}
|
|
2307
2374
|
function isParserLike(value) {
|
|
@@ -2485,15 +2552,15 @@ function collectRetainedLeadingCandidatesAtState(terms, state) {
|
|
|
2485
2552
|
function createSeqState(sourceState, index, states) {
|
|
2486
2553
|
const seqState = {
|
|
2487
2554
|
index,
|
|
2488
|
-
states:
|
|
2555
|
+
states: require_internal_annotations.annotateFreshArray(sourceState, states)
|
|
2489
2556
|
};
|
|
2490
|
-
return
|
|
2557
|
+
return require_internal_annotations.inheritAnnotations(sourceState, seqState);
|
|
2491
2558
|
}
|
|
2492
2559
|
function getSeqChildState(seqState, index, parser) {
|
|
2493
2560
|
return require_annotation_state.getWrappedChildState(seqState, seqState.states[index], parser);
|
|
2494
2561
|
}
|
|
2495
2562
|
function updateSeqChildState(sourceState, index, childState, parser) {
|
|
2496
|
-
return
|
|
2563
|
+
return require_internal_annotations.annotateFreshArray(sourceState.states, sourceState.states.map((state, stateIndex) => stateIndex === index ? require_annotation_state.getWrappedChildState(sourceState.states, childState, parser) : state));
|
|
2497
2564
|
}
|
|
2498
2565
|
function shouldAdvanceSeqBeforeParse(parser, parserState, initialParserState, currentContext, index, parsers) {
|
|
2499
2566
|
const token = currentContext.buffer[0];
|
|
@@ -2586,7 +2653,7 @@ async function advanceSeqSuggestContextAsync(context, parsers, initialStates) {
|
|
|
2586
2653
|
function createSeqComplete(parsers, combinedMode) {
|
|
2587
2654
|
const syncParsers = parsers;
|
|
2588
2655
|
return (state, exec) => require_mode_dispatch.dispatchByMode(combinedMode, () => {
|
|
2589
|
-
const stateArray =
|
|
2656
|
+
const stateArray = require_internal_annotations.annotateFreshArray(state, state.states);
|
|
2590
2657
|
const runtime = exec?.dependencyRuntime ?? require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry);
|
|
2591
2658
|
const childExec = {
|
|
2592
2659
|
...exec,
|
|
@@ -2626,7 +2693,7 @@ function createSeqComplete(parsers, combinedMode) {
|
|
|
2626
2693
|
} : {}
|
|
2627
2694
|
};
|
|
2628
2695
|
}, async () => {
|
|
2629
|
-
const stateArray =
|
|
2696
|
+
const stateArray = require_internal_annotations.annotateFreshArray(state, state.states);
|
|
2630
2697
|
const runtime = exec?.dependencyRuntime ?? require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry);
|
|
2631
2698
|
const childExec = {
|
|
2632
2699
|
...exec,
|
|
@@ -2748,7 +2815,7 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2748
2815
|
for (const [parser, index] of remainingParsers) {
|
|
2749
2816
|
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2750
2817
|
if (result.success && result.consumed.length > 0) {
|
|
2751
|
-
const newStateArray =
|
|
2818
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2752
2819
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2753
2820
|
currentContext = {
|
|
2754
2821
|
...currentContext,
|
|
@@ -2773,7 +2840,7 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2773
2840
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2774
2841
|
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2775
2842
|
if (result.success && result.consumed.length < 1) {
|
|
2776
|
-
const newStateArray =
|
|
2843
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2777
2844
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2778
2845
|
currentContext = {
|
|
2779
2846
|
...currentContext,
|
|
@@ -2814,7 +2881,7 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2814
2881
|
for (const [parser, index] of remainingParsers) {
|
|
2815
2882
|
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2816
2883
|
if (result.success && result.consumed.length > 0) {
|
|
2817
|
-
const newStateArray =
|
|
2884
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2818
2885
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2819
2886
|
currentContext = {
|
|
2820
2887
|
...currentContext,
|
|
@@ -2839,7 +2906,7 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2839
2906
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2840
2907
|
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2841
2908
|
if (result.success && result.consumed.length < 1) {
|
|
2842
|
-
const newStateArray =
|
|
2909
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2843
2910
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2844
2911
|
currentContext = {
|
|
2845
2912
|
...currentContext,
|
|
@@ -2875,7 +2942,7 @@ function markFailedTupleSuggestSources(parsers, stateArray, failedParserIndexes,
|
|
|
2875
2942
|
const parser = parsers[index];
|
|
2876
2943
|
if (parser == null) continue;
|
|
2877
2944
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
2878
|
-
const nodes =
|
|
2945
|
+
const nodes = require_internal_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
2879
2946
|
if (nodes.length < 1) continue;
|
|
2880
2947
|
const failedRuntime = require_dependency_runtime.createDependencyRuntimeContext();
|
|
2881
2948
|
require_dependency_runtime.collectExplicitSourceValues(nodes, failedRuntime);
|
|
@@ -2892,7 +2959,7 @@ async function markFailedTupleSuggestSourcesAsync(parsers, stateArray, failedPar
|
|
|
2892
2959
|
const parser = parsers[index];
|
|
2893
2960
|
if (parser == null) continue;
|
|
2894
2961
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
2895
|
-
const nodes =
|
|
2962
|
+
const nodes = require_internal_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
2896
2963
|
if (nodes.length < 1) continue;
|
|
2897
2964
|
const failedRuntime = require_dependency_runtime.createDependencyRuntimeContext();
|
|
2898
2965
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(nodes, failedRuntime);
|
|
@@ -2932,7 +2999,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2932
2999
|
for (const [parser, index] of remainingParsers) {
|
|
2933
3000
|
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2934
3001
|
if (result.success && result.consumed.length > 0) {
|
|
2935
|
-
const newStateArray =
|
|
3002
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2936
3003
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2937
3004
|
currentContext = {
|
|
2938
3005
|
...currentContext,
|
|
@@ -2953,7 +3020,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2953
3020
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2954
3021
|
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2955
3022
|
if (result.success && result.consumed.length < 1) {
|
|
2956
|
-
const newStateArray =
|
|
3023
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2957
3024
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2958
3025
|
currentContext = {
|
|
2959
3026
|
...currentContext,
|
|
@@ -2999,7 +3066,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2999
3066
|
const resultOrPromise = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3000
3067
|
const result = await resultOrPromise;
|
|
3001
3068
|
if (result.success && result.consumed.length > 0) {
|
|
3002
|
-
const newStateArray =
|
|
3069
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3003
3070
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3004
3071
|
currentContext = {
|
|
3005
3072
|
...currentContext,
|
|
@@ -3021,7 +3088,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3021
3088
|
const resultOrPromise = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3022
3089
|
const result = await resultOrPromise;
|
|
3023
3090
|
if (result.success && result.consumed.length < 1) {
|
|
3024
|
-
const newStateArray =
|
|
3091
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3025
3092
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
3026
3093
|
currentContext = {
|
|
3027
3094
|
...currentContext,
|
|
@@ -3299,7 +3366,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3299
3366
|
configurable: true,
|
|
3300
3367
|
enumerable: false
|
|
3301
3368
|
});
|
|
3302
|
-
|
|
3369
|
+
require_internal_parser.defineInheritedAnnotationParser(tupleParser);
|
|
3303
3370
|
return tupleParser;
|
|
3304
3371
|
}
|
|
3305
3372
|
function seq(...rawArgs) {
|
|
@@ -3627,7 +3694,7 @@ function seq(...rawArgs) {
|
|
|
3627
3694
|
configurable: true,
|
|
3628
3695
|
enumerable: false
|
|
3629
3696
|
});
|
|
3630
|
-
|
|
3697
|
+
require_internal_parser.defineInheritedAnnotationParser(seqParser);
|
|
3631
3698
|
return seqParser;
|
|
3632
3699
|
}
|
|
3633
3700
|
function merge(...args) {
|
|
@@ -3651,6 +3718,7 @@ function merge(...args) {
|
|
|
3651
3718
|
const syncSorted = syncWithIndex.toSorted(([a], [b]) => b.priority - a.priority);
|
|
3652
3719
|
const syncParsers = syncSorted.map(([p]) => p);
|
|
3653
3720
|
if (!options.allowDuplicates) checkDuplicateOptionNames(sorted.map(([parser, originalIndex]) => [String(originalIndex), parser.usage]));
|
|
3721
|
+
checkDuplicateReachableLeadingCommandNames(sorted.map(([parser, originalIndex]) => [String(originalIndex), parser]));
|
|
3654
3722
|
const mergedFieldParsers = collectChildFieldParsers(parsers);
|
|
3655
3723
|
const duplicateOutputFieldNames = collectDuplicateFieldNames(mergedFieldParsers);
|
|
3656
3724
|
const parserStateKey = (index) => `__parser_${index}`;
|
|
@@ -3826,8 +3894,8 @@ function merge(...args) {
|
|
|
3826
3894
|
if (resolvedState && typeof resolvedState === "object") {
|
|
3827
3895
|
const extractedState = {};
|
|
3828
3896
|
for (const field in parser.initialState) extractedState[field] = field in resolvedState ? resolvedState[field] : parser.initialState[field];
|
|
3829
|
-
const annotations =
|
|
3830
|
-
if (annotations !== void 0) return
|
|
3897
|
+
const annotations = require_internal_annotations.getAnnotations(resolvedState);
|
|
3898
|
+
if (annotations !== void 0) return require_internal_annotations.inheritAnnotations(resolvedState, extractedState);
|
|
3831
3899
|
return extractedState;
|
|
3832
3900
|
}
|
|
3833
3901
|
return parser.initialState;
|
|
@@ -3980,7 +4048,7 @@ function merge(...args) {
|
|
|
3980
4048
|
if (resolvedState && typeof resolvedState === "object") {
|
|
3981
4049
|
const extractedState = {};
|
|
3982
4050
|
for (const field in parser.initialState) extractedState[field] = field in resolvedState ? resolvedState[field] : parser.initialState[field];
|
|
3983
|
-
return
|
|
4051
|
+
return require_internal_annotations.inheritAnnotations(resolvedState, extractedState);
|
|
3984
4052
|
}
|
|
3985
4053
|
return parser.initialState;
|
|
3986
4054
|
}
|
|
@@ -4277,7 +4345,7 @@ function merge(...args) {
|
|
|
4277
4345
|
};
|
|
4278
4346
|
}
|
|
4279
4347
|
};
|
|
4280
|
-
|
|
4348
|
+
require_internal_parser.defineInheritedAnnotationParser(mergeParser);
|
|
4281
4349
|
return mergeParser;
|
|
4282
4350
|
}
|
|
4283
4351
|
/**
|
|
@@ -4413,7 +4481,7 @@ async function seedSuggestRuntimeFromFieldParsersAsync(parser, state, runtime, p
|
|
|
4413
4481
|
*/
|
|
4414
4482
|
function preParseSuggestContext(context, parsers) {
|
|
4415
4483
|
if (context.buffer.length < 1 || !Array.isArray(context.state)) return context;
|
|
4416
|
-
return preParseSuggestLoop(context,
|
|
4484
|
+
return preParseSuggestLoop(context, require_internal_annotations.annotateFreshArray(context.state, context.state.slice()), parsers);
|
|
4417
4485
|
}
|
|
4418
4486
|
/**
|
|
4419
4487
|
* Async variant of {@link preParseSuggestContext} that awaits async child
|
|
@@ -4422,7 +4490,7 @@ function preParseSuggestContext(context, parsers) {
|
|
|
4422
4490
|
*/
|
|
4423
4491
|
async function preParseSuggestContextAsync(context, parsers) {
|
|
4424
4492
|
if (context.buffer.length < 1 || !Array.isArray(context.state)) return context;
|
|
4425
|
-
return await preParseSuggestLoop(context,
|
|
4493
|
+
return await preParseSuggestLoop(context, require_internal_annotations.annotateFreshArray(context.state, context.state.slice()), parsers);
|
|
4426
4494
|
}
|
|
4427
4495
|
/**
|
|
4428
4496
|
* Shared loop for sync and async concat suggest pre-parse. When a child
|
|
@@ -4529,7 +4597,7 @@ function concat(...parsers) {
|
|
|
4529
4597
|
for (const [parser, index] of remainingParsers) {
|
|
4530
4598
|
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
4531
4599
|
if (result.success && result.consumed.length > 0) {
|
|
4532
|
-
const newStateArray =
|
|
4600
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
4533
4601
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
4534
4602
|
currentContext = {
|
|
4535
4603
|
...currentContext,
|
|
@@ -4550,7 +4618,7 @@ function concat(...parsers) {
|
|
|
4550
4618
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
4551
4619
|
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
4552
4620
|
if (result.success && result.consumed.length < 1) {
|
|
4553
|
-
const newStateArray =
|
|
4621
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
4554
4622
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
4555
4623
|
currentContext = {
|
|
4556
4624
|
...currentContext,
|
|
@@ -4595,7 +4663,7 @@ function concat(...parsers) {
|
|
|
4595
4663
|
for (const [parser, index] of remainingParsers) {
|
|
4596
4664
|
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
4597
4665
|
if (result.success && result.consumed.length > 0) {
|
|
4598
|
-
const newStateArray =
|
|
4666
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
4599
4667
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
4600
4668
|
currentContext = {
|
|
4601
4669
|
...currentContext,
|
|
@@ -4616,7 +4684,7 @@ function concat(...parsers) {
|
|
|
4616
4684
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
4617
4685
|
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
4618
4686
|
if (result.success && result.consumed.length < 1) {
|
|
4619
|
-
const newStateArray =
|
|
4687
|
+
const newStateArray = require_internal_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
4620
4688
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
4621
4689
|
currentContext = {
|
|
4622
4690
|
...currentContext,
|
|
@@ -4891,7 +4959,7 @@ function concat(...parsers) {
|
|
|
4891
4959
|
return { fragments: result };
|
|
4892
4960
|
}
|
|
4893
4961
|
};
|
|
4894
|
-
|
|
4962
|
+
require_internal_parser.defineInheritedAnnotationParser(concatParser);
|
|
4895
4963
|
return concatParser;
|
|
4896
4964
|
}
|
|
4897
4965
|
function group(label, parser, options = {}) {
|
|
@@ -5951,7 +6019,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5951
6019
|
return { fragments };
|
|
5952
6020
|
}
|
|
5953
6021
|
};
|
|
5954
|
-
|
|
6022
|
+
require_internal_parser.defineInheritedAnnotationParser(conditionalParser);
|
|
5955
6023
|
return conditionalParser;
|
|
5956
6024
|
}
|
|
5957
6025
|
|