@optique/core 0.10.0-dev.323 → 0.10.0-dev.327

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.
@@ -1,5 +1,6 @@
1
1
  const require_message = require('./message.cjs');
2
2
  const require_dependency = require('./dependency.cjs');
3
+ const require_mode_dispatch = require('./mode-dispatch.cjs');
3
4
  const require_usage = require('./usage.cjs');
4
5
  const require_suggestion = require('./suggestion.cjs');
5
6
 
@@ -118,7 +119,7 @@ function generateNoMatchError(context) {
118
119
  * Creates a complete() method shared by or() and longestMatch().
119
120
  * @internal
120
121
  */
121
- function createExclusiveComplete(parsers, options, noMatchContext, isAsync) {
122
+ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
122
123
  const syncParsers = parsers;
123
124
  return (state) => {
124
125
  if (state == null) return {
@@ -130,67 +131,63 @@ function createExclusiveComplete(parsers, options, noMatchContext, isAsync) {
130
131
  success: false,
131
132
  error: result.error
132
133
  };
133
- if (isAsync) return (async () => {
134
+ return require_mode_dispatch.dispatchByMode(mode, () => syncParsers[i].complete(result.next.state), async () => {
134
135
  const completeResult = await parsers[i].complete(result.next.state);
135
136
  return completeResult;
136
- })();
137
- return syncParsers[i].complete(result.next.state);
137
+ });
138
138
  };
139
139
  }
140
140
  /**
141
141
  * Creates a suggest() method shared by or() and longestMatch().
142
142
  * @internal
143
143
  */
144
- function createExclusiveSuggest(parsers, isAsync) {
144
+ function createExclusiveSuggest(parsers, mode) {
145
145
  const syncParsers = parsers;
146
- if (isAsync) return (context, prefix) => {
147
- return async function* () {
146
+ return (context, prefix) => {
147
+ return require_mode_dispatch.dispatchIterableByMode(mode, function* () {
148
148
  const suggestions = [];
149
- if (context.state == null) for (const parser of parsers) {
149
+ if (context.state == null) for (const parser of syncParsers) {
150
150
  const parserSuggestions = parser.suggest({
151
151
  ...context,
152
152
  state: parser.initialState
153
153
  }, prefix);
154
- if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
155
- else suggestions.push(...parserSuggestions);
154
+ suggestions.push(...parserSuggestions);
156
155
  }
157
156
  else {
158
157
  const [index, parserResult] = context.state;
159
158
  if (parserResult.success) {
160
- const parser = parsers[index];
161
- const parserSuggestions = parser.suggest({
159
+ const parserSuggestions = syncParsers[index].suggest({
162
160
  ...context,
163
161
  state: parserResult.next.state
164
162
  }, prefix);
165
- if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
166
- else suggestions.push(...parserSuggestions);
163
+ suggestions.push(...parserSuggestions);
167
164
  }
168
165
  }
169
166
  yield* require_suggestion.deduplicateSuggestions(suggestions);
170
- }();
171
- };
172
- return (context, prefix) => {
173
- return function* () {
167
+ }, async function* () {
174
168
  const suggestions = [];
175
- if (context.state == null) for (const parser of syncParsers) {
169
+ if (context.state == null) for (const parser of parsers) {
176
170
  const parserSuggestions = parser.suggest({
177
171
  ...context,
178
172
  state: parser.initialState
179
173
  }, prefix);
180
- suggestions.push(...parserSuggestions);
174
+ if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
175
+ else suggestions.push(...parserSuggestions);
181
176
  }
182
177
  else {
183
178
  const [index, parserResult] = context.state;
184
179
  if (parserResult.success) {
185
- const parserSuggestions = syncParsers[index].suggest({
180
+ const parser = parsers[index];
181
+ const parserSuggestions = parser.suggest({
186
182
  ...context,
187
183
  state: parserResult.next.state
188
184
  }, prefix);
189
- suggestions.push(...parserSuggestions);
185
+ if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
186
+ else suggestions.push(...parserSuggestions);
190
187
  }
191
188
  }
192
189
  yield* require_suggestion.deduplicateSuggestions(suggestions);
193
- }();
190
+ });
194
191
  };
195
192
  }
196
193
  /**
@@ -227,7 +224,6 @@ function or(...args) {
227
224
  }
228
225
  const noMatchContext = analyzeNoMatchContext(parsers);
229
226
  const combinedMode = parsers.some((p) => p.$mode === "async") ? "async" : "sync";
230
- const isAsync = combinedMode === "async";
231
227
  const syncParsers = parsers;
232
228
  const getInitialError = (context) => ({
233
229
  consumed: 0,
@@ -364,12 +360,11 @@ function or(...args) {
364
360
  terms: parsers.map((p) => p.usage)
365
361
  }],
366
362
  initialState: void 0,
367
- complete: createExclusiveComplete(parsers, options, noMatchContext, isAsync),
363
+ complete: createExclusiveComplete(parsers, options, noMatchContext, combinedMode),
368
364
  parse(context) {
369
- if (isAsync) return parseAsync(context);
370
- return parseSync(context);
365
+ return require_mode_dispatch.dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
371
366
  },
372
- suggest: createExclusiveSuggest(parsers, isAsync),
367
+ suggest: createExclusiveSuggest(parsers, combinedMode),
373
368
  getDocFragments(state, _defaultValue) {
374
369
  let description;
375
370
  let fragments;
@@ -419,7 +414,6 @@ function longestMatch(...args) {
419
414
  }
420
415
  const noMatchContext = analyzeNoMatchContext(parsers);
421
416
  const combinedMode = parsers.some((p) => p.$mode === "async") ? "async" : "sync";
422
- const isAsync = combinedMode === "async";
423
417
  const syncParsers = parsers;
424
418
  const getInitialError = (context) => ({
425
419
  consumed: 0,
@@ -502,12 +496,11 @@ function longestMatch(...args) {
502
496
  terms: parsers.map((p) => p.usage)
503
497
  }],
504
498
  initialState: void 0,
505
- complete: createExclusiveComplete(parsers, options, noMatchContext, isAsync),
499
+ complete: createExclusiveComplete(parsers, options, noMatchContext, combinedMode),
506
500
  parse(context) {
507
- if (isAsync) return parseAsync(context);
508
- return parseSync(context);
501
+ return require_mode_dispatch.dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
509
502
  },
510
- suggest: createExclusiveSuggest(parsers, isAsync),
503
+ suggest: createExclusiveSuggest(parsers, combinedMode),
511
504
  getDocFragments(state, _defaultValue) {
512
505
  let description;
513
506
  let footer;
@@ -760,7 +753,6 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
760
753
  if (!options.allowDuplicates) checkDuplicateOptionNames(parserPairs.map(([field, parser]) => [field, parser.usage]));
761
754
  const noMatchContext = analyzeNoMatchContext(parserKeys.map((k) => parsers[k]));
762
755
  const combinedMode = parserKeys.some((k) => parsers[k].$mode === "async") ? "async" : "sync";
763
- const isAsync = combinedMode === "async";
764
756
  const getInitialError = (context) => ({
765
757
  consumed: 0,
766
758
  error: context.buffer.length > 0 ? (() => {
@@ -895,11 +887,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
895
887
  usage: parserPairs.flatMap(([_, p]) => p.usage),
896
888
  initialState,
897
889
  parse(context) {
898
- if (isAsync) return parseAsync(context);
899
- return parseSync(context);
890
+ return require_mode_dispatch.dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
900
891
  },
901
892
  complete(state) {
902
- if (!isAsync) {
893
+ return require_mode_dispatch.dispatchByMode(combinedMode, () => {
903
894
  const preCompletedState = {};
904
895
  const preCompletedKeys = /* @__PURE__ */ new Set();
905
896
  for (const field of parserKeys) {
@@ -949,8 +940,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
949
940
  success: true,
950
941
  value: result
951
942
  };
952
- }
953
- return (async () => {
943
+ }, async () => {
954
944
  const preCompletedState = {};
955
945
  const preCompletedKeys = /* @__PURE__ */ new Set();
956
946
  for (const field of parserKeys) {
@@ -1000,12 +990,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1000
990
  success: true,
1001
991
  value: result
1002
992
  };
1003
- })();
993
+ });
1004
994
  },
1005
995
  suggest(context, prefix) {
1006
- if (isAsync) return suggestObjectAsync(context, prefix, parserPairs);
1007
- const syncParserPairs = parserPairs;
1008
- return suggestObjectSync(context, prefix, syncParserPairs);
996
+ return require_mode_dispatch.dispatchIterableByMode(combinedMode, () => {
997
+ const syncParserPairs = parserPairs;
998
+ return suggestObjectSync(context, prefix, syncParserPairs);
999
+ }, () => suggestObjectAsync(context, prefix, parserPairs));
1009
1000
  },
1010
1001
  getDocFragments(state, defaultValue) {
1011
1002
  const fragments = parserPairs.flatMap(([field, p]) => {
@@ -1075,7 +1066,6 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1075
1066
  options = maybeParsersOrOptions ?? {};
1076
1067
  }
1077
1068
  const combinedMode = parsers.some((p) => p.$mode === "async") ? "async" : "sync";
1078
- const isAsync = combinedMode === "async";
1079
1069
  const syncParsers = parsers;
1080
1070
  if (!options.allowDuplicates) checkDuplicateOptionNames(parsers.map((parser, index) => [String(index), parser.usage]));
1081
1071
  const parseSync = (context) => {
@@ -1212,11 +1202,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1212
1202
  priority: parsers.length > 0 ? Math.max(...parsers.map((p) => p.priority)) : 0,
1213
1203
  initialState: parsers.map((parser) => parser.initialState),
1214
1204
  parse(context) {
1215
- if (isAsync) return parseAsync(context);
1216
- return parseSync(context);
1205
+ return require_mode_dispatch.dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
1217
1206
  },
1218
1207
  complete(state) {
1219
- if (!isAsync) {
1208
+ return require_mode_dispatch.dispatchByMode(combinedMode, () => {
1220
1209
  const stateArray = state;
1221
1210
  const preCompletedState = [];
1222
1211
  for (let i = 0; i < syncParsers.length; i++) {
@@ -1264,8 +1253,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1264
1253
  success: true,
1265
1254
  value: result
1266
1255
  };
1267
- }
1268
- return (async () => {
1256
+ }, async () => {
1269
1257
  const stateArray = state;
1270
1258
  const preCompletedState = [];
1271
1259
  for (let i = 0; i < parsers.length; i++) {
@@ -1313,11 +1301,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1313
1301
  success: true,
1314
1302
  value: result
1315
1303
  };
1316
- })();
1304
+ });
1317
1305
  },
1318
1306
  suggest(context, prefix) {
1319
- if (isAsync) return suggestTupleAsync(context, prefix, parsers);
1320
- return suggestTupleSync(context, prefix, syncParsers);
1307
+ return require_mode_dispatch.dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
1321
1308
  },
1322
1309
  getDocFragments(state, defaultValue) {
1323
1310
  const fragments = syncParsers.flatMap((p, i) => {
@@ -1,5 +1,6 @@
1
1
  import { message, optionName, values } from "./message.js";
2
2
  import { DependencyRegistry, dependencyId, isDeferredParseState, isDependencySourceState, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, wrappedDependencySourceMarker } from "./dependency.js";
3
+ import { dispatchByMode, dispatchIterableByMode } from "./mode-dispatch.js";
3
4
  import { extractArgumentMetavars, extractCommandNames, extractOptionNames } from "./usage.js";
4
5
  import { createErrorWithSuggestions, deduplicateSuggestions } from "./suggestion.js";
5
6
 
@@ -118,7 +119,7 @@ function generateNoMatchError(context) {
118
119
  * Creates a complete() method shared by or() and longestMatch().
119
120
  * @internal
120
121
  */
121
- function createExclusiveComplete(parsers, options, noMatchContext, isAsync) {
122
+ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
122
123
  const syncParsers = parsers;
123
124
  return (state) => {
124
125
  if (state == null) return {
@@ -130,67 +131,63 @@ function createExclusiveComplete(parsers, options, noMatchContext, isAsync) {
130
131
  success: false,
131
132
  error: result.error
132
133
  };
133
- if (isAsync) return (async () => {
134
+ return dispatchByMode(mode, () => syncParsers[i].complete(result.next.state), async () => {
134
135
  const completeResult = await parsers[i].complete(result.next.state);
135
136
  return completeResult;
136
- })();
137
- return syncParsers[i].complete(result.next.state);
137
+ });
138
138
  };
139
139
  }
140
140
  /**
141
141
  * Creates a suggest() method shared by or() and longestMatch().
142
142
  * @internal
143
143
  */
144
- function createExclusiveSuggest(parsers, isAsync) {
144
+ function createExclusiveSuggest(parsers, mode) {
145
145
  const syncParsers = parsers;
146
- if (isAsync) return (context, prefix) => {
147
- return async function* () {
146
+ return (context, prefix) => {
147
+ return dispatchIterableByMode(mode, function* () {
148
148
  const suggestions = [];
149
- if (context.state == null) for (const parser of parsers) {
149
+ if (context.state == null) for (const parser of syncParsers) {
150
150
  const parserSuggestions = parser.suggest({
151
151
  ...context,
152
152
  state: parser.initialState
153
153
  }, prefix);
154
- if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
155
- else suggestions.push(...parserSuggestions);
154
+ suggestions.push(...parserSuggestions);
156
155
  }
157
156
  else {
158
157
  const [index, parserResult] = context.state;
159
158
  if (parserResult.success) {
160
- const parser = parsers[index];
161
- const parserSuggestions = parser.suggest({
159
+ const parserSuggestions = syncParsers[index].suggest({
162
160
  ...context,
163
161
  state: parserResult.next.state
164
162
  }, prefix);
165
- if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
166
- else suggestions.push(...parserSuggestions);
163
+ suggestions.push(...parserSuggestions);
167
164
  }
168
165
  }
169
166
  yield* deduplicateSuggestions(suggestions);
170
- }();
171
- };
172
- return (context, prefix) => {
173
- return function* () {
167
+ }, async function* () {
174
168
  const suggestions = [];
175
- if (context.state == null) for (const parser of syncParsers) {
169
+ if (context.state == null) for (const parser of parsers) {
176
170
  const parserSuggestions = parser.suggest({
177
171
  ...context,
178
172
  state: parser.initialState
179
173
  }, prefix);
180
- suggestions.push(...parserSuggestions);
174
+ if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
175
+ else suggestions.push(...parserSuggestions);
181
176
  }
182
177
  else {
183
178
  const [index, parserResult] = context.state;
184
179
  if (parserResult.success) {
185
- const parserSuggestions = syncParsers[index].suggest({
180
+ const parser = parsers[index];
181
+ const parserSuggestions = parser.suggest({
186
182
  ...context,
187
183
  state: parserResult.next.state
188
184
  }, prefix);
189
- suggestions.push(...parserSuggestions);
185
+ if (parser.$mode === "async") for await (const s of parserSuggestions) suggestions.push(s);
186
+ else suggestions.push(...parserSuggestions);
190
187
  }
191
188
  }
192
189
  yield* deduplicateSuggestions(suggestions);
193
- }();
190
+ });
194
191
  };
195
192
  }
196
193
  /**
@@ -227,7 +224,6 @@ function or(...args) {
227
224
  }
228
225
  const noMatchContext = analyzeNoMatchContext(parsers);
229
226
  const combinedMode = parsers.some((p) => p.$mode === "async") ? "async" : "sync";
230
- const isAsync = combinedMode === "async";
231
227
  const syncParsers = parsers;
232
228
  const getInitialError = (context) => ({
233
229
  consumed: 0,
@@ -364,12 +360,11 @@ function or(...args) {
364
360
  terms: parsers.map((p) => p.usage)
365
361
  }],
366
362
  initialState: void 0,
367
- complete: createExclusiveComplete(parsers, options, noMatchContext, isAsync),
363
+ complete: createExclusiveComplete(parsers, options, noMatchContext, combinedMode),
368
364
  parse(context) {
369
- if (isAsync) return parseAsync(context);
370
- return parseSync(context);
365
+ return dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
371
366
  },
372
- suggest: createExclusiveSuggest(parsers, isAsync),
367
+ suggest: createExclusiveSuggest(parsers, combinedMode),
373
368
  getDocFragments(state, _defaultValue) {
374
369
  let description;
375
370
  let fragments;
@@ -419,7 +414,6 @@ function longestMatch(...args) {
419
414
  }
420
415
  const noMatchContext = analyzeNoMatchContext(parsers);
421
416
  const combinedMode = parsers.some((p) => p.$mode === "async") ? "async" : "sync";
422
- const isAsync = combinedMode === "async";
423
417
  const syncParsers = parsers;
424
418
  const getInitialError = (context) => ({
425
419
  consumed: 0,
@@ -502,12 +496,11 @@ function longestMatch(...args) {
502
496
  terms: parsers.map((p) => p.usage)
503
497
  }],
504
498
  initialState: void 0,
505
- complete: createExclusiveComplete(parsers, options, noMatchContext, isAsync),
499
+ complete: createExclusiveComplete(parsers, options, noMatchContext, combinedMode),
506
500
  parse(context) {
507
- if (isAsync) return parseAsync(context);
508
- return parseSync(context);
501
+ return dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
509
502
  },
510
- suggest: createExclusiveSuggest(parsers, isAsync),
503
+ suggest: createExclusiveSuggest(parsers, combinedMode),
511
504
  getDocFragments(state, _defaultValue) {
512
505
  let description;
513
506
  let footer;
@@ -760,7 +753,6 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
760
753
  if (!options.allowDuplicates) checkDuplicateOptionNames(parserPairs.map(([field, parser]) => [field, parser.usage]));
761
754
  const noMatchContext = analyzeNoMatchContext(parserKeys.map((k) => parsers[k]));
762
755
  const combinedMode = parserKeys.some((k) => parsers[k].$mode === "async") ? "async" : "sync";
763
- const isAsync = combinedMode === "async";
764
756
  const getInitialError = (context) => ({
765
757
  consumed: 0,
766
758
  error: context.buffer.length > 0 ? (() => {
@@ -895,11 +887,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
895
887
  usage: parserPairs.flatMap(([_, p]) => p.usage),
896
888
  initialState,
897
889
  parse(context) {
898
- if (isAsync) return parseAsync(context);
899
- return parseSync(context);
890
+ return dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
900
891
  },
901
892
  complete(state) {
902
- if (!isAsync) {
893
+ return dispatchByMode(combinedMode, () => {
903
894
  const preCompletedState = {};
904
895
  const preCompletedKeys = /* @__PURE__ */ new Set();
905
896
  for (const field of parserKeys) {
@@ -949,8 +940,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
949
940
  success: true,
950
941
  value: result
951
942
  };
952
- }
953
- return (async () => {
943
+ }, async () => {
954
944
  const preCompletedState = {};
955
945
  const preCompletedKeys = /* @__PURE__ */ new Set();
956
946
  for (const field of parserKeys) {
@@ -1000,12 +990,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1000
990
  success: true,
1001
991
  value: result
1002
992
  };
1003
- })();
993
+ });
1004
994
  },
1005
995
  suggest(context, prefix) {
1006
- if (isAsync) return suggestObjectAsync(context, prefix, parserPairs);
1007
- const syncParserPairs = parserPairs;
1008
- return suggestObjectSync(context, prefix, syncParserPairs);
996
+ return dispatchIterableByMode(combinedMode, () => {
997
+ const syncParserPairs = parserPairs;
998
+ return suggestObjectSync(context, prefix, syncParserPairs);
999
+ }, () => suggestObjectAsync(context, prefix, parserPairs));
1009
1000
  },
1010
1001
  getDocFragments(state, defaultValue) {
1011
1002
  const fragments = parserPairs.flatMap(([field, p]) => {
@@ -1075,7 +1066,6 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1075
1066
  options = maybeParsersOrOptions ?? {};
1076
1067
  }
1077
1068
  const combinedMode = parsers.some((p) => p.$mode === "async") ? "async" : "sync";
1078
- const isAsync = combinedMode === "async";
1079
1069
  const syncParsers = parsers;
1080
1070
  if (!options.allowDuplicates) checkDuplicateOptionNames(parsers.map((parser, index) => [String(index), parser.usage]));
1081
1071
  const parseSync = (context) => {
@@ -1212,11 +1202,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1212
1202
  priority: parsers.length > 0 ? Math.max(...parsers.map((p) => p.priority)) : 0,
1213
1203
  initialState: parsers.map((parser) => parser.initialState),
1214
1204
  parse(context) {
1215
- if (isAsync) return parseAsync(context);
1216
- return parseSync(context);
1205
+ return dispatchByMode(combinedMode, () => parseSync(context), () => parseAsync(context));
1217
1206
  },
1218
1207
  complete(state) {
1219
- if (!isAsync) {
1208
+ return dispatchByMode(combinedMode, () => {
1220
1209
  const stateArray = state;
1221
1210
  const preCompletedState = [];
1222
1211
  for (let i = 0; i < syncParsers.length; i++) {
@@ -1264,8 +1253,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1264
1253
  success: true,
1265
1254
  value: result
1266
1255
  };
1267
- }
1268
- return (async () => {
1256
+ }, async () => {
1269
1257
  const stateArray = state;
1270
1258
  const preCompletedState = [];
1271
1259
  for (let i = 0; i < parsers.length; i++) {
@@ -1313,11 +1301,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
1313
1301
  success: true,
1314
1302
  value: result
1315
1303
  };
1316
- })();
1304
+ });
1317
1305
  },
1318
1306
  suggest(context, prefix) {
1319
- if (isAsync) return suggestTupleAsync(context, prefix, parsers);
1320
- return suggestTupleSync(context, prefix, syncParsers);
1307
+ return dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
1321
1308
  },
1322
1309
  getDocFragments(state, defaultValue) {
1323
1310
  const fragments = syncParsers.flatMap((p, i) => {
@@ -531,6 +531,35 @@ function isDeferredParseState(value) {
531
531
  return typeof value === "object" && value !== null && deferredParseMarker in value && value[deferredParseMarker] === true;
532
532
  }
533
533
  /**
534
+ * Gets all dependency IDs from a derived parser.
535
+ * If the parser was created with `deriveFrom` (multiple dependencies),
536
+ * returns the array of dependency IDs. Otherwise, returns an array
537
+ * containing the single dependency ID.
538
+ *
539
+ * @param parser The derived value parser to get dependency IDs from.
540
+ * @returns An array of dependency ID symbols.
541
+ * @internal
542
+ * @since 0.10.0
543
+ */
544
+ function getDependencyIds(parser) {
545
+ if (dependencyIds in parser) return parser[dependencyIds];
546
+ return [parser[dependencyId]];
547
+ }
548
+ /**
549
+ * Gets the default values function from a derived parser, if present.
550
+ * This function is available on parsers created with `deriveFrom` that
551
+ * specify default values for their dependencies.
552
+ *
553
+ * @param parser The derived value parser to get the default values function from.
554
+ * @returns The default values function, or undefined if not available.
555
+ * @internal
556
+ * @since 0.10.0
557
+ */
558
+ function getDefaultValuesFunction(parser) {
559
+ if (defaultValues in parser) return parser[defaultValues];
560
+ return void 0;
561
+ }
562
+ /**
534
563
  * Creates a deferred parse state for a DerivedValueParser.
535
564
  *
536
565
  * @template T The type of value the parser will produce.
@@ -735,6 +764,8 @@ exports.deriveFromAsync = deriveFromAsync;
735
764
  exports.deriveFromSync = deriveFromSync;
736
765
  exports.derivedValueParserMarker = derivedValueParserMarker;
737
766
  exports.formatDependencyError = formatDependencyError;
767
+ exports.getDefaultValuesFunction = getDefaultValuesFunction;
768
+ exports.getDependencyIds = getDependencyIds;
738
769
  exports.isDeferredParseState = isDeferredParseState;
739
770
  exports.isDependencySource = isDependencySource;
740
771
  exports.isDependencySourceState = isDependencySourceState;
@@ -1,5 +1,6 @@
1
1
  import { NonEmptyString } from "./nonempty.cjs";
2
2
  import { Message } from "./message.cjs";
3
+ import { DependencyRegistryLike } from "./registry-types.cjs";
3
4
  import { ValueParser, ValueParserResult } from "./valueparser.cjs";
4
5
  import { Mode, Suggestion } from "./parser.cjs";
5
6
 
@@ -533,6 +534,29 @@ interface DeferredParseState<T = unknown> {
533
534
  * @since 0.10.0
534
535
  */
535
536
  declare function isDeferredParseState<T>(value: unknown): value is DeferredParseState<T>;
537
+ /**
538
+ * Gets all dependency IDs from a derived parser.
539
+ * If the parser was created with `deriveFrom` (multiple dependencies),
540
+ * returns the array of dependency IDs. Otherwise, returns an array
541
+ * containing the single dependency ID.
542
+ *
543
+ * @param parser The derived value parser to get dependency IDs from.
544
+ * @returns An array of dependency ID symbols.
545
+ * @internal
546
+ * @since 0.10.0
547
+ */
548
+ declare function getDependencyIds<M extends Mode, T, S>(parser: DerivedValueParser<M, T, S>): readonly symbol[];
549
+ /**
550
+ * Gets the default values function from a derived parser, if present.
551
+ * This function is available on parsers created with `deriveFrom` that
552
+ * specify default values for their dependencies.
553
+ *
554
+ * @param parser The derived value parser to get the default values function from.
555
+ * @returns The default values function, or undefined if not available.
556
+ * @internal
557
+ * @since 0.10.0
558
+ */
559
+ declare function getDefaultValuesFunction<M extends Mode, T, S>(parser: DerivedValueParser<M, T, S>): (() => readonly unknown[]) | undefined;
536
560
  /**
537
561
  * Creates a deferred parse state for a DerivedValueParser.
538
562
  *
@@ -688,7 +712,7 @@ interface ResolvedDependency<T = unknown> {
688
712
  * to DerivedValueParser options.
689
713
  * @since 0.10.0
690
714
  */
691
- declare class DependencyRegistry {
715
+ declare class DependencyRegistry implements DependencyRegistryLike {
692
716
  private readonly values;
693
717
  /**
694
718
  * Registers a resolved dependency value.
@@ -747,4 +771,4 @@ type DependencyError = {
747
771
  */
748
772
  declare function formatDependencyError(error: DependencyError): Message;
749
773
  //#endregion
750
- export { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker };
774
+ export { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker };
@@ -1,5 +1,6 @@
1
1
  import { NonEmptyString } from "./nonempty.js";
2
2
  import { Message } from "./message.js";
3
+ import { DependencyRegistryLike } from "./registry-types.js";
3
4
  import { ValueParser, ValueParserResult } from "./valueparser.js";
4
5
  import { Mode, Suggestion } from "./parser.js";
5
6
 
@@ -533,6 +534,29 @@ interface DeferredParseState<T = unknown> {
533
534
  * @since 0.10.0
534
535
  */
535
536
  declare function isDeferredParseState<T>(value: unknown): value is DeferredParseState<T>;
537
+ /**
538
+ * Gets all dependency IDs from a derived parser.
539
+ * If the parser was created with `deriveFrom` (multiple dependencies),
540
+ * returns the array of dependency IDs. Otherwise, returns an array
541
+ * containing the single dependency ID.
542
+ *
543
+ * @param parser The derived value parser to get dependency IDs from.
544
+ * @returns An array of dependency ID symbols.
545
+ * @internal
546
+ * @since 0.10.0
547
+ */
548
+ declare function getDependencyIds<M extends Mode, T, S>(parser: DerivedValueParser<M, T, S>): readonly symbol[];
549
+ /**
550
+ * Gets the default values function from a derived parser, if present.
551
+ * This function is available on parsers created with `deriveFrom` that
552
+ * specify default values for their dependencies.
553
+ *
554
+ * @param parser The derived value parser to get the default values function from.
555
+ * @returns The default values function, or undefined if not available.
556
+ * @internal
557
+ * @since 0.10.0
558
+ */
559
+ declare function getDefaultValuesFunction<M extends Mode, T, S>(parser: DerivedValueParser<M, T, S>): (() => readonly unknown[]) | undefined;
536
560
  /**
537
561
  * Creates a deferred parse state for a DerivedValueParser.
538
562
  *
@@ -688,7 +712,7 @@ interface ResolvedDependency<T = unknown> {
688
712
  * to DerivedValueParser options.
689
713
  * @since 0.10.0
690
714
  */
691
- declare class DependencyRegistry {
715
+ declare class DependencyRegistry implements DependencyRegistryLike {
692
716
  private readonly values;
693
717
  /**
694
718
  * Registers a resolved dependency value.
@@ -747,4 +771,4 @@ type DependencyError = {
747
771
  */
748
772
  declare function formatDependencyError(error: DependencyError): Message;
749
773
  //#endregion
750
- export { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker };
774
+ export { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker };