@optique/core 1.0.0-dev.1842 → 1.0.0-dev.1848
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/annotations.cjs +58 -33
- package/dist/annotations.js +58 -33
- package/package.json +1 -1
package/dist/annotations.cjs
CHANGED
|
@@ -69,38 +69,51 @@ function cacheProtectedMethod(cache, key, factory) {
|
|
|
69
69
|
cache.set(key, created);
|
|
70
70
|
return created;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
function defineProtectedDataProperty(target, key, descriptor) {
|
|
73
|
+
const value = protectAnnotationValue(descriptor.value);
|
|
74
|
+
Object.defineProperty(target, key, {
|
|
75
|
+
configurable: descriptor.configurable,
|
|
76
|
+
enumerable: descriptor.enumerable,
|
|
77
|
+
get: () => value,
|
|
78
|
+
set: () => throwReadonlyAnnotationMutation()
|
|
79
|
+
});
|
|
78
80
|
}
|
|
79
81
|
function createProtectedObjectView(target) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
preventExtensions() {
|
|
97
|
-
throwReadonlyAnnotationMutation();
|
|
98
|
-
},
|
|
99
|
-
getOwnPropertyDescriptor(target$1, key) {
|
|
100
|
-
return protectDescriptor(Reflect.getOwnPropertyDescriptor(target$1, key));
|
|
82
|
+
if (Array.isArray(target)) {
|
|
83
|
+
const view$1 = new Array(target.length);
|
|
84
|
+
for (const key of Reflect.ownKeys(target)) {
|
|
85
|
+
if (key === "length") continue;
|
|
86
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
87
|
+
if (descriptor == null) continue;
|
|
88
|
+
if ("value" in descriptor) {
|
|
89
|
+
defineProtectedDataProperty(view$1, key, descriptor);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
Object.defineProperty(view$1, key, {
|
|
93
|
+
configurable: descriptor.configurable,
|
|
94
|
+
enumerable: descriptor.enumerable,
|
|
95
|
+
get: descriptor.get == null ? void 0 : () => protectAnnotationValue(descriptor.get.call(target)),
|
|
96
|
+
set: () => throwReadonlyAnnotationMutation()
|
|
97
|
+
});
|
|
101
98
|
}
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
return registerProtectedAnnotationView(target, Object.freeze(view$1));
|
|
100
|
+
}
|
|
101
|
+
const view = Object.create(Object.getPrototypeOf(target));
|
|
102
|
+
for (const key of Reflect.ownKeys(target)) {
|
|
103
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
104
|
+
if (descriptor == null) continue;
|
|
105
|
+
if ("value" in descriptor) {
|
|
106
|
+
defineProtectedDataProperty(view, key, descriptor);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
Object.defineProperty(view, key, {
|
|
110
|
+
configurable: descriptor.configurable,
|
|
111
|
+
enumerable: descriptor.enumerable,
|
|
112
|
+
get: descriptor.get == null ? void 0 : () => protectAnnotationValue(descriptor.get.call(target)),
|
|
113
|
+
set: () => throwReadonlyAnnotationMutation()
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return registerProtectedAnnotationView(target, Object.freeze(view));
|
|
104
117
|
}
|
|
105
118
|
function createProtectedMapView(target) {
|
|
106
119
|
const methodCache = /* @__PURE__ */ new Map();
|
|
@@ -212,11 +225,13 @@ function createProtectedDateView(target) {
|
|
|
212
225
|
}
|
|
213
226
|
function createProtectedRegExpView(target) {
|
|
214
227
|
const methodCache = /* @__PURE__ */ new Map();
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
228
|
+
const cloned = new RegExp(target);
|
|
229
|
+
cloned.lastIndex = target.lastIndex;
|
|
230
|
+
const view = new Proxy(cloned, {
|
|
231
|
+
get(clonedTarget, key) {
|
|
232
|
+
const value = Reflect.get(clonedTarget, key, clonedTarget);
|
|
218
233
|
if (key === "compile") return cacheProtectedMethod(methodCache, key, () => (..._args) => throwReadonlyAnnotationMutation());
|
|
219
|
-
return typeof value === "function" ? value.bind(
|
|
234
|
+
return typeof value === "function" ? value.bind(clonedTarget) : value;
|
|
220
235
|
},
|
|
221
236
|
set() {
|
|
222
237
|
throwReadonlyAnnotationMutation();
|
|
@@ -241,6 +256,16 @@ function createProtectedURLSearchParamsView(target) {
|
|
|
241
256
|
const view = new Proxy(target, {
|
|
242
257
|
get(target$1, key) {
|
|
243
258
|
if (key === "append" || key === "delete" || key === "set" || key === "sort") return cacheProtectedMethod(methodCache, key, () => (..._args) => throwReadonlyAnnotationMutation());
|
|
259
|
+
if (key === "forEach") return cacheProtectedMethod(methodCache, key, () => (callback, thisArg) => target$1.forEach((value$1, name) => {
|
|
260
|
+
callback.call(thisArg, value$1, name, view);
|
|
261
|
+
}));
|
|
262
|
+
if (key === "keys" || key === "values") return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
263
|
+
const iterator = key === "keys" ? target$1.keys() : target$1.values();
|
|
264
|
+
for (const value$1 of iterator) yield value$1;
|
|
265
|
+
});
|
|
266
|
+
if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
267
|
+
for (const entry of target$1.entries()) yield entry;
|
|
268
|
+
});
|
|
244
269
|
const value = Reflect.get(target$1, key, target$1);
|
|
245
270
|
return typeof value === "function" ? value.bind(target$1) : value;
|
|
246
271
|
},
|
package/dist/annotations.js
CHANGED
|
@@ -68,38 +68,51 @@ function cacheProtectedMethod(cache, key, factory) {
|
|
|
68
68
|
cache.set(key, created);
|
|
69
69
|
return created;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
function defineProtectedDataProperty(target, key, descriptor) {
|
|
72
|
+
const value = protectAnnotationValue(descriptor.value);
|
|
73
|
+
Object.defineProperty(target, key, {
|
|
74
|
+
configurable: descriptor.configurable,
|
|
75
|
+
enumerable: descriptor.enumerable,
|
|
76
|
+
get: () => value,
|
|
77
|
+
set: () => throwReadonlyAnnotationMutation()
|
|
78
|
+
});
|
|
77
79
|
}
|
|
78
80
|
function createProtectedObjectView(target) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
preventExtensions() {
|
|
96
|
-
throwReadonlyAnnotationMutation();
|
|
97
|
-
},
|
|
98
|
-
getOwnPropertyDescriptor(target$1, key) {
|
|
99
|
-
return protectDescriptor(Reflect.getOwnPropertyDescriptor(target$1, key));
|
|
81
|
+
if (Array.isArray(target)) {
|
|
82
|
+
const view$1 = new Array(target.length);
|
|
83
|
+
for (const key of Reflect.ownKeys(target)) {
|
|
84
|
+
if (key === "length") continue;
|
|
85
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
86
|
+
if (descriptor == null) continue;
|
|
87
|
+
if ("value" in descriptor) {
|
|
88
|
+
defineProtectedDataProperty(view$1, key, descriptor);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
Object.defineProperty(view$1, key, {
|
|
92
|
+
configurable: descriptor.configurable,
|
|
93
|
+
enumerable: descriptor.enumerable,
|
|
94
|
+
get: descriptor.get == null ? void 0 : () => protectAnnotationValue(descriptor.get.call(target)),
|
|
95
|
+
set: () => throwReadonlyAnnotationMutation()
|
|
96
|
+
});
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
return registerProtectedAnnotationView(target, Object.freeze(view$1));
|
|
99
|
+
}
|
|
100
|
+
const view = Object.create(Object.getPrototypeOf(target));
|
|
101
|
+
for (const key of Reflect.ownKeys(target)) {
|
|
102
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
103
|
+
if (descriptor == null) continue;
|
|
104
|
+
if ("value" in descriptor) {
|
|
105
|
+
defineProtectedDataProperty(view, key, descriptor);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
Object.defineProperty(view, key, {
|
|
109
|
+
configurable: descriptor.configurable,
|
|
110
|
+
enumerable: descriptor.enumerable,
|
|
111
|
+
get: descriptor.get == null ? void 0 : () => protectAnnotationValue(descriptor.get.call(target)),
|
|
112
|
+
set: () => throwReadonlyAnnotationMutation()
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return registerProtectedAnnotationView(target, Object.freeze(view));
|
|
103
116
|
}
|
|
104
117
|
function createProtectedMapView(target) {
|
|
105
118
|
const methodCache = /* @__PURE__ */ new Map();
|
|
@@ -211,11 +224,13 @@ function createProtectedDateView(target) {
|
|
|
211
224
|
}
|
|
212
225
|
function createProtectedRegExpView(target) {
|
|
213
226
|
const methodCache = /* @__PURE__ */ new Map();
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
227
|
+
const cloned = new RegExp(target);
|
|
228
|
+
cloned.lastIndex = target.lastIndex;
|
|
229
|
+
const view = new Proxy(cloned, {
|
|
230
|
+
get(clonedTarget, key) {
|
|
231
|
+
const value = Reflect.get(clonedTarget, key, clonedTarget);
|
|
217
232
|
if (key === "compile") return cacheProtectedMethod(methodCache, key, () => (..._args) => throwReadonlyAnnotationMutation());
|
|
218
|
-
return typeof value === "function" ? value.bind(
|
|
233
|
+
return typeof value === "function" ? value.bind(clonedTarget) : value;
|
|
219
234
|
},
|
|
220
235
|
set() {
|
|
221
236
|
throwReadonlyAnnotationMutation();
|
|
@@ -240,6 +255,16 @@ function createProtectedURLSearchParamsView(target) {
|
|
|
240
255
|
const view = new Proxy(target, {
|
|
241
256
|
get(target$1, key) {
|
|
242
257
|
if (key === "append" || key === "delete" || key === "set" || key === "sort") return cacheProtectedMethod(methodCache, key, () => (..._args) => throwReadonlyAnnotationMutation());
|
|
258
|
+
if (key === "forEach") return cacheProtectedMethod(methodCache, key, () => (callback, thisArg) => target$1.forEach((value$1, name) => {
|
|
259
|
+
callback.call(thisArg, value$1, name, view);
|
|
260
|
+
}));
|
|
261
|
+
if (key === "keys" || key === "values") return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
262
|
+
const iterator = key === "keys" ? target$1.keys() : target$1.values();
|
|
263
|
+
for (const value$1 of iterator) yield value$1;
|
|
264
|
+
});
|
|
265
|
+
if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
266
|
+
for (const entry of target$1.entries()) yield entry;
|
|
267
|
+
});
|
|
243
268
|
const value = Reflect.get(target$1, key, target$1);
|
|
244
269
|
return typeof value === "function" ? value.bind(target$1) : value;
|
|
245
270
|
},
|