@optique/core 1.0.0-dev.1793 → 1.0.0-dev.1797
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 +36 -0
- package/dist/annotation-state.js +36 -0
- package/package.json +1 -1
|
@@ -5,12 +5,18 @@ const require_parser = require('./parser.cjs');
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared targets for annotation-view proxies.
|
|
7
7
|
*
|
|
8
|
+
* Maps a proxy returned by {@link withAnnotationView} back to its original
|
|
9
|
+
* target object.
|
|
10
|
+
*
|
|
8
11
|
* @internal
|
|
9
12
|
*/
|
|
10
13
|
const annotationViewTargets = /* @__PURE__ */ new WeakMap();
|
|
11
14
|
/**
|
|
12
15
|
* Unwraps an annotation-view proxy to its original target object.
|
|
13
16
|
*
|
|
17
|
+
* @param value The candidate value that may be an annotation-view proxy.
|
|
18
|
+
* @returns The original target object when the input is a tracked
|
|
19
|
+
* annotation-view proxy; otherwise the input value unchanged.
|
|
14
20
|
* @internal
|
|
15
21
|
*/
|
|
16
22
|
function unwrapAnnotationView(value) {
|
|
@@ -20,6 +26,10 @@ function unwrapAnnotationView(value) {
|
|
|
20
26
|
/**
|
|
21
27
|
* Creates a proxy that exposes annotations without changing the target shape.
|
|
22
28
|
*
|
|
29
|
+
* @param state The object state to expose through an annotation-aware view.
|
|
30
|
+
* @param annotations The annotations to surface through the proxy.
|
|
31
|
+
* @returns A proxy over the unwrapped target object that reports the supplied
|
|
32
|
+
* annotations while preserving the target's structural behavior.
|
|
23
33
|
* @internal
|
|
24
34
|
*/
|
|
25
35
|
function withAnnotationView(state, annotations) {
|
|
@@ -40,6 +50,9 @@ function withAnnotationView(state, annotations) {
|
|
|
40
50
|
/**
|
|
41
51
|
* Removes Optique's internal primitive-state annotation wrapper when present.
|
|
42
52
|
*
|
|
53
|
+
* @param state The parser state to normalize.
|
|
54
|
+
* @returns The wrapped primitive sentinel when the input is an injected
|
|
55
|
+
* annotation wrapper; otherwise the original input unchanged.
|
|
43
56
|
* @internal
|
|
44
57
|
*/
|
|
45
58
|
function normalizeInjectedAnnotationState(state) {
|
|
@@ -51,6 +64,9 @@ function normalizeInjectedAnnotationState(state) {
|
|
|
51
64
|
*
|
|
52
65
|
* This treats plain `undefined` and annotation-wrapped `undefined` the same.
|
|
53
66
|
*
|
|
67
|
+
* @param state The parser state to inspect.
|
|
68
|
+
* @returns `true` when the normalized state is still `undefined`;
|
|
69
|
+
* otherwise `false`.
|
|
54
70
|
* @internal
|
|
55
71
|
*/
|
|
56
72
|
function isAnnotationWrappedInitialState(state) {
|
|
@@ -60,6 +76,14 @@ function isAnnotationWrappedInitialState(state) {
|
|
|
60
76
|
* Propagates parent annotations into a child parse state when the child parser
|
|
61
77
|
* explicitly opts into parent annotation inheritance.
|
|
62
78
|
*
|
|
79
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
80
|
+
* @param childState The child parse state that may receive inherited
|
|
81
|
+
* annotations.
|
|
82
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
83
|
+
* wrapper injection is allowed.
|
|
84
|
+
* @returns The original child state when no injection is needed or possible,
|
|
85
|
+
* or an annotation-injected child state that preserves the original
|
|
86
|
+
* sentinel or object shape when inheritance applies.
|
|
63
87
|
* @internal
|
|
64
88
|
*/
|
|
65
89
|
function getWrappedChildParseState(parentState, childState, parser) {
|
|
@@ -77,6 +101,13 @@ function getWrappedChildParseState(parentState, childState, parser) {
|
|
|
77
101
|
* Propagates parent annotations into a child state while preserving the child
|
|
78
102
|
* state's shape for parsers that do not opt into full wrapper injection.
|
|
79
103
|
*
|
|
104
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
105
|
+
* @param childState The child state that may receive inherited annotations.
|
|
106
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
107
|
+
* full wrapper injection is allowed.
|
|
108
|
+
* @returns The original child state when no wrapping is needed, an
|
|
109
|
+
* annotation-injected child state when inheritance applies, or an
|
|
110
|
+
* annotation-view proxy that preserves the child's object shape.
|
|
80
111
|
* @internal
|
|
81
112
|
*/
|
|
82
113
|
function getWrappedChildState(parentState, childState, parser) {
|
|
@@ -97,6 +128,11 @@ function getWrappedChildState(parentState, childState, parser) {
|
|
|
97
128
|
* Reconciles object-owned child state with parent annotations using the same
|
|
98
129
|
* shared object-state inheritance rule across parser families.
|
|
99
130
|
*
|
|
131
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
132
|
+
* @param childState The object-owned child state to reconcile.
|
|
133
|
+
* @returns The original child state when no reconciliation is needed, or a
|
|
134
|
+
* child state with inherited annotations when the object state should
|
|
135
|
+
* carry the parent's annotations.
|
|
100
136
|
* @internal
|
|
101
137
|
*/
|
|
102
138
|
function reconcileObjectChildState(parentState, childState) {
|
package/dist/annotation-state.js
CHANGED
|
@@ -5,12 +5,18 @@ import { inheritParentAnnotationsKey } from "./parser.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared targets for annotation-view proxies.
|
|
7
7
|
*
|
|
8
|
+
* Maps a proxy returned by {@link withAnnotationView} back to its original
|
|
9
|
+
* target object.
|
|
10
|
+
*
|
|
8
11
|
* @internal
|
|
9
12
|
*/
|
|
10
13
|
const annotationViewTargets = /* @__PURE__ */ new WeakMap();
|
|
11
14
|
/**
|
|
12
15
|
* Unwraps an annotation-view proxy to its original target object.
|
|
13
16
|
*
|
|
17
|
+
* @param value The candidate value that may be an annotation-view proxy.
|
|
18
|
+
* @returns The original target object when the input is a tracked
|
|
19
|
+
* annotation-view proxy; otherwise the input value unchanged.
|
|
14
20
|
* @internal
|
|
15
21
|
*/
|
|
16
22
|
function unwrapAnnotationView(value) {
|
|
@@ -20,6 +26,10 @@ function unwrapAnnotationView(value) {
|
|
|
20
26
|
/**
|
|
21
27
|
* Creates a proxy that exposes annotations without changing the target shape.
|
|
22
28
|
*
|
|
29
|
+
* @param state The object state to expose through an annotation-aware view.
|
|
30
|
+
* @param annotations The annotations to surface through the proxy.
|
|
31
|
+
* @returns A proxy over the unwrapped target object that reports the supplied
|
|
32
|
+
* annotations while preserving the target's structural behavior.
|
|
23
33
|
* @internal
|
|
24
34
|
*/
|
|
25
35
|
function withAnnotationView(state, annotations) {
|
|
@@ -40,6 +50,9 @@ function withAnnotationView(state, annotations) {
|
|
|
40
50
|
/**
|
|
41
51
|
* Removes Optique's internal primitive-state annotation wrapper when present.
|
|
42
52
|
*
|
|
53
|
+
* @param state The parser state to normalize.
|
|
54
|
+
* @returns The wrapped primitive sentinel when the input is an injected
|
|
55
|
+
* annotation wrapper; otherwise the original input unchanged.
|
|
43
56
|
* @internal
|
|
44
57
|
*/
|
|
45
58
|
function normalizeInjectedAnnotationState(state) {
|
|
@@ -51,6 +64,9 @@ function normalizeInjectedAnnotationState(state) {
|
|
|
51
64
|
*
|
|
52
65
|
* This treats plain `undefined` and annotation-wrapped `undefined` the same.
|
|
53
66
|
*
|
|
67
|
+
* @param state The parser state to inspect.
|
|
68
|
+
* @returns `true` when the normalized state is still `undefined`;
|
|
69
|
+
* otherwise `false`.
|
|
54
70
|
* @internal
|
|
55
71
|
*/
|
|
56
72
|
function isAnnotationWrappedInitialState(state) {
|
|
@@ -60,6 +76,14 @@ function isAnnotationWrappedInitialState(state) {
|
|
|
60
76
|
* Propagates parent annotations into a child parse state when the child parser
|
|
61
77
|
* explicitly opts into parent annotation inheritance.
|
|
62
78
|
*
|
|
79
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
80
|
+
* @param childState The child parse state that may receive inherited
|
|
81
|
+
* annotations.
|
|
82
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
83
|
+
* wrapper injection is allowed.
|
|
84
|
+
* @returns The original child state when no injection is needed or possible,
|
|
85
|
+
* or an annotation-injected child state that preserves the original
|
|
86
|
+
* sentinel or object shape when inheritance applies.
|
|
63
87
|
* @internal
|
|
64
88
|
*/
|
|
65
89
|
function getWrappedChildParseState(parentState, childState, parser) {
|
|
@@ -77,6 +101,13 @@ function getWrappedChildParseState(parentState, childState, parser) {
|
|
|
77
101
|
* Propagates parent annotations into a child state while preserving the child
|
|
78
102
|
* state's shape for parsers that do not opt into full wrapper injection.
|
|
79
103
|
*
|
|
104
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
105
|
+
* @param childState The child state that may receive inherited annotations.
|
|
106
|
+
* @param parser The child parser whose inheritance marker controls whether
|
|
107
|
+
* full wrapper injection is allowed.
|
|
108
|
+
* @returns The original child state when no wrapping is needed, an
|
|
109
|
+
* annotation-injected child state when inheritance applies, or an
|
|
110
|
+
* annotation-view proxy that preserves the child's object shape.
|
|
80
111
|
* @internal
|
|
81
112
|
*/
|
|
82
113
|
function getWrappedChildState(parentState, childState, parser) {
|
|
@@ -97,6 +128,11 @@ function getWrappedChildState(parentState, childState, parser) {
|
|
|
97
128
|
* Reconciles object-owned child state with parent annotations using the same
|
|
98
129
|
* shared object-state inheritance rule across parser families.
|
|
99
130
|
*
|
|
131
|
+
* @param parentState The parent parser state that may carry annotations.
|
|
132
|
+
* @param childState The object-owned child state to reconcile.
|
|
133
|
+
* @returns The original child state when no reconciliation is needed, or a
|
|
134
|
+
* child state with inherited annotations when the object state should
|
|
135
|
+
* carry the parent's annotations.
|
|
100
136
|
* @internal
|
|
101
137
|
*/
|
|
102
138
|
function reconcileObjectChildState(parentState, childState) {
|