@optique/inquirer 1.0.0-dev.1580 → 1.0.0-dev.1590

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
@@ -70,8 +70,8 @@ function isExitPromptError(error) {
70
70
  return typeof error === "object" && error != null && "name" in error && error.name === "ExitPromptError";
71
71
  }
72
72
  const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
73
- function shouldDeferPrompt(parser, state) {
74
- return typeof parser.shouldDeferCompletion === "function" && parser.shouldDeferCompletion(state) === true;
73
+ function shouldDeferPrompt(parser, state, exec) {
74
+ return typeof parser.shouldDeferCompletion === "function" && parser.shouldDeferCompletion(state, exec) === true;
75
75
  }
76
76
  function deferredPromptResult(placeholderValue) {
77
77
  if (placeholderValue == null || typeof placeholderValue !== "object") return {
@@ -295,9 +295,9 @@ function prompt(parser, config) {
295
295
  const result = await executePromptRaw();
296
296
  return validatePromptedValue(result);
297
297
  }
298
- function usePromptOrDefer(state, result) {
298
+ function usePromptOrDefer(state, result, exec) {
299
299
  if (result.success) return Promise.resolve(result);
300
- if (!shouldDeferPrompt(parser, state)) return executePrompt();
300
+ if (!shouldDeferPrompt(parser, state, exec)) return executePrompt();
301
301
  let ph;
302
302
  try {
303
303
  ph = "placeholder" in parser ? parser.placeholder : void 0;
@@ -369,9 +369,9 @@ function prompt(parser, config) {
369
369
  if (result instanceof Promise) return result.then(processResult);
370
370
  return Promise.resolve(processResult(result));
371
371
  },
372
- complete: (state) => {
372
+ complete: (state, exec) => {
373
373
  if (isPromptBindState(state) && state.hasCliValue) {
374
- const r = withAnnotatedInnerState(state, state.cliState, (annotatedInnerState) => parser.complete(annotatedInnerState));
374
+ const r = withAnnotatedInnerState(state, state.cliState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec));
375
375
  if (r instanceof Promise) return r;
376
376
  return Promise.resolve(r);
377
377
  }
@@ -386,13 +386,13 @@ function prompt(parser, config) {
386
386
  const innerInitialState = parser.initialState;
387
387
  const effectiveInitialState = annotations != null && innerInitialState == null ? (0, __optique_core_annotations.injectAnnotations)(innerInitialState, annotations) : innerInitialState;
388
388
  if (hasDeferHook) {
389
- const annotatedR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
389
+ const annotatedR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec));
390
390
  const usePromptOrDeferSentinel = (res) => {
391
391
  if (res.success && res.value === void 0) return usePromptOrDefer(state, {
392
392
  success: false,
393
393
  error: []
394
- });
395
- return usePromptOrDefer(state, res);
394
+ }, exec);
395
+ return usePromptOrDefer(state, res, exec);
396
396
  };
397
397
  const cachedResult$1 = annotatedR instanceof Promise ? annotatedR.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(annotatedR);
398
398
  promptCache.set(state, cachedResult$1);
@@ -414,10 +414,10 @@ function prompt(parser, config) {
414
414
  const cliStateIsInjected = cliState$1 != null && typeof cliState$1 === "object" && (0, __optique_core_annotations.unwrapInjectedAnnotationWrapper)(cliState$1) !== cliState$1;
415
415
  const handleCompleteResult = (res) => {
416
416
  if (res.success && res.value === void 0 && cliStateIsInjected) return executePrompt();
417
- return usePromptOrDefer(state, res);
417
+ return usePromptOrDefer(state, res, exec);
418
418
  };
419
419
  const completeState = parseResult.success ? parseResult.next.state : effectiveInitialState;
420
- const completeR = parser.complete(completeState);
420
+ const completeR = parser.complete(completeState, exec);
421
421
  if (completeR instanceof Promise) return completeR.then(handleCompleteResult);
422
422
  return handleCompleteResult(completeR);
423
423
  }
@@ -432,13 +432,13 @@ function prompt(parser, config) {
432
432
  if (shouldAttemptInnerCompletion(cliState, state)) {
433
433
  const useCompleteResultOrPrompt = (result) => {
434
434
  if (result.success && result.value === void 0 && cliStateIsInjectedAnnotationWrapper) return executePrompt();
435
- return usePromptOrDefer(state, result);
435
+ return usePromptOrDefer(state, result, exec);
436
436
  };
437
- const r = withAnnotatedInnerState(state, cliState, (annotatedInnerState) => parser.complete(annotatedInnerState));
437
+ const r = withAnnotatedInnerState(state, cliState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec));
438
438
  if (r instanceof Promise) return r.then(useCompleteResultOrPrompt);
439
439
  return useCompleteResultOrPrompt(r);
440
440
  }
441
- if (shouldDeferPrompt(parser, state)) {
441
+ if (shouldDeferPrompt(parser, state, exec)) {
442
442
  let ph;
443
443
  try {
444
444
  ph = "placeholder" in parser ? parser.placeholder : void 0;
package/dist/index.js CHANGED
@@ -47,8 +47,8 @@ function isExitPromptError(error) {
47
47
  return typeof error === "object" && error != null && "name" in error && error.name === "ExitPromptError";
48
48
  }
49
49
  const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
50
- function shouldDeferPrompt(parser, state) {
51
- return typeof parser.shouldDeferCompletion === "function" && parser.shouldDeferCompletion(state) === true;
50
+ function shouldDeferPrompt(parser, state, exec) {
51
+ return typeof parser.shouldDeferCompletion === "function" && parser.shouldDeferCompletion(state, exec) === true;
52
52
  }
53
53
  function deferredPromptResult(placeholderValue) {
54
54
  if (placeholderValue == null || typeof placeholderValue !== "object") return {
@@ -272,9 +272,9 @@ function prompt(parser, config) {
272
272
  const result = await executePromptRaw();
273
273
  return validatePromptedValue(result);
274
274
  }
275
- function usePromptOrDefer(state, result) {
275
+ function usePromptOrDefer(state, result, exec) {
276
276
  if (result.success) return Promise.resolve(result);
277
- if (!shouldDeferPrompt(parser, state)) return executePrompt();
277
+ if (!shouldDeferPrompt(parser, state, exec)) return executePrompt();
278
278
  let ph;
279
279
  try {
280
280
  ph = "placeholder" in parser ? parser.placeholder : void 0;
@@ -346,9 +346,9 @@ function prompt(parser, config) {
346
346
  if (result instanceof Promise) return result.then(processResult);
347
347
  return Promise.resolve(processResult(result));
348
348
  },
349
- complete: (state) => {
349
+ complete: (state, exec) => {
350
350
  if (isPromptBindState(state) && state.hasCliValue) {
351
- const r = withAnnotatedInnerState(state, state.cliState, (annotatedInnerState) => parser.complete(annotatedInnerState));
351
+ const r = withAnnotatedInnerState(state, state.cliState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec));
352
352
  if (r instanceof Promise) return r;
353
353
  return Promise.resolve(r);
354
354
  }
@@ -363,13 +363,13 @@ function prompt(parser, config) {
363
363
  const innerInitialState = parser.initialState;
364
364
  const effectiveInitialState = annotations != null && innerInitialState == null ? injectAnnotations(innerInitialState, annotations) : innerInitialState;
365
365
  if (hasDeferHook) {
366
- const annotatedR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState));
366
+ const annotatedR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec));
367
367
  const usePromptOrDeferSentinel = (res) => {
368
368
  if (res.success && res.value === void 0) return usePromptOrDefer(state, {
369
369
  success: false,
370
370
  error: []
371
- });
372
- return usePromptOrDefer(state, res);
371
+ }, exec);
372
+ return usePromptOrDefer(state, res, exec);
373
373
  };
374
374
  const cachedResult$1 = annotatedR instanceof Promise ? annotatedR.then(usePromptOrDeferSentinel) : usePromptOrDeferSentinel(annotatedR);
375
375
  promptCache.set(state, cachedResult$1);
@@ -391,10 +391,10 @@ function prompt(parser, config) {
391
391
  const cliStateIsInjected = cliState$1 != null && typeof cliState$1 === "object" && unwrapInjectedAnnotationWrapper(cliState$1) !== cliState$1;
392
392
  const handleCompleteResult = (res) => {
393
393
  if (res.success && res.value === void 0 && cliStateIsInjected) return executePrompt();
394
- return usePromptOrDefer(state, res);
394
+ return usePromptOrDefer(state, res, exec);
395
395
  };
396
396
  const completeState = parseResult.success ? parseResult.next.state : effectiveInitialState;
397
- const completeR = parser.complete(completeState);
397
+ const completeR = parser.complete(completeState, exec);
398
398
  if (completeR instanceof Promise) return completeR.then(handleCompleteResult);
399
399
  return handleCompleteResult(completeR);
400
400
  }
@@ -409,13 +409,13 @@ function prompt(parser, config) {
409
409
  if (shouldAttemptInnerCompletion(cliState, state)) {
410
410
  const useCompleteResultOrPrompt = (result) => {
411
411
  if (result.success && result.value === void 0 && cliStateIsInjectedAnnotationWrapper) return executePrompt();
412
- return usePromptOrDefer(state, result);
412
+ return usePromptOrDefer(state, result, exec);
413
413
  };
414
- const r = withAnnotatedInnerState(state, cliState, (annotatedInnerState) => parser.complete(annotatedInnerState));
414
+ const r = withAnnotatedInnerState(state, cliState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec));
415
415
  if (r instanceof Promise) return r.then(useCompleteResultOrPrompt);
416
416
  return useCompleteResultOrPrompt(r);
417
417
  }
418
- if (shouldDeferPrompt(parser, state)) {
418
+ if (shouldDeferPrompt(parser, state, exec)) {
419
419
  let ph;
420
420
  try {
421
421
  ph = "placeholder" in parser ? parser.placeholder : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.0.0-dev.1580+2d932679",
3
+ "version": "1.0.0-dev.1590+eb65aeba",
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.1580+2d932679"
59
+ "@optique/core": "1.0.0-dev.1590+eb65aeba"
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.1580+2d932679"
65
+ "@optique/env": "1.0.0-dev.1590+eb65aeba"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",