@optique/core 1.0.0-dev.1884 → 1.0.0-dev.1886
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 +68 -648
- package/dist/annotations.d.cts +6 -50
- package/dist/annotations.d.ts +6 -50
- package/dist/annotations.js +69 -647
- package/dist/constructs.cjs +11 -1
- package/dist/constructs.d.cts +6 -3
- package/dist/constructs.d.ts +6 -3
- package/dist/constructs.js +11 -1
- package/dist/context.d.cts +4 -4
- package/dist/context.d.ts +4 -4
- package/dist/facade.cjs +1 -1
- package/dist/facade.js +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/parser.cjs +1 -1
- package/dist/parser.js +2 -2
- package/package.json +1 -1
package/dist/annotations.d.cts
CHANGED
|
@@ -50,32 +50,6 @@ declare const annotationWrapperKey: unique symbol;
|
|
|
50
50
|
* @since 0.10.0
|
|
51
51
|
*/
|
|
52
52
|
type Annotations = Record<symbol, unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* Read-only annotation view returned from parser state.
|
|
55
|
-
*
|
|
56
|
-
* Top-level annotation records are exposed as read-only objects, and supported
|
|
57
|
-
* nested container values (plain objects, arrays, `Map`, `Set`, `Date`,
|
|
58
|
-
* `RegExp`, `URL`, and `URLSearchParams`) are surfaced through protected
|
|
59
|
-
* views that throw on ordinary mutation attempts.
|
|
60
|
-
*
|
|
61
|
-
* Opaque live objects and functions remain reference-preserving.
|
|
62
|
-
*
|
|
63
|
-
* @since 1.0.0
|
|
64
|
-
*/
|
|
65
|
-
type ReadonlyAnnotations = Readonly<Annotations>;
|
|
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;
|
|
79
53
|
/**
|
|
80
54
|
* Options for parse functions.
|
|
81
55
|
* @since 0.10.0
|
|
@@ -84,21 +58,15 @@ interface ParseOptions {
|
|
|
84
58
|
/**
|
|
85
59
|
* Annotations to attach to the parsing session.
|
|
86
60
|
* Parsers can access these annotations via getAnnotations(state).
|
|
87
|
-
*
|
|
88
|
-
* Optique treats these values as immutable input and exposes them back to
|
|
89
|
-
* parsers only through protected read-only views.
|
|
90
61
|
*/
|
|
91
|
-
|
|
62
|
+
annotations?: Annotations;
|
|
92
63
|
}
|
|
93
64
|
/**
|
|
94
65
|
* Extracts annotations from parser state.
|
|
95
66
|
*
|
|
96
67
|
* @param state Parser state that may contain annotations
|
|
97
|
-
* @returns
|
|
98
|
-
* present
|
|
68
|
+
* @returns Annotations object or undefined if no annotations are present
|
|
99
69
|
* @since 0.10.0
|
|
100
|
-
* @since 1.0.0 Returns protected read-only annotation views instead of
|
|
101
|
-
* caller-owned objects.
|
|
102
70
|
*
|
|
103
71
|
* @example
|
|
104
72
|
* ```typescript
|
|
@@ -106,7 +74,7 @@ interface ParseOptions {
|
|
|
106
74
|
* const myData = annotations?.[myDataKey];
|
|
107
75
|
* ```
|
|
108
76
|
*/
|
|
109
|
-
declare function getAnnotations(state: unknown):
|
|
77
|
+
declare function getAnnotations(state: unknown): Annotations | undefined;
|
|
110
78
|
/**
|
|
111
79
|
* Reattaches annotations to a freshly created array state.
|
|
112
80
|
*
|
|
@@ -144,7 +112,7 @@ declare function inheritAnnotations<T>(source: unknown, target: T): T;
|
|
|
144
112
|
* @returns `true` when the record has at least one own symbol key.
|
|
145
113
|
* @internal
|
|
146
114
|
*/
|
|
147
|
-
declare function hasMeaningfulAnnotations(annotations:
|
|
115
|
+
declare function hasMeaningfulAnnotations(annotations: Annotations | null | undefined): annotations is Annotations;
|
|
148
116
|
/**
|
|
149
117
|
* Injects annotations into parser state while preserving state shape.
|
|
150
118
|
*
|
|
@@ -161,19 +129,7 @@ declare function hasMeaningfulAnnotations(annotations: AnnotationInput | null |
|
|
|
161
129
|
* @returns Annotated state.
|
|
162
130
|
* @internal
|
|
163
131
|
*/
|
|
164
|
-
declare function injectAnnotations<TState>(state: TState, annotations:
|
|
165
|
-
/**
|
|
166
|
-
* Injects annotations for a fresh parse run.
|
|
167
|
-
*
|
|
168
|
-
* This path re-wraps protected views from previous runs so stateful container
|
|
169
|
-
* internals remain isolated across parse entrypoints.
|
|
170
|
-
*
|
|
171
|
-
* @param state The parser state to annotate.
|
|
172
|
-
* @param annotations The annotations to inject.
|
|
173
|
-
* @returns Annotated state for the fresh run.
|
|
174
|
-
* @internal
|
|
175
|
-
*/
|
|
176
|
-
declare function injectFreshRunAnnotations<TState>(state: TState, annotations: AnnotationInput): TState;
|
|
132
|
+
declare function injectAnnotations<TState>(state: TState, annotations: Annotations): TState;
|
|
177
133
|
/**
|
|
178
134
|
* Unwraps a primitive-state annotation wrapper injected by Optique internals.
|
|
179
135
|
*
|
|
@@ -193,4 +149,4 @@ declare function unwrapInjectedAnnotationWrapper<T>(value: T): T;
|
|
|
193
149
|
*/
|
|
194
150
|
declare function isInjectedAnnotationWrapper(value: unknown): boolean;
|
|
195
151
|
//#endregion
|
|
196
|
-
export { Annotations, ParseOptions,
|
|
152
|
+
export { Annotations, ParseOptions, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
|
package/dist/annotations.d.ts
CHANGED
|
@@ -50,32 +50,6 @@ declare const annotationWrapperKey: unique symbol;
|
|
|
50
50
|
* @since 0.10.0
|
|
51
51
|
*/
|
|
52
52
|
type Annotations = Record<symbol, unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* Read-only annotation view returned from parser state.
|
|
55
|
-
*
|
|
56
|
-
* Top-level annotation records are exposed as read-only objects, and supported
|
|
57
|
-
* nested container values (plain objects, arrays, `Map`, `Set`, `Date`,
|
|
58
|
-
* `RegExp`, `URL`, and `URLSearchParams`) are surfaced through protected
|
|
59
|
-
* views that throw on ordinary mutation attempts.
|
|
60
|
-
*
|
|
61
|
-
* Opaque live objects and functions remain reference-preserving.
|
|
62
|
-
*
|
|
63
|
-
* @since 1.0.0
|
|
64
|
-
*/
|
|
65
|
-
type ReadonlyAnnotations = Readonly<Annotations>;
|
|
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;
|
|
79
53
|
/**
|
|
80
54
|
* Options for parse functions.
|
|
81
55
|
* @since 0.10.0
|
|
@@ -84,21 +58,15 @@ interface ParseOptions {
|
|
|
84
58
|
/**
|
|
85
59
|
* Annotations to attach to the parsing session.
|
|
86
60
|
* Parsers can access these annotations via getAnnotations(state).
|
|
87
|
-
*
|
|
88
|
-
* Optique treats these values as immutable input and exposes them back to
|
|
89
|
-
* parsers only through protected read-only views.
|
|
90
61
|
*/
|
|
91
|
-
|
|
62
|
+
annotations?: Annotations;
|
|
92
63
|
}
|
|
93
64
|
/**
|
|
94
65
|
* Extracts annotations from parser state.
|
|
95
66
|
*
|
|
96
67
|
* @param state Parser state that may contain annotations
|
|
97
|
-
* @returns
|
|
98
|
-
* present
|
|
68
|
+
* @returns Annotations object or undefined if no annotations are present
|
|
99
69
|
* @since 0.10.0
|
|
100
|
-
* @since 1.0.0 Returns protected read-only annotation views instead of
|
|
101
|
-
* caller-owned objects.
|
|
102
70
|
*
|
|
103
71
|
* @example
|
|
104
72
|
* ```typescript
|
|
@@ -106,7 +74,7 @@ interface ParseOptions {
|
|
|
106
74
|
* const myData = annotations?.[myDataKey];
|
|
107
75
|
* ```
|
|
108
76
|
*/
|
|
109
|
-
declare function getAnnotations(state: unknown):
|
|
77
|
+
declare function getAnnotations(state: unknown): Annotations | undefined;
|
|
110
78
|
/**
|
|
111
79
|
* Reattaches annotations to a freshly created array state.
|
|
112
80
|
*
|
|
@@ -144,7 +112,7 @@ declare function inheritAnnotations<T>(source: unknown, target: T): T;
|
|
|
144
112
|
* @returns `true` when the record has at least one own symbol key.
|
|
145
113
|
* @internal
|
|
146
114
|
*/
|
|
147
|
-
declare function hasMeaningfulAnnotations(annotations:
|
|
115
|
+
declare function hasMeaningfulAnnotations(annotations: Annotations | null | undefined): annotations is Annotations;
|
|
148
116
|
/**
|
|
149
117
|
* Injects annotations into parser state while preserving state shape.
|
|
150
118
|
*
|
|
@@ -161,19 +129,7 @@ declare function hasMeaningfulAnnotations(annotations: AnnotationInput | null |
|
|
|
161
129
|
* @returns Annotated state.
|
|
162
130
|
* @internal
|
|
163
131
|
*/
|
|
164
|
-
declare function injectAnnotations<TState>(state: TState, annotations:
|
|
165
|
-
/**
|
|
166
|
-
* Injects annotations for a fresh parse run.
|
|
167
|
-
*
|
|
168
|
-
* This path re-wraps protected views from previous runs so stateful container
|
|
169
|
-
* internals remain isolated across parse entrypoints.
|
|
170
|
-
*
|
|
171
|
-
* @param state The parser state to annotate.
|
|
172
|
-
* @param annotations The annotations to inject.
|
|
173
|
-
* @returns Annotated state for the fresh run.
|
|
174
|
-
* @internal
|
|
175
|
-
*/
|
|
176
|
-
declare function injectFreshRunAnnotations<TState>(state: TState, annotations: AnnotationInput): TState;
|
|
132
|
+
declare function injectAnnotations<TState>(state: TState, annotations: Annotations): TState;
|
|
177
133
|
/**
|
|
178
134
|
* Unwraps a primitive-state annotation wrapper injected by Optique internals.
|
|
179
135
|
*
|
|
@@ -193,4 +149,4 @@ declare function unwrapInjectedAnnotationWrapper<T>(value: T): T;
|
|
|
193
149
|
*/
|
|
194
150
|
declare function isInjectedAnnotationWrapper(value: unknown): boolean;
|
|
195
151
|
//#endregion
|
|
196
|
-
export { Annotations, ParseOptions,
|
|
152
|
+
export { Annotations, ParseOptions, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
|