@optique/inquirer 1.0.0-dev.764 → 1.0.0-dev.771

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
@@ -152,7 +152,7 @@ function prompt(parser, config) {
152
152
  if (cliStateHasAnnotations) return true;
153
153
  if ((0, __optique_core_annotations.getAnnotations)(state) == null || typeof cliState !== "object") return false;
154
154
  if ("hasCliValue" in cliState) return true;
155
- if (Array.isArray(cliState)) return false;
155
+ if (Array.isArray(cliState)) return typeof Reflect.get(parser, deferPromptUntilConfigResolvesKey) === "function";
156
156
  const prototype = Object.getPrototypeOf(cliState);
157
157
  return prototype !== Object.prototype && prototype !== null;
158
158
  }
@@ -348,8 +348,19 @@ function prompt(parser, config) {
348
348
  promptCache = null;
349
349
  return cached;
350
350
  }
351
- const r = withAnnotatedInnerState(state, parser.initialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
352
- const cachedResult = r instanceof Promise ? r.then((res) => usePromptOrDefer(state, res)) : usePromptOrDefer(state, r);
351
+ const innerInitialState = parser.initialState;
352
+ const annotations = (0, __optique_core_annotations.getAnnotations)(state);
353
+ 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);
362
+ };
363
+ const cachedResult = r instanceof Promise ? r.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(r);
353
364
  promptCache = {
354
365
  state,
355
366
  result: cachedResult
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Separator, checkbox, confirm, editor, expand, input, number, password, rawlist, select } from "@inquirer/prompts";
2
- import { annotationKey, getAnnotations, inheritAnnotations, unwrapInjectedAnnotationWrapper } from "@optique/core/annotations";
2
+ import { annotationKey, getAnnotations, inheritAnnotations, injectAnnotations, unwrapInjectedAnnotationWrapper } from "@optique/core/annotations";
3
3
  import { message } from "@optique/core/message";
4
4
 
5
5
  //#region src/index.ts
@@ -129,7 +129,7 @@ function prompt(parser, config) {
129
129
  if (cliStateHasAnnotations) return true;
130
130
  if (getAnnotations(state) == null || typeof cliState !== "object") return false;
131
131
  if ("hasCliValue" in cliState) return true;
132
- if (Array.isArray(cliState)) return false;
132
+ if (Array.isArray(cliState)) return typeof Reflect.get(parser, deferPromptUntilConfigResolvesKey) === "function";
133
133
  const prototype = Object.getPrototypeOf(cliState);
134
134
  return prototype !== Object.prototype && prototype !== null;
135
135
  }
@@ -325,8 +325,19 @@ function prompt(parser, config) {
325
325
  promptCache = null;
326
326
  return cached;
327
327
  }
328
- const r = withAnnotatedInnerState(state, parser.initialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
329
- const cachedResult = r instanceof Promise ? r.then((res) => usePromptOrDefer(state, res)) : usePromptOrDefer(state, r);
328
+ const innerInitialState = parser.initialState;
329
+ const annotations = getAnnotations(state);
330
+ 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);
339
+ };
340
+ const cachedResult = r instanceof Promise ? r.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(r);
330
341
  promptCache = {
331
342
  state,
332
343
  result: cachedResult
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.0.0-dev.764+b6aec70a",
3
+ "version": "1.0.0-dev.771+55c12309",
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.764+b6aec70a"
59
+ "@optique/core": "1.0.0-dev.771+55c12309"
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.764+b6aec70a"
65
+ "@optique/env": "1.0.0-dev.771+55c12309"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",