@optique/core 1.0.0-dev.1903 → 1.0.0-dev.1970
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 +66 -31
- package/dist/annotation-state.d.cts +24 -0
- package/dist/annotation-state.d.ts +24 -0
- package/dist/annotation-state.js +65 -31
- package/dist/annotations.cjs +2 -267
- package/dist/annotations.d.cts +2 -152
- package/dist/annotations.d.ts +2 -152
- package/dist/annotations.js +2 -256
- package/dist/completion.d.cts +1 -1
- package/dist/completion.d.ts +1 -1
- package/dist/constructs.cjs +206 -238
- package/dist/constructs.d.cts +1 -1
- package/dist/constructs.d.ts +1 -1
- package/dist/constructs.js +96 -128
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/dependency-metadata.cjs +1 -1
- package/dist/dependency-metadata.d.cts +1 -1
- package/dist/dependency-metadata.d.ts +1 -1
- package/dist/dependency-metadata.js +1 -1
- package/dist/dependency-runtime.cjs +2 -2
- package/dist/dependency-runtime.js +2 -2
- package/dist/dependency.cjs +7 -1111
- package/dist/dependency.d.cts +2 -838
- package/dist/dependency.d.ts +2 -838
- package/dist/dependency.js +2 -1078
- package/dist/execution-context.cjs +56 -0
- package/dist/execution-context.js +53 -0
- package/dist/extension.cjs +87 -0
- package/dist/extension.d.cts +97 -0
- package/dist/extension.d.ts +97 -0
- package/dist/extension.js +76 -0
- package/dist/facade.cjs +19 -19
- package/dist/facade.d.cts +1 -1
- package/dist/facade.d.ts +1 -1
- package/dist/facade.js +19 -19
- package/dist/index.cjs +4 -41
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/internal/annotations.cjs +316 -0
- package/dist/internal/annotations.d.cts +140 -0
- package/dist/internal/annotations.d.ts +140 -0
- package/dist/internal/annotations.js +306 -0
- package/dist/internal/dependency.cjs +984 -0
- package/dist/internal/dependency.d.cts +539 -0
- package/dist/internal/dependency.d.ts +539 -0
- package/dist/internal/dependency.js +964 -0
- package/dist/{mode-dispatch.cjs → internal/mode-dispatch.cjs} +1 -3
- package/dist/{mode-dispatch.d.cts → internal/mode-dispatch.d.cts} +3 -7
- package/dist/{mode-dispatch.d.ts → internal/mode-dispatch.d.ts} +3 -7
- package/dist/{mode-dispatch.js → internal/mode-dispatch.js} +1 -3
- package/dist/internal/parser.cjs +728 -0
- package/dist/internal/parser.d.cts +947 -0
- package/dist/internal/parser.d.ts +947 -0
- package/dist/internal/parser.js +711 -0
- package/dist/modifiers.cjs +67 -95
- package/dist/modifiers.d.cts +1 -1
- package/dist/modifiers.d.ts +1 -1
- package/dist/modifiers.js +51 -79
- package/dist/parser.cjs +11 -743
- package/dist/parser.d.cts +3 -991
- package/dist/parser.d.ts +3 -991
- package/dist/parser.js +2 -704
- package/dist/phase2-seed.cjs +4 -4
- package/dist/phase2-seed.js +4 -4
- package/dist/primitives.cjs +39 -74
- package/dist/primitives.d.cts +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.js +26 -61
- package/dist/program.d.cts +1 -1
- package/dist/program.d.ts +1 -1
- package/dist/valueparser.cjs +23 -23
- package/dist/valueparser.d.cts +3 -3
- package/dist/valueparser.d.ts +3 -3
- package/dist/valueparser.js +23 -23
- package/package.json +9 -9
package/dist/constructs.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { annotateFreshArray, getAnnotations, inheritAnnotations } from "./annotations.js";
|
|
1
|
+
import { annotateFreshArray, getAnnotations, inheritAnnotations } from "./internal/annotations.js";
|
|
2
2
|
import { message, optionName, text, values } from "./message.js";
|
|
3
3
|
import { validateLabel } from "./validate.js";
|
|
4
4
|
import { extractArgumentMetavars, extractCommandNames, extractOptionNames, isDocHidden, mergeHidden } from "./usage.js";
|
|
5
5
|
import { deduplicateDocFragments } from "./doc.js";
|
|
6
|
-
import { dispatchByMode, dispatchIterableByMode } from "./mode-dispatch.js";
|
|
7
|
-
import { createDependencySourceState, dependencyId, isDependencySourceState, isPendingDependencySourceState, isWrappedDependencySource, wrappedDependencySourceMarker } from "./dependency.js";
|
|
6
|
+
import { dispatchByMode, dispatchIterableByMode } from "./internal/mode-dispatch.js";
|
|
7
|
+
import { createDependencySourceState, dependencyId, isDependencySourceState, isPendingDependencySourceState, isWrappedDependencySource, wrappedDependencySourceMarker } from "./internal/dependency.js";
|
|
8
8
|
import { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, createDependencyRuntimeContext, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync } from "./dependency-runtime.js";
|
|
9
|
+
import { defineInheritedAnnotationParser, getParserSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
10
|
+
import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, reconcileObjectChildState, unwrapAnnotationView } from "./annotation-state.js";
|
|
11
|
+
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
9
12
|
import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, phase2SeedFromValueResult } from "./phase2-seed.js";
|
|
10
13
|
import { DEFAULT_FIND_SIMILAR_OPTIONS, createErrorWithSuggestions, createSuggestionMessage, deduplicateSuggestions, findSimilar } from "./suggestion.js";
|
|
11
14
|
import { collectLeadingCandidates } from "./usage-internals.js";
|
|
12
|
-
import { defineInheritedAnnotationParser, getParserSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
|
|
13
|
-
import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, reconcileObjectChildState, unwrapAnnotationView } from "./annotation-state.js";
|
|
14
15
|
|
|
15
16
|
//#region src/constructs.ts
|
|
16
17
|
/**
|
|
@@ -21,13 +22,6 @@ const EMPTY_LEADING_NAMES = /* @__PURE__ */ new Set();
|
|
|
21
22
|
function isNonCliBoundSourceState(state, parser) {
|
|
22
23
|
return parser[unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object" && Object.hasOwn(state, "hasCliValue") && state.hasCliValue === false;
|
|
23
24
|
}
|
|
24
|
-
function withChildExecPath(exec, segment) {
|
|
25
|
-
if (exec == null) return void 0;
|
|
26
|
-
return {
|
|
27
|
-
...exec,
|
|
28
|
-
path: [...exec.path ?? [], segment]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
25
|
function withDependencyRuntimeExec(usage, exec, runtime) {
|
|
32
26
|
if (exec == null) return {
|
|
33
27
|
usage,
|
|
@@ -43,35 +37,9 @@ function withDependencyRuntimeExec(usage, exec, runtime) {
|
|
|
43
37
|
dependencyRegistry: runtime.registry
|
|
44
38
|
};
|
|
45
39
|
}
|
|
46
|
-
function
|
|
47
|
-
if (parent == null) return child;
|
|
48
|
-
if (child == null) return parent;
|
|
49
|
-
return {
|
|
50
|
-
...parent,
|
|
51
|
-
trace: child.trace ?? parent.trace,
|
|
52
|
-
dependencyRuntime: child.dependencyRuntime ?? parent.dependencyRuntime,
|
|
53
|
-
dependencyRegistry: child.dependencyRegistry ?? parent.dependencyRegistry,
|
|
54
|
-
commandPath: child.commandPath ?? parent.commandPath,
|
|
55
|
-
preCompletedByParser: child.preCompletedByParser ?? parent.preCompletedByParser,
|
|
56
|
-
excludedSourceFields: child.excludedSourceFields ?? parent.excludedSourceFields
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function withChildContext(context, segment, state, parser, usage) {
|
|
60
|
-
const exec = withChildExecPath(context.exec, segment);
|
|
61
|
-
const dependencyRegistry = context.dependencyRegistry ?? exec?.dependencyRegistry;
|
|
40
|
+
function withChildContext$1(context, segment, state, parser, usage) {
|
|
62
41
|
const childState = parser == null ? state : getWrappedChildParseState(context.state, state, parser);
|
|
63
|
-
return
|
|
64
|
-
...context,
|
|
65
|
-
state: childState,
|
|
66
|
-
...usage != null ? { usage } : {},
|
|
67
|
-
...exec != null ? {
|
|
68
|
-
exec: dependencyRegistry === exec.dependencyRegistry ? exec : {
|
|
69
|
-
...exec,
|
|
70
|
-
dependencyRegistry
|
|
71
|
-
},
|
|
72
|
-
dependencyRegistry
|
|
73
|
-
} : {}
|
|
74
|
-
};
|
|
42
|
+
return withChildContext(context, segment, childState, usage);
|
|
75
43
|
}
|
|
76
44
|
function isUnmatchedDependencyState(state, parser) {
|
|
77
45
|
if (state === void 0) return true;
|
|
@@ -451,7 +419,7 @@ function assertParsers(parsers, callerName) {
|
|
|
451
419
|
for (let i = 0; i < parsers.length; i++) {
|
|
452
420
|
const p = parsers[i];
|
|
453
421
|
const r = p;
|
|
454
|
-
if (p == null || typeof p !== "object" && typeof p !== "function" || !(r
|
|
422
|
+
if (p == null || typeof p !== "object" && typeof p !== "function" || !(r.mode === "sync" || r.mode === "async") || !Array.isArray(r.usage) || typeof r.priority !== "number" || Number.isNaN(r.priority) || !("initialState" in p) || typeof r.parse !== "function" || typeof r.complete !== "function" || typeof r.suggest !== "function" || typeof r.getDocFragments !== "function") throw new TypeError(`${callerName} argument at index ${i} is not a valid Parser.`);
|
|
455
423
|
}
|
|
456
424
|
}
|
|
457
425
|
/**
|
|
@@ -568,7 +536,7 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
568
536
|
};
|
|
569
537
|
}, async () => {
|
|
570
538
|
const candidate = await findExclusiveZeroInputCandidateAsync(parsers, state, exec);
|
|
571
|
-
if (candidate != null && (parsers[candidate.index]
|
|
539
|
+
if (candidate != null && (parsers[candidate.index].mode === "sync" || exec?.phase !== "parse" && exec?.phase !== "suggest")) {
|
|
572
540
|
const p = parsers[candidate.index];
|
|
573
541
|
const annotatedState = getWrappedChildState(state, candidate.parseResult.next.state, p);
|
|
574
542
|
return await p.complete(annotatedState, withChildExecPath(exec, candidate.index));
|
|
@@ -601,14 +569,14 @@ function createExclusiveSuggest(parsers, mode) {
|
|
|
601
569
|
const activeState = normalizeExclusiveState(context.state);
|
|
602
570
|
if (activeState == null || activeState[1].success && activeState[1].consumed.length === 0) for (let i = 0; i < syncParsers.length; i++) {
|
|
603
571
|
const parser = syncParsers[i];
|
|
604
|
-
const parserSuggestions = parser.suggest(withChildContext(context, i, parser.initialState, parser), prefix);
|
|
572
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, i, parser.initialState, parser), prefix);
|
|
605
573
|
suggestions.push(...parserSuggestions);
|
|
606
574
|
}
|
|
607
575
|
else {
|
|
608
576
|
const [index, parserResult] = activeState;
|
|
609
577
|
if (parserResult.success) {
|
|
610
578
|
const parser = syncParsers[index];
|
|
611
|
-
const parserSuggestions = parser.suggest(withChildContext(context, index, parserResult.next.state, parser), prefix);
|
|
579
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, index, parserResult.next.state, parser), prefix);
|
|
612
580
|
suggestions.push(...parserSuggestions);
|
|
613
581
|
}
|
|
614
582
|
}
|
|
@@ -618,16 +586,16 @@ function createExclusiveSuggest(parsers, mode) {
|
|
|
618
586
|
const activeState = normalizeExclusiveState(context.state);
|
|
619
587
|
if (activeState == null || activeState[1].success && activeState[1].consumed.length === 0) for (let i = 0; i < parsers.length; i++) {
|
|
620
588
|
const parser = parsers[i];
|
|
621
|
-
const parserSuggestions = parser.suggest(withChildContext(context, i, parser.initialState, parser), prefix);
|
|
622
|
-
if (parser
|
|
589
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, i, parser.initialState, parser), prefix);
|
|
590
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
623
591
|
else suggestions.push(...parserSuggestions);
|
|
624
592
|
}
|
|
625
593
|
else {
|
|
626
594
|
const [index, parserResult] = activeState;
|
|
627
595
|
if (parserResult.success) {
|
|
628
596
|
const parser = parsers[index];
|
|
629
|
-
const parserSuggestions = parser.suggest(withChildContext(context, index, parserResult.next.state, parser), prefix);
|
|
630
|
-
if (parser
|
|
597
|
+
const parserSuggestions = parser.suggest(withChildContext$1(context, index, parserResult.next.state, parser), prefix);
|
|
598
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
631
599
|
else suggestions.push(...parserSuggestions);
|
|
632
600
|
}
|
|
633
601
|
}
|
|
@@ -765,7 +733,7 @@ function or(...args) {
|
|
|
765
733
|
if (parsers.length < 1) throw new TypeError("or() requires at least one parser argument.");
|
|
766
734
|
assertParsers(parsers, "or()");
|
|
767
735
|
const noMatchContext = analyzeNoMatchContext(parsers);
|
|
768
|
-
const combinedMode = parsers.some((p) => p
|
|
736
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
769
737
|
const syncParsers = parsers;
|
|
770
738
|
const getInitialError = (context) => ({
|
|
771
739
|
consumed: 0,
|
|
@@ -786,7 +754,7 @@ function or(...args) {
|
|
|
786
754
|
let provisionalConsuming = null;
|
|
787
755
|
let provisionalAmbiguous = false;
|
|
788
756
|
for (const [parser, i] of orderedParsers) {
|
|
789
|
-
const result = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
757
|
+
const result = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
790
758
|
if (result.success && result.consumed.length > 0) {
|
|
791
759
|
if (result.provisional) {
|
|
792
760
|
const activeBranchLocked = activeState != null && activeState[1].success && activeState[1].consumed.length > 0;
|
|
@@ -830,7 +798,7 @@ function or(...args) {
|
|
|
830
798
|
}
|
|
831
799
|
const previouslyConsumed = activeState[1].consumed;
|
|
832
800
|
const checkResult = parser.parse({
|
|
833
|
-
...withChildContext(context, i, parser.initialState, parser),
|
|
801
|
+
...withChildContext$1(context, i, parser.initialState, parser),
|
|
834
802
|
buffer: previouslyConsumed
|
|
835
803
|
});
|
|
836
804
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
@@ -840,7 +808,7 @@ function or(...args) {
|
|
|
840
808
|
error: message`${values(activeState[1].consumed)} and ${values(result.consumed)} cannot be used together.`
|
|
841
809
|
};
|
|
842
810
|
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
843
|
-
const replayedResult = parser.parse(withChildContext({
|
|
811
|
+
const replayedResult = parser.parse(withChildContext$1({
|
|
844
812
|
...context,
|
|
845
813
|
...replayExec != null ? {
|
|
846
814
|
exec: replayExec,
|
|
@@ -930,13 +898,13 @@ function or(...args) {
|
|
|
930
898
|
if (activeState != null && activeState[1].success) {
|
|
931
899
|
const previouslyConsumed = activeState[1].consumed;
|
|
932
900
|
const checkResult = provisionalConsuming.parser.parse({
|
|
933
|
-
...withChildContext(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
901
|
+
...withChildContext$1(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
934
902
|
buffer: previouslyConsumed
|
|
935
903
|
});
|
|
936
904
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
937
905
|
if (canConsumeShared && checkResult.success) {
|
|
938
906
|
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
939
|
-
const replayedResult = provisionalConsuming.parser.parse(withChildContext({
|
|
907
|
+
const replayedResult = provisionalConsuming.parser.parse(withChildContext$1({
|
|
940
908
|
...context,
|
|
941
909
|
...replayExec != null ? {
|
|
942
910
|
exec: replayExec,
|
|
@@ -982,7 +950,7 @@ function or(...args) {
|
|
|
982
950
|
let provisionalConsuming = null;
|
|
983
951
|
let provisionalAmbiguous = false;
|
|
984
952
|
for (const [parser, i] of orderedParsers) {
|
|
985
|
-
const resultOrPromise = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
953
|
+
const resultOrPromise = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
986
954
|
const result = await resultOrPromise;
|
|
987
955
|
if (result.success && result.consumed.length > 0) {
|
|
988
956
|
if (result.provisional) {
|
|
@@ -1027,7 +995,7 @@ function or(...args) {
|
|
|
1027
995
|
}
|
|
1028
996
|
const previouslyConsumed = activeState[1].consumed;
|
|
1029
997
|
const checkResultOrPromise = parser.parse({
|
|
1030
|
-
...withChildContext(context, i, parser.initialState, parser),
|
|
998
|
+
...withChildContext$1(context, i, parser.initialState, parser),
|
|
1031
999
|
buffer: previouslyConsumed
|
|
1032
1000
|
});
|
|
1033
1001
|
const checkResult = await checkResultOrPromise;
|
|
@@ -1038,7 +1006,7 @@ function or(...args) {
|
|
|
1038
1006
|
error: message`${values(activeState[1].consumed)} and ${values(result.consumed)} cannot be used together.`
|
|
1039
1007
|
};
|
|
1040
1008
|
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
1041
|
-
const replayedResultOrPromise = parser.parse(withChildContext({
|
|
1009
|
+
const replayedResultOrPromise = parser.parse(withChildContext$1({
|
|
1042
1010
|
...context,
|
|
1043
1011
|
...replayExec != null ? {
|
|
1044
1012
|
exec: replayExec,
|
|
@@ -1129,13 +1097,13 @@ function or(...args) {
|
|
|
1129
1097
|
if (activeState != null && activeState[1].success) {
|
|
1130
1098
|
const previouslyConsumed = activeState[1].consumed;
|
|
1131
1099
|
const checkResult = await provisionalConsuming.parser.parse({
|
|
1132
|
-
...withChildContext(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1100
|
+
...withChildContext$1(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1133
1101
|
buffer: previouslyConsumed
|
|
1134
1102
|
});
|
|
1135
1103
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
1136
1104
|
if (canConsumeShared && checkResult.success) {
|
|
1137
1105
|
const replayExec = mergeChildExec(context.exec, checkResult.next.exec);
|
|
1138
|
-
const replayedResult = await provisionalConsuming.parser.parse(withChildContext({
|
|
1106
|
+
const replayedResult = await provisionalConsuming.parser.parse(withChildContext$1({
|
|
1139
1107
|
...context,
|
|
1140
1108
|
...replayExec != null ? {
|
|
1141
1109
|
exec: replayExec,
|
|
@@ -1172,7 +1140,7 @@ function or(...args) {
|
|
|
1172
1140
|
};
|
|
1173
1141
|
};
|
|
1174
1142
|
const singleResult = {
|
|
1175
|
-
|
|
1143
|
+
mode: combinedMode,
|
|
1176
1144
|
$valueType: [],
|
|
1177
1145
|
$stateType: [],
|
|
1178
1146
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
@@ -1242,7 +1210,7 @@ function longestMatch(...args) {
|
|
|
1242
1210
|
if (parsers.length < 1) throw new TypeError("longestMatch() requires at least one parser argument.");
|
|
1243
1211
|
assertParsers(parsers, "longestMatch()");
|
|
1244
1212
|
const noMatchContext = analyzeNoMatchContext(parsers);
|
|
1245
|
-
const combinedMode = parsers.some((p) => p
|
|
1213
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
1246
1214
|
const syncParsers = parsers;
|
|
1247
1215
|
const getInitialError = (context) => ({
|
|
1248
1216
|
consumed: 0,
|
|
@@ -1259,7 +1227,7 @@ function longestMatch(...args) {
|
|
|
1259
1227
|
const activeState = normalizeExclusiveState(context.state);
|
|
1260
1228
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
1261
1229
|
const parser = syncParsers[i];
|
|
1262
|
-
const result = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1230
|
+
const result = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1263
1231
|
if (result.success) {
|
|
1264
1232
|
const consumed = context.buffer.length - result.next.buffer.length;
|
|
1265
1233
|
const bestIsProvisional = bestMatch != null && bestMatch.result.success && !!bestMatch.result.provisional;
|
|
@@ -1299,7 +1267,7 @@ function longestMatch(...args) {
|
|
|
1299
1267
|
const activeState = normalizeExclusiveState(context.state);
|
|
1300
1268
|
for (let i = 0; i < parsers.length; i++) {
|
|
1301
1269
|
const parser = parsers[i];
|
|
1302
|
-
const resultOrPromise = parser.parse(withChildContext(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1270
|
+
const resultOrPromise = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1303
1271
|
const result = await resultOrPromise;
|
|
1304
1272
|
if (result.success) {
|
|
1305
1273
|
const consumed = context.buffer.length - result.next.buffer.length;
|
|
@@ -1335,7 +1303,7 @@ function longestMatch(...args) {
|
|
|
1335
1303
|
};
|
|
1336
1304
|
};
|
|
1337
1305
|
const multiResult = {
|
|
1338
|
-
|
|
1306
|
+
mode: combinedMode,
|
|
1339
1307
|
$valueType: [],
|
|
1340
1308
|
$stateType: [],
|
|
1341
1309
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
@@ -1420,14 +1388,14 @@ function* suggestObjectSync(context, prefix, parserPairs) {
|
|
|
1420
1388
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
1421
1389
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
1422
1390
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1423
|
-
yield* parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1391
|
+
yield* parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1424
1392
|
return;
|
|
1425
1393
|
}
|
|
1426
1394
|
}
|
|
1427
1395
|
const suggestions = [];
|
|
1428
1396
|
for (const [field, parser] of parserPairs) {
|
|
1429
1397
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1430
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1398
|
+
const fieldSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1431
1399
|
suggestions.push(...fieldSuggestions);
|
|
1432
1400
|
}
|
|
1433
1401
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -1456,7 +1424,7 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1456
1424
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
1457
1425
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
1458
1426
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1459
|
-
const suggestions$1 = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1427
|
+
const suggestions$1 = parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1460
1428
|
for await (const s of suggestions$1) yield s;
|
|
1461
1429
|
return;
|
|
1462
1430
|
}
|
|
@@ -1464,7 +1432,7 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1464
1432
|
const suggestions = [];
|
|
1465
1433
|
for (const [field, parser] of parserPairs) {
|
|
1466
1434
|
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1467
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1435
|
+
const fieldSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1468
1436
|
for await (const s of fieldSuggestions) suggestions.push(s);
|
|
1469
1437
|
}
|
|
1470
1438
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -1787,7 +1755,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1787
1755
|
};
|
|
1788
1756
|
if (!options.allowDuplicates) checkDuplicateOptionNames(parserPairs.map(([field, parser]) => [field, parser.usage]));
|
|
1789
1757
|
const noMatchContext = analyzeNoMatchContext(parserKeys.map((k) => parsers[k]));
|
|
1790
|
-
const combinedMode = parserKeys.some((k) => parsers[k]
|
|
1758
|
+
const combinedMode = parserKeys.some((k) => parsers[k].mode === "async") ? "async" : "sync";
|
|
1791
1759
|
const getInitialError = (context) => ({
|
|
1792
1760
|
consumed: 0,
|
|
1793
1761
|
error: context.buffer.length > 0 ? (() => {
|
|
@@ -1812,7 +1780,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1812
1780
|
madeProgress = false;
|
|
1813
1781
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
1814
1782
|
for (const [field, parser] of parserPairs) {
|
|
1815
|
-
const result = parser.parse(withChildContext(currentContext, field, getFieldState(field, parser), parser));
|
|
1783
|
+
const result = parser.parse(withChildContext$1(currentContext, field, getFieldState(field, parser), parser));
|
|
1816
1784
|
if (result.success && result.consumed.length > 0) {
|
|
1817
1785
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
1818
1786
|
currentContext = {
|
|
@@ -1844,7 +1812,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1844
1812
|
const typedParser = parser;
|
|
1845
1813
|
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken) continue;
|
|
1846
1814
|
const fieldState = getFieldState(field, parser);
|
|
1847
|
-
const result = typedParser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1815
|
+
const result = typedParser.parse(withChildContext$1(currentContext, field, fieldState, parser));
|
|
1848
1816
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
1849
1817
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
1850
1818
|
currentContext = {
|
|
@@ -1909,7 +1877,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1909
1877
|
madeProgress = false;
|
|
1910
1878
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
1911
1879
|
for (const [field, parser] of parserPairs) {
|
|
1912
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, field, getFieldState(field, parser), parser));
|
|
1880
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, field, getFieldState(field, parser), parser));
|
|
1913
1881
|
const result = await resultOrPromise;
|
|
1914
1882
|
if (result.success && result.consumed.length > 0) {
|
|
1915
1883
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -1941,7 +1909,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1941
1909
|
if (consumedFields.has(field)) continue;
|
|
1942
1910
|
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
1943
1911
|
const fieldState = getFieldState(field, parser);
|
|
1944
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1912
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, field, fieldState, parser));
|
|
1945
1913
|
const result = await resultOrPromise;
|
|
1946
1914
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
1947
1915
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -1997,7 +1965,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1997
1965
|
};
|
|
1998
1966
|
};
|
|
1999
1967
|
const objectParser = {
|
|
2000
|
-
|
|
1968
|
+
mode: combinedMode,
|
|
2001
1969
|
$valueType: [],
|
|
2002
1970
|
$stateType: [],
|
|
2003
1971
|
[fieldParsersKey]: parserPairs,
|
|
@@ -2326,7 +2294,7 @@ function suggestTupleSync(context, prefix, parsers) {
|
|
|
2326
2294
|
for (let i = 0; i < parsers.length; i++) {
|
|
2327
2295
|
const parser = parsers[i];
|
|
2328
2296
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[i] : parser.initialState;
|
|
2329
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry, i, parserState, parser), prefix);
|
|
2297
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, i, parserState, parser), prefix);
|
|
2330
2298
|
suggestions.push(...parserSuggestions);
|
|
2331
2299
|
}
|
|
2332
2300
|
return deduplicateSuggestions(suggestions);
|
|
@@ -2360,8 +2328,8 @@ async function* suggestTupleAsync(context, prefix, parsers) {
|
|
|
2360
2328
|
for (let i = 0; i < parsers.length; i++) {
|
|
2361
2329
|
const parser = parsers[i];
|
|
2362
2330
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[i] : parser.initialState;
|
|
2363
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry, i, parserState, parser), prefix);
|
|
2364
|
-
if (parser
|
|
2331
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, i, parserState, parser), prefix);
|
|
2332
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
2365
2333
|
else suggestions.push(...parserSuggestions);
|
|
2366
2334
|
}
|
|
2367
2335
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -2376,7 +2344,7 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2376
2344
|
const stateArray = Array.isArray(currentContext.state) ? [...currentContext.state] : parsers.map((parser) => parser.initialState);
|
|
2377
2345
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2378
2346
|
for (const [parser, index] of remainingParsers) {
|
|
2379
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2347
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2380
2348
|
if (result.success && result.consumed.length > 0) {
|
|
2381
2349
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2382
2350
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2401,7 +2369,7 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2401
2369
|
}
|
|
2402
2370
|
}
|
|
2403
2371
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2404
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2372
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2405
2373
|
if (result.success && result.consumed.length < 1) {
|
|
2406
2374
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2407
2375
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2442,7 +2410,7 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2442
2410
|
const stateArray = Array.isArray(currentContext.state) ? [...currentContext.state] : parsers.map((parser) => parser.initialState);
|
|
2443
2411
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2444
2412
|
for (const [parser, index] of remainingParsers) {
|
|
2445
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2413
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2446
2414
|
if (result.success && result.consumed.length > 0) {
|
|
2447
2415
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2448
2416
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2467,7 +2435,7 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2467
2435
|
}
|
|
2468
2436
|
}
|
|
2469
2437
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2470
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2438
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2471
2439
|
if (result.success && result.consumed.length < 1) {
|
|
2472
2440
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2473
2441
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2544,7 +2512,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2544
2512
|
parsers = labelOrParsers;
|
|
2545
2513
|
options = maybeParsersOrOptions ?? {};
|
|
2546
2514
|
}
|
|
2547
|
-
const combinedMode = parsers.some((p) => p
|
|
2515
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
2548
2516
|
const syncParsers = parsers;
|
|
2549
2517
|
if (!options.allowDuplicates) checkDuplicateOptionNames(parsers.map((parser, index) => [String(index), parser.usage]));
|
|
2550
2518
|
const parseSync = (context) => {
|
|
@@ -2560,7 +2528,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2560
2528
|
const stateArray = currentContext.state;
|
|
2561
2529
|
const remainingParsers = syncParsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2562
2530
|
for (const [parser, index] of remainingParsers) {
|
|
2563
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2531
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2564
2532
|
if (result.success && result.consumed.length > 0) {
|
|
2565
2533
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2566
2534
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2581,7 +2549,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2581
2549
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
2582
2550
|
}
|
|
2583
2551
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2584
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2552
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2585
2553
|
if (result.success && result.consumed.length < 1) {
|
|
2586
2554
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2587
2555
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2626,7 +2594,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2626
2594
|
const stateArray = currentContext.state;
|
|
2627
2595
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
2628
2596
|
for (const [parser, index] of remainingParsers) {
|
|
2629
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2597
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2630
2598
|
const result = await resultOrPromise;
|
|
2631
2599
|
if (result.success && result.consumed.length > 0) {
|
|
2632
2600
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
@@ -2648,7 +2616,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2648
2616
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
2649
2617
|
}
|
|
2650
2618
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2651
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2619
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
2652
2620
|
const result = await resultOrPromise;
|
|
2653
2621
|
if (result.success && result.consumed.length < 1) {
|
|
2654
2622
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
@@ -2682,7 +2650,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2682
2650
|
};
|
|
2683
2651
|
};
|
|
2684
2652
|
const tupleParser = {
|
|
2685
|
-
|
|
2653
|
+
mode: combinedMode,
|
|
2686
2654
|
$valueType: [],
|
|
2687
2655
|
$stateType: [],
|
|
2688
2656
|
[fieldParsersKey]: parsers.map((parser, index) => [String(index), parser]),
|
|
@@ -2939,7 +2907,7 @@ function merge(...args) {
|
|
|
2939
2907
|
const rawParsers = args.slice(startIndex, endIndex);
|
|
2940
2908
|
if (rawParsers.length < 1) throw new TypeError("merge() requires at least one parser argument.");
|
|
2941
2909
|
assertParsers(rawParsers, "merge()");
|
|
2942
|
-
const combinedMode = rawParsers.some((p) => p
|
|
2910
|
+
const combinedMode = rawParsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
2943
2911
|
const isAsync = combinedMode === "async";
|
|
2944
2912
|
const syncRawParsers = rawParsers;
|
|
2945
2913
|
const withIndex = rawParsers.map((p, i) => [p, i]);
|
|
@@ -3006,7 +2974,7 @@ function merge(...args) {
|
|
|
3006
2974
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
3007
2975
|
const parser = syncParsers[i];
|
|
3008
2976
|
const parserState = extractParserState(parser, currentContext, i);
|
|
3009
|
-
const result = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
2977
|
+
const result = parser.parse(withChildContext$1(currentContext, i, parserState, parser));
|
|
3010
2978
|
if (result.success) {
|
|
3011
2979
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3012
2980
|
const newState = mergeResultState(parser, currentContext, parserState, result, i);
|
|
@@ -3051,7 +3019,7 @@ function merge(...args) {
|
|
|
3051
3019
|
for (let i = 0; i < parsers.length; i++) {
|
|
3052
3020
|
const parser = parsers[i];
|
|
3053
3021
|
const parserState = extractParserState(parser, currentContext, i);
|
|
3054
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
3022
|
+
const resultOrPromise = parser.parse(withChildContext$1(currentContext, i, parserState, parser));
|
|
3055
3023
|
const result = await resultOrPromise;
|
|
3056
3024
|
if (result.success) {
|
|
3057
3025
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -3092,7 +3060,7 @@ function merge(...args) {
|
|
|
3092
3060
|
};
|
|
3093
3061
|
};
|
|
3094
3062
|
const mergeParser = {
|
|
3095
|
-
|
|
3063
|
+
mode: combinedMode,
|
|
3096
3064
|
$valueType: [],
|
|
3097
3065
|
$stateType: [],
|
|
3098
3066
|
[fieldParsersKey]: mergedFieldParsers,
|
|
@@ -3447,7 +3415,7 @@ function merge(...args) {
|
|
|
3447
3415
|
for (let i = 0; i < parsers.length; i++) {
|
|
3448
3416
|
const parser = parsers[i];
|
|
3449
3417
|
const parserState = extractState(parser, i);
|
|
3450
|
-
const childContext = withChildContext(contextWithRegistry$1, i, parserState, parser);
|
|
3418
|
+
const childContext = withChildContext$1(contextWithRegistry$1, i, parserState, parser);
|
|
3451
3419
|
const excludedSourceFields = perChildExcludedSourceFields$1[i];
|
|
3452
3420
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
3453
3421
|
const childRuntime = createDependencyRuntimeContext(runtime$1.registry.clone());
|
|
@@ -3461,7 +3429,7 @@ function merge(...args) {
|
|
|
3461
3429
|
};
|
|
3462
3430
|
})();
|
|
3463
3431
|
const parserSuggestions = parser.suggest(contextForChild, prefix);
|
|
3464
|
-
if (parser
|
|
3432
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
3465
3433
|
else suggestions.push(...parserSuggestions);
|
|
3466
3434
|
}
|
|
3467
3435
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -3488,7 +3456,7 @@ function merge(...args) {
|
|
|
3488
3456
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
3489
3457
|
const parser = syncParsers[i];
|
|
3490
3458
|
const parserState = extractState(parser, i);
|
|
3491
|
-
const childContext = withChildContext(contextWithRegistry, i, parserState, parser);
|
|
3459
|
+
const childContext = withChildContext$1(contextWithRegistry, i, parserState, parser);
|
|
3492
3460
|
const excludedSourceFields = perChildExcludedSourceFields[i];
|
|
3493
3461
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
3494
3462
|
const childRuntime = createDependencyRuntimeContext(runtime.registry.clone());
|
|
@@ -3749,7 +3717,7 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3749
3717
|
for (let ri = 0; ri < remaining.length; ri++) {
|
|
3750
3718
|
const [parser, index] = remaining[ri];
|
|
3751
3719
|
const parserState = index < stateArray.length ? stateArray[index] : parser.initialState;
|
|
3752
|
-
const resultOrPromise = parser.parse(withChildContext(context, index, parserState, parser));
|
|
3720
|
+
const resultOrPromise = parser.parse(withChildContext$1(context, index, parserState, parser));
|
|
3753
3721
|
if (resultOrPromise != null && typeof resultOrPromise === "object" && "then" in resultOrPromise && typeof resultOrPromise.then === "function") {
|
|
3754
3722
|
const tail = remaining.slice(ri + 1);
|
|
3755
3723
|
return resultOrPromise.then((result$1) => {
|
|
@@ -3801,7 +3769,7 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3801
3769
|
function concat(...parsers) {
|
|
3802
3770
|
if (parsers.length < 1) throw new TypeError("concat() requires at least one parser argument.");
|
|
3803
3771
|
assertParsers(parsers, "concat()");
|
|
3804
|
-
const combinedMode = parsers.some((p) => p
|
|
3772
|
+
const combinedMode = parsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
3805
3773
|
const isAsync = combinedMode === "async";
|
|
3806
3774
|
const syncParsers = parsers;
|
|
3807
3775
|
const initialState = parsers.map((parser) => parser.initialState);
|
|
@@ -3818,7 +3786,7 @@ function concat(...parsers) {
|
|
|
3818
3786
|
const stateArray = currentContext.state;
|
|
3819
3787
|
const remainingParsers = syncParsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
3820
3788
|
for (const [parser, index] of remainingParsers) {
|
|
3821
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3789
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3822
3790
|
if (result.success && result.consumed.length > 0) {
|
|
3823
3791
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3824
3792
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -3839,7 +3807,7 @@ function concat(...parsers) {
|
|
|
3839
3807
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
3840
3808
|
}
|
|
3841
3809
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
3842
|
-
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3810
|
+
const result = parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3843
3811
|
if (result.success && result.consumed.length < 1) {
|
|
3844
3812
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3845
3813
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -3884,7 +3852,7 @@ function concat(...parsers) {
|
|
|
3884
3852
|
const stateArray = currentContext.state;
|
|
3885
3853
|
const remainingParsers = parsers.map((parser, index) => [parser, index]).filter(([_, index]) => !matchedParsers.has(index)).sort(([parserA], [parserB]) => parserB.priority - parserA.priority);
|
|
3886
3854
|
for (const [parser, index] of remainingParsers) {
|
|
3887
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3855
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3888
3856
|
if (result.success && result.consumed.length > 0) {
|
|
3889
3857
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3890
3858
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -3905,7 +3873,7 @@ function concat(...parsers) {
|
|
|
3905
3873
|
} else if (!result.success && error.consumed < result.consumed) error = result;
|
|
3906
3874
|
}
|
|
3907
3875
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
3908
|
-
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3876
|
+
const result = await parser.parse(withChildContext$1(currentContext, index, stateArray[index], parser));
|
|
3909
3877
|
if (result.success && result.consumed.length < 1) {
|
|
3910
3878
|
const newStateArray = annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3911
3879
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -4038,7 +4006,7 @@ function concat(...parsers) {
|
|
|
4038
4006
|
};
|
|
4039
4007
|
};
|
|
4040
4008
|
const concatParser = {
|
|
4041
|
-
|
|
4009
|
+
mode: combinedMode,
|
|
4042
4010
|
$valueType: [],
|
|
4043
4011
|
$stateType: [],
|
|
4044
4012
|
priority: parsers.length > 0 ? Math.max(...parsers.map((p) => p.priority)) : 0,
|
|
@@ -4133,8 +4101,8 @@ function concat(...parsers) {
|
|
|
4133
4101
|
for (let i = 0; i < parsers.length; i++) {
|
|
4134
4102
|
const parser = parsers[i];
|
|
4135
4103
|
const parserState = stateArray$1 && Array.isArray(stateArray$1) ? stateArray$1[i] : parser.initialState;
|
|
4136
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry$1, i, parserState, parser), prefix);
|
|
4137
|
-
if (parser
|
|
4104
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry$1, i, parserState, parser), prefix);
|
|
4105
|
+
if (parser.mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
|
|
4138
4106
|
else suggestions.push(...parserSuggestions);
|
|
4139
4107
|
}
|
|
4140
4108
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -4146,7 +4114,7 @@ function concat(...parsers) {
|
|
|
4146
4114
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
4147
4115
|
const parser = syncParsers[i];
|
|
4148
4116
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[i] : parser.initialState;
|
|
4149
|
-
const parserSuggestions = parser.suggest(withChildContext(contextWithRegistry, i, parserState, parser), prefix);
|
|
4117
|
+
const parserSuggestions = parser.suggest(withChildContext$1(contextWithRegistry, i, parserState, parser), prefix);
|
|
4150
4118
|
suggestions.push(...parserSuggestions);
|
|
4151
4119
|
}
|
|
4152
4120
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -4184,7 +4152,7 @@ function concat(...parsers) {
|
|
|
4184
4152
|
function group(label, parser, options = {}) {
|
|
4185
4153
|
validateLabel(label);
|
|
4186
4154
|
const groupParser = {
|
|
4187
|
-
|
|
4155
|
+
mode: parser.mode,
|
|
4188
4156
|
$valueType: parser.$valueType,
|
|
4189
4157
|
$stateType: parser.$stateType,
|
|
4190
4158
|
priority: parser.priority,
|
|
@@ -4204,7 +4172,7 @@ function group(label, parser, options = {}) {
|
|
|
4204
4172
|
parse: (context) => parser.parse(context),
|
|
4205
4173
|
complete: (state, exec) => parser.complete(state, exec),
|
|
4206
4174
|
suggest: (context, prefix) => {
|
|
4207
|
-
if (options.hidden === true) return dispatchIterableByMode(parser
|
|
4175
|
+
if (options.hidden === true) return dispatchIterableByMode(parser.mode, function* () {}, async function* () {});
|
|
4208
4176
|
return parser.suggest(context, prefix);
|
|
4209
4177
|
},
|
|
4210
4178
|
getDocFragments: (state, defaultValue) => {
|
|
@@ -4330,7 +4298,7 @@ function group(label, parser, options = {}) {
|
|
|
4330
4298
|
function conditional(discriminator, branches, defaultBranch, options) {
|
|
4331
4299
|
const branchParsers = Object.entries(branches);
|
|
4332
4300
|
const allBranchParsers = defaultBranch ? [...branchParsers.map(([_, p]) => p), defaultBranch] : branchParsers.map(([_, p]) => p);
|
|
4333
|
-
const combinedMode = discriminator
|
|
4301
|
+
const combinedMode = discriminator.mode === "async" || allBranchParsers.some((p) => p.mode === "async") ? "async" : "sync";
|
|
4334
4302
|
const isAsync = combinedMode === "async";
|
|
4335
4303
|
const maxPriority = Math.max(discriminator.priority, ...allBranchParsers.map((p) => p.priority));
|
|
4336
4304
|
function appendLiteralToUsage(usage$1, literalValue) {
|
|
@@ -4381,7 +4349,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4381
4349
|
const syncDefaultBranch = defaultBranch;
|
|
4382
4350
|
if (state.selectedBranch !== void 0) {
|
|
4383
4351
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
4384
|
-
const branchResult = branchParser.parse(withChildContext(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4352
|
+
const branchResult = branchParser.parse(withChildContext$1(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4385
4353
|
if (branchResult.success) {
|
|
4386
4354
|
const mergedExec = mergeChildExec(context.exec, branchResult.next.exec);
|
|
4387
4355
|
return {
|
|
@@ -4402,7 +4370,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4402
4370
|
}
|
|
4403
4371
|
return branchResult;
|
|
4404
4372
|
}
|
|
4405
|
-
const discriminatorResult = syncDiscriminator.parse({ ...withChildContext(context, "_discriminator", state.discriminatorState, syncDiscriminator) });
|
|
4373
|
+
const discriminatorResult = syncDiscriminator.parse({ ...withChildContext$1(context, "_discriminator", state.discriminatorState, syncDiscriminator) });
|
|
4406
4374
|
if (discriminatorResult.success) {
|
|
4407
4375
|
const annotatedDiscriminatorState = getWrappedChildState(state, discriminatorResult.next.state, syncDiscriminator);
|
|
4408
4376
|
const completionResult = syncDiscriminator.complete(annotatedDiscriminatorState, withChildExecPath(context.exec, "_discriminator"));
|
|
@@ -4412,7 +4380,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4412
4380
|
if (branchParser) {
|
|
4413
4381
|
const discriminatorExec = mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4414
4382
|
const branchParseResult = branchParser.parse({
|
|
4415
|
-
...withChildContext({
|
|
4383
|
+
...withChildContext$1({
|
|
4416
4384
|
...context,
|
|
4417
4385
|
...discriminatorExec != null ? {
|
|
4418
4386
|
exec: discriminatorExec,
|
|
@@ -4478,7 +4446,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4478
4446
|
}
|
|
4479
4447
|
const discriminatorConsumed = discriminatorResult.success ? discriminatorResult.consumed.length : discriminatorResult.consumed;
|
|
4480
4448
|
if (syncDefaultBranch !== void 0) {
|
|
4481
|
-
const defaultResult = syncDefaultBranch.parse(withChildContext(context, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch, syncDefaultBranch.usage));
|
|
4449
|
+
const defaultResult = syncDefaultBranch.parse(withChildContext$1(context, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch, syncDefaultBranch.usage));
|
|
4482
4450
|
if (defaultResult.success && (defaultResult.consumed.length > 0 || discriminatorConsumed === 0 && context.buffer.length === 0)) {
|
|
4483
4451
|
const mergedExec = mergeChildExec(context.exec, defaultResult.next.exec);
|
|
4484
4452
|
const commitDefault = defaultResult.consumed.length > 0 || context.buffer.length === 0;
|
|
@@ -4512,7 +4480,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4512
4480
|
const state = context.state ?? initialState;
|
|
4513
4481
|
if (state.selectedBranch !== void 0) {
|
|
4514
4482
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
4515
|
-
const branchResult = await branchParser.parse(withChildContext(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4483
|
+
const branchResult = await branchParser.parse(withChildContext$1(context, "_branch", state.branchState, branchParser, branchParser.usage));
|
|
4516
4484
|
if (branchResult.success) {
|
|
4517
4485
|
const mergedExec = mergeChildExec(context.exec, branchResult.next.exec);
|
|
4518
4486
|
return {
|
|
@@ -4534,9 +4502,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4534
4502
|
}
|
|
4535
4503
|
return branchResult;
|
|
4536
4504
|
}
|
|
4537
|
-
const discriminatorResult = await discriminator.parse({ ...withChildContext(context, "_discriminator", state.discriminatorState, discriminator) });
|
|
4505
|
+
const discriminatorResult = await discriminator.parse({ ...withChildContext$1(context, "_discriminator", state.discriminatorState, discriminator) });
|
|
4538
4506
|
if (discriminatorResult.success) {
|
|
4539
|
-
if (discriminatorResult.consumed.length === 0 && discriminator
|
|
4507
|
+
if (discriminatorResult.consumed.length === 0 && discriminator.mode === "async") {
|
|
4540
4508
|
const discriminatorExec = mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4541
4509
|
const speculationContext = {
|
|
4542
4510
|
...context,
|
|
@@ -4553,7 +4521,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4553
4521
|
let speculativeError;
|
|
4554
4522
|
let ambiguous = false;
|
|
4555
4523
|
for (const [key, bp] of branchParsers) {
|
|
4556
|
-
const branchResult = await bp.parse(withChildContext(speculationContext, "_branch", bp.initialState, bp, bp.usage));
|
|
4524
|
+
const branchResult = await bp.parse(withChildContext$1(speculationContext, "_branch", bp.initialState, bp, bp.usage));
|
|
4557
4525
|
if (branchResult.success && branchResult.consumed.length > 0) {
|
|
4558
4526
|
if (branchResult.provisional) {
|
|
4559
4527
|
if (provisionalHit == null && !provisionalAmbiguous) provisionalHit = {
|
|
@@ -4612,7 +4580,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4612
4580
|
}
|
|
4613
4581
|
let deferredBranchState = state.branchState;
|
|
4614
4582
|
if (defaultBranch !== void 0 && !ambiguous && !provisionalAmbiguous) {
|
|
4615
|
-
const defaultResult = await defaultBranch.parse(withChildContext(speculationContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4583
|
+
const defaultResult = await defaultBranch.parse(withChildContext$1(speculationContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4616
4584
|
if (defaultResult.success && defaultResult.consumed.length > 0) {
|
|
4617
4585
|
const defaultExec = mergeChildExec(discriminatorExec ?? context.exec, defaultResult.next.exec);
|
|
4618
4586
|
return {
|
|
@@ -4660,7 +4628,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4660
4628
|
if (branchParser) {
|
|
4661
4629
|
const discriminatorExec = mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
4662
4630
|
const branchParseResult = await branchParser.parse({
|
|
4663
|
-
...withChildContext({
|
|
4631
|
+
...withChildContext$1({
|
|
4664
4632
|
...context,
|
|
4665
4633
|
...discriminatorExec != null ? {
|
|
4666
4634
|
exec: discriminatorExec,
|
|
@@ -4725,7 +4693,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4725
4693
|
}
|
|
4726
4694
|
const discriminatorConsumed = discriminatorResult.success ? discriminatorResult.consumed.length : discriminatorResult.consumed;
|
|
4727
4695
|
if (defaultBranch !== void 0) {
|
|
4728
|
-
const defaultResult = await defaultBranch.parse(withChildContext(context, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4696
|
+
const defaultResult = await defaultBranch.parse(withChildContext$1(context, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
4729
4697
|
if (defaultResult.success && (defaultResult.consumed.length > 0 || discriminatorConsumed === 0 && context.buffer.length === 0)) {
|
|
4730
4698
|
const mergedExec = mergeChildExec(context.exec, defaultResult.next.exec);
|
|
4731
4699
|
const commitDefault = defaultResult.consumed.length > 0 || context.buffer.length === 0;
|
|
@@ -5046,7 +5014,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5046
5014
|
dependencyRegistry: runtime.registry
|
|
5047
5015
|
} } : {}
|
|
5048
5016
|
};
|
|
5049
|
-
yield* syncDiscriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState, syncDiscriminator), prefix);
|
|
5017
|
+
yield* syncDiscriminator.suggest(withChildContext$1(suggestContext, "_discriminator", state.discriminatorState, syncDiscriminator), prefix);
|
|
5050
5018
|
const annotatedDiscState = getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
5051
5019
|
const discComplete = syncDiscriminator.complete(annotatedDiscState, withChildExecPath(suggestContext.exec ? {
|
|
5052
5020
|
...suggestContext.exec,
|
|
@@ -5054,8 +5022,8 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5054
5022
|
} : void 0, "_discriminator"));
|
|
5055
5023
|
if (discComplete.success && syncBranches[discComplete.value] !== void 0) {
|
|
5056
5024
|
const resolvedBranch = syncBranches[discComplete.value];
|
|
5057
|
-
yield* resolvedBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5058
|
-
} else if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
5025
|
+
yield* resolvedBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5026
|
+
} else if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
5059
5027
|
} else {
|
|
5060
5028
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
5061
5029
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
@@ -5075,7 +5043,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5075
5043
|
dependencyRegistry: runtime.registry
|
|
5076
5044
|
} } : {}
|
|
5077
5045
|
};
|
|
5078
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5046
|
+
yield* branchParser.suggest(withChildContext$1(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5079
5047
|
}
|
|
5080
5048
|
}
|
|
5081
5049
|
async function* suggestAsync(context, prefix) {
|
|
@@ -5098,9 +5066,9 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5098
5066
|
dependencyRegistry: runtime.registry
|
|
5099
5067
|
} } : {}
|
|
5100
5068
|
};
|
|
5101
|
-
yield* discriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState, discriminator), prefix);
|
|
5069
|
+
yield* discriminator.suggest(withChildContext$1(suggestContext, "_discriminator", state.discriminatorState, discriminator), prefix);
|
|
5102
5070
|
let discResolved = false;
|
|
5103
|
-
if (discriminator
|
|
5071
|
+
if (discriminator.mode === "sync") {
|
|
5104
5072
|
const annotatedDiscState = getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
5105
5073
|
const discComplete = discriminator.complete(annotatedDiscState, withChildExecPath(suggestContext.exec ? {
|
|
5106
5074
|
...suggestContext.exec,
|
|
@@ -5108,12 +5076,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5108
5076
|
} : void 0, "_discriminator"));
|
|
5109
5077
|
if (discComplete.success && branches[discComplete.value] !== void 0) {
|
|
5110
5078
|
const resolvedBranch = branches[discComplete.value];
|
|
5111
|
-
yield* resolvedBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5079
|
+
yield* resolvedBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
5112
5080
|
discResolved = true;
|
|
5113
5081
|
}
|
|
5114
5082
|
}
|
|
5115
5083
|
if (!discResolved) {
|
|
5116
|
-
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
5084
|
+
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext$1(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
5117
5085
|
}
|
|
5118
5086
|
} else {
|
|
5119
5087
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
@@ -5134,11 +5102,11 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5134
5102
|
dependencyRegistry: runtime.registry
|
|
5135
5103
|
} } : {}
|
|
5136
5104
|
};
|
|
5137
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5105
|
+
yield* branchParser.suggest(withChildContext$1(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
5138
5106
|
}
|
|
5139
5107
|
}
|
|
5140
5108
|
const conditionalParser = {
|
|
5141
|
-
|
|
5109
|
+
mode: combinedMode,
|
|
5142
5110
|
$valueType: [],
|
|
5143
5111
|
$stateType: [],
|
|
5144
5112
|
priority: maxPriority,
|