@optique/core 0.10.0-dev.292 → 0.10.0-dev.294

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.
@@ -20,6 +20,12 @@ const DerivedValueParserMarker = Symbol.for("@optique/core/dependency/DerivedVal
20
20
  */
21
21
  const DependencyId = Symbol.for("@optique/core/dependency/DependencyId");
22
22
  /**
23
+ * A unique symbol used to store multiple dependency IDs on derived parsers
24
+ * that depend on multiple sources (created via {@link deriveFrom}).
25
+ * @since 0.10.0
26
+ */
27
+ const DependencyIds = Symbol.for("@optique/core/dependency/DependencyIds");
28
+ /**
23
29
  * A unique symbol used to access the parseWithDependency method on derived parsers.
24
30
  * @since 0.10.0
25
31
  */
@@ -55,14 +61,22 @@ const ParseWithDependency = Symbol.for("@optique/core/dependency/ParseWithDepend
55
61
  */
56
62
  function dependency(parser) {
57
63
  const id = Symbol();
58
- return {
64
+ const result = {
59
65
  ...parser,
60
66
  [DependencySourceMarker]: true,
61
67
  [DependencyId]: id,
62
68
  derive(options) {
63
69
  return createDerivedValueParser(id, parser, options);
70
+ },
71
+ deriveSync(options) {
72
+ if (parser.$mode === "async") return createAsyncDerivedParserFromSyncFactory(id, options);
73
+ return createSyncDerivedParser(id, options);
74
+ },
75
+ deriveAsync(options) {
76
+ return createDerivedValueParser(id, parser, options);
64
77
  }
65
78
  };
79
+ return result;
66
80
  }
67
81
  /**
68
82
  * Checks if a value parser is a {@link DependencySource}.
@@ -116,17 +130,70 @@ function isDerivedValueParser(parser) {
116
130
  * @since 0.10.0
117
131
  */
118
132
  function deriveFrom(options) {
119
- const isAsync = options.dependencies.some((dep) => dep.$mode === "async");
133
+ const depsAsync = options.dependencies.some((dep) => dep.$mode === "async");
134
+ const factoryReturnsAsync = determineFactoryModeForDeriveFrom(options);
135
+ const sourceId = options.dependencies.length > 0 ? options.dependencies[0][DependencyId] : Symbol();
136
+ const isAsync = depsAsync || factoryReturnsAsync;
137
+ if (isAsync) {
138
+ if (factoryReturnsAsync) return createAsyncDerivedFromParserFromAsyncFactory(sourceId, options);
139
+ return createAsyncDerivedFromParserFromSyncFactory(sourceId, options);
140
+ }
141
+ return createSyncDerivedFromParser(sourceId, options);
142
+ }
143
+ /**
144
+ * Creates a derived value parser from multiple dependency sources
145
+ * with a synchronous factory.
146
+ *
147
+ * This function allows creating a parser whose behavior depends on
148
+ * multiple other parsers' values. The factory explicitly returns
149
+ * a sync parser.
150
+ *
151
+ * @template Deps A tuple of DependencySource types.
152
+ * @template T The type of value the derived parser produces.
153
+ * @param options Configuration for the derived parser with sync factory.
154
+ * @returns A {@link DerivedValueParser} that depends on the given sources.
155
+ * @since 0.10.0
156
+ */
157
+ function deriveFromSync(options) {
158
+ const depsAsync = options.dependencies.some((dep) => dep.$mode === "async");
120
159
  const sourceId = options.dependencies.length > 0 ? options.dependencies[0][DependencyId] : Symbol();
121
- if (isAsync) return createAsyncDerivedFromParser(sourceId, options);
160
+ if (depsAsync) return createAsyncDerivedFromParserFromSyncFactory(sourceId, options);
122
161
  return createSyncDerivedFromParser(sourceId, options);
123
162
  }
163
+ /**
164
+ * Creates a derived value parser from multiple dependency sources
165
+ * with an asynchronous factory.
166
+ *
167
+ * This function allows creating a parser whose behavior depends on
168
+ * multiple other parsers' values. The factory explicitly returns
169
+ * an async parser.
170
+ *
171
+ * @template Deps A tuple of DependencySource types.
172
+ * @template T The type of value the derived parser produces.
173
+ * @param options Configuration for the derived parser with async factory.
174
+ * @returns A {@link DerivedValueParser} that depends on the given sources.
175
+ * @since 0.10.0
176
+ */
177
+ function deriveFromAsync(options) {
178
+ const sourceId = options.dependencies.length > 0 ? options.dependencies[0][DependencyId] : Symbol();
179
+ return createAsyncDerivedFromParserFromAsyncFactory(sourceId, options);
180
+ }
181
+ /**
182
+ * Determines if the factory returns an async parser for deriveFrom options.
183
+ */
184
+ function determineFactoryModeForDeriveFrom(options) {
185
+ const defaultValues = options.defaultValues();
186
+ const parser = options.factory(...defaultValues);
187
+ return parser.$mode === "async";
188
+ }
124
189
  function createSyncDerivedFromParser(sourceId, options) {
190
+ const allDependencyIds = options.dependencies.map((dep) => dep[DependencyId]);
125
191
  return {
126
192
  $mode: "sync",
127
193
  metavar: options.metavar,
128
194
  [DerivedValueParserMarker]: true,
129
195
  [DependencyId]: sourceId,
196
+ [DependencyIds]: allDependencyIds,
130
197
  parse(input) {
131
198
  const sourceValues = options.defaultValues();
132
199
  const derivedParser = options.factory(...sourceValues);
@@ -148,12 +215,51 @@ function createSyncDerivedFromParser(sourceId, options) {
148
215
  }
149
216
  };
150
217
  }
151
- function createAsyncDerivedFromParser(sourceId, options) {
218
+ /**
219
+ * Creates an async derived parser from multiple dependencies when the
220
+ * factory returns an async parser.
221
+ */
222
+ function createAsyncDerivedFromParserFromAsyncFactory(sourceId, options) {
223
+ const allDependencyIds = options.dependencies.map((dep) => dep[DependencyId]);
224
+ return {
225
+ $mode: "async",
226
+ metavar: options.metavar,
227
+ [DerivedValueParserMarker]: true,
228
+ [DependencyId]: sourceId,
229
+ [DependencyIds]: allDependencyIds,
230
+ parse(input) {
231
+ const sourceValues = options.defaultValues();
232
+ const derivedParser = options.factory(...sourceValues);
233
+ return derivedParser.parse(input);
234
+ },
235
+ [ParseWithDependency](input, dependencyValue) {
236
+ const derivedParser = options.factory(...dependencyValue);
237
+ return derivedParser.parse(input);
238
+ },
239
+ format(value) {
240
+ const sourceValues = options.defaultValues();
241
+ const derivedParser = options.factory(...sourceValues);
242
+ return derivedParser.format(value);
243
+ },
244
+ async *suggest(prefix) {
245
+ const sourceValues = options.defaultValues();
246
+ const derivedParser = options.factory(...sourceValues);
247
+ if (derivedParser.suggest) for await (const suggestion of derivedParser.suggest(prefix)) yield suggestion;
248
+ }
249
+ };
250
+ }
251
+ /**
252
+ * Creates an async derived parser from multiple dependencies when the
253
+ * sources are async but the factory returns a sync parser.
254
+ */
255
+ function createAsyncDerivedFromParserFromSyncFactory(sourceId, options) {
256
+ const allDependencyIds = options.dependencies.map((dep) => dep[DependencyId]);
152
257
  return {
153
258
  $mode: "async",
154
259
  metavar: options.metavar,
155
260
  [DerivedValueParserMarker]: true,
156
261
  [DependencyId]: sourceId,
262
+ [DependencyIds]: allDependencyIds,
157
263
  parse(input) {
158
264
  const sourceValues = options.defaultValues();
159
265
  const derivedParser = options.factory(...sourceValues);
@@ -176,9 +282,23 @@ function createAsyncDerivedFromParser(sourceId, options) {
176
282
  };
177
283
  }
178
284
  function createDerivedValueParser(sourceId, sourceParser, options) {
179
- if (sourceParser.$mode === "async") return createAsyncDerivedParser(sourceId, options);
285
+ const factoryReturnsAsync = determineFactoryMode(options);
286
+ const isAsync = sourceParser.$mode === "async" || factoryReturnsAsync;
287
+ if (isAsync) {
288
+ if (factoryReturnsAsync) return createAsyncDerivedParserFromAsyncFactory(sourceId, options);
289
+ return createAsyncDerivedParserFromSyncFactory(sourceId, options);
290
+ }
180
291
  return createSyncDerivedParser(sourceId, options);
181
292
  }
293
+ /**
294
+ * Determines if the factory returns an async parser by calling it with
295
+ * the default value and checking the mode.
296
+ */
297
+ function determineFactoryMode(options) {
298
+ const defaultValue = options.defaultValue();
299
+ const parser = options.factory(defaultValue);
300
+ return parser.$mode === "async";
301
+ }
182
302
  function createSyncDerivedParser(sourceId, options) {
183
303
  return {
184
304
  $mode: "sync",
@@ -206,7 +326,42 @@ function createSyncDerivedParser(sourceId, options) {
206
326
  }
207
327
  };
208
328
  }
209
- function createAsyncDerivedParser(sourceId, options) {
329
+ /**
330
+ * Creates an async derived parser when the factory returns an async parser.
331
+ * The parse result is awaited since the factory returns an async parser.
332
+ */
333
+ function createAsyncDerivedParserFromAsyncFactory(sourceId, options) {
334
+ return {
335
+ $mode: "async",
336
+ metavar: options.metavar,
337
+ [DerivedValueParserMarker]: true,
338
+ [DependencyId]: sourceId,
339
+ parse(input) {
340
+ const sourceValue = options.defaultValue();
341
+ const derivedParser = options.factory(sourceValue);
342
+ return derivedParser.parse(input);
343
+ },
344
+ [ParseWithDependency](input, dependencyValue) {
345
+ const derivedParser = options.factory(dependencyValue);
346
+ return derivedParser.parse(input);
347
+ },
348
+ format(value) {
349
+ const sourceValue = options.defaultValue();
350
+ const derivedParser = options.factory(sourceValue);
351
+ return derivedParser.format(value);
352
+ },
353
+ async *suggest(prefix) {
354
+ const sourceValue = options.defaultValue();
355
+ const derivedParser = options.factory(sourceValue);
356
+ if (derivedParser.suggest) for await (const suggestion of derivedParser.suggest(prefix)) yield suggestion;
357
+ }
358
+ };
359
+ }
360
+ /**
361
+ * Creates an async derived parser when the source is async but the factory
362
+ * returns a sync parser. The sync result is wrapped in a Promise.
363
+ */
364
+ function createAsyncDerivedParserFromSyncFactory(sourceId, options) {
210
365
  return {
211
366
  $mode: "async",
212
367
  metavar: options.metavar,
@@ -260,11 +415,13 @@ function isDeferredParseState(value) {
260
415
  * @since 0.10.0
261
416
  */
262
417
  function createDeferredParseState(rawInput, parser, preliminaryResult) {
418
+ const multipleIds = DependencyIds in parser ? parser[DependencyIds] : void 0;
263
419
  return {
264
420
  [DeferredParseMarker]: true,
265
421
  rawInput,
266
422
  parser,
267
423
  dependencyId: parser[DependencyId],
424
+ dependencyIds: multipleIds,
268
425
  preliminaryResult
269
426
  };
270
427
  }
@@ -367,6 +524,7 @@ function formatDependencyError(error) {
367
524
  //#endregion
368
525
  exports.DeferredParseMarker = DeferredParseMarker;
369
526
  exports.DependencyId = DependencyId;
527
+ exports.DependencyIds = DependencyIds;
370
528
  exports.DependencyRegistry = DependencyRegistry;
371
529
  exports.DependencySourceMarker = DependencySourceMarker;
372
530
  exports.DependencySourceStateMarker = DependencySourceStateMarker;
@@ -376,6 +534,8 @@ exports.createDeferredParseState = createDeferredParseState;
376
534
  exports.createDependencySourceState = createDependencySourceState;
377
535
  exports.dependency = dependency;
378
536
  exports.deriveFrom = deriveFrom;
537
+ exports.deriveFromAsync = deriveFromAsync;
538
+ exports.deriveFromSync = deriveFromSync;
379
539
  exports.formatDependencyError = formatDependencyError;
380
540
  exports.isDeferredParseState = isDeferredParseState;
381
541
  exports.isDependencySource = isDependencySource;
@@ -24,19 +24,34 @@ declare const DerivedValueParserMarker: unique symbol;
24
24
  * @since 0.10.0
25
25
  */
26
26
  declare const DependencyId: unique symbol;
27
+ /**
28
+ * A unique symbol used to store multiple dependency IDs on derived parsers
29
+ * that depend on multiple sources (created via {@link deriveFrom}).
30
+ * @since 0.10.0
31
+ */
32
+ declare const DependencyIds: unique symbol;
27
33
  /**
28
34
  * A unique symbol used to access the parseWithDependency method on derived parsers.
29
35
  * @since 0.10.0
30
36
  */
31
37
  declare const ParseWithDependency: unique symbol;
38
+ /**
39
+ * Combines two modes into a single mode.
40
+ * If either mode is async, the result is async.
41
+ * @template M1 The first mode.
42
+ * @template M2 The second mode.
43
+ * @since 0.10.0
44
+ */
45
+ type CombineMode<M1 extends Mode, M2 extends Mode> = M1 extends "async" ? "async" : M2 extends "async" ? "async" : "sync";
32
46
  /**
33
47
  * Options for creating a derived value parser.
34
48
  *
35
49
  * @template S The type of the source dependency value.
36
50
  * @template T The type of the derived parser value.
51
+ * @template FM The mode of the factory's returned parser.
37
52
  * @since 0.10.0
38
53
  */
39
- interface DeriveOptions<S, T> {
54
+ interface DeriveOptions<S, T, FM extends Mode = Mode> {
40
55
  /**
41
56
  * The metavariable name for the derived parser. Used in help messages
42
57
  * to indicate what kind of value this parser expects.
@@ -49,7 +64,7 @@ interface DeriveOptions<S, T> {
49
64
  * @param sourceValue The value parsed from the dependency source.
50
65
  * @returns A {@link ValueParser} for the derived value.
51
66
  */
52
- readonly factory: (sourceValue: S) => ValueParser<"sync", T>;
67
+ readonly factory: (sourceValue: S) => ValueParser<FM, T>;
53
68
  /**
54
69
  * Default value to use when the dependency source is not provided.
55
70
  * This allows the derived parser to work even when the dependency
@@ -59,6 +74,48 @@ interface DeriveOptions<S, T> {
59
74
  */
60
75
  readonly defaultValue: () => S;
61
76
  }
77
+ /**
78
+ * Options for creating a derived value parser with a synchronous factory.
79
+ *
80
+ * @template S The type of the source dependency value.
81
+ * @template T The type of the derived parser value.
82
+ * @since 0.10.0
83
+ */
84
+ interface DeriveSyncOptions<S, T> {
85
+ /**
86
+ * The metavariable name for the derived parser.
87
+ */
88
+ readonly metavar: NonEmptyString;
89
+ /**
90
+ * Factory function that creates a synchronous {@link ValueParser}.
91
+ */
92
+ readonly factory: (sourceValue: S) => ValueParser<"sync", T>;
93
+ /**
94
+ * Default value to use when the dependency source is not provided.
95
+ */
96
+ readonly defaultValue: () => S;
97
+ }
98
+ /**
99
+ * Options for creating a derived value parser with an asynchronous factory.
100
+ *
101
+ * @template S The type of the source dependency value.
102
+ * @template T The type of the derived parser value.
103
+ * @since 0.10.0
104
+ */
105
+ interface DeriveAsyncOptions<S, T> {
106
+ /**
107
+ * The metavariable name for the derived parser.
108
+ */
109
+ readonly metavar: NonEmptyString;
110
+ /**
111
+ * Factory function that creates an asynchronous {@link ValueParser}.
112
+ */
113
+ readonly factory: (sourceValue: S) => ValueParser<"async", T>;
114
+ /**
115
+ * Default value to use when the dependency source is not provided.
116
+ */
117
+ readonly defaultValue: () => S;
118
+ }
62
119
  /**
63
120
  * Represents a dependency source that can be used to create derived parsers.
64
121
  *
@@ -87,14 +144,40 @@ interface DependencySource<M extends Mode = "sync", T = unknown> extends ValuePa
87
144
  * dependency source's value.
88
145
  *
89
146
  * The derived parser uses a factory function to create parsers based on
90
- * the source value. Currently, only synchronous factory functions are
91
- * supported.
147
+ * the source value. The factory can return either a sync or async parser,
148
+ * and the resulting derived parser's mode will be the combination of
149
+ * the source mode and the factory's returned parser mode.
92
150
  *
93
151
  * @template U The type of value the derived parser produces.
152
+ * @template FM The mode of the factory's returned parser.
94
153
  * @param options Configuration for the derived parser.
95
154
  * @returns A {@link DerivedValueParser} that depends on this source.
96
155
  */
97
- derive<U>(options: DeriveOptions<T, U>): DerivedValueParser<M, U, T>;
156
+ derive<U, FM extends Mode = "sync">(options: DeriveOptions<T, U, FM>): DerivedValueParser<CombineMode<M, FM>, U, T>;
157
+ /**
158
+ * Creates a derived value parser with a synchronous factory.
159
+ *
160
+ * This is a convenience method that explicitly requires a sync factory,
161
+ * making the type inference more predictable.
162
+ *
163
+ * @template U The type of value the derived parser produces.
164
+ * @param options Configuration for the derived parser with sync factory.
165
+ * @returns A {@link DerivedValueParser} that depends on this source.
166
+ * @since 0.10.0
167
+ */
168
+ deriveSync<U>(options: DeriveSyncOptions<T, U>): DerivedValueParser<M, U, T>;
169
+ /**
170
+ * Creates a derived value parser with an asynchronous factory.
171
+ *
172
+ * This is a convenience method that explicitly requires an async factory,
173
+ * making the type inference more predictable.
174
+ *
175
+ * @template U The type of value the derived parser produces.
176
+ * @param options Configuration for the derived parser with async factory.
177
+ * @returns A {@link DerivedValueParser} that depends on this source.
178
+ * @since 0.10.0
179
+ */
180
+ deriveAsync<U>(options: DeriveAsyncOptions<T, U>): DerivedValueParser<"async", U, T>;
98
181
  }
99
182
  /**
100
183
  * Extracts the value type from a DependencySource.
@@ -131,9 +214,10 @@ type AnyDependencySource = DependencySource<Mode, any>;
131
214
  *
132
215
  * @template Deps A tuple of DependencySource types.
133
216
  * @template T The type of the derived parser value.
217
+ * @template FM The mode of the factory's returned parser.
134
218
  * @since 0.10.0
135
219
  */
136
- interface DeriveFromOptions<Deps extends readonly AnyDependencySource[], T> {
220
+ interface DeriveFromOptions<Deps extends readonly AnyDependencySource[], T, FM extends Mode = Mode> {
137
221
  /**
138
222
  * The metavariable name for the derived parser. Used in help messages
139
223
  * to indicate what kind of value this parser expects.
@@ -150,7 +234,7 @@ interface DeriveFromOptions<Deps extends readonly AnyDependencySource[], T> {
150
234
  * @param values The values parsed from the dependency sources (in order).
151
235
  * @returns A {@link ValueParser} for the derived value.
152
236
  */
153
- readonly factory: (...values: DependencyValues<Deps>) => ValueParser<"sync", T>;
237
+ readonly factory: (...values: DependencyValues<Deps>) => ValueParser<FM, T>;
154
238
  /**
155
239
  * Default values to use when the dependency sources are not provided.
156
240
  * Must return a tuple with the same length and types as the dependencies.
@@ -159,6 +243,58 @@ interface DeriveFromOptions<Deps extends readonly AnyDependencySource[], T> {
159
243
  */
160
244
  readonly defaultValues: () => DependencyValues<Deps>;
161
245
  }
246
+ /**
247
+ * Options for creating a derived value parser from multiple dependencies
248
+ * with a synchronous factory.
249
+ *
250
+ * @template Deps A tuple of DependencySource types.
251
+ * @template T The type of the derived parser value.
252
+ * @since 0.10.0
253
+ */
254
+ interface DeriveFromSyncOptions<Deps extends readonly AnyDependencySource[], T> {
255
+ /**
256
+ * The metavariable name for the derived parser.
257
+ */
258
+ readonly metavar: NonEmptyString;
259
+ /**
260
+ * The dependency sources that this derived parser depends on.
261
+ */
262
+ readonly dependencies: Deps;
263
+ /**
264
+ * Factory function that creates a synchronous {@link ValueParser}.
265
+ */
266
+ readonly factory: (...values: DependencyValues<Deps>) => ValueParser<"sync", T>;
267
+ /**
268
+ * Default values to use when the dependency sources are not provided.
269
+ */
270
+ readonly defaultValues: () => DependencyValues<Deps>;
271
+ }
272
+ /**
273
+ * Options for creating a derived value parser from multiple dependencies
274
+ * with an asynchronous factory.
275
+ *
276
+ * @template Deps A tuple of DependencySource types.
277
+ * @template T The type of the derived parser value.
278
+ * @since 0.10.0
279
+ */
280
+ interface DeriveFromAsyncOptions<Deps extends readonly AnyDependencySource[], T> {
281
+ /**
282
+ * The metavariable name for the derived parser.
283
+ */
284
+ readonly metavar: NonEmptyString;
285
+ /**
286
+ * The dependency sources that this derived parser depends on.
287
+ */
288
+ readonly dependencies: Deps;
289
+ /**
290
+ * Factory function that creates an asynchronous {@link ValueParser}.
291
+ */
292
+ readonly factory: (...values: DependencyValues<Deps>) => ValueParser<"async", T>;
293
+ /**
294
+ * Default values to use when the dependency sources are not provided.
295
+ */
296
+ readonly defaultValues: () => DependencyValues<Deps>;
297
+ }
162
298
  /**
163
299
  * A value parser that depends on another parser's value.
164
300
  *
@@ -178,9 +314,19 @@ interface DerivedValueParser<M extends Mode = "sync", T = unknown, S = unknown>
178
314
  readonly [DerivedValueParserMarker]: true;
179
315
  /**
180
316
  * The unique identifier of the dependency source this parser depends on.
317
+ * For parsers created with {@link deriveFrom} that have multiple dependencies,
318
+ * this is set to the first dependency's ID for backwards compatibility.
181
319
  * @internal
182
320
  */
183
321
  readonly [DependencyId]: symbol;
322
+ /**
323
+ * The unique identifiers of all dependency sources this parser depends on.
324
+ * Present only for parsers created with {@link deriveFrom} that have multiple
325
+ * dependencies. If present, this takes precedence over {@link DependencyId}
326
+ * during dependency resolution.
327
+ * @internal
328
+ */
329
+ readonly [DependencyIds]?: readonly symbol[];
184
330
  /**
185
331
  * Parses the input using the actual dependency value instead of the default.
186
332
  * This method is used during dependency resolution in `complete()`.
@@ -269,7 +415,37 @@ declare function isDerivedValueParser<M extends Mode, T>(parser: ValueParser<M,
269
415
  * ```
270
416
  * @since 0.10.0
271
417
  */
272
- declare function deriveFrom<Deps extends readonly AnyDependencySource[], T>(options: DeriveFromOptions<Deps, T>): DerivedValueParser<CombinedDependencyMode<Deps>, T, DependencyValues<Deps>>;
418
+ declare function deriveFrom<Deps extends readonly AnyDependencySource[], T, FM extends Mode = "sync">(options: DeriveFromOptions<Deps, T, FM>): DerivedValueParser<CombineMode<CombinedDependencyMode<Deps>, FM>, T, DependencyValues<Deps>>;
419
+ /**
420
+ * Creates a derived value parser from multiple dependency sources
421
+ * with a synchronous factory.
422
+ *
423
+ * This function allows creating a parser whose behavior depends on
424
+ * multiple other parsers' values. The factory explicitly returns
425
+ * a sync parser.
426
+ *
427
+ * @template Deps A tuple of DependencySource types.
428
+ * @template T The type of value the derived parser produces.
429
+ * @param options Configuration for the derived parser with sync factory.
430
+ * @returns A {@link DerivedValueParser} that depends on the given sources.
431
+ * @since 0.10.0
432
+ */
433
+ declare function deriveFromSync<Deps extends readonly AnyDependencySource[], T>(options: DeriveFromSyncOptions<Deps, T>): DerivedValueParser<CombinedDependencyMode<Deps>, T, DependencyValues<Deps>>;
434
+ /**
435
+ * Creates a derived value parser from multiple dependency sources
436
+ * with an asynchronous factory.
437
+ *
438
+ * This function allows creating a parser whose behavior depends on
439
+ * multiple other parsers' values. The factory explicitly returns
440
+ * an async parser.
441
+ *
442
+ * @template Deps A tuple of DependencySource types.
443
+ * @template T The type of value the derived parser produces.
444
+ * @param options Configuration for the derived parser with async factory.
445
+ * @returns A {@link DerivedValueParser} that depends on the given sources.
446
+ * @since 0.10.0
447
+ */
448
+ declare function deriveFromAsync<Deps extends readonly AnyDependencySource[], T>(options: DeriveFromAsyncOptions<Deps, T>): DerivedValueParser<"async", T, DependencyValues<Deps>>;
273
449
  /**
274
450
  * A unique symbol used to identify deferred parse states.
275
451
  * @since 0.10.0
@@ -300,9 +476,14 @@ interface DeferredParseState<T = unknown> {
300
476
  */
301
477
  readonly parser: DerivedValueParser<Mode, T, unknown>;
302
478
  /**
303
- * The dependency ID that this parser depends on.
479
+ * The dependency ID that this parser depends on (for single-dependency parsers).
304
480
  */
305
481
  readonly dependencyId: symbol;
482
+ /**
483
+ * The dependency IDs that this parser depends on (for multi-dependency parsers).
484
+ * If present, this is used instead of `dependencyId`.
485
+ */
486
+ readonly dependencyIds?: readonly symbol[];
306
487
  /**
307
488
  * The preliminary parse result using the default dependency value.
308
489
  * This is used as a fallback if dependency resolution is not needed
@@ -454,4 +635,4 @@ type DependencyError = {
454
635
  */
455
636
  declare function formatDependencyError(error: DependencyError): Message;
456
637
  //#endregion
457
- export { AnyDependencySource, CombinedDependencyMode, DeferredParseMarker, DeferredParseState, DependencyError, DependencyId, DependencyMode, DependencyRegistry, DependencySource, DependencySourceMarker, DependencySourceState, DependencySourceStateMarker, DependencyValue, DependencyValues, DeriveFromOptions, DeriveOptions, DerivedValueParser, DerivedValueParserMarker, ParseWithDependency, ResolvedDependency, createDeferredParseState, createDependencySourceState, dependency, deriveFrom, formatDependencyError, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser };
638
+ export { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseMarker, DeferredParseState, DependencyError, DependencyId, DependencyIds, DependencyMode, DependencyRegistry, DependencySource, DependencySourceMarker, DependencySourceState, DependencySourceStateMarker, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DerivedValueParserMarker, ParseWithDependency, ResolvedDependency, createDeferredParseState, createDependencySourceState, dependency, deriveFrom, deriveFromAsync, deriveFromSync, formatDependencyError, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser };