@optique/inquirer 1.0.0-dev.1495 → 1.0.0-dev.1500

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
@@ -23,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  const __inquirer_prompts = __toESM(require("@inquirer/prompts"));
25
25
  const __optique_core_annotations = __toESM(require("@optique/core/annotations"));
26
- const __optique_core_context = __toESM(require("@optique/core/context"));
27
26
  const __optique_core_message = __toESM(require("@optique/core/message"));
28
27
 
29
28
  //#region src/index.ts
@@ -71,17 +70,26 @@ function isExitPromptError(error) {
71
70
  return typeof error === "object" && error != null && "name" in error && error.name === "ExitPromptError";
72
71
  }
73
72
  const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
74
- var DeferredPromptValue = class {
75
- [__optique_core_context.placeholder] = true;
76
- constructor() {}
77
- };
78
73
  function shouldDeferPrompt(parser, state) {
79
74
  return typeof parser.shouldDeferCompletion === "function" && parser.shouldDeferCompletion(state) === true;
80
75
  }
81
- function deferredPromptResult() {
76
+ function deferredPromptResult(placeholderValue) {
77
+ if (placeholderValue == null || typeof placeholderValue !== "object") return {
78
+ success: true,
79
+ value: placeholderValue,
80
+ deferred: true
81
+ };
82
+ const isArray = Array.isArray(placeholderValue);
83
+ const keys = /* @__PURE__ */ new Map();
84
+ for (const key of Reflect.ownKeys(placeholderValue)) {
85
+ if (isArray && key === "length") continue;
86
+ keys.set(key, null);
87
+ }
82
88
  return {
83
89
  success: true,
84
- value: new DeferredPromptValue()
90
+ value: placeholderValue,
91
+ deferred: true,
92
+ deferredKeys: keys
85
93
  };
86
94
  }
87
95
  function withAnnotationView(state, annotations, run) {
@@ -289,7 +297,12 @@ function prompt(parser, config) {
289
297
  }
290
298
  function usePromptOrDefer(state, result) {
291
299
  if (result.success) return Promise.resolve(result);
292
- return shouldDeferPrompt(parser, state) ? Promise.resolve(deferredPromptResult()) : executePrompt();
300
+ if (!shouldDeferPrompt(parser, state)) return executePrompt();
301
+ let ph;
302
+ try {
303
+ ph = "placeholder" in parser ? parser.placeholder : void 0;
304
+ } catch {}
305
+ return Promise.resolve(deferredPromptResult(ph));
293
306
  }
294
307
  const promptedParser = {
295
308
  $mode: "async",
@@ -423,7 +436,14 @@ function prompt(parser, config) {
423
436
  if (r instanceof Promise) return r.then(useCompleteResultOrPrompt);
424
437
  return useCompleteResultOrPrompt(r);
425
438
  }
426
- return shouldDeferPrompt(parser, state) ? Promise.resolve(deferredPromptResult()) : executePrompt();
439
+ if (shouldDeferPrompt(parser, state)) {
440
+ let ph;
441
+ try {
442
+ ph = "placeholder" in parser ? parser.placeholder : void 0;
443
+ } catch {}
444
+ return Promise.resolve(deferredPromptResult(ph));
445
+ }
446
+ return executePrompt();
427
447
  },
428
448
  suggest: (context, prefix) => {
429
449
  const innerState = isPromptBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
@@ -442,6 +462,17 @@ function prompt(parser, config) {
442
462
  return parser.getDocFragments(state, defaultValue);
443
463
  }
444
464
  };
465
+ if ("placeholder" in parser) Object.defineProperty(promptedParser, "placeholder", {
466
+ get() {
467
+ try {
468
+ return parser.placeholder;
469
+ } catch {
470
+ return void 0;
471
+ }
472
+ },
473
+ configurable: true,
474
+ enumerable: false
475
+ });
445
476
  return promptedParser;
446
477
  }
447
478
  /** Normalize choices to the format Inquirer.js expects. */
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Separator, checkbox, confirm, editor, expand, input, number, password, rawlist, select } from "@inquirer/prompts";
2
2
  import { annotationKey, getAnnotations, inheritAnnotations, injectAnnotations, unwrapInjectedAnnotationWrapper } from "@optique/core/annotations";
3
- import { placeholder } from "@optique/core/context";
4
3
  import { message } from "@optique/core/message";
5
4
 
6
5
  //#region src/index.ts
@@ -48,17 +47,26 @@ function isExitPromptError(error) {
48
47
  return typeof error === "object" && error != null && "name" in error && error.name === "ExitPromptError";
49
48
  }
50
49
  const inheritParentAnnotationsKey = Symbol.for("@optique/core/inheritParentAnnotations");
51
- var DeferredPromptValue = class {
52
- [placeholder] = true;
53
- constructor() {}
54
- };
55
50
  function shouldDeferPrompt(parser, state) {
56
51
  return typeof parser.shouldDeferCompletion === "function" && parser.shouldDeferCompletion(state) === true;
57
52
  }
58
- function deferredPromptResult() {
53
+ function deferredPromptResult(placeholderValue) {
54
+ if (placeholderValue == null || typeof placeholderValue !== "object") return {
55
+ success: true,
56
+ value: placeholderValue,
57
+ deferred: true
58
+ };
59
+ const isArray = Array.isArray(placeholderValue);
60
+ const keys = /* @__PURE__ */ new Map();
61
+ for (const key of Reflect.ownKeys(placeholderValue)) {
62
+ if (isArray && key === "length") continue;
63
+ keys.set(key, null);
64
+ }
59
65
  return {
60
66
  success: true,
61
- value: new DeferredPromptValue()
67
+ value: placeholderValue,
68
+ deferred: true,
69
+ deferredKeys: keys
62
70
  };
63
71
  }
64
72
  function withAnnotationView(state, annotations, run) {
@@ -266,7 +274,12 @@ function prompt(parser, config) {
266
274
  }
267
275
  function usePromptOrDefer(state, result) {
268
276
  if (result.success) return Promise.resolve(result);
269
- return shouldDeferPrompt(parser, state) ? Promise.resolve(deferredPromptResult()) : executePrompt();
277
+ if (!shouldDeferPrompt(parser, state)) return executePrompt();
278
+ let ph;
279
+ try {
280
+ ph = "placeholder" in parser ? parser.placeholder : void 0;
281
+ } catch {}
282
+ return Promise.resolve(deferredPromptResult(ph));
270
283
  }
271
284
  const promptedParser = {
272
285
  $mode: "async",
@@ -400,7 +413,14 @@ function prompt(parser, config) {
400
413
  if (r instanceof Promise) return r.then(useCompleteResultOrPrompt);
401
414
  return useCompleteResultOrPrompt(r);
402
415
  }
403
- return shouldDeferPrompt(parser, state) ? Promise.resolve(deferredPromptResult()) : executePrompt();
416
+ if (shouldDeferPrompt(parser, state)) {
417
+ let ph;
418
+ try {
419
+ ph = "placeholder" in parser ? parser.placeholder : void 0;
420
+ } catch {}
421
+ return Promise.resolve(deferredPromptResult(ph));
422
+ }
423
+ return executePrompt();
404
424
  },
405
425
  suggest: (context, prefix) => {
406
426
  const innerState = isPromptBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
@@ -419,6 +439,17 @@ function prompt(parser, config) {
419
439
  return parser.getDocFragments(state, defaultValue);
420
440
  }
421
441
  };
442
+ if ("placeholder" in parser) Object.defineProperty(promptedParser, "placeholder", {
443
+ get() {
444
+ try {
445
+ return parser.placeholder;
446
+ } catch {
447
+ return void 0;
448
+ }
449
+ },
450
+ configurable: true,
451
+ enumerable: false
452
+ });
422
453
  return promptedParser;
423
454
  }
424
455
  /** Normalize choices to the format Inquirer.js expects. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.0.0-dev.1495+f6fe8a79",
3
+ "version": "1.0.0-dev.1500+dc0650e5",
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.1495+f6fe8a79"
59
+ "@optique/core": "1.0.0-dev.1500+dc0650e5"
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.1495+f6fe8a79"
65
+ "@optique/env": "1.0.0-dev.1500+dc0650e5"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",