@optique/core 1.0.0-dev.1899 → 1.0.0-dev.1901
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 +97 -6
- package/dist/annotation-state.js +97 -6
- package/dist/modifiers.cjs +18 -8
- package/dist/modifiers.js +19 -9
- package/package.json +1 -1
|
@@ -132,14 +132,103 @@ function normalizeNestedDelegatedStructuredState(source, seen) {
|
|
|
132
132
|
entry.result = clone;
|
|
133
133
|
return clone;
|
|
134
134
|
}
|
|
135
|
+
function normalizeNestedDelegatedMapState(source, seen) {
|
|
136
|
+
const clone = /* @__PURE__ */ new Map();
|
|
137
|
+
const entry = {
|
|
138
|
+
clone,
|
|
139
|
+
finalized: false,
|
|
140
|
+
result: clone
|
|
141
|
+
};
|
|
142
|
+
seen.set(source, entry);
|
|
143
|
+
const normalizedEntries = [];
|
|
144
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
145
|
+
let changed = false;
|
|
146
|
+
for (const [key, value] of source) {
|
|
147
|
+
const nextKey = normalizeNestedDelegatedAnnotationState(key, seen);
|
|
148
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(value, seen);
|
|
149
|
+
normalizedEntries.push([nextKey, nextValue]);
|
|
150
|
+
if (!isPendingNestedNormalizationAlias(key, nextKey, seen) && nextKey !== key || !isPendingNestedNormalizationAlias(value, nextValue, seen) && nextValue !== value) changed = true;
|
|
151
|
+
}
|
|
152
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
153
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
154
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
155
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
156
|
+
if (nextValue === descriptor.value) continue;
|
|
157
|
+
overrides.set(key, nextValue);
|
|
158
|
+
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
159
|
+
}
|
|
160
|
+
if (!changed) {
|
|
161
|
+
entry.finalized = true;
|
|
162
|
+
entry.result = source;
|
|
163
|
+
return source;
|
|
164
|
+
}
|
|
165
|
+
for (const [key, value] of normalizedEntries) clone.set(key, value);
|
|
166
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
167
|
+
for (const [key, nextValue] of overrides) {
|
|
168
|
+
const descriptor = descriptors[key];
|
|
169
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
170
|
+
descriptors[key] = {
|
|
171
|
+
...descriptor,
|
|
172
|
+
value: nextValue
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
Object.defineProperties(clone, descriptors);
|
|
176
|
+
entry.finalized = true;
|
|
177
|
+
entry.result = clone;
|
|
178
|
+
return clone;
|
|
179
|
+
}
|
|
180
|
+
function normalizeNestedDelegatedSetState(source, seen) {
|
|
181
|
+
const clone = /* @__PURE__ */ new Set();
|
|
182
|
+
const entry = {
|
|
183
|
+
clone,
|
|
184
|
+
finalized: false,
|
|
185
|
+
result: clone
|
|
186
|
+
};
|
|
187
|
+
seen.set(source, entry);
|
|
188
|
+
const normalizedValues = [];
|
|
189
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
190
|
+
let changed = false;
|
|
191
|
+
for (const value of source) {
|
|
192
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(value, seen);
|
|
193
|
+
normalizedValues.push(nextValue);
|
|
194
|
+
if (nextValue !== value && !isPendingNestedNormalizationAlias(value, nextValue, seen)) changed = true;
|
|
195
|
+
}
|
|
196
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
197
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
198
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
199
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
200
|
+
if (nextValue === descriptor.value) continue;
|
|
201
|
+
overrides.set(key, nextValue);
|
|
202
|
+
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
203
|
+
}
|
|
204
|
+
if (!changed) {
|
|
205
|
+
entry.finalized = true;
|
|
206
|
+
entry.result = source;
|
|
207
|
+
return source;
|
|
208
|
+
}
|
|
209
|
+
for (const value of normalizedValues) clone.add(value);
|
|
210
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
211
|
+
for (const [key, nextValue] of overrides) {
|
|
212
|
+
const descriptor = descriptors[key];
|
|
213
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
214
|
+
descriptors[key] = {
|
|
215
|
+
...descriptor,
|
|
216
|
+
value: nextValue
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
Object.defineProperties(clone, descriptors);
|
|
220
|
+
entry.finalized = true;
|
|
221
|
+
entry.result = clone;
|
|
222
|
+
return clone;
|
|
223
|
+
}
|
|
135
224
|
/**
|
|
136
|
-
* Recursively removes delegated annotation carriers from plain-object
|
|
137
|
-
* structures.
|
|
225
|
+
* Recursively removes delegated annotation carriers from plain-object, array,
|
|
226
|
+
* and built-in collection structures.
|
|
138
227
|
*
|
|
139
|
-
* Nested plain objects and
|
|
140
|
-
* carrier is found below them.
|
|
141
|
-
* level and then preserved as-is to avoid mutating or reconstructing
|
|
142
|
-
* instances.
|
|
228
|
+
* Nested plain objects, arrays, Maps, and Sets are shallow-cloned only when a
|
|
229
|
+
* delegated carrier is found below them. Other non-plain objects are unwrapped
|
|
230
|
+
* at the top level and then preserved as-is to avoid mutating or reconstructing
|
|
231
|
+
* class instances.
|
|
143
232
|
*
|
|
144
233
|
* @param value The candidate value to normalize.
|
|
145
234
|
* @param seen Tracks already-normalized objects so cyclic values keep their
|
|
@@ -155,6 +244,8 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
155
244
|
const existing = seen.get(source);
|
|
156
245
|
if (existing != null) return existing.finalized ? existing.result : existing.clone;
|
|
157
246
|
if (Array.isArray(source)) return normalizeNestedDelegatedStructuredState(source, seen);
|
|
247
|
+
if (source instanceof Map) return normalizeNestedDelegatedMapState(source, seen);
|
|
248
|
+
if (source instanceof Set) return normalizeNestedDelegatedSetState(source, seen);
|
|
158
249
|
const proto = Object.getPrototypeOf(source);
|
|
159
250
|
if (proto !== Object.prototype && proto !== null) return normalized;
|
|
160
251
|
return normalizeNestedDelegatedStructuredState(source, seen);
|
package/dist/annotation-state.js
CHANGED
|
@@ -132,14 +132,103 @@ function normalizeNestedDelegatedStructuredState(source, seen) {
|
|
|
132
132
|
entry.result = clone;
|
|
133
133
|
return clone;
|
|
134
134
|
}
|
|
135
|
+
function normalizeNestedDelegatedMapState(source, seen) {
|
|
136
|
+
const clone = /* @__PURE__ */ new Map();
|
|
137
|
+
const entry = {
|
|
138
|
+
clone,
|
|
139
|
+
finalized: false,
|
|
140
|
+
result: clone
|
|
141
|
+
};
|
|
142
|
+
seen.set(source, entry);
|
|
143
|
+
const normalizedEntries = [];
|
|
144
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
145
|
+
let changed = false;
|
|
146
|
+
for (const [key, value] of source) {
|
|
147
|
+
const nextKey = normalizeNestedDelegatedAnnotationState(key, seen);
|
|
148
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(value, seen);
|
|
149
|
+
normalizedEntries.push([nextKey, nextValue]);
|
|
150
|
+
if (!isPendingNestedNormalizationAlias(key, nextKey, seen) && nextKey !== key || !isPendingNestedNormalizationAlias(value, nextValue, seen) && nextValue !== value) changed = true;
|
|
151
|
+
}
|
|
152
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
153
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
154
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
155
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
156
|
+
if (nextValue === descriptor.value) continue;
|
|
157
|
+
overrides.set(key, nextValue);
|
|
158
|
+
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
159
|
+
}
|
|
160
|
+
if (!changed) {
|
|
161
|
+
entry.finalized = true;
|
|
162
|
+
entry.result = source;
|
|
163
|
+
return source;
|
|
164
|
+
}
|
|
165
|
+
for (const [key, value] of normalizedEntries) clone.set(key, value);
|
|
166
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
167
|
+
for (const [key, nextValue] of overrides) {
|
|
168
|
+
const descriptor = descriptors[key];
|
|
169
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
170
|
+
descriptors[key] = {
|
|
171
|
+
...descriptor,
|
|
172
|
+
value: nextValue
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
Object.defineProperties(clone, descriptors);
|
|
176
|
+
entry.finalized = true;
|
|
177
|
+
entry.result = clone;
|
|
178
|
+
return clone;
|
|
179
|
+
}
|
|
180
|
+
function normalizeNestedDelegatedSetState(source, seen) {
|
|
181
|
+
const clone = /* @__PURE__ */ new Set();
|
|
182
|
+
const entry = {
|
|
183
|
+
clone,
|
|
184
|
+
finalized: false,
|
|
185
|
+
result: clone
|
|
186
|
+
};
|
|
187
|
+
seen.set(source, entry);
|
|
188
|
+
const normalizedValues = [];
|
|
189
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
190
|
+
let changed = false;
|
|
191
|
+
for (const value of source) {
|
|
192
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(value, seen);
|
|
193
|
+
normalizedValues.push(nextValue);
|
|
194
|
+
if (nextValue !== value && !isPendingNestedNormalizationAlias(value, nextValue, seen)) changed = true;
|
|
195
|
+
}
|
|
196
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
197
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
198
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
199
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
200
|
+
if (nextValue === descriptor.value) continue;
|
|
201
|
+
overrides.set(key, nextValue);
|
|
202
|
+
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
203
|
+
}
|
|
204
|
+
if (!changed) {
|
|
205
|
+
entry.finalized = true;
|
|
206
|
+
entry.result = source;
|
|
207
|
+
return source;
|
|
208
|
+
}
|
|
209
|
+
for (const value of normalizedValues) clone.add(value);
|
|
210
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
211
|
+
for (const [key, nextValue] of overrides) {
|
|
212
|
+
const descriptor = descriptors[key];
|
|
213
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
214
|
+
descriptors[key] = {
|
|
215
|
+
...descriptor,
|
|
216
|
+
value: nextValue
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
Object.defineProperties(clone, descriptors);
|
|
220
|
+
entry.finalized = true;
|
|
221
|
+
entry.result = clone;
|
|
222
|
+
return clone;
|
|
223
|
+
}
|
|
135
224
|
/**
|
|
136
|
-
* Recursively removes delegated annotation carriers from plain-object
|
|
137
|
-
* structures.
|
|
225
|
+
* Recursively removes delegated annotation carriers from plain-object, array,
|
|
226
|
+
* and built-in collection structures.
|
|
138
227
|
*
|
|
139
|
-
* Nested plain objects and
|
|
140
|
-
* carrier is found below them.
|
|
141
|
-
* level and then preserved as-is to avoid mutating or reconstructing
|
|
142
|
-
* instances.
|
|
228
|
+
* Nested plain objects, arrays, Maps, and Sets are shallow-cloned only when a
|
|
229
|
+
* delegated carrier is found below them. Other non-plain objects are unwrapped
|
|
230
|
+
* at the top level and then preserved as-is to avoid mutating or reconstructing
|
|
231
|
+
* class instances.
|
|
143
232
|
*
|
|
144
233
|
* @param value The candidate value to normalize.
|
|
145
234
|
* @param seen Tracks already-normalized objects so cyclic values keep their
|
|
@@ -155,6 +244,8 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
155
244
|
const existing = seen.get(source);
|
|
156
245
|
if (existing != null) return existing.finalized ? existing.result : existing.clone;
|
|
157
246
|
if (Array.isArray(source)) return normalizeNestedDelegatedStructuredState(source, seen);
|
|
247
|
+
if (source instanceof Map) return normalizeNestedDelegatedMapState(source, seen);
|
|
248
|
+
if (source instanceof Set) return normalizeNestedDelegatedSetState(source, seen);
|
|
158
249
|
const proto = Object.getPrototypeOf(source);
|
|
159
250
|
if (proto !== Object.prototype && proto !== null) return normalized;
|
|
160
251
|
return normalizeNestedDelegatedStructuredState(source, seen);
|
package/dist/modifiers.cjs
CHANGED
|
@@ -90,22 +90,28 @@ function normalizeOptionalLikeCompleteResult(result) {
|
|
|
90
90
|
}
|
|
91
91
|
function completeOptionalLikeSync(parser, state, exec) {
|
|
92
92
|
const hasCarrier = require_annotation_state.hasDelegatedAnnotationCarrier(state);
|
|
93
|
+
const shouldRetryFalseResult = require_annotation_state.isAnnotationWrappedInitialState(state);
|
|
94
|
+
const run = (candidate) => normalizeOptionalLikeCompleteResult(parser.complete(candidate, exec));
|
|
93
95
|
try {
|
|
94
|
-
|
|
96
|
+
const result = run(state);
|
|
97
|
+
if (!result.success && shouldRetryFalseResult) return run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
98
|
+
return result;
|
|
95
99
|
} catch (error) {
|
|
96
100
|
if (!hasCarrier) throw error;
|
|
97
|
-
|
|
98
|
-
return normalizeOptionalLikeCompleteResult(parser.complete(fallbackState, exec));
|
|
101
|
+
return run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
async function completeOptionalLikeAsync(parser, state, exec) {
|
|
102
105
|
const hasCarrier = require_annotation_state.hasDelegatedAnnotationCarrier(state);
|
|
106
|
+
const shouldRetryFalseResult = require_annotation_state.isAnnotationWrappedInitialState(state);
|
|
107
|
+
const run = async (candidate) => normalizeOptionalLikeCompleteResult(await parser.complete(candidate, exec));
|
|
103
108
|
try {
|
|
104
|
-
|
|
109
|
+
const result = await run(state);
|
|
110
|
+
if (!result.success && shouldRetryFalseResult) return await run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
111
|
+
return result;
|
|
105
112
|
} catch (error) {
|
|
106
113
|
if (!hasCarrier) throw error;
|
|
107
|
-
|
|
108
|
-
return normalizeOptionalLikeCompleteResult(await parser.complete(fallbackState, exec));
|
|
114
|
+
return await run(require_annotation_state.normalizeDelegatedAnnotationState(state));
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
function normalizeOptionalLikePhase2Seed(seed) {
|
|
@@ -253,10 +259,14 @@ function adaptShouldDeferCompletion(innerCheck, parser) {
|
|
|
253
259
|
return (state, exec) => {
|
|
254
260
|
if (Array.isArray(state) || state != null && typeof state === "object") {
|
|
255
261
|
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
262
|
+
const hasCarrier = require_annotation_state.hasDelegatedAnnotationCarrier(innerState);
|
|
263
|
+
const shouldRetryFalseResult = hasCarrier && require_annotation_state.isAnnotationWrappedInitialState(innerState);
|
|
256
264
|
try {
|
|
257
|
-
|
|
265
|
+
const result = innerCheck(innerState, exec);
|
|
266
|
+
if (!result && shouldRetryFalseResult) return innerCheck(require_annotation_state.normalizeDelegatedAnnotationState(innerState), exec);
|
|
267
|
+
return result;
|
|
258
268
|
} catch (error) {
|
|
259
|
-
if (!
|
|
269
|
+
if (!hasCarrier) throw error;
|
|
260
270
|
return innerCheck(require_annotation_state.normalizeDelegatedAnnotationState(innerState), exec);
|
|
261
271
|
}
|
|
262
272
|
}
|
package/dist/modifiers.js
CHANGED
|
@@ -4,7 +4,7 @@ import { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode } fro
|
|
|
4
4
|
import { composeDependencyMetadata } from "./dependency-metadata.js";
|
|
5
5
|
import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, phase2SeedFromValueResult } from "./phase2-seed.js";
|
|
6
6
|
import { defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
|
|
7
|
-
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
7
|
+
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
8
8
|
|
|
9
9
|
//#region src/modifiers.ts
|
|
10
10
|
function withChildExecPath(exec, segment) {
|
|
@@ -90,22 +90,28 @@ function normalizeOptionalLikeCompleteResult(result) {
|
|
|
90
90
|
}
|
|
91
91
|
function completeOptionalLikeSync(parser, state, exec) {
|
|
92
92
|
const hasCarrier = hasDelegatedAnnotationCarrier(state);
|
|
93
|
+
const shouldRetryFalseResult = isAnnotationWrappedInitialState(state);
|
|
94
|
+
const run = (candidate) => normalizeOptionalLikeCompleteResult(parser.complete(candidate, exec));
|
|
93
95
|
try {
|
|
94
|
-
|
|
96
|
+
const result = run(state);
|
|
97
|
+
if (!result.success && shouldRetryFalseResult) return run(normalizeDelegatedAnnotationState(state));
|
|
98
|
+
return result;
|
|
95
99
|
} catch (error) {
|
|
96
100
|
if (!hasCarrier) throw error;
|
|
97
|
-
|
|
98
|
-
return normalizeOptionalLikeCompleteResult(parser.complete(fallbackState, exec));
|
|
101
|
+
return run(normalizeDelegatedAnnotationState(state));
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
async function completeOptionalLikeAsync(parser, state, exec) {
|
|
102
105
|
const hasCarrier = hasDelegatedAnnotationCarrier(state);
|
|
106
|
+
const shouldRetryFalseResult = isAnnotationWrappedInitialState(state);
|
|
107
|
+
const run = async (candidate) => normalizeOptionalLikeCompleteResult(await parser.complete(candidate, exec));
|
|
103
108
|
try {
|
|
104
|
-
|
|
109
|
+
const result = await run(state);
|
|
110
|
+
if (!result.success && shouldRetryFalseResult) return await run(normalizeDelegatedAnnotationState(state));
|
|
111
|
+
return result;
|
|
105
112
|
} catch (error) {
|
|
106
113
|
if (!hasCarrier) throw error;
|
|
107
|
-
|
|
108
|
-
return normalizeOptionalLikeCompleteResult(await parser.complete(fallbackState, exec));
|
|
114
|
+
return await run(normalizeDelegatedAnnotationState(state));
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
function normalizeOptionalLikePhase2Seed(seed) {
|
|
@@ -253,10 +259,14 @@ function adaptShouldDeferCompletion(innerCheck, parser) {
|
|
|
253
259
|
return (state, exec) => {
|
|
254
260
|
if (Array.isArray(state) || state != null && typeof state === "object") {
|
|
255
261
|
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
262
|
+
const hasCarrier = hasDelegatedAnnotationCarrier(innerState);
|
|
263
|
+
const shouldRetryFalseResult = hasCarrier && isAnnotationWrappedInitialState(innerState);
|
|
256
264
|
try {
|
|
257
|
-
|
|
265
|
+
const result = innerCheck(innerState, exec);
|
|
266
|
+
if (!result && shouldRetryFalseResult) return innerCheck(normalizeDelegatedAnnotationState(innerState), exec);
|
|
267
|
+
return result;
|
|
258
268
|
} catch (error) {
|
|
259
|
-
if (!
|
|
269
|
+
if (!hasCarrier) throw error;
|
|
260
270
|
return innerCheck(normalizeDelegatedAnnotationState(innerState), exec);
|
|
261
271
|
}
|
|
262
272
|
}
|