@optique/core 1.0.0-dev.1854 → 1.0.0-dev.1856
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/annotations.cjs +15 -0
- package/dist/annotations.d.cts +13 -1
- package/dist/annotations.d.ts +13 -1
- package/dist/annotations.js +15 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.js +2 -2
- package/package.json +1 -1
package/dist/annotations.cjs
CHANGED
|
@@ -361,6 +361,20 @@ function protectAnnotationValue(value, context) {
|
|
|
361
361
|
return value;
|
|
362
362
|
}
|
|
363
363
|
/**
|
|
364
|
+
* Normalizes annotation input for a fresh parse run.
|
|
365
|
+
*
|
|
366
|
+
* When callers feed a protected annotation view returned by `getAnnotations()`
|
|
367
|
+
* back into a new parse entrypoint, Optique unwraps it to the caller-owned
|
|
368
|
+
* record first so the new run gets its own protected views.
|
|
369
|
+
*
|
|
370
|
+
* @param annotations The caller-supplied annotations input.
|
|
371
|
+
* @returns The raw annotation record to inject for the new run.
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
function normalizeRunAnnotationInput(annotations) {
|
|
375
|
+
return isProtectedAnnotationView(annotations) ? unwrapProtectedAnnotationTarget(annotations) : annotations;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
364
378
|
* Extracts annotations from parser state.
|
|
365
379
|
*
|
|
366
380
|
* @param state Parser state that may contain annotations
|
|
@@ -594,4 +608,5 @@ exports.hasMeaningfulAnnotations = hasMeaningfulAnnotations;
|
|
|
594
608
|
exports.inheritAnnotations = inheritAnnotations;
|
|
595
609
|
exports.injectAnnotations = injectAnnotations;
|
|
596
610
|
exports.isInjectedAnnotationWrapper = isInjectedAnnotationWrapper;
|
|
611
|
+
exports.normalizeRunAnnotationInput = normalizeRunAnnotationInput;
|
|
597
612
|
exports.unwrapInjectedAnnotationWrapper = unwrapInjectedAnnotationWrapper;
|
package/dist/annotations.d.cts
CHANGED
|
@@ -64,6 +64,18 @@ type Annotations = Record<symbol, unknown>;
|
|
|
64
64
|
*/
|
|
65
65
|
type ReadonlyAnnotations = Readonly<Annotations>;
|
|
66
66
|
type AnnotationInput = Annotations | ReadonlyAnnotations;
|
|
67
|
+
/**
|
|
68
|
+
* Normalizes annotation input for a fresh parse run.
|
|
69
|
+
*
|
|
70
|
+
* When callers feed a protected annotation view returned by `getAnnotations()`
|
|
71
|
+
* back into a new parse entrypoint, Optique unwraps it to the caller-owned
|
|
72
|
+
* record first so the new run gets its own protected views.
|
|
73
|
+
*
|
|
74
|
+
* @param annotations The caller-supplied annotations input.
|
|
75
|
+
* @returns The raw annotation record to inject for the new run.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
declare function normalizeRunAnnotationInput(annotations: AnnotationInput): AnnotationInput;
|
|
67
79
|
/**
|
|
68
80
|
* Options for parse functions.
|
|
69
81
|
* @since 0.10.0
|
|
@@ -169,4 +181,4 @@ declare function unwrapInjectedAnnotationWrapper<T>(value: T): T;
|
|
|
169
181
|
*/
|
|
170
182
|
declare function isInjectedAnnotationWrapper(value: unknown): boolean;
|
|
171
183
|
//#endregion
|
|
172
|
-
export { Annotations, ParseOptions, ReadonlyAnnotations, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
|
|
184
|
+
export { Annotations, ParseOptions, ReadonlyAnnotations, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, normalizeRunAnnotationInput, unwrapInjectedAnnotationWrapper };
|
package/dist/annotations.d.ts
CHANGED
|
@@ -64,6 +64,18 @@ type Annotations = Record<symbol, unknown>;
|
|
|
64
64
|
*/
|
|
65
65
|
type ReadonlyAnnotations = Readonly<Annotations>;
|
|
66
66
|
type AnnotationInput = Annotations | ReadonlyAnnotations;
|
|
67
|
+
/**
|
|
68
|
+
* Normalizes annotation input for a fresh parse run.
|
|
69
|
+
*
|
|
70
|
+
* When callers feed a protected annotation view returned by `getAnnotations()`
|
|
71
|
+
* back into a new parse entrypoint, Optique unwraps it to the caller-owned
|
|
72
|
+
* record first so the new run gets its own protected views.
|
|
73
|
+
*
|
|
74
|
+
* @param annotations The caller-supplied annotations input.
|
|
75
|
+
* @returns The raw annotation record to inject for the new run.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
declare function normalizeRunAnnotationInput(annotations: AnnotationInput): AnnotationInput;
|
|
67
79
|
/**
|
|
68
80
|
* Options for parse functions.
|
|
69
81
|
* @since 0.10.0
|
|
@@ -169,4 +181,4 @@ declare function unwrapInjectedAnnotationWrapper<T>(value: T): T;
|
|
|
169
181
|
*/
|
|
170
182
|
declare function isInjectedAnnotationWrapper(value: unknown): boolean;
|
|
171
183
|
//#endregion
|
|
172
|
-
export { Annotations, ParseOptions, ReadonlyAnnotations, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
|
|
184
|
+
export { Annotations, ParseOptions, ReadonlyAnnotations, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, normalizeRunAnnotationInput, unwrapInjectedAnnotationWrapper };
|
package/dist/annotations.js
CHANGED
|
@@ -360,6 +360,20 @@ function protectAnnotationValue(value, context) {
|
|
|
360
360
|
return value;
|
|
361
361
|
}
|
|
362
362
|
/**
|
|
363
|
+
* Normalizes annotation input for a fresh parse run.
|
|
364
|
+
*
|
|
365
|
+
* When callers feed a protected annotation view returned by `getAnnotations()`
|
|
366
|
+
* back into a new parse entrypoint, Optique unwraps it to the caller-owned
|
|
367
|
+
* record first so the new run gets its own protected views.
|
|
368
|
+
*
|
|
369
|
+
* @param annotations The caller-supplied annotations input.
|
|
370
|
+
* @returns The raw annotation record to inject for the new run.
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
function normalizeRunAnnotationInput(annotations) {
|
|
374
|
+
return isProtectedAnnotationView(annotations) ? unwrapProtectedAnnotationTarget(annotations) : annotations;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
363
377
|
* Extracts annotations from parser state.
|
|
364
378
|
*
|
|
365
379
|
* @param state Parser state that may contain annotations
|
|
@@ -583,4 +597,4 @@ function isInjectedAnnotationWrapper(value) {
|
|
|
583
597
|
}
|
|
584
598
|
|
|
585
599
|
//#endregion
|
|
586
|
-
export { annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
|
|
600
|
+
export { annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, normalizeRunAnnotationInput, unwrapInjectedAnnotationWrapper };
|
package/dist/parser.cjs
CHANGED
|
@@ -69,7 +69,7 @@ function createParserContext(frame, exec) {
|
|
|
69
69
|
function injectAnnotationsIntoState(state, options) {
|
|
70
70
|
const annotations = options?.annotations;
|
|
71
71
|
if (!require_annotations.hasMeaningfulAnnotations(annotations)) return state;
|
|
72
|
-
return require_annotations.injectAnnotations(state, annotations);
|
|
72
|
+
return require_annotations.injectAnnotations(state, require_annotations.normalizeRunAnnotationInput(annotations));
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Parses an array of command-line arguments using the provided combined parser.
|
package/dist/parser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasMeaningfulAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
|
|
1
|
+
import { hasMeaningfulAnnotations, injectAnnotations, isInjectedAnnotationWrapper, normalizeRunAnnotationInput, unwrapInjectedAnnotationWrapper } from "./annotations.js";
|
|
2
2
|
import { cloneMessage, message } from "./message.js";
|
|
3
3
|
import { cloneUsage, normalizeUsage } from "./usage.js";
|
|
4
4
|
import { cloneDocEntry, isDocEntryHidden } from "./doc.js";
|
|
@@ -69,7 +69,7 @@ function createParserContext(frame, exec) {
|
|
|
69
69
|
function injectAnnotationsIntoState(state, options) {
|
|
70
70
|
const annotations = options?.annotations;
|
|
71
71
|
if (!hasMeaningfulAnnotations(annotations)) return state;
|
|
72
|
-
return injectAnnotations(state, annotations);
|
|
72
|
+
return injectAnnotations(state, normalizeRunAnnotationInput(annotations));
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Parses an array of command-line arguments using the provided combined parser.
|