@optique/core 1.1.0-dev.2096 → 1.1.0-dev.2148
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/annotation-state.cjs +26 -26
- package/dist/annotation-state.d.cts +133 -1
- package/dist/annotation-state.d.ts +133 -1
- package/dist/annotations.cjs +2 -2
- package/dist/constructs.cjs +141 -73
- package/dist/constructs.js +70 -2
- package/dist/dependency-metadata.cjs +12 -12
- package/dist/dependency-metadata.d.cts +34 -3
- package/dist/dependency-metadata.d.ts +34 -3
- package/dist/dependency-runtime.cjs +37 -13
- package/dist/dependency-runtime.d.cts +197 -2
- package/dist/dependency-runtime.d.ts +197 -2
- package/dist/dependency-runtime.js +22 -1
- package/dist/dependency.cjs +7 -7
- package/dist/displaywidth.d.cts +12 -0
- package/dist/displaywidth.d.ts +12 -0
- package/dist/execution-context.d.cts +23 -0
- package/dist/execution-context.d.ts +23 -0
- package/dist/extension.cjs +14 -14
- package/dist/facade.cjs +46 -36
- package/dist/facade.js +31 -21
- package/dist/index.cjs +22 -21
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/input-trace.d.cts +2 -1
- package/dist/input-trace.d.ts +2 -1
- package/dist/internal/annotations.cjs +3 -0
- package/dist/internal/annotations.d.cts +47 -5
- package/dist/internal/annotations.d.ts +47 -5
- package/dist/internal/annotations.js +1 -1
- package/dist/internal/command-alias.cjs +16 -0
- package/dist/internal/command-alias.js +14 -0
- package/dist/internal/dependency.cjs +131 -0
- package/dist/internal/dependency.d.cts +311 -2
- package/dist/internal/dependency.d.ts +311 -2
- package/dist/internal/dependency.js +119 -1
- package/dist/internal/parser.cjs +35 -13
- package/dist/internal/parser.d.cts +44 -3
- package/dist/internal/parser.d.ts +44 -3
- package/dist/internal/parser.js +28 -6
- package/dist/modifiers.cjs +41 -41
- package/dist/parser.cjs +11 -11
- package/dist/phase2-seed.cjs +2 -2
- package/dist/phase2-seed.d.cts +50 -0
- package/dist/phase2-seed.d.ts +50 -0
- package/dist/primitives.cjs +74 -33
- package/dist/primitives.d.cts +10 -0
- package/dist/primitives.d.ts +10 -0
- package/dist/primitives.js +54 -13
- package/dist/suggestion.cjs +72 -2
- package/dist/suggestion.d.cts +188 -0
- package/dist/suggestion.d.ts +188 -0
- package/dist/suggestion.js +71 -3
- package/dist/usage-internals.cjs +5 -1
- package/dist/usage-internals.js +5 -1
- package/dist/usage.cjs +9 -1
- package/dist/usage.d.cts +14 -0
- package/dist/usage.d.ts +14 -0
- package/dist/usage.js +9 -1
- package/dist/validate.cjs +1 -0
- package/dist/validate.d.cts +99 -0
- package/dist/validate.d.ts +99 -0
- package/dist/validate.js +1 -1
- package/dist/valueparser.cjs +333 -79
- package/dist/valueparser.d.cts +197 -1
- package/dist/valueparser.d.ts +197 -1
- package/dist/valueparser.js +334 -81
- package/package.json +19 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_internal_annotations = require('./internal/annotations.cjs');
|
|
2
|
+
const require_internal_parser = require('./internal/parser.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/annotation-state.ts
|
|
5
5
|
/**
|
|
@@ -41,12 +41,12 @@ function withAnnotationView(state, annotations) {
|
|
|
41
41
|
const target = unwrapAnnotationView(state);
|
|
42
42
|
const view = new Proxy(target, {
|
|
43
43
|
get(target$1, key) {
|
|
44
|
-
if (key ===
|
|
44
|
+
if (key === require_internal_annotations.annotationKey) return annotations;
|
|
45
45
|
const value = Reflect.get(target$1, key, target$1);
|
|
46
46
|
return typeof value === "function" ? value.bind(target$1) : value;
|
|
47
47
|
},
|
|
48
48
|
has(target$1, key) {
|
|
49
|
-
return key ===
|
|
49
|
+
return key === require_internal_annotations.annotationKey || Reflect.has(target$1, key);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
annotationViewTargets.set(view, target);
|
|
@@ -61,7 +61,7 @@ function withAnnotationView(state, annotations) {
|
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
63
|
function normalizeInjectedAnnotationState(state) {
|
|
64
|
-
return
|
|
64
|
+
return require_internal_annotations.unwrapInjectedAnnotationWrapper(state);
|
|
65
65
|
}
|
|
66
66
|
function isNonPlainDelegatedObject(state) {
|
|
67
67
|
const proto = Object.getPrototypeOf(state);
|
|
@@ -70,7 +70,7 @@ function isNonPlainDelegatedObject(state) {
|
|
|
70
70
|
}
|
|
71
71
|
function inheritDelegatedAnnotations(parentState, childState) {
|
|
72
72
|
const target = normalizeDelegatedAnnotationState(childState);
|
|
73
|
-
const delegatedState =
|
|
73
|
+
const delegatedState = require_internal_annotations.inheritAnnotations(parentState, target);
|
|
74
74
|
if (delegatedState !== target) delegatedAnnotationCloneTargets.set(delegatedState, target);
|
|
75
75
|
return delegatedState;
|
|
76
76
|
}
|
|
@@ -96,7 +96,7 @@ function normalizeDelegatedAnnotationState(state) {
|
|
|
96
96
|
* @internal
|
|
97
97
|
*/
|
|
98
98
|
function hasDelegatedAnnotationCarrier(state) {
|
|
99
|
-
return state != null && typeof state === "object" && (
|
|
99
|
+
return state != null && typeof state === "object" && (require_internal_annotations.isInjectedAnnotationWrapper(state) || delegatedAnnotationCloneTargets.has(state) || annotationViewTargets.has(state));
|
|
100
100
|
}
|
|
101
101
|
function getOrCreateNestedNormalizationClone(entry) {
|
|
102
102
|
entry.clone ??= entry.createClone();
|
|
@@ -319,11 +319,11 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
319
319
|
* @internal
|
|
320
320
|
*/
|
|
321
321
|
function getDelegatedAnnotationState(parentState, childState) {
|
|
322
|
-
const annotations =
|
|
322
|
+
const annotations = require_internal_annotations.getAnnotations(parentState);
|
|
323
323
|
if (annotations === void 0) return childState;
|
|
324
|
-
if (
|
|
325
|
-
if (childState == null || typeof childState !== "object") return
|
|
326
|
-
if (
|
|
324
|
+
if (require_internal_annotations.isInjectedAnnotationWrapper(childState)) return require_internal_annotations.injectAnnotations(normalizeInjectedAnnotationState(childState), annotations);
|
|
325
|
+
if (childState == null || typeof childState !== "object") return require_internal_annotations.injectAnnotations(childState, annotations);
|
|
326
|
+
if (require_internal_annotations.getAnnotations(childState) === annotations && (delegatedAnnotationCloneTargets.has(childState) || annotationViewTargets.has(childState))) return childState;
|
|
327
327
|
if (isNonPlainDelegatedObject(childState)) return withAnnotationView(childState, annotations);
|
|
328
328
|
return inheritDelegatedAnnotations(parentState, childState);
|
|
329
329
|
}
|
|
@@ -356,15 +356,15 @@ function isAnnotationWrappedInitialState(state) {
|
|
|
356
356
|
* @internal
|
|
357
357
|
*/
|
|
358
358
|
function getWrappedChildParseState(parentState, childState, parser) {
|
|
359
|
-
const annotations =
|
|
360
|
-
const shouldInheritAnnotations = Reflect.get(parser,
|
|
359
|
+
const annotations = require_internal_annotations.getAnnotations(parentState);
|
|
360
|
+
const shouldInheritAnnotations = Reflect.get(parser, require_internal_parser.inheritParentAnnotationsKey) === true;
|
|
361
361
|
if (childState == null) {
|
|
362
|
-
if (annotations !== void 0 && shouldInheritAnnotations) return
|
|
362
|
+
if (annotations !== void 0 && shouldInheritAnnotations) return require_internal_annotations.injectAnnotations(childState, annotations);
|
|
363
363
|
return childState;
|
|
364
364
|
}
|
|
365
|
-
if (annotations === void 0 || typeof childState !== "object" ||
|
|
366
|
-
const injectedState =
|
|
367
|
-
return
|
|
365
|
+
if (annotations === void 0 || typeof childState !== "object" || require_internal_annotations.getAnnotations(childState) === annotations || !shouldInheritAnnotations) return childState;
|
|
366
|
+
const injectedState = require_internal_annotations.injectAnnotations(childState, annotations);
|
|
367
|
+
return require_internal_annotations.getAnnotations(injectedState) === annotations ? injectedState : childState;
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
370
370
|
* Propagates parent annotations into a child state while preserving the child
|
|
@@ -380,16 +380,16 @@ function getWrappedChildParseState(parentState, childState, parser) {
|
|
|
380
380
|
* @internal
|
|
381
381
|
*/
|
|
382
382
|
function getWrappedChildState(parentState, childState, parser) {
|
|
383
|
-
const annotations =
|
|
384
|
-
const shouldInheritAnnotations = Reflect.get(parser,
|
|
383
|
+
const annotations = require_internal_annotations.getAnnotations(parentState);
|
|
384
|
+
const shouldInheritAnnotations = Reflect.get(parser, require_internal_parser.inheritParentAnnotationsKey) === true;
|
|
385
385
|
if (childState == null) {
|
|
386
|
-
if (annotations !== void 0 && shouldInheritAnnotations) return
|
|
386
|
+
if (annotations !== void 0 && shouldInheritAnnotations) return require_internal_annotations.injectAnnotations(childState, annotations);
|
|
387
387
|
return childState;
|
|
388
388
|
}
|
|
389
|
-
if (annotations === void 0 || typeof childState !== "object" ||
|
|
389
|
+
if (annotations === void 0 || typeof childState !== "object" || require_internal_annotations.getAnnotations(childState) === annotations) return childState;
|
|
390
390
|
if (shouldInheritAnnotations) {
|
|
391
|
-
const injectedState =
|
|
392
|
-
if (
|
|
391
|
+
const injectedState = require_internal_annotations.injectAnnotations(childState, annotations);
|
|
392
|
+
if (require_internal_annotations.getAnnotations(injectedState) === annotations) return injectedState;
|
|
393
393
|
}
|
|
394
394
|
return withAnnotationView(childState, annotations);
|
|
395
395
|
}
|
|
@@ -405,9 +405,9 @@ function getWrappedChildState(parentState, childState, parser) {
|
|
|
405
405
|
* @internal
|
|
406
406
|
*/
|
|
407
407
|
function reconcileObjectChildState(parentState, childState) {
|
|
408
|
-
const annotations =
|
|
409
|
-
if (annotations === void 0 || childState == null || typeof childState !== "object" ||
|
|
410
|
-
return
|
|
408
|
+
const annotations = require_internal_annotations.getAnnotations(parentState);
|
|
409
|
+
if (annotations === void 0 || childState == null || typeof childState !== "object" || require_internal_annotations.getAnnotations(childState) === annotations) return childState;
|
|
410
|
+
return require_internal_annotations.inheritAnnotations(parentState, childState);
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
//#endregion
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { Annotations } from "./internal/annotations.cjs";
|
|
2
|
+
import { Mode, Parser } from "./internal/parser.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/annotation-state.d.ts
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Shared targets for annotation-view proxies.
|
|
8
|
+
*
|
|
9
|
+
* Maps a proxy returned by {@link withAnnotationView} back to its original
|
|
10
|
+
* target object.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare const annotationViewTargets: WeakMap<object, object>;
|
|
15
|
+
/**
|
|
16
|
+
* Unwraps an annotation-view proxy to its original target object.
|
|
17
|
+
*
|
|
18
|
+
* @param value The candidate value that may be an annotation-view proxy.
|
|
19
|
+
* @returns The original target object when the input is a tracked
|
|
20
|
+
* annotation-view proxy; otherwise the input value unchanged.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
declare function unwrapAnnotationView<T>(value: T): T;
|
|
5
24
|
/**
|
|
6
25
|
* Creates an annotation-aware proxy without changing the target shape.
|
|
7
26
|
*
|
|
@@ -20,5 +39,118 @@ declare function withAnnotationView<T extends object>(state: T, annotations: Ann
|
|
|
20
39
|
* annotation wrapper; otherwise the original input unchanged.
|
|
21
40
|
* @internal
|
|
22
41
|
*/
|
|
42
|
+
declare function normalizeInjectedAnnotationState<T>(state: T): T;
|
|
43
|
+
/**
|
|
44
|
+
* Removes Optique's internal annotation carriers from a delegated state.
|
|
45
|
+
*
|
|
46
|
+
* This unwraps primitive-state annotation wrappers, tracked delegated clones,
|
|
47
|
+
* and annotation-view proxies used for object states.
|
|
48
|
+
*
|
|
49
|
+
* @param state The delegated state to normalize.
|
|
50
|
+
* @returns The original underlying state value.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
declare function normalizeDelegatedAnnotationState<T>(state: T): T;
|
|
54
|
+
/**
|
|
55
|
+
* Returns whether the given state uses an internal delegated annotation carrier.
|
|
56
|
+
*
|
|
57
|
+
* @param state The candidate state to inspect.
|
|
58
|
+
* @returns `true` when the state is an injected primitive wrapper, a tracked
|
|
59
|
+
* delegated clone, or an annotation-view proxy.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
declare function hasDelegatedAnnotationCarrier(state: unknown): boolean;
|
|
63
|
+
interface NestedNormalizationEntry {
|
|
64
|
+
clone: object | undefined;
|
|
65
|
+
createClone: () => object;
|
|
66
|
+
finalized: boolean;
|
|
67
|
+
result: object;
|
|
68
|
+
preferCloneOnRead: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Recursively removes delegated annotation carriers from plain-object, array,
|
|
72
|
+
* and built-in collection structures.
|
|
73
|
+
*
|
|
74
|
+
* Nested plain objects, arrays, Maps, and Sets are shallow-cloned only when a
|
|
75
|
+
* delegated carrier is found below them. Other non-plain objects are unwrapped
|
|
76
|
+
* at the top level and then preserved as-is to avoid mutating or reconstructing
|
|
77
|
+
* class instances.
|
|
78
|
+
*
|
|
79
|
+
* @param value The candidate value to normalize.
|
|
80
|
+
* @param seen Tracks already-normalized objects so cyclic values keep their
|
|
81
|
+
* shape.
|
|
82
|
+
* @returns The original value when no delegated carriers are present, or a
|
|
83
|
+
* normalized clone with delegated carriers removed.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
declare function normalizeNestedDelegatedAnnotationState<T>(value: T, seen?: WeakMap<object, NestedNormalizationEntry>, preferPendingClone?: boolean): T;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a short-lived delegated state that exposes the parent's annotations
|
|
89
|
+
* regardless of the child state's runtime shape.
|
|
90
|
+
*
|
|
91
|
+
* Primitive and nullish states use `injectAnnotations()`, clone-based object
|
|
92
|
+
* delegation is tracked so it can be normalized back out later, and non-plain
|
|
93
|
+
* objects use an annotation-view proxy so class invariants such as private
|
|
94
|
+
* fields remain intact.
|
|
95
|
+
*
|
|
96
|
+
* @param parentState The state carrying the annotations to delegate.
|
|
97
|
+
* @param childState The child state that should observe those annotations.
|
|
98
|
+
* @returns A delegated child state that exposes the parent's annotations.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
declare function getDelegatedAnnotationState<TState>(parentState: unknown, childState: TState): TState;
|
|
102
|
+
/**
|
|
103
|
+
* Returns whether a state is still at the initial sentinel after normalizing
|
|
104
|
+
* Optique's injected annotation wrapper.
|
|
105
|
+
*
|
|
106
|
+
* This treats plain `undefined` and annotation-wrapped `undefined` the same.
|
|
107
|
+
*
|
|
108
|
+
* @param state The parser state to inspect.
|
|
109
|
+
* @returns `true` when the normalized state is still `undefined`;
|
|
110
|
+
* otherwise `false`.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
declare function isAnnotationWrappedInitialState(state: unknown): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Propagates parent annotations into a child parse state when the child parser
|
|
116
|
+
* explicitly opts into parent annotation inheritance.
|
|
117
|
+
*
|
|
118
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
119
|
+
* @param childState The child parse state that may receive inherited
|
|
120
|
+
* annotations.
|
|
121
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
122
|
+
* wrapper injection is allowed.
|
|
123
|
+
* @returns The original child state when no injection is needed or possible,
|
|
124
|
+
* or an annotation-injected child state that preserves the original
|
|
125
|
+
* sentinel or object shape when inheritance applies.
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
declare function getWrappedChildParseState<TState>(parentState: unknown, childState: TState, parser: Parser<Mode, unknown, unknown>): TState;
|
|
129
|
+
/**
|
|
130
|
+
* Propagates parent annotations into a child state while preserving the child
|
|
131
|
+
* state's shape for parsers that do not opt into full wrapper injection.
|
|
132
|
+
*
|
|
133
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
134
|
+
* @param childState The child state that may receive inherited annotations.
|
|
135
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
136
|
+
* full wrapper injection is allowed.
|
|
137
|
+
* @returns The original child state when no wrapping is needed, an
|
|
138
|
+
* annotation-injected child state when inheritance applies, or an
|
|
139
|
+
* annotation-view proxy that preserves the child's object shape.
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
declare function getWrappedChildState<TState>(parentState: unknown, childState: TState, parser: Parser<Mode, unknown, unknown>): TState;
|
|
143
|
+
/**
|
|
144
|
+
* Reconciles object-owned child state with parent annotations using the same
|
|
145
|
+
* shared object-state inheritance rule across parser families.
|
|
146
|
+
*
|
|
147
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
148
|
+
* @param childState The object-owned child state to reconcile.
|
|
149
|
+
* @returns The original child state when no reconciliation is needed, or a
|
|
150
|
+
* child state with inherited annotations when the object state should
|
|
151
|
+
* carry the parent's annotations.
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
declare function reconcileObjectChildState<TState>(parentState: unknown, childState: TState): TState;
|
|
23
155
|
//#endregion
|
|
24
|
-
export { withAnnotationView };
|
|
156
|
+
export { annotationViewTargets, getDelegatedAnnotationState, getWrappedChildParseState, getWrappedChildState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeInjectedAnnotationState, normalizeNestedDelegatedAnnotationState, reconcileObjectChildState, unwrapAnnotationView, withAnnotationView };
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { Annotations } from "./internal/annotations.js";
|
|
2
|
+
import { Mode, Parser } from "./internal/parser.js";
|
|
2
3
|
|
|
3
4
|
//#region src/annotation-state.d.ts
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Shared targets for annotation-view proxies.
|
|
8
|
+
*
|
|
9
|
+
* Maps a proxy returned by {@link withAnnotationView} back to its original
|
|
10
|
+
* target object.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
declare const annotationViewTargets: WeakMap<object, object>;
|
|
15
|
+
/**
|
|
16
|
+
* Unwraps an annotation-view proxy to its original target object.
|
|
17
|
+
*
|
|
18
|
+
* @param value The candidate value that may be an annotation-view proxy.
|
|
19
|
+
* @returns The original target object when the input is a tracked
|
|
20
|
+
* annotation-view proxy; otherwise the input value unchanged.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
declare function unwrapAnnotationView<T>(value: T): T;
|
|
5
24
|
/**
|
|
6
25
|
* Creates an annotation-aware proxy without changing the target shape.
|
|
7
26
|
*
|
|
@@ -20,5 +39,118 @@ declare function withAnnotationView<T extends object>(state: T, annotations: Ann
|
|
|
20
39
|
* annotation wrapper; otherwise the original input unchanged.
|
|
21
40
|
* @internal
|
|
22
41
|
*/
|
|
42
|
+
declare function normalizeInjectedAnnotationState<T>(state: T): T;
|
|
43
|
+
/**
|
|
44
|
+
* Removes Optique's internal annotation carriers from a delegated state.
|
|
45
|
+
*
|
|
46
|
+
* This unwraps primitive-state annotation wrappers, tracked delegated clones,
|
|
47
|
+
* and annotation-view proxies used for object states.
|
|
48
|
+
*
|
|
49
|
+
* @param state The delegated state to normalize.
|
|
50
|
+
* @returns The original underlying state value.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
declare function normalizeDelegatedAnnotationState<T>(state: T): T;
|
|
54
|
+
/**
|
|
55
|
+
* Returns whether the given state uses an internal delegated annotation carrier.
|
|
56
|
+
*
|
|
57
|
+
* @param state The candidate state to inspect.
|
|
58
|
+
* @returns `true` when the state is an injected primitive wrapper, a tracked
|
|
59
|
+
* delegated clone, or an annotation-view proxy.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
declare function hasDelegatedAnnotationCarrier(state: unknown): boolean;
|
|
63
|
+
interface NestedNormalizationEntry {
|
|
64
|
+
clone: object | undefined;
|
|
65
|
+
createClone: () => object;
|
|
66
|
+
finalized: boolean;
|
|
67
|
+
result: object;
|
|
68
|
+
preferCloneOnRead: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Recursively removes delegated annotation carriers from plain-object, array,
|
|
72
|
+
* and built-in collection structures.
|
|
73
|
+
*
|
|
74
|
+
* Nested plain objects, arrays, Maps, and Sets are shallow-cloned only when a
|
|
75
|
+
* delegated carrier is found below them. Other non-plain objects are unwrapped
|
|
76
|
+
* at the top level and then preserved as-is to avoid mutating or reconstructing
|
|
77
|
+
* class instances.
|
|
78
|
+
*
|
|
79
|
+
* @param value The candidate value to normalize.
|
|
80
|
+
* @param seen Tracks already-normalized objects so cyclic values keep their
|
|
81
|
+
* shape.
|
|
82
|
+
* @returns The original value when no delegated carriers are present, or a
|
|
83
|
+
* normalized clone with delegated carriers removed.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
declare function normalizeNestedDelegatedAnnotationState<T>(value: T, seen?: WeakMap<object, NestedNormalizationEntry>, preferPendingClone?: boolean): T;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a short-lived delegated state that exposes the parent's annotations
|
|
89
|
+
* regardless of the child state's runtime shape.
|
|
90
|
+
*
|
|
91
|
+
* Primitive and nullish states use `injectAnnotations()`, clone-based object
|
|
92
|
+
* delegation is tracked so it can be normalized back out later, and non-plain
|
|
93
|
+
* objects use an annotation-view proxy so class invariants such as private
|
|
94
|
+
* fields remain intact.
|
|
95
|
+
*
|
|
96
|
+
* @param parentState The state carrying the annotations to delegate.
|
|
97
|
+
* @param childState The child state that should observe those annotations.
|
|
98
|
+
* @returns A delegated child state that exposes the parent's annotations.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
declare function getDelegatedAnnotationState<TState>(parentState: unknown, childState: TState): TState;
|
|
102
|
+
/**
|
|
103
|
+
* Returns whether a state is still at the initial sentinel after normalizing
|
|
104
|
+
* Optique's injected annotation wrapper.
|
|
105
|
+
*
|
|
106
|
+
* This treats plain `undefined` and annotation-wrapped `undefined` the same.
|
|
107
|
+
*
|
|
108
|
+
* @param state The parser state to inspect.
|
|
109
|
+
* @returns `true` when the normalized state is still `undefined`;
|
|
110
|
+
* otherwise `false`.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
declare function isAnnotationWrappedInitialState(state: unknown): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Propagates parent annotations into a child parse state when the child parser
|
|
116
|
+
* explicitly opts into parent annotation inheritance.
|
|
117
|
+
*
|
|
118
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
119
|
+
* @param childState The child parse state that may receive inherited
|
|
120
|
+
* annotations.
|
|
121
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
122
|
+
* wrapper injection is allowed.
|
|
123
|
+
* @returns The original child state when no injection is needed or possible,
|
|
124
|
+
* or an annotation-injected child state that preserves the original
|
|
125
|
+
* sentinel or object shape when inheritance applies.
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
declare function getWrappedChildParseState<TState>(parentState: unknown, childState: TState, parser: Parser<Mode, unknown, unknown>): TState;
|
|
129
|
+
/**
|
|
130
|
+
* Propagates parent annotations into a child state while preserving the child
|
|
131
|
+
* state's shape for parsers that do not opt into full wrapper injection.
|
|
132
|
+
*
|
|
133
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
134
|
+
* @param childState The child state that may receive inherited annotations.
|
|
135
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
136
|
+
* full wrapper injection is allowed.
|
|
137
|
+
* @returns The original child state when no wrapping is needed, an
|
|
138
|
+
* annotation-injected child state when inheritance applies, or an
|
|
139
|
+
* annotation-view proxy that preserves the child's object shape.
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
declare function getWrappedChildState<TState>(parentState: unknown, childState: TState, parser: Parser<Mode, unknown, unknown>): TState;
|
|
143
|
+
/**
|
|
144
|
+
* Reconciles object-owned child state with parent annotations using the same
|
|
145
|
+
* shared object-state inheritance rule across parser families.
|
|
146
|
+
*
|
|
147
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
148
|
+
* @param childState The object-owned child state to reconcile.
|
|
149
|
+
* @returns The original child state when no reconciliation is needed, or a
|
|
150
|
+
* child state with inherited annotations when the object state should
|
|
151
|
+
* carry the parent's annotations.
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
declare function reconcileObjectChildState<TState>(parentState: unknown, childState: TState): TState;
|
|
23
155
|
//#endregion
|
|
24
|
-
export { withAnnotationView };
|
|
156
|
+
export { annotationViewTargets, getDelegatedAnnotationState, getWrappedChildParseState, getWrappedChildState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeInjectedAnnotationState, normalizeNestedDelegatedAnnotationState, reconcileObjectChildState, unwrapAnnotationView, withAnnotationView };
|
package/dist/annotations.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_internal_annotations = require('./internal/annotations.cjs');
|
|
2
2
|
|
|
3
|
-
exports.getAnnotations =
|
|
3
|
+
exports.getAnnotations = require_internal_annotations.getAnnotations;
|