@optique/core 1.0.0-dev.1864 → 1.0.0-dev.1866

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.
@@ -107,6 +107,52 @@ function copyOwnProperties(source, target, transformValue, excludedKeys) {
107
107
  function normalizeProtectedCollectionItem(value, context) {
108
108
  return context.rewrapProtectedViews && isProtectedAnnotationView(value) ? unwrapProtectedAnnotationTarget(value) : value;
109
109
  }
110
+ function getProtectedProxyFallbackValue(target, key, context) {
111
+ const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, key);
112
+ if (ownDescriptor != null && "value" in ownDescriptor) {
113
+ if (ownDescriptor.configurable === false && ownDescriptor.writable === false) return ownDescriptor.value;
114
+ const value$1 = ownDescriptor.value;
115
+ return typeof value$1 === "function" ? value$1.bind(target) : protectAnnotationValue(value$1, context);
116
+ }
117
+ const value = Reflect.get(target, key, target);
118
+ return typeof value === "function" ? value.bind(target) : protectAnnotationValue(value, context);
119
+ }
120
+ function getProtectedProxyOwnPropertyDescriptor(target, key, context) {
121
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, key);
122
+ if (descriptor == null || !("value" in descriptor)) return descriptor;
123
+ if (descriptor.configurable === false && descriptor.writable === false) return descriptor;
124
+ const value = protectAnnotationValue(descriptor.value, context);
125
+ return value === descriptor.value ? descriptor : {
126
+ ...descriptor,
127
+ value
128
+ };
129
+ }
130
+ function resolveProtectedMapLookup(target, lookup) {
131
+ if (target.has(lookup)) return {
132
+ found: true,
133
+ value: target.get(lookup)
134
+ };
135
+ const rawLookup = unwrapProtectedAnnotationTarget(lookup);
136
+ if (rawLookup !== lookup && target.has(rawLookup)) return {
137
+ found: true,
138
+ value: target.get(rawLookup)
139
+ };
140
+ for (const [entryKey, entryValue] of target.entries()) if (unwrapProtectedAnnotationTarget(entryKey) === rawLookup) return {
141
+ found: true,
142
+ value: entryValue
143
+ };
144
+ return { found: false };
145
+ }
146
+ function hasProtectedSetLookup(target, lookup) {
147
+ if (target.has(lookup)) return true;
148
+ const rawLookup = unwrapProtectedAnnotationTarget(lookup);
149
+ if (rawLookup !== lookup && target.has(rawLookup)) return true;
150
+ for (const value of target.values()) if (unwrapProtectedAnnotationTarget(value) === rawLookup) return true;
151
+ return false;
152
+ }
153
+ function usesSubclassProxyFallback(target, basePrototype) {
154
+ return Object.getPrototypeOf(target) !== basePrototype;
155
+ }
110
156
  const regExpExcludedKeys = new Set(["lastIndex"]);
111
157
  function copyRegExpMetadata(source, target, transformValue) {
112
158
  copyOwnProperties(source, target, transformValue, regExpExcludedKeys);
@@ -158,6 +204,53 @@ function createProtectedObjectView(target, context) {
158
204
  return Object.freeze(view);
159
205
  }
160
206
  function createProtectedMapView(target, context) {
207
+ if (usesSubclassProxyFallback(target, Map.prototype)) {
208
+ const methodCache$1 = /* @__PURE__ */ new Map();
209
+ const view$1 = new Proxy(target, {
210
+ get(target$1, key) {
211
+ if (key === "size") return target$1.size;
212
+ if (key === "valueOf") return cacheProtectedMethod(methodCache$1, key, () => () => view$1);
213
+ if (key === "set" || key === "delete" || key === "clear") return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
214
+ if (key === "get") return cacheProtectedMethod(methodCache$1, key, () => (lookup) => {
215
+ const resolved = resolveProtectedMapLookup(target$1, lookup);
216
+ return resolved.found ? protectAnnotationValue(resolved.value, context) : void 0;
217
+ });
218
+ if (key === "has") return cacheProtectedMethod(methodCache$1, key, () => (lookup) => resolveProtectedMapLookup(target$1, lookup).found);
219
+ if (key === "forEach") return cacheProtectedMethod(methodCache$1, key, () => (callback, thisArg) => target$1.forEach((value, mapKey) => {
220
+ callback.call(thisArg, protectAnnotationValue(value, context), protectAnnotationValue(mapKey, context), view$1);
221
+ }));
222
+ if (key === "keys") return cacheProtectedMethod(methodCache$1, key, () => function* () {
223
+ for (const value of target$1.keys()) yield protectAnnotationValue(value, context);
224
+ });
225
+ if (key === "values") return cacheProtectedMethod(methodCache$1, key, () => function* () {
226
+ for (const value of target$1.values()) yield protectAnnotationValue(value, context);
227
+ });
228
+ if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache$1, key, () => function* () {
229
+ for (const [entryKey, entryValue] of target$1.entries()) yield [protectAnnotationValue(entryKey, context), protectAnnotationValue(entryValue, context)];
230
+ });
231
+ return getProtectedProxyFallbackValue(target$1, key, context);
232
+ },
233
+ getOwnPropertyDescriptor(target$1, key) {
234
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
235
+ },
236
+ set() {
237
+ throwReadonlyAnnotationMutation();
238
+ },
239
+ defineProperty() {
240
+ throwReadonlyAnnotationMutation();
241
+ },
242
+ deleteProperty() {
243
+ throwReadonlyAnnotationMutation();
244
+ },
245
+ setPrototypeOf() {
246
+ throwReadonlyAnnotationMutation();
247
+ },
248
+ preventExtensions() {
249
+ throwReadonlyAnnotationMutation();
250
+ }
251
+ });
252
+ return registerProtectedAnnotationView(context, target, view$1);
253
+ }
161
254
  const methodCache = /* @__PURE__ */ new Map();
162
255
  const cloned = /* @__PURE__ */ new Map();
163
256
  for (const [entryKey, entryValue] of target.entries()) cloned.set(normalizeProtectedCollectionItem(entryKey, context), normalizeProtectedCollectionItem(entryValue, context));
@@ -208,6 +301,50 @@ function createProtectedMapView(target, context) {
208
301
  return view;
209
302
  }
210
303
  function createProtectedSetView(target, context) {
304
+ if (usesSubclassProxyFallback(target, Set.prototype)) {
305
+ const methodCache$1 = /* @__PURE__ */ new Map();
306
+ const view$1 = new Proxy(target, {
307
+ get(target$1, key) {
308
+ if (key === "size") return target$1.size;
309
+ if (key === "valueOf") return cacheProtectedMethod(methodCache$1, key, () => () => view$1);
310
+ if (key === "add" || key === "delete" || key === "clear") return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
311
+ if (key === "has") return cacheProtectedMethod(methodCache$1, key, () => (lookup) => hasProtectedSetLookup(target$1, lookup));
312
+ if (key === "forEach") return cacheProtectedMethod(methodCache$1, key, () => (callback, thisArg) => target$1.forEach((value) => {
313
+ const protectedValue = protectAnnotationValue(value, context);
314
+ callback.call(thisArg, protectedValue, protectedValue, view$1);
315
+ }));
316
+ if (key === "keys" || key === "values" || key === Symbol.iterator) return cacheProtectedMethod(methodCache$1, key, () => function* () {
317
+ for (const value of target$1.values()) yield protectAnnotationValue(value, context);
318
+ });
319
+ if (key === "entries") return cacheProtectedMethod(methodCache$1, key, () => function* () {
320
+ for (const value of target$1.values()) {
321
+ const protectedValue = protectAnnotationValue(value, context);
322
+ yield [protectedValue, protectedValue];
323
+ }
324
+ });
325
+ return getProtectedProxyFallbackValue(target$1, key, context);
326
+ },
327
+ getOwnPropertyDescriptor(target$1, key) {
328
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
329
+ },
330
+ set() {
331
+ throwReadonlyAnnotationMutation();
332
+ },
333
+ defineProperty() {
334
+ throwReadonlyAnnotationMutation();
335
+ },
336
+ deleteProperty() {
337
+ throwReadonlyAnnotationMutation();
338
+ },
339
+ setPrototypeOf() {
340
+ throwReadonlyAnnotationMutation();
341
+ },
342
+ preventExtensions() {
343
+ throwReadonlyAnnotationMutation();
344
+ }
345
+ });
346
+ return registerProtectedAnnotationView(context, target, view$1);
347
+ }
211
348
  const methodCache = /* @__PURE__ */ new Map();
212
349
  const cloned = /* @__PURE__ */ new Set();
213
350
  for (const value of target.values()) cloned.add(normalizeProtectedCollectionItem(value, context));
@@ -255,6 +392,34 @@ function createProtectedSetView(target, context) {
255
392
  return view;
256
393
  }
257
394
  function createProtectedDateView(target, context) {
395
+ if (usesSubclassProxyFallback(target, Date.prototype)) {
396
+ const methodCache$1 = /* @__PURE__ */ new Map();
397
+ const view$1 = new Proxy(target, {
398
+ get(target$1, key) {
399
+ if (typeof key === "string" && key.startsWith("set")) return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
400
+ return getProtectedProxyFallbackValue(target$1, key, context);
401
+ },
402
+ getOwnPropertyDescriptor(target$1, key) {
403
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
404
+ },
405
+ set() {
406
+ throwReadonlyAnnotationMutation();
407
+ },
408
+ defineProperty() {
409
+ throwReadonlyAnnotationMutation();
410
+ },
411
+ deleteProperty() {
412
+ throwReadonlyAnnotationMutation();
413
+ },
414
+ setPrototypeOf() {
415
+ throwReadonlyAnnotationMutation();
416
+ },
417
+ preventExtensions() {
418
+ throwReadonlyAnnotationMutation();
419
+ }
420
+ });
421
+ return registerProtectedAnnotationView(context, target, view$1);
422
+ }
258
423
  const methodCache = /* @__PURE__ */ new Map();
259
424
  const cloned = new Date(target.getTime());
260
425
  const view = new Proxy(cloned, {
@@ -318,6 +483,45 @@ function createProtectedRegExpView(target, context) {
318
483
  return view;
319
484
  }
320
485
  function createProtectedURLSearchParamsView(target, context) {
486
+ if (usesSubclassProxyFallback(target, URLSearchParams.prototype)) {
487
+ const methodCache$1 = /* @__PURE__ */ new Map();
488
+ const view$1 = new Proxy(target, {
489
+ get(target$1, key) {
490
+ if (key === "append" || key === "delete" || key === "set" || key === "sort") return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
491
+ if (key === "valueOf") return cacheProtectedMethod(methodCache$1, key, () => () => view$1);
492
+ if (key === "forEach") return cacheProtectedMethod(methodCache$1, key, () => (callback, thisArg) => target$1.forEach((value, name) => {
493
+ callback.call(thisArg, value, name, view$1);
494
+ }));
495
+ if (key === "keys" || key === "values") return cacheProtectedMethod(methodCache$1, key, () => function* () {
496
+ const iterator = key === "keys" ? target$1.keys() : target$1.values();
497
+ for (const value of iterator) yield value;
498
+ });
499
+ if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache$1, key, () => function* () {
500
+ for (const entry of target$1.entries()) yield entry;
501
+ });
502
+ return getProtectedProxyFallbackValue(target$1, key, context);
503
+ },
504
+ getOwnPropertyDescriptor(target$1, key) {
505
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
506
+ },
507
+ set() {
508
+ throwReadonlyAnnotationMutation();
509
+ },
510
+ defineProperty() {
511
+ throwReadonlyAnnotationMutation();
512
+ },
513
+ deleteProperty() {
514
+ throwReadonlyAnnotationMutation();
515
+ },
516
+ setPrototypeOf() {
517
+ throwReadonlyAnnotationMutation();
518
+ },
519
+ preventExtensions() {
520
+ throwReadonlyAnnotationMutation();
521
+ }
522
+ });
523
+ return registerProtectedAnnotationView(context, target, view$1);
524
+ }
321
525
  const methodCache = /* @__PURE__ */ new Map();
322
526
  const cloned = new URLSearchParams(target);
323
527
  const view = new Proxy(cloned, {
@@ -359,6 +563,35 @@ function createProtectedURLSearchParamsView(target, context) {
359
563
  return view;
360
564
  }
361
565
  function createProtectedURLView(target, context) {
566
+ if (usesSubclassProxyFallback(target, URL.prototype)) {
567
+ const methodCache = /* @__PURE__ */ new Map();
568
+ const view$1 = new Proxy(target, {
569
+ get(target$1, key) {
570
+ if (key === "valueOf") return cacheProtectedMethod(methodCache, key, () => () => view$1);
571
+ if (key === "searchParams") return protectAnnotationValue(target$1.searchParams, context);
572
+ return getProtectedProxyFallbackValue(target$1, key, context);
573
+ },
574
+ getOwnPropertyDescriptor(target$1, key) {
575
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
576
+ },
577
+ set() {
578
+ throwReadonlyAnnotationMutation();
579
+ },
580
+ defineProperty() {
581
+ throwReadonlyAnnotationMutation();
582
+ },
583
+ deleteProperty() {
584
+ throwReadonlyAnnotationMutation();
585
+ },
586
+ setPrototypeOf() {
587
+ throwReadonlyAnnotationMutation();
588
+ },
589
+ preventExtensions() {
590
+ throwReadonlyAnnotationMutation();
591
+ }
592
+ });
593
+ return registerProtectedAnnotationView(context, target, view$1);
594
+ }
362
595
  const cloned = new URL(target.href);
363
596
  const view = new Proxy(cloned, {
364
597
  get(clonedTarget, key) {
@@ -106,6 +106,52 @@ function copyOwnProperties(source, target, transformValue, excludedKeys) {
106
106
  function normalizeProtectedCollectionItem(value, context) {
107
107
  return context.rewrapProtectedViews && isProtectedAnnotationView(value) ? unwrapProtectedAnnotationTarget(value) : value;
108
108
  }
109
+ function getProtectedProxyFallbackValue(target, key, context) {
110
+ const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, key);
111
+ if (ownDescriptor != null && "value" in ownDescriptor) {
112
+ if (ownDescriptor.configurable === false && ownDescriptor.writable === false) return ownDescriptor.value;
113
+ const value$1 = ownDescriptor.value;
114
+ return typeof value$1 === "function" ? value$1.bind(target) : protectAnnotationValue(value$1, context);
115
+ }
116
+ const value = Reflect.get(target, key, target);
117
+ return typeof value === "function" ? value.bind(target) : protectAnnotationValue(value, context);
118
+ }
119
+ function getProtectedProxyOwnPropertyDescriptor(target, key, context) {
120
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, key);
121
+ if (descriptor == null || !("value" in descriptor)) return descriptor;
122
+ if (descriptor.configurable === false && descriptor.writable === false) return descriptor;
123
+ const value = protectAnnotationValue(descriptor.value, context);
124
+ return value === descriptor.value ? descriptor : {
125
+ ...descriptor,
126
+ value
127
+ };
128
+ }
129
+ function resolveProtectedMapLookup(target, lookup) {
130
+ if (target.has(lookup)) return {
131
+ found: true,
132
+ value: target.get(lookup)
133
+ };
134
+ const rawLookup = unwrapProtectedAnnotationTarget(lookup);
135
+ if (rawLookup !== lookup && target.has(rawLookup)) return {
136
+ found: true,
137
+ value: target.get(rawLookup)
138
+ };
139
+ for (const [entryKey, entryValue] of target.entries()) if (unwrapProtectedAnnotationTarget(entryKey) === rawLookup) return {
140
+ found: true,
141
+ value: entryValue
142
+ };
143
+ return { found: false };
144
+ }
145
+ function hasProtectedSetLookup(target, lookup) {
146
+ if (target.has(lookup)) return true;
147
+ const rawLookup = unwrapProtectedAnnotationTarget(lookup);
148
+ if (rawLookup !== lookup && target.has(rawLookup)) return true;
149
+ for (const value of target.values()) if (unwrapProtectedAnnotationTarget(value) === rawLookup) return true;
150
+ return false;
151
+ }
152
+ function usesSubclassProxyFallback(target, basePrototype) {
153
+ return Object.getPrototypeOf(target) !== basePrototype;
154
+ }
109
155
  const regExpExcludedKeys = new Set(["lastIndex"]);
110
156
  function copyRegExpMetadata(source, target, transformValue) {
111
157
  copyOwnProperties(source, target, transformValue, regExpExcludedKeys);
@@ -157,6 +203,53 @@ function createProtectedObjectView(target, context) {
157
203
  return Object.freeze(view);
158
204
  }
159
205
  function createProtectedMapView(target, context) {
206
+ if (usesSubclassProxyFallback(target, Map.prototype)) {
207
+ const methodCache$1 = /* @__PURE__ */ new Map();
208
+ const view$1 = new Proxy(target, {
209
+ get(target$1, key) {
210
+ if (key === "size") return target$1.size;
211
+ if (key === "valueOf") return cacheProtectedMethod(methodCache$1, key, () => () => view$1);
212
+ if (key === "set" || key === "delete" || key === "clear") return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
213
+ if (key === "get") return cacheProtectedMethod(methodCache$1, key, () => (lookup) => {
214
+ const resolved = resolveProtectedMapLookup(target$1, lookup);
215
+ return resolved.found ? protectAnnotationValue(resolved.value, context) : void 0;
216
+ });
217
+ if (key === "has") return cacheProtectedMethod(methodCache$1, key, () => (lookup) => resolveProtectedMapLookup(target$1, lookup).found);
218
+ if (key === "forEach") return cacheProtectedMethod(methodCache$1, key, () => (callback, thisArg) => target$1.forEach((value, mapKey) => {
219
+ callback.call(thisArg, protectAnnotationValue(value, context), protectAnnotationValue(mapKey, context), view$1);
220
+ }));
221
+ if (key === "keys") return cacheProtectedMethod(methodCache$1, key, () => function* () {
222
+ for (const value of target$1.keys()) yield protectAnnotationValue(value, context);
223
+ });
224
+ if (key === "values") return cacheProtectedMethod(methodCache$1, key, () => function* () {
225
+ for (const value of target$1.values()) yield protectAnnotationValue(value, context);
226
+ });
227
+ if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache$1, key, () => function* () {
228
+ for (const [entryKey, entryValue] of target$1.entries()) yield [protectAnnotationValue(entryKey, context), protectAnnotationValue(entryValue, context)];
229
+ });
230
+ return getProtectedProxyFallbackValue(target$1, key, context);
231
+ },
232
+ getOwnPropertyDescriptor(target$1, key) {
233
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
234
+ },
235
+ set() {
236
+ throwReadonlyAnnotationMutation();
237
+ },
238
+ defineProperty() {
239
+ throwReadonlyAnnotationMutation();
240
+ },
241
+ deleteProperty() {
242
+ throwReadonlyAnnotationMutation();
243
+ },
244
+ setPrototypeOf() {
245
+ throwReadonlyAnnotationMutation();
246
+ },
247
+ preventExtensions() {
248
+ throwReadonlyAnnotationMutation();
249
+ }
250
+ });
251
+ return registerProtectedAnnotationView(context, target, view$1);
252
+ }
160
253
  const methodCache = /* @__PURE__ */ new Map();
161
254
  const cloned = /* @__PURE__ */ new Map();
162
255
  for (const [entryKey, entryValue] of target.entries()) cloned.set(normalizeProtectedCollectionItem(entryKey, context), normalizeProtectedCollectionItem(entryValue, context));
@@ -207,6 +300,50 @@ function createProtectedMapView(target, context) {
207
300
  return view;
208
301
  }
209
302
  function createProtectedSetView(target, context) {
303
+ if (usesSubclassProxyFallback(target, Set.prototype)) {
304
+ const methodCache$1 = /* @__PURE__ */ new Map();
305
+ const view$1 = new Proxy(target, {
306
+ get(target$1, key) {
307
+ if (key === "size") return target$1.size;
308
+ if (key === "valueOf") return cacheProtectedMethod(methodCache$1, key, () => () => view$1);
309
+ if (key === "add" || key === "delete" || key === "clear") return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
310
+ if (key === "has") return cacheProtectedMethod(methodCache$1, key, () => (lookup) => hasProtectedSetLookup(target$1, lookup));
311
+ if (key === "forEach") return cacheProtectedMethod(methodCache$1, key, () => (callback, thisArg) => target$1.forEach((value) => {
312
+ const protectedValue = protectAnnotationValue(value, context);
313
+ callback.call(thisArg, protectedValue, protectedValue, view$1);
314
+ }));
315
+ if (key === "keys" || key === "values" || key === Symbol.iterator) return cacheProtectedMethod(methodCache$1, key, () => function* () {
316
+ for (const value of target$1.values()) yield protectAnnotationValue(value, context);
317
+ });
318
+ if (key === "entries") return cacheProtectedMethod(methodCache$1, key, () => function* () {
319
+ for (const value of target$1.values()) {
320
+ const protectedValue = protectAnnotationValue(value, context);
321
+ yield [protectedValue, protectedValue];
322
+ }
323
+ });
324
+ return getProtectedProxyFallbackValue(target$1, key, context);
325
+ },
326
+ getOwnPropertyDescriptor(target$1, key) {
327
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
328
+ },
329
+ set() {
330
+ throwReadonlyAnnotationMutation();
331
+ },
332
+ defineProperty() {
333
+ throwReadonlyAnnotationMutation();
334
+ },
335
+ deleteProperty() {
336
+ throwReadonlyAnnotationMutation();
337
+ },
338
+ setPrototypeOf() {
339
+ throwReadonlyAnnotationMutation();
340
+ },
341
+ preventExtensions() {
342
+ throwReadonlyAnnotationMutation();
343
+ }
344
+ });
345
+ return registerProtectedAnnotationView(context, target, view$1);
346
+ }
210
347
  const methodCache = /* @__PURE__ */ new Map();
211
348
  const cloned = /* @__PURE__ */ new Set();
212
349
  for (const value of target.values()) cloned.add(normalizeProtectedCollectionItem(value, context));
@@ -254,6 +391,34 @@ function createProtectedSetView(target, context) {
254
391
  return view;
255
392
  }
256
393
  function createProtectedDateView(target, context) {
394
+ if (usesSubclassProxyFallback(target, Date.prototype)) {
395
+ const methodCache$1 = /* @__PURE__ */ new Map();
396
+ const view$1 = new Proxy(target, {
397
+ get(target$1, key) {
398
+ if (typeof key === "string" && key.startsWith("set")) return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
399
+ return getProtectedProxyFallbackValue(target$1, key, context);
400
+ },
401
+ getOwnPropertyDescriptor(target$1, key) {
402
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
403
+ },
404
+ set() {
405
+ throwReadonlyAnnotationMutation();
406
+ },
407
+ defineProperty() {
408
+ throwReadonlyAnnotationMutation();
409
+ },
410
+ deleteProperty() {
411
+ throwReadonlyAnnotationMutation();
412
+ },
413
+ setPrototypeOf() {
414
+ throwReadonlyAnnotationMutation();
415
+ },
416
+ preventExtensions() {
417
+ throwReadonlyAnnotationMutation();
418
+ }
419
+ });
420
+ return registerProtectedAnnotationView(context, target, view$1);
421
+ }
257
422
  const methodCache = /* @__PURE__ */ new Map();
258
423
  const cloned = new Date(target.getTime());
259
424
  const view = new Proxy(cloned, {
@@ -317,6 +482,45 @@ function createProtectedRegExpView(target, context) {
317
482
  return view;
318
483
  }
319
484
  function createProtectedURLSearchParamsView(target, context) {
485
+ if (usesSubclassProxyFallback(target, URLSearchParams.prototype)) {
486
+ const methodCache$1 = /* @__PURE__ */ new Map();
487
+ const view$1 = new Proxy(target, {
488
+ get(target$1, key) {
489
+ if (key === "append" || key === "delete" || key === "set" || key === "sort") return cacheProtectedMethod(methodCache$1, key, () => (..._args) => throwReadonlyAnnotationMutation());
490
+ if (key === "valueOf") return cacheProtectedMethod(methodCache$1, key, () => () => view$1);
491
+ if (key === "forEach") return cacheProtectedMethod(methodCache$1, key, () => (callback, thisArg) => target$1.forEach((value, name) => {
492
+ callback.call(thisArg, value, name, view$1);
493
+ }));
494
+ if (key === "keys" || key === "values") return cacheProtectedMethod(methodCache$1, key, () => function* () {
495
+ const iterator = key === "keys" ? target$1.keys() : target$1.values();
496
+ for (const value of iterator) yield value;
497
+ });
498
+ if (key === "entries" || key === Symbol.iterator) return cacheProtectedMethod(methodCache$1, key, () => function* () {
499
+ for (const entry of target$1.entries()) yield entry;
500
+ });
501
+ return getProtectedProxyFallbackValue(target$1, key, context);
502
+ },
503
+ getOwnPropertyDescriptor(target$1, key) {
504
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
505
+ },
506
+ set() {
507
+ throwReadonlyAnnotationMutation();
508
+ },
509
+ defineProperty() {
510
+ throwReadonlyAnnotationMutation();
511
+ },
512
+ deleteProperty() {
513
+ throwReadonlyAnnotationMutation();
514
+ },
515
+ setPrototypeOf() {
516
+ throwReadonlyAnnotationMutation();
517
+ },
518
+ preventExtensions() {
519
+ throwReadonlyAnnotationMutation();
520
+ }
521
+ });
522
+ return registerProtectedAnnotationView(context, target, view$1);
523
+ }
320
524
  const methodCache = /* @__PURE__ */ new Map();
321
525
  const cloned = new URLSearchParams(target);
322
526
  const view = new Proxy(cloned, {
@@ -358,6 +562,35 @@ function createProtectedURLSearchParamsView(target, context) {
358
562
  return view;
359
563
  }
360
564
  function createProtectedURLView(target, context) {
565
+ if (usesSubclassProxyFallback(target, URL.prototype)) {
566
+ const methodCache = /* @__PURE__ */ new Map();
567
+ const view$1 = new Proxy(target, {
568
+ get(target$1, key) {
569
+ if (key === "valueOf") return cacheProtectedMethod(methodCache, key, () => () => view$1);
570
+ if (key === "searchParams") return protectAnnotationValue(target$1.searchParams, context);
571
+ return getProtectedProxyFallbackValue(target$1, key, context);
572
+ },
573
+ getOwnPropertyDescriptor(target$1, key) {
574
+ return getProtectedProxyOwnPropertyDescriptor(target$1, key, context);
575
+ },
576
+ set() {
577
+ throwReadonlyAnnotationMutation();
578
+ },
579
+ defineProperty() {
580
+ throwReadonlyAnnotationMutation();
581
+ },
582
+ deleteProperty() {
583
+ throwReadonlyAnnotationMutation();
584
+ },
585
+ setPrototypeOf() {
586
+ throwReadonlyAnnotationMutation();
587
+ },
588
+ preventExtensions() {
589
+ throwReadonlyAnnotationMutation();
590
+ }
591
+ });
592
+ return registerProtectedAnnotationView(context, target, view$1);
593
+ }
361
594
  const cloned = new URL(target.href);
362
595
  const view = new Proxy(cloned, {
363
596
  get(clonedTarget, key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1864+06db45bf",
3
+ "version": "1.0.0-dev.1866+7ab2516f",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",