@optique/core 1.0.0-dev.1661 → 1.0.0-dev.1665
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 +84 -55
- package/dist/constructs.js +84 -55
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -158,7 +158,11 @@ function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()
|
|
|
158
158
|
changed$1 = true;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
if (!changed$1) {
|
|
162
|
+
seen.set(source, source);
|
|
163
|
+
return source;
|
|
164
|
+
}
|
|
165
|
+
return clone$1;
|
|
162
166
|
}
|
|
163
167
|
const proto = Object.getPrototypeOf(source);
|
|
164
168
|
if (proto !== Object.prototype && proto !== null) return source;
|
|
@@ -986,15 +990,15 @@ function* suggestObjectSync(context, prefix, parserPairs) {
|
|
|
986
990
|
if (context.buffer.length > 0) {
|
|
987
991
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
988
992
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
989
|
-
const
|
|
990
|
-
yield* parser.suggest(withChildContext(contextWithRegistry, field,
|
|
993
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
994
|
+
yield* parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
991
995
|
return;
|
|
992
996
|
}
|
|
993
997
|
}
|
|
994
998
|
const suggestions = [];
|
|
995
999
|
for (const [field, parser] of parserPairs) {
|
|
996
|
-
const
|
|
997
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field,
|
|
1000
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1001
|
+
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
998
1002
|
suggestions.push(...fieldSuggestions);
|
|
999
1003
|
}
|
|
1000
1004
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -1022,16 +1026,16 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1022
1026
|
if (context.buffer.length > 0) {
|
|
1023
1027
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
1024
1028
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
1025
|
-
const
|
|
1026
|
-
const suggestions$1 = parser.suggest(withChildContext(contextWithRegistry, field,
|
|
1029
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1030
|
+
const suggestions$1 = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1027
1031
|
for await (const s of suggestions$1) yield s;
|
|
1028
1032
|
return;
|
|
1029
1033
|
}
|
|
1030
1034
|
}
|
|
1031
1035
|
const suggestions = [];
|
|
1032
1036
|
for (const [field, parser] of parserPairs) {
|
|
1033
|
-
const
|
|
1034
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field,
|
|
1037
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1038
|
+
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1035
1039
|
for await (const s of fieldSuggestions) suggestions.push(s);
|
|
1036
1040
|
}
|
|
1037
1041
|
yield* require_suggestion.deduplicateSuggestions(suggestions);
|
|
@@ -1333,10 +1337,17 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1333
1337
|
const createFieldStateGetter = (parentState, annotateChildState = getAnnotatedChildState) => {
|
|
1334
1338
|
return (field, parser) => {
|
|
1335
1339
|
const fieldKey = field;
|
|
1336
|
-
const cache = parentState != null && typeof parentState === "object" ?
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
+
const cache = parentState != null && typeof parentState === "object" ? (() => {
|
|
1341
|
+
const annotatorCaches = inheritedFieldStateCache.get(parentState) ?? (() => {
|
|
1342
|
+
const nextCaches = /* @__PURE__ */ new WeakMap();
|
|
1343
|
+
inheritedFieldStateCache.set(parentState, nextCaches);
|
|
1344
|
+
return nextCaches;
|
|
1345
|
+
})();
|
|
1346
|
+
return annotatorCaches.get(annotateChildState) ?? (() => {
|
|
1347
|
+
const stateCache = /* @__PURE__ */ new Map();
|
|
1348
|
+
annotatorCaches.set(annotateChildState, stateCache);
|
|
1349
|
+
return stateCache;
|
|
1350
|
+
})();
|
|
1340
1351
|
})() : void 0;
|
|
1341
1352
|
if (cache?.has(fieldKey)) return cache.get(fieldKey);
|
|
1342
1353
|
const sourceState = parentState != null && typeof parentState === "object" && fieldKey in parentState ? parentState[fieldKey] : parser.initialState;
|
|
@@ -1499,6 +1510,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1499
1510
|
parse(context) {
|
|
1500
1511
|
return require_mode_dispatch.dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
|
|
1501
1512
|
},
|
|
1513
|
+
getSuggestRuntimeNodes(state, path) {
|
|
1514
|
+
const stateRecord = state != null && typeof state === "object" ? state : objectParser.initialState;
|
|
1515
|
+
return buildSuggestRuntimeNodesFromPairs(parserPairs, stateRecord, path);
|
|
1516
|
+
},
|
|
1502
1517
|
complete(state, exec) {
|
|
1503
1518
|
return require_mode_dispatch.dispatchByMode(combinedMode, () => {
|
|
1504
1519
|
const runtime = exec?.dependencyRuntime ?? require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry);
|
|
@@ -1742,7 +1757,7 @@ async function* suggestTupleAsync(context, prefix, parsers) {
|
|
|
1742
1757
|
state: createAnnotatedArrayStateRecord(stateArray)
|
|
1743
1758
|
}, buildIndexedParserPairs(parsers), runtime.registry, advancedContext.exec);
|
|
1744
1759
|
}
|
|
1745
|
-
|
|
1760
|
+
await markFailedTupleSuggestSourcesAsync(parsers, stateArray, advanced.failedParserIndexes, runtime, advancedContext.exec?.path);
|
|
1746
1761
|
const contextWithRegistry = {
|
|
1747
1762
|
...advancedContext,
|
|
1748
1763
|
dependencyRegistry: runtime.registry,
|
|
@@ -1896,18 +1911,36 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
1896
1911
|
function markFailedTupleSuggestSources(parsers, stateArray, failedParserIndexes, runtime, parentPath) {
|
|
1897
1912
|
if (failedParserIndexes.length < 1) return;
|
|
1898
1913
|
const prefix = parentPath ?? [];
|
|
1899
|
-
const failedSourceIds = /* @__PURE__ */ new Set();
|
|
1900
1914
|
for (const index of failedParserIndexes) {
|
|
1901
1915
|
const parser = parsers[index];
|
|
1902
1916
|
if (parser == null) continue;
|
|
1903
1917
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
1904
1918
|
const nodes = require_parser.getParserSuggestRuntimeNodes(parser, getAnnotatedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
1919
|
+
if (nodes.length < 1) continue;
|
|
1920
|
+
const failedRuntime = require_dependency_runtime.createDependencyRuntimeContext();
|
|
1921
|
+
require_dependency_runtime.collectExplicitSourceValues(nodes, failedRuntime);
|
|
1922
|
+
for (const node of nodes) {
|
|
1923
|
+
const sourceId = node.parser.dependencyMetadata?.source?.sourceId;
|
|
1924
|
+
if (sourceId != null && failedRuntime.isSourceFailed(sourceId)) runtime.markSourceFailed(sourceId);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
async function markFailedTupleSuggestSourcesAsync(parsers, stateArray, failedParserIndexes, runtime, parentPath) {
|
|
1929
|
+
if (failedParserIndexes.length < 1) return;
|
|
1930
|
+
const prefix = parentPath ?? [];
|
|
1931
|
+
for (const index of failedParserIndexes) {
|
|
1932
|
+
const parser = parsers[index];
|
|
1933
|
+
if (parser == null) continue;
|
|
1934
|
+
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
1935
|
+
const nodes = require_parser.getParserSuggestRuntimeNodes(parser, getAnnotatedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
1936
|
+
if (nodes.length < 1) continue;
|
|
1937
|
+
const failedRuntime = require_dependency_runtime.createDependencyRuntimeContext();
|
|
1938
|
+
await require_dependency_runtime.collectExplicitSourceValuesAsync(nodes, failedRuntime);
|
|
1905
1939
|
for (const node of nodes) {
|
|
1906
1940
|
const sourceId = node.parser.dependencyMetadata?.source?.sourceId;
|
|
1907
|
-
if (sourceId != null)
|
|
1941
|
+
if (sourceId != null && failedRuntime.isSourceFailed(sourceId)) runtime.markSourceFailed(sourceId);
|
|
1908
1942
|
}
|
|
1909
1943
|
}
|
|
1910
|
-
for (const sourceId of failedSourceIds) runtime.markSourceFailed(sourceId);
|
|
1911
1944
|
}
|
|
1912
1945
|
function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
1913
1946
|
const label = typeof labelOrParsers === "string" ? labelOrParsers : void 0;
|
|
@@ -2306,7 +2339,7 @@ function merge(...args) {
|
|
|
2306
2339
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
2307
2340
|
const parser = syncParsers[i];
|
|
2308
2341
|
const parserState = extractParserState(parser, currentContext, i);
|
|
2309
|
-
const result = parser.parse(withChildContext(currentContext, i, parserState));
|
|
2342
|
+
const result = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
2310
2343
|
if (result.success) {
|
|
2311
2344
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2312
2345
|
const newState = mergeResultState(parser, currentContext, parserState, result, i);
|
|
@@ -2351,7 +2384,7 @@ function merge(...args) {
|
|
|
2351
2384
|
for (let i = 0; i < parsers.length; i++) {
|
|
2352
2385
|
const parser = parsers[i];
|
|
2353
2386
|
const parserState = extractParserState(parser, currentContext, i);
|
|
2354
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, i, parserState));
|
|
2387
|
+
const resultOrPromise = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
2355
2388
|
const result = await resultOrPromise;
|
|
2356
2389
|
if (result.success) {
|
|
2357
2390
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2600,7 +2633,7 @@ function merge(...args) {
|
|
|
2600
2633
|
for (let i = 0; i < parsers.length; i++) {
|
|
2601
2634
|
const parser = parsers[i];
|
|
2602
2635
|
const parserState = extractState(parser, i);
|
|
2603
|
-
const childContext = withChildContext(contextWithRegistry$1, i, parserState);
|
|
2636
|
+
const childContext = withChildContext(contextWithRegistry$1, i, parserState, parser);
|
|
2604
2637
|
const excludedSourceFields = perChildExcludedSourceFields$1[i];
|
|
2605
2638
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
2606
2639
|
const childRuntime = require_dependency_runtime.createDependencyRuntimeContext(runtime$1.registry.clone());
|
|
@@ -2641,7 +2674,7 @@ function merge(...args) {
|
|
|
2641
2674
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
2642
2675
|
const parser = syncParsers[i];
|
|
2643
2676
|
const parserState = extractState(parser, i);
|
|
2644
|
-
const childContext = withChildContext(contextWithRegistry, i, parserState);
|
|
2677
|
+
const childContext = withChildContext(contextWithRegistry, i, parserState, parser);
|
|
2645
2678
|
const excludedSourceFields = perChildExcludedSourceFields[i];
|
|
2646
2679
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
2647
2680
|
const childRuntime = require_dependency_runtime.createDependencyRuntimeContext(runtime.registry.clone());
|
|
@@ -3434,7 +3467,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3434
3467
|
...branchResult.next,
|
|
3435
3468
|
state: {
|
|
3436
3469
|
...state,
|
|
3437
|
-
branchState: branchResult.next.state
|
|
3470
|
+
branchState: getAnnotatedChildState(state, branchResult.next.state, branchParser)
|
|
3438
3471
|
},
|
|
3439
3472
|
...mergedExec != null ? {
|
|
3440
3473
|
exec: mergedExec,
|
|
@@ -3478,7 +3511,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3478
3511
|
kind: "branch",
|
|
3479
3512
|
key: value
|
|
3480
3513
|
},
|
|
3481
|
-
branchState: branchParseResult.next.state
|
|
3514
|
+
branchState: getAnnotatedChildState(state, branchParseResult.next.state, branchParser)
|
|
3482
3515
|
},
|
|
3483
3516
|
...mergedExec != null ? {
|
|
3484
3517
|
exec: mergedExec,
|
|
@@ -3499,7 +3532,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3499
3532
|
kind: "branch",
|
|
3500
3533
|
key: value
|
|
3501
3534
|
},
|
|
3502
|
-
branchState: branchParser.initialState
|
|
3535
|
+
branchState: getAnnotatedChildState(state, branchParser.initialState, branchParser)
|
|
3503
3536
|
},
|
|
3504
3537
|
...discriminatorExec != null ? {
|
|
3505
3538
|
exec: discriminatorExec,
|
|
@@ -3522,7 +3555,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3522
3555
|
state: {
|
|
3523
3556
|
...state,
|
|
3524
3557
|
selectedBranch: { kind: "default" },
|
|
3525
|
-
branchState: defaultResult.next.state
|
|
3558
|
+
branchState: getAnnotatedChildState(state, defaultResult.next.state, syncDefaultBranch)
|
|
3526
3559
|
},
|
|
3527
3560
|
...mergedExec != null ? {
|
|
3528
3561
|
exec: mergedExec,
|
|
@@ -3552,7 +3585,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3552
3585
|
...branchResult.next,
|
|
3553
3586
|
state: {
|
|
3554
3587
|
...state,
|
|
3555
|
-
branchState: branchResult.next.state
|
|
3588
|
+
branchState: getAnnotatedChildState(state, branchResult.next.state, branchParser)
|
|
3556
3589
|
},
|
|
3557
3590
|
...mergedExec != null ? {
|
|
3558
3591
|
exec: mergedExec,
|
|
@@ -3596,7 +3629,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3596
3629
|
kind: "branch",
|
|
3597
3630
|
key: value
|
|
3598
3631
|
},
|
|
3599
|
-
branchState: branchParseResult.next.state
|
|
3632
|
+
branchState: getAnnotatedChildState(state, branchParseResult.next.state, branchParser)
|
|
3600
3633
|
},
|
|
3601
3634
|
...mergedExec != null ? {
|
|
3602
3635
|
exec: mergedExec,
|
|
@@ -3617,7 +3650,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3617
3650
|
kind: "branch",
|
|
3618
3651
|
key: value
|
|
3619
3652
|
},
|
|
3620
|
-
branchState: branchParser.initialState
|
|
3653
|
+
branchState: getAnnotatedChildState(state, branchParser.initialState, branchParser)
|
|
3621
3654
|
},
|
|
3622
3655
|
...discriminatorExec != null ? {
|
|
3623
3656
|
exec: discriminatorExec,
|
|
@@ -3640,7 +3673,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3640
3673
|
state: {
|
|
3641
3674
|
...state,
|
|
3642
3675
|
selectedBranch: { kind: "default" },
|
|
3643
|
-
branchState: defaultResult.next.state
|
|
3676
|
+
branchState: getAnnotatedChildState(state, defaultResult.next.state, defaultBranch)
|
|
3644
3677
|
},
|
|
3645
3678
|
...mergedExec != null ? {
|
|
3646
3679
|
exec: mergedExec,
|
|
@@ -3663,7 +3696,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3663
3696
|
const syncBranches = branches;
|
|
3664
3697
|
if (state.selectedBranch === void 0) {
|
|
3665
3698
|
if (syncDefaultBranch !== void 0) {
|
|
3666
|
-
const branchState = state.branchState ?? syncDefaultBranch.initialState;
|
|
3699
|
+
const branchState = getAnnotatedChildState(state, state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch);
|
|
3667
3700
|
const defaultResult = unwrapCompleteResult(syncDefaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
3668
3701
|
if (!defaultResult.success) return defaultResult;
|
|
3669
3702
|
return {
|
|
@@ -3683,12 +3716,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3683
3716
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
3684
3717
|
const combinedState = {
|
|
3685
3718
|
_discriminator: state.discriminatorState,
|
|
3686
|
-
_branch: state.branchState
|
|
3719
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3687
3720
|
};
|
|
3688
3721
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
3689
3722
|
require_dependency_runtime.collectExplicitSourceValues(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
3690
3723
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
3691
|
-
const resolvedBranchState = require_dependency_runtime.resolveStateWithRuntime(state.branchState, runtime);
|
|
3724
|
+
const resolvedBranchState = getAnnotatedChildState(state, require_dependency_runtime.resolveStateWithRuntime(state.branchState, runtime), branchParser);
|
|
3692
3725
|
const completionExec = {
|
|
3693
3726
|
...exec ?? {
|
|
3694
3727
|
usage: branchParser.usage,
|
|
@@ -3726,7 +3759,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3726
3759
|
const completeAsync = async (state, exec) => {
|
|
3727
3760
|
if (state.selectedBranch === void 0) {
|
|
3728
3761
|
if (defaultBranch !== void 0) {
|
|
3729
|
-
const branchState = state.branchState ?? defaultBranch.initialState;
|
|
3762
|
+
const branchState = getAnnotatedChildState(state, state.branchState ?? defaultBranch.initialState, defaultBranch);
|
|
3730
3763
|
const defaultResult = unwrapCompleteResult(await defaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
3731
3764
|
if (!defaultResult.success) return defaultResult;
|
|
3732
3765
|
return {
|
|
@@ -3746,12 +3779,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3746
3779
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
3747
3780
|
const combinedState = {
|
|
3748
3781
|
_discriminator: state.discriminatorState,
|
|
3749
|
-
_branch: state.branchState
|
|
3782
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3750
3783
|
};
|
|
3751
3784
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
3752
3785
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
3753
3786
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
3754
|
-
const resolvedBranchState = await require_dependency_runtime.resolveStateWithRuntimeAsync(state.branchState, runtime);
|
|
3787
|
+
const resolvedBranchState = getAnnotatedChildState(state, await require_dependency_runtime.resolveStateWithRuntimeAsync(state.branchState, runtime), branchParser);
|
|
3755
3788
|
const completionExec = {
|
|
3756
3789
|
...exec ?? {
|
|
3757
3790
|
usage: branchParser.usage,
|
|
@@ -3793,14 +3826,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3793
3826
|
const syncDefaultBranch = defaultBranch;
|
|
3794
3827
|
if (state.selectedBranch === void 0) {
|
|
3795
3828
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3796
|
-
|
|
3797
|
-
_discriminator: state.discriminatorState,
|
|
3798
|
-
_branch: state.branchState
|
|
3799
|
-
}, context.exec?.path), runtime);
|
|
3800
|
-
require_dependency_runtime.collectSourcesFromState({
|
|
3829
|
+
const defaultCombinedState = {
|
|
3801
3830
|
_discriminator: state.discriminatorState,
|
|
3802
|
-
_branch: state.branchState
|
|
3803
|
-
}
|
|
3831
|
+
_branch: syncDefaultBranch == null ? state.branchState : getAnnotatedChildState(state, state.branchState, syncDefaultBranch)
|
|
3832
|
+
};
|
|
3833
|
+
require_dependency_runtime.collectExplicitSourceValues(require_dependency_runtime.buildRuntimeNodesFromPairs(syncDefaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", syncDefaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
3834
|
+
require_dependency_runtime.collectSourcesFromState(defaultCombinedState, runtime);
|
|
3804
3835
|
const suggestContext = {
|
|
3805
3836
|
...context,
|
|
3806
3837
|
dependencyRegistry: runtime.registry,
|
|
@@ -3811,13 +3842,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3811
3842
|
} } : {}
|
|
3812
3843
|
};
|
|
3813
3844
|
yield* syncDiscriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState), prefix);
|
|
3814
|
-
if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState), prefix);
|
|
3845
|
+
if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
3815
3846
|
} else {
|
|
3816
3847
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
3817
3848
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3818
3849
|
const combinedState = {
|
|
3819
3850
|
_discriminator: state.discriminatorState,
|
|
3820
|
-
_branch: state.branchState
|
|
3851
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3821
3852
|
};
|
|
3822
3853
|
require_dependency_runtime.collectExplicitSourceValues(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
3823
3854
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
@@ -3830,21 +3861,19 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3830
3861
|
dependencyRegistry: runtime.registry
|
|
3831
3862
|
} } : {}
|
|
3832
3863
|
};
|
|
3833
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState), prefix);
|
|
3864
|
+
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
3834
3865
|
}
|
|
3835
3866
|
}
|
|
3836
3867
|
async function* suggestAsync(context, prefix) {
|
|
3837
3868
|
const state = context.state ?? initialState;
|
|
3838
3869
|
if (state.selectedBranch === void 0) {
|
|
3839
3870
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3840
|
-
|
|
3871
|
+
const defaultCombinedState = {
|
|
3841
3872
|
_discriminator: state.discriminatorState,
|
|
3842
|
-
_branch: state.branchState
|
|
3843
|
-
}
|
|
3844
|
-
require_dependency_runtime.
|
|
3845
|
-
|
|
3846
|
-
_branch: state.branchState
|
|
3847
|
-
}, runtime);
|
|
3873
|
+
_branch: defaultBranch == null ? state.branchState : getAnnotatedChildState(state, state.branchState, defaultBranch)
|
|
3874
|
+
};
|
|
3875
|
+
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs(defaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", defaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
3876
|
+
require_dependency_runtime.collectSourcesFromState(defaultCombinedState, runtime);
|
|
3848
3877
|
const suggestContext = {
|
|
3849
3878
|
...context,
|
|
3850
3879
|
dependencyRegistry: runtime.registry,
|
|
@@ -3855,13 +3884,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3855
3884
|
} } : {}
|
|
3856
3885
|
};
|
|
3857
3886
|
yield* discriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState), prefix);
|
|
3858
|
-
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState), prefix);
|
|
3887
|
+
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
3859
3888
|
} else {
|
|
3860
3889
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
3861
3890
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3862
3891
|
const combinedState = {
|
|
3863
3892
|
_discriminator: state.discriminatorState,
|
|
3864
|
-
_branch: state.branchState
|
|
3893
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3865
3894
|
};
|
|
3866
3895
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
3867
3896
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
@@ -3874,7 +3903,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3874
3903
|
dependencyRegistry: runtime.registry
|
|
3875
3904
|
} } : {}
|
|
3876
3905
|
};
|
|
3877
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState), prefix);
|
|
3906
|
+
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
3878
3907
|
}
|
|
3879
3908
|
}
|
|
3880
3909
|
const conditionalParser = {
|
package/dist/constructs.js
CHANGED
|
@@ -158,7 +158,11 @@ function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()
|
|
|
158
158
|
changed$1 = true;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
if (!changed$1) {
|
|
162
|
+
seen.set(source, source);
|
|
163
|
+
return source;
|
|
164
|
+
}
|
|
165
|
+
return clone$1;
|
|
162
166
|
}
|
|
163
167
|
const proto = Object.getPrototypeOf(source);
|
|
164
168
|
if (proto !== Object.prototype && proto !== null) return source;
|
|
@@ -986,15 +990,15 @@ function* suggestObjectSync(context, prefix, parserPairs) {
|
|
|
986
990
|
if (context.buffer.length > 0) {
|
|
987
991
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
988
992
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
989
|
-
const
|
|
990
|
-
yield* parser.suggest(withChildContext(contextWithRegistry, field,
|
|
993
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
994
|
+
yield* parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
991
995
|
return;
|
|
992
996
|
}
|
|
993
997
|
}
|
|
994
998
|
const suggestions = [];
|
|
995
999
|
for (const [field, parser] of parserPairs) {
|
|
996
|
-
const
|
|
997
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field,
|
|
1000
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1001
|
+
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
998
1002
|
suggestions.push(...fieldSuggestions);
|
|
999
1003
|
}
|
|
1000
1004
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -1022,16 +1026,16 @@ async function* suggestObjectAsync(context, prefix, parserPairs) {
|
|
|
1022
1026
|
if (context.buffer.length > 0) {
|
|
1023
1027
|
const lastToken = context.buffer[context.buffer.length - 1];
|
|
1024
1028
|
for (const [field, parser] of parserPairs) if (isOptionRequiringValue(parser.usage, lastToken)) {
|
|
1025
|
-
const
|
|
1026
|
-
const suggestions$1 = parser.suggest(withChildContext(contextWithRegistry, field,
|
|
1029
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1030
|
+
const suggestions$1 = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1027
1031
|
for await (const s of suggestions$1) yield s;
|
|
1028
1032
|
return;
|
|
1029
1033
|
}
|
|
1030
1034
|
}
|
|
1031
1035
|
const suggestions = [];
|
|
1032
1036
|
for (const [field, parser] of parserPairs) {
|
|
1033
|
-
const
|
|
1034
|
-
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field,
|
|
1037
|
+
const annotatedFieldState = getAnnotatedFieldState(context.state, field, parser);
|
|
1038
|
+
const fieldSuggestions = parser.suggest(withChildContext(contextWithRegistry, field, annotatedFieldState, parser), prefix);
|
|
1035
1039
|
for await (const s of fieldSuggestions) suggestions.push(s);
|
|
1036
1040
|
}
|
|
1037
1041
|
yield* deduplicateSuggestions(suggestions);
|
|
@@ -1333,10 +1337,17 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1333
1337
|
const createFieldStateGetter = (parentState, annotateChildState = getAnnotatedChildState) => {
|
|
1334
1338
|
return (field, parser) => {
|
|
1335
1339
|
const fieldKey = field;
|
|
1336
|
-
const cache = parentState != null && typeof parentState === "object" ?
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
+
const cache = parentState != null && typeof parentState === "object" ? (() => {
|
|
1341
|
+
const annotatorCaches = inheritedFieldStateCache.get(parentState) ?? (() => {
|
|
1342
|
+
const nextCaches = /* @__PURE__ */ new WeakMap();
|
|
1343
|
+
inheritedFieldStateCache.set(parentState, nextCaches);
|
|
1344
|
+
return nextCaches;
|
|
1345
|
+
})();
|
|
1346
|
+
return annotatorCaches.get(annotateChildState) ?? (() => {
|
|
1347
|
+
const stateCache = /* @__PURE__ */ new Map();
|
|
1348
|
+
annotatorCaches.set(annotateChildState, stateCache);
|
|
1349
|
+
return stateCache;
|
|
1350
|
+
})();
|
|
1340
1351
|
})() : void 0;
|
|
1341
1352
|
if (cache?.has(fieldKey)) return cache.get(fieldKey);
|
|
1342
1353
|
const sourceState = parentState != null && typeof parentState === "object" && fieldKey in parentState ? parentState[fieldKey] : parser.initialState;
|
|
@@ -1499,6 +1510,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1499
1510
|
parse(context) {
|
|
1500
1511
|
return dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
|
|
1501
1512
|
},
|
|
1513
|
+
getSuggestRuntimeNodes(state, path) {
|
|
1514
|
+
const stateRecord = state != null && typeof state === "object" ? state : objectParser.initialState;
|
|
1515
|
+
return buildSuggestRuntimeNodesFromPairs(parserPairs, stateRecord, path);
|
|
1516
|
+
},
|
|
1502
1517
|
complete(state, exec) {
|
|
1503
1518
|
return dispatchByMode(combinedMode, () => {
|
|
1504
1519
|
const runtime = exec?.dependencyRuntime ?? createDependencyRuntimeContext(exec?.dependencyRegistry);
|
|
@@ -1742,7 +1757,7 @@ async function* suggestTupleAsync(context, prefix, parsers) {
|
|
|
1742
1757
|
state: createAnnotatedArrayStateRecord(stateArray)
|
|
1743
1758
|
}, buildIndexedParserPairs(parsers), runtime.registry, advancedContext.exec);
|
|
1744
1759
|
}
|
|
1745
|
-
|
|
1760
|
+
await markFailedTupleSuggestSourcesAsync(parsers, stateArray, advanced.failedParserIndexes, runtime, advancedContext.exec?.path);
|
|
1746
1761
|
const contextWithRegistry = {
|
|
1747
1762
|
...advancedContext,
|
|
1748
1763
|
dependencyRegistry: runtime.registry,
|
|
@@ -1896,18 +1911,36 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
1896
1911
|
function markFailedTupleSuggestSources(parsers, stateArray, failedParserIndexes, runtime, parentPath) {
|
|
1897
1912
|
if (failedParserIndexes.length < 1) return;
|
|
1898
1913
|
const prefix = parentPath ?? [];
|
|
1899
|
-
const failedSourceIds = /* @__PURE__ */ new Set();
|
|
1900
1914
|
for (const index of failedParserIndexes) {
|
|
1901
1915
|
const parser = parsers[index];
|
|
1902
1916
|
if (parser == null) continue;
|
|
1903
1917
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
1904
1918
|
const nodes = getParserSuggestRuntimeNodes(parser, getAnnotatedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
1919
|
+
if (nodes.length < 1) continue;
|
|
1920
|
+
const failedRuntime = createDependencyRuntimeContext();
|
|
1921
|
+
collectExplicitSourceValues(nodes, failedRuntime);
|
|
1922
|
+
for (const node of nodes) {
|
|
1923
|
+
const sourceId = node.parser.dependencyMetadata?.source?.sourceId;
|
|
1924
|
+
if (sourceId != null && failedRuntime.isSourceFailed(sourceId)) runtime.markSourceFailed(sourceId);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
async function markFailedTupleSuggestSourcesAsync(parsers, stateArray, failedParserIndexes, runtime, parentPath) {
|
|
1929
|
+
if (failedParserIndexes.length < 1) return;
|
|
1930
|
+
const prefix = parentPath ?? [];
|
|
1931
|
+
for (const index of failedParserIndexes) {
|
|
1932
|
+
const parser = parsers[index];
|
|
1933
|
+
if (parser == null) continue;
|
|
1934
|
+
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
1935
|
+
const nodes = getParserSuggestRuntimeNodes(parser, getAnnotatedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
1936
|
+
if (nodes.length < 1) continue;
|
|
1937
|
+
const failedRuntime = createDependencyRuntimeContext();
|
|
1938
|
+
await collectExplicitSourceValuesAsync(nodes, failedRuntime);
|
|
1905
1939
|
for (const node of nodes) {
|
|
1906
1940
|
const sourceId = node.parser.dependencyMetadata?.source?.sourceId;
|
|
1907
|
-
if (sourceId != null)
|
|
1941
|
+
if (sourceId != null && failedRuntime.isSourceFailed(sourceId)) runtime.markSourceFailed(sourceId);
|
|
1908
1942
|
}
|
|
1909
1943
|
}
|
|
1910
|
-
for (const sourceId of failedSourceIds) runtime.markSourceFailed(sourceId);
|
|
1911
1944
|
}
|
|
1912
1945
|
function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
1913
1946
|
const label = typeof labelOrParsers === "string" ? labelOrParsers : void 0;
|
|
@@ -2306,7 +2339,7 @@ function merge(...args) {
|
|
|
2306
2339
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
2307
2340
|
const parser = syncParsers[i];
|
|
2308
2341
|
const parserState = extractParserState(parser, currentContext, i);
|
|
2309
|
-
const result = parser.parse(withChildContext(currentContext, i, parserState));
|
|
2342
|
+
const result = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
2310
2343
|
if (result.success) {
|
|
2311
2344
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2312
2345
|
const newState = mergeResultState(parser, currentContext, parserState, result, i);
|
|
@@ -2351,7 +2384,7 @@ function merge(...args) {
|
|
|
2351
2384
|
for (let i = 0; i < parsers.length; i++) {
|
|
2352
2385
|
const parser = parsers[i];
|
|
2353
2386
|
const parserState = extractParserState(parser, currentContext, i);
|
|
2354
|
-
const resultOrPromise = parser.parse(withChildContext(currentContext, i, parserState));
|
|
2387
|
+
const resultOrPromise = parser.parse(withChildContext(currentContext, i, parserState, parser));
|
|
2355
2388
|
const result = await resultOrPromise;
|
|
2356
2389
|
if (result.success) {
|
|
2357
2390
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -2600,7 +2633,7 @@ function merge(...args) {
|
|
|
2600
2633
|
for (let i = 0; i < parsers.length; i++) {
|
|
2601
2634
|
const parser = parsers[i];
|
|
2602
2635
|
const parserState = extractState(parser, i);
|
|
2603
|
-
const childContext = withChildContext(contextWithRegistry$1, i, parserState);
|
|
2636
|
+
const childContext = withChildContext(contextWithRegistry$1, i, parserState, parser);
|
|
2604
2637
|
const excludedSourceFields = perChildExcludedSourceFields$1[i];
|
|
2605
2638
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
2606
2639
|
const childRuntime = createDependencyRuntimeContext(runtime$1.registry.clone());
|
|
@@ -2641,7 +2674,7 @@ function merge(...args) {
|
|
|
2641
2674
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
2642
2675
|
const parser = syncParsers[i];
|
|
2643
2676
|
const parserState = extractState(parser, i);
|
|
2644
|
-
const childContext = withChildContext(contextWithRegistry, i, parserState);
|
|
2677
|
+
const childContext = withChildContext(contextWithRegistry, i, parserState, parser);
|
|
2645
2678
|
const excludedSourceFields = perChildExcludedSourceFields[i];
|
|
2646
2679
|
const contextForChild = excludedSourceFields == null ? childContext : (() => {
|
|
2647
2680
|
const childRuntime = createDependencyRuntimeContext(runtime.registry.clone());
|
|
@@ -3434,7 +3467,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3434
3467
|
...branchResult.next,
|
|
3435
3468
|
state: {
|
|
3436
3469
|
...state,
|
|
3437
|
-
branchState: branchResult.next.state
|
|
3470
|
+
branchState: getAnnotatedChildState(state, branchResult.next.state, branchParser)
|
|
3438
3471
|
},
|
|
3439
3472
|
...mergedExec != null ? {
|
|
3440
3473
|
exec: mergedExec,
|
|
@@ -3478,7 +3511,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3478
3511
|
kind: "branch",
|
|
3479
3512
|
key: value
|
|
3480
3513
|
},
|
|
3481
|
-
branchState: branchParseResult.next.state
|
|
3514
|
+
branchState: getAnnotatedChildState(state, branchParseResult.next.state, branchParser)
|
|
3482
3515
|
},
|
|
3483
3516
|
...mergedExec != null ? {
|
|
3484
3517
|
exec: mergedExec,
|
|
@@ -3499,7 +3532,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3499
3532
|
kind: "branch",
|
|
3500
3533
|
key: value
|
|
3501
3534
|
},
|
|
3502
|
-
branchState: branchParser.initialState
|
|
3535
|
+
branchState: getAnnotatedChildState(state, branchParser.initialState, branchParser)
|
|
3503
3536
|
},
|
|
3504
3537
|
...discriminatorExec != null ? {
|
|
3505
3538
|
exec: discriminatorExec,
|
|
@@ -3522,7 +3555,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3522
3555
|
state: {
|
|
3523
3556
|
...state,
|
|
3524
3557
|
selectedBranch: { kind: "default" },
|
|
3525
|
-
branchState: defaultResult.next.state
|
|
3558
|
+
branchState: getAnnotatedChildState(state, defaultResult.next.state, syncDefaultBranch)
|
|
3526
3559
|
},
|
|
3527
3560
|
...mergedExec != null ? {
|
|
3528
3561
|
exec: mergedExec,
|
|
@@ -3552,7 +3585,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3552
3585
|
...branchResult.next,
|
|
3553
3586
|
state: {
|
|
3554
3587
|
...state,
|
|
3555
|
-
branchState: branchResult.next.state
|
|
3588
|
+
branchState: getAnnotatedChildState(state, branchResult.next.state, branchParser)
|
|
3556
3589
|
},
|
|
3557
3590
|
...mergedExec != null ? {
|
|
3558
3591
|
exec: mergedExec,
|
|
@@ -3596,7 +3629,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3596
3629
|
kind: "branch",
|
|
3597
3630
|
key: value
|
|
3598
3631
|
},
|
|
3599
|
-
branchState: branchParseResult.next.state
|
|
3632
|
+
branchState: getAnnotatedChildState(state, branchParseResult.next.state, branchParser)
|
|
3600
3633
|
},
|
|
3601
3634
|
...mergedExec != null ? {
|
|
3602
3635
|
exec: mergedExec,
|
|
@@ -3617,7 +3650,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3617
3650
|
kind: "branch",
|
|
3618
3651
|
key: value
|
|
3619
3652
|
},
|
|
3620
|
-
branchState: branchParser.initialState
|
|
3653
|
+
branchState: getAnnotatedChildState(state, branchParser.initialState, branchParser)
|
|
3621
3654
|
},
|
|
3622
3655
|
...discriminatorExec != null ? {
|
|
3623
3656
|
exec: discriminatorExec,
|
|
@@ -3640,7 +3673,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3640
3673
|
state: {
|
|
3641
3674
|
...state,
|
|
3642
3675
|
selectedBranch: { kind: "default" },
|
|
3643
|
-
branchState: defaultResult.next.state
|
|
3676
|
+
branchState: getAnnotatedChildState(state, defaultResult.next.state, defaultBranch)
|
|
3644
3677
|
},
|
|
3645
3678
|
...mergedExec != null ? {
|
|
3646
3679
|
exec: mergedExec,
|
|
@@ -3663,7 +3696,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3663
3696
|
const syncBranches = branches;
|
|
3664
3697
|
if (state.selectedBranch === void 0) {
|
|
3665
3698
|
if (syncDefaultBranch !== void 0) {
|
|
3666
|
-
const branchState = state.branchState ?? syncDefaultBranch.initialState;
|
|
3699
|
+
const branchState = getAnnotatedChildState(state, state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch);
|
|
3667
3700
|
const defaultResult = unwrapCompleteResult(syncDefaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
3668
3701
|
if (!defaultResult.success) return defaultResult;
|
|
3669
3702
|
return {
|
|
@@ -3683,12 +3716,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3683
3716
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
3684
3717
|
const combinedState = {
|
|
3685
3718
|
_discriminator: state.discriminatorState,
|
|
3686
|
-
_branch: state.branchState
|
|
3719
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3687
3720
|
};
|
|
3688
3721
|
const runtime = createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
3689
3722
|
collectExplicitSourceValues(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
3690
3723
|
collectSourcesFromState(combinedState, runtime);
|
|
3691
|
-
const resolvedBranchState = resolveStateWithRuntime(state.branchState, runtime);
|
|
3724
|
+
const resolvedBranchState = getAnnotatedChildState(state, resolveStateWithRuntime(state.branchState, runtime), branchParser);
|
|
3692
3725
|
const completionExec = {
|
|
3693
3726
|
...exec ?? {
|
|
3694
3727
|
usage: branchParser.usage,
|
|
@@ -3726,7 +3759,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3726
3759
|
const completeAsync = async (state, exec) => {
|
|
3727
3760
|
if (state.selectedBranch === void 0) {
|
|
3728
3761
|
if (defaultBranch !== void 0) {
|
|
3729
|
-
const branchState = state.branchState ?? defaultBranch.initialState;
|
|
3762
|
+
const branchState = getAnnotatedChildState(state, state.branchState ?? defaultBranch.initialState, defaultBranch);
|
|
3730
3763
|
const defaultResult = unwrapCompleteResult(await defaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
3731
3764
|
if (!defaultResult.success) return defaultResult;
|
|
3732
3765
|
return {
|
|
@@ -3746,12 +3779,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3746
3779
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
3747
3780
|
const combinedState = {
|
|
3748
3781
|
_discriminator: state.discriminatorState,
|
|
3749
|
-
_branch: state.branchState
|
|
3782
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3750
3783
|
};
|
|
3751
3784
|
const runtime = createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
3752
3785
|
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
3753
3786
|
collectSourcesFromState(combinedState, runtime);
|
|
3754
|
-
const resolvedBranchState = await resolveStateWithRuntimeAsync(state.branchState, runtime);
|
|
3787
|
+
const resolvedBranchState = getAnnotatedChildState(state, await resolveStateWithRuntimeAsync(state.branchState, runtime), branchParser);
|
|
3755
3788
|
const completionExec = {
|
|
3756
3789
|
...exec ?? {
|
|
3757
3790
|
usage: branchParser.usage,
|
|
@@ -3793,14 +3826,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3793
3826
|
const syncDefaultBranch = defaultBranch;
|
|
3794
3827
|
if (state.selectedBranch === void 0) {
|
|
3795
3828
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3796
|
-
|
|
3797
|
-
_discriminator: state.discriminatorState,
|
|
3798
|
-
_branch: state.branchState
|
|
3799
|
-
}, context.exec?.path), runtime);
|
|
3800
|
-
collectSourcesFromState({
|
|
3829
|
+
const defaultCombinedState = {
|
|
3801
3830
|
_discriminator: state.discriminatorState,
|
|
3802
|
-
_branch: state.branchState
|
|
3803
|
-
}
|
|
3831
|
+
_branch: syncDefaultBranch == null ? state.branchState : getAnnotatedChildState(state, state.branchState, syncDefaultBranch)
|
|
3832
|
+
};
|
|
3833
|
+
collectExplicitSourceValues(buildRuntimeNodesFromPairs(syncDefaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", syncDefaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
3834
|
+
collectSourcesFromState(defaultCombinedState, runtime);
|
|
3804
3835
|
const suggestContext = {
|
|
3805
3836
|
...context,
|
|
3806
3837
|
dependencyRegistry: runtime.registry,
|
|
@@ -3811,13 +3842,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3811
3842
|
} } : {}
|
|
3812
3843
|
};
|
|
3813
3844
|
yield* syncDiscriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState), prefix);
|
|
3814
|
-
if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState), prefix);
|
|
3845
|
+
if (syncDefaultBranch !== void 0) yield* syncDefaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
3815
3846
|
} else {
|
|
3816
3847
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
3817
3848
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3818
3849
|
const combinedState = {
|
|
3819
3850
|
_discriminator: state.discriminatorState,
|
|
3820
|
-
_branch: state.branchState
|
|
3851
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3821
3852
|
};
|
|
3822
3853
|
collectExplicitSourceValues(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
3823
3854
|
collectSourcesFromState(combinedState, runtime);
|
|
@@ -3830,21 +3861,19 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3830
3861
|
dependencyRegistry: runtime.registry
|
|
3831
3862
|
} } : {}
|
|
3832
3863
|
};
|
|
3833
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState), prefix);
|
|
3864
|
+
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
3834
3865
|
}
|
|
3835
3866
|
}
|
|
3836
3867
|
async function* suggestAsync(context, prefix) {
|
|
3837
3868
|
const state = context.state ?? initialState;
|
|
3838
3869
|
if (state.selectedBranch === void 0) {
|
|
3839
3870
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3840
|
-
|
|
3871
|
+
const defaultCombinedState = {
|
|
3841
3872
|
_discriminator: state.discriminatorState,
|
|
3842
|
-
_branch: state.branchState
|
|
3843
|
-
}
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
_branch: state.branchState
|
|
3847
|
-
}, runtime);
|
|
3873
|
+
_branch: defaultBranch == null ? state.branchState : getAnnotatedChildState(state, state.branchState, defaultBranch)
|
|
3874
|
+
};
|
|
3875
|
+
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs(defaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", defaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
3876
|
+
collectSourcesFromState(defaultCombinedState, runtime);
|
|
3848
3877
|
const suggestContext = {
|
|
3849
3878
|
...context,
|
|
3850
3879
|
dependencyRegistry: runtime.registry,
|
|
@@ -3855,13 +3884,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3855
3884
|
} } : {}
|
|
3856
3885
|
};
|
|
3857
3886
|
yield* discriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState), prefix);
|
|
3858
|
-
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState), prefix);
|
|
3887
|
+
if (defaultBranch !== void 0) yield* defaultBranch.suggest(withChildContext(suggestContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
3859
3888
|
} else {
|
|
3860
3889
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
3861
3890
|
const runtime = createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
3862
3891
|
const combinedState = {
|
|
3863
3892
|
_discriminator: state.discriminatorState,
|
|
3864
|
-
_branch: state.branchState
|
|
3893
|
+
_branch: getAnnotatedChildState(state, state.branchState, branchParser)
|
|
3865
3894
|
};
|
|
3866
3895
|
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
3867
3896
|
collectSourcesFromState(combinedState, runtime);
|
|
@@ -3874,7 +3903,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3874
3903
|
dependencyRegistry: runtime.registry
|
|
3875
3904
|
} } : {}
|
|
3876
3905
|
};
|
|
3877
|
-
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState), prefix);
|
|
3906
|
+
yield* branchParser.suggest(withChildContext(suggestContext, "_branch", state.branchState, branchParser), prefix);
|
|
3878
3907
|
}
|
|
3879
3908
|
}
|
|
3880
3909
|
const conditionalParser = {
|