@optique/core 1.0.0-dev.1658 → 1.0.0-dev.1661

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/parser.cjs CHANGED
@@ -24,6 +24,26 @@ const require_constructs = require('./constructs.cjs');
24
24
  */
25
25
  const unmatchedNonCliDependencySourceStateMarker = Symbol.for("@optique/core/parser/unmatchedNonCliDependencySourceStateMarker");
26
26
  /**
27
+ * Internal marker for parsers that want parent-state annotations injected
28
+ * directly into rebuilt child states instead of relying on structural
29
+ * inheritance.
30
+ *
31
+ * Wrappers like `bindConfig()`, `bindEnv()`, and `prompt()` opt in because
32
+ * their fallback contracts depend on carrying annotations through wrapper
33
+ * state objects during parse, complete, and suggest.
34
+ *
35
+ * @internal
36
+ */
37
+ const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
38
+ /**
39
+ * Internal marker for wrapper parsers that should only treat annotation-only
40
+ * primitive wrapper states as completable when a nested source-binding wrapper
41
+ * produced them.
42
+ *
43
+ * @internal
44
+ */
45
+ const annotationWrapperRequiresSourceBindingKey = Symbol.for("@optique/core/annotationWrapperRequiresSourceBinding");
46
+ /**
27
47
  * Creates a {@link ParserContext} from a {@link ParseFrame} and an
28
48
  * {@link ExecutionContext}. The returned object provides both structured
29
49
  * access (`frame`, `exec`) and flat access (`buffer`, `state`, etc.)
@@ -336,6 +356,66 @@ function getParserSuggestRuntimeNodes(parser, state, path) {
336
356
  }];
337
357
  }
338
358
  /**
359
+ * Returns wrapper-aware suggest-time runtime nodes for parsers that delegate
360
+ * to an inner parser while also exposing their own source metadata.
361
+ *
362
+ * The inner parser's nodes are always preserved so nested wrappers and
363
+ * constructs can continue to seed the dependency runtime recursively. When
364
+ * the outer parser itself owns source metadata, its `(path, parser, state)`
365
+ * node is appended so outer precedence rules still apply.
366
+ *
367
+ * @internal
368
+ */
369
+ function getDelegatingSuggestRuntimeNodes(innerParser, outerParser, state, path, innerState, outerPosition = "append") {
370
+ const innerNodes = getParserSuggestRuntimeNodes(innerParser, innerState, path);
371
+ if (outerParser.dependencyMetadata?.source == null) return innerNodes;
372
+ const outerNode = {
373
+ path,
374
+ parser: outerParser,
375
+ state
376
+ };
377
+ return outerPosition === "prepend" ? [outerNode, ...innerNodes] : [...innerNodes, outerNode];
378
+ }
379
+ /**
380
+ * Composes source metadata for a wrapper parser while preserving any derived
381
+ * or transform capabilities from the inner parser unchanged.
382
+ *
383
+ * @internal
384
+ */
385
+ function composeWrappedSourceMetadata(dependencyMetadata, wrapSource) {
386
+ if (dependencyMetadata?.source == null) return dependencyMetadata;
387
+ return {
388
+ ...dependencyMetadata,
389
+ source: wrapSource(dependencyMetadata.source)
390
+ };
391
+ }
392
+ /**
393
+ * Marks a parser as inheriting parent-state annotations through wrapper-state
394
+ * reconstruction.
395
+ *
396
+ * @internal
397
+ */
398
+ function defineInheritedAnnotationParser(parser) {
399
+ Object.defineProperty(parser, inheritParentAnnotationsKey, {
400
+ value: true,
401
+ configurable: true,
402
+ enumerable: false
403
+ });
404
+ }
405
+ /**
406
+ * Marks a wrapper parser as requiring a real source-binding state before
407
+ * annotation-only primitive wrappers should trigger completion.
408
+ *
409
+ * @internal
410
+ */
411
+ function defineSourceBindingOnlyAnnotationCompletionParser(parser) {
412
+ Object.defineProperty(parser, annotationWrapperRequiresSourceBindingKey, {
413
+ value: true,
414
+ configurable: true,
415
+ enumerable: false
416
+ });
417
+ }
418
+ /**
339
419
  * Generates command-line suggestions based on current parsing state.
340
420
  * This function processes the input arguments up to the last argument,
341
421
  * then calls the parser's suggest method with the remaining prefix.
@@ -624,19 +704,25 @@ function buildDocPage(parser, context, args) {
624
704
  //#endregion
625
705
  exports.DuplicateOptionError = require_constructs.DuplicateOptionError;
626
706
  exports.WithDefaultError = require_modifiers.WithDefaultError;
707
+ exports.annotationWrapperRequiresSourceBindingKey = annotationWrapperRequiresSourceBindingKey;
627
708
  exports.argument = require_primitives.argument;
628
709
  exports.command = require_primitives.command;
710
+ exports.composeWrappedSourceMetadata = composeWrappedSourceMetadata;
629
711
  exports.concat = require_constructs.concat;
630
712
  exports.conditional = require_constructs.conditional;
631
713
  exports.constant = require_primitives.constant;
632
714
  exports.createParserContext = createParserContext;
715
+ exports.defineInheritedAnnotationParser = defineInheritedAnnotationParser;
716
+ exports.defineSourceBindingOnlyAnnotationCompletionParser = defineSourceBindingOnlyAnnotationCompletionParser;
633
717
  exports.fail = require_primitives.fail;
634
718
  exports.flag = require_primitives.flag;
719
+ exports.getDelegatingSuggestRuntimeNodes = getDelegatingSuggestRuntimeNodes;
635
720
  exports.getDocPage = getDocPage;
636
721
  exports.getDocPageAsync = getDocPageAsync;
637
722
  exports.getDocPageSync = getDocPageSync;
638
723
  exports.getParserSuggestRuntimeNodes = getParserSuggestRuntimeNodes;
639
724
  exports.group = require_constructs.group;
725
+ exports.inheritParentAnnotationsKey = inheritParentAnnotationsKey;
640
726
  exports.longestMatch = require_constructs.longestMatch;
641
727
  exports.map = require_modifiers.map;
642
728
  exports.merge = require_constructs.merge;
package/dist/parser.d.cts CHANGED
@@ -399,6 +399,26 @@ interface ExecutionContext {
399
399
  * @internal
400
400
  */
401
401
  declare const unmatchedNonCliDependencySourceStateMarker: unique symbol;
402
+ /**
403
+ * Internal marker for parsers that want parent-state annotations injected
404
+ * directly into rebuilt child states instead of relying on structural
405
+ * inheritance.
406
+ *
407
+ * Wrappers like `bindConfig()`, `bindEnv()`, and `prompt()` opt in because
408
+ * their fallback contracts depend on carrying annotations through wrapper
409
+ * state objects during parse, complete, and suggest.
410
+ *
411
+ * @internal
412
+ */
413
+ declare const inheritParentAnnotationsKey: unique symbol;
414
+ /**
415
+ * Internal marker for wrapper parsers that should only treat annotation-only
416
+ * primitive wrapper states as completable when a nested source-binding wrapper
417
+ * produced them.
418
+ *
419
+ * @internal
420
+ */
421
+ declare const annotationWrapperRequiresSourceBindingKey: unique symbol;
402
422
  /**
403
423
  * The context of the parser, which includes the input buffer and the state.
404
424
  *
@@ -722,6 +742,39 @@ declare function suggestSync<T>(parser: Parser<"sync", T, unknown>, args: readon
722
742
  * @internal
723
743
  */
724
744
  declare function getParserSuggestRuntimeNodes<TState>(parser: Parser<Mode, unknown, TState>, state: TState, path: readonly PropertyKey[]): readonly RuntimeNode[];
745
+ /**
746
+ * Returns wrapper-aware suggest-time runtime nodes for parsers that delegate
747
+ * to an inner parser while also exposing their own source metadata.
748
+ *
749
+ * The inner parser's nodes are always preserved so nested wrappers and
750
+ * constructs can continue to seed the dependency runtime recursively. When
751
+ * the outer parser itself owns source metadata, its `(path, parser, state)`
752
+ * node is appended so outer precedence rules still apply.
753
+ *
754
+ * @internal
755
+ */
756
+ declare function getDelegatingSuggestRuntimeNodes<TInnerState>(innerParser: Parser<Mode, unknown, TInnerState>, outerParser: Parser<Mode, unknown, unknown>, state: unknown, path: readonly PropertyKey[], innerState: TInnerState, outerPosition?: "append" | "prepend"): readonly RuntimeNode[];
757
+ /**
758
+ * Composes source metadata for a wrapper parser while preserving any derived
759
+ * or transform capabilities from the inner parser unchanged.
760
+ *
761
+ * @internal
762
+ */
763
+ declare function composeWrappedSourceMetadata(dependencyMetadata: ParserDependencyMetadata | undefined, wrapSource: (source: NonNullable<ParserDependencyMetadata["source"]>) => NonNullable<ParserDependencyMetadata["source"]>): ParserDependencyMetadata | undefined;
764
+ /**
765
+ * Marks a parser as inheriting parent-state annotations through wrapper-state
766
+ * reconstruction.
767
+ *
768
+ * @internal
769
+ */
770
+ declare function defineInheritedAnnotationParser(parser: object): void;
771
+ /**
772
+ * Marks a wrapper parser as requiring a real source-binding state before
773
+ * annotation-only primitive wrappers should trigger completion.
774
+ *
775
+ * @internal
776
+ */
777
+ declare function defineSourceBindingOnlyAnnotationCompletionParser(parser: object): void;
725
778
  /**
726
779
  * Generates command-line suggestions based on current parsing state.
727
780
  * This function processes the input arguments up to the last argument,
@@ -856,4 +909,4 @@ declare function getDocPage(parser: Parser<"sync", unknown, unknown>, argsOrOpti
856
909
  declare function getDocPage(parser: Parser<"async", unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): Promise<DocPage | undefined>;
857
910
  declare function getDocPage<M extends Mode>(parser: Parser<M, unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): ModeValue<M, DocPage | undefined>;
858
911
  //#endregion
859
- export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, argument, command, concat, conditional, constant, createParserContext, fail, flag, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
912
+ export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
package/dist/parser.d.ts CHANGED
@@ -399,6 +399,26 @@ interface ExecutionContext {
399
399
  * @internal
400
400
  */
401
401
  declare const unmatchedNonCliDependencySourceStateMarker: unique symbol;
402
+ /**
403
+ * Internal marker for parsers that want parent-state annotations injected
404
+ * directly into rebuilt child states instead of relying on structural
405
+ * inheritance.
406
+ *
407
+ * Wrappers like `bindConfig()`, `bindEnv()`, and `prompt()` opt in because
408
+ * their fallback contracts depend on carrying annotations through wrapper
409
+ * state objects during parse, complete, and suggest.
410
+ *
411
+ * @internal
412
+ */
413
+ declare const inheritParentAnnotationsKey: unique symbol;
414
+ /**
415
+ * Internal marker for wrapper parsers that should only treat annotation-only
416
+ * primitive wrapper states as completable when a nested source-binding wrapper
417
+ * produced them.
418
+ *
419
+ * @internal
420
+ */
421
+ declare const annotationWrapperRequiresSourceBindingKey: unique symbol;
402
422
  /**
403
423
  * The context of the parser, which includes the input buffer and the state.
404
424
  *
@@ -722,6 +742,39 @@ declare function suggestSync<T>(parser: Parser<"sync", T, unknown>, args: readon
722
742
  * @internal
723
743
  */
724
744
  declare function getParserSuggestRuntimeNodes<TState>(parser: Parser<Mode, unknown, TState>, state: TState, path: readonly PropertyKey[]): readonly RuntimeNode[];
745
+ /**
746
+ * Returns wrapper-aware suggest-time runtime nodes for parsers that delegate
747
+ * to an inner parser while also exposing their own source metadata.
748
+ *
749
+ * The inner parser's nodes are always preserved so nested wrappers and
750
+ * constructs can continue to seed the dependency runtime recursively. When
751
+ * the outer parser itself owns source metadata, its `(path, parser, state)`
752
+ * node is appended so outer precedence rules still apply.
753
+ *
754
+ * @internal
755
+ */
756
+ declare function getDelegatingSuggestRuntimeNodes<TInnerState>(innerParser: Parser<Mode, unknown, TInnerState>, outerParser: Parser<Mode, unknown, unknown>, state: unknown, path: readonly PropertyKey[], innerState: TInnerState, outerPosition?: "append" | "prepend"): readonly RuntimeNode[];
757
+ /**
758
+ * Composes source metadata for a wrapper parser while preserving any derived
759
+ * or transform capabilities from the inner parser unchanged.
760
+ *
761
+ * @internal
762
+ */
763
+ declare function composeWrappedSourceMetadata(dependencyMetadata: ParserDependencyMetadata | undefined, wrapSource: (source: NonNullable<ParserDependencyMetadata["source"]>) => NonNullable<ParserDependencyMetadata["source"]>): ParserDependencyMetadata | undefined;
764
+ /**
765
+ * Marks a parser as inheriting parent-state annotations through wrapper-state
766
+ * reconstruction.
767
+ *
768
+ * @internal
769
+ */
770
+ declare function defineInheritedAnnotationParser(parser: object): void;
771
+ /**
772
+ * Marks a wrapper parser as requiring a real source-binding state before
773
+ * annotation-only primitive wrappers should trigger completion.
774
+ *
775
+ * @internal
776
+ */
777
+ declare function defineSourceBindingOnlyAnnotationCompletionParser(parser: object): void;
725
778
  /**
726
779
  * Generates command-line suggestions based on current parsing state.
727
780
  * This function processes the input arguments up to the last argument,
@@ -856,4 +909,4 @@ declare function getDocPage(parser: Parser<"sync", unknown, unknown>, argsOrOpti
856
909
  declare function getDocPage(parser: Parser<"async", unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): Promise<DocPage | undefined>;
857
910
  declare function getDocPage<M extends Mode>(parser: Parser<M, unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): ModeValue<M, DocPage | undefined>;
858
911
  //#endregion
859
- export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, argument, command, concat, conditional, constant, createParserContext, fail, flag, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
912
+ export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
package/dist/parser.js CHANGED
@@ -24,6 +24,26 @@ import { DuplicateOptionError, concat, conditional, group, longestMatch, merge,
24
24
  */
25
25
  const unmatchedNonCliDependencySourceStateMarker = Symbol.for("@optique/core/parser/unmatchedNonCliDependencySourceStateMarker");
26
26
  /**
27
+ * Internal marker for parsers that want parent-state annotations injected
28
+ * directly into rebuilt child states instead of relying on structural
29
+ * inheritance.
30
+ *
31
+ * Wrappers like `bindConfig()`, `bindEnv()`, and `prompt()` opt in because
32
+ * their fallback contracts depend on carrying annotations through wrapper
33
+ * state objects during parse, complete, and suggest.
34
+ *
35
+ * @internal
36
+ */
37
+ const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
38
+ /**
39
+ * Internal marker for wrapper parsers that should only treat annotation-only
40
+ * primitive wrapper states as completable when a nested source-binding wrapper
41
+ * produced them.
42
+ *
43
+ * @internal
44
+ */
45
+ const annotationWrapperRequiresSourceBindingKey = Symbol.for("@optique/core/annotationWrapperRequiresSourceBinding");
46
+ /**
27
47
  * Creates a {@link ParserContext} from a {@link ParseFrame} and an
28
48
  * {@link ExecutionContext}. The returned object provides both structured
29
49
  * access (`frame`, `exec`) and flat access (`buffer`, `state`, etc.)
@@ -336,6 +356,66 @@ function getParserSuggestRuntimeNodes(parser, state, path) {
336
356
  }];
337
357
  }
338
358
  /**
359
+ * Returns wrapper-aware suggest-time runtime nodes for parsers that delegate
360
+ * to an inner parser while also exposing their own source metadata.
361
+ *
362
+ * The inner parser's nodes are always preserved so nested wrappers and
363
+ * constructs can continue to seed the dependency runtime recursively. When
364
+ * the outer parser itself owns source metadata, its `(path, parser, state)`
365
+ * node is appended so outer precedence rules still apply.
366
+ *
367
+ * @internal
368
+ */
369
+ function getDelegatingSuggestRuntimeNodes(innerParser, outerParser, state, path, innerState, outerPosition = "append") {
370
+ const innerNodes = getParserSuggestRuntimeNodes(innerParser, innerState, path);
371
+ if (outerParser.dependencyMetadata?.source == null) return innerNodes;
372
+ const outerNode = {
373
+ path,
374
+ parser: outerParser,
375
+ state
376
+ };
377
+ return outerPosition === "prepend" ? [outerNode, ...innerNodes] : [...innerNodes, outerNode];
378
+ }
379
+ /**
380
+ * Composes source metadata for a wrapper parser while preserving any derived
381
+ * or transform capabilities from the inner parser unchanged.
382
+ *
383
+ * @internal
384
+ */
385
+ function composeWrappedSourceMetadata(dependencyMetadata, wrapSource) {
386
+ if (dependencyMetadata?.source == null) return dependencyMetadata;
387
+ return {
388
+ ...dependencyMetadata,
389
+ source: wrapSource(dependencyMetadata.source)
390
+ };
391
+ }
392
+ /**
393
+ * Marks a parser as inheriting parent-state annotations through wrapper-state
394
+ * reconstruction.
395
+ *
396
+ * @internal
397
+ */
398
+ function defineInheritedAnnotationParser(parser) {
399
+ Object.defineProperty(parser, inheritParentAnnotationsKey, {
400
+ value: true,
401
+ configurable: true,
402
+ enumerable: false
403
+ });
404
+ }
405
+ /**
406
+ * Marks a wrapper parser as requiring a real source-binding state before
407
+ * annotation-only primitive wrappers should trigger completion.
408
+ *
409
+ * @internal
410
+ */
411
+ function defineSourceBindingOnlyAnnotationCompletionParser(parser) {
412
+ Object.defineProperty(parser, annotationWrapperRequiresSourceBindingKey, {
413
+ value: true,
414
+ configurable: true,
415
+ enumerable: false
416
+ });
417
+ }
418
+ /**
339
419
  * Generates command-line suggestions based on current parsing state.
340
420
  * This function processes the input arguments up to the last argument,
341
421
  * then calls the parser's suggest method with the remaining prefix.
@@ -622,4 +702,4 @@ function buildDocPage(parser, context, args) {
622
702
  }
623
703
 
624
704
  //#endregion
625
- export { DuplicateOptionError, WithDefaultError, argument, command, concat, conditional, constant, createParserContext, fail, flag, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
705
+ export { DuplicateOptionError, WithDefaultError, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
@@ -232,12 +232,13 @@ function fail() {
232
232
  * if the parser is a derived parser and dependency values are available.
233
233
  * @internal
234
234
  */
235
- function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry) {
235
+ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry, exec) {
236
236
  if (!valueParser.suggest) return;
237
237
  if (require_dependency.isDerivedValueParser(valueParser) && require_dependency.suggestWithDependency in valueParser) {
238
238
  const derived = valueParser;
239
239
  const suggestWithDep = derived[require_dependency.suggestWithDependency];
240
240
  if (suggestWithDep && dependencyRegistry) {
241
+ const dependencyRuntime = exec?.dependencyRuntime;
241
242
  const depIds = require_dependency.getDependencyIds(derived);
242
243
  const defaultsFn = require_dependency.getDefaultValuesFunction(derived);
243
244
  const defaults = defaultsFn?.();
@@ -248,7 +249,8 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry)
248
249
  if (dependencyRegistry.has(depId)) {
249
250
  dependencyValues.push(dependencyRegistry.get(depId));
250
251
  hasAnyValue = true;
251
- } else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
252
+ } else if (dependencyRuntime?.isSourceFailed(depId)) return;
253
+ else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
252
254
  else {
253
255
  yield* valueParser.suggest(prefix);
254
256
  return;
@@ -275,7 +277,7 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
275
277
  const valuePart = prefix.slice(equalsIndex + 1);
276
278
  if (optionNames$1.includes(optionPart)) {
277
279
  if (valueParser && valueParser.suggest) {
278
- const valueSuggestions = getSuggestionsWithDependency(valueParser, valuePart, context.dependencyRegistry);
280
+ const valueSuggestions = getSuggestionsWithDependency(valueParser, valuePart, context.dependencyRegistry, context.exec);
279
281
  for (const suggestion of valueSuggestions) if (suggestion.kind === "literal") yield {
280
282
  kind: "literal",
281
283
  text: `${optionPart}=${suggestion.text}`,
@@ -305,7 +307,7 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
305
307
  const lastToken = context.buffer[context.buffer.length - 1];
306
308
  if (optionNames$1.includes(lastToken)) shouldSuggestValues = true;
307
309
  } else if (context.state === void 0 && context.buffer.length === 0 && (context.exec?.path?.length ?? 0) === 0 && !(prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) shouldSuggestValues = true;
308
- if (shouldSuggestValues) yield* getSuggestionsWithDependency(valueParser, prefix, context.dependencyRegistry);
310
+ if (shouldSuggestValues) yield* getSuggestionsWithDependency(valueParser, prefix, context.dependencyRegistry, context.exec);
309
311
  }
310
312
  }
311
313
  }
@@ -314,12 +316,13 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
314
316
  * if the parser is a derived parser and dependency values are available.
315
317
  * @internal
316
318
  */
317
- async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry) {
319
+ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry, exec) {
318
320
  if (!valueParser.suggest) return;
319
321
  if (require_dependency.isDerivedValueParser(valueParser) && require_dependency.suggestWithDependency in valueParser) {
320
322
  const derived = valueParser;
321
323
  const suggestWithDep = derived[require_dependency.suggestWithDependency];
322
324
  if (suggestWithDep && dependencyRegistry) {
325
+ const dependencyRuntime = exec?.dependencyRuntime;
323
326
  const depIds = require_dependency.getDependencyIds(derived);
324
327
  const defaultsFn = require_dependency.getDefaultValuesFunction(derived);
325
328
  const defaults = defaultsFn?.();
@@ -330,7 +333,8 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
330
333
  if (dependencyRegistry.has(depId)) {
331
334
  dependencyValues.push(dependencyRegistry.get(depId));
332
335
  hasAnyValue = true;
333
- } else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
336
+ } else if (dependencyRuntime?.isSourceFailed(depId)) return;
337
+ else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
334
338
  else {
335
339
  for await (const suggestion of valueParser.suggest(prefix)) yield suggestion;
336
340
  return;
@@ -357,7 +361,7 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
357
361
  const valuePart = prefix.slice(equalsIndex + 1);
358
362
  if (optionNames$1.includes(optionPart)) {
359
363
  if (valueParser && valueParser.suggest) {
360
- const valueSuggestions = getSuggestionsWithDependencyAsync(valueParser, valuePart, context.dependencyRegistry);
364
+ const valueSuggestions = getSuggestionsWithDependencyAsync(valueParser, valuePart, context.dependencyRegistry, context.exec);
361
365
  for await (const suggestion of valueSuggestions) if (suggestion.kind === "literal") yield {
362
366
  kind: "literal",
363
367
  text: `${optionPart}=${suggestion.text}`,
@@ -387,7 +391,7 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
387
391
  const lastToken = context.buffer[context.buffer.length - 1];
388
392
  if (optionNames$1.includes(lastToken)) shouldSuggestValues = true;
389
393
  } else if (context.state === void 0 && context.buffer.length === 0 && (context.exec?.path?.length ?? 0) === 0 && !(prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) shouldSuggestValues = true;
390
- if (shouldSuggestValues) for await (const suggestion of getSuggestionsWithDependencyAsync(valueParser, prefix, context.dependencyRegistry)) yield suggestion;
394
+ if (shouldSuggestValues) for await (const suggestion of getSuggestionsWithDependencyAsync(valueParser, prefix, context.dependencyRegistry, context.exec)) yield suggestion;
391
395
  }
392
396
  }
393
397
  }
@@ -395,17 +399,17 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
395
399
  * Internal sync helper for argument suggest functionality.
396
400
  * @internal
397
401
  */
398
- function* suggestArgumentSync(valueParser, hidden, prefix, dependencyRegistry) {
402
+ function* suggestArgumentSync(valueParser, hidden, prefix, dependencyRegistry, exec) {
399
403
  if (hidden) return;
400
- if (valueParser.suggest) yield* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry);
404
+ if (valueParser.suggest) yield* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry, exec);
401
405
  }
402
406
  /**
403
407
  * Internal async helper for argument suggest functionality.
404
408
  * @internal
405
409
  */
406
- async function* suggestArgumentAsync(valueParser, hidden, prefix, dependencyRegistry) {
410
+ async function* suggestArgumentAsync(valueParser, hidden, prefix, dependencyRegistry, exec) {
407
411
  if (hidden) return;
408
- if (valueParser.suggest) yield* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry);
412
+ if (valueParser.suggest) yield* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry, exec);
409
413
  }
410
414
  function option(...args) {
411
415
  const lastArg = args.at(-1);
@@ -1029,8 +1033,8 @@ function argument(valueParser, options = {}) {
1029
1033
  },
1030
1034
  suggest(context, prefix) {
1031
1035
  if (context.state != null) return require_mode_dispatch.dispatchIterableByMode(valueParser.$mode, function* () {}, async function* () {});
1032
- if (isAsync) return suggestArgumentAsync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry);
1033
- return suggestArgumentSync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry);
1036
+ if (isAsync) return suggestArgumentAsync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
1037
+ return suggestArgumentSync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
1034
1038
  },
1035
1039
  getDocFragments(_state, defaultValue) {
1036
1040
  if (require_usage.isDocHidden(options.hidden)) return {
@@ -232,12 +232,13 @@ function fail() {
232
232
  * if the parser is a derived parser and dependency values are available.
233
233
  * @internal
234
234
  */
235
- function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry) {
235
+ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry, exec) {
236
236
  if (!valueParser.suggest) return;
237
237
  if (isDerivedValueParser(valueParser) && suggestWithDependency in valueParser) {
238
238
  const derived = valueParser;
239
239
  const suggestWithDep = derived[suggestWithDependency];
240
240
  if (suggestWithDep && dependencyRegistry) {
241
+ const dependencyRuntime = exec?.dependencyRuntime;
241
242
  const depIds = getDependencyIds(derived);
242
243
  const defaultsFn = getDefaultValuesFunction(derived);
243
244
  const defaults = defaultsFn?.();
@@ -248,7 +249,8 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry)
248
249
  if (dependencyRegistry.has(depId)) {
249
250
  dependencyValues.push(dependencyRegistry.get(depId));
250
251
  hasAnyValue = true;
251
- } else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
252
+ } else if (dependencyRuntime?.isSourceFailed(depId)) return;
253
+ else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
252
254
  else {
253
255
  yield* valueParser.suggest(prefix);
254
256
  return;
@@ -275,7 +277,7 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
275
277
  const valuePart = prefix.slice(equalsIndex + 1);
276
278
  if (optionNames$1.includes(optionPart)) {
277
279
  if (valueParser && valueParser.suggest) {
278
- const valueSuggestions = getSuggestionsWithDependency(valueParser, valuePart, context.dependencyRegistry);
280
+ const valueSuggestions = getSuggestionsWithDependency(valueParser, valuePart, context.dependencyRegistry, context.exec);
279
281
  for (const suggestion of valueSuggestions) if (suggestion.kind === "literal") yield {
280
282
  kind: "literal",
281
283
  text: `${optionPart}=${suggestion.text}`,
@@ -305,7 +307,7 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
305
307
  const lastToken = context.buffer[context.buffer.length - 1];
306
308
  if (optionNames$1.includes(lastToken)) shouldSuggestValues = true;
307
309
  } else if (context.state === void 0 && context.buffer.length === 0 && (context.exec?.path?.length ?? 0) === 0 && !(prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) shouldSuggestValues = true;
308
- if (shouldSuggestValues) yield* getSuggestionsWithDependency(valueParser, prefix, context.dependencyRegistry);
310
+ if (shouldSuggestValues) yield* getSuggestionsWithDependency(valueParser, prefix, context.dependencyRegistry, context.exec);
309
311
  }
310
312
  }
311
313
  }
@@ -314,12 +316,13 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
314
316
  * if the parser is a derived parser and dependency values are available.
315
317
  * @internal
316
318
  */
317
- async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry) {
319
+ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry, exec) {
318
320
  if (!valueParser.suggest) return;
319
321
  if (isDerivedValueParser(valueParser) && suggestWithDependency in valueParser) {
320
322
  const derived = valueParser;
321
323
  const suggestWithDep = derived[suggestWithDependency];
322
324
  if (suggestWithDep && dependencyRegistry) {
325
+ const dependencyRuntime = exec?.dependencyRuntime;
323
326
  const depIds = getDependencyIds(derived);
324
327
  const defaultsFn = getDefaultValuesFunction(derived);
325
328
  const defaults = defaultsFn?.();
@@ -330,7 +333,8 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
330
333
  if (dependencyRegistry.has(depId)) {
331
334
  dependencyValues.push(dependencyRegistry.get(depId));
332
335
  hasAnyValue = true;
333
- } else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
336
+ } else if (dependencyRuntime?.isSourceFailed(depId)) return;
337
+ else if (defaults && i < defaults.length) dependencyValues.push(defaults[i]);
334
338
  else {
335
339
  for await (const suggestion of valueParser.suggest(prefix)) yield suggestion;
336
340
  return;
@@ -357,7 +361,7 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
357
361
  const valuePart = prefix.slice(equalsIndex + 1);
358
362
  if (optionNames$1.includes(optionPart)) {
359
363
  if (valueParser && valueParser.suggest) {
360
- const valueSuggestions = getSuggestionsWithDependencyAsync(valueParser, valuePart, context.dependencyRegistry);
364
+ const valueSuggestions = getSuggestionsWithDependencyAsync(valueParser, valuePart, context.dependencyRegistry, context.exec);
361
365
  for await (const suggestion of valueSuggestions) if (suggestion.kind === "literal") yield {
362
366
  kind: "literal",
363
367
  text: `${optionPart}=${suggestion.text}`,
@@ -387,7 +391,7 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
387
391
  const lastToken = context.buffer[context.buffer.length - 1];
388
392
  if (optionNames$1.includes(lastToken)) shouldSuggestValues = true;
389
393
  } else if (context.state === void 0 && context.buffer.length === 0 && (context.exec?.path?.length ?? 0) === 0 && !(prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) shouldSuggestValues = true;
390
- if (shouldSuggestValues) for await (const suggestion of getSuggestionsWithDependencyAsync(valueParser, prefix, context.dependencyRegistry)) yield suggestion;
394
+ if (shouldSuggestValues) for await (const suggestion of getSuggestionsWithDependencyAsync(valueParser, prefix, context.dependencyRegistry, context.exec)) yield suggestion;
391
395
  }
392
396
  }
393
397
  }
@@ -395,17 +399,17 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
395
399
  * Internal sync helper for argument suggest functionality.
396
400
  * @internal
397
401
  */
398
- function* suggestArgumentSync(valueParser, hidden, prefix, dependencyRegistry) {
402
+ function* suggestArgumentSync(valueParser, hidden, prefix, dependencyRegistry, exec) {
399
403
  if (hidden) return;
400
- if (valueParser.suggest) yield* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry);
404
+ if (valueParser.suggest) yield* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry, exec);
401
405
  }
402
406
  /**
403
407
  * Internal async helper for argument suggest functionality.
404
408
  * @internal
405
409
  */
406
- async function* suggestArgumentAsync(valueParser, hidden, prefix, dependencyRegistry) {
410
+ async function* suggestArgumentAsync(valueParser, hidden, prefix, dependencyRegistry, exec) {
407
411
  if (hidden) return;
408
- if (valueParser.suggest) yield* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry);
412
+ if (valueParser.suggest) yield* getSuggestionsWithDependencyAsync(valueParser, prefix, dependencyRegistry, exec);
409
413
  }
410
414
  function option(...args) {
411
415
  const lastArg = args.at(-1);
@@ -1029,8 +1033,8 @@ function argument(valueParser, options = {}) {
1029
1033
  },
1030
1034
  suggest(context, prefix) {
1031
1035
  if (context.state != null) return dispatchIterableByMode(valueParser.$mode, function* () {}, async function* () {});
1032
- if (isAsync) return suggestArgumentAsync(valueParser, isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry);
1033
- return suggestArgumentSync(valueParser, isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry);
1036
+ if (isAsync) return suggestArgumentAsync(valueParser, isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
1037
+ return suggestArgumentSync(valueParser, isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
1034
1038
  },
1035
1039
  getDocFragments(_state, defaultValue) {
1036
1040
  if (isDocHidden(options.hidden)) return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1658+b57e115b",
3
+ "version": "1.0.0-dev.1661+6fc17d4f",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",