@optique/core 1.3.0-dev.2387 → 1.3.0-dev.2390
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/constructs.cjs +277 -59
- package/dist/constructs.js +278 -60
- package/dist/dependency-runtime.cjs +91 -11
- package/dist/dependency-runtime.d.cts +128 -7
- package/dist/dependency-runtime.d.ts +128 -7
- package/dist/dependency-runtime.js +88 -11
- package/dist/facade.cjs +2 -1
- package/dist/facade.js +2 -1
- package/dist/internal/parser.cjs +2 -1
- package/dist/internal/parser.d.cts +10 -0
- package/dist/internal/parser.d.ts +10 -0
- package/dist/internal/parser.js +2 -1
- package/dist/primitives.cjs +10 -0
- package/dist/primitives.js +11 -1
- package/package.json +2 -2
package/dist/constructs.js
CHANGED
|
@@ -5,7 +5,7 @@ import { extractArgumentMetavars, extractCommandNames, extractOptionNames, isDoc
|
|
|
5
5
|
import { deduplicateDocFragments } from "./doc.js";
|
|
6
6
|
import { dispatchByMode, dispatchIterableByMode } from "./internal/mode-dispatch.js";
|
|
7
7
|
import { createDependencySourceState, dependencyId, isDependencySourceState, isPendingDependencySourceState, isWrappedDependencySource, wrappedDependencySourceMarker } from "./internal/dependency.js";
|
|
8
|
-
import { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyRuntimeContext, effectfulSchedulingNodesKey, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync } from "./dependency-runtime.js";
|
|
8
|
+
import { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyRuntimeContext, effectfulSchedulingNodesKey, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey } from "./dependency-runtime.js";
|
|
9
9
|
import { defineInheritedAnnotationParser, defineParseLanes, getOwnParseLanes, getParserSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
10
10
|
import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, reconcileObjectChildState, unwrapAnnotationView } from "./annotation-state.js";
|
|
11
11
|
import { allowDuplicateLeadingCommandNamesKey } from "./internal/command-alias.js";
|
|
@@ -134,6 +134,54 @@ function expandEffectfulRuntimeNodes(nodes) {
|
|
|
134
134
|
for (const node of nodes) visit(node);
|
|
135
135
|
return expanded;
|
|
136
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Expands a construct's direct-child nodes for explicit source
|
|
139
|
+
* collection.
|
|
140
|
+
*
|
|
141
|
+
* A direct child that opted in through {@link sourceCollectionExpansionKey}
|
|
142
|
+
* (a `conditional()` or a `command()`, possibly behind transparent
|
|
143
|
+
* wrappers) is replaced in place by its scheduling-hook expansion, so
|
|
144
|
+
* its command-line source values—the discriminator, a committed branch,
|
|
145
|
+
* a selected command subtree—register into the parent's runtime in the
|
|
146
|
+
* child's declaration position. Every other node passes through
|
|
147
|
+
* unchanged, keeping the existing collection scope for plain nested
|
|
148
|
+
* constructs and uncommitted exclusive branches.
|
|
149
|
+
*/
|
|
150
|
+
function expandSourceCollectionNodes(nodes) {
|
|
151
|
+
let expanded;
|
|
152
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
153
|
+
const node = nodes[i];
|
|
154
|
+
const optedIn = node.parser[sourceCollectionExpansionKey] === true;
|
|
155
|
+
if (!optedIn) {
|
|
156
|
+
expanded?.push(node);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (expanded == null) expanded = nodes.slice(0, i);
|
|
160
|
+
expanded.push(...expandEffectfulRuntimeNodes([node]));
|
|
161
|
+
}
|
|
162
|
+
return expanded ?? nodes;
|
|
163
|
+
}
|
|
164
|
+
let conditionalInstanceCounter = 0;
|
|
165
|
+
/**
|
|
166
|
+
* Statically collects the dependency source IDs reachable through a
|
|
167
|
+
* parser's composed metadata and flattened field pairs. Used as the
|
|
168
|
+
* `providesSourceIds` estimate for a conditional()'s branches: an
|
|
169
|
+
* undercount only delays an effectful completion from the seed pass to
|
|
170
|
+
* the final pass of a `runWith()` run.
|
|
171
|
+
*/
|
|
172
|
+
function collectStaticSourceIds(parser, out, seen) {
|
|
173
|
+
if (seen.has(parser)) return;
|
|
174
|
+
seen.add(parser);
|
|
175
|
+
const source = parser.dependencyMetadata?.source;
|
|
176
|
+
if (source != null) {
|
|
177
|
+
out.add(source.sourceId);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const pairs = parser[fieldParsersKey];
|
|
181
|
+
if (pairs != null) for (const [, child] of pairs) collectStaticSourceIds(child, out, seen);
|
|
182
|
+
const scope = parser[staticSourceScopeKey];
|
|
183
|
+
if (scope != null) for (const child of scope) collectStaticSourceIds(child, out, seen);
|
|
184
|
+
}
|
|
137
185
|
function isDeferredCompletionResult(result) {
|
|
138
186
|
return typeof result === "object" && result !== null && "success" in result && result.success === true && "deferred" in result && result.deferred === true;
|
|
139
187
|
}
|
|
@@ -179,9 +227,19 @@ async function scheduleEffectfulSourceCompletions(nodes, state, runtime, exec, p
|
|
|
179
227
|
error: preCompletedFailure
|
|
180
228
|
};
|
|
181
229
|
const direct = new Set(nodes);
|
|
182
|
-
const
|
|
230
|
+
const collected = /* @__PURE__ */ new Set();
|
|
231
|
+
const expandedNodes = [];
|
|
232
|
+
for (const node of nodes) {
|
|
233
|
+
const optedIn = node.parser[sourceCollectionExpansionKey] === true;
|
|
234
|
+
for (const expandedNode of expandEffectfulRuntimeNodes([node])) {
|
|
235
|
+
expandedNodes.push(expandedNode);
|
|
236
|
+
if (optedIn || expandedNode === node) collected.add(expandedNode);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const effectful = await completeEffectfulSourcesAsync(expandedNodes, state, runtime, exec, {
|
|
183
240
|
...demandNodes != null ? { demandNodes: expandEffectfulRuntimeNodes(demandNodes) } : {},
|
|
184
|
-
isReusable: (node) => direct.has(node)
|
|
241
|
+
isReusable: (node) => direct.has(node),
|
|
242
|
+
isCollected: (node) => collected.has(node)
|
|
185
243
|
});
|
|
186
244
|
if (!effectful.success) return {
|
|
187
245
|
success: false,
|
|
@@ -936,6 +994,11 @@ function getNoMatchError(options, noMatchContext) {
|
|
|
936
994
|
* when the committed branch completes.
|
|
937
995
|
*/
|
|
938
996
|
function defineExclusiveSchedulingNodes(exclusiveParser, parsers) {
|
|
997
|
+
Object.defineProperty(exclusiveParser, staticSourceScopeKey, {
|
|
998
|
+
value: parsers,
|
|
999
|
+
configurable: true,
|
|
1000
|
+
enumerable: false
|
|
1001
|
+
});
|
|
939
1002
|
Object.defineProperty(exclusiveParser, effectfulSchedulingNodesKey, {
|
|
940
1003
|
value: ((state, parentPath) => {
|
|
941
1004
|
const active = normalizeExclusiveState(state);
|
|
@@ -1734,7 +1797,7 @@ function* suggestObjectSync(context, prefix, parserPairs) {
|
|
|
1734
1797
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
1735
1798
|
const sourceParserPairs = filterExcludedFieldParsers(parserPairs, context.exec?.excludedSourceFields);
|
|
1736
1799
|
const nodes = buildRuntimeNodesFromPairs(sourceParserPairs, context.state && typeof context.state === "object" ? context.state : {}, context.exec?.path);
|
|
1737
|
-
collectExplicitSourceValues(nodes, runtime);
|
|
1800
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(nodes), runtime);
|
|
1738
1801
|
if (context.state && typeof context.state === "object") collectSourcesFromState(context.state, runtime, /* @__PURE__ */ new WeakSet(), context.exec?.excludedSourceFields);
|
|
1739
1802
|
completeDependencySourceDefaults(context, sourceParserPairs, runtime.registry, context.exec);
|
|
1740
1803
|
const contextWithRegistry = {
|
|
@@ -1770,7 +1833,7 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1770
1833
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
1771
1834
|
const sourceParserPairs = filterExcludedFieldParsers(parserPairs, context.exec?.excludedSourceFields);
|
|
1772
1835
|
const nodes = buildRuntimeNodesFromPairs(sourceParserPairs, context.state && typeof context.state === "object" ? context.state : {}, context.exec?.path);
|
|
1773
|
-
await collectExplicitSourceValuesAsync(nodes, runtime);
|
|
1836
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(nodes), runtime);
|
|
1774
1837
|
if (context.state && typeof context.state === "object") collectSourcesFromState(context.state, runtime, /* @__PURE__ */ new WeakSet(), context.exec?.excludedSourceFields);
|
|
1775
1838
|
await completeDependencySourceDefaultsAsync(context, sourceParserPairs, runtime.registry, context.exec);
|
|
1776
1839
|
const contextWithRegistry = {
|
|
@@ -2431,7 +2494,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2431
2494
|
const fieldParser = parsers[field];
|
|
2432
2495
|
annotatedState[fieldKey] = getFieldState(field, fieldParser);
|
|
2433
2496
|
}
|
|
2434
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromPairs(typedParserPairs, annotatedState, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
2497
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromPairs(typedParserPairs, annotatedState, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
2435
2498
|
const resolvedFieldStates = resolveStateWithRuntime(annotatedState, runtime);
|
|
2436
2499
|
const result = {};
|
|
2437
2500
|
const deferredKeys = /* @__PURE__ */ new Map();
|
|
@@ -2486,7 +2549,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2486
2549
|
}
|
|
2487
2550
|
const allRuntimeNodes = buildRuntimeNodesFromPairs(asyncParserPairs, annotatedState, exec?.path);
|
|
2488
2551
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
2489
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
2552
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
2490
2553
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), annotatedState, runtime, childExec, preCompleted);
|
|
2491
2554
|
if (effectfulFailure != null) return effectfulFailure;
|
|
2492
2555
|
const resolvedFieldStates = await resolveStateWithRuntimeAsync(annotatedState, runtime);
|
|
@@ -2567,7 +2630,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2567
2630
|
const fieldParser = parsers[field];
|
|
2568
2631
|
annotatedState[fieldKey] = getFieldState(field, fieldParser);
|
|
2569
2632
|
}
|
|
2570
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromPairs(typedParserPairs, annotatedState, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
2633
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromPairs(typedParserPairs, annotatedState, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
2571
2634
|
const resolvedFieldStates = resolveStateWithRuntime(annotatedState, runtime);
|
|
2572
2635
|
const result = {};
|
|
2573
2636
|
const deferredKeys = /* @__PURE__ */ new Map();
|
|
@@ -2612,7 +2675,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2612
2675
|
}
|
|
2613
2676
|
const allRuntimeNodes = buildRuntimeNodesFromPairs(asyncParserPairs, annotatedState, exec?.path);
|
|
2614
2677
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
2615
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
2678
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
2616
2679
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), annotatedState, runtime, childExec, preCompleted);
|
|
2617
2680
|
if (effectfulFailure != null) return null;
|
|
2618
2681
|
const resolvedFieldStates = await resolveStateWithRuntimeAsync(annotatedState, runtime);
|
|
@@ -2993,7 +3056,7 @@ function createSeqComplete(parsers, combinedMode) {
|
|
|
2993
3056
|
const pairs = buildIndexedParserPairs(syncParsers);
|
|
2994
3057
|
const stateRecord = createAnnotatedArrayStateRecord(stateArray);
|
|
2995
3058
|
const preCompleted = preCompleteAndRegisterDependencies(stateRecord, pairs, runtime.registry, childExec);
|
|
2996
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
3059
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
2997
3060
|
const phase3Exec = {
|
|
2998
3061
|
...childExec,
|
|
2999
3062
|
preCompletedByParser: void 0
|
|
@@ -3035,7 +3098,7 @@ function createSeqComplete(parsers, combinedMode) {
|
|
|
3035
3098
|
const preCompleted = await preCompleteAndRegisterDependenciesAsync(stateRecord, pairs, runtime.registry, childExec);
|
|
3036
3099
|
const allRuntimeNodes = buildRuntimeNodesFromArray(parsers, stateArray, exec?.path);
|
|
3037
3100
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
3038
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
3101
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
3039
3102
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), stateArray, runtime, childExec, preCompleted);
|
|
3040
3103
|
if (effectfulFailure != null) return effectfulFailure;
|
|
3041
3104
|
const phase3Exec = {
|
|
@@ -3077,7 +3140,7 @@ function suggestTupleSync(context, prefix, parsers) {
|
|
|
3077
3140
|
const runtime = createDependencyRuntimeContext(advancedContext.dependencyRegistry?.clone());
|
|
3078
3141
|
if (stateArray && Array.isArray(stateArray)) {
|
|
3079
3142
|
const nodes = buildSuggestRuntimeNodesFromArray(parsers, stateArray, advancedContext.exec?.path);
|
|
3080
|
-
collectExplicitSourceValues(nodes, runtime);
|
|
3143
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(nodes), runtime);
|
|
3081
3144
|
fillMissingSourceDefaults(nodes, runtime);
|
|
3082
3145
|
collectSourcesFromState(stateArray, runtime);
|
|
3083
3146
|
completeDependencySourceDefaults({
|
|
@@ -3111,7 +3174,7 @@ async function* suggestTupleAsync(context, prefix, parsers) {
|
|
|
3111
3174
|
const runtime = createDependencyRuntimeContext(advancedContext.dependencyRegistry?.clone());
|
|
3112
3175
|
if (stateArray && Array.isArray(stateArray)) {
|
|
3113
3176
|
const nodes = buildSuggestRuntimeNodesFromArray(parsers, stateArray, advancedContext.exec?.path);
|
|
3114
|
-
await collectExplicitSourceValuesAsync(nodes, runtime);
|
|
3177
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(nodes), runtime);
|
|
3115
3178
|
await fillMissingSourceDefaultsAsync(nodes, runtime);
|
|
3116
3179
|
collectSourcesFromState(stateArray, runtime);
|
|
3117
3180
|
await completeDependencySourceDefaultsAsync({
|
|
@@ -3280,7 +3343,7 @@ function markFailedTupleSuggestSources(parsers, stateArray, failedParserIndexes,
|
|
|
3280
3343
|
const nodes = getParserSuggestRuntimeNodes(parser, getWrappedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
3281
3344
|
if (nodes.length < 1) continue;
|
|
3282
3345
|
const failedRuntime = createDependencyRuntimeContext();
|
|
3283
|
-
collectExplicitSourceValues(nodes, failedRuntime);
|
|
3346
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(nodes), failedRuntime);
|
|
3284
3347
|
for (const node of nodes) {
|
|
3285
3348
|
const sourceId = node.parser.dependencyMetadata?.source?.sourceId;
|
|
3286
3349
|
if (sourceId != null && failedRuntime.isSourceFailed(sourceId)) runtime.markSourceFailed(sourceId);
|
|
@@ -3297,7 +3360,7 @@ async function markFailedTupleSuggestSourcesAsync(parsers, stateArray, failedPar
|
|
|
3297
3360
|
const nodes = getParserSuggestRuntimeNodes(parser, getWrappedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
3298
3361
|
if (nodes.length < 1) continue;
|
|
3299
3362
|
const failedRuntime = createDependencyRuntimeContext();
|
|
3300
|
-
await collectExplicitSourceValuesAsync(nodes, failedRuntime);
|
|
3363
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(nodes), failedRuntime);
|
|
3301
3364
|
for (const node of nodes) {
|
|
3302
3365
|
const sourceId = node.parser.dependencyMetadata?.source?.sourceId;
|
|
3303
3366
|
if (sourceId != null && failedRuntime.isSourceFailed(sourceId)) runtime.markSourceFailed(sourceId);
|
|
@@ -3481,7 +3544,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3481
3544
|
const tuplePairs = buildIndexedParserPairs(syncParsers);
|
|
3482
3545
|
const tupleState = createAnnotatedArrayStateRecord(stateArray);
|
|
3483
3546
|
const preCompleted = preCompleteAndRegisterDependencies(tupleState, tuplePairs, runtime.registry, childExec);
|
|
3484
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
3547
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
3485
3548
|
const phase3Exec = {
|
|
3486
3549
|
...childExec,
|
|
3487
3550
|
preCompletedByParser: void 0
|
|
@@ -3530,7 +3593,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3530
3593
|
const preCompleted = await preCompleteAndRegisterDependenciesAsync(tupleState, tuplePairs, runtime.registry, childExec);
|
|
3531
3594
|
const allRuntimeNodes = buildRuntimeNodesFromArray(parsers, stateArray, exec?.path);
|
|
3532
3595
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
3533
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
3596
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
3534
3597
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), stateArray, runtime, childExec, preCompleted);
|
|
3535
3598
|
if (effectfulFailure != null) return effectfulFailure;
|
|
3536
3599
|
const phase3Exec = {
|
|
@@ -3579,7 +3642,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3579
3642
|
const tuplePairs = buildIndexedParserPairs(syncParsers);
|
|
3580
3643
|
const tupleState = createAnnotatedArrayStateRecord(stateArray);
|
|
3581
3644
|
const preCompleted = preCompleteAndRegisterDependencies(tupleState, tuplePairs, runtime.registry, childExec);
|
|
3582
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
3645
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
3583
3646
|
const phase3Exec = {
|
|
3584
3647
|
...childExec,
|
|
3585
3648
|
preCompletedByParser: void 0
|
|
@@ -3618,7 +3681,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3618
3681
|
const preCompleted = await preCompleteAndRegisterDependenciesAsync(tupleState, tuplePairs, runtime.registry, childExec);
|
|
3619
3682
|
const allRuntimeNodes = buildRuntimeNodesFromArray(parsers, stateArray, exec?.path);
|
|
3620
3683
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
3621
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
3684
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
3622
3685
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), stateArray, runtime, childExec, preCompleted);
|
|
3623
3686
|
if (effectfulFailure != null) return null;
|
|
3624
3687
|
const phase3Exec = {
|
|
@@ -3845,7 +3908,7 @@ function seq(...rawArgs) {
|
|
|
3845
3908
|
const pairs = buildIndexedParserPairs(syncParsers);
|
|
3846
3909
|
const stateRecord = createAnnotatedArrayStateRecord(stateArray);
|
|
3847
3910
|
const preCompleted = preCompleteAndRegisterDependencies(stateRecord, pairs, runtime.registry, childExec);
|
|
3848
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
3911
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
3849
3912
|
const phase3Exec = {
|
|
3850
3913
|
...childExec,
|
|
3851
3914
|
preCompletedByParser: void 0
|
|
@@ -3884,7 +3947,7 @@ function seq(...rawArgs) {
|
|
|
3884
3947
|
const preCompleted = await preCompleteAndRegisterDependenciesAsync(stateRecord, pairs, runtime.registry, childExec);
|
|
3885
3948
|
const allRuntimeNodes = buildRuntimeNodesFromArray(parsers, stateArray, exec?.path);
|
|
3886
3949
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
3887
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
3950
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
3888
3951
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), stateArray, runtime, childExec, preCompleted);
|
|
3889
3952
|
if (effectfulFailure != null) return null;
|
|
3890
3953
|
const phase3Exec = {
|
|
@@ -3926,7 +3989,7 @@ function seq(...rawArgs) {
|
|
|
3926
3989
|
const state = advancedContext.state;
|
|
3927
3990
|
const stateArray = state.states;
|
|
3928
3991
|
const nodes = buildSuggestRuntimeNodesFromArray(syncParsers, stateArray, advancedContext.exec?.path);
|
|
3929
|
-
collectExplicitSourceValues(nodes, runtime);
|
|
3992
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(nodes), runtime);
|
|
3930
3993
|
fillMissingSourceDefaults(nodes, runtime);
|
|
3931
3994
|
collectSourcesFromState(stateArray, runtime);
|
|
3932
3995
|
completeDependencySourceDefaults({
|
|
@@ -3956,7 +4019,7 @@ function seq(...rawArgs) {
|
|
|
3956
4019
|
const state = advancedContext.state;
|
|
3957
4020
|
const stateArray = state.states;
|
|
3958
4021
|
const nodes = buildSuggestRuntimeNodesFromArray(parsers, stateArray, advancedContext.exec?.path);
|
|
3959
|
-
await collectExplicitSourceValuesAsync(nodes, runtime);
|
|
4022
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(nodes), runtime);
|
|
3960
4023
|
await fillMissingSourceDefaultsAsync(nodes, runtime);
|
|
3961
4024
|
collectSourcesFromState(stateArray, runtime);
|
|
3962
4025
|
await completeDependencySourceDefaultsAsync({
|
|
@@ -4569,7 +4632,7 @@ function merge(...args) {
|
|
|
4569
4632
|
excludedSourceFields: void 0
|
|
4570
4633
|
};
|
|
4571
4634
|
});
|
|
4572
|
-
collectExplicitSourceValues(buildRuntimeNodesFromPairs(unambiguousFieldParsers, state, exec?.path), runtime);
|
|
4635
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(buildRuntimeNodesFromPairs(unambiguousFieldParsers, state, exec?.path)), runtime);
|
|
4573
4636
|
const resolvedState = resolveStateWithRuntime(state, runtime);
|
|
4574
4637
|
const object$1 = {};
|
|
4575
4638
|
const deferredKeys = /* @__PURE__ */ new Map();
|
|
@@ -4642,7 +4705,7 @@ function merge(...args) {
|
|
|
4642
4705
|
};
|
|
4643
4706
|
}
|
|
4644
4707
|
const mergeNodes = buildMergeSchedulingNodes(state, exec?.path);
|
|
4645
|
-
await collectExplicitSourceValuesAsync(mergeNodes, runtime);
|
|
4708
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(mergeNodes), runtime);
|
|
4646
4709
|
const effectfulPreCompleted = /* @__PURE__ */ new Map();
|
|
4647
4710
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(mergeNodes, state, runtime, childExec, effectfulPreCompleted);
|
|
4648
4711
|
if (effectfulFailure != null) return effectfulFailure;
|
|
@@ -4743,7 +4806,7 @@ function merge(...args) {
|
|
|
4743
4806
|
excludedSourceFields: void 0
|
|
4744
4807
|
};
|
|
4745
4808
|
});
|
|
4746
|
-
collectExplicitSourceValues(buildRuntimeNodesFromPairs(unambiguousFieldParsers, state, exec?.path), runtime);
|
|
4809
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(buildRuntimeNodesFromPairs(unambiguousFieldParsers, state, exec?.path)), runtime);
|
|
4747
4810
|
const resolvedState = resolveStateWithRuntime(state, runtime);
|
|
4748
4811
|
const object$1 = {};
|
|
4749
4812
|
const deferredKeys = /* @__PURE__ */ new Map();
|
|
@@ -4809,7 +4872,7 @@ function merge(...args) {
|
|
|
4809
4872
|
};
|
|
4810
4873
|
}
|
|
4811
4874
|
const mergeNodes = buildMergeSchedulingNodes(state, exec?.path);
|
|
4812
|
-
await collectExplicitSourceValuesAsync(mergeNodes, runtime);
|
|
4875
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(mergeNodes), runtime);
|
|
4813
4876
|
const effectfulPreCompleted = /* @__PURE__ */ new Map();
|
|
4814
4877
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(mergeNodes, state, runtime, childExec, effectfulPreCompleted);
|
|
4815
4878
|
if (effectfulFailure != null) return null;
|
|
@@ -4902,7 +4965,7 @@ function merge(...args) {
|
|
|
4902
4965
|
const excludedSourceFields = new Set(pairs.map(([field]) => field).filter((field) => duplicateFieldNames$1.has(field)));
|
|
4903
4966
|
return excludedSourceFields.size > 0 ? excludedSourceFields : void 0;
|
|
4904
4967
|
});
|
|
4905
|
-
if (context.state && typeof context.state === "object") await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs(childFieldPairs$1, context.state, context.exec?.path), runtime$1);
|
|
4968
|
+
if (context.state && typeof context.state === "object") await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(buildRuntimeNodesFromPairs(childFieldPairs$1, context.state, context.exec?.path)), runtime$1);
|
|
4906
4969
|
if (context.state && typeof context.state === "object") collectSourcesFromState(context.state, runtime$1, /* @__PURE__ */ new WeakSet(), duplicateFieldNames$1);
|
|
4907
4970
|
await completeDependencySourceDefaultsAsync(context, childFieldPairs$1, runtime$1.registry, context.exec);
|
|
4908
4971
|
const contextWithRegistry$1 = {
|
|
@@ -4942,7 +5005,7 @@ function merge(...args) {
|
|
|
4942
5005
|
const excludedSourceFields = new Set(pairs.map(([field]) => field).filter((field) => duplicateFieldNames.has(field)));
|
|
4943
5006
|
return excludedSourceFields.size > 0 ? excludedSourceFields : void 0;
|
|
4944
5007
|
});
|
|
4945
|
-
if (context.state && typeof context.state === "object") collectExplicitSourceValues(buildRuntimeNodesFromPairs(childFieldPairs, context.state, context.exec?.path), runtime);
|
|
5008
|
+
if (context.state && typeof context.state === "object") collectExplicitSourceValues(expandSourceCollectionNodes(buildRuntimeNodesFromPairs(childFieldPairs, context.state, context.exec?.path)), runtime);
|
|
4946
5009
|
if (context.state && typeof context.state === "object") collectSourcesFromState(context.state, runtime, /* @__PURE__ */ new WeakSet(), duplicateFieldNames);
|
|
4947
5010
|
completeDependencySourceDefaults(context, childFieldPairs, runtime.registry, context.exec);
|
|
4948
5011
|
const contextWithRegistry = {
|
|
@@ -5049,7 +5112,7 @@ function buildSuggestRegistry(preParsedContext, parsers) {
|
|
|
5049
5112
|
const runtime = createDependencyRuntimeContext(preParsedContext.dependencyRegistry?.clone());
|
|
5050
5113
|
if (stateArray && Array.isArray(stateArray)) {
|
|
5051
5114
|
const nodes = buildSuggestRuntimeNodesFromArray(parsers, stateArray, preParsedContext.exec?.path);
|
|
5052
|
-
collectExplicitSourceValues(nodes, runtime);
|
|
5115
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(nodes), runtime);
|
|
5053
5116
|
fillMissingSourceDefaults(nodes, runtime);
|
|
5054
5117
|
collectSourcesFromState(stateArray, runtime);
|
|
5055
5118
|
completeDependencySourceDefaults({
|
|
@@ -5077,7 +5140,7 @@ async function buildSuggestRegistryAsync(preParsedContext, parsers) {
|
|
|
5077
5140
|
const runtime = createDependencyRuntimeContext(preParsedContext.dependencyRegistry?.clone());
|
|
5078
5141
|
if (stateArray && Array.isArray(stateArray)) {
|
|
5079
5142
|
const nodes = buildSuggestRuntimeNodesFromArray(parsers, stateArray, preParsedContext.exec?.path);
|
|
5080
|
-
await collectExplicitSourceValuesAsync(nodes, runtime);
|
|
5143
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(nodes), runtime);
|
|
5081
5144
|
await fillMissingSourceDefaultsAsync(nodes, runtime);
|
|
5082
5145
|
collectSourcesFromState(stateArray, runtime);
|
|
5083
5146
|
await completeDependencySourceDefaultsAsync({
|
|
@@ -5107,7 +5170,7 @@ function seedSuggestRuntimeFromFieldParsers(parser, state, runtime, parentPath)
|
|
|
5107
5170
|
const pairs = filterDuplicateFieldParsers(rawPairs);
|
|
5108
5171
|
const stateRecord = state != null && typeof state === "object" ? state : {};
|
|
5109
5172
|
const nodes = buildSuggestRuntimeNodesFromPairs(pairs, stateRecord, parentPath);
|
|
5110
|
-
collectExplicitSourceValues(nodes, runtime);
|
|
5173
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(nodes), runtime);
|
|
5111
5174
|
fillMissingSourceDefaults(nodes, runtime);
|
|
5112
5175
|
collectSourcesFromState(state, runtime, /* @__PURE__ */ new WeakSet(), duplicateFieldNames);
|
|
5113
5176
|
completeDependencySourceDefaults({
|
|
@@ -5139,7 +5202,7 @@ async function seedSuggestRuntimeFromFieldParsersAsync(parser, state, runtime, p
|
|
|
5139
5202
|
const pairs = filterDuplicateFieldParsers(rawPairs);
|
|
5140
5203
|
const stateRecord = state != null && typeof state === "object" ? state : {};
|
|
5141
5204
|
const nodes = buildSuggestRuntimeNodesFromPairs(pairs, stateRecord, parentPath);
|
|
5142
|
-
await collectExplicitSourceValuesAsync(nodes, runtime);
|
|
5205
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(nodes), runtime);
|
|
5143
5206
|
await fillMissingSourceDefaultsAsync(nodes, runtime);
|
|
5144
5207
|
collectSourcesFromState(state, runtime, /* @__PURE__ */ new WeakSet(), duplicateFieldNames);
|
|
5145
5208
|
await completeDependencySourceDefaultsAsync({
|
|
@@ -5414,7 +5477,7 @@ function concat(...parsers) {
|
|
|
5414
5477
|
const concatPairs = buildIndexedParserPairs(syncParsers);
|
|
5415
5478
|
const concatState = createAnnotatedArrayStateRecord(stateArray);
|
|
5416
5479
|
const preCompleted = preCompleteAndRegisterDependencies(concatState, concatPairs, runtime.registry, childExec);
|
|
5417
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
5480
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
5418
5481
|
const phase3Exec = {
|
|
5419
5482
|
...childExec,
|
|
5420
5483
|
preCompletedByParser: void 0
|
|
@@ -5466,7 +5529,7 @@ function concat(...parsers) {
|
|
|
5466
5529
|
const preCompleted = await preCompleteAndRegisterDependenciesAsync(concatState, concatPairs, runtime.registry, childExec);
|
|
5467
5530
|
const allRuntimeNodes = buildRuntimeNodesFromArray(parsers, stateArray, exec?.path);
|
|
5468
5531
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
5469
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
5532
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
5470
5533
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), stateArray, runtime, childExec, preCompleted);
|
|
5471
5534
|
if (effectfulFailure != null) return effectfulFailure;
|
|
5472
5535
|
const phase3Exec = {
|
|
@@ -5538,7 +5601,7 @@ function concat(...parsers) {
|
|
|
5538
5601
|
const concatPairs = buildIndexedParserPairs(syncParsers);
|
|
5539
5602
|
const concatState = createAnnotatedArrayStateRecord(stateArray);
|
|
5540
5603
|
const preCompleted = preCompleteAndRegisterDependencies(concatState, concatPairs, runtime.registry, childExec);
|
|
5541
|
-
collectExplicitSourceValues(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys())), runtime);
|
|
5604
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(filterPreCompletedRuntimeNodes(buildRuntimeNodesFromArray(syncParsers, stateArray, exec?.path), new Set(preCompleted.keys()))), runtime);
|
|
5542
5605
|
const phase3Exec = {
|
|
5543
5606
|
...childExec,
|
|
5544
5607
|
preCompletedByParser: void 0
|
|
@@ -5574,7 +5637,7 @@ function concat(...parsers) {
|
|
|
5574
5637
|
const preCompleted = await preCompleteAndRegisterDependenciesAsync(concatState, concatPairs, runtime.registry, childExec);
|
|
5575
5638
|
const allRuntimeNodes = buildRuntimeNodesFromArray(parsers, stateArray, exec?.path);
|
|
5576
5639
|
const runtimeNodes = filterPreCompletedRuntimeNodes(allRuntimeNodes, new Set(preCompleted.keys()));
|
|
5577
|
-
await collectExplicitSourceValuesAsync(runtimeNodes, runtime);
|
|
5640
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(runtimeNodes), runtime);
|
|
5578
5641
|
const effectfulFailure = await scheduleEffectfulSourceCompletions(filterSchedulableRuntimeNodes(allRuntimeNodes, preCompleted), stateArray, runtime, childExec, preCompleted);
|
|
5579
5642
|
if (effectfulFailure != null) return null;
|
|
5580
5643
|
const phase3Exec = {
|
|
@@ -5674,6 +5737,7 @@ function group(label, parser, options = {}) {
|
|
|
5674
5737
|
initialState: parser.initialState,
|
|
5675
5738
|
...fieldParsersKey in parser ? { [fieldParsersKey]: parser[fieldParsersKey] } : {},
|
|
5676
5739
|
...effectfulSchedulingNodesKey in parser ? { [effectfulSchedulingNodesKey]: parser[effectfulSchedulingNodesKey] } : {},
|
|
5740
|
+
...sourceCollectionExpansionKey in parser ? { [sourceCollectionExpansionKey]: parser[sourceCollectionExpansionKey] } : {},
|
|
5677
5741
|
...typeof parser.shouldDeferCompletion === "function" ? { shouldDeferCompletion: parser.shouldDeferCompletion.bind(parser) } : {},
|
|
5678
5742
|
...typeof parser.canSkip === "function" ? { canSkip: parser.canSkip.bind(parser) } : {},
|
|
5679
5743
|
getSuggestRuntimeNodes(state, path) {
|
|
@@ -5728,6 +5792,11 @@ function group(label, parser, options = {}) {
|
|
|
5728
5792
|
}
|
|
5729
5793
|
};
|
|
5730
5794
|
defineParseLanes(groupParser, getOwnParseLanes(parser));
|
|
5795
|
+
Object.defineProperty(groupParser, staticSourceScopeKey, {
|
|
5796
|
+
value: [parser],
|
|
5797
|
+
configurable: true,
|
|
5798
|
+
enumerable: false
|
|
5799
|
+
});
|
|
5731
5800
|
Object.defineProperty(groupParser, extractPhase2SeedKey, {
|
|
5732
5801
|
value(state, exec) {
|
|
5733
5802
|
return extractPhase2Seed(parser, state, exec);
|
|
@@ -6320,7 +6389,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6320
6389
|
_branch: getWrappedChildState(state, state.branchState, branchParser)
|
|
6321
6390
|
};
|
|
6322
6391
|
const runtime = createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
6323
|
-
collectExplicitSourceValues(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
6392
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path)), runtime);
|
|
6324
6393
|
collectSourcesFromState(combinedState, runtime);
|
|
6325
6394
|
const resolvedBranchState = getWrappedChildState(state, resolveStateWithRuntime(state.branchState, runtime), branchParser);
|
|
6326
6395
|
const completionExec = {
|
|
@@ -6359,13 +6428,23 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6359
6428
|
} : {}
|
|
6360
6429
|
};
|
|
6361
6430
|
};
|
|
6431
|
+
const preparedKeyPrefix = `c${++conditionalInstanceCounter}|`;
|
|
6432
|
+
const preparedKeyFor = (parentPath) => preparedKeyPrefix + serializeSchedulingPath(parentPath ?? []);
|
|
6433
|
+
const branchProvidedSourceIds = (() => {
|
|
6434
|
+
const out = /* @__PURE__ */ new Set();
|
|
6435
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6436
|
+
for (const key of Object.keys(branches)) collectStaticSourceIds(branches[key], out, seen);
|
|
6437
|
+
if (defaultBranch != null) collectStaticSourceIds(defaultBranch, out, seen);
|
|
6438
|
+
return out;
|
|
6439
|
+
})();
|
|
6362
6440
|
const buildConditionalSchedulingNodes = (state, parentPath) => {
|
|
6363
6441
|
if (state == null || typeof state !== "object") return [];
|
|
6364
6442
|
const conditionalState = state;
|
|
6443
|
+
const annotatedDiscriminatorState = getWrappedChildState(conditionalState, conditionalState.discriminatorState, discriminator);
|
|
6365
6444
|
const nodes = [{
|
|
6366
6445
|
path: [...parentPath ?? [], "_discriminator"],
|
|
6367
6446
|
parser: discriminator,
|
|
6368
|
-
state:
|
|
6447
|
+
state: annotatedDiscriminatorState
|
|
6369
6448
|
}];
|
|
6370
6449
|
const selected = conditionalState.selectedBranch;
|
|
6371
6450
|
if (selected !== void 0 && conditionalState.speculative !== true) {
|
|
@@ -6375,7 +6454,115 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6375
6454
|
parser: branchParser,
|
|
6376
6455
|
state: getWrappedChildState(conditionalState, conditionalState.branchState, branchParser)
|
|
6377
6456
|
});
|
|
6457
|
+
return nodes;
|
|
6458
|
+
}
|
|
6459
|
+
const discriminatorSource = discriminator.dependencyMetadata?.source;
|
|
6460
|
+
const innerCompleteSource = discriminatorSource?.completeSource;
|
|
6461
|
+
const discriminatorPathKey = serializeSchedulingPath([...parentPath ?? [], "_discriminator"]);
|
|
6462
|
+
const cell = {};
|
|
6463
|
+
const teeDiscriminatorNode = () => {
|
|
6464
|
+
if (discriminatorSource == null || innerCompleteSource == null) return;
|
|
6465
|
+
nodes[0] = {
|
|
6466
|
+
...nodes[0],
|
|
6467
|
+
parser: { dependencyMetadata: {
|
|
6468
|
+
...discriminator.dependencyMetadata,
|
|
6469
|
+
source: {
|
|
6470
|
+
...discriminatorSource,
|
|
6471
|
+
completeSource: async (s, e) => {
|
|
6472
|
+
const result = await innerCompleteSource(s, e);
|
|
6473
|
+
if (result != null) cell.result = result;
|
|
6474
|
+
return result;
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
} }
|
|
6478
|
+
};
|
|
6479
|
+
};
|
|
6480
|
+
if (conditionalState.speculative === true) {
|
|
6481
|
+
if (selected?.kind !== "branch" || innerCompleteSource == null) return nodes;
|
|
6482
|
+
teeDiscriminatorNode();
|
|
6483
|
+
const speculativeKey = selected.key;
|
|
6484
|
+
nodes.push({
|
|
6485
|
+
path: [...parentPath ?? [], "_branch"],
|
|
6486
|
+
parser: {},
|
|
6487
|
+
state: conditionalState,
|
|
6488
|
+
...discriminatorSource != null ? { requiresSourceId: discriminatorSource.sourceId } : {},
|
|
6489
|
+
providesSourceIds: branchProvidedSourceIds,
|
|
6490
|
+
prepare: async (ctx) => {
|
|
6491
|
+
const session = ctx.exec?.effectfulCompletionSession;
|
|
6492
|
+
if (session == null) return void 0;
|
|
6493
|
+
const result = cell.result ?? session.completedByPath.get(discriminatorPathKey);
|
|
6494
|
+
if (result == null || isDeferredCompletionResult(result) || result.success !== true) return void 0;
|
|
6495
|
+
if (String(result.value) !== speculativeKey) return void 0;
|
|
6496
|
+
const branchParser = branches[speculativeKey];
|
|
6497
|
+
if (branchParser == null) return void 0;
|
|
6498
|
+
return await ctx.schedule(expandEffectfulRuntimeNodes([{
|
|
6499
|
+
path: [...parentPath ?? [], "_branch"],
|
|
6500
|
+
parser: branchParser,
|
|
6501
|
+
state: getWrappedChildState(conditionalState, conditionalState.branchState, branchParser)
|
|
6502
|
+
}]));
|
|
6503
|
+
}
|
|
6504
|
+
});
|
|
6505
|
+
return nodes;
|
|
6378
6506
|
}
|
|
6507
|
+
if (selected !== void 0) return nodes;
|
|
6508
|
+
if (discriminatorSource == null && typeof discriminator.shouldDeferCompletion === "function") return nodes;
|
|
6509
|
+
teeDiscriminatorNode();
|
|
6510
|
+
nodes.push({
|
|
6511
|
+
path: [...parentPath ?? [], "_branch"],
|
|
6512
|
+
parser: {},
|
|
6513
|
+
state: conditionalState,
|
|
6514
|
+
...discriminatorSource != null ? { requiresSourceId: discriminatorSource.sourceId } : {},
|
|
6515
|
+
providesSourceIds: branchProvidedSourceIds,
|
|
6516
|
+
prepare: async (ctx) => {
|
|
6517
|
+
const session = ctx.exec?.effectfulCompletionSession;
|
|
6518
|
+
if (session == null) return void 0;
|
|
6519
|
+
const key = preparedKeyFor(parentPath);
|
|
6520
|
+
let prepared = session.preparedByPath.get(key);
|
|
6521
|
+
if (prepared == null) {
|
|
6522
|
+
let discriminatorResult = cell.result ?? session.completedByPath.get(discriminatorPathKey);
|
|
6523
|
+
if (discriminatorResult == null && innerCompleteSource == null) {
|
|
6524
|
+
const discriminatorExec = ctx.exec == null ? void 0 : {
|
|
6525
|
+
...ctx.exec,
|
|
6526
|
+
path: [...parentPath ?? [], "_discriminator"]
|
|
6527
|
+
};
|
|
6528
|
+
discriminatorResult = unwrapCompleteResult(await discriminator.complete(annotatedDiscriminatorState, discriminatorExec));
|
|
6529
|
+
}
|
|
6530
|
+
if (discriminatorResult == null || isDeferredCompletionResult(discriminatorResult)) return void 0;
|
|
6531
|
+
const namedBranch = discriminatorResult.success ? branches[String(discriminatorResult.value)] : void 0;
|
|
6532
|
+
const branchParser = namedBranch ?? defaultBranch;
|
|
6533
|
+
let branchState;
|
|
6534
|
+
if (branchParser != null) {
|
|
6535
|
+
const branchExec = ctx.exec == null ? void 0 : {
|
|
6536
|
+
...ctx.exec,
|
|
6537
|
+
path: [...parentPath ?? [], "_branch"]
|
|
6538
|
+
};
|
|
6539
|
+
const annotatedInitial = getWrappedChildState(conditionalState, branchParser.initialState, branchParser);
|
|
6540
|
+
const replayResult = await branchParser.parse({
|
|
6541
|
+
buffer: [],
|
|
6542
|
+
optionsTerminated: false,
|
|
6543
|
+
usage: [],
|
|
6544
|
+
exec: branchExec,
|
|
6545
|
+
dependencyRegistry: ctx.exec?.dependencyRegistry,
|
|
6546
|
+
state: annotatedInitial
|
|
6547
|
+
});
|
|
6548
|
+
branchState = replayResult.success ? replayResult.next.state : annotatedInitial;
|
|
6549
|
+
}
|
|
6550
|
+
prepared = {
|
|
6551
|
+
discriminatorResult,
|
|
6552
|
+
branchParser,
|
|
6553
|
+
branchKey: namedBranch != null ? String(discriminatorResult.value) : void 0,
|
|
6554
|
+
branchState
|
|
6555
|
+
};
|
|
6556
|
+
session.preparedByPath.set(key, prepared);
|
|
6557
|
+
}
|
|
6558
|
+
if (prepared.branchParser == null) return void 0;
|
|
6559
|
+
return await ctx.schedule(expandEffectfulRuntimeNodes([{
|
|
6560
|
+
path: [...parentPath ?? [], "_branch"],
|
|
6561
|
+
parser: prepared.branchParser,
|
|
6562
|
+
state: getWrappedChildState(conditionalState, prepared.branchState, prepared.branchParser)
|
|
6563
|
+
}]));
|
|
6564
|
+
}
|
|
6565
|
+
});
|
|
6379
6566
|
return nodes;
|
|
6380
6567
|
};
|
|
6381
6568
|
const completeAsync = async (state, exec) => {
|
|
@@ -6391,27 +6578,44 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6391
6578
|
value: [state.selectedBranch.key, void 0]
|
|
6392
6579
|
};
|
|
6393
6580
|
if (state.selectedBranch === void 0) {
|
|
6581
|
+
let prepared;
|
|
6394
6582
|
if (exec?.phase !== "parse" && exec?.phase !== "suggest") {
|
|
6583
|
+
if (exec?.effectfulCompletionSession != null) {
|
|
6584
|
+
const schedulingRuntime = createDependencyRuntimeContext(exec.dependencyRegistry?.clone());
|
|
6585
|
+
const schedulingExec = {
|
|
6586
|
+
...exec,
|
|
6587
|
+
phase: "complete",
|
|
6588
|
+
dependencyRuntime: schedulingRuntime,
|
|
6589
|
+
dependencyRegistry: schedulingRuntime.registry
|
|
6590
|
+
};
|
|
6591
|
+
const schedulingFailure = await scheduleEffectfulSourceCompletions(buildConditionalSchedulingNodes(state, exec.path), state, schedulingRuntime, schedulingExec, /* @__PURE__ */ new Map());
|
|
6592
|
+
if (schedulingFailure != null) return schedulingFailure;
|
|
6593
|
+
prepared = exec.effectfulCompletionSession.preparedByPath.get(preparedKeyFor(exec.path));
|
|
6594
|
+
}
|
|
6395
6595
|
const annotatedDiscriminatorStateForDeferred = getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
6396
|
-
const deferredDiscriminatorResult = unwrapCompleteResult(await discriminator.complete(annotatedDiscriminatorStateForDeferred, withChildExecPath(exec, "_discriminator")));
|
|
6596
|
+
const deferredDiscriminatorResult = prepared != null ? prepared.discriminatorResult : unwrapCompleteResult(await discriminator.complete(annotatedDiscriminatorStateForDeferred, withChildExecPath(exec, "_discriminator")));
|
|
6397
6597
|
if (deferredDiscriminatorResult.success) {
|
|
6398
6598
|
const deferredValue = deferredDiscriminatorResult.value;
|
|
6399
6599
|
const deferredBranch = branches[deferredValue];
|
|
6400
6600
|
if (deferredBranch) {
|
|
6401
6601
|
const branchExec = withChildExecPath(exec, "_branch");
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
state
|
|
6413
|
-
|
|
6414
|
-
|
|
6602
|
+
let branchState;
|
|
6603
|
+
if (prepared != null && prepared.branchKey === deferredValue) branchState = prepared.branchState;
|
|
6604
|
+
else {
|
|
6605
|
+
const emptyCtx = {
|
|
6606
|
+
buffer: [],
|
|
6607
|
+
optionsTerminated: false,
|
|
6608
|
+
usage: [],
|
|
6609
|
+
exec: branchExec,
|
|
6610
|
+
dependencyRegistry: exec?.dependencyRegistry
|
|
6611
|
+
};
|
|
6612
|
+
const annotatedInitial = getWrappedChildState(state, deferredBranch.initialState, deferredBranch);
|
|
6613
|
+
const replayResult = await deferredBranch.parse({
|
|
6614
|
+
...emptyCtx,
|
|
6615
|
+
state: annotatedInitial
|
|
6616
|
+
});
|
|
6617
|
+
branchState = replayResult.success ? replayResult.next.state : annotatedInitial;
|
|
6618
|
+
}
|
|
6415
6619
|
const annotatedBranchState = getWrappedChildState(state, branchState, deferredBranch);
|
|
6416
6620
|
const branchResult$1 = unwrapCompleteResult(await deferredBranch.complete(annotatedBranchState, branchExec));
|
|
6417
6621
|
if (branchResult$1.success) return {
|
|
@@ -6439,7 +6643,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6439
6643
|
value: [void 0, void 0]
|
|
6440
6644
|
};
|
|
6441
6645
|
if (defaultBranch !== void 0) {
|
|
6442
|
-
const branchState = getWrappedChildState(state, state.branchState ?? defaultBranch.initialState, defaultBranch);
|
|
6646
|
+
const branchState = getWrappedChildState(state, (prepared != null && prepared.branchKey == null ? prepared.branchState : void 0) ?? state.branchState ?? defaultBranch.initialState, defaultBranch);
|
|
6443
6647
|
const defaultResult = unwrapCompleteResult(await defaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
6444
6648
|
if (!defaultResult.success) return defaultResult;
|
|
6445
6649
|
return {
|
|
@@ -6463,7 +6667,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6463
6667
|
_branch: getWrappedChildState(state, state.branchState, branchParser)
|
|
6464
6668
|
};
|
|
6465
6669
|
const runtime = createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
6466
|
-
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
6670
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path)), runtime);
|
|
6467
6671
|
collectSourcesFromState(combinedState, runtime);
|
|
6468
6672
|
const completionExec = {
|
|
6469
6673
|
...exec ?? {
|
|
@@ -6486,7 +6690,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6486
6690
|
if (wasSpeculative && needsDiscriminatorCompletion) {
|
|
6487
6691
|
const discOnlyState = { _discriminator: annotatedDiscriminatorState };
|
|
6488
6692
|
const discOnlyRuntime = createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
6489
|
-
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs([["_discriminator", discriminator]], discOnlyState, exec?.path), discOnlyRuntime);
|
|
6693
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(buildRuntimeNodesFromPairs([["_discriminator", discriminator]], discOnlyState, exec?.path)), discOnlyRuntime);
|
|
6490
6694
|
collectSourcesFromState(discOnlyState, discOnlyRuntime);
|
|
6491
6695
|
discriminatorCompletionExec = {
|
|
6492
6696
|
...completionExec,
|
|
@@ -6552,7 +6756,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6552
6756
|
_discriminator: annotatedDiscriminatorState,
|
|
6553
6757
|
_branch: syncDefaultBranch == null ? state.branchState : getWrappedChildState(state, state.branchState, syncDefaultBranch)
|
|
6554
6758
|
};
|
|
6555
|
-
collectExplicitSourceValues(buildRuntimeNodesFromPairs(syncDefaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", syncDefaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
6759
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(buildRuntimeNodesFromPairs(syncDefaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", syncDefaultBranch]], defaultCombinedState, context.exec?.path)), runtime);
|
|
6556
6760
|
collectSourcesFromState(defaultCombinedState, runtime);
|
|
6557
6761
|
const suggestContext = {
|
|
6558
6762
|
...context,
|
|
@@ -6581,7 +6785,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6581
6785
|
_discriminator: annotatedDiscriminatorState,
|
|
6582
6786
|
_branch: getWrappedChildState(state, state.branchState, branchParser)
|
|
6583
6787
|
};
|
|
6584
|
-
collectExplicitSourceValues(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
6788
|
+
collectExplicitSourceValues(expandSourceCollectionNodes(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path)), runtime);
|
|
6585
6789
|
collectSourcesFromState(combinedState, runtime);
|
|
6586
6790
|
const suggestContext = {
|
|
6587
6791
|
...context,
|
|
@@ -6604,7 +6808,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6604
6808
|
_discriminator: annotatedDiscriminatorState,
|
|
6605
6809
|
_branch: defaultBranch == null ? state.branchState : getWrappedChildState(state, state.branchState, defaultBranch)
|
|
6606
6810
|
};
|
|
6607
|
-
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs(defaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", defaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
6811
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(buildRuntimeNodesFromPairs(defaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", defaultBranch]], defaultCombinedState, context.exec?.path)), runtime);
|
|
6608
6812
|
collectSourcesFromState(defaultCombinedState, runtime);
|
|
6609
6813
|
const suggestContext = {
|
|
6610
6814
|
...context,
|
|
@@ -6640,7 +6844,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6640
6844
|
_discriminator: annotatedDiscriminatorState,
|
|
6641
6845
|
_branch: getWrappedChildState(state, state.branchState, branchParser)
|
|
6642
6846
|
};
|
|
6643
|
-
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
6847
|
+
await collectExplicitSourceValuesAsync(expandSourceCollectionNodes(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path)), runtime);
|
|
6644
6848
|
collectSourcesFromState(combinedState, runtime);
|
|
6645
6849
|
const suggestContext = {
|
|
6646
6850
|
...context,
|
|
@@ -6756,6 +6960,20 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6756
6960
|
configurable: true,
|
|
6757
6961
|
enumerable: false
|
|
6758
6962
|
});
|
|
6963
|
+
Object.defineProperty(conditionalParser, sourceCollectionExpansionKey, {
|
|
6964
|
+
value: true,
|
|
6965
|
+
configurable: true,
|
|
6966
|
+
enumerable: false
|
|
6967
|
+
});
|
|
6968
|
+
Object.defineProperty(conditionalParser, staticSourceScopeKey, {
|
|
6969
|
+
value: [
|
|
6970
|
+
discriminator,
|
|
6971
|
+
...Object.values(branches),
|
|
6972
|
+
...defaultBranch != null ? [defaultBranch] : []
|
|
6973
|
+
],
|
|
6974
|
+
configurable: true,
|
|
6975
|
+
enumerable: false
|
|
6976
|
+
});
|
|
6759
6977
|
return fluent(conditionalParser);
|
|
6760
6978
|
}
|
|
6761
6979
|
|