@optique/inquirer 1.0.0-dev.788 → 1.0.0-dev.886

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/index.cjs CHANGED
@@ -348,19 +348,52 @@ function prompt(parser, config) {
348
348
  promptCache = null;
349
349
  return cached;
350
350
  }
351
- const innerInitialState = parser.initialState;
352
- const annotations = (0, __optique_core_annotations.getAnnotations)(state);
353
351
  const hasDeferHook = typeof Reflect.get(parser, deferPromptUntilConfigResolvesKey) === "function";
354
- const effectiveInitialState = annotations != null && innerInitialState == null && hasDeferHook ? (0, __optique_core_annotations.injectAnnotations)(innerInitialState, annotations) : innerInitialState;
355
- const r = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
356
- const usePromptOrDeferSentinel = (res) => {
357
- if (hasDeferHook && res.success && res.value === void 0) return usePromptOrDefer(state, {
358
- success: false,
359
- error: []
360
- });
361
- return usePromptOrDefer(state, res);
352
+ const annotations = (0, __optique_core_annotations.getAnnotations)(state);
353
+ const innerInitialState = parser.initialState;
354
+ const effectiveInitialState = annotations != null && innerInitialState == null ? (0, __optique_core_annotations.injectAnnotations)(innerInitialState, annotations) : innerInitialState;
355
+ if (hasDeferHook) {
356
+ const annotatedR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
357
+ const usePromptOrDeferSentinel = (res) => {
358
+ if (res.success && res.value === void 0) return usePromptOrDefer(state, {
359
+ success: false,
360
+ error: []
361
+ });
362
+ return usePromptOrDefer(state, res);
363
+ };
364
+ const cachedResult$1 = annotatedR instanceof Promise ? annotatedR.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(annotatedR);
365
+ promptCache = {
366
+ state,
367
+ result: cachedResult$1
368
+ };
369
+ return cachedResult$1;
370
+ }
371
+ const simParseR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedState) => parser.parse({
372
+ buffer: [],
373
+ state: annotatedState,
374
+ optionsTerminated: false,
375
+ usage: parser.usage
376
+ }));
377
+ const decideFromParse = (parseResult) => {
378
+ const consumed = parseResult.success ? parseResult.consumed.length : 0;
379
+ const cliState$1 = parseResult.success && consumed === 0 ? parseResult.next.state : void 0;
380
+ const hasSourceBindingMarker = (s) => s != null && typeof s === "object" && "hasCliValue" in s && Object.getOwnPropertySymbols(s).length > 0;
381
+ const cliStateIsPassthrough = cliState$1 != null && typeof cliState$1 === "object" && (0, __optique_core_annotations.unwrapInjectedAnnotationWrapper)(cliState$1) !== cliState$1;
382
+ const isSourceBinding = shouldAttemptInnerCompletion(cliState$1, state) && !cliStateIsPassthrough || hasSourceBindingMarker(cliState$1) || Array.isArray(cliState$1) && cliState$1.length === 1 && (hasSourceBindingMarker(cliState$1[0]) || typeof cliState$1[0] === "object" && cliState$1[0] != null && __optique_core_annotations.annotationKey in cliState$1[0]);
383
+ if (isSourceBinding) {
384
+ const cliStateIsInjected = cliState$1 != null && typeof cliState$1 === "object" && (0, __optique_core_annotations.unwrapInjectedAnnotationWrapper)(cliState$1) !== cliState$1;
385
+ const handleCompleteResult = (res) => {
386
+ if (res.success && res.value === void 0 && cliStateIsInjected) return executePrompt();
387
+ return usePromptOrDefer(state, res);
388
+ };
389
+ const completeState = parseResult.success ? parseResult.next.state : effectiveInitialState;
390
+ const completeR = parser.complete(completeState);
391
+ if (completeR instanceof Promise) return completeR.then(handleCompleteResult);
392
+ return handleCompleteResult(completeR);
393
+ }
394
+ return executePrompt();
362
395
  };
363
- const cachedResult = r instanceof Promise ? r.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(r);
396
+ const cachedResult = simParseR instanceof Promise ? simParseR.then(decideFromParse) : decideFromParse(simParseR);
364
397
  promptCache = {
365
398
  state,
366
399
  result: cachedResult
package/dist/index.js CHANGED
@@ -325,19 +325,52 @@ function prompt(parser, config) {
325
325
  promptCache = null;
326
326
  return cached;
327
327
  }
328
- const innerInitialState = parser.initialState;
329
- const annotations = getAnnotations(state);
330
328
  const hasDeferHook = typeof Reflect.get(parser, deferPromptUntilConfigResolvesKey) === "function";
331
- const effectiveInitialState = annotations != null && innerInitialState == null && hasDeferHook ? injectAnnotations(innerInitialState, annotations) : innerInitialState;
332
- const r = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
333
- const usePromptOrDeferSentinel = (res) => {
334
- if (hasDeferHook && res.success && res.value === void 0) return usePromptOrDefer(state, {
335
- success: false,
336
- error: []
337
- });
338
- return usePromptOrDefer(state, res);
329
+ const annotations = getAnnotations(state);
330
+ const innerInitialState = parser.initialState;
331
+ const effectiveInitialState = annotations != null && innerInitialState == null ? injectAnnotations(innerInitialState, annotations) : innerInitialState;
332
+ if (hasDeferHook) {
333
+ const annotatedR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
334
+ const usePromptOrDeferSentinel = (res) => {
335
+ if (res.success && res.value === void 0) return usePromptOrDefer(state, {
336
+ success: false,
337
+ error: []
338
+ });
339
+ return usePromptOrDefer(state, res);
340
+ };
341
+ const cachedResult$1 = annotatedR instanceof Promise ? annotatedR.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(annotatedR);
342
+ promptCache = {
343
+ state,
344
+ result: cachedResult$1
345
+ };
346
+ return cachedResult$1;
347
+ }
348
+ const simParseR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedState) => parser.parse({
349
+ buffer: [],
350
+ state: annotatedState,
351
+ optionsTerminated: false,
352
+ usage: parser.usage
353
+ }));
354
+ const decideFromParse = (parseResult) => {
355
+ const consumed = parseResult.success ? parseResult.consumed.length : 0;
356
+ const cliState$1 = parseResult.success && consumed === 0 ? parseResult.next.state : void 0;
357
+ const hasSourceBindingMarker = (s) => s != null && typeof s === "object" && "hasCliValue" in s && Object.getOwnPropertySymbols(s).length > 0;
358
+ const cliStateIsPassthrough = cliState$1 != null && typeof cliState$1 === "object" && unwrapInjectedAnnotationWrapper(cliState$1) !== cliState$1;
359
+ const isSourceBinding = shouldAttemptInnerCompletion(cliState$1, state) && !cliStateIsPassthrough || hasSourceBindingMarker(cliState$1) || Array.isArray(cliState$1) && cliState$1.length === 1 && (hasSourceBindingMarker(cliState$1[0]) || typeof cliState$1[0] === "object" && cliState$1[0] != null && annotationKey in cliState$1[0]);
360
+ if (isSourceBinding) {
361
+ const cliStateIsInjected = cliState$1 != null && typeof cliState$1 === "object" && unwrapInjectedAnnotationWrapper(cliState$1) !== cliState$1;
362
+ const handleCompleteResult = (res) => {
363
+ if (res.success && res.value === void 0 && cliStateIsInjected) return executePrompt();
364
+ return usePromptOrDefer(state, res);
365
+ };
366
+ const completeState = parseResult.success ? parseResult.next.state : effectiveInitialState;
367
+ const completeR = parser.complete(completeState);
368
+ if (completeR instanceof Promise) return completeR.then(handleCompleteResult);
369
+ return handleCompleteResult(completeR);
370
+ }
371
+ return executePrompt();
339
372
  };
340
- const cachedResult = r instanceof Promise ? r.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(r);
373
+ const cachedResult = simParseR instanceof Promise ? simParseR.then(decideFromParse) : decideFromParse(simParseR);
341
374
  promptCache = {
342
375
  state,
343
376
  result: cachedResult
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.0.0-dev.788+1f1c275f",
3
+ "version": "1.0.0-dev.886+4b42a9bd",
4
4
  "description": "Interactive prompt support for Optique via Inquirer.js",
5
5
  "keywords": [
6
6
  "CLI",
@@ -56,13 +56,13 @@
56
56
  "sideEffects": false,
57
57
  "dependencies": {
58
58
  "@inquirer/prompts": "^8.3.0",
59
- "@optique/core": "1.0.0-dev.788+1f1c275f"
59
+ "@optique/core": "1.0.0-dev.886+4b42a9bd"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "^20.19.9",
63
63
  "tsdown": "^0.13.0",
64
64
  "typescript": "^5.8.3",
65
- "@optique/env": "1.0.0-dev.788+1f1c275f"
65
+ "@optique/env": "1.0.0-dev.886+4b42a9bd"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",