@optique/inquirer 1.0.0-dev.521 → 1.0.0-dev.524

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
@@ -80,7 +80,6 @@ function prompt(parser, config) {
80
80
  [promptBindStateKey] = true;
81
81
  hasCliValue = false;
82
82
  };
83
- const promptBindInitialState = new PromptBindInitialStateClass();
84
83
  let promptCache = null;
85
84
  async function executePrompt() {
86
85
  const prompts = getPromptFunctions();
@@ -186,7 +185,9 @@ function prompt(parser, config) {
186
185
  type: "optional",
187
186
  terms: parser.usage
188
187
  }],
189
- initialState: promptBindInitialState,
188
+ get initialState() {
189
+ return new PromptBindInitialStateClass();
190
+ },
190
191
  parse: (context) => {
191
192
  const annotations = (0, __optique_core_annotations.getAnnotations)(context.state);
192
193
  const innerState = isPromptBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
@@ -242,16 +243,20 @@ function prompt(parser, config) {
242
243
  return Promise.resolve(r);
243
244
  }
244
245
  if (state instanceof PromptBindInitialStateClass) {
245
- if (promptCache !== null) {
246
- const cached = promptCache;
246
+ if (promptCache?.state === state) {
247
+ const cached = promptCache.result;
247
248
  promptCache = null;
248
249
  return cached;
249
250
  }
250
251
  const innerState = parser.initialState;
251
252
  const r = parser.complete(innerState);
252
253
  const fallback = (res) => res.success ? Promise.resolve(res) : executePrompt();
253
- promptCache = r instanceof Promise ? r.then(fallback) : fallback(r);
254
- return promptCache;
254
+ const cachedResult = r instanceof Promise ? r.then(fallback) : fallback(r);
255
+ promptCache = {
256
+ state,
257
+ result: cachedResult
258
+ };
259
+ return cachedResult;
255
260
  }
256
261
  const cliState = isPromptBindState(state) ? state.cliState : void 0;
257
262
  const cliStateHasAnnotations = cliState != null && typeof cliState === "object" && __optique_core_annotations.annotationKey in cliState;
package/dist/index.js CHANGED
@@ -57,7 +57,6 @@ function prompt(parser, config) {
57
57
  [promptBindStateKey] = true;
58
58
  hasCliValue = false;
59
59
  };
60
- const promptBindInitialState = new PromptBindInitialStateClass();
61
60
  let promptCache = null;
62
61
  async function executePrompt() {
63
62
  const prompts = getPromptFunctions();
@@ -163,7 +162,9 @@ function prompt(parser, config) {
163
162
  type: "optional",
164
163
  terms: parser.usage
165
164
  }],
166
- initialState: promptBindInitialState,
165
+ get initialState() {
166
+ return new PromptBindInitialStateClass();
167
+ },
167
168
  parse: (context) => {
168
169
  const annotations = getAnnotations(context.state);
169
170
  const innerState = isPromptBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
@@ -219,16 +220,20 @@ function prompt(parser, config) {
219
220
  return Promise.resolve(r);
220
221
  }
221
222
  if (state instanceof PromptBindInitialStateClass) {
222
- if (promptCache !== null) {
223
- const cached = promptCache;
223
+ if (promptCache?.state === state) {
224
+ const cached = promptCache.result;
224
225
  promptCache = null;
225
226
  return cached;
226
227
  }
227
228
  const innerState = parser.initialState;
228
229
  const r = parser.complete(innerState);
229
230
  const fallback = (res) => res.success ? Promise.resolve(res) : executePrompt();
230
- promptCache = r instanceof Promise ? r.then(fallback) : fallback(r);
231
- return promptCache;
231
+ const cachedResult = r instanceof Promise ? r.then(fallback) : fallback(r);
232
+ promptCache = {
233
+ state,
234
+ result: cachedResult
235
+ };
236
+ return cachedResult;
232
237
  }
233
238
  const cliState = isPromptBindState(state) ? state.cliState : void 0;
234
239
  const cliStateHasAnnotations = cliState != null && typeof cliState === "object" && annotationKey in cliState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.0.0-dev.521+01058fcd",
3
+ "version": "1.0.0-dev.524+fdcc3eb9",
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.521+01058fcd"
59
+ "@optique/core": "1.0.0-dev.524+fdcc3eb9"
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.521+01058fcd"
65
+ "@optique/env": "1.0.0-dev.524+fdcc3eb9"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsdown",