@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.
- package/dist/ichigo.cjs +43 -9
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +43 -9
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +43 -9
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/types/ichigo/util/ReactiveProxy.d.ts +27 -0
- package/package.json +1 -1
package/dist/ichigo.esm.js
CHANGED
|
@@ -8017,6 +8017,41 @@ class ReactiveProxy {
|
|
|
8017
8017
|
* This allows mapping variable names to their actual source paths for dependency tracking.
|
|
8018
8018
|
*/
|
|
8019
8019
|
static pathAliases = new Map();
|
|
8020
|
+
/**
|
|
8021
|
+
* The `Object.prototype.toString` tags of the *only* value types we deeply
|
|
8022
|
+
* proxy. Everything else is returned untouched (raw).
|
|
8023
|
+
*
|
|
8024
|
+
* Rationale: a Proxy can only safely intercept plain data containers. Built-in
|
|
8025
|
+
* and host objects — `Date`, `RegExp`, `File`, `Blob`, `FileList`, `Promise`,
|
|
8026
|
+
* `WeakMap`/`WeakSet`, typed arrays, DOM nodes, etc. — carry private internal
|
|
8027
|
+
* slots, and invoking their native methods with a Proxy as the `this`/receiver
|
|
8028
|
+
* throws "Illegal invocation". They must therefore never be wrapped. This is an
|
|
8029
|
+
* allow-list rather than a deny-list so that *every* such exotic type is
|
|
8030
|
+
* excluded by default, not just the handful we happened to enumerate.
|
|
8031
|
+
*
|
|
8032
|
+
* Plain user-defined class instances report `[object Object]` (unless they set
|
|
8033
|
+
* `Symbol.toStringTag`) and so remain reactive, preserving prior behaviour.
|
|
8034
|
+
* `Map`/`Set` stay reactive because the proxy specially wraps their mutation
|
|
8035
|
+
* methods (see the `get` trap); `WeakMap`/`WeakSet` are intentionally excluded
|
|
8036
|
+
* since they cannot be wrapped that way and would break the same as `File`.
|
|
8037
|
+
*
|
|
8038
|
+
* Callers that want a plain object kept non-reactive can still opt out
|
|
8039
|
+
* explicitly via {@link markRaw}.
|
|
8040
|
+
*/
|
|
8041
|
+
static REACTIVE_TYPE_TAGS = new Set([
|
|
8042
|
+
'[object Object]',
|
|
8043
|
+
'[object Array]',
|
|
8044
|
+
'[object Arguments]',
|
|
8045
|
+
'[object Map]',
|
|
8046
|
+
'[object Set]',
|
|
8047
|
+
]);
|
|
8048
|
+
/**
|
|
8049
|
+
* Whether the given non-null object value is one we deeply proxy.
|
|
8050
|
+
* See {@link REACTIVE_TYPE_TAGS} for the reasoning.
|
|
8051
|
+
*/
|
|
8052
|
+
static isReactivable(value) {
|
|
8053
|
+
return this.REACTIVE_TYPE_TAGS.has(Object.prototype.toString.call(value));
|
|
8054
|
+
}
|
|
8020
8055
|
/**
|
|
8021
8056
|
* Creates a reactive proxy for the given object.
|
|
8022
8057
|
* The proxy will call the onChange callback whenever a property is modified.
|
|
@@ -8036,11 +8071,10 @@ class ReactiveProxy {
|
|
|
8036
8071
|
if (this.rawObjects.has(target)) {
|
|
8037
8072
|
return target;
|
|
8038
8073
|
}
|
|
8039
|
-
//
|
|
8040
|
-
//
|
|
8041
|
-
//
|
|
8042
|
-
|
|
8043
|
-
if (typeTag === '[object Date]' || typeTag === '[object RegExp]' || typeTag === '[object Error]') {
|
|
8074
|
+
// Only deeply proxy plain data containers; return every built-in/host
|
|
8075
|
+
// object (Date, File, Blob, Promise, WeakMap, DOM nodes, …) as-is, since
|
|
8076
|
+
// their native methods break when invoked through a Proxy receiver.
|
|
8077
|
+
if (!this.isReactivable(target)) {
|
|
8044
8078
|
return target;
|
|
8045
8079
|
}
|
|
8046
8080
|
// Check if the target is already a proxy - if so, return it as-is to prevent double-wrapping
|
|
@@ -8076,10 +8110,10 @@ class ReactiveProxy {
|
|
|
8076
8110
|
if (ReactiveProxy.rawObjects.has(value)) {
|
|
8077
8111
|
return value;
|
|
8078
8112
|
}
|
|
8079
|
-
//
|
|
8080
|
-
//
|
|
8081
|
-
|
|
8082
|
-
if (
|
|
8113
|
+
// Only deeply proxy plain data containers; hand back built-in
|
|
8114
|
+
// and host objects (Date, File, Blob, Promise, WeakMap, DOM
|
|
8115
|
+
// nodes, …) untouched so their native methods keep working.
|
|
8116
|
+
if (!ReactiveProxy.isReactivable(value)) {
|
|
8083
8117
|
return value;
|
|
8084
8118
|
}
|
|
8085
8119
|
// Build the nested path
|