@optique/core 1.0.0-dev.1901 → 1.0.0-dev.1970
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotation-state.cjs +115 -60
- package/dist/annotation-state.d.cts +24 -0
- package/dist/annotation-state.d.ts +24 -0
- package/dist/annotation-state.js +114 -60
- package/dist/annotations.cjs +2 -267
- package/dist/annotations.d.cts +2 -152
- package/dist/annotations.d.ts +2 -152
- package/dist/annotations.js +2 -256
- package/dist/completion.d.cts +1 -1
- package/dist/completion.d.ts +1 -1
- package/dist/constructs.cjs +206 -238
- package/dist/constructs.d.cts +1 -1
- package/dist/constructs.d.ts +1 -1
- package/dist/constructs.js +96 -128
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/dependency-metadata.cjs +1 -1
- package/dist/dependency-metadata.d.cts +1 -1
- package/dist/dependency-metadata.d.ts +1 -1
- package/dist/dependency-metadata.js +1 -1
- package/dist/dependency-runtime.cjs +2 -2
- package/dist/dependency-runtime.js +2 -2
- package/dist/dependency.cjs +7 -1111
- package/dist/dependency.d.cts +2 -838
- package/dist/dependency.d.ts +2 -838
- package/dist/dependency.js +2 -1078
- package/dist/execution-context.cjs +56 -0
- package/dist/execution-context.js +53 -0
- package/dist/extension.cjs +87 -0
- package/dist/extension.d.cts +97 -0
- package/dist/extension.d.ts +97 -0
- package/dist/extension.js +76 -0
- package/dist/facade.cjs +19 -19
- package/dist/facade.d.cts +1 -1
- package/dist/facade.d.ts +1 -1
- package/dist/facade.js +19 -19
- package/dist/index.cjs +4 -41
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/internal/annotations.cjs +316 -0
- package/dist/internal/annotations.d.cts +140 -0
- package/dist/internal/annotations.d.ts +140 -0
- package/dist/internal/annotations.js +306 -0
- package/dist/internal/dependency.cjs +984 -0
- package/dist/internal/dependency.d.cts +539 -0
- package/dist/internal/dependency.d.ts +539 -0
- package/dist/internal/dependency.js +964 -0
- package/dist/{mode-dispatch.cjs → internal/mode-dispatch.cjs} +1 -3
- package/dist/{mode-dispatch.d.cts → internal/mode-dispatch.d.cts} +3 -7
- package/dist/{mode-dispatch.d.ts → internal/mode-dispatch.d.ts} +3 -7
- package/dist/{mode-dispatch.js → internal/mode-dispatch.js} +1 -3
- package/dist/internal/parser.cjs +728 -0
- package/dist/internal/parser.d.cts +947 -0
- package/dist/internal/parser.d.ts +947 -0
- package/dist/internal/parser.js +711 -0
- package/dist/modifiers.cjs +108 -125
- package/dist/modifiers.d.cts +1 -1
- package/dist/modifiers.d.ts +1 -1
- package/dist/modifiers.js +92 -109
- package/dist/parser.cjs +11 -743
- package/dist/parser.d.cts +3 -991
- package/dist/parser.d.ts +3 -991
- package/dist/parser.js +2 -704
- package/dist/phase2-seed.cjs +4 -4
- package/dist/phase2-seed.js +4 -4
- package/dist/primitives.cjs +39 -74
- package/dist/primitives.d.cts +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.js +26 -61
- package/dist/program.d.cts +1 -1
- package/dist/program.d.ts +1 -1
- package/dist/valueparser.cjs +23 -23
- package/dist/valueparser.d.cts +3 -3
- package/dist/valueparser.d.ts +3 -3
- package/dist/valueparser.js +23 -23
- package/package.json +9 -9
package/dist/modifiers.cjs
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
const require_annotations = require('./annotations.cjs');
|
|
1
|
+
const require_annotations = require('./internal/annotations.cjs');
|
|
2
2
|
const require_message = require('./message.cjs');
|
|
3
|
-
const require_mode_dispatch = require('./mode-dispatch.cjs');
|
|
4
|
-
const
|
|
5
|
-
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
6
|
-
const require_parser = require('./parser.cjs');
|
|
3
|
+
const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
4
|
+
const require_parser = require('./internal/parser.cjs');
|
|
7
5
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
6
|
+
const require_execution_context = require('./execution-context.cjs');
|
|
7
|
+
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
8
|
+
const require_dependency_metadata = require('./dependency-metadata.cjs');
|
|
8
9
|
|
|
9
10
|
//#region src/modifiers.ts
|
|
10
|
-
function withChildExecPath(exec, segment) {
|
|
11
|
-
if (exec == null) return void 0;
|
|
12
|
-
return {
|
|
13
|
-
...exec,
|
|
14
|
-
path: [...exec.path ?? [], segment]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function mergeChildExec(parent, child) {
|
|
18
|
-
if (parent == null) return child;
|
|
19
|
-
if (child == null) return parent;
|
|
20
|
-
return {
|
|
21
|
-
...parent,
|
|
22
|
-
trace: child.trace ?? parent.trace,
|
|
23
|
-
dependencyRuntime: child.dependencyRuntime ?? parent.dependencyRuntime,
|
|
24
|
-
dependencyRegistry: child.dependencyRegistry ?? parent.dependencyRegistry,
|
|
25
|
-
commandPath: child.commandPath ?? parent.commandPath,
|
|
26
|
-
preCompletedByParser: child.preCompletedByParser ?? parent.preCompletedByParser,
|
|
27
|
-
excludedSourceFields: child.excludedSourceFields ?? parent.excludedSourceFields
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function withChildContext(context, segment, state) {
|
|
31
|
-
const exec = withChildExecPath(context.exec, segment);
|
|
32
|
-
const dependencyRegistry = context.dependencyRegistry ?? exec?.dependencyRegistry;
|
|
33
|
-
return {
|
|
34
|
-
...context,
|
|
35
|
-
state,
|
|
36
|
-
...exec != null ? {
|
|
37
|
-
exec: dependencyRegistry === exec.dependencyRegistry ? exec : {
|
|
38
|
-
...exec,
|
|
39
|
-
dependencyRegistry
|
|
40
|
-
},
|
|
41
|
-
dependencyRegistry
|
|
42
|
-
} : {}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
11
|
function isTerminalMultipleItemState(state) {
|
|
46
12
|
const unwrapped = unwrapMultipleItemState(state).value;
|
|
47
13
|
return unwrapped != null && typeof unwrapped === "object" && Object.hasOwn(unwrapped, "success") && typeof unwrapped.success === "boolean";
|
|
@@ -82,91 +48,105 @@ function unwrapMultipleItemState(state) {
|
|
|
82
48
|
function isPromiseLike(value) {
|
|
83
49
|
return value != null && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
84
50
|
}
|
|
85
|
-
function normalizeOptionalLikeCompleteResult(result) {
|
|
86
|
-
return result.success ? {
|
|
51
|
+
function normalizeOptionalLikeCompleteResult(result, shouldNormalize) {
|
|
52
|
+
return result.success && shouldNormalize ? {
|
|
87
53
|
...result,
|
|
88
54
|
value: require_annotation_state.normalizeNestedDelegatedAnnotationState(result.value)
|
|
89
55
|
} : result;
|
|
90
56
|
}
|
|
57
|
+
function shouldRetryOptionalLikeCompatibilityError(error, state) {
|
|
58
|
+
return error instanceof TypeError && state != null && typeof state === "object" && require_annotations.isInjectedAnnotationWrapper(state);
|
|
59
|
+
}
|
|
91
60
|
function completeOptionalLikeSync(parser, state, exec) {
|
|
92
61
|
const hasCarrier = require_annotation_state.hasDelegatedAnnotationCarrier(state);
|
|
93
|
-
const shouldRetryFalseResult = require_annotation_state.isAnnotationWrappedInitialState(state);
|
|
94
|
-
const run = (candidate) => normalizeOptionalLikeCompleteResult(parser.complete(candidate, exec));
|
|
62
|
+
const shouldRetryFalseResult = hasCarrier && require_annotation_state.isAnnotationWrappedInitialState(state);
|
|
63
|
+
const run = (candidate, shouldNormalize) => normalizeOptionalLikeCompleteResult(parser.complete(candidate, exec), shouldNormalize);
|
|
95
64
|
try {
|
|
96
|
-
const result = run(state);
|
|
97
|
-
if (!result.success && shouldRetryFalseResult) return run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
65
|
+
const result = run(state, hasCarrier);
|
|
66
|
+
if (!result.success && shouldRetryFalseResult) return run(require_annotation_state.normalizeDelegatedAnnotationState(state), false);
|
|
98
67
|
return result;
|
|
99
68
|
} catch (error) {
|
|
100
|
-
if (!
|
|
101
|
-
return run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
69
|
+
if (!shouldRetryOptionalLikeCompatibilityError(error, state)) throw error;
|
|
70
|
+
return run(require_annotation_state.normalizeDelegatedAnnotationState(state), false);
|
|
102
71
|
}
|
|
103
72
|
}
|
|
104
73
|
async function completeOptionalLikeAsync(parser, state, exec) {
|
|
105
74
|
const hasCarrier = require_annotation_state.hasDelegatedAnnotationCarrier(state);
|
|
106
|
-
const shouldRetryFalseResult = require_annotation_state.isAnnotationWrappedInitialState(state);
|
|
107
|
-
const run = async (candidate) => normalizeOptionalLikeCompleteResult(await parser.complete(candidate, exec));
|
|
75
|
+
const shouldRetryFalseResult = hasCarrier && require_annotation_state.isAnnotationWrappedInitialState(state);
|
|
76
|
+
const run = async (candidate, shouldNormalize) => normalizeOptionalLikeCompleteResult(await parser.complete(candidate, exec), shouldNormalize);
|
|
108
77
|
try {
|
|
109
|
-
const result = await run(state);
|
|
110
|
-
if (!result.success && shouldRetryFalseResult) return await run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
78
|
+
const result = await run(state, hasCarrier);
|
|
79
|
+
if (!result.success && shouldRetryFalseResult) return await run(require_annotation_state.normalizeDelegatedAnnotationState(state), false);
|
|
111
80
|
return result;
|
|
112
81
|
} catch (error) {
|
|
113
|
-
if (!
|
|
114
|
-
return await run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
82
|
+
if (!shouldRetryOptionalLikeCompatibilityError(error, state)) throw error;
|
|
83
|
+
return await run(require_annotation_state.normalizeDelegatedAnnotationState(state), false);
|
|
115
84
|
}
|
|
116
85
|
}
|
|
117
|
-
function normalizeOptionalLikePhase2Seed(seed) {
|
|
118
|
-
return seed == null ? null : {
|
|
86
|
+
function normalizeOptionalLikePhase2Seed(seed, shouldNormalize) {
|
|
87
|
+
return seed == null ? null : shouldNormalize ? {
|
|
119
88
|
...seed,
|
|
120
89
|
value: require_annotation_state.normalizeNestedDelegatedAnnotationState(seed.value)
|
|
121
|
-
};
|
|
90
|
+
} : seed;
|
|
122
91
|
}
|
|
123
92
|
function extractOptionalLikePhase2Seed(parser, state, exec) {
|
|
124
|
-
if (!Array.isArray(state) && !(state != null && typeof state === "object")) return require_mode_dispatch.wrapForMode(parser
|
|
93
|
+
if (!Array.isArray(state) && !(state != null && typeof state === "object")) return require_mode_dispatch.wrapForMode(parser.mode, null);
|
|
125
94
|
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
126
95
|
const hasCarrier = require_annotation_state.hasDelegatedAnnotationCarrier(innerState);
|
|
127
|
-
|
|
96
|
+
const shouldRetryFalseResult = hasCarrier && require_annotation_state.isAnnotationWrappedInitialState(innerState);
|
|
97
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => {
|
|
128
98
|
try {
|
|
129
99
|
const result = parser.complete(innerState, exec);
|
|
130
|
-
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result));
|
|
100
|
+
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result), hasCarrier);
|
|
101
|
+
if (shouldRetryFalseResult) {
|
|
102
|
+
const fallbackState = require_annotation_state.normalizeDelegatedAnnotationState(innerState);
|
|
103
|
+
const fallbackResult = parser.complete(fallbackState, exec);
|
|
104
|
+
if (fallbackResult.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(fallbackResult), false);
|
|
105
|
+
}
|
|
131
106
|
const seed = require_phase2_seed.extractPhase2Seed(parser, innerState, exec);
|
|
132
107
|
if (seed == null && hasCarrier) {
|
|
133
108
|
const fallbackState = require_annotation_state.normalizeDelegatedAnnotationState(innerState);
|
|
134
|
-
return normalizeOptionalLikePhase2Seed(require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec));
|
|
109
|
+
return normalizeOptionalLikePhase2Seed(require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec), false);
|
|
135
110
|
}
|
|
136
|
-
return normalizeOptionalLikePhase2Seed(seed);
|
|
111
|
+
return normalizeOptionalLikePhase2Seed(seed, hasCarrier);
|
|
137
112
|
} catch (error) {
|
|
138
|
-
if (!
|
|
113
|
+
if (!shouldRetryOptionalLikeCompatibilityError(error, innerState)) throw error;
|
|
139
114
|
const fallbackState = require_annotation_state.normalizeDelegatedAnnotationState(innerState);
|
|
140
115
|
const result = parser.complete(fallbackState, exec);
|
|
141
|
-
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result));
|
|
142
|
-
return normalizeOptionalLikePhase2Seed(require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec));
|
|
116
|
+
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result), false);
|
|
117
|
+
return normalizeOptionalLikePhase2Seed(require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec), false);
|
|
143
118
|
}
|
|
144
119
|
}, async () => {
|
|
145
120
|
try {
|
|
146
121
|
const result = await parser.complete(innerState, exec);
|
|
147
|
-
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result));
|
|
122
|
+
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result), hasCarrier);
|
|
123
|
+
if (shouldRetryFalseResult) {
|
|
124
|
+
const fallbackState = require_annotation_state.normalizeDelegatedAnnotationState(innerState);
|
|
125
|
+
const fallbackResult = await parser.complete(fallbackState, exec);
|
|
126
|
+
if (fallbackResult.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(fallbackResult), false);
|
|
127
|
+
}
|
|
148
128
|
const seed = await require_phase2_seed.extractPhase2Seed(parser, innerState, exec);
|
|
149
129
|
if (seed == null && hasCarrier) {
|
|
150
130
|
const fallbackState = require_annotation_state.normalizeDelegatedAnnotationState(innerState);
|
|
151
|
-
return normalizeOptionalLikePhase2Seed(await require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec));
|
|
131
|
+
return normalizeOptionalLikePhase2Seed(await require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec), false);
|
|
152
132
|
}
|
|
153
|
-
return normalizeOptionalLikePhase2Seed(seed);
|
|
133
|
+
return normalizeOptionalLikePhase2Seed(seed, hasCarrier);
|
|
154
134
|
} catch (error) {
|
|
155
|
-
if (!
|
|
135
|
+
if (!shouldRetryOptionalLikeCompatibilityError(error, innerState)) throw error;
|
|
156
136
|
const fallbackState = require_annotation_state.normalizeDelegatedAnnotationState(innerState);
|
|
157
137
|
const result = await parser.complete(fallbackState, exec);
|
|
158
|
-
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result));
|
|
159
|
-
return normalizeOptionalLikePhase2Seed(await require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec));
|
|
138
|
+
if (result.success) return normalizeOptionalLikePhase2Seed(require_phase2_seed.phase2SeedFromValueResult(result), false);
|
|
139
|
+
return normalizeOptionalLikePhase2Seed(await require_phase2_seed.extractPhase2Seed(parser, fallbackState, exec), false);
|
|
160
140
|
}
|
|
161
141
|
});
|
|
162
142
|
}
|
|
163
143
|
/**
|
|
164
144
|
* Computes the inner state to pass through to the wrapped parser inside
|
|
165
145
|
* {@link optional} / {@link withDefault}. When the outer state is an
|
|
166
|
-
* array, the inner state is `state[0]`. Otherwise
|
|
146
|
+
* array, the inner state is `state[0]`. Otherwise, including the
|
|
167
147
|
* common case where `optional()` sits at top level and the outer state
|
|
168
148
|
* is either `undefined` or an annotation wrapper from `parseOptionalLike`
|
|
169
|
-
* / `parse({ annotations })
|
|
149
|
+
* / `parse({ annotations })`, we use the wrapped parser's
|
|
170
150
|
* `initialState`, propagating annotations from the outer state so that
|
|
171
151
|
* source-binding wrappers under `optional()` / `withDefault()` (e.g.,
|
|
172
152
|
* `bindEnv()` / `bindConfig()`) can resolve their fallbacks.
|
|
@@ -176,19 +156,19 @@ function extractOptionalLikePhase2Seed(parser, state, exec) {
|
|
|
176
156
|
function deriveOptionalInnerParseState(outerState, parser) {
|
|
177
157
|
if (Array.isArray(outerState)) {
|
|
178
158
|
const innerState = outerState[0];
|
|
179
|
-
if (require_annotations.getAnnotations(outerState) != null && innerState != null && typeof innerState === "object") return
|
|
159
|
+
if (require_annotations.getAnnotations(outerState) != null && innerState != null && typeof innerState === "object") return require_annotation_state.getDelegatedAnnotationState(outerState, innerState);
|
|
180
160
|
return innerState;
|
|
181
161
|
}
|
|
182
162
|
const initial = parser.initialState;
|
|
183
163
|
if (initial != null && typeof initial !== "object") return initial;
|
|
184
|
-
return require_annotations.inheritAnnotations(outerState, initial);
|
|
164
|
+
return initial != null && typeof initial === "object" ? require_annotation_state.getDelegatedAnnotationState(outerState, initial) : require_annotations.inheritAnnotations(outerState, initial);
|
|
185
165
|
}
|
|
186
166
|
/**
|
|
187
167
|
* Internal helper for optional-style parsing logic shared by optional()
|
|
188
168
|
* and withDefault(). Handles the common pattern of:
|
|
189
169
|
* - Unwrapping optional state to inner parser state
|
|
190
|
-
* - Detecting if inner parser actually matched (state changed or no consumption)
|
|
191
|
-
* - Returning success with undefined state when inner parser fails without consuming
|
|
170
|
+
* - Detecting if the inner parser actually matched (state changed or no consumption)
|
|
171
|
+
* - Returning success with undefined state when the inner parser fails without consuming
|
|
192
172
|
* @internal
|
|
193
173
|
*/
|
|
194
174
|
function parseOptionalStyleSync(context, parser) {
|
|
@@ -215,9 +195,12 @@ async function parseOptionalStyleAsync(context, parser) {
|
|
|
215
195
|
* Internal helper to process optional-style parse results.
|
|
216
196
|
* @internal
|
|
217
197
|
*/
|
|
198
|
+
function hasOptionalLikeParseStateChanged(previousState, nextState) {
|
|
199
|
+
return previousState !== nextState && require_annotation_state.normalizeDelegatedAnnotationState(previousState) !== require_annotation_state.normalizeDelegatedAnnotationState(nextState);
|
|
200
|
+
}
|
|
218
201
|
function processOptionalStyleResult(result, innerState, context) {
|
|
219
202
|
if (result.success) {
|
|
220
|
-
if (result.next.state
|
|
203
|
+
if (hasOptionalLikeParseStateChanged(innerState, result.next.state) || result.consumed.length === 0) return {
|
|
221
204
|
success: true,
|
|
222
205
|
...result.provisional ? { provisional: true } : {},
|
|
223
206
|
next: {
|
|
@@ -249,7 +232,7 @@ function processOptionalStyleResult(result, innerState, context) {
|
|
|
249
232
|
* {@link withDefault} before delegating to the inner parser's hook.
|
|
250
233
|
*
|
|
251
234
|
* When state is an array, the adapter unwraps `state[0]` and propagates
|
|
252
|
-
* annotations from the outer array. Non-array objects (e.g
|
|
235
|
+
* annotations from the outer array. Non-array objects (e.g. PromptBindState
|
|
253
236
|
* from `prompt()`) are passed through directly. `undefined` returns `false`
|
|
254
237
|
* without calling the inner hook.
|
|
255
238
|
*
|
|
@@ -266,7 +249,7 @@ function adaptShouldDeferCompletion(innerCheck, parser) {
|
|
|
266
249
|
if (!result && shouldRetryFalseResult) return innerCheck(require_annotation_state.normalizeDelegatedAnnotationState(innerState), exec);
|
|
267
250
|
return result;
|
|
268
251
|
} catch (error) {
|
|
269
|
-
if (!
|
|
252
|
+
if (!shouldRetryOptionalLikeCompatibilityError(error, innerState)) throw error;
|
|
270
253
|
return innerCheck(require_annotation_state.normalizeDelegatedAnnotationState(innerState), exec);
|
|
271
254
|
}
|
|
272
255
|
}
|
|
@@ -324,7 +307,7 @@ function optional(parser) {
|
|
|
324
307
|
for await (const s of suggestions) yield s;
|
|
325
308
|
}
|
|
326
309
|
const optionalParser = {
|
|
327
|
-
|
|
310
|
+
mode: parser.mode,
|
|
328
311
|
$valueType: [],
|
|
329
312
|
$stateType: [],
|
|
330
313
|
...parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true ? { [require_parser.unmatchedNonCliDependencySourceStateMarker]: true } : {},
|
|
@@ -355,13 +338,13 @@ function optional(parser) {
|
|
|
355
338
|
return extractOptionalLikePhase2Seed(parser, state, exec);
|
|
356
339
|
},
|
|
357
340
|
parse(context) {
|
|
358
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
341
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => parseOptionalStyleSync(context, syncParser), () => parseOptionalStyleAsync(context, parser));
|
|
359
342
|
},
|
|
360
343
|
complete(state, exec) {
|
|
361
344
|
if (!Array.isArray(state)) {
|
|
362
345
|
const delegateToInner = (resolvedInnerState) => {
|
|
363
|
-
const innerResult = require_mode_dispatch.dispatchByMode(parser
|
|
364
|
-
return require_mode_dispatch.mapModeValue(parser
|
|
346
|
+
const innerResult = require_mode_dispatch.dispatchByMode(parser.mode, () => completeOptionalLikeSync(syncParser, resolvedInnerState, exec), async () => await completeOptionalLikeAsync(parser, resolvedInnerState, exec));
|
|
347
|
+
return require_mode_dispatch.mapModeValue(parser.mode, innerResult, (result) => result.success ? result : {
|
|
365
348
|
success: true,
|
|
366
349
|
value: void 0
|
|
367
350
|
});
|
|
@@ -373,7 +356,7 @@ function optional(parser) {
|
|
|
373
356
|
const sourceMetadata = parser.dependencyMetadata?.source;
|
|
374
357
|
if (sourceMetadata?.preservesSourceValue !== false && sourceMetadata?.getMissingSourceValue != null) {
|
|
375
358
|
const delegatedState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
376
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
359
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => completeOptionalLikeSync(syncParser, delegatedState, exec), async () => await completeOptionalLikeAsync(parser, delegatedState, exec));
|
|
377
360
|
}
|
|
378
361
|
if (parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object") {
|
|
379
362
|
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
@@ -385,10 +368,10 @@ function optional(parser) {
|
|
|
385
368
|
};
|
|
386
369
|
}
|
|
387
370
|
const innerElement = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
388
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
371
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => completeOptionalLikeSync(syncParser, innerElement, exec), async () => await completeOptionalLikeAsync(parser, innerElement, exec));
|
|
389
372
|
},
|
|
390
373
|
suggest(context, prefix) {
|
|
391
|
-
return require_mode_dispatch.dispatchIterableByMode(parser
|
|
374
|
+
return require_mode_dispatch.dispatchIterableByMode(parser.mode, () => suggestSync(context, prefix), () => suggestAsync(context, prefix));
|
|
392
375
|
},
|
|
393
376
|
getDocFragments(state, defaultValue) {
|
|
394
377
|
const innerState = state.kind === "unavailable" ? { kind: "unavailable" } : state.state === void 0 ? { kind: "unavailable" } : {
|
|
@@ -413,7 +396,7 @@ function optional(parser) {
|
|
|
413
396
|
const innerValidate = parser.validateValue.bind(parser);
|
|
414
397
|
Object.defineProperty(optionalParser, "validateValue", {
|
|
415
398
|
value(v) {
|
|
416
|
-
if (v === void 0) return require_mode_dispatch.wrapForMode(parser
|
|
399
|
+
if (v === void 0) return require_mode_dispatch.wrapForMode(parser.mode, {
|
|
417
400
|
success: true,
|
|
418
401
|
value: v
|
|
419
402
|
});
|
|
@@ -493,7 +476,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
493
476
|
for await (const s of suggestions) yield s;
|
|
494
477
|
}
|
|
495
478
|
const withDefaultParser = {
|
|
496
|
-
|
|
479
|
+
mode: parser.mode,
|
|
497
480
|
$valueType: [],
|
|
498
481
|
$stateType: [],
|
|
499
482
|
...parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true ? { [require_parser.unmatchedNonCliDependencySourceStateMarker]: true } : {},
|
|
@@ -523,7 +506,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
523
506
|
return extractOptionalLikePhase2Seed(parser, state, exec);
|
|
524
507
|
},
|
|
525
508
|
parse(context) {
|
|
526
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
509
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => parseOptionalStyleSync(context, syncParser), () => parseOptionalStyleAsync(context, parser));
|
|
527
510
|
},
|
|
528
511
|
complete(state, exec) {
|
|
529
512
|
function evaluateDefault() {
|
|
@@ -536,12 +519,12 @@ function withDefault(parser, defaultValue, options) {
|
|
|
536
519
|
if (!Array.isArray(state)) {
|
|
537
520
|
if (typeof parser.shouldDeferCompletion === "function" && state != null && typeof state === "object") {
|
|
538
521
|
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
539
|
-
const innerResult = require_mode_dispatch.dispatchByMode(parser
|
|
522
|
+
const innerResult = require_mode_dispatch.dispatchByMode(parser.mode, () => completeOptionalLikeSync(syncParser, innerState, exec), async () => await completeOptionalLikeAsync(parser, innerState, exec));
|
|
540
523
|
return innerResult;
|
|
541
524
|
}
|
|
542
525
|
if (parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object") {
|
|
543
526
|
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
544
|
-
const innerResult = require_mode_dispatch.dispatchByMode(parser
|
|
527
|
+
const innerResult = require_mode_dispatch.dispatchByMode(parser.mode, () => completeOptionalLikeSync(syncParser, innerState, exec), async () => await completeOptionalLikeAsync(parser, innerState, exec));
|
|
545
528
|
const handleInnerResult = (result) => {
|
|
546
529
|
if (result.success && result.value !== void 0) return result;
|
|
547
530
|
try {
|
|
@@ -556,7 +539,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
556
539
|
};
|
|
557
540
|
}
|
|
558
541
|
};
|
|
559
|
-
return require_mode_dispatch.mapModeValue(parser
|
|
542
|
+
return require_mode_dispatch.mapModeValue(parser.mode, innerResult, handleInnerResult);
|
|
560
543
|
}
|
|
561
544
|
try {
|
|
562
545
|
const value = evaluateDefault();
|
|
@@ -572,10 +555,10 @@ function withDefault(parser, defaultValue, options) {
|
|
|
572
555
|
}
|
|
573
556
|
}
|
|
574
557
|
const innerElement = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
575
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
558
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => completeOptionalLikeSync(syncParser, innerElement, exec), async () => await completeOptionalLikeAsync(parser, innerElement, exec));
|
|
576
559
|
},
|
|
577
560
|
suggest(context, prefix) {
|
|
578
|
-
return require_mode_dispatch.dispatchIterableByMode(parser
|
|
561
|
+
return require_mode_dispatch.dispatchIterableByMode(parser.mode, () => suggestSync(context, prefix), () => suggestAsync(context, prefix));
|
|
579
562
|
},
|
|
580
563
|
getDocFragments(state, upperDefaultValue) {
|
|
581
564
|
const innerState = state.kind === "unavailable" ? { kind: "unavailable" } : state.state === void 0 ? { kind: "unavailable" } : {
|
|
@@ -737,7 +720,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
737
720
|
*/
|
|
738
721
|
function map(parser, transform) {
|
|
739
722
|
const complete = (state, exec) => {
|
|
740
|
-
return require_mode_dispatch.mapModeValue(parser
|
|
723
|
+
return require_mode_dispatch.mapModeValue(parser.mode, parser.complete(state, exec), (result) => {
|
|
741
724
|
if (!result.success) return result;
|
|
742
725
|
if (result.deferred) try {
|
|
743
726
|
return {
|
|
@@ -763,7 +746,7 @@ function map(parser, transform) {
|
|
|
763
746
|
$valueType: [],
|
|
764
747
|
complete,
|
|
765
748
|
[require_phase2_seed.extractPhase2SeedKey](state, exec) {
|
|
766
|
-
return require_mode_dispatch.mapModeValue(parser
|
|
749
|
+
return require_mode_dispatch.mapModeValue(parser.mode, require_phase2_seed.completeOrExtractPhase2Seed(parser, state, exec), (seed) => {
|
|
767
750
|
if (seed == null) return null;
|
|
768
751
|
if (seed.deferred) try {
|
|
769
752
|
return {
|
|
@@ -955,13 +938,13 @@ function multiple(parser, options = {}) {
|
|
|
955
938
|
let added = !canExtendCurrent;
|
|
956
939
|
let itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
|
|
957
940
|
const currentItemStateWithAnnotations = canExtendCurrent ? currentItemState : require_annotations.inheritAnnotations(context.state, syncParser.initialState);
|
|
958
|
-
let result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, currentItemStateWithAnnotations));
|
|
941
|
+
let result = parseSyncWithUnwrappedFallback(require_execution_context.withChildContext(context, itemIndex, currentItemStateWithAnnotations));
|
|
959
942
|
if (!result.success) {
|
|
960
943
|
if (result.consumed !== 0) return result;
|
|
961
944
|
if (!added && canOpenFreshItem) {
|
|
962
945
|
const nextInitialState = require_annotations.inheritAnnotations(context.state, syncParser.initialState);
|
|
963
946
|
itemIndex = context.state.length;
|
|
964
|
-
result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
|
|
947
|
+
result = parseSyncWithUnwrappedFallback(require_execution_context.withChildContext(context, itemIndex, nextInitialState));
|
|
965
948
|
if (!result.success) {
|
|
966
949
|
if (min === 0 && context.buffer.length === 0 && result.consumed === 0) return {
|
|
967
950
|
success: true,
|
|
@@ -978,7 +961,7 @@ function multiple(parser, options = {}) {
|
|
|
978
961
|
};
|
|
979
962
|
else return result;
|
|
980
963
|
}
|
|
981
|
-
const mergedExec = mergeChildExec(context.exec, result.next.exec);
|
|
964
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
982
965
|
if (added && result.consumed.length === 0 && result.next.optionsTerminated === context.optionsTerminated && isUnstartedMultipleItemState(result.next.state, currentItemStateWithAnnotations)) return {
|
|
983
966
|
success: true,
|
|
984
967
|
next: {
|
|
@@ -1035,13 +1018,13 @@ function multiple(parser, options = {}) {
|
|
|
1035
1018
|
let added = !canExtendCurrent;
|
|
1036
1019
|
let itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
|
|
1037
1020
|
const currentItemStateWithAnnotations = canExtendCurrent ? currentItemState : require_annotations.inheritAnnotations(context.state, parser.initialState);
|
|
1038
|
-
let result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, currentItemStateWithAnnotations));
|
|
1021
|
+
let result = await parseAsyncWithUnwrappedFallback(require_execution_context.withChildContext(context, itemIndex, currentItemStateWithAnnotations));
|
|
1039
1022
|
if (!result.success) {
|
|
1040
1023
|
if (result.consumed !== 0) return result;
|
|
1041
1024
|
if (!added && canOpenFreshItem) {
|
|
1042
1025
|
const nextInitialState = require_annotations.inheritAnnotations(context.state, parser.initialState);
|
|
1043
1026
|
itemIndex = context.state.length;
|
|
1044
|
-
result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
|
|
1027
|
+
result = await parseAsyncWithUnwrappedFallback(require_execution_context.withChildContext(context, itemIndex, nextInitialState));
|
|
1045
1028
|
if (!result.success) {
|
|
1046
1029
|
if (min === 0 && context.buffer.length === 0 && result.consumed === 0) return {
|
|
1047
1030
|
success: true,
|
|
@@ -1058,7 +1041,7 @@ function multiple(parser, options = {}) {
|
|
|
1058
1041
|
};
|
|
1059
1042
|
else return result;
|
|
1060
1043
|
}
|
|
1061
|
-
const mergedExec = mergeChildExec(context.exec, result.next.exec);
|
|
1044
|
+
const mergedExec = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
1062
1045
|
if (added && result.consumed.length === 0 && result.next.optionsTerminated === context.optionsTerminated && isUnstartedMultipleItemState(result.next.state, currentItemStateWithAnnotations)) return {
|
|
1063
1046
|
success: true,
|
|
1064
1047
|
next: {
|
|
@@ -1104,7 +1087,7 @@ function multiple(parser, options = {}) {
|
|
|
1104
1087
|
};
|
|
1105
1088
|
};
|
|
1106
1089
|
const resultParser = {
|
|
1107
|
-
|
|
1090
|
+
mode: parser.mode,
|
|
1108
1091
|
$valueType: [],
|
|
1109
1092
|
$stateType: [],
|
|
1110
1093
|
priority: parser.priority,
|
|
@@ -1125,15 +1108,15 @@ function multiple(parser, options = {}) {
|
|
|
1125
1108
|
}, ...innerNodes] : innerNodes;
|
|
1126
1109
|
},
|
|
1127
1110
|
parse(context) {
|
|
1128
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
1111
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => parseSync(context), () => parseAsync(context));
|
|
1129
1112
|
},
|
|
1130
1113
|
complete(state, exec) {
|
|
1131
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
1114
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => {
|
|
1132
1115
|
const result = [];
|
|
1133
1116
|
const deferredIndices = /* @__PURE__ */ new Map();
|
|
1134
1117
|
let hasDeferred = false;
|
|
1135
1118
|
for (let i = 0; i < state.length; i++) {
|
|
1136
|
-
const valueResult = completeSyncWithUnwrappedFallback(state[i], withChildExecPath(exec, i));
|
|
1119
|
+
const valueResult = completeSyncWithUnwrappedFallback(state[i], require_execution_context.withChildExecPath(exec, i));
|
|
1137
1120
|
if (valueResult.success) {
|
|
1138
1121
|
const unwrappedValue = unwrapInjectedWrapper(valueResult.value);
|
|
1139
1122
|
result.push(unwrappedValue);
|
|
@@ -1151,7 +1134,7 @@ function multiple(parser, options = {}) {
|
|
|
1151
1134
|
const deferredIndices = /* @__PURE__ */ new Map();
|
|
1152
1135
|
let hasDeferred = false;
|
|
1153
1136
|
for (let i = 0; i < state.length; i++) {
|
|
1154
|
-
const valueResult = await completeAsyncWithUnwrappedFallback(state[i], withChildExecPath(exec, i));
|
|
1137
|
+
const valueResult = await completeAsyncWithUnwrappedFallback(state[i], require_execution_context.withChildExecPath(exec, i));
|
|
1155
1138
|
if (valueResult.success) {
|
|
1156
1139
|
const unwrappedValue = unwrapInjectedWrapper(valueResult.value);
|
|
1157
1140
|
values.push(unwrappedValue);
|
|
@@ -1167,13 +1150,13 @@ function multiple(parser, options = {}) {
|
|
|
1167
1150
|
});
|
|
1168
1151
|
},
|
|
1169
1152
|
[require_phase2_seed.extractPhase2SeedKey](state, exec) {
|
|
1170
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
1153
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => {
|
|
1171
1154
|
const values = [];
|
|
1172
1155
|
const deferredIndices = /* @__PURE__ */ new Map();
|
|
1173
1156
|
let hasDeferred = false;
|
|
1174
1157
|
let hasAnySeed = false;
|
|
1175
1158
|
for (let i = 0; i < state.length; i++) {
|
|
1176
|
-
const seed = extractPhase2SeedSyncWithUnwrappedFallback(state[i], withChildExecPath(exec, i));
|
|
1159
|
+
const seed = extractPhase2SeedSyncWithUnwrappedFallback(state[i], require_execution_context.withChildExecPath(exec, i));
|
|
1177
1160
|
if (seed == null) continue;
|
|
1178
1161
|
hasAnySeed = true;
|
|
1179
1162
|
values[i] = seed.value;
|
|
@@ -1195,7 +1178,7 @@ function multiple(parser, options = {}) {
|
|
|
1195
1178
|
let hasDeferred = false;
|
|
1196
1179
|
let hasAnySeed = false;
|
|
1197
1180
|
for (let i = 0; i < state.length; i++) {
|
|
1198
|
-
const seed = await extractPhase2SeedAsyncWithUnwrappedFallback(state[i], withChildExecPath(exec, i));
|
|
1181
|
+
const seed = await extractPhase2SeedAsyncWithUnwrappedFallback(state[i], require_execution_context.withChildExecPath(exec, i));
|
|
1199
1182
|
if (seed == null) continue;
|
|
1200
1183
|
hasAnySeed = true;
|
|
1201
1184
|
values[i] = seed.value;
|
|
@@ -1217,7 +1200,7 @@ function multiple(parser, options = {}) {
|
|
|
1217
1200
|
const currentItemState = context.state.at(-1);
|
|
1218
1201
|
const canExtendCurrent = currentItemState != null && !isTerminalMultipleItemState(currentItemState);
|
|
1219
1202
|
const canOpenNew = context.state.length < max;
|
|
1220
|
-
if (!canExtendCurrent && !canOpenNew) return require_mode_dispatch.dispatchIterableByMode(parser
|
|
1203
|
+
if (!canExtendCurrent && !canOpenNew) return require_mode_dispatch.dispatchIterableByMode(parser.mode, function* () {}, async function* () {});
|
|
1221
1204
|
const itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
|
|
1222
1205
|
const suggestInitialState = canExtendCurrent ? currentItemState : require_annotations.inheritAnnotations(context.state, parser.initialState);
|
|
1223
1206
|
const suggestFallbackState = unwrapInjectedWrapper(suggestInitialState);
|
|
@@ -1225,7 +1208,7 @@ function multiple(parser, options = {}) {
|
|
|
1225
1208
|
const collectSelectedValuesSync = () => {
|
|
1226
1209
|
const selectedValues = /* @__PURE__ */ new Set();
|
|
1227
1210
|
for (let i = 0; i < context.state.length; i++) {
|
|
1228
|
-
const childContext = withChildContext(context, i, context.state[i]);
|
|
1211
|
+
const childContext = require_execution_context.withChildContext(context, i, context.state[i]);
|
|
1229
1212
|
const completed = completeSyncWithUnwrappedFallback(childContext.state, childContext.exec);
|
|
1230
1213
|
if (completed.success) selectedValues.add(String(unwrapInjectedWrapper(completed.value)));
|
|
1231
1214
|
}
|
|
@@ -1234,7 +1217,7 @@ function multiple(parser, options = {}) {
|
|
|
1234
1217
|
const collectSelectedValuesAsync = async () => {
|
|
1235
1218
|
const selectedValues = /* @__PURE__ */ new Set();
|
|
1236
1219
|
for (let i = 0; i < context.state.length; i++) {
|
|
1237
|
-
const childContext = withChildContext(context, i, context.state[i]);
|
|
1220
|
+
const childContext = require_execution_context.withChildContext(context, i, context.state[i]);
|
|
1238
1221
|
const completed = await completeAsyncWithUnwrappedFallback(childContext.state, childContext.exec);
|
|
1239
1222
|
if (completed.success) selectedValues.add(String(unwrapInjectedWrapper(completed.value)));
|
|
1240
1223
|
}
|
|
@@ -1260,7 +1243,7 @@ function multiple(parser, options = {}) {
|
|
|
1260
1243
|
description
|
|
1261
1244
|
]);
|
|
1262
1245
|
};
|
|
1263
|
-
return require_mode_dispatch.dispatchIterableByMode(parser
|
|
1246
|
+
return require_mode_dispatch.dispatchIterableByMode(parser.mode, function* () {
|
|
1264
1247
|
const selectedValues = collectSelectedValuesSync();
|
|
1265
1248
|
const emitted = /* @__PURE__ */ new Set();
|
|
1266
1249
|
const yieldUnique = function* (suggestions) {
|
|
@@ -1274,12 +1257,12 @@ function multiple(parser, options = {}) {
|
|
|
1274
1257
|
};
|
|
1275
1258
|
let shouldTryFallback = false;
|
|
1276
1259
|
try {
|
|
1277
|
-
yield* yieldUnique(syncParser.suggest(withChildContext(context, itemIndex, suggestInitialState), prefix));
|
|
1260
|
+
yield* yieldUnique(syncParser.suggest(require_execution_context.withChildContext(context, itemIndex, suggestInitialState), prefix));
|
|
1278
1261
|
} catch (error) {
|
|
1279
1262
|
if (!hasSuggestFallbackState) throw error;
|
|
1280
1263
|
shouldTryFallback = true;
|
|
1281
1264
|
}
|
|
1282
|
-
if (shouldTryFallback) yield* yieldUnique(syncParser.suggest(withChildContext(context, itemIndex, suggestFallbackState), prefix));
|
|
1265
|
+
if (shouldTryFallback) yield* yieldUnique(syncParser.suggest(require_execution_context.withChildContext(context, itemIndex, suggestFallbackState), prefix));
|
|
1283
1266
|
}, async function* () {
|
|
1284
1267
|
const selectedValues = await collectSelectedValuesAsync();
|
|
1285
1268
|
const emitted = /* @__PURE__ */ new Set();
|
|
@@ -1294,12 +1277,12 @@ function multiple(parser, options = {}) {
|
|
|
1294
1277
|
};
|
|
1295
1278
|
let shouldTryFallback = false;
|
|
1296
1279
|
try {
|
|
1297
|
-
yield* yieldUnique(parser.suggest(withChildContext(context, itemIndex, suggestInitialState), prefix));
|
|
1280
|
+
yield* yieldUnique(parser.suggest(require_execution_context.withChildContext(context, itemIndex, suggestInitialState), prefix));
|
|
1298
1281
|
} catch (error) {
|
|
1299
1282
|
if (!hasSuggestFallbackState) throw error;
|
|
1300
1283
|
shouldTryFallback = true;
|
|
1301
1284
|
}
|
|
1302
|
-
if (shouldTryFallback) yield* yieldUnique(parser.suggest(withChildContext(context, itemIndex, suggestFallbackState), prefix));
|
|
1285
|
+
if (shouldTryFallback) yield* yieldUnique(parser.suggest(require_execution_context.withChildContext(context, itemIndex, suggestFallbackState), prefix));
|
|
1303
1286
|
});
|
|
1304
1287
|
},
|
|
1305
1288
|
getDocFragments(state, defaultValue) {
|
|
@@ -1393,15 +1376,15 @@ function multiple(parser, options = {}) {
|
|
|
1393
1376
|
value(values) {
|
|
1394
1377
|
if (!Array.isArray(values)) {
|
|
1395
1378
|
const actualType = values === null ? "null" : typeof values;
|
|
1396
|
-
return require_mode_dispatch.wrapForMode(parser
|
|
1379
|
+
return require_mode_dispatch.wrapForMode(parser.mode, {
|
|
1397
1380
|
success: false,
|
|
1398
1381
|
error: require_message.message`Expected an array of values, but received ${actualType}.`
|
|
1399
1382
|
});
|
|
1400
1383
|
}
|
|
1401
1384
|
const arity = validateArity(values);
|
|
1402
|
-
if (!arity.success) return require_mode_dispatch.wrapForMode(parser
|
|
1403
|
-
if (innerValidate == null) return require_mode_dispatch.wrapForMode(parser
|
|
1404
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
1385
|
+
if (!arity.success) return require_mode_dispatch.wrapForMode(parser.mode, arity);
|
|
1386
|
+
if (innerValidate == null) return require_mode_dispatch.wrapForMode(parser.mode, arity);
|
|
1387
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => {
|
|
1405
1388
|
let changed = false;
|
|
1406
1389
|
const normalized = [];
|
|
1407
1390
|
for (const v of values) {
|
|
@@ -1519,7 +1502,7 @@ function nonEmpty(parser) {
|
|
|
1519
1502
|
return processNonEmptyResult(result);
|
|
1520
1503
|
};
|
|
1521
1504
|
const nonEmptyParser = {
|
|
1522
|
-
|
|
1505
|
+
mode: parser.mode,
|
|
1523
1506
|
$valueType: parser.$valueType,
|
|
1524
1507
|
$stateType: parser.$stateType,
|
|
1525
1508
|
priority: parser.priority,
|
|
@@ -1536,7 +1519,7 @@ function nonEmpty(parser) {
|
|
|
1536
1519
|
}] : []);
|
|
1537
1520
|
},
|
|
1538
1521
|
parse(context) {
|
|
1539
|
-
return require_mode_dispatch.dispatchByMode(parser
|
|
1522
|
+
return require_mode_dispatch.dispatchByMode(parser.mode, () => parseSync(context), () => parseAsync(context));
|
|
1540
1523
|
},
|
|
1541
1524
|
complete(state, exec) {
|
|
1542
1525
|
return parser.complete(state, exec);
|
package/dist/modifiers.d.cts
CHANGED
package/dist/modifiers.d.ts
CHANGED