@optique/core 1.0.0-dev.1842 → 1.0.0-dev.1846
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 +52 -29
- package/dist/annotations.js +52 -29
- 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();
|
|
@@ -241,6 +254,16 @@ function createProtectedURLSearchParamsView(target) {
|
|
|
241
254
|
const view = new Proxy(target, {
|
|
242
255
|
get(target$1, key) {
|
|
243
256
|
if (key === "append" || key === "delete" || key === "set" || key === "sort") return cacheProtectedMethod(methodCache, key, () => (..._args) => throwReadonlyAnnotationMutation());
|
|
257
|
+
if (key === "forEach") return cacheProtectedMethod(methodCache, key, () => (callback, thisArg) => target$1.forEach((value$1, name) => {
|
|
258
|
+
callback.call(thisArg, value$1, name, view);
|
|
259
|
+
}));
|
|
260
|
+
if (key === "keys" || key === "values") return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
261
|
+
const iterator = key === "keys" ? target$1.keys() : target$1.values();
|
|
262
|
+
for (const value$1 of iterator) yield value$1;
|
|
263
|
+
});
|
|
264
|
+
if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
265
|
+
for (const entry of target$1.entries()) yield entry;
|
|
266
|
+
});
|
|
244
267
|
const value = Reflect.get(target$1, key, target$1);
|
|
245
268
|
return typeof value === "function" ? value.bind(target$1) : value;
|
|
246
269
|
},
|
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();
|
|
@@ -240,6 +253,16 @@ function createProtectedURLSearchParamsView(target) {
|
|
|
240
253
|
const view = new Proxy(target, {
|
|
241
254
|
get(target$1, key) {
|
|
242
255
|
if (key === "append" || key === "delete" || key === "set" || key === "sort") return cacheProtectedMethod(methodCache, key, () => (..._args) => throwReadonlyAnnotationMutation());
|
|
256
|
+
if (key === "forEach") return cacheProtectedMethod(methodCache, key, () => (callback, thisArg) => target$1.forEach((value$1, name) => {
|
|
257
|
+
callback.call(thisArg, value$1, name, view);
|
|
258
|
+
}));
|
|
259
|
+
if (key === "keys" || key === "values") return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
260
|
+
const iterator = key === "keys" ? target$1.keys() : target$1.values();
|
|
261
|
+
for (const value$1 of iterator) yield value$1;
|
|
262
|
+
});
|
|
263
|
+
if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache, key, () => function* () {
|
|
264
|
+
for (const entry of target$1.entries()) yield entry;
|
|
265
|
+
});
|
|
243
266
|
const value = Reflect.get(target$1, key, target$1);
|
|
244
267
|
return typeof value === "function" ? value.bind(target$1) : value;
|
|
245
268
|
},
|