@optique/core 1.0.0-dev.1828 → 1.0.0-dev.1841
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/context.d.cts +59 -26
- package/dist/context.d.ts +59 -26
- package/dist/facade.cjs +30 -29
- package/dist/facade.d.cts +7 -6
- package/dist/facade.d.ts +7 -6
- package/dist/facade.js +30 -29
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/context.d.cts
CHANGED
|
@@ -12,6 +12,46 @@ import { Annotations } from "./annotations.cjs";
|
|
|
12
12
|
* @since 1.0.0
|
|
13
13
|
*/
|
|
14
14
|
type SourceContextPhase = "single-pass" | "two-pass";
|
|
15
|
+
/**
|
|
16
|
+
* Phase-1 annotation collection request for a {@link SourceContext}.
|
|
17
|
+
*
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
interface SourceContextPhase1Request {
|
|
21
|
+
/**
|
|
22
|
+
* Indicates that the runner is collecting initial annotations before the
|
|
23
|
+
* first parse pass.
|
|
24
|
+
*/
|
|
25
|
+
readonly phase: "phase1";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Phase-2 annotation collection request for a {@link SourceContext}.
|
|
29
|
+
*
|
|
30
|
+
* @since 1.0.0
|
|
31
|
+
*/
|
|
32
|
+
interface SourceContextPhase2Request {
|
|
33
|
+
/**
|
|
34
|
+
* Indicates that the runner is recollecting annotations after a usable
|
|
35
|
+
* first parse pass.
|
|
36
|
+
*/
|
|
37
|
+
readonly phase: "phase2";
|
|
38
|
+
/**
|
|
39
|
+
* Parsed result from the first pass, or a best-effort partial value
|
|
40
|
+
* extracted from parser state when the first pass reached a usable
|
|
41
|
+
* intermediate state but did not complete successfully.
|
|
42
|
+
*/
|
|
43
|
+
readonly parsed: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Request object passed to {@link SourceContext.getAnnotations} and
|
|
47
|
+
* {@link SourceContext.getInternalAnnotations}.
|
|
48
|
+
*
|
|
49
|
+
* This makes phase 1 and phase 2 explicit so successful parser results of
|
|
50
|
+
* `undefined` are no longer ambiguous.
|
|
51
|
+
*
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
*/
|
|
54
|
+
type SourceContextRequest = SourceContextPhase1Request | SourceContextPhase2Request;
|
|
15
55
|
/**
|
|
16
56
|
* Brand symbol for ParserValuePlaceholder type.
|
|
17
57
|
* @internal
|
|
@@ -128,10 +168,11 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
128
168
|
* This method is called during phase 1 for every context and during phase 2
|
|
129
169
|
* only for `two-pass` contexts:
|
|
130
170
|
*
|
|
131
|
-
* 1. *Phase 1*: `
|
|
132
|
-
* 2. *Phase 2*: `
|
|
133
|
-
*
|
|
134
|
-
*
|
|
171
|
+
* 1. *Phase 1*: `request.phase` is `"phase1"`.
|
|
172
|
+
* 2. *Phase 2*: `request.phase` is `"phase2"` and `request.parsed`
|
|
173
|
+
* contains the first pass result, or a best-effort partial value
|
|
174
|
+
* extracted from parser state when the first pass reached a usable
|
|
175
|
+
* intermediate state but still did not complete successfully.
|
|
135
176
|
* Deferred or otherwise unresolved fields may be `undefined`. This
|
|
136
177
|
* second return value is treated as the context's final annotation
|
|
137
178
|
* snapshot for the second parse pass, replacing that context's phase-one
|
|
@@ -139,9 +180,15 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
139
180
|
* second call is skipped and the original parse failure is reported
|
|
140
181
|
* instead.
|
|
141
182
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
183
|
+
* Omitting the request is treated as a manual phase-1 call for
|
|
184
|
+
* convenience, so `context.getAnnotations()` continues to work for
|
|
185
|
+
* simple one-shot annotation reads.
|
|
186
|
+
*
|
|
187
|
+
* @param request Optional request describing which collection phase the
|
|
188
|
+
* runner is performing. `single-pass` contexts can ignore
|
|
189
|
+
* this parameter. `two-pass` contexts should branch on
|
|
190
|
+
* `request.phase` rather than inferring phases from
|
|
191
|
+
* `request.parsed`.
|
|
145
192
|
* @param options Optional context-required options provided by the caller
|
|
146
193
|
* of `runWith()`. These are the options declared via the
|
|
147
194
|
* `TRequiredOptions` type parameter.
|
|
@@ -150,36 +197,22 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
150
197
|
* during phase 1. Can be a Promise for async operations (e.g.,
|
|
151
198
|
* loading config files).
|
|
152
199
|
*/
|
|
153
|
-
getAnnotations(
|
|
200
|
+
getAnnotations(request?: SourceContextRequest, options?: unknown): Promise<Annotations> | Annotations;
|
|
154
201
|
/**
|
|
155
202
|
* Optional hook to provide additional internal annotations during
|
|
156
203
|
* annotation collection. Called after {@link getAnnotations} with the
|
|
157
|
-
* same
|
|
204
|
+
* same request object and the annotations returned by `getAnnotations()`.
|
|
158
205
|
*
|
|
159
206
|
* Returns additional annotations to merge, or `undefined` to add nothing.
|
|
160
207
|
* This enables contexts to inject phase-specific markers without
|
|
161
208
|
* exposing them through the primary `getAnnotations()` API.
|
|
162
209
|
*
|
|
163
|
-
* @param
|
|
164
|
-
* `undefined` during the first pass.
|
|
210
|
+
* @param request The request describing the current collection phase.
|
|
165
211
|
* @param annotations The annotations returned by `getAnnotations()`.
|
|
166
212
|
* @returns Additional annotations to merge, or `undefined`.
|
|
167
213
|
* @since 1.0.0
|
|
168
214
|
*/
|
|
169
|
-
getInternalAnnotations?(
|
|
170
|
-
/**
|
|
171
|
-
* Optional hook to transform the parsed value before it is passed to
|
|
172
|
-
* {@link getAnnotations} during phase-2 annotation collection.
|
|
173
|
-
*
|
|
174
|
-
* This allows contexts to distinguish between "parsed value was
|
|
175
|
-
* `undefined`" and "no parse happened yet" by wrapping `undefined`
|
|
176
|
-
* values with a context-private marker.
|
|
177
|
-
*
|
|
178
|
-
* @param parsed The parsed value to finalize.
|
|
179
|
-
* @returns The finalized parsed value.
|
|
180
|
-
* @since 1.0.0
|
|
181
|
-
*/
|
|
182
|
-
finalizeParsed?(parsed: unknown): unknown;
|
|
215
|
+
getInternalAnnotations?(request: SourceContextRequest, annotations: Annotations): Annotations | undefined;
|
|
183
216
|
/**
|
|
184
217
|
* Optional synchronous cleanup method. Called by `runWith()` and
|
|
185
218
|
* `runWithSync()` after parsing completes. In `runWith()`, this happens
|
|
@@ -199,4 +232,4 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
199
232
|
[Symbol.asyncDispose]?(): void | PromiseLike<void>;
|
|
200
233
|
}
|
|
201
234
|
//#endregion
|
|
202
|
-
export { type Annotations, ParserValuePlaceholder, SourceContext, SourceContextPhase };
|
|
235
|
+
export { type Annotations, ParserValuePlaceholder, SourceContext, SourceContextPhase, SourceContextPhase1Request, SourceContextPhase2Request, SourceContextRequest };
|
package/dist/context.d.ts
CHANGED
|
@@ -12,6 +12,46 @@ import { Annotations } from "./annotations.js";
|
|
|
12
12
|
* @since 1.0.0
|
|
13
13
|
*/
|
|
14
14
|
type SourceContextPhase = "single-pass" | "two-pass";
|
|
15
|
+
/**
|
|
16
|
+
* Phase-1 annotation collection request for a {@link SourceContext}.
|
|
17
|
+
*
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
interface SourceContextPhase1Request {
|
|
21
|
+
/**
|
|
22
|
+
* Indicates that the runner is collecting initial annotations before the
|
|
23
|
+
* first parse pass.
|
|
24
|
+
*/
|
|
25
|
+
readonly phase: "phase1";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Phase-2 annotation collection request for a {@link SourceContext}.
|
|
29
|
+
*
|
|
30
|
+
* @since 1.0.0
|
|
31
|
+
*/
|
|
32
|
+
interface SourceContextPhase2Request {
|
|
33
|
+
/**
|
|
34
|
+
* Indicates that the runner is recollecting annotations after a usable
|
|
35
|
+
* first parse pass.
|
|
36
|
+
*/
|
|
37
|
+
readonly phase: "phase2";
|
|
38
|
+
/**
|
|
39
|
+
* Parsed result from the first pass, or a best-effort partial value
|
|
40
|
+
* extracted from parser state when the first pass reached a usable
|
|
41
|
+
* intermediate state but did not complete successfully.
|
|
42
|
+
*/
|
|
43
|
+
readonly parsed: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Request object passed to {@link SourceContext.getAnnotations} and
|
|
47
|
+
* {@link SourceContext.getInternalAnnotations}.
|
|
48
|
+
*
|
|
49
|
+
* This makes phase 1 and phase 2 explicit so successful parser results of
|
|
50
|
+
* `undefined` are no longer ambiguous.
|
|
51
|
+
*
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
*/
|
|
54
|
+
type SourceContextRequest = SourceContextPhase1Request | SourceContextPhase2Request;
|
|
15
55
|
/**
|
|
16
56
|
* Brand symbol for ParserValuePlaceholder type.
|
|
17
57
|
* @internal
|
|
@@ -128,10 +168,11 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
128
168
|
* This method is called during phase 1 for every context and during phase 2
|
|
129
169
|
* only for `two-pass` contexts:
|
|
130
170
|
*
|
|
131
|
-
* 1. *Phase 1*: `
|
|
132
|
-
* 2. *Phase 2*: `
|
|
133
|
-
*
|
|
134
|
-
*
|
|
171
|
+
* 1. *Phase 1*: `request.phase` is `"phase1"`.
|
|
172
|
+
* 2. *Phase 2*: `request.phase` is `"phase2"` and `request.parsed`
|
|
173
|
+
* contains the first pass result, or a best-effort partial value
|
|
174
|
+
* extracted from parser state when the first pass reached a usable
|
|
175
|
+
* intermediate state but still did not complete successfully.
|
|
135
176
|
* Deferred or otherwise unresolved fields may be `undefined`. This
|
|
136
177
|
* second return value is treated as the context's final annotation
|
|
137
178
|
* snapshot for the second parse pass, replacing that context's phase-one
|
|
@@ -139,9 +180,15 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
139
180
|
* second call is skipped and the original parse failure is reported
|
|
140
181
|
* instead.
|
|
141
182
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
183
|
+
* Omitting the request is treated as a manual phase-1 call for
|
|
184
|
+
* convenience, so `context.getAnnotations()` continues to work for
|
|
185
|
+
* simple one-shot annotation reads.
|
|
186
|
+
*
|
|
187
|
+
* @param request Optional request describing which collection phase the
|
|
188
|
+
* runner is performing. `single-pass` contexts can ignore
|
|
189
|
+
* this parameter. `two-pass` contexts should branch on
|
|
190
|
+
* `request.phase` rather than inferring phases from
|
|
191
|
+
* `request.parsed`.
|
|
145
192
|
* @param options Optional context-required options provided by the caller
|
|
146
193
|
* of `runWith()`. These are the options declared via the
|
|
147
194
|
* `TRequiredOptions` type parameter.
|
|
@@ -150,36 +197,22 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
150
197
|
* during phase 1. Can be a Promise for async operations (e.g.,
|
|
151
198
|
* loading config files).
|
|
152
199
|
*/
|
|
153
|
-
getAnnotations(
|
|
200
|
+
getAnnotations(request?: SourceContextRequest, options?: unknown): Promise<Annotations> | Annotations;
|
|
154
201
|
/**
|
|
155
202
|
* Optional hook to provide additional internal annotations during
|
|
156
203
|
* annotation collection. Called after {@link getAnnotations} with the
|
|
157
|
-
* same
|
|
204
|
+
* same request object and the annotations returned by `getAnnotations()`.
|
|
158
205
|
*
|
|
159
206
|
* Returns additional annotations to merge, or `undefined` to add nothing.
|
|
160
207
|
* This enables contexts to inject phase-specific markers without
|
|
161
208
|
* exposing them through the primary `getAnnotations()` API.
|
|
162
209
|
*
|
|
163
|
-
* @param
|
|
164
|
-
* `undefined` during the first pass.
|
|
210
|
+
* @param request The request describing the current collection phase.
|
|
165
211
|
* @param annotations The annotations returned by `getAnnotations()`.
|
|
166
212
|
* @returns Additional annotations to merge, or `undefined`.
|
|
167
213
|
* @since 1.0.0
|
|
168
214
|
*/
|
|
169
|
-
getInternalAnnotations?(
|
|
170
|
-
/**
|
|
171
|
-
* Optional hook to transform the parsed value before it is passed to
|
|
172
|
-
* {@link getAnnotations} during phase-2 annotation collection.
|
|
173
|
-
*
|
|
174
|
-
* This allows contexts to distinguish between "parsed value was
|
|
175
|
-
* `undefined`" and "no parse happened yet" by wrapping `undefined`
|
|
176
|
-
* values with a context-private marker.
|
|
177
|
-
*
|
|
178
|
-
* @param parsed The parsed value to finalize.
|
|
179
|
-
* @returns The finalized parsed value.
|
|
180
|
-
* @since 1.0.0
|
|
181
|
-
*/
|
|
182
|
-
finalizeParsed?(parsed: unknown): unknown;
|
|
215
|
+
getInternalAnnotations?(request: SourceContextRequest, annotations: Annotations): Annotations | undefined;
|
|
183
216
|
/**
|
|
184
217
|
* Optional synchronous cleanup method. Called by `runWith()` and
|
|
185
218
|
* `runWithSync()` after parsing completes. In `runWith()`, this happens
|
|
@@ -199,4 +232,4 @@ interface SourceContext<TRequiredOptions = void> {
|
|
|
199
232
|
[Symbol.asyncDispose]?(): void | PromiseLike<void>;
|
|
200
233
|
}
|
|
201
234
|
//#endregion
|
|
202
|
-
export { type Annotations, ParserValuePlaceholder, SourceContext, SourceContextPhase };
|
|
235
|
+
export { type Annotations, ParserValuePlaceholder, SourceContext, SourceContextPhase, SourceContextPhase1Request, SourceContextPhase2Request, SourceContextRequest };
|
package/dist/facade.cjs
CHANGED
|
@@ -28,9 +28,6 @@ const SuppressedErrorCtor = typeof SuppressedError === "function" ? SuppressedEr
|
|
|
28
28
|
}
|
|
29
29
|
return SuppressedErrorPolyfill;
|
|
30
30
|
})();
|
|
31
|
-
function finalizeParsedForContext(context, parsed) {
|
|
32
|
-
return context.finalizeParsed != null ? context.finalizeParsed(parsed) : parsed;
|
|
33
|
-
}
|
|
34
31
|
function isPlainObject(value$1) {
|
|
35
32
|
const proto = Object.getPrototypeOf(value$1);
|
|
36
33
|
return proto === Object.prototype || proto === null;
|
|
@@ -89,9 +86,6 @@ function prepareParsedForContexts(parsed, deferred, deferredKeys) {
|
|
|
89
86
|
if (parsed == null || typeof parsed !== "object") return void 0;
|
|
90
87
|
return parsed;
|
|
91
88
|
}
|
|
92
|
-
function withPreparedParsedForContext(context, preparedParsed, run) {
|
|
93
|
-
return run(finalizeParsedForContext(context, preparedParsed));
|
|
94
|
-
}
|
|
95
89
|
function isBufferUnchanged(previous, current) {
|
|
96
90
|
return current.length > 0 && current.length === previous.length && current.every((item, i) => item === previous[i]);
|
|
97
91
|
}
|
|
@@ -1247,9 +1241,10 @@ async function collectPhase1Annotations(contexts, options) {
|
|
|
1247
1241
|
const annotationsList = [];
|
|
1248
1242
|
let snapshots;
|
|
1249
1243
|
for (const context of contexts) {
|
|
1250
|
-
const
|
|
1244
|
+
const request = { phase: "phase1" };
|
|
1245
|
+
const result = context.getAnnotations(request, options);
|
|
1251
1246
|
const annotations = result instanceof Promise ? await result : result;
|
|
1252
|
-
const internalAnnotations = context.getInternalAnnotations?.(
|
|
1247
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, annotations);
|
|
1253
1248
|
const snapshot = internalAnnotations == null ? annotations : mergeAnnotations([annotations, internalAnnotations]);
|
|
1254
1249
|
annotationsList.push(snapshot);
|
|
1255
1250
|
if (snapshots != null) snapshots.push(snapshot);
|
|
@@ -1283,12 +1278,14 @@ async function collectFinalAnnotations(contexts, phase1Snapshots, parsed, option
|
|
|
1283
1278
|
annotationsList.push(phase1Snapshots[index]);
|
|
1284
1279
|
continue;
|
|
1285
1280
|
}
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1281
|
+
const request = {
|
|
1282
|
+
phase: "phase2",
|
|
1283
|
+
parsed: preparedParsed
|
|
1284
|
+
};
|
|
1285
|
+
const result = context.getAnnotations(request, options);
|
|
1286
|
+
const annotations = result instanceof Promise ? await result : result;
|
|
1287
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, annotations);
|
|
1288
|
+
const mergedAnnotations = internalAnnotations == null ? annotations : mergeAnnotations([annotations, internalAnnotations]);
|
|
1292
1289
|
annotationsList.push(mergedAnnotations);
|
|
1293
1290
|
}
|
|
1294
1291
|
return { annotations: mergeAnnotations(annotationsList) };
|
|
@@ -1300,15 +1297,16 @@ async function collectFinalAnnotations(contexts, phase1Snapshots, parsed, option
|
|
|
1300
1297
|
* @param contexts Source contexts to collect annotations from.
|
|
1301
1298
|
* @param options Optional context-required options to pass to each context.
|
|
1302
1299
|
* @returns Merged annotations, per-context snapshots, and a two-phase hint.
|
|
1303
|
-
* @throws
|
|
1300
|
+
* @throws {TypeError} If any context returns a Promise.
|
|
1304
1301
|
*/
|
|
1305
1302
|
function collectPhase1AnnotationsSync(contexts, options) {
|
|
1306
1303
|
const annotationsList = [];
|
|
1307
1304
|
let snapshots;
|
|
1308
1305
|
for (const context of contexts) {
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1311
|
-
|
|
1306
|
+
const request = { phase: "phase1" };
|
|
1307
|
+
const result = context.getAnnotations(request, options);
|
|
1308
|
+
if (result instanceof Promise) throw new TypeError(`Context ${String(context.id)} returned a Promise in sync mode. Use runWith() or runWithAsync() for async contexts.`);
|
|
1309
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, result);
|
|
1312
1310
|
const snapshot = internalAnnotations == null ? result : mergeAnnotations([result, internalAnnotations]);
|
|
1313
1311
|
annotationsList.push(snapshot);
|
|
1314
1312
|
if (snapshots != null) snapshots.push(snapshot);
|
|
@@ -1332,7 +1330,7 @@ function collectPhase1AnnotationsSync(contexts, options) {
|
|
|
1332
1330
|
* @param parsed Optional parsed result from a previous parse pass.
|
|
1333
1331
|
* @param options Optional context-required options to pass to each context.
|
|
1334
1332
|
* @returns Merged annotations.
|
|
1335
|
-
* @throws
|
|
1333
|
+
* @throws {TypeError} If any context returns a Promise.
|
|
1336
1334
|
*/
|
|
1337
1335
|
function collectFinalAnnotationsSync(contexts, phase1Snapshots, parsed, options, deferred, deferredKeys) {
|
|
1338
1336
|
const annotationsList = [];
|
|
@@ -1343,12 +1341,14 @@ function collectFinalAnnotationsSync(contexts, phase1Snapshots, parsed, options,
|
|
|
1343
1341
|
annotationsList.push(phase1Snapshots[index]);
|
|
1344
1342
|
continue;
|
|
1345
1343
|
}
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
});
|
|
1344
|
+
const request = {
|
|
1345
|
+
phase: "phase2",
|
|
1346
|
+
parsed: preparedParsed
|
|
1347
|
+
};
|
|
1348
|
+
const result = context.getAnnotations(request, options);
|
|
1349
|
+
if (result instanceof Promise) throw new TypeError(`Context ${String(context.id)} returned a Promise in sync mode. Use runWith() or runWithAsync() for async contexts.`);
|
|
1350
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, result);
|
|
1351
|
+
const mergedAnnotations = internalAnnotations == null ? result : mergeAnnotations([result, internalAnnotations]);
|
|
1352
1352
|
annotationsList.push(mergedAnnotations);
|
|
1353
1353
|
}
|
|
1354
1354
|
return { annotations: mergeAnnotations(annotationsList) };
|
|
@@ -1436,9 +1436,10 @@ async function runWithBody(parser, programName, contexts, args, options) {
|
|
|
1436
1436
|
* reaches a usable intermediate state but still does not complete
|
|
1437
1437
|
* successfully, the runner extracts a best-effort seed from that state
|
|
1438
1438
|
* instead.
|
|
1439
|
-
* 3. *Phase 2*: Call `getAnnotations(parsed)` on all
|
|
1440
|
-
* the first pass value. Deferred or otherwise
|
|
1441
|
-
* `parsed` may be `undefined`. Each two-pass
|
|
1439
|
+
* 3. *Phase 2*: Call `getAnnotations({ phase: "phase2", parsed })` on all
|
|
1440
|
+
* two-pass contexts with the first pass value. Deferred or otherwise
|
|
1441
|
+
* unresolved fields in `parsed` may be `undefined`. Each two-pass
|
|
1442
|
+
* context's phase-two return
|
|
1442
1443
|
* value replaces its own phase-one contribution for the final parse, so
|
|
1443
1444
|
* returning `{}` clears any annotations that context provided during
|
|
1444
1445
|
* phase 1. Single-pass contexts reuse their phase-one snapshot.
|
|
@@ -1558,7 +1559,7 @@ function runWithSyncBody(parser, programName, contexts, args, options) {
|
|
|
1558
1559
|
* {@link SourceContext.id}.
|
|
1559
1560
|
* @throws {TypeError} If any context omits `phase` or declares an invalid
|
|
1560
1561
|
* phase value.
|
|
1561
|
-
* @throws {
|
|
1562
|
+
* @throws {TypeError} If any context returns a Promise or if a context's
|
|
1562
1563
|
* `[Symbol.asyncDispose]` returns a Promise.
|
|
1563
1564
|
* @throws {SuppressedError} If the runner throws and a context's disposal
|
|
1564
1565
|
* also throws. The original error is available via `.suppressed` and the
|
package/dist/facade.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { HiddenVisibility, OptionName } from "./usage.cjs";
|
|
|
3
3
|
import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.cjs";
|
|
4
4
|
import { InferMode, InferValue, Mode, ModeValue, Parser } from "./parser.cjs";
|
|
5
5
|
import { ShellCompletion } from "./completion.cjs";
|
|
6
|
-
import { ParserValuePlaceholder, SourceContext } from "./context.cjs";
|
|
6
|
+
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.cjs";
|
|
7
7
|
import { Program } from "./program.cjs";
|
|
8
8
|
|
|
9
9
|
//#region src/facade.d.ts
|
|
@@ -416,9 +416,10 @@ type ContextOptionsParam<TContexts extends readonly SourceContext<unknown>[], TV
|
|
|
416
416
|
* reaches a usable intermediate state but still does not complete
|
|
417
417
|
* successfully, the runner extracts a best-effort seed from that state
|
|
418
418
|
* instead.
|
|
419
|
-
* 3. *Phase 2*: Call `getAnnotations(parsed)` on all
|
|
420
|
-
* the first pass value. Deferred or otherwise
|
|
421
|
-
* `parsed` may be `undefined`. Each two-pass
|
|
419
|
+
* 3. *Phase 2*: Call `getAnnotations({ phase: "phase2", parsed })` on all
|
|
420
|
+
* two-pass contexts with the first pass value. Deferred or otherwise
|
|
421
|
+
* unresolved fields in `parsed` may be `undefined`. Each two-pass
|
|
422
|
+
* context's phase-two return
|
|
422
423
|
* value replaces its own phase-one contribution for the final parse, so
|
|
423
424
|
* returning `{}` clears any annotations that context provided during
|
|
424
425
|
* phase 1. Single-pass contexts reuse their phase-one snapshot.
|
|
@@ -491,7 +492,7 @@ declare function runWith<TParser extends Parser<Mode, unknown, unknown>, TContex
|
|
|
491
492
|
* {@link SourceContext.id}.
|
|
492
493
|
* @throws {TypeError} If any context omits `phase` or declares an invalid
|
|
493
494
|
* phase value.
|
|
494
|
-
* @throws {
|
|
495
|
+
* @throws {TypeError} If any context returns a Promise or if a context's
|
|
495
496
|
* `[Symbol.asyncDispose]` returns a Promise.
|
|
496
497
|
* @throws {SuppressedError} If the runner throws and a context's disposal
|
|
497
498
|
* also throws. The original error is available via `.suppressed` and the
|
|
@@ -522,4 +523,4 @@ declare function runWithSync<TParser extends Parser<"sync", unknown, unknown>, T
|
|
|
522
523
|
*/
|
|
523
524
|
declare function runWithAsync<TParser extends Parser<Mode, unknown, unknown>, TContexts extends readonly SourceContext<unknown>[], THelp = void, TError = never>(parser: TParser, programName: string, contexts: TContexts, options: RunWithOptions<THelp, TError> & ContextOptionsParam<TContexts, InferValue<TParser>>): Promise<InferValue<TParser>>;
|
|
524
525
|
//#endregion
|
|
525
|
-
export { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
|
526
|
+
export { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, type SourceContextRequest, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
package/dist/facade.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { HiddenVisibility, OptionName } from "./usage.js";
|
|
|
3
3
|
import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.js";
|
|
4
4
|
import { InferMode, InferValue, Mode, ModeValue, Parser } from "./parser.js";
|
|
5
5
|
import { ShellCompletion } from "./completion.js";
|
|
6
|
-
import { ParserValuePlaceholder, SourceContext } from "./context.js";
|
|
6
|
+
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.js";
|
|
7
7
|
import { Program } from "./program.js";
|
|
8
8
|
|
|
9
9
|
//#region src/facade.d.ts
|
|
@@ -416,9 +416,10 @@ type ContextOptionsParam<TContexts extends readonly SourceContext<unknown>[], TV
|
|
|
416
416
|
* reaches a usable intermediate state but still does not complete
|
|
417
417
|
* successfully, the runner extracts a best-effort seed from that state
|
|
418
418
|
* instead.
|
|
419
|
-
* 3. *Phase 2*: Call `getAnnotations(parsed)` on all
|
|
420
|
-
* the first pass value. Deferred or otherwise
|
|
421
|
-
* `parsed` may be `undefined`. Each two-pass
|
|
419
|
+
* 3. *Phase 2*: Call `getAnnotations({ phase: "phase2", parsed })` on all
|
|
420
|
+
* two-pass contexts with the first pass value. Deferred or otherwise
|
|
421
|
+
* unresolved fields in `parsed` may be `undefined`. Each two-pass
|
|
422
|
+
* context's phase-two return
|
|
422
423
|
* value replaces its own phase-one contribution for the final parse, so
|
|
423
424
|
* returning `{}` clears any annotations that context provided during
|
|
424
425
|
* phase 1. Single-pass contexts reuse their phase-one snapshot.
|
|
@@ -491,7 +492,7 @@ declare function runWith<TParser extends Parser<Mode, unknown, unknown>, TContex
|
|
|
491
492
|
* {@link SourceContext.id}.
|
|
492
493
|
* @throws {TypeError} If any context omits `phase` or declares an invalid
|
|
493
494
|
* phase value.
|
|
494
|
-
* @throws {
|
|
495
|
+
* @throws {TypeError} If any context returns a Promise or if a context's
|
|
495
496
|
* `[Symbol.asyncDispose]` returns a Promise.
|
|
496
497
|
* @throws {SuppressedError} If the runner throws and a context's disposal
|
|
497
498
|
* also throws. The original error is available via `.suppressed` and the
|
|
@@ -522,4 +523,4 @@ declare function runWithSync<TParser extends Parser<"sync", unknown, unknown>, T
|
|
|
522
523
|
*/
|
|
523
524
|
declare function runWithAsync<TParser extends Parser<Mode, unknown, unknown>, TContexts extends readonly SourceContext<unknown>[], THelp = void, TError = never>(parser: TParser, programName: string, contexts: TContexts, options: RunWithOptions<THelp, TError> & ContextOptionsParam<TContexts, InferValue<TParser>>): Promise<InferValue<TParser>>;
|
|
524
525
|
//#endregion
|
|
525
|
-
export { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
|
526
|
+
export { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, type SourceContextRequest, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
package/dist/facade.js
CHANGED
|
@@ -28,9 +28,6 @@ const SuppressedErrorCtor = typeof SuppressedError === "function" ? SuppressedEr
|
|
|
28
28
|
}
|
|
29
29
|
return SuppressedErrorPolyfill;
|
|
30
30
|
})();
|
|
31
|
-
function finalizeParsedForContext(context, parsed) {
|
|
32
|
-
return context.finalizeParsed != null ? context.finalizeParsed(parsed) : parsed;
|
|
33
|
-
}
|
|
34
31
|
function isPlainObject(value$1) {
|
|
35
32
|
const proto = Object.getPrototypeOf(value$1);
|
|
36
33
|
return proto === Object.prototype || proto === null;
|
|
@@ -89,9 +86,6 @@ function prepareParsedForContexts(parsed, deferred, deferredKeys) {
|
|
|
89
86
|
if (parsed == null || typeof parsed !== "object") return void 0;
|
|
90
87
|
return parsed;
|
|
91
88
|
}
|
|
92
|
-
function withPreparedParsedForContext(context, preparedParsed, run) {
|
|
93
|
-
return run(finalizeParsedForContext(context, preparedParsed));
|
|
94
|
-
}
|
|
95
89
|
function isBufferUnchanged(previous, current) {
|
|
96
90
|
return current.length > 0 && current.length === previous.length && current.every((item, i) => item === previous[i]);
|
|
97
91
|
}
|
|
@@ -1247,9 +1241,10 @@ async function collectPhase1Annotations(contexts, options) {
|
|
|
1247
1241
|
const annotationsList = [];
|
|
1248
1242
|
let snapshots;
|
|
1249
1243
|
for (const context of contexts) {
|
|
1250
|
-
const
|
|
1244
|
+
const request = { phase: "phase1" };
|
|
1245
|
+
const result = context.getAnnotations(request, options);
|
|
1251
1246
|
const annotations = result instanceof Promise ? await result : result;
|
|
1252
|
-
const internalAnnotations = context.getInternalAnnotations?.(
|
|
1247
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, annotations);
|
|
1253
1248
|
const snapshot = internalAnnotations == null ? annotations : mergeAnnotations([annotations, internalAnnotations]);
|
|
1254
1249
|
annotationsList.push(snapshot);
|
|
1255
1250
|
if (snapshots != null) snapshots.push(snapshot);
|
|
@@ -1283,12 +1278,14 @@ async function collectFinalAnnotations(contexts, phase1Snapshots, parsed, option
|
|
|
1283
1278
|
annotationsList.push(phase1Snapshots[index]);
|
|
1284
1279
|
continue;
|
|
1285
1280
|
}
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1281
|
+
const request = {
|
|
1282
|
+
phase: "phase2",
|
|
1283
|
+
parsed: preparedParsed
|
|
1284
|
+
};
|
|
1285
|
+
const result = context.getAnnotations(request, options);
|
|
1286
|
+
const annotations = result instanceof Promise ? await result : result;
|
|
1287
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, annotations);
|
|
1288
|
+
const mergedAnnotations = internalAnnotations == null ? annotations : mergeAnnotations([annotations, internalAnnotations]);
|
|
1292
1289
|
annotationsList.push(mergedAnnotations);
|
|
1293
1290
|
}
|
|
1294
1291
|
return { annotations: mergeAnnotations(annotationsList) };
|
|
@@ -1300,15 +1297,16 @@ async function collectFinalAnnotations(contexts, phase1Snapshots, parsed, option
|
|
|
1300
1297
|
* @param contexts Source contexts to collect annotations from.
|
|
1301
1298
|
* @param options Optional context-required options to pass to each context.
|
|
1302
1299
|
* @returns Merged annotations, per-context snapshots, and a two-phase hint.
|
|
1303
|
-
* @throws
|
|
1300
|
+
* @throws {TypeError} If any context returns a Promise.
|
|
1304
1301
|
*/
|
|
1305
1302
|
function collectPhase1AnnotationsSync(contexts, options) {
|
|
1306
1303
|
const annotationsList = [];
|
|
1307
1304
|
let snapshots;
|
|
1308
1305
|
for (const context of contexts) {
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1311
|
-
|
|
1306
|
+
const request = { phase: "phase1" };
|
|
1307
|
+
const result = context.getAnnotations(request, options);
|
|
1308
|
+
if (result instanceof Promise) throw new TypeError(`Context ${String(context.id)} returned a Promise in sync mode. Use runWith() or runWithAsync() for async contexts.`);
|
|
1309
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, result);
|
|
1312
1310
|
const snapshot = internalAnnotations == null ? result : mergeAnnotations([result, internalAnnotations]);
|
|
1313
1311
|
annotationsList.push(snapshot);
|
|
1314
1312
|
if (snapshots != null) snapshots.push(snapshot);
|
|
@@ -1332,7 +1330,7 @@ function collectPhase1AnnotationsSync(contexts, options) {
|
|
|
1332
1330
|
* @param parsed Optional parsed result from a previous parse pass.
|
|
1333
1331
|
* @param options Optional context-required options to pass to each context.
|
|
1334
1332
|
* @returns Merged annotations.
|
|
1335
|
-
* @throws
|
|
1333
|
+
* @throws {TypeError} If any context returns a Promise.
|
|
1336
1334
|
*/
|
|
1337
1335
|
function collectFinalAnnotationsSync(contexts, phase1Snapshots, parsed, options, deferred, deferredKeys) {
|
|
1338
1336
|
const annotationsList = [];
|
|
@@ -1343,12 +1341,14 @@ function collectFinalAnnotationsSync(contexts, phase1Snapshots, parsed, options,
|
|
|
1343
1341
|
annotationsList.push(phase1Snapshots[index]);
|
|
1344
1342
|
continue;
|
|
1345
1343
|
}
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
});
|
|
1344
|
+
const request = {
|
|
1345
|
+
phase: "phase2",
|
|
1346
|
+
parsed: preparedParsed
|
|
1347
|
+
};
|
|
1348
|
+
const result = context.getAnnotations(request, options);
|
|
1349
|
+
if (result instanceof Promise) throw new TypeError(`Context ${String(context.id)} returned a Promise in sync mode. Use runWith() or runWithAsync() for async contexts.`);
|
|
1350
|
+
const internalAnnotations = context.getInternalAnnotations?.(request, result);
|
|
1351
|
+
const mergedAnnotations = internalAnnotations == null ? result : mergeAnnotations([result, internalAnnotations]);
|
|
1352
1352
|
annotationsList.push(mergedAnnotations);
|
|
1353
1353
|
}
|
|
1354
1354
|
return { annotations: mergeAnnotations(annotationsList) };
|
|
@@ -1436,9 +1436,10 @@ async function runWithBody(parser, programName, contexts, args, options) {
|
|
|
1436
1436
|
* reaches a usable intermediate state but still does not complete
|
|
1437
1437
|
* successfully, the runner extracts a best-effort seed from that state
|
|
1438
1438
|
* instead.
|
|
1439
|
-
* 3. *Phase 2*: Call `getAnnotations(parsed)` on all
|
|
1440
|
-
* the first pass value. Deferred or otherwise
|
|
1441
|
-
* `parsed` may be `undefined`. Each two-pass
|
|
1439
|
+
* 3. *Phase 2*: Call `getAnnotations({ phase: "phase2", parsed })` on all
|
|
1440
|
+
* two-pass contexts with the first pass value. Deferred or otherwise
|
|
1441
|
+
* unresolved fields in `parsed` may be `undefined`. Each two-pass
|
|
1442
|
+
* context's phase-two return
|
|
1442
1443
|
* value replaces its own phase-one contribution for the final parse, so
|
|
1443
1444
|
* returning `{}` clears any annotations that context provided during
|
|
1444
1445
|
* phase 1. Single-pass contexts reuse their phase-one snapshot.
|
|
@@ -1558,7 +1559,7 @@ function runWithSyncBody(parser, programName, contexts, args, options) {
|
|
|
1558
1559
|
* {@link SourceContext.id}.
|
|
1559
1560
|
* @throws {TypeError} If any context omits `phase` or declares an invalid
|
|
1560
1561
|
* phase value.
|
|
1561
|
-
* @throws {
|
|
1562
|
+
* @throws {TypeError} If any context returns a Promise or if a context's
|
|
1562
1563
|
* `[Symbol.asyncDispose]` returns a Promise.
|
|
1563
1564
|
* @throws {SuppressedError} If the runner throws and a context's disposal
|
|
1564
1565
|
* also throws. The original error is available via `.suppressed` and the
|
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOpt
|
|
|
9
9
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.cjs";
|
|
10
10
|
import { CombineModes, DocState, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, annotationWrapperRequiresSourceBindingKey, composeWrappedSourceMetadata, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, inheritParentAnnotationsKey, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync, unmatchedNonCliDependencySourceStateMarker } from "./parser.cjs";
|
|
11
11
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
|
|
12
|
-
import { ParserValuePlaceholder, SourceContext } from "./context.cjs";
|
|
12
|
+
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.cjs";
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDependencyValues, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.cjs";
|
|
14
14
|
import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
|
15
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOpt
|
|
|
9
9
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
10
10
|
import { CombineModes, DocState, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, annotationWrapperRequiresSourceBindingKey, composeWrappedSourceMetadata, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, inheritParentAnnotationsKey, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
|
|
11
11
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
12
|
-
import { ParserValuePlaceholder, SourceContext } from "./context.js";
|
|
12
|
+
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.js";
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDependencyValues, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
|
|
14
14
|
import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
|
15
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|