@optique/core 1.0.0-dev.1901 → 1.0.0-dev.1970

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.
Files changed (77) hide show
  1. package/dist/annotation-state.cjs +115 -60
  2. package/dist/annotation-state.d.cts +24 -0
  3. package/dist/annotation-state.d.ts +24 -0
  4. package/dist/annotation-state.js +114 -60
  5. package/dist/annotations.cjs +2 -267
  6. package/dist/annotations.d.cts +2 -152
  7. package/dist/annotations.d.ts +2 -152
  8. package/dist/annotations.js +2 -256
  9. package/dist/completion.d.cts +1 -1
  10. package/dist/completion.d.ts +1 -1
  11. package/dist/constructs.cjs +206 -238
  12. package/dist/constructs.d.cts +1 -1
  13. package/dist/constructs.d.ts +1 -1
  14. package/dist/constructs.js +96 -128
  15. package/dist/context.d.cts +1 -1
  16. package/dist/context.d.ts +1 -1
  17. package/dist/dependency-metadata.cjs +1 -1
  18. package/dist/dependency-metadata.d.cts +1 -1
  19. package/dist/dependency-metadata.d.ts +1 -1
  20. package/dist/dependency-metadata.js +1 -1
  21. package/dist/dependency-runtime.cjs +2 -2
  22. package/dist/dependency-runtime.js +2 -2
  23. package/dist/dependency.cjs +7 -1111
  24. package/dist/dependency.d.cts +2 -838
  25. package/dist/dependency.d.ts +2 -838
  26. package/dist/dependency.js +2 -1078
  27. package/dist/execution-context.cjs +56 -0
  28. package/dist/execution-context.js +53 -0
  29. package/dist/extension.cjs +87 -0
  30. package/dist/extension.d.cts +97 -0
  31. package/dist/extension.d.ts +97 -0
  32. package/dist/extension.js +76 -0
  33. package/dist/facade.cjs +19 -19
  34. package/dist/facade.d.cts +1 -1
  35. package/dist/facade.d.ts +1 -1
  36. package/dist/facade.js +19 -19
  37. package/dist/index.cjs +4 -41
  38. package/dist/index.d.cts +7 -7
  39. package/dist/index.d.ts +7 -7
  40. package/dist/index.js +5 -5
  41. package/dist/internal/annotations.cjs +316 -0
  42. package/dist/internal/annotations.d.cts +140 -0
  43. package/dist/internal/annotations.d.ts +140 -0
  44. package/dist/internal/annotations.js +306 -0
  45. package/dist/internal/dependency.cjs +984 -0
  46. package/dist/internal/dependency.d.cts +539 -0
  47. package/dist/internal/dependency.d.ts +539 -0
  48. package/dist/internal/dependency.js +964 -0
  49. package/dist/{mode-dispatch.cjs → internal/mode-dispatch.cjs} +1 -3
  50. package/dist/{mode-dispatch.d.cts → internal/mode-dispatch.d.cts} +3 -7
  51. package/dist/{mode-dispatch.d.ts → internal/mode-dispatch.d.ts} +3 -7
  52. package/dist/{mode-dispatch.js → internal/mode-dispatch.js} +1 -3
  53. package/dist/internal/parser.cjs +728 -0
  54. package/dist/internal/parser.d.cts +947 -0
  55. package/dist/internal/parser.d.ts +947 -0
  56. package/dist/internal/parser.js +711 -0
  57. package/dist/modifiers.cjs +108 -125
  58. package/dist/modifiers.d.cts +1 -1
  59. package/dist/modifiers.d.ts +1 -1
  60. package/dist/modifiers.js +92 -109
  61. package/dist/parser.cjs +11 -743
  62. package/dist/parser.d.cts +3 -991
  63. package/dist/parser.d.ts +3 -991
  64. package/dist/parser.js +2 -704
  65. package/dist/phase2-seed.cjs +4 -4
  66. package/dist/phase2-seed.js +4 -4
  67. package/dist/primitives.cjs +39 -74
  68. package/dist/primitives.d.cts +1 -1
  69. package/dist/primitives.d.ts +1 -1
  70. package/dist/primitives.js +26 -61
  71. package/dist/program.d.cts +1 -1
  72. package/dist/program.d.ts +1 -1
  73. package/dist/valueparser.cjs +23 -23
  74. package/dist/valueparser.d.cts +3 -3
  75. package/dist/valueparser.d.ts +3 -3
  76. package/dist/valueparser.js +23 -23
  77. package/package.json +9 -9
@@ -1,152 +1,2 @@
1
- //#region src/annotations.d.ts
2
- /**
3
- * Runtime context extension system for Optique parsers.
4
- *
5
- * This module provides the annotations system that allows external runtime data
6
- * to be passed to parsers during the parsing session. This enables use cases like
7
- * config file fallbacks, environment-based validation, and shared context.
8
- *
9
- * @module
10
- * @since 0.10.0
11
- */
12
- /**
13
- * Annotation key symbol for storing data in parser state.
14
- * @since 0.10.0
15
- */
16
- declare const annotationKey: unique symbol;
17
- /**
18
- * Internal marker attached during the first pass of `runWith()` so wrappers
19
- * with side effects can defer work until two-pass contexts have resolved.
20
- *
21
- * @internal
22
- */
23
- declare const firstPassAnnotationKey: unique symbol;
24
- /**
25
- * Internal key for preserving primitive parser state values when annotations
26
- * are injected into non-object states.
27
- * @internal
28
- */
29
- declare const annotationStateValueKey: unique symbol;
30
- /**
31
- * Internal marker key that indicates annotation wrapping was injected by
32
- * Optique internals for non-object states.
33
- * @internal
34
- */
35
- declare const annotationWrapperKey: unique symbol;
36
- /**
37
- * Annotations that can be passed to parsers during execution.
38
- * Allows external packages to provide additional data that parsers can access
39
- * during complete() or parse() phases.
40
- *
41
- * @example
42
- * ```typescript
43
- * const myDataKey = Symbol.for("@my-package/data");
44
- * const result = parse(parser, args, {
45
- * annotations: {
46
- * [myDataKey]: { foo: "bar" }
47
- * }
48
- * });
49
- * ```
50
- * @since 0.10.0
51
- */
52
- type Annotations = Record<symbol, unknown>;
53
- /**
54
- * Options for parse functions.
55
- * @since 0.10.0
56
- */
57
- interface ParseOptions {
58
- /**
59
- * Annotations to attach to the parsing session.
60
- * Parsers can access these annotations via getAnnotations(state).
61
- */
62
- annotations?: Annotations;
63
- }
64
- /**
65
- * Extracts annotations from parser state.
66
- *
67
- * @param state Parser state that may contain annotations
68
- * @returns Annotations object or undefined if no annotations are present
69
- * @since 0.10.0
70
- *
71
- * @example
72
- * ```typescript
73
- * const annotations = getAnnotations(state);
74
- * const myData = annotations?.[myDataKey];
75
- * ```
76
- */
77
- declare function getAnnotations(state: unknown): Annotations | undefined;
78
- /**
79
- * Reattaches annotations to a freshly created array state.
80
- *
81
- * Array spread copies elements but drops symbol properties, so parsers that
82
- * rebuild array states need to copy annotations back explicitly.
83
- *
84
- * @param source The original state that may carry annotations.
85
- * @param target The freshly created array state.
86
- * @returns The target array, with annotations copied when available.
87
- * @internal
88
- */
89
- declare function annotateFreshArray<T>(source: unknown, target: readonly T[]): readonly T[];
90
- /**
91
- * Propagates annotations from one parser state to another.
92
- *
93
- * This is mainly used by parsers that rebuild array states with spread syntax.
94
- * Array spread copies elements but drops custom symbol properties, so we need
95
- * to reattach annotations explicitly when present.
96
- *
97
- * @param source The original state that may carry annotations.
98
- * @param target The new state to receive annotations.
99
- * @returns The target state, with annotations copied when available.
100
- * @internal
101
- */
102
- declare function inheritAnnotations<T>(source: unknown, target: T): T;
103
- /**
104
- * Returns whether an annotations record carries at least one own symbol key.
105
- *
106
- * An annotations object with no own symbol keys is treated as a no-op by the
107
- * injection pipeline: it should behave identically to omitting the
108
- * `annotations` option entirely. `null` and `undefined` are accepted for
109
- * call-site convenience and always return `false`.
110
- *
111
- * @param annotations The annotations record to check.
112
- * @returns `true` when the record has at least one own symbol key.
113
- * @internal
114
- */
115
- declare function hasMeaningfulAnnotations(annotations: Annotations | null | undefined): annotations is Annotations;
116
- /**
117
- * Injects annotations into parser state while preserving state shape.
118
- *
119
- * - Primitive, null, and undefined states are wrapped with internal metadata.
120
- * - Array states are cloned and annotated without mutating the original.
121
- * - Plain object states are shallow-cloned with annotations attached.
122
- * - Built-in object states (Date/Map/Set/RegExp) are cloned by constructor.
123
- * - Other non-plain object states are cloned via prototype/descriptors.
124
- * - If the `annotations` record has no own symbol keys, the state is
125
- * returned unchanged; an empty annotations object is a no-op.
126
- *
127
- * @param state The parser state to annotate.
128
- * @param annotations The annotations to inject.
129
- * @returns Annotated state.
130
- * @internal
131
- */
132
- declare function injectAnnotations<TState>(state: TState, annotations: Annotations): TState;
133
- /**
134
- * Unwraps a primitive-state annotation wrapper injected by Optique internals.
135
- *
136
- * @param value Value to potentially unwrap.
137
- * @returns The unwrapped primitive value when the input is an injected wrapper;
138
- * otherwise the original value.
139
- * @internal
140
- */
141
- declare function unwrapInjectedAnnotationWrapper<T>(value: T): T;
142
- /**
143
- * Returns whether the given value is an internal primitive-state annotation
144
- * wrapper that was injected by Optique.
145
- *
146
- * @param value Value to check.
147
- * @returns `true` if the value is an injected internal wrapper.
148
- * @internal
149
- */
150
- declare function isInjectedAnnotationWrapper(value: unknown): boolean;
151
- //#endregion
152
- export { Annotations, ParseOptions, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
1
+ import { Annotations, ParseOptions, getAnnotations } from "./internal/annotations.cjs";
2
+ export { type Annotations, type ParseOptions, getAnnotations };
@@ -1,152 +1,2 @@
1
- //#region src/annotations.d.ts
2
- /**
3
- * Runtime context extension system for Optique parsers.
4
- *
5
- * This module provides the annotations system that allows external runtime data
6
- * to be passed to parsers during the parsing session. This enables use cases like
7
- * config file fallbacks, environment-based validation, and shared context.
8
- *
9
- * @module
10
- * @since 0.10.0
11
- */
12
- /**
13
- * Annotation key symbol for storing data in parser state.
14
- * @since 0.10.0
15
- */
16
- declare const annotationKey: unique symbol;
17
- /**
18
- * Internal marker attached during the first pass of `runWith()` so wrappers
19
- * with side effects can defer work until two-pass contexts have resolved.
20
- *
21
- * @internal
22
- */
23
- declare const firstPassAnnotationKey: unique symbol;
24
- /**
25
- * Internal key for preserving primitive parser state values when annotations
26
- * are injected into non-object states.
27
- * @internal
28
- */
29
- declare const annotationStateValueKey: unique symbol;
30
- /**
31
- * Internal marker key that indicates annotation wrapping was injected by
32
- * Optique internals for non-object states.
33
- * @internal
34
- */
35
- declare const annotationWrapperKey: unique symbol;
36
- /**
37
- * Annotations that can be passed to parsers during execution.
38
- * Allows external packages to provide additional data that parsers can access
39
- * during complete() or parse() phases.
40
- *
41
- * @example
42
- * ```typescript
43
- * const myDataKey = Symbol.for("@my-package/data");
44
- * const result = parse(parser, args, {
45
- * annotations: {
46
- * [myDataKey]: { foo: "bar" }
47
- * }
48
- * });
49
- * ```
50
- * @since 0.10.0
51
- */
52
- type Annotations = Record<symbol, unknown>;
53
- /**
54
- * Options for parse functions.
55
- * @since 0.10.0
56
- */
57
- interface ParseOptions {
58
- /**
59
- * Annotations to attach to the parsing session.
60
- * Parsers can access these annotations via getAnnotations(state).
61
- */
62
- annotations?: Annotations;
63
- }
64
- /**
65
- * Extracts annotations from parser state.
66
- *
67
- * @param state Parser state that may contain annotations
68
- * @returns Annotations object or undefined if no annotations are present
69
- * @since 0.10.0
70
- *
71
- * @example
72
- * ```typescript
73
- * const annotations = getAnnotations(state);
74
- * const myData = annotations?.[myDataKey];
75
- * ```
76
- */
77
- declare function getAnnotations(state: unknown): Annotations | undefined;
78
- /**
79
- * Reattaches annotations to a freshly created array state.
80
- *
81
- * Array spread copies elements but drops symbol properties, so parsers that
82
- * rebuild array states need to copy annotations back explicitly.
83
- *
84
- * @param source The original state that may carry annotations.
85
- * @param target The freshly created array state.
86
- * @returns The target array, with annotations copied when available.
87
- * @internal
88
- */
89
- declare function annotateFreshArray<T>(source: unknown, target: readonly T[]): readonly T[];
90
- /**
91
- * Propagates annotations from one parser state to another.
92
- *
93
- * This is mainly used by parsers that rebuild array states with spread syntax.
94
- * Array spread copies elements but drops custom symbol properties, so we need
95
- * to reattach annotations explicitly when present.
96
- *
97
- * @param source The original state that may carry annotations.
98
- * @param target The new state to receive annotations.
99
- * @returns The target state, with annotations copied when available.
100
- * @internal
101
- */
102
- declare function inheritAnnotations<T>(source: unknown, target: T): T;
103
- /**
104
- * Returns whether an annotations record carries at least one own symbol key.
105
- *
106
- * An annotations object with no own symbol keys is treated as a no-op by the
107
- * injection pipeline: it should behave identically to omitting the
108
- * `annotations` option entirely. `null` and `undefined` are accepted for
109
- * call-site convenience and always return `false`.
110
- *
111
- * @param annotations The annotations record to check.
112
- * @returns `true` when the record has at least one own symbol key.
113
- * @internal
114
- */
115
- declare function hasMeaningfulAnnotations(annotations: Annotations | null | undefined): annotations is Annotations;
116
- /**
117
- * Injects annotations into parser state while preserving state shape.
118
- *
119
- * - Primitive, null, and undefined states are wrapped with internal metadata.
120
- * - Array states are cloned and annotated without mutating the original.
121
- * - Plain object states are shallow-cloned with annotations attached.
122
- * - Built-in object states (Date/Map/Set/RegExp) are cloned by constructor.
123
- * - Other non-plain object states are cloned via prototype/descriptors.
124
- * - If the `annotations` record has no own symbol keys, the state is
125
- * returned unchanged; an empty annotations object is a no-op.
126
- *
127
- * @param state The parser state to annotate.
128
- * @param annotations The annotations to inject.
129
- * @returns Annotated state.
130
- * @internal
131
- */
132
- declare function injectAnnotations<TState>(state: TState, annotations: Annotations): TState;
133
- /**
134
- * Unwraps a primitive-state annotation wrapper injected by Optique internals.
135
- *
136
- * @param value Value to potentially unwrap.
137
- * @returns The unwrapped primitive value when the input is an injected wrapper;
138
- * otherwise the original value.
139
- * @internal
140
- */
141
- declare function unwrapInjectedAnnotationWrapper<T>(value: T): T;
142
- /**
143
- * Returns whether the given value is an internal primitive-state annotation
144
- * wrapper that was injected by Optique.
145
- *
146
- * @param value Value to check.
147
- * @returns `true` if the value is an injected internal wrapper.
148
- * @internal
149
- */
150
- declare function isInjectedAnnotationWrapper(value: unknown): boolean;
151
- //#endregion
152
- export { Annotations, ParseOptions, annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
1
+ import { Annotations, ParseOptions, getAnnotations } from "./internal/annotations.js";
2
+ export { type Annotations, type ParseOptions, getAnnotations };
@@ -1,257 +1,3 @@
1
- //#region src/annotations.ts
2
- /**
3
- * Runtime context extension system for Optique parsers.
4
- *
5
- * This module provides the annotations system that allows external runtime data
6
- * to be passed to parsers during the parsing session. This enables use cases like
7
- * config file fallbacks, environment-based validation, and shared context.
8
- *
9
- * @module
10
- * @since 0.10.0
11
- */
12
- /**
13
- * Annotation key symbol for storing data in parser state.
14
- * @since 0.10.0
15
- */
16
- const annotationKey = Symbol.for("@optique/core/parser/annotation");
17
- /**
18
- * Internal marker attached during the first pass of `runWith()` so wrappers
19
- * with side effects can defer work until two-pass contexts have resolved.
20
- *
21
- * @internal
22
- */
23
- const firstPassAnnotationKey = Symbol.for("@optique/core/parser/firstPass");
24
- /**
25
- * Internal key for preserving primitive parser state values when annotations
26
- * are injected into non-object states.
27
- * @internal
28
- */
29
- const annotationStateValueKey = Symbol.for("@optique/core/parser/annotationStateValue");
30
- /**
31
- * Internal marker key that indicates annotation wrapping was injected by
32
- * Optique internals for non-object states.
33
- * @internal
34
- */
35
- const annotationWrapperKey = Symbol.for("@optique/core/parser/annotationWrapper");
36
- /**
37
- * Internal symbol keys that define Optique's primitive-state annotation
38
- * wrapper shape.
39
- * @internal
40
- */
41
- const annotationWrapperKeys = new Set([
42
- annotationKey,
43
- annotationStateValueKey,
44
- annotationWrapperKey
45
- ]);
46
- const injectedAnnotationWrappers = /* @__PURE__ */ new WeakSet();
47
- /**
48
- * Extracts annotations from parser state.
49
- *
50
- * @param state Parser state that may contain annotations
51
- * @returns Annotations object or undefined if no annotations are present
52
- * @since 0.10.0
53
- *
54
- * @example
55
- * ```typescript
56
- * const annotations = getAnnotations(state);
57
- * const myData = annotations?.[myDataKey];
58
- * ```
59
- */
60
- function getAnnotations(state) {
61
- if (state == null || typeof state !== "object") return void 0;
62
- const stateObj = state;
63
- const annotations = stateObj[annotationKey];
64
- if (annotations != null && typeof annotations === "object") return annotations;
65
- return void 0;
66
- }
67
- /**
68
- * Reattaches annotations to a freshly created array state.
69
- *
70
- * Array spread copies elements but drops symbol properties, so parsers that
71
- * rebuild array states need to copy annotations back explicitly.
72
- *
73
- * @param source The original state that may carry annotations.
74
- * @param target The freshly created array state.
75
- * @returns The target array, with annotations copied when available.
76
- * @internal
77
- */
78
- function annotateFreshArray(source, target) {
79
- const annotations = getAnnotations(source);
80
- if (annotations === void 0) return target;
81
- const annotated = target;
82
- annotated[annotationKey] = annotations;
83
- return annotated;
84
- }
85
- /**
86
- * Propagates annotations from one parser state to another.
87
- *
88
- * This is mainly used by parsers that rebuild array states with spread syntax.
89
- * Array spread copies elements but drops custom symbol properties, so we need
90
- * to reattach annotations explicitly when present.
91
- *
92
- * @param source The original state that may carry annotations.
93
- * @param target The new state to receive annotations.
94
- * @returns The target state, with annotations copied when available.
95
- * @internal
96
- */
97
- function inheritAnnotations(source, target) {
98
- const annotations = getAnnotations(source);
99
- if (annotations === void 0) return target;
100
- if (target == null || typeof target !== "object") return injectAnnotations(target, annotations);
101
- if (isInjectedAnnotationWrapper(target)) return injectAnnotations(target, annotations);
102
- if (Array.isArray(target)) {
103
- const cloned$1 = [...target];
104
- cloned$1[annotationKey] = annotations;
105
- return cloned$1;
106
- }
107
- if (target instanceof Date) {
108
- const cloned$1 = new Date(target.getTime());
109
- cloned$1[annotationKey] = annotations;
110
- return cloned$1;
111
- }
112
- if (target instanceof Map) {
113
- const cloned$1 = new Map(target);
114
- cloned$1[annotationKey] = annotations;
115
- return cloned$1;
116
- }
117
- if (target instanceof Set) {
118
- const cloned$1 = new Set(target);
119
- cloned$1[annotationKey] = annotations;
120
- return cloned$1;
121
- }
122
- if (target instanceof RegExp) {
123
- const cloned$1 = new RegExp(target);
124
- cloned$1[annotationKey] = annotations;
125
- return cloned$1;
126
- }
127
- if (Object.getPrototypeOf(target) !== Object.prototype && Object.getPrototypeOf(target) !== null) return target;
128
- const cloned = Object.create(Object.getPrototypeOf(target), Object.getOwnPropertyDescriptors(target));
129
- cloned[annotationKey] = annotations;
130
- return cloned;
131
- }
132
- /**
133
- * Returns whether an annotations record carries at least one own symbol key.
134
- *
135
- * An annotations object with no own symbol keys is treated as a no-op by the
136
- * injection pipeline: it should behave identically to omitting the
137
- * `annotations` option entirely. `null` and `undefined` are accepted for
138
- * call-site convenience and always return `false`.
139
- *
140
- * @param annotations The annotations record to check.
141
- * @returns `true` when the record has at least one own symbol key.
142
- * @internal
143
- */
144
- function hasMeaningfulAnnotations(annotations) {
145
- return annotations != null && Object.getOwnPropertySymbols(annotations).length > 0;
146
- }
147
- /**
148
- * Injects annotations into parser state while preserving state shape.
149
- *
150
- * - Primitive, null, and undefined states are wrapped with internal metadata.
151
- * - Array states are cloned and annotated without mutating the original.
152
- * - Plain object states are shallow-cloned with annotations attached.
153
- * - Built-in object states (Date/Map/Set/RegExp) are cloned by constructor.
154
- * - Other non-plain object states are cloned via prototype/descriptors.
155
- * - If the `annotations` record has no own symbol keys, the state is
156
- * returned unchanged; an empty annotations object is a no-op.
157
- *
158
- * @param state The parser state to annotate.
159
- * @param annotations The annotations to inject.
160
- * @returns Annotated state.
161
- * @internal
162
- */
163
- function injectAnnotations(state, annotations) {
164
- if (!hasMeaningfulAnnotations(annotations)) return state;
165
- if (state == null || typeof state !== "object") {
166
- const wrapper = {};
167
- Object.defineProperties(wrapper, {
168
- [annotationKey]: {
169
- value: annotations,
170
- enumerable: true,
171
- writable: true,
172
- configurable: true
173
- },
174
- [annotationStateValueKey]: {
175
- value: state,
176
- enumerable: false,
177
- writable: true,
178
- configurable: true
179
- },
180
- [annotationWrapperKey]: {
181
- value: true,
182
- enumerable: false,
183
- writable: true,
184
- configurable: true
185
- }
186
- });
187
- injectedAnnotationWrappers.add(wrapper);
188
- return wrapper;
189
- }
190
- if (Array.isArray(state)) {
191
- const cloned$1 = [...state];
192
- cloned$1[annotationKey] = annotations;
193
- return cloned$1;
194
- }
195
- if (isInjectedAnnotationWrapper(state)) {
196
- state[annotationKey] = annotations;
197
- return state;
198
- }
199
- if (state instanceof Date) {
200
- const cloned$1 = new Date(state.getTime());
201
- cloned$1[annotationKey] = annotations;
202
- return cloned$1;
203
- }
204
- if (state instanceof Map) {
205
- const cloned$1 = new Map(state);
206
- cloned$1[annotationKey] = annotations;
207
- return cloned$1;
208
- }
209
- if (state instanceof Set) {
210
- const cloned$1 = new Set(state);
211
- cloned$1[annotationKey] = annotations;
212
- return cloned$1;
213
- }
214
- if (state instanceof RegExp) {
215
- const cloned$1 = new RegExp(state);
216
- cloned$1[annotationKey] = annotations;
217
- return cloned$1;
218
- }
219
- const proto = Object.getPrototypeOf(state);
220
- if (proto === Object.prototype || proto === null) return {
221
- ...state,
222
- [annotationKey]: annotations
223
- };
224
- const cloned = Object.create(proto, Object.getOwnPropertyDescriptors(state));
225
- cloned[annotationKey] = annotations;
226
- return cloned;
227
- }
228
- /**
229
- * Unwraps a primitive-state annotation wrapper injected by Optique internals.
230
- *
231
- * @param value Value to potentially unwrap.
232
- * @returns The unwrapped primitive value when the input is an injected wrapper;
233
- * otherwise the original value.
234
- * @internal
235
- */
236
- function unwrapInjectedAnnotationWrapper(value) {
237
- if (value == null || typeof value !== "object") return value;
238
- const valueRecord = value;
239
- if (valueRecord[annotationWrapperKey] !== true) return value;
240
- const ownKeys = Reflect.ownKeys(valueRecord);
241
- if (ownKeys.length === 3 && ownKeys.every((key) => annotationWrapperKeys.has(key)) && isInjectedAnnotationWrapper(value)) return valueRecord[annotationStateValueKey];
242
- return value;
243
- }
244
- /**
245
- * Returns whether the given value is an internal primitive-state annotation
246
- * wrapper that was injected by Optique.
247
- *
248
- * @param value Value to check.
249
- * @returns `true` if the value is an injected internal wrapper.
250
- * @internal
251
- */
252
- function isInjectedAnnotationWrapper(value) {
253
- return value != null && typeof value === "object" && injectedAnnotationWrappers.has(value);
254
- }
1
+ import { getAnnotations } from "./internal/annotations.js";
255
2
 
256
- //#endregion
257
- export { annotateFreshArray, annotationKey, annotationStateValueKey, annotationWrapperKey, firstPassAnnotationKey, getAnnotations, hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper };
3
+ export { getAnnotations };
@@ -1,4 +1,4 @@
1
- import { Suggestion } from "./parser.cjs";
1
+ import { Suggestion } from "./internal/parser.cjs";
2
2
 
3
3
  //#region src/completion.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { Suggestion } from "./parser.js";
1
+ import { Suggestion } from "./internal/parser.js";
2
2
 
3
3
  //#region src/completion.d.ts
4
4