@optique/core 1.0.0-dev.1895 → 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 +42 -47
- package/dist/annotation-state.js +43 -48
- package/package.json +1 -1
|
@@ -92,6 +92,46 @@ function isPendingNestedNormalizationAlias(originalValue, normalizedValue, seen)
|
|
|
92
92
|
const entry = seen.get(originalValue);
|
|
93
93
|
return entry != null && !entry.finalized && entry.clone === normalizedValue;
|
|
94
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
|
+
}
|
|
95
135
|
/**
|
|
96
136
|
* Recursively removes delegated annotation carriers from plain-object and array
|
|
97
137
|
* structures.
|
|
@@ -114,55 +154,10 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
114
154
|
const source = normalized;
|
|
115
155
|
const existing = seen.get(source);
|
|
116
156
|
if (existing != null) return existing.finalized ? existing.result : existing.clone;
|
|
117
|
-
if (Array.isArray(source))
|
|
118
|
-
let changed$1 = false;
|
|
119
|
-
const clone$1 = require_annotations.annotateFreshArray(source, source.slice());
|
|
120
|
-
const entry$1 = {
|
|
121
|
-
clone: clone$1,
|
|
122
|
-
finalized: false,
|
|
123
|
-
result: clone$1
|
|
124
|
-
};
|
|
125
|
-
seen.set(source, entry$1);
|
|
126
|
-
for (let i = 0; i < source.length; i++) {
|
|
127
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(source[i], seen);
|
|
128
|
-
if (nextValue !== source[i]) {
|
|
129
|
-
clone$1[i] = nextValue;
|
|
130
|
-
if (!isPendingNestedNormalizationAlias(source[i], nextValue, seen)) changed$1 = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
entry$1.finalized = true;
|
|
134
|
-
entry$1.result = changed$1 ? clone$1 : source;
|
|
135
|
-
return changed$1 ? clone$1 : source;
|
|
136
|
-
}
|
|
157
|
+
if (Array.isArray(source)) return normalizeNestedDelegatedStructuredState(source, seen);
|
|
137
158
|
const proto = Object.getPrototypeOf(source);
|
|
138
159
|
if (proto !== Object.prototype && proto !== null) return normalized;
|
|
139
|
-
|
|
140
|
-
let changed = false;
|
|
141
|
-
const clone = Object.create(proto);
|
|
142
|
-
const entry = {
|
|
143
|
-
clone,
|
|
144
|
-
finalized: false,
|
|
145
|
-
result: clone
|
|
146
|
-
};
|
|
147
|
-
seen.set(source, entry);
|
|
148
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
149
|
-
const descriptor = descriptors[key];
|
|
150
|
-
if (descriptor != null && "value" in descriptor) {
|
|
151
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
152
|
-
if (nextValue !== descriptor.value) {
|
|
153
|
-
descriptors[key] = {
|
|
154
|
-
...descriptor,
|
|
155
|
-
value: nextValue
|
|
156
|
-
};
|
|
157
|
-
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
entry.finalized = true;
|
|
162
|
-
entry.result = changed ? clone : source;
|
|
163
|
-
if (!changed) return source;
|
|
164
|
-
Object.defineProperties(clone, descriptors);
|
|
165
|
-
return clone;
|
|
160
|
+
return normalizeNestedDelegatedStructuredState(source, seen);
|
|
166
161
|
}
|
|
167
162
|
/**
|
|
168
163
|
* Creates a short-lived delegated state that exposes the parent's annotations
|
package/dist/annotation-state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { annotationKey, getAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
|
|
2
2
|
import { inheritParentAnnotationsKey } from "./parser.js";
|
|
3
3
|
|
|
4
4
|
//#region src/annotation-state.ts
|
|
@@ -92,6 +92,46 @@ function isPendingNestedNormalizationAlias(originalValue, normalizedValue, seen)
|
|
|
92
92
|
const entry = seen.get(originalValue);
|
|
93
93
|
return entry != null && !entry.finalized && entry.clone === normalizedValue;
|
|
94
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
|
+
}
|
|
95
135
|
/**
|
|
96
136
|
* Recursively removes delegated annotation carriers from plain-object and array
|
|
97
137
|
* structures.
|
|
@@ -114,55 +154,10 @@ function normalizeNestedDelegatedAnnotationState(value, seen = /* @__PURE__ */ n
|
|
|
114
154
|
const source = normalized;
|
|
115
155
|
const existing = seen.get(source);
|
|
116
156
|
if (existing != null) return existing.finalized ? existing.result : existing.clone;
|
|
117
|
-
if (Array.isArray(source))
|
|
118
|
-
let changed$1 = false;
|
|
119
|
-
const clone$1 = annotateFreshArray(source, source.slice());
|
|
120
|
-
const entry$1 = {
|
|
121
|
-
clone: clone$1,
|
|
122
|
-
finalized: false,
|
|
123
|
-
result: clone$1
|
|
124
|
-
};
|
|
125
|
-
seen.set(source, entry$1);
|
|
126
|
-
for (let i = 0; i < source.length; i++) {
|
|
127
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(source[i], seen);
|
|
128
|
-
if (nextValue !== source[i]) {
|
|
129
|
-
clone$1[i] = nextValue;
|
|
130
|
-
if (!isPendingNestedNormalizationAlias(source[i], nextValue, seen)) changed$1 = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
entry$1.finalized = true;
|
|
134
|
-
entry$1.result = changed$1 ? clone$1 : source;
|
|
135
|
-
return changed$1 ? clone$1 : source;
|
|
136
|
-
}
|
|
157
|
+
if (Array.isArray(source)) return normalizeNestedDelegatedStructuredState(source, seen);
|
|
137
158
|
const proto = Object.getPrototypeOf(source);
|
|
138
159
|
if (proto !== Object.prototype && proto !== null) return normalized;
|
|
139
|
-
|
|
140
|
-
let changed = false;
|
|
141
|
-
const clone = Object.create(proto);
|
|
142
|
-
const entry = {
|
|
143
|
-
clone,
|
|
144
|
-
finalized: false,
|
|
145
|
-
result: clone
|
|
146
|
-
};
|
|
147
|
-
seen.set(source, entry);
|
|
148
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
149
|
-
const descriptor = descriptors[key];
|
|
150
|
-
if (descriptor != null && "value" in descriptor) {
|
|
151
|
-
const nextValue = normalizeNestedDelegatedAnnotationState(descriptor.value, seen);
|
|
152
|
-
if (nextValue !== descriptor.value) {
|
|
153
|
-
descriptors[key] = {
|
|
154
|
-
...descriptor,
|
|
155
|
-
value: nextValue
|
|
156
|
-
};
|
|
157
|
-
if (!isPendingNestedNormalizationAlias(descriptor.value, nextValue, seen)) changed = true;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
entry.finalized = true;
|
|
162
|
-
entry.result = changed ? clone : source;
|
|
163
|
-
if (!changed) return source;
|
|
164
|
-
Object.defineProperties(clone, descriptors);
|
|
165
|
-
return clone;
|
|
160
|
+
return normalizeNestedDelegatedStructuredState(source, seen);
|
|
166
161
|
}
|
|
167
162
|
/**
|
|
168
163
|
* Creates a short-lived delegated state that exposes the parent's annotations
|