vref 0.1.4 → 0.1.5
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/README.md +13 -9
- package/dist/index.cjs.cjs +1 -1
- package/dist/index.d.ts +44 -12
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
# VRef
|
|
2
2
|
|
|
3
|
-
A
|
|
4
|
-
Designed to be **low-level** and **predictable**.
|
|
3
|
+
A minimal reactive library to track and respond to changes in variables, providing predictable, low-level reactivity.
|
|
5
4
|
|
|
6
5
|
---
|
|
7
6
|
|
|
8
|
-
###
|
|
7
|
+
### Usage
|
|
9
8
|
|
|
10
9
|
```ts
|
|
11
10
|
import ref from 'vref';
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
// Primitive value
|
|
13
|
+
const count = ref(0, (evt) => {
|
|
14
|
+
console.log('Changed:', evt.value);
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
count.value = 1;
|
|
16
18
|
count.value++;
|
|
19
|
+
|
|
17
20
|
console.log(count.value); // 2
|
|
18
|
-
```
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
const user = ref({ name: 'John', age: 25 },
|
|
22
|
+
// Object value
|
|
23
|
+
const user = ref({ name: 'John', age: 25 }, (evt) => {
|
|
24
|
+
console.log('Changed:', evt);
|
|
25
|
+
});
|
|
22
26
|
|
|
23
|
-
user.value.age = 26; //
|
|
24
|
-
user.value.name = 'Doe'; //
|
|
27
|
+
user.value.age = 26; // triggers onchange
|
|
28
|
+
user.value.name = 'Doe'; // triggers onchange
|
|
25
29
|
```
|
|
26
30
|
|
|
27
31
|
---
|
package/dist/index.cjs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={Get:"get",Set:"set",Add:"add",Has:"has",Delete:"delete",Clear:"clear",ForbiddenKeys:new Set(["__proto__","constructor","prototype"]),ReduceKeys:new Set(["reduce","reduceRight"])},t=Symbol("is_proxy"),r=Symbol("raw_object"),n=Symbol("parents"),i=new Set(["copyWithin","fill","push","reverse","unshift"]),a=new Set(["concat","flat","slice","toReversed","toSpliced","with"]),o=new Set(["every","findIndex","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some"]),s=new Set(["entries","keys","values",Symbol.iterator]),c=new Set(["includes","indexOf","lastIndexOf"]),u=new Set(["at"]),l=new Set(["filter","find","findLast","pop","shift","sort","splice","toSorted"]),f=new Set(["copyWithin","fill","reverse","set","sort"]),d=new Set(["forEach"]),p=new Set(["forEach"]);function h(t){return e.ForbiddenKeys.has(t)}function y(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function v(e){return function(e){return"object"==typeof e&&null!==e}(e)||function(e){return Array.isArray(e)||y(e)}(e)}function g(e){return e[t]??!1}function H(e){return v(e)&&g(e)}function S(e){return e instanceof Map||e instanceof WeakMap}function w(e){return e instanceof Set||e instanceof WeakSet}function b(e){return e[r]}function k(e){return H(e)?b(e):e}function A(...e){const[t]=e;return v(t)?z(...e):t}function O(e){return e.map(e=>k(e))}function m(e,t,r,n,i){return e.map(e=>A(e,t,r,n,i,!1))}function j(e,t,r,n,i,...a){const[o,...s]=a;if("function"==typeof o){function c(...a){const s=a.map(a=>A(a,e===a?void 0:t,r,n,i,!1));return o.apply(this,s)}return[c,...s]}return a}function x(e,t,r,...n){const i=t.has(this)?O(n):n;return e[r].apply(this,i)}function R(e,t,r,n,...i){const a=t.get(this),o=a?O(i):i,s=e[r].apply(this,o);return a&&n({target:a,action:r,key:void 0,value:i,prevValue:void 0}),s===this&&a?a:s}function V(e,t,r,...n){const i=t.get(this),[a]=n,o=i?k(a):a;return e.has.call(this,o)||(e.add.call(this,o),i&&r({target:i,action:"add",key:a,value:a,prevValue:void 0})),i??this}function P(e,t,r,...n){const i=t.get(this),[a]=n,o=i?k(a):a,s=function(e,t){return e instanceof WeakMap?e.get(t):e.has(t)?t:void 0}(this,o),c=e.delete.call(this,o);return c&&i&&r({target:i,action:"delete",key:a,value:void 0,prevValue:s}),c}function M(e,t,r,n,...i){const a=t.get(this),[o]=i,s=a?k(o):o,c=e.get.call(this,s);return a?A(c,a,t,r,n):c}function _(e,t,...r){const n=t.has(this),[i]=r,a=n?k(i):i;return e.has.call(this,a)}function W(e,t,r,...n){const i=t.get(this),[a,o]=n,s=i?k(a):a,c=i?k(o):o,u=e.get.call(this,s);return Object.is(c,u)||(e.set.call(this,s,c),i&&r({target:i,action:"set",key:a,value:o,prevValue:u})),i??this}function E(e,t,r){if(this.size>0){const n=t.get(this);e.clear.call(this),n&&r({target:n,action:"clear",key:void 0,value:void 0,prevValue:void 0})}}function K(e,t,r,...n){const i=g(this)||t.has(this)?O(n):n;return e[r].apply(this,i)}function L(t,r,n,i,a,...o){const s=r.get(this);let c;return c=s?e.ReduceKeys.has(i)?function(e,t,r,n,i,...a){const[o,...s]=a;return[function(...a){const s=a.map((a,o)=>o>0?A(a,e===a?void 0:t,r,n,i,!1):a);return o.apply(this,s)},...s]}(this,s,r,n,a,...o):j(this,s,r,n,a,...o):o,t[i].apply(this,c)}function D(e,t,r,n,i){const a=t.get(this),o=e[n].call(this);return a?function(e,t,r,n,i,a,o){const s=Array.isArray(t),c="entries"===a||S(t)&&a===Symbol.iterator,u=Object.create(Object.getPrototypeOf(e));return u.next=function(t){const a=k(this===u?e:this),l=e.next.call(a,t);if(!l.done)if(c)if(s){const[,e]=l.value;l.value[1]=A(e,r,n,i,o,!1)}else l.value=l.value.map(e=>A(e,r,n,i,o,!1));else l.value=A(l.value,r,n,i,o,!1);return l},u[Symbol.iterator]=function(){return k(this)},u}(o,this,a,t,r,n,i):o}function I(e,t,r,n,i,...a){const o=t.get(this),s=o?O(a):a,c=e[n].apply(this,s);return o?m(c,o,t,r,i):c}function C(e,t,r,n,i,...a){const o=t.get(this),s=o?O(a):a,c=e[n].apply(this,s);return o?A(c,o,t,r,i):c}function F(e,t,r,n,i,...a){const o=t.get(this);let s;switch(n){case"filter":case"find":case"findLast":case"sort":case"toSorted":const c=o?j(this,o,t,r,i,...a):a;switch(s=e[n].apply(this,c),n){case"filter":case"toSorted":return o?m(s,o,t,r,i):s;case"find":case"findLast":return o?A(s,o,t,r,i):s;case"sort":return o&&i({target:o,action:"sort",key:void 0,value:a,prevValue:void 0}),o??this}case"pop":case"shift":case"splice":const u=o?O(a):a;switch(s=e[n].apply(this,u),o&&i({target:o,action:n,key:void 0,value:a,prevValue:void 0}),n){case"pop":case"shift":return o?A(s,o,t,r,i,!1):s;case"splice":return o?m(s,o,t,r,i):s}}}function G(e,...t){return function(...r){const[n,i]=t;let a;var o;return o=n,a="[object Object]"!==Object.prototype.toString.call(o)||Object.getPrototypeOf(o)!==Object.prototype&&!o.constructor?k(this):this,function(e,t){H(e)&&t.set(b(e),e)}(this,i),e.apply(a,t.concat(r))}}function z(H,b,k,A,O,m){if(g(H))return H;let j=A.get(H);b&&(j?j.add(b):(j=new Set([b]),A.set(H,j)));const B=k.get(H);if(B)return B;let q=!1;const J=new Proxy(H,{get(g,b,m){if(b===n)return j;if(b===t)return!0;if(b===r)return H;let B;try{B=Reflect.get(g,b,m)}catch{B=Reflect.get(g,b)}if(!h(b)&&void 0!==B){if(v(B))return z(B,J,k,A,O);if("function"==typeof B){const t=function(e,t,r,n,i){return{conflictArrayHandler:G(F,e,r,n,t,i),mutationArrayHandler:G(R,e,r,t,i),producerArrayHandler:G(I,e,r,n,t,i),iterationHandler:G(L,e,r,n,t,i),iteratorHandler:G(D,e,r,n,t,i),lookupArrayHandler:G(x,e,r,t),pickingArrayHandler:G(C,e,r,n,t,i),getHandler:G(M,e,r,n,i),setHandler:G(W,e,r,i),addHandler:G(V,e,r,i),hasHandler:G(_,e,r),deleteHandler:G(P,e,r,i),clearHandler:G(E,e,r,i),defaultHandler:G(K,e,r,t)}}(g,b,k,A,O);if(Array.isArray(g)){if(l.has(b))return t.conflictArrayHandler;if(i.has(b))return t.mutationArrayHandler;if(a.has(b))return t.producerArrayHandler;if(o.has(b))return t.iterationHandler;if(s.has(b))return t.iteratorHandler;if(c.has(b))return t.lookupArrayHandler;if(u.has(b))return t.pickingArrayHandler}if(y(g)&&f.has(b))return t.mutationArrayHandler;if(S(g)){if(b===e.Get)return t.getHandler;if(b===e.Set)return t.setHandler}if(w(g)&&b===e.Add)return t.addHandler;if(g instanceof Map&&d.has(b)||g instanceof Set&&p.has(b))return t.iterationHandler;if(function(e){return e instanceof Map||e instanceof Set}(g)){if(b===e.Clear)return t.clearHandler;if(s.has(b))return t.iteratorHandler}if(function(e){return S(e)||w(e)}(g)){if(b===e.Has)return t.hasHandler;if(b===e.Delete)return t.deleteHandler}return t.defaultHandler}}return B},set(e,t,r,n){if(h(t))return!0;const i=e[t];if(!Object.is(i,r)){q=!0;const a=Reflect.set(e,t,r,n);return q=!1,a&&O({target:J,action:"set",key:t,value:r,prevValue:i}),a}return!0},deleteProperty(e,t){if(h(t))return!0;if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t],n=Reflect.deleteProperty(e,t);return n&&O({target:J,action:"delete",key:t,value:void 0,prevValue:r}),n}return!0},defineProperty(e,t,r){if(h(t))return!0;const n=e[t],i=Reflect.defineProperty(e,t,r);if(!q&&i){const e=r.value;Object.is(n,e)||O({target:J,action:"define",key:t,value:e,prevValue:n})}return i},setPrototypeOf:()=>!0});return(m??1)&&k.set(H,J),J}exports.default=function(e,t,r){const n=r?.cache??new WeakMap,i=r?.cacheParents??new WeakMap;return z(Object.preventExtensions({value:e}),void 0,n,i,t)},exports.getRaw=k,exports.isRef=H;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,18 +24,30 @@ type OnChangeHandler = (event: ChangeEvent) => void;
|
|
|
24
24
|
*/
|
|
25
25
|
type RefOptions = {
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
* Optional cache used to store mappings of raw objects to their corresponding proxies.
|
|
28
|
+
*
|
|
29
|
+
* This ensures that the same object reference always returns the same proxy,
|
|
30
|
+
* preserving identity across repeated accesses (e.g., `obj.a === obj.a` remains true).
|
|
31
|
+
*
|
|
32
|
+
* Normally, this cache is automatically managed internally by the reactive system.
|
|
33
|
+
* You can provide a custom WeakMap if you want multiple refs to share the same
|
|
34
|
+
* reactivity graph or maintain consistent proxies across different refs.
|
|
35
|
+
*
|
|
36
|
+
* ⚠️ Note: Passing an invalid or reused cache may cause unexpected proxy behavior.
|
|
37
|
+
*/
|
|
38
38
|
cache?: WeakMap<object, object>;
|
|
39
|
+
/**
|
|
40
|
+
* Optional cache used to track the direct parent proxies of each raw object.
|
|
41
|
+
*
|
|
42
|
+
* Stores a mapping where the key is a raw object and the value is a Set of
|
|
43
|
+
* its immediate proxy parents (one level up in the object graph).
|
|
44
|
+
*
|
|
45
|
+
* Normally, this cache is internally managed. You can provide your own
|
|
46
|
+
* WeakMap if you want multiple refs to share the same parent-tracking graph.
|
|
47
|
+
*
|
|
48
|
+
* ⚠️ Note: Passing an invalid or reused cache may cause unexpected proxy behavior.
|
|
49
|
+
*/
|
|
50
|
+
cacheParents?: WeakMap<object, Set<object>>;
|
|
39
51
|
};
|
|
40
52
|
/**
|
|
41
53
|
* A reactive reference object.
|
|
@@ -56,6 +68,7 @@ type Ref<T> = {
|
|
|
56
68
|
* - `value`: the reactive value.
|
|
57
69
|
* - `onchange`: callback triggered on every change.
|
|
58
70
|
* - `options.cache`: optional WeakMap for shared proxy identity.
|
|
71
|
+
* - `options.cacheParents`: optional WeakMap for parents proxy.
|
|
59
72
|
*
|
|
60
73
|
* Example:
|
|
61
74
|
* ```ts
|
|
@@ -65,12 +78,31 @@ type Ref<T> = {
|
|
|
65
78
|
*
|
|
66
79
|
* @param initial Initial value.
|
|
67
80
|
* @param onchange Callback that receives ChangeEvent on every change.
|
|
68
|
-
|
|
81
|
+
* @param options Optional RefOptions for proxy identity (`cache`) and parent tracking (`cacheParents`).
|
|
69
82
|
* @returns A reactive Ref object.
|
|
70
83
|
*/
|
|
71
84
|
declare function ref<T>(initial: T, onchange: OnChangeHandler, options?: RefOptions): Ref<T>;
|
|
72
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Safely checks whether a value is a reactive proxy.
|
|
88
|
+
*
|
|
89
|
+
* - Returns `true` only if:
|
|
90
|
+
* 1. The value is proxiable (object, array, etc.),
|
|
91
|
+
* 2. And it is actually a proxy created by the reactive system.
|
|
92
|
+
*
|
|
93
|
+
* @param value Any value to test.
|
|
94
|
+
* @returns `true` if the value is a valid reactive proxy, otherwise `false`.
|
|
95
|
+
*/
|
|
73
96
|
declare function isProxyTry(value: any): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Safely retrieves the raw (unproxied) value.
|
|
99
|
+
*
|
|
100
|
+
* - If `value` is a proxy created by the reactive system, it returns its original raw target.
|
|
101
|
+
* - If `value` is not a proxy, it simply returns the input as-is.
|
|
102
|
+
*
|
|
103
|
+
* @param value Any value that may or may not be a proxy.
|
|
104
|
+
* @returns The raw underlying value if proxied, otherwise the original value.
|
|
105
|
+
*/
|
|
74
106
|
declare function getRawTry(value: any): any;
|
|
75
107
|
|
|
76
108
|
export { ref as default, getRawTry as getRaw, isProxyTry as isRef };
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={Get:"get",Set:"set",Add:"add",Has:"has",Delete:"delete",Clear:"clear",ForbiddenKeys:new Set(["__proto__","constructor","prototype"])},e=Symbol("is_proxy"),r=Symbol("raw_object"),n=new Set(["copyWithin","fill","push","reverse","unshift"]),a=new Set(["concat","flat","slice","toReversed","toSpliced","with"]),
|
|
1
|
+
const t={Get:"get",Set:"set",Add:"add",Has:"has",Delete:"delete",Clear:"clear",ForbiddenKeys:new Set(["__proto__","constructor","prototype"]),ReduceKeys:new Set(["reduce","reduceRight"])},e=Symbol("is_proxy"),r=Symbol("raw_object"),n=Symbol("parents"),i=new Set(["copyWithin","fill","push","reverse","unshift"]),a=new Set(["concat","flat","slice","toReversed","toSpliced","with"]),o=new Set(["every","findIndex","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some"]),s=new Set(["entries","keys","values",Symbol.iterator]),c=new Set(["includes","indexOf","lastIndexOf"]),u=new Set(["at"]),l=new Set(["filter","find","findLast","pop","shift","sort","splice","toSorted"]),f=new Set(["copyWithin","fill","reverse","set","sort"]),d=new Set(["forEach"]),h=new Set(["forEach"]);function p(e){return t.ForbiddenKeys.has(e)}function y(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function v(t){return function(t){return"object"==typeof t&&null!==t}(t)||function(t){return Array.isArray(t)||y(t)}(t)}function g(t){return t[e]??!1}function H(t){return v(t)&&g(t)}function S(t){return t instanceof Map||t instanceof WeakMap}function w(t){return t instanceof Set||t instanceof WeakSet}function b(t){return t[r]}function k(t){return H(t)?b(t):t}function A(...t){const[e]=t;return v(e)?z(...t):e}function O(t){return t.map(t=>k(t))}function m(t,e,r,n,i){return t.map(t=>A(t,e,r,n,i,!1))}function j(t,e,r,n,i,...a){const[o,...s]=a;if("function"==typeof o){function c(...a){const s=a.map(a=>A(a,t===a?void 0:e,r,n,i,!1));return o.apply(this,s)}return[c,...s]}return a}function R(t,e,r,...n){const i=e.has(this)?O(n):n;return t[r].apply(this,i)}function V(t,e,r,n,...i){const a=e.get(this),o=a?O(i):i,s=t[r].apply(this,o);return a&&n({target:a,action:r,key:void 0,value:i,prevValue:void 0}),s===this&&a?a:s}function x(t,e,r,...n){const i=e.get(this),[a]=n,o=i?k(a):a;return t.has.call(this,o)||(t.add.call(this,o),i&&r({target:i,action:"add",key:a,value:a,prevValue:void 0})),i??this}function P(t,e,r,...n){const i=e.get(this),[a]=n,o=i?k(a):a,s=function(t,e){return t instanceof WeakMap?t.get(e):t.has(e)?e:void 0}(this,o),c=t.delete.call(this,o);return c&&i&&r({target:i,action:"delete",key:a,value:void 0,prevValue:s}),c}function M(t,e,r,n,...i){const a=e.get(this),[o]=i,s=a?k(o):o,c=t.get.call(this,s);return a?A(c,a,e,r,n):c}function W(t,e,...r){const n=e.has(this),[i]=r,a=n?k(i):i;return t.has.call(this,a)}function _(t,e,r,...n){const i=e.get(this),[a,o]=n,s=i?k(a):a,c=i?k(o):o,u=t.get.call(this,s);return Object.is(c,u)||(t.set.call(this,s,c),i&&r({target:i,action:"set",key:a,value:o,prevValue:u})),i??this}function E(t,e,r){if(this.size>0){const n=e.get(this);t.clear.call(this),n&&r({target:n,action:"clear",key:void 0,value:void 0,prevValue:void 0})}}function K(t,e,r,...n){const i=g(this)||e.has(this)?O(n):n;return t[r].apply(this,i)}function L(e,r,n,i,a,...o){const s=r.get(this);let c;return c=s?t.ReduceKeys.has(i)?function(t,e,r,n,i,...a){const[o,...s]=a;return[function(...a){const s=a.map((a,o)=>o>0?A(a,t===a?void 0:e,r,n,i,!1):a);return o.apply(this,s)},...s]}(this,s,r,n,a,...o):j(this,s,r,n,a,...o):o,e[i].apply(this,c)}function D(t,e,r,n,i){const a=e.get(this),o=t[n].call(this);return a?function(t,e,r,n,i,a,o){const s=Array.isArray(e),c="entries"===a||S(e)&&a===Symbol.iterator,u=Object.create(Object.getPrototypeOf(t));return u.next=function(e){const a=k(this===u?t:this),l=t.next.call(a,e);if(!l.done)if(c)if(s){const[,t]=l.value;l.value[1]=A(t,r,n,i,o,!1)}else l.value=l.value.map(t=>A(t,r,n,i,o,!1));else l.value=A(l.value,r,n,i,o,!1);return l},u[Symbol.iterator]=function(){return k(this)},u}(o,this,a,e,r,n,i):o}function I(t,e,r,n,i,...a){const o=e.get(this),s=o?O(a):a,c=t[n].apply(this,s);return o?m(c,o,e,r,i):c}function C(t,e,r,n,i,...a){const o=e.get(this),s=o?O(a):a,c=t[n].apply(this,s);return o?A(c,o,e,r,i):c}function F(t,e,r,n,i,...a){const o=e.get(this);let s;switch(n){case"filter":case"find":case"findLast":case"sort":case"toSorted":const c=o?j(this,o,e,r,i,...a):a;switch(s=t[n].apply(this,c),n){case"filter":case"toSorted":return o?m(s,o,e,r,i):s;case"find":case"findLast":return o?A(s,o,e,r,i):s;case"sort":return o&&i({target:o,action:"sort",key:void 0,value:a,prevValue:void 0}),o??this}case"pop":case"shift":case"splice":const u=o?O(a):a;switch(s=t[n].apply(this,u),o&&i({target:o,action:n,key:void 0,value:a,prevValue:void 0}),n){case"pop":case"shift":return o?A(s,o,e,r,i,!1):s;case"splice":return o?m(s,o,e,r,i):s}}}function G(t,...e){return function(...r){const[n,i]=e;let a;var o;return o=n,a="[object Object]"!==Object.prototype.toString.call(o)||Object.getPrototypeOf(o)!==Object.prototype&&!o.constructor?k(this):this,function(t,e){H(t)&&e.set(b(t),t)}(this,i),t.apply(a,e.concat(r))}}function z(H,b,k,A,O,m){if(g(H))return H;let j=A.get(H);b&&(j?j.add(b):(j=new Set([b]),A.set(H,j)));const B=k.get(H);if(B)return B;let q=!1;const J=new Proxy(H,{get(g,b,m){if(b===n)return j;if(b===e)return!0;if(b===r)return H;let B;try{B=Reflect.get(g,b,m)}catch{B=Reflect.get(g,b)}if(!p(b)&&void 0!==B){if(v(B))return z(B,J,k,A,O);if("function"==typeof B){const e=function(t,e,r,n,i){return{conflictArrayHandler:G(F,t,r,n,e,i),mutationArrayHandler:G(V,t,r,e,i),producerArrayHandler:G(I,t,r,n,e,i),iterationHandler:G(L,t,r,n,e,i),iteratorHandler:G(D,t,r,n,e,i),lookupArrayHandler:G(R,t,r,e),pickingArrayHandler:G(C,t,r,n,e,i),getHandler:G(M,t,r,n,i),setHandler:G(_,t,r,i),addHandler:G(x,t,r,i),hasHandler:G(W,t,r),deleteHandler:G(P,t,r,i),clearHandler:G(E,t,r,i),defaultHandler:G(K,t,r,e)}}(g,b,k,A,O);if(Array.isArray(g)){if(l.has(b))return e.conflictArrayHandler;if(i.has(b))return e.mutationArrayHandler;if(a.has(b))return e.producerArrayHandler;if(o.has(b))return e.iterationHandler;if(s.has(b))return e.iteratorHandler;if(c.has(b))return e.lookupArrayHandler;if(u.has(b))return e.pickingArrayHandler}if(y(g)&&f.has(b))return e.mutationArrayHandler;if(S(g)){if(b===t.Get)return e.getHandler;if(b===t.Set)return e.setHandler}if(w(g)&&b===t.Add)return e.addHandler;if(g instanceof Map&&d.has(b)||g instanceof Set&&h.has(b))return e.iterationHandler;if(function(t){return t instanceof Map||t instanceof Set}(g)){if(b===t.Clear)return e.clearHandler;if(s.has(b))return e.iteratorHandler}if(function(t){return S(t)||w(t)}(g)){if(b===t.Has)return e.hasHandler;if(b===t.Delete)return e.deleteHandler}return e.defaultHandler}}return B},set(t,e,r,n){if(p(e))return!0;const i=t[e];if(!Object.is(i,r)){q=!0;const a=Reflect.set(t,e,r,n);return q=!1,a&&O({target:J,action:"set",key:e,value:r,prevValue:i}),a}return!0},deleteProperty(t,e){if(p(e))return!0;if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e],n=Reflect.deleteProperty(t,e);return n&&O({target:J,action:"delete",key:e,value:void 0,prevValue:r}),n}return!0},defineProperty(t,e,r){if(p(e))return!0;const n=t[e],i=Reflect.defineProperty(t,e,r);if(!q&&i){const t=r.value;Object.is(n,t)||O({target:J,action:"define",key:e,value:t,prevValue:n})}return i},setPrototypeOf:()=>!0});return(m??1)&&k.set(H,J),J}function B(t,e,r){const n=r?.cache??new WeakMap,i=r?.cacheParents??new WeakMap;return z(Object.preventExtensions({value:t}),void 0,n,i,e)}export{B as default,k as getRaw,H as isRef};
|