@mintjamsinc/ichigojs 0.1.72 → 0.1.73

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.
@@ -8023,6 +8023,41 @@
8023
8023
  * This allows mapping variable names to their actual source paths for dependency tracking.
8024
8024
  */
8025
8025
  static pathAliases = new Map();
8026
+ /**
8027
+ * The `Object.prototype.toString` tags of the *only* value types we deeply
8028
+ * proxy. Everything else is returned untouched (raw).
8029
+ *
8030
+ * Rationale: a Proxy can only safely intercept plain data containers. Built-in
8031
+ * and host objects — `Date`, `RegExp`, `File`, `Blob`, `FileList`, `Promise`,
8032
+ * `WeakMap`/`WeakSet`, typed arrays, DOM nodes, etc. — carry private internal
8033
+ * slots, and invoking their native methods with a Proxy as the `this`/receiver
8034
+ * throws "Illegal invocation". They must therefore never be wrapped. This is an
8035
+ * allow-list rather than a deny-list so that *every* such exotic type is
8036
+ * excluded by default, not just the handful we happened to enumerate.
8037
+ *
8038
+ * Plain user-defined class instances report `[object Object]` (unless they set
8039
+ * `Symbol.toStringTag`) and so remain reactive, preserving prior behaviour.
8040
+ * `Map`/`Set` stay reactive because the proxy specially wraps their mutation
8041
+ * methods (see the `get` trap); `WeakMap`/`WeakSet` are intentionally excluded
8042
+ * since they cannot be wrapped that way and would break the same as `File`.
8043
+ *
8044
+ * Callers that want a plain object kept non-reactive can still opt out
8045
+ * explicitly via {@link markRaw}.
8046
+ */
8047
+ static REACTIVE_TYPE_TAGS = new Set([
8048
+ '[object Object]',
8049
+ '[object Array]',
8050
+ '[object Arguments]',
8051
+ '[object Map]',
8052
+ '[object Set]',
8053
+ ]);
8054
+ /**
8055
+ * Whether the given non-null object value is one we deeply proxy.
8056
+ * See {@link REACTIVE_TYPE_TAGS} for the reasoning.
8057
+ */
8058
+ static isReactivable(value) {
8059
+ return this.REACTIVE_TYPE_TAGS.has(Object.prototype.toString.call(value));
8060
+ }
8026
8061
  /**
8027
8062
  * Creates a reactive proxy for the given object.
8028
8063
  * The proxy will call the onChange callback whenever a property is modified.
@@ -8042,11 +8077,10 @@
8042
8077
  if (this.rawObjects.has(target)) {
8043
8078
  return target;
8044
8079
  }
8045
- // Don't wrap built-in objects that have internal slots
8046
- // These objects require their methods to be called with the correct 'this' context
8047
- // Use Object.prototype.toString for more reliable type checking
8048
- const typeTag = Object.prototype.toString.call(target);
8049
- if (typeTag === '[object Date]' || typeTag === '[object RegExp]' || typeTag === '[object Error]') {
8080
+ // Only deeply proxy plain data containers; return every built-in/host
8081
+ // object (Date, File, Blob, Promise, WeakMap, DOM nodes, …) as-is, since
8082
+ // their native methods break when invoked through a Proxy receiver.
8083
+ if (!this.isReactivable(target)) {
8050
8084
  return target;
8051
8085
  }
8052
8086
  // Check if the target is already a proxy - if so, return it as-is to prevent double-wrapping
@@ -8082,10 +8116,10 @@
8082
8116
  if (ReactiveProxy.rawObjects.has(value)) {
8083
8117
  return value;
8084
8118
  }
8085
- // Don't wrap built-in objects that have internal slots
8086
- // Use Object.prototype.toString for more reliable type checking
8087
- const valueTypeTag = Object.prototype.toString.call(value);
8088
- if (valueTypeTag === '[object Date]' || valueTypeTag === '[object RegExp]' || valueTypeTag === '[object Error]') {
8119
+ // Only deeply proxy plain data containers; hand back built-in
8120
+ // and host objects (Date, File, Blob, Promise, WeakMap, DOM
8121
+ // nodes, …) untouched so their native methods keep working.
8122
+ if (!ReactiveProxy.isReactivable(value)) {
8089
8123
  return value;
8090
8124
  }
8091
8125
  // Build the nested path