@optique/core 1.0.0-dev.1659 → 1.0.0-dev.1663
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/constructs.cjs +25 -13
- package/dist/constructs.js +25 -13
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -137,7 +137,11 @@ function containsAnnotationView(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
137
137
|
if (Array.isArray(source)) return source.some((item) => containsAnnotationView(item, seen));
|
|
138
138
|
const proto = Object.getPrototypeOf(source);
|
|
139
139
|
if (proto !== Object.prototype && proto !== null) return false;
|
|
140
|
-
|
|
140
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
141
|
+
return Reflect.ownKeys(descriptors).some((key) => {
|
|
142
|
+
const descriptor = descriptors[key];
|
|
143
|
+
return descriptor != null && "value" in descriptor ? containsAnnotationView(descriptor.value, seen) : false;
|
|
144
|
+
});
|
|
141
145
|
}
|
|
142
146
|
function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
143
147
|
if (value == null || typeof value !== "object") return value;
|
|
@@ -222,17 +226,18 @@ function getAnnotatedFieldState(parentState, field, parser) {
|
|
|
222
226
|
}
|
|
223
227
|
const annotationViewTargets = /* @__PURE__ */ new WeakMap();
|
|
224
228
|
function withAnnotationView(state, annotations) {
|
|
225
|
-
const
|
|
226
|
-
|
|
229
|
+
const target = unwrapAnnotationView(state);
|
|
230
|
+
const view = new Proxy(target, {
|
|
231
|
+
get(target$1, key) {
|
|
227
232
|
if (key === require_annotations.annotationKey) return annotations;
|
|
228
|
-
const value = Reflect.get(target, key, target);
|
|
229
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
233
|
+
const value = Reflect.get(target$1, key, target$1);
|
|
234
|
+
return typeof value === "function" ? value.bind(target$1) : value;
|
|
230
235
|
},
|
|
231
|
-
has(target, key) {
|
|
232
|
-
return key === require_annotations.annotationKey || Reflect.has(target, key);
|
|
236
|
+
has(target$1, key) {
|
|
237
|
+
return key === require_annotations.annotationKey || Reflect.has(target$1, key);
|
|
233
238
|
}
|
|
234
239
|
});
|
|
235
|
-
annotationViewTargets.set(view,
|
|
240
|
+
annotationViewTargets.set(view, target);
|
|
236
241
|
return view;
|
|
237
242
|
}
|
|
238
243
|
function getParseChildState(parentState, childState, parser) {
|
|
@@ -249,7 +254,7 @@ function getParseChildState(parentState, childState, parser) {
|
|
|
249
254
|
function getObjectParseChildState(parentState, childState, _parser) {
|
|
250
255
|
const annotations = require_annotations.getAnnotations(parentState);
|
|
251
256
|
if (annotations === void 0 || childState == null || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations) return childState;
|
|
252
|
-
return require_annotations.
|
|
257
|
+
return require_annotations.inheritAnnotations(parentState, childState);
|
|
253
258
|
}
|
|
254
259
|
function getAnnotatedChildState(parentState, childState, parser) {
|
|
255
260
|
const annotations = require_annotations.getAnnotations(parentState);
|
|
@@ -1328,10 +1333,17 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1328
1333
|
const createFieldStateGetter = (parentState, annotateChildState = getAnnotatedChildState) => {
|
|
1329
1334
|
return (field, parser) => {
|
|
1330
1335
|
const fieldKey = field;
|
|
1331
|
-
const cache = parentState != null && typeof parentState === "object" ?
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
|
|
1336
|
+
const cache = parentState != null && typeof parentState === "object" ? (() => {
|
|
1337
|
+
const annotatorCaches = inheritedFieldStateCache.get(parentState) ?? (() => {
|
|
1338
|
+
const nextCaches = /* @__PURE__ */ new WeakMap();
|
|
1339
|
+
inheritedFieldStateCache.set(parentState, nextCaches);
|
|
1340
|
+
return nextCaches;
|
|
1341
|
+
})();
|
|
1342
|
+
return annotatorCaches.get(annotateChildState) ?? (() => {
|
|
1343
|
+
const stateCache = /* @__PURE__ */ new Map();
|
|
1344
|
+
annotatorCaches.set(annotateChildState, stateCache);
|
|
1345
|
+
return stateCache;
|
|
1346
|
+
})();
|
|
1335
1347
|
})() : void 0;
|
|
1336
1348
|
if (cache?.has(fieldKey)) return cache.get(fieldKey);
|
|
1337
1349
|
const sourceState = parentState != null && typeof parentState === "object" && fieldKey in parentState ? parentState[fieldKey] : parser.initialState;
|
package/dist/constructs.js
CHANGED
|
@@ -137,7 +137,11 @@ function containsAnnotationView(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
137
137
|
if (Array.isArray(source)) return source.some((item) => containsAnnotationView(item, seen));
|
|
138
138
|
const proto = Object.getPrototypeOf(source);
|
|
139
139
|
if (proto !== Object.prototype && proto !== null) return false;
|
|
140
|
-
|
|
140
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
141
|
+
return Reflect.ownKeys(descriptors).some((key) => {
|
|
142
|
+
const descriptor = descriptors[key];
|
|
143
|
+
return descriptor != null && "value" in descriptor ? containsAnnotationView(descriptor.value, seen) : false;
|
|
144
|
+
});
|
|
141
145
|
}
|
|
142
146
|
function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
143
147
|
if (value == null || typeof value !== "object") return value;
|
|
@@ -222,17 +226,18 @@ function getAnnotatedFieldState(parentState, field, parser) {
|
|
|
222
226
|
}
|
|
223
227
|
const annotationViewTargets = /* @__PURE__ */ new WeakMap();
|
|
224
228
|
function withAnnotationView(state, annotations) {
|
|
225
|
-
const
|
|
226
|
-
|
|
229
|
+
const target = unwrapAnnotationView(state);
|
|
230
|
+
const view = new Proxy(target, {
|
|
231
|
+
get(target$1, key) {
|
|
227
232
|
if (key === annotationKey) return annotations;
|
|
228
|
-
const value = Reflect.get(target, key, target);
|
|
229
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
233
|
+
const value = Reflect.get(target$1, key, target$1);
|
|
234
|
+
return typeof value === "function" ? value.bind(target$1) : value;
|
|
230
235
|
},
|
|
231
|
-
has(target, key) {
|
|
232
|
-
return key === annotationKey || Reflect.has(target, key);
|
|
236
|
+
has(target$1, key) {
|
|
237
|
+
return key === annotationKey || Reflect.has(target$1, key);
|
|
233
238
|
}
|
|
234
239
|
});
|
|
235
|
-
annotationViewTargets.set(view,
|
|
240
|
+
annotationViewTargets.set(view, target);
|
|
236
241
|
return view;
|
|
237
242
|
}
|
|
238
243
|
function getParseChildState(parentState, childState, parser) {
|
|
@@ -249,7 +254,7 @@ function getParseChildState(parentState, childState, parser) {
|
|
|
249
254
|
function getObjectParseChildState(parentState, childState, _parser) {
|
|
250
255
|
const annotations = getAnnotations(parentState);
|
|
251
256
|
if (annotations === void 0 || childState == null || typeof childState !== "object" || getAnnotations(childState) === annotations) return childState;
|
|
252
|
-
return
|
|
257
|
+
return inheritAnnotations(parentState, childState);
|
|
253
258
|
}
|
|
254
259
|
function getAnnotatedChildState(parentState, childState, parser) {
|
|
255
260
|
const annotations = getAnnotations(parentState);
|
|
@@ -1328,10 +1333,17 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1328
1333
|
const createFieldStateGetter = (parentState, annotateChildState = getAnnotatedChildState) => {
|
|
1329
1334
|
return (field, parser) => {
|
|
1330
1335
|
const fieldKey = field;
|
|
1331
|
-
const cache = parentState != null && typeof parentState === "object" ?
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
|
|
1336
|
+
const cache = parentState != null && typeof parentState === "object" ? (() => {
|
|
1337
|
+
const annotatorCaches = inheritedFieldStateCache.get(parentState) ?? (() => {
|
|
1338
|
+
const nextCaches = /* @__PURE__ */ new WeakMap();
|
|
1339
|
+
inheritedFieldStateCache.set(parentState, nextCaches);
|
|
1340
|
+
return nextCaches;
|
|
1341
|
+
})();
|
|
1342
|
+
return annotatorCaches.get(annotateChildState) ?? (() => {
|
|
1343
|
+
const stateCache = /* @__PURE__ */ new Map();
|
|
1344
|
+
annotatorCaches.set(annotateChildState, stateCache);
|
|
1345
|
+
return stateCache;
|
|
1346
|
+
})();
|
|
1335
1347
|
})() : void 0;
|
|
1336
1348
|
if (cache?.has(fieldKey)) return cache.get(fieldKey);
|
|
1337
1349
|
const sourceState = parentState != null && typeof parentState === "object" && fieldKey in parentState ? parentState[fieldKey] : parser.initialState;
|