@optique/core 1.0.0-dev.1893 → 1.0.0-dev.1897
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 +52 -43
- package/dist/annotation-state.js +52 -43
- package/package.json +1 -1
|
@@ -87,6 +87,51 @@ function normalizeDelegatedAnnotationState(state) {
|
|
|
87
87
|
function hasDelegatedAnnotationCarrier(state) {
|
|
88
88
|
return state != null && typeof state === "object" && (require_annotations.isInjectedAnnotationWrapper(state) || annotationViewTargets.has(state));
|
|
89
89
|
}
|
|
90
|
+
function isPendingNestedNormalizationAlias(originalValue, normalizedValue, seen) {
|
|
91
|
+
if (originalValue == null || typeof originalValue !== "object") return false;
|
|
92
|
+
const entry = seen.get(originalValue);
|
|
93
|
+
return entry != null && !entry.finalized && entry.clone === normalizedValue;
|
|
94
|
+
}
|
|
95
|
+
function createPendingNestedNormalizationClone(source) {
|
|
96
|
+
return Array.isArray(source) ? [] : Object.create(Object.getPrototypeOf(source));
|
|
97
|
+
}
|
|
98
|
+
function normalizeNestedDelegatedStructuredState(source, seen) {
|
|
99
|
+
const clone = createPendingNestedNormalizationClone(source);
|
|
100
|
+
const entry = {
|
|
101
|
+
clone,
|
|
102
|
+
finalized: false,
|
|
103
|
+
result: clone
|
|
104
|
+
};
|
|
105
|
+
seen.set(source, entry);
|
|
106
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
107
|
+
let changed = false;
|
|
108
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
109
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
110
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
111
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
112
|
+
if (nextValue === descriptor.value) continue;
|
|
113
|
+
overrides.set(key, nextValue);
|
|
114
|
+
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
115
|
+
}
|
|
116
|
+
if (!changed) {
|
|
117
|
+
entry.finalized = true;
|
|
118
|
+
entry.result = source;
|
|
119
|
+
return source;
|
|
120
|
+
}
|
|
121
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
122
|
+
for (const [key, nextValue] of overrides) {
|
|
123
|
+
const descriptor = descriptors[key];
|
|
124
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
125
|
+
descriptors[key] = {
|
|
126
|
+
...descriptor,
|
|
127
|
+
value: nextValue
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
Object.defineProperties(clone, descriptors);
|
|
131
|
+
entry.finalized = true;
|
|
132
|
+
entry.result = clone;
|
|
133
|
+
return clone;
|
|
134
|
+
}
|
|
90
135
|
/**
|
|
91
136
|
* Recursively removes delegated annotation carriers from plain-object and array
|
|
92
137
|
* structures.
|
|
@@ -107,49 +152,12 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
107
152
|
const normalized = normalizeDelegatedAnnotationState(value);
|
|
108
153
|
if (normalized == null || typeof normalized !== "object") return normalized;
|
|
109
154
|
const source = normalized;
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
const clone$1 = [...source];
|
|
114
|
-
seen.set(source, clone$1);
|
|
115
|
-
for (let i = 0; i < source.length; i++) {
|
|
116
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(source[i], seen);
|
|
117
|
-
if (nextValue !== source[i]) {
|
|
118
|
-
clone$1[i] = nextValue;
|
|
119
|
-
changed$1 = true;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (!changed$1) {
|
|
123
|
-
seen.set(source, source);
|
|
124
|
-
return source;
|
|
125
|
-
}
|
|
126
|
-
return clone$1;
|
|
127
|
-
}
|
|
155
|
+
const existing = seen.get(source);
|
|
156
|
+
if (existing != null) return existing.finalized ? existing.result : existing.clone;
|
|
157
|
+
if (Array.isArray(source)) return normalizeNestedDelegatedStructuredState(source, seen);
|
|
128
158
|
const proto = Object.getPrototypeOf(source);
|
|
129
159
|
if (proto !== Object.prototype && proto !== null) return normalized;
|
|
130
|
-
|
|
131
|
-
let changed = false;
|
|
132
|
-
const clone = Object.create(proto);
|
|
133
|
-
seen.set(source, clone);
|
|
134
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
135
|
-
const descriptor = descriptors[key];
|
|
136
|
-
if (descriptor != null && "value" in descriptor) {
|
|
137
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
138
|
-
if (nextValue !== descriptor.value) {
|
|
139
|
-
descriptors[key] = {
|
|
140
|
-
...descriptor,
|
|
141
|
-
value: nextValue
|
|
142
|
-
};
|
|
143
|
-
changed = true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!changed) {
|
|
148
|
-
seen.set(source, source);
|
|
149
|
-
return source;
|
|
150
|
-
}
|
|
151
|
-
Object.defineProperties(clone, descriptors);
|
|
152
|
-
return clone;
|
|
160
|
+
return normalizeNestedDelegatedStructuredState(source, seen);
|
|
153
161
|
}
|
|
154
162
|
/**
|
|
155
163
|
* Creates a short-lived delegated state that exposes the parent's annotations
|
|
@@ -167,9 +175,10 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
167
175
|
*/
|
|
168
176
|
function getDelegatedAnnotationState(parentState, childState) {
|
|
169
177
|
const annotations = require_annotations.getAnnotations(parentState);
|
|
170
|
-
if (annotations === void 0
|
|
171
|
-
if (childState == null || typeof childState !== "object") return require_annotations.injectAnnotations(childState, annotations);
|
|
178
|
+
if (annotations === void 0) return childState;
|
|
172
179
|
if (require_annotations.isInjectedAnnotationWrapper(childState)) return require_annotations.injectAnnotations(normalizeInjectedAnnotationState(childState), annotations);
|
|
180
|
+
if (require_annotations.getAnnotations(childState) === annotations) return childState;
|
|
181
|
+
if (childState == null || typeof childState !== "object") return require_annotations.injectAnnotations(childState, annotations);
|
|
173
182
|
if (isNonPlainDelegatedObject(childState)) return withAnnotationView(childState, annotations);
|
|
174
183
|
return require_annotations.inheritAnnotations(parentState, childState);
|
|
175
184
|
}
|
package/dist/annotation-state.js
CHANGED
|
@@ -87,6 +87,51 @@ function normalizeDelegatedAnnotationState(state) {
|
|
|
87
87
|
function hasDelegatedAnnotationCarrier(state) {
|
|
88
88
|
return state != null && typeof state === "object" && (isInjectedAnnotationWrapper(state) || annotationViewTargets.has(state));
|
|
89
89
|
}
|
|
90
|
+
function isPendingNestedNormalizationAlias(originalValue, normalizedValue, seen) {
|
|
91
|
+
if (originalValue == null || typeof originalValue !== "object") return false;
|
|
92
|
+
const entry = seen.get(originalValue);
|
|
93
|
+
return entry != null && !entry.finalized && entry.clone === normalizedValue;
|
|
94
|
+
}
|
|
95
|
+
function createPendingNestedNormalizationClone(source) {
|
|
96
|
+
return Array.isArray(source) ? [] : Object.create(Object.getPrototypeOf(source));
|
|
97
|
+
}
|
|
98
|
+
function normalizeNestedDelegatedStructuredState(source, seen) {
|
|
99
|
+
const clone = createPendingNestedNormalizationClone(source);
|
|
100
|
+
const entry = {
|
|
101
|
+
clone,
|
|
102
|
+
finalized: false,
|
|
103
|
+
result: clone
|
|
104
|
+
};
|
|
105
|
+
seen.set(source, entry);
|
|
106
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
107
|
+
let changed = false;
|
|
108
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
109
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
110
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
111
|
+
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
112
|
+
if (nextValue === descriptor.value) continue;
|
|
113
|
+
overrides.set(key, nextValue);
|
|
114
|
+
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
115
|
+
}
|
|
116
|
+
if (!changed) {
|
|
117
|
+
entry.finalized = true;
|
|
118
|
+
entry.result = source;
|
|
119
|
+
return source;
|
|
120
|
+
}
|
|
121
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
122
|
+
for (const [key, nextValue] of overrides) {
|
|
123
|
+
const descriptor = descriptors[key];
|
|
124
|
+
if (descriptor == null || !("value" in descriptor)) continue;
|
|
125
|
+
descriptors[key] = {
|
|
126
|
+
...descriptor,
|
|
127
|
+
value: nextValue
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
Object.defineProperties(clone, descriptors);
|
|
131
|
+
entry.finalized = true;
|
|
132
|
+
entry.result = clone;
|
|
133
|
+
return clone;
|
|
134
|
+
}
|
|
90
135
|
/**
|
|
91
136
|
* Recursively removes delegated annotation carriers from plain-object and array
|
|
92
137
|
* structures.
|
|
@@ -107,49 +152,12 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
107
152
|
const normalized = normalizeDelegatedAnnotationState(value);
|
|
108
153
|
if (normalized == null || typeof normalized !== "object") return normalized;
|
|
109
154
|
const source = normalized;
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
const clone$1 = [...source];
|
|
114
|
-
seen.set(source, clone$1);
|
|
115
|
-
for (let i = 0; i < source.length; i++) {
|
|
116
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(source[i], seen);
|
|
117
|
-
if (nextValue !== source[i]) {
|
|
118
|
-
clone$1[i] = nextValue;
|
|
119
|
-
changed$1 = true;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (!changed$1) {
|
|
123
|
-
seen.set(source, source);
|
|
124
|
-
return source;
|
|
125
|
-
}
|
|
126
|
-
return clone$1;
|
|
127
|
-
}
|
|
155
|
+
const existing = seen.get(source);
|
|
156
|
+
if (existing != null) return existing.finalized ? existing.result : existing.clone;
|
|
157
|
+
if (Array.isArray(source)) return normalizeNestedDelegatedStructuredState(source, seen);
|
|
128
158
|
const proto = Object.getPrototypeOf(source);
|
|
129
159
|
if (proto !== Object.prototype && proto !== null) return normalized;
|
|
130
|
-
|
|
131
|
-
let changed = false;
|
|
132
|
-
const clone = Object.create(proto);
|
|
133
|
-
seen.set(source, clone);
|
|
134
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
135
|
-
const descriptor = descriptors[key];
|
|
136
|
-
if (descriptor != null && "value" in descriptor) {
|
|
137
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
138
|
-
if (nextValue !== descriptor.value) {
|
|
139
|
-
descriptors[key] = {
|
|
140
|
-
...descriptor,
|
|
141
|
-
value: nextValue
|
|
142
|
-
};
|
|
143
|
-
changed = true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!changed) {
|
|
148
|
-
seen.set(source, source);
|
|
149
|
-
return source;
|
|
150
|
-
}
|
|
151
|
-
Object.defineProperties(clone, descriptors);
|
|
152
|
-
return clone;
|
|
160
|
+
return normalizeNestedDelegatedStructuredState(source, seen);
|
|
153
161
|
}
|
|
154
162
|
/**
|
|
155
163
|
* Creates a short-lived delegated state that exposes the parent's annotations
|
|
@@ -167,9 +175,10 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
167
175
|
*/
|
|
168
176
|
function getDelegatedAnnotationState(parentState, childState) {
|
|
169
177
|
const annotations = getAnnotations(parentState);
|
|
170
|
-
if (annotations === void 0
|
|
171
|
-
if (childState == null || typeof childState !== "object") return injectAnnotations(childState, annotations);
|
|
178
|
+
if (annotations === void 0) return childState;
|
|
172
179
|
if (isInjectedAnnotationWrapper(childState)) return injectAnnotations(normalizeInjectedAnnotationState(childState), annotations);
|
|
180
|
+
if (getAnnotations(childState) === annotations) return childState;
|
|
181
|
+
if (childState == null || typeof childState !== "object") return injectAnnotations(childState, annotations);
|
|
173
182
|
if (isNonPlainDelegatedObject(childState)) return withAnnotationView(childState, annotations);
|
|
174
183
|
return inheritAnnotations(parentState, childState);
|
|
175
184
|
}
|