@optique/core 1.0.0-dev.1786 → 1.0.0-dev.1787
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotation-state.cjs +100 -0
- package/dist/annotation-state.js +95 -0
- package/dist/constructs.cjs +83 -128
- package/dist/constructs.js +82 -127
- package/dist/facade.cjs +1 -1
- package/dist/facade.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.js +1 -1
- package/dist/primitives.cjs +59 -38
- package/dist/primitives.js +59 -38
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
const require_annotations = require('./annotations.cjs');
|
|
2
2
|
const require_message = require('./message.cjs');
|
|
3
|
-
const require_dependency = require('./dependency.cjs');
|
|
4
3
|
const require_validate = require('./validate.cjs');
|
|
5
4
|
const require_usage = require('./usage.cjs');
|
|
6
5
|
const require_doc = require('./doc.cjs');
|
|
7
6
|
const require_mode_dispatch = require('./mode-dispatch.cjs');
|
|
7
|
+
const require_dependency = require('./dependency.cjs');
|
|
8
|
+
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
8
9
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
9
10
|
const require_suggestion = require('./suggestion.cjs');
|
|
10
11
|
const require_usage_internals = require('./usage-internals.cjs');
|
|
11
12
|
const require_parser = require('./parser.cjs');
|
|
12
|
-
const
|
|
13
|
+
const require_annotation_state = require('./annotation-state.cjs');
|
|
13
14
|
|
|
14
15
|
//#region src/constructs.ts
|
|
15
16
|
/**
|
|
@@ -57,7 +58,7 @@ function mergeChildExec(parent, child) {
|
|
|
57
58
|
function withChildContext(context, segment, state, parser, usage) {
|
|
58
59
|
const exec = withChildExecPath(context.exec, segment);
|
|
59
60
|
const dependencyRegistry = context.dependencyRegistry ?? exec?.dependencyRegistry;
|
|
60
|
-
const childState = parser == null ? state :
|
|
61
|
+
const childState = parser == null ? state : require_annotation_state.getWrappedChildParseState(context.state, state, parser);
|
|
61
62
|
return {
|
|
62
63
|
...context,
|
|
63
64
|
state: childState,
|
|
@@ -139,15 +140,11 @@ const fieldParsersKey = Symbol("fieldParsers");
|
|
|
139
140
|
* to consume results from parsers that still return `DependencySourceState`.
|
|
140
141
|
* @internal
|
|
141
142
|
*/
|
|
142
|
-
function unwrapAnnotationView(value) {
|
|
143
|
-
if (value == null || typeof value !== "object") return value;
|
|
144
|
-
return annotationViewTargets.get(value) ?? value;
|
|
145
|
-
}
|
|
146
143
|
function containsAnnotationView(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
147
144
|
if (value == null || typeof value !== "object") return false;
|
|
148
145
|
const candidate = value;
|
|
149
|
-
if (annotationViewTargets.has(candidate)) return true;
|
|
150
|
-
const source = unwrapAnnotationView(candidate);
|
|
146
|
+
if (require_annotation_state.annotationViewTargets.has(candidate)) return true;
|
|
147
|
+
const source = require_annotation_state.unwrapAnnotationView(candidate);
|
|
151
148
|
if (seen.has(source)) return false;
|
|
152
149
|
seen.add(source);
|
|
153
150
|
if (Array.isArray(source)) return source.some((item) => containsAnnotationView(item, seen));
|
|
@@ -161,7 +158,7 @@ function containsAnnotationView(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
161
158
|
}
|
|
162
159
|
function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
163
160
|
if (value == null || typeof value !== "object") return value;
|
|
164
|
-
const source = unwrapAnnotationView(value);
|
|
161
|
+
const source = require_annotation_state.unwrapAnnotationView(value);
|
|
165
162
|
if (seen.has(source)) return seen.get(source);
|
|
166
163
|
if (Array.isArray(source)) {
|
|
167
164
|
let changed$1 = false;
|
|
@@ -305,61 +302,19 @@ function prepareStateForCompletion(fieldState, parser) {
|
|
|
305
302
|
*/
|
|
306
303
|
function getAnnotatedFieldState(parentState, field, parser) {
|
|
307
304
|
const sourceState = parentState != null && typeof parentState === "object" && field in parentState ? parentState[field] : parser.initialState;
|
|
308
|
-
return
|
|
309
|
-
}
|
|
310
|
-
const annotationViewTargets = /* @__PURE__ */ new WeakMap();
|
|
311
|
-
function withAnnotationView(state, annotations) {
|
|
312
|
-
const target = unwrapAnnotationView(state);
|
|
313
|
-
const view = new Proxy(target, {
|
|
314
|
-
get(target$1, key) {
|
|
315
|
-
if (key === require_annotations.annotationKey) return annotations;
|
|
316
|
-
const value = Reflect.get(target$1, key, target$1);
|
|
317
|
-
return typeof value === "function" ? value.bind(target$1) : value;
|
|
318
|
-
},
|
|
319
|
-
has(target$1, key) {
|
|
320
|
-
return key === require_annotations.annotationKey || Reflect.has(target$1, key);
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
annotationViewTargets.set(view, target);
|
|
324
|
-
return view;
|
|
325
|
-
}
|
|
326
|
-
function getParseChildState(parentState, childState, parser) {
|
|
327
|
-
const annotations = require_annotations.getAnnotations(parentState);
|
|
328
|
-
const shouldInheritAnnotations = Reflect.get(parser, require_parser.inheritParentAnnotationsKey) === true;
|
|
329
|
-
if (childState == null) {
|
|
330
|
-
if (annotations !== void 0 && shouldInheritAnnotations) return require_annotations.injectAnnotations({}, annotations);
|
|
331
|
-
return childState;
|
|
332
|
-
}
|
|
333
|
-
if (annotations === void 0 || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations || !shouldInheritAnnotations) return childState;
|
|
334
|
-
const injectedState = require_annotations.injectAnnotations(childState, annotations);
|
|
335
|
-
return require_annotations.getAnnotations(injectedState) === annotations ? injectedState : childState;
|
|
305
|
+
return require_annotation_state.getWrappedChildState(parentState, sourceState, parser);
|
|
336
306
|
}
|
|
337
307
|
function getObjectParseChildState(parentState, childState, _parser) {
|
|
338
308
|
const annotations = require_annotations.getAnnotations(parentState);
|
|
339
309
|
if (annotations === void 0 || childState == null || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations) return childState;
|
|
340
310
|
return require_annotations.inheritAnnotations(parentState, childState);
|
|
341
311
|
}
|
|
342
|
-
function getAnnotatedChildState(parentState, childState, parser) {
|
|
343
|
-
const annotations = require_annotations.getAnnotations(parentState);
|
|
344
|
-
const shouldInheritAnnotations = Reflect.get(parser, require_parser.inheritParentAnnotationsKey) === true;
|
|
345
|
-
if (childState == null) {
|
|
346
|
-
if (annotations !== void 0 && shouldInheritAnnotations) return require_annotations.injectAnnotations({}, annotations);
|
|
347
|
-
return childState;
|
|
348
|
-
}
|
|
349
|
-
if (typeof childState !== "object") return childState;
|
|
350
|
-
if (annotations === void 0 || require_annotations.getAnnotations(childState) === annotations) return childState;
|
|
351
|
-
if (shouldInheritAnnotations) {
|
|
352
|
-
const injectedState = require_annotations.injectAnnotations(childState, annotations);
|
|
353
|
-
if (require_annotations.getAnnotations(injectedState) === annotations) return injectedState;
|
|
354
|
-
}
|
|
355
|
-
return withAnnotationView(childState, annotations);
|
|
356
|
-
}
|
|
357
312
|
function buildSuggestRuntimeNodesFromPairs(pairs, state, parentPath) {
|
|
358
313
|
const prefix = parentPath ?? [];
|
|
359
314
|
const nodes = [];
|
|
360
315
|
for (const [field, parser] of pairs) {
|
|
361
316
|
const fieldState = Object.hasOwn(state, field) ? state[field] : parser.initialState;
|
|
362
|
-
nodes.push(...require_parser.getParserSuggestRuntimeNodes(parser,
|
|
317
|
+
nodes.push(...require_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(state, fieldState, parser), [...prefix, field]));
|
|
363
318
|
}
|
|
364
319
|
return nodes;
|
|
365
320
|
}
|
|
@@ -369,7 +324,7 @@ function buildSuggestRuntimeNodesFromArray(parsers, stateArray, parentPath) {
|
|
|
369
324
|
for (let i = 0; i < parsers.length; i++) {
|
|
370
325
|
const parser = parsers[i];
|
|
371
326
|
const elementState = i < stateArray.length ? stateArray[i] : void 0;
|
|
372
|
-
nodes.push(...require_parser.getParserSuggestRuntimeNodes(parser,
|
|
327
|
+
nodes.push(...require_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(stateArray, elementState, parser), [...prefix, i]));
|
|
373
328
|
}
|
|
374
329
|
return nodes;
|
|
375
330
|
}
|
|
@@ -569,7 +524,7 @@ function normalizeExclusiveState(state) {
|
|
|
569
524
|
}
|
|
570
525
|
function annotateExclusiveParserResult(parentState, parser, result) {
|
|
571
526
|
if (!result.success) return result;
|
|
572
|
-
const annotatedState =
|
|
527
|
+
const annotatedState = require_annotation_state.getWrappedChildState(parentState, result.next.state, parser);
|
|
573
528
|
if (annotatedState === result.next.state) return result;
|
|
574
529
|
return {
|
|
575
530
|
...result,
|
|
@@ -595,7 +550,7 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
595
550
|
const candidate = findExclusiveZeroInputCandidateSync(syncParsers, state, exec);
|
|
596
551
|
if (candidate != null) {
|
|
597
552
|
const p = syncParsers[candidate.index];
|
|
598
|
-
const annotatedState =
|
|
553
|
+
const annotatedState = require_annotation_state.getWrappedChildState(state, candidate.parseResult.next.state, p);
|
|
599
554
|
return p.complete(annotatedState, withChildExecPath(exec, candidate.index));
|
|
600
555
|
}
|
|
601
556
|
return {
|
|
@@ -606,7 +561,7 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
606
561
|
const candidate = await findExclusiveZeroInputCandidateAsync(parsers, state, exec);
|
|
607
562
|
if (candidate != null && (parsers[candidate.index].$mode === "sync" || exec?.phase !== "parse" && exec?.phase !== "suggest")) {
|
|
608
563
|
const p = parsers[candidate.index];
|
|
609
|
-
const annotatedState =
|
|
564
|
+
const annotatedState = require_annotation_state.getWrappedChildState(state, candidate.parseResult.next.state, p);
|
|
610
565
|
return await p.complete(annotatedState, withChildExecPath(exec, candidate.index));
|
|
611
566
|
}
|
|
612
567
|
return {
|
|
@@ -695,7 +650,7 @@ function findExclusiveZeroInputCandidateSync(parsers, state, exec) {
|
|
|
695
650
|
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
696
651
|
const parseResult = parser.parse({
|
|
697
652
|
...emptyCtx,
|
|
698
|
-
state:
|
|
653
|
+
state: require_annotation_state.getWrappedChildState(state, parser.initialState, parser)
|
|
699
654
|
});
|
|
700
655
|
if (!parseResult.success || parseResult.provisional) continue;
|
|
701
656
|
candidateCount++;
|
|
@@ -726,7 +681,7 @@ async function findExclusiveZeroInputCandidateAsync(parsers, state, exec) {
|
|
|
726
681
|
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
727
682
|
const parseResult = await parser.parse({
|
|
728
683
|
...emptyCtx,
|
|
729
|
-
state:
|
|
684
|
+
state: require_annotation_state.getWrappedChildState(state, parser.initialState, parser)
|
|
730
685
|
});
|
|
731
686
|
if (!parseResult.success || parseResult.provisional) continue;
|
|
732
687
|
candidateCount++;
|
|
@@ -1799,7 +1754,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1799
1754
|
return state;
|
|
1800
1755
|
};
|
|
1801
1756
|
const inheritedFieldStateCache = /* @__PURE__ */ new WeakMap();
|
|
1802
|
-
const createFieldStateGetter = (parentState, annotateChildState =
|
|
1757
|
+
const createFieldStateGetter = (parentState, annotateChildState = require_annotation_state.getWrappedChildState) => {
|
|
1803
1758
|
return (field, parser) => {
|
|
1804
1759
|
const fieldKey = field;
|
|
1805
1760
|
const cache = parentState != null && typeof parentState === "object" ? (() => {
|
|
@@ -1857,7 +1812,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1857
1812
|
optionsTerminated: result.next.optionsTerminated,
|
|
1858
1813
|
state: {
|
|
1859
1814
|
...currentContext.state,
|
|
1860
|
-
[field]:
|
|
1815
|
+
[field]: require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser)
|
|
1861
1816
|
},
|
|
1862
1817
|
...mergedExec != null ? {
|
|
1863
1818
|
trace: mergedExec.trace,
|
|
@@ -1887,7 +1842,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1887
1842
|
...currentContext,
|
|
1888
1843
|
state: {
|
|
1889
1844
|
...currentContext.state,
|
|
1890
|
-
[field]:
|
|
1845
|
+
[field]: require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser)
|
|
1891
1846
|
},
|
|
1892
1847
|
...mergedExec != null ? {
|
|
1893
1848
|
trace: mergedExec.trace,
|
|
@@ -1955,7 +1910,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1955
1910
|
optionsTerminated: result.next.optionsTerminated,
|
|
1956
1911
|
state: {
|
|
1957
1912
|
...currentContext.state,
|
|
1958
|
-
[field]:
|
|
1913
|
+
[field]: require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser)
|
|
1959
1914
|
},
|
|
1960
1915
|
...mergedExec != null ? {
|
|
1961
1916
|
trace: mergedExec.trace,
|
|
@@ -1985,7 +1940,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1985
1940
|
...currentContext,
|
|
1986
1941
|
state: {
|
|
1987
1942
|
...currentContext.state,
|
|
1988
|
-
[field]:
|
|
1943
|
+
[field]: require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser)
|
|
1989
1944
|
},
|
|
1990
1945
|
...mergedExec != null ? {
|
|
1991
1946
|
trace: mergedExec.trace,
|
|
@@ -2414,7 +2369,7 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2414
2369
|
for (const [parser, index] of remainingParsers) {
|
|
2415
2370
|
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2416
2371
|
if (result.success && result.consumed.length > 0) {
|
|
2417
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ?
|
|
2372
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2418
2373
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2419
2374
|
currentContext = {
|
|
2420
2375
|
...currentContext,
|
|
@@ -2439,7 +2394,7 @@ function advanceTupleSuggestContextSync(context, parsers) {
|
|
|
2439
2394
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2440
2395
|
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2441
2396
|
if (result.success && result.consumed.length < 1) {
|
|
2442
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ?
|
|
2397
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2443
2398
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2444
2399
|
currentContext = {
|
|
2445
2400
|
...currentContext,
|
|
@@ -2480,7 +2435,7 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2480
2435
|
for (const [parser, index] of remainingParsers) {
|
|
2481
2436
|
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2482
2437
|
if (result.success && result.consumed.length > 0) {
|
|
2483
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ?
|
|
2438
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2484
2439
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2485
2440
|
currentContext = {
|
|
2486
2441
|
...currentContext,
|
|
@@ -2505,7 +2460,7 @@ async function advanceTupleSuggestContextAsync(context, parsers) {
|
|
|
2505
2460
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2506
2461
|
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2507
2462
|
if (result.success && result.consumed.length < 1) {
|
|
2508
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ?
|
|
2463
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((state, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : state));
|
|
2509
2464
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2510
2465
|
currentContext = {
|
|
2511
2466
|
...currentContext,
|
|
@@ -2541,7 +2496,7 @@ function markFailedTupleSuggestSources(parsers, stateArray, failedParserIndexes,
|
|
|
2541
2496
|
const parser = parsers[index];
|
|
2542
2497
|
if (parser == null) continue;
|
|
2543
2498
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
2544
|
-
const nodes = require_parser.getParserSuggestRuntimeNodes(parser,
|
|
2499
|
+
const nodes = require_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
2545
2500
|
if (nodes.length < 1) continue;
|
|
2546
2501
|
const failedRuntime = require_dependency_runtime.createDependencyRuntimeContext();
|
|
2547
2502
|
require_dependency_runtime.collectExplicitSourceValues(nodes, failedRuntime);
|
|
@@ -2558,7 +2513,7 @@ async function markFailedTupleSuggestSourcesAsync(parsers, stateArray, failedPar
|
|
|
2558
2513
|
const parser = parsers[index];
|
|
2559
2514
|
if (parser == null) continue;
|
|
2560
2515
|
const parserState = stateArray && Array.isArray(stateArray) ? stateArray[index] : parser.initialState;
|
|
2561
|
-
const nodes = require_parser.getParserSuggestRuntimeNodes(parser,
|
|
2516
|
+
const nodes = require_parser.getParserSuggestRuntimeNodes(parser, require_annotation_state.getWrappedChildState(stateArray, parserState, parser), [...prefix, index]);
|
|
2562
2517
|
if (nodes.length < 1) continue;
|
|
2563
2518
|
const failedRuntime = require_dependency_runtime.createDependencyRuntimeContext();
|
|
2564
2519
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(nodes, failedRuntime);
|
|
@@ -2598,7 +2553,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2598
2553
|
for (const [parser, index] of remainingParsers) {
|
|
2599
2554
|
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2600
2555
|
if (result.success && result.consumed.length > 0) {
|
|
2601
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
2556
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2602
2557
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2603
2558
|
currentContext = {
|
|
2604
2559
|
...currentContext,
|
|
@@ -2619,7 +2574,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2619
2574
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
2620
2575
|
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2621
2576
|
if (result.success && result.consumed.length < 1) {
|
|
2622
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
2577
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2623
2578
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2624
2579
|
currentContext = {
|
|
2625
2580
|
...currentContext,
|
|
@@ -2665,7 +2620,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2665
2620
|
const resultOrPromise = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2666
2621
|
const result = await resultOrPromise;
|
|
2667
2622
|
if (result.success && result.consumed.length > 0) {
|
|
2668
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
2623
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2669
2624
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2670
2625
|
currentContext = {
|
|
2671
2626
|
...currentContext,
|
|
@@ -2687,7 +2642,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2687
2642
|
const resultOrPromise = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
2688
2643
|
const result = await resultOrPromise;
|
|
2689
2644
|
if (result.success && result.consumed.length < 1) {
|
|
2690
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
2645
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
2691
2646
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
2692
2647
|
currentContext = {
|
|
2693
2648
|
...currentContext,
|
|
@@ -3626,7 +3581,7 @@ function buildSuggestRegistry(preParsedContext, parsers) {
|
|
|
3626
3581
|
state: createAnnotatedArrayStateRecord(stateArray)
|
|
3627
3582
|
}, buildIndexedParserPairs(parsers), runtime.registry, preParsedContext.exec);
|
|
3628
3583
|
const prefix = preParsedContext.exec?.path ?? [];
|
|
3629
|
-
for (let i = 0; i < parsers.length; i++) seedSuggestRuntimeFromFieldParsers(parsers[i],
|
|
3584
|
+
for (let i = 0; i < parsers.length; i++) seedSuggestRuntimeFromFieldParsers(parsers[i], require_annotation_state.getWrappedChildState(stateArray, stateArray[i], parsers[i]), runtime, [...prefix, i]);
|
|
3630
3585
|
}
|
|
3631
3586
|
return {
|
|
3632
3587
|
context: {
|
|
@@ -3654,7 +3609,7 @@ async function buildSuggestRegistryAsync(preParsedContext, parsers) {
|
|
|
3654
3609
|
state: createAnnotatedArrayStateRecord(stateArray)
|
|
3655
3610
|
}, buildIndexedParserPairs(parsers), runtime.registry, preParsedContext.exec);
|
|
3656
3611
|
const prefix = preParsedContext.exec?.path ?? [];
|
|
3657
|
-
for (let i = 0; i < parsers.length; i++) await seedSuggestRuntimeFromFieldParsersAsync(parsers[i],
|
|
3612
|
+
for (let i = 0; i < parsers.length; i++) await seedSuggestRuntimeFromFieldParsersAsync(parsers[i], require_annotation_state.getWrappedChildState(stateArray, stateArray[i], parsers[i]), runtime, [...prefix, i]);
|
|
3658
3613
|
}
|
|
3659
3614
|
return {
|
|
3660
3615
|
context: {
|
|
@@ -3790,7 +3745,7 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3790
3745
|
const tail = remaining.slice(ri + 1);
|
|
3791
3746
|
return resultOrPromise.then((result$1) => {
|
|
3792
3747
|
if (result$1.success && result$1.consumed.length > 0) {
|
|
3793
|
-
stateArray[index] =
|
|
3748
|
+
stateArray[index] = require_annotation_state.getWrappedChildState(context.state, result$1.next.state, parser);
|
|
3794
3749
|
matchedParsers.add(index);
|
|
3795
3750
|
const mergedExec = mergeChildExec(context.exec, result$1.next.exec);
|
|
3796
3751
|
return preParseSuggestLoop({
|
|
@@ -3817,7 +3772,7 @@ function tryParseSuggestList(context, stateArray, parsers, matchedParsers, remai
|
|
|
3817
3772
|
}
|
|
3818
3773
|
const result = resultOrPromise;
|
|
3819
3774
|
if (result.success && result.consumed.length > 0) {
|
|
3820
|
-
stateArray[index] =
|
|
3775
|
+
stateArray[index] = require_annotation_state.getWrappedChildState(context.state, result.next.state, parser);
|
|
3821
3776
|
matchedParsers.add(index);
|
|
3822
3777
|
const mergedExec = mergeChildExec(context.exec, result.next.exec);
|
|
3823
3778
|
return {
|
|
@@ -3856,7 +3811,7 @@ function concat(...parsers) {
|
|
|
3856
3811
|
for (const [parser, index] of remainingParsers) {
|
|
3857
3812
|
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3858
3813
|
if (result.success && result.consumed.length > 0) {
|
|
3859
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
3814
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3860
3815
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3861
3816
|
currentContext = {
|
|
3862
3817
|
...currentContext,
|
|
@@ -3877,7 +3832,7 @@ function concat(...parsers) {
|
|
|
3877
3832
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
3878
3833
|
const result = parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3879
3834
|
if (result.success && result.consumed.length < 1) {
|
|
3880
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
3835
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3881
3836
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3882
3837
|
currentContext = {
|
|
3883
3838
|
...currentContext,
|
|
@@ -3922,7 +3877,7 @@ function concat(...parsers) {
|
|
|
3922
3877
|
for (const [parser, index] of remainingParsers) {
|
|
3923
3878
|
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3924
3879
|
if (result.success && result.consumed.length > 0) {
|
|
3925
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
3880
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3926
3881
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3927
3882
|
currentContext = {
|
|
3928
3883
|
...currentContext,
|
|
@@ -3943,7 +3898,7 @@ function concat(...parsers) {
|
|
|
3943
3898
|
if (!foundMatch) for (const [parser, index] of remainingParsers) {
|
|
3944
3899
|
const result = await parser.parse(withChildContext(currentContext, index, stateArray[index], parser));
|
|
3945
3900
|
if (result.success && result.consumed.length < 1) {
|
|
3946
|
-
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ?
|
|
3901
|
+
const newStateArray = require_annotations.annotateFreshArray(currentContext.state, stateArray.map((s, idx) => idx === index ? require_annotation_state.getWrappedChildState(currentContext.state, result.next.state, parser) : s));
|
|
3947
3902
|
const mergedExec = mergeChildExec(currentContext.exec, result.next.exec);
|
|
3948
3903
|
currentContext = {
|
|
3949
3904
|
...currentContext,
|
|
@@ -4426,7 +4381,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4426
4381
|
...branchResult.next,
|
|
4427
4382
|
state: {
|
|
4428
4383
|
...state,
|
|
4429
|
-
branchState:
|
|
4384
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchResult.next.state, branchParser)
|
|
4430
4385
|
},
|
|
4431
4386
|
...mergedExec != null ? {
|
|
4432
4387
|
exec: mergedExec,
|
|
@@ -4440,7 +4395,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4440
4395
|
}
|
|
4441
4396
|
const discriminatorResult = syncDiscriminator.parse({ ...withChildContext(context, "_discriminator", state.discriminatorState, syncDiscriminator) });
|
|
4442
4397
|
if (discriminatorResult.success) {
|
|
4443
|
-
const annotatedDiscriminatorState =
|
|
4398
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, syncDiscriminator);
|
|
4444
4399
|
const completionResult = syncDiscriminator.complete(annotatedDiscriminatorState, withChildExecPath(context.exec, "_discriminator"));
|
|
4445
4400
|
if (completionResult.success) {
|
|
4446
4401
|
const value = completionResult.value;
|
|
@@ -4473,7 +4428,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4473
4428
|
kind: "branch",
|
|
4474
4429
|
key: value
|
|
4475
4430
|
},
|
|
4476
|
-
branchState:
|
|
4431
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchParseResult.next.state, branchParser)
|
|
4477
4432
|
},
|
|
4478
4433
|
...mergedExec != null ? {
|
|
4479
4434
|
exec: mergedExec,
|
|
@@ -4494,7 +4449,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4494
4449
|
kind: "branch",
|
|
4495
4450
|
key: value
|
|
4496
4451
|
},
|
|
4497
|
-
branchState:
|
|
4452
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchParser.initialState, branchParser)
|
|
4498
4453
|
},
|
|
4499
4454
|
...discriminatorExec != null ? {
|
|
4500
4455
|
exec: discriminatorExec,
|
|
@@ -4526,7 +4481,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4526
4481
|
state: {
|
|
4527
4482
|
...state,
|
|
4528
4483
|
...commitDefault ? { selectedBranch: { kind: "default" } } : {},
|
|
4529
|
-
branchState:
|
|
4484
|
+
branchState: require_annotation_state.getWrappedChildState(state, defaultResult.next.state, syncDefaultBranch)
|
|
4530
4485
|
},
|
|
4531
4486
|
...mergedExec != null ? {
|
|
4532
4487
|
exec: mergedExec,
|
|
@@ -4558,7 +4513,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4558
4513
|
...branchResult.next,
|
|
4559
4514
|
state: {
|
|
4560
4515
|
...state,
|
|
4561
|
-
branchState:
|
|
4516
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchResult.next.state, branchParser)
|
|
4562
4517
|
},
|
|
4563
4518
|
...mergedExec != null ? {
|
|
4564
4519
|
exec: mergedExec,
|
|
@@ -4620,7 +4575,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4620
4575
|
if (speculativeHit != null && !ambiguous) {
|
|
4621
4576
|
const { key, bp, result: branchResult } = speculativeHit;
|
|
4622
4577
|
if (branchResult.success) {
|
|
4623
|
-
const annotatedDiscriminatorState$2 =
|
|
4578
|
+
const annotatedDiscriminatorState$2 = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, discriminator);
|
|
4624
4579
|
const mergedExec = mergeChildExec(discriminatorExec, branchResult.next.exec);
|
|
4625
4580
|
return {
|
|
4626
4581
|
success: true,
|
|
@@ -4634,7 +4589,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4634
4589
|
kind: "branch",
|
|
4635
4590
|
key
|
|
4636
4591
|
},
|
|
4637
|
-
branchState:
|
|
4592
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchResult.next.state, bp),
|
|
4638
4593
|
speculative: true
|
|
4639
4594
|
},
|
|
4640
4595
|
...mergedExec != null ? {
|
|
@@ -4659,7 +4614,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4659
4614
|
state: {
|
|
4660
4615
|
...state,
|
|
4661
4616
|
selectedBranch: { kind: "default" },
|
|
4662
|
-
branchState:
|
|
4617
|
+
branchState: require_annotation_state.getWrappedChildState(state, defaultResult.next.state, defaultBranch)
|
|
4663
4618
|
},
|
|
4664
4619
|
...defaultExec != null ? {
|
|
4665
4620
|
exec: defaultExec,
|
|
@@ -4670,10 +4625,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4670
4625
|
};
|
|
4671
4626
|
}
|
|
4672
4627
|
if (!defaultResult.success && defaultResult.consumed > 0) return defaultResult;
|
|
4673
|
-
if (defaultResult.success && defaultResult.consumed.length === 0 && speculationContext.buffer.length === 0) deferredBranchState =
|
|
4628
|
+
if (defaultResult.success && defaultResult.consumed.length === 0 && speculationContext.buffer.length === 0) deferredBranchState = require_annotation_state.getWrappedChildState(state, defaultResult.next.state, defaultBranch);
|
|
4674
4629
|
}
|
|
4675
4630
|
if (speculativeError != null && !ambiguous && !provisionalAmbiguous) return speculativeError;
|
|
4676
|
-
const annotatedDiscriminatorState$1 =
|
|
4631
|
+
const annotatedDiscriminatorState$1 = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, discriminator);
|
|
4677
4632
|
return {
|
|
4678
4633
|
success: true,
|
|
4679
4634
|
provisional: true,
|
|
@@ -4688,7 +4643,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4688
4643
|
consumed: []
|
|
4689
4644
|
};
|
|
4690
4645
|
}
|
|
4691
|
-
const annotatedDiscriminatorState =
|
|
4646
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, discriminator);
|
|
4692
4647
|
const completionResult = await discriminator.complete(annotatedDiscriminatorState, withChildExecPath(context.exec, "_discriminator"));
|
|
4693
4648
|
if (completionResult.success) {
|
|
4694
4649
|
const value = completionResult.value;
|
|
@@ -4720,7 +4675,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4720
4675
|
kind: "branch",
|
|
4721
4676
|
key: value
|
|
4722
4677
|
},
|
|
4723
|
-
branchState:
|
|
4678
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchParseResult.next.state, branchParser)
|
|
4724
4679
|
},
|
|
4725
4680
|
...mergedExec != null ? {
|
|
4726
4681
|
exec: mergedExec,
|
|
@@ -4741,7 +4696,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4741
4696
|
kind: "branch",
|
|
4742
4697
|
key: value
|
|
4743
4698
|
},
|
|
4744
|
-
branchState:
|
|
4699
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchParser.initialState, branchParser)
|
|
4745
4700
|
},
|
|
4746
4701
|
...discriminatorExec != null ? {
|
|
4747
4702
|
exec: discriminatorExec,
|
|
@@ -4773,7 +4728,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4773
4728
|
state: {
|
|
4774
4729
|
...state,
|
|
4775
4730
|
...commitDefault ? { selectedBranch: { kind: "default" } } : {},
|
|
4776
|
-
branchState:
|
|
4731
|
+
branchState: require_annotation_state.getWrappedChildState(state, defaultResult.next.state, defaultBranch)
|
|
4777
4732
|
},
|
|
4778
4733
|
...mergedExec != null ? {
|
|
4779
4734
|
exec: mergedExec,
|
|
@@ -4797,7 +4752,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4797
4752
|
const syncBranches = branches;
|
|
4798
4753
|
if (state.selectedBranch === void 0) {
|
|
4799
4754
|
{
|
|
4800
|
-
const annotatedDiscriminatorStateForDeferred =
|
|
4755
|
+
const annotatedDiscriminatorStateForDeferred = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
4801
4756
|
const deferredDiscriminatorResult = unwrapCompleteResult(syncDiscriminator.complete(annotatedDiscriminatorStateForDeferred, withChildExecPath(exec, "_discriminator")));
|
|
4802
4757
|
if (deferredDiscriminatorResult.success) {
|
|
4803
4758
|
const deferredValue = deferredDiscriminatorResult.value;
|
|
@@ -4811,13 +4766,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4811
4766
|
exec: branchExec,
|
|
4812
4767
|
dependencyRegistry: exec?.dependencyRegistry
|
|
4813
4768
|
};
|
|
4814
|
-
const annotatedInitial =
|
|
4769
|
+
const annotatedInitial = require_annotation_state.getWrappedChildState(state, deferredBranch.initialState, deferredBranch);
|
|
4815
4770
|
const replayResult = deferredBranch.parse({
|
|
4816
4771
|
...emptyCtx,
|
|
4817
4772
|
state: annotatedInitial
|
|
4818
4773
|
});
|
|
4819
4774
|
const branchState = replayResult.success ? replayResult.next.state : annotatedInitial;
|
|
4820
|
-
const annotatedBranchState =
|
|
4775
|
+
const annotatedBranchState = require_annotation_state.getWrappedChildState(state, branchState, deferredBranch);
|
|
4821
4776
|
const branchResult$1 = unwrapCompleteResult(deferredBranch.complete(annotatedBranchState, branchExec));
|
|
4822
4777
|
if (branchResult$1.success) return {
|
|
4823
4778
|
success: true,
|
|
@@ -4840,7 +4795,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4840
4795
|
} else if (syncDefaultBranch === void 0) return deferredDiscriminatorResult;
|
|
4841
4796
|
}
|
|
4842
4797
|
if (syncDefaultBranch !== void 0) {
|
|
4843
|
-
const branchState =
|
|
4798
|
+
const branchState = require_annotation_state.getWrappedChildState(state, state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch);
|
|
4844
4799
|
const defaultResult = unwrapCompleteResult(syncDefaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
4845
4800
|
if (!defaultResult.success) return defaultResult;
|
|
4846
4801
|
return {
|
|
@@ -4858,15 +4813,15 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4858
4813
|
};
|
|
4859
4814
|
}
|
|
4860
4815
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
4861
|
-
const annotatedDiscriminatorState =
|
|
4816
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
4862
4817
|
const combinedState = {
|
|
4863
4818
|
_discriminator: annotatedDiscriminatorState,
|
|
4864
|
-
_branch:
|
|
4819
|
+
_branch: require_annotation_state.getWrappedChildState(state, state.branchState, branchParser)
|
|
4865
4820
|
};
|
|
4866
4821
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
4867
4822
|
require_dependency_runtime.collectExplicitSourceValues(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
4868
4823
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
4869
|
-
const resolvedBranchState =
|
|
4824
|
+
const resolvedBranchState = require_annotation_state.getWrappedChildState(state, require_dependency_runtime.resolveStateWithRuntime(state.branchState, runtime), branchParser);
|
|
4870
4825
|
const completionExec = {
|
|
4871
4826
|
...exec ?? {
|
|
4872
4827
|
usage: branchParser.usage,
|
|
@@ -4917,7 +4872,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4917
4872
|
};
|
|
4918
4873
|
if (state.selectedBranch === void 0) {
|
|
4919
4874
|
if (exec?.phase !== "parse" && exec?.phase !== "suggest") {
|
|
4920
|
-
const annotatedDiscriminatorStateForDeferred =
|
|
4875
|
+
const annotatedDiscriminatorStateForDeferred = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
4921
4876
|
const deferredDiscriminatorResult = unwrapCompleteResult(await discriminator.complete(annotatedDiscriminatorStateForDeferred, withChildExecPath(exec, "_discriminator")));
|
|
4922
4877
|
if (deferredDiscriminatorResult.success) {
|
|
4923
4878
|
const deferredValue = deferredDiscriminatorResult.value;
|
|
@@ -4931,13 +4886,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4931
4886
|
exec: branchExec,
|
|
4932
4887
|
dependencyRegistry: exec?.dependencyRegistry
|
|
4933
4888
|
};
|
|
4934
|
-
const annotatedInitial =
|
|
4889
|
+
const annotatedInitial = require_annotation_state.getWrappedChildState(state, deferredBranch.initialState, deferredBranch);
|
|
4935
4890
|
const replayResult = await deferredBranch.parse({
|
|
4936
4891
|
...emptyCtx,
|
|
4937
4892
|
state: annotatedInitial
|
|
4938
4893
|
});
|
|
4939
4894
|
const branchState = replayResult.success ? replayResult.next.state : annotatedInitial;
|
|
4940
|
-
const annotatedBranchState =
|
|
4895
|
+
const annotatedBranchState = require_annotation_state.getWrappedChildState(state, branchState, deferredBranch);
|
|
4941
4896
|
const branchResult$1 = unwrapCompleteResult(await deferredBranch.complete(annotatedBranchState, branchExec));
|
|
4942
4897
|
if (branchResult$1.success) return {
|
|
4943
4898
|
success: true,
|
|
@@ -4964,7 +4919,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4964
4919
|
value: [void 0, void 0]
|
|
4965
4920
|
};
|
|
4966
4921
|
if (defaultBranch !== void 0) {
|
|
4967
|
-
const branchState =
|
|
4922
|
+
const branchState = require_annotation_state.getWrappedChildState(state, state.branchState ?? defaultBranch.initialState, defaultBranch);
|
|
4968
4923
|
const defaultResult = unwrapCompleteResult(await defaultBranch.complete(branchState, withChildExecPath(exec, "_branch")));
|
|
4969
4924
|
if (!defaultResult.success) return defaultResult;
|
|
4970
4925
|
return {
|
|
@@ -4982,10 +4937,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4982
4937
|
};
|
|
4983
4938
|
}
|
|
4984
4939
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
4985
|
-
const annotatedDiscriminatorState =
|
|
4940
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
4986
4941
|
const combinedState = {
|
|
4987
4942
|
_discriminator: annotatedDiscriminatorState,
|
|
4988
|
-
_branch:
|
|
4943
|
+
_branch: require_annotation_state.getWrappedChildState(state, state.branchState, branchParser)
|
|
4989
4944
|
};
|
|
4990
4945
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
4991
4946
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, exec?.path), runtime);
|
|
@@ -5031,7 +4986,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5031
4986
|
error: options?.errors?.branchMismatch ? options.errors.branchMismatch(resolvedKey, speculativeKey) : require_message.message`Branch mismatch: tokens for ${speculativeKey} were consumed, but the discriminator resolved to ${resolvedKey}.`
|
|
5032
4987
|
};
|
|
5033
4988
|
}
|
|
5034
|
-
const resolvedBranchState =
|
|
4989
|
+
const resolvedBranchState = require_annotation_state.getWrappedChildState(state, await require_dependency_runtime.resolveStateWithRuntimeAsync(state.branchState, runtime), branchParser);
|
|
5035
4990
|
const branchResult = unwrapCompleteResult(await branchParser.complete(resolvedBranchState, withChildExecPath(completionExec, "_branch")));
|
|
5036
4991
|
if (!branchResult.success) {
|
|
5037
4992
|
if (discriminatorValue !== void 0 && options?.errors?.branchError) return {
|
|
@@ -5051,12 +5006,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5051
5006
|
};
|
|
5052
5007
|
const getConditionalBranchSeedSync = (currentState, branchParser, branchState, exec) => {
|
|
5053
5008
|
const branchExec = withChildExecPath(exec, "_branch");
|
|
5054
|
-
const annotatedState =
|
|
5009
|
+
const annotatedState = require_annotation_state.getWrappedChildState(currentState, branchState, branchParser);
|
|
5055
5010
|
return extractOrCompletePhase2SeedSync(branchParser, annotatedState, branchExec);
|
|
5056
5011
|
};
|
|
5057
5012
|
const getConditionalBranchSeedAsync = async (currentState, branchParser, branchState, exec) => {
|
|
5058
5013
|
const branchExec = withChildExecPath(exec, "_branch");
|
|
5059
|
-
const annotatedState =
|
|
5014
|
+
const annotatedState = require_annotation_state.getWrappedChildState(currentState, branchState, branchParser);
|
|
5060
5015
|
return await extractOrCompletePhase2SeedAsync(branchParser, annotatedState, branchExec);
|
|
5061
5016
|
};
|
|
5062
5017
|
function* suggestSync(context, prefix) {
|
|
@@ -5066,10 +5021,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5066
5021
|
const syncDefaultBranch = defaultBranch;
|
|
5067
5022
|
if (state.selectedBranch === void 0) {
|
|
5068
5023
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
5069
|
-
const annotatedDiscriminatorState =
|
|
5024
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
5070
5025
|
const defaultCombinedState = {
|
|
5071
5026
|
_discriminator: annotatedDiscriminatorState,
|
|
5072
|
-
_branch: syncDefaultBranch == null ? state.branchState :
|
|
5027
|
+
_branch: syncDefaultBranch == null ? state.branchState : require_annotation_state.getWrappedChildState(state, state.branchState, syncDefaultBranch)
|
|
5073
5028
|
};
|
|
5074
5029
|
require_dependency_runtime.collectExplicitSourceValues(require_dependency_runtime.buildRuntimeNodesFromPairs(syncDefaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", syncDefaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
5075
5030
|
require_dependency_runtime.collectSourcesFromState(defaultCombinedState, runtime);
|
|
@@ -5083,7 +5038,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5083
5038
|
} } : {}
|
|
5084
5039
|
};
|
|
5085
5040
|
yield* syncDiscriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState, syncDiscriminator), prefix);
|
|
5086
|
-
const annotatedDiscState =
|
|
5041
|
+
const annotatedDiscState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
5087
5042
|
const discComplete = syncDiscriminator.complete(annotatedDiscState, withChildExecPath(suggestContext.exec ? {
|
|
5088
5043
|
...suggestContext.exec,
|
|
5089
5044
|
phase: "suggest"
|
|
@@ -5095,10 +5050,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5095
5050
|
} else {
|
|
5096
5051
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
5097
5052
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
5098
|
-
const annotatedDiscriminatorState =
|
|
5053
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator);
|
|
5099
5054
|
const combinedState = {
|
|
5100
5055
|
_discriminator: annotatedDiscriminatorState,
|
|
5101
|
-
_branch:
|
|
5056
|
+
_branch: require_annotation_state.getWrappedChildState(state, state.branchState, branchParser)
|
|
5102
5057
|
};
|
|
5103
5058
|
require_dependency_runtime.collectExplicitSourceValues(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
5104
5059
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
@@ -5118,10 +5073,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5118
5073
|
const state = context.state ?? initialState;
|
|
5119
5074
|
if (state.selectedBranch === void 0) {
|
|
5120
5075
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
5121
|
-
const annotatedDiscriminatorState =
|
|
5076
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
5122
5077
|
const defaultCombinedState = {
|
|
5123
5078
|
_discriminator: annotatedDiscriminatorState,
|
|
5124
|
-
_branch: defaultBranch == null ? state.branchState :
|
|
5079
|
+
_branch: defaultBranch == null ? state.branchState : require_annotation_state.getWrappedChildState(state, state.branchState, defaultBranch)
|
|
5125
5080
|
};
|
|
5126
5081
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs(defaultBranch == null ? [["_discriminator", discriminator]] : [["_discriminator", discriminator], ["_branch", defaultBranch]], defaultCombinedState, context.exec?.path), runtime);
|
|
5127
5082
|
require_dependency_runtime.collectSourcesFromState(defaultCombinedState, runtime);
|
|
@@ -5137,7 +5092,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5137
5092
|
yield* discriminator.suggest(withChildContext(suggestContext, "_discriminator", state.discriminatorState, discriminator), prefix);
|
|
5138
5093
|
let discResolved = false;
|
|
5139
5094
|
if (discriminator.$mode === "sync") {
|
|
5140
|
-
const annotatedDiscState =
|
|
5095
|
+
const annotatedDiscState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
5141
5096
|
const discComplete = discriminator.complete(annotatedDiscState, withChildExecPath(suggestContext.exec ? {
|
|
5142
5097
|
...suggestContext.exec,
|
|
5143
5098
|
phase: "suggest"
|
|
@@ -5154,10 +5109,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5154
5109
|
} else {
|
|
5155
5110
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
5156
5111
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
5157
|
-
const annotatedDiscriminatorState =
|
|
5112
|
+
const annotatedDiscriminatorState = require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator);
|
|
5158
5113
|
const combinedState = {
|
|
5159
5114
|
_discriminator: annotatedDiscriminatorState,
|
|
5160
|
-
_branch:
|
|
5115
|
+
_branch: require_annotation_state.getWrappedChildState(state, state.branchState, branchParser)
|
|
5161
5116
|
};
|
|
5162
5117
|
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator], ["_branch", branchParser]], combinedState, context.exec?.path), runtime);
|
|
5163
5118
|
require_dependency_runtime.collectSourcesFromState(combinedState, runtime);
|
|
@@ -5197,7 +5152,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5197
5152
|
const syncBranches = branches;
|
|
5198
5153
|
const discriminatorExec = withChildExecPath(exec, "_discriminator");
|
|
5199
5154
|
if (state.selectedBranch === void 0) {
|
|
5200
|
-
const discriminatorSeed$1 = require_phase2_seed.completeOrExtractPhase2Seed(syncDiscriminator,
|
|
5155
|
+
const discriminatorSeed$1 = require_phase2_seed.completeOrExtractPhase2Seed(syncDiscriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator), discriminatorExec);
|
|
5201
5156
|
if (typeof discriminatorSeed$1?.value === "string") {
|
|
5202
5157
|
const branchParser$1 = syncBranches[discriminatorSeed$1.value];
|
|
5203
5158
|
if (branchParser$1 != null) {
|
|
@@ -5213,12 +5168,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5213
5168
|
}
|
|
5214
5169
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
5215
5170
|
const branchSeed = getConditionalBranchSeedSync(state, branchParser, state.branchState ?? branchParser.initialState, exec);
|
|
5216
|
-
const discriminatorSeed = state.selectedBranch.kind === "default" ? null : state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key ? { value: state.discriminatorValue } : require_phase2_seed.completeOrExtractPhase2Seed(syncDiscriminator,
|
|
5171
|
+
const discriminatorSeed = state.selectedBranch.kind === "default" ? null : state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key ? { value: state.discriminatorValue } : require_phase2_seed.completeOrExtractPhase2Seed(syncDiscriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, syncDiscriminator), discriminatorExec) ?? { value: state.selectedBranch.key };
|
|
5217
5172
|
return combineTuplePhase2Seeds(discriminatorSeed, branchSeed);
|
|
5218
5173
|
}, async () => {
|
|
5219
5174
|
const discriminatorExec = withChildExecPath(exec, "_discriminator");
|
|
5220
5175
|
if (state.selectedBranch === void 0) {
|
|
5221
|
-
const discriminatorSeed$1 = await require_phase2_seed.completeOrExtractPhase2Seed(discriminator,
|
|
5176
|
+
const discriminatorSeed$1 = await require_phase2_seed.completeOrExtractPhase2Seed(discriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator), discriminatorExec);
|
|
5222
5177
|
if (typeof discriminatorSeed$1?.value === "string") {
|
|
5223
5178
|
const branchParser$1 = branches[discriminatorSeed$1.value];
|
|
5224
5179
|
if (branchParser$1 != null) {
|
|
@@ -5234,7 +5189,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
5234
5189
|
}
|
|
5235
5190
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
5236
5191
|
const branchSeed = await getConditionalBranchSeedAsync(state, branchParser, state.branchState ?? branchParser.initialState, exec);
|
|
5237
|
-
const discriminatorSeed = state.selectedBranch.kind === "default" ? null : state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key ? { value: state.discriminatorValue } : await require_phase2_seed.completeOrExtractPhase2Seed(discriminator,
|
|
5192
|
+
const discriminatorSeed = state.selectedBranch.kind === "default" ? null : state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key ? { value: state.discriminatorValue } : await require_phase2_seed.completeOrExtractPhase2Seed(discriminator, require_annotation_state.getWrappedChildState(state, state.discriminatorState, discriminator), discriminatorExec) ?? { value: state.selectedBranch.key };
|
|
5238
5193
|
return combineTuplePhase2Seeds(discriminatorSeed, branchSeed);
|
|
5239
5194
|
});
|
|
5240
5195
|
},
|