@optique/core 1.0.0-dev.1878 → 1.0.0-dev.1882

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.
@@ -79,6 +79,8 @@ function cacheProtectedMethod(cache, key, factory) {
79
79
  return created;
80
80
  }
81
81
  function getProtectedClonePropertyValue(cache, target, key, value, context) {
82
+ const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, key);
83
+ if (ownDescriptor != null && "value" in ownDescriptor && ownDescriptor.configurable === false && ownDescriptor.writable === false) return ownDescriptor.value;
82
84
  if (typeof value !== "function") return protectAnnotationValue(value, context);
83
85
  if (key === "constructor") return value;
84
86
  return cacheProtectedMethod(cache, key, () => value.bind(target));
@@ -528,7 +530,7 @@ function createProtectedURLView(target, context) {
528
530
  const cloned = syncPrototype ? new URL(target.href) : tryCloneURLSubclass(target) ?? new URL(target.href);
529
531
  const view = new Proxy(cloned, {
530
532
  get(clonedTarget, key) {
531
- if (key === "valueOf") return () => view;
533
+ if (key === "valueOf") return cacheProtectedMethod(methodCache, key, () => () => view);
532
534
  if (key === "searchParams") return protectAnnotationValue(clonedTarget.searchParams, context);
533
535
  const value = Reflect.get(clonedTarget, key, clonedTarget);
534
536
  return getProtectedClonePropertyValue(methodCache, clonedTarget, key, value, context);
@@ -78,6 +78,8 @@ function cacheProtectedMethod(cache, key, factory) {
78
78
  return created;
79
79
  }
80
80
  function getProtectedClonePropertyValue(cache, target, key, value, context) {
81
+ const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, key);
82
+ if (ownDescriptor != null && "value" in ownDescriptor && ownDescriptor.configurable === false && ownDescriptor.writable === false) return ownDescriptor.value;
81
83
  if (typeof value !== "function") return protectAnnotationValue(value, context);
82
84
  if (key === "constructor") return value;
83
85
  return cacheProtectedMethod(cache, key, () => value.bind(target));
@@ -527,7 +529,7 @@ function createProtectedURLView(target, context) {
527
529
  const cloned = syncPrototype ? new URL(target.href) : tryCloneURLSubclass(target) ?? new URL(target.href);
528
530
  const view = new Proxy(cloned, {
529
531
  get(clonedTarget, key) {
530
- if (key === "valueOf") return () => view;
532
+ if (key === "valueOf") return cacheProtectedMethod(methodCache, key, () => () => view);
531
533
  if (key === "searchParams") return protectAnnotationValue(clonedTarget.searchParams, context);
532
534
  const value = Reflect.get(clonedTarget, key, clonedTarget);
533
535
  return getProtectedClonePropertyValue(methodCache, clonedTarget, key, value, context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1878+1ab0e08e",
3
+ "version": "1.0.0-dev.1882+0393b288",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",