vref 0.1.2 → 0.1.4

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});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"]),i=new Set(["every","findIndex","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some"]),o=new Set(["entries","keys","values",Symbol.iterator]),s=new Set(["includes","indexOf","lastIndexOf"]),c=new Set(["at"]),u=new Set(["filter","find","findLast","pop","shift","sort","splice","toSorted"]),l=new Set(["copyWithin","fill","reverse","set","sort"]),f=new Set(["forEach"]),d=new Set(["forEach"]);function h(e){return t.ForbiddenKeys.has(e)}function p(t){return"object"==typeof t&&null!==t}function y(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function v(t){return Array.isArray(t)||y(t)}function g(t){return t[e]??!1}function H(t){return t instanceof Map||t instanceof WeakMap}function S(t){return t instanceof Set||t instanceof WeakSet}function b(t){return t[r]}function w(t){return p(t)&&g(t)?b(t):t}function A(...t){const[e]=t;return p(e)?K(...t):e}function k(t){return t.map(t=>w(t))}function j(t,e,r){return t.map(t=>A(t,e,r,!1))}function O(t,e,...r){if(r.length>0){const[n,...a]=r;if("function"==typeof n){function i(...r){const a=r.map(r=>A(r,t,e));return n.apply(this,a)}return[i,...a]}}return r}function m(t,e,r,...n){const a=e.has(this)?k(n):n;return t[r].apply(this,a)}function x(t,e,r,n,...a){const i=e.get(this),o=i?k(a):a,s=t[r].apply(this,o);return i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),s}function V(t,e,r,...n){const a=e.get(this),[i]=n,o=a?w(i):i;return t.has.call(this,o)||(t.add.call(this,o),a&&r({target:a,action:"add",key:i,value:i,prevValue:void 0})),a??this}function P(t,e,r,...n){const a=e.get(this),[i]=n,o=a?w(i):i,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&&a&&r({target:a,action:"delete",key:i,value:void 0,prevValue:s}),c}function M(t,e,r,...n){const a=e.has(this),[i]=n,o=a?w(i):i,s=t.get.call(this,o);return a?A(s,e,r):s}function R(t,e,...r){const n=e.has(this),[a]=r,i=n?w(a):a;return t.has.call(this,i)}function _(t,e,r,...n){const a=e.get(this),[i,o]=n,s=a?w(i):i,c=a?w(o):o,u=t.get.call(this,s);return Object.is(c,u)||(t.set.call(this,s,c),a&&r({target:a,action:"set",key:i,value:o,prevValue:u})),a??this}function W(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 E(t,e,r,...n){const a=g(this)||e.has(this)?k(n):n;return t[r].apply(this,a)}function L(t,e,r,n,...a){const i=e.has(this)?O(e,n,...a):a;return t[r].apply(this,i)}function D(t,e,r,n){const a=e.get(this),i=t[r].call(this);return a?function(t,...e){const[r,n,a,i]=e,o=Array.isArray(r),s="entries"===a||H(r)&&a===Symbol.iterator,c={next(e){const r=w(this===c?t:this),a=t.next.call(r,e);if(!a.done)if(s)if(o){const[,t]=a.value;a.value[1]=A(t,n,i)}else a.value=a.value.map(t=>A(t,n,i));else a.value=A(a.value,n,i);return a},[Symbol.iterator](){return w(this)}};return c}(i,this,e,r,n):i}function I(t,e,r,n,...a){const i=e.has(this),o=i?k(a):a,s=t[r].apply(this,o);return i?j(s,e,n):s}function C(t,e,r,n,...a){const i=e.has(this),o=i?k(a):a,s=t[r].apply(this,o);return i?A(s,e,n):s}function F(t,e,r,n,...a){const i=e.get(this);let o;switch(r){case"filter":case"find":case"findLast":case"sort":case"toSorted":const s=i?O(e,n,...a):a;switch(o=t[r].apply(this,s),r){case"filter":case"toSorted":return i?j(o,e,n):o;case"find":case"findLast":return i?A(o,e,n):o;case"sort":return i&&n({target:i,action:"sort",key:void 0,value:a,prevValue:void 0}),i??this}case"pop":case"shift":case"splice":const c=i?k(a):a;switch(o=t[r].apply(this,c),i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),r){case"pop":case"shift":return i?A(o,e,n,!1):o;case"splice":return i?j(o,e,n):o}}}function G(t,...e){return function(...r){const[n,a]=e;let i;var o;return o=n,i="[object Object]"!==Object.prototype.toString.call(o)||Object.getPrototypeOf(o)!==Object.prototype&&!o.constructor?w(this):this,function(t,e){p(t)&&g(t)&&e.set(b(t),t)}(this,a),t.apply(i,e.concat(r))}}function K(p,b,w,A){if(g(p))return p;const k=b.get(p);if(k)return k;let j=!1;const O=new Proxy(p,{get(g,A,k){if(A===e)return!0;if(A===r)return p;let j;try{j=Reflect.get(g,A,k)}catch{j=Reflect.get(g,A)}if(!h(A)&&null!=j&&(v(j)||"object"==typeof j||"function"==typeof j)){if(v(j)||"object"==typeof j)return K(j,b,w);const e=function(t,e,r,n){return{conflictArrayHandler:G(F,t,r,e,n),mutationArrayHandler:G(x,t,r,e,n),producerArrayHandler:G(I,t,r,e,n),iterationHandler:G(L,t,r,e,n),iteratorHandler:G(D,t,r,e,n),lookupArrayHandler:G(m,t,r,e),pickingArrayHandler:G(C,t,r,e,n),getHandler:G(M,t,r,n),setHandler:G(_,t,r,n),addHandler:G(V,t,r,n),hasHandler:G(R,t,r),deleteHandler:G(P,t,r,n),clearHandler:G(W,t,r,n),defaultHandler:G(E,t,r,e)}}(g,A,b,w);if(Array.isArray(g)){if(u.has(A))return e.conflictArrayHandler;if(n.has(A))return e.mutationArrayHandler;if(a.has(A))return e.producerArrayHandler;if(i.has(A))return e.iterationHandler;if(o.has(A))return e.iteratorHandler;if(s.has(A))return e.lookupArrayHandler;if(c.has(A))return e.pickingArrayHandler}if(y(g)&&l.has(A))return e.mutationArrayHandler;if(H(g)){if(A===t.Get)return e.getHandler;if(A===t.Set)return e.setHandler}if(S(g)&&A===t.Add)return e.addHandler;if(g instanceof Map&&f.has(A)||g instanceof Set&&d.has(A))return e.iterationHandler;if(function(t){return t instanceof Map||t instanceof Set}(g)){if(A===t.Clear)return e.clearHandler;if(o.has(A))return e.iteratorHandler}if(function(t){return H(t)||S(t)}(g)){if(A===t.Has)return e.hasHandler;if(A===t.Delete)return e.deleteHandler}return e.defaultHandler}return j},set(t,e,r,n){if(h(e))return!0;const a=t[e];if(!Object.is(a,r)){j=!0;const i=Reflect.set(t,e,r,n);return j=!1,i&&w({target:O,action:"set",key:e,value:r,prevValue:a}),i}return!0},deleteProperty(t,e){if(h(e))return!0;if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e],n=Reflect.deleteProperty(t,e);return n&&w({target:O,action:"delete",key:e,value:void 0,prevValue:r}),n}return!0},defineProperty(t,e,r){if(h(e))return!0;const n=t[e],a=Reflect.defineProperty(t,e,r);if(!j&&a){const t=r.value;Object.is(n,t)||w({target:O,action:"define",key:e,value:t,prevValue:n})}return a},setPrototypeOf:()=>!0});return(A??1)&&b.set(p,O),O}exports.default=function(t,e,r){const n=r?.cache??new WeakMap;return K(Object.preventExtensions({value:t}),n,e)},exports.getRaw=w;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});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"]),i=new Set(["every","findIndex","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some"]),o=new Set(["entries","keys","values",Symbol.iterator]),s=new Set(["includes","indexOf","lastIndexOf"]),c=new Set(["at"]),u=new Set(["filter","find","findLast","pop","shift","sort","splice","toSorted"]),l=new Set(["copyWithin","fill","reverse","set","sort"]),f=new Set(["forEach"]),d=new Set(["forEach"]);function h(e){return t.ForbiddenKeys.has(e)}function p(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function y(t){return function(t){return"object"==typeof t&&null!==t}(t)||function(t){return Array.isArray(t)||p(t)}(t)}function v(t){return t[e]??!1}function g(t){return y(t)&&v(t)}function H(t){return t instanceof Map||t instanceof WeakMap}function S(t){return t instanceof Set||t instanceof WeakSet}function w(t){return t[r]}function b(t){return g(t)?w(t):t}function A(...t){const[e]=t;return y(e)?K(...t):e}function k(t){return t.map(t=>b(t))}function O(t,e,r){return t.map(t=>A(t,e,r,!1))}function m(t,e,...r){if(r.length>0){const[n,...a]=r;if("function"==typeof n){function i(...r){const a=r.map(r=>A(r,t,e));return n.apply(this,a)}return[i,...a]}}return r}function j(t,e,r,...n){const a=e.has(this)?k(n):n;return t[r].apply(this,a)}function x(t,e,r,n,...a){const i=e.get(this),o=i?k(a):a,s=t[r].apply(this,o);return i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),s}function V(t,e,r,...n){const a=e.get(this),[i]=n,o=a?b(i):i;return t.has.call(this,o)||(t.add.call(this,o),a&&r({target:a,action:"add",key:i,value:i,prevValue:void 0})),a??this}function P(t,e,r,...n){const a=e.get(this),[i]=n,o=a?b(i):i,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&&a&&r({target:a,action:"delete",key:i,value:void 0,prevValue:s}),c}function R(t,e,r,...n){const a=e.has(this),[i]=n,o=a?b(i):i,s=t.get.call(this,o);return a?A(s,e,r):s}function M(t,e,...r){const n=e.has(this),[a]=r,i=n?b(a):a;return t.has.call(this,i)}function _(t,e,r,...n){const a=e.get(this),[i,o]=n,s=a?b(i):i,c=a?b(o):o,u=t.get.call(this,s);return Object.is(c,u)||(t.set.call(this,s,c),a&&r({target:a,action:"set",key:i,value:o,prevValue:u})),a??this}function W(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 E(t,e,r,...n){const a=v(this)||e.has(this)?k(n):n;return t[r].apply(this,a)}function L(t,e,r,n,...a){const i=e.has(this)?m(e,n,...a):a;return t[r].apply(this,i)}function D(t,e,r,n){const a=e.get(this),i=t[r].call(this);return a?function(t,...e){const[r,n,a,i]=e,o=Array.isArray(r),s="entries"===a||H(r)&&a===Symbol.iterator,c={next(e){const r=b(this===c?t:this),a=t.next.call(r,e);if(!a.done)if(s)if(o){const[,t]=a.value;a.value[1]=A(t,n,i)}else a.value=a.value.map(t=>A(t,n,i));else a.value=A(a.value,n,i);return a},[Symbol.iterator](){return b(this)}};return c}(i,this,e,r,n):i}function I(t,e,r,n,...a){const i=e.has(this),o=i?k(a):a,s=t[r].apply(this,o);return i?O(s,e,n):s}function C(t,e,r,n,...a){const i=e.has(this),o=i?k(a):a,s=t[r].apply(this,o);return i?A(s,e,n):s}function F(t,e,r,n,...a){const i=e.get(this);let o;switch(r){case"filter":case"find":case"findLast":case"sort":case"toSorted":const s=i?m(e,n,...a):a;switch(o=t[r].apply(this,s),r){case"filter":case"toSorted":return i?O(o,e,n):o;case"find":case"findLast":return i?A(o,e,n):o;case"sort":return i&&n({target:i,action:"sort",key:void 0,value:a,prevValue:void 0}),i??this}case"pop":case"shift":case"splice":const c=i?k(a):a;switch(o=t[r].apply(this,c),i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),r){case"pop":case"shift":return i?A(o,e,n,!1):o;case"splice":return i?O(o,e,n):o}}}function G(t,...e){return function(...r){const[n,a]=e;let i;var o;return o=n,i="[object Object]"!==Object.prototype.toString.call(o)||Object.getPrototypeOf(o)!==Object.prototype&&!o.constructor?b(this):this,function(t,e){g(t)&&e.set(w(t),t)}(this,a),t.apply(i,e.concat(r))}}function K(g,w,b,A){if(v(g))return g;const k=w.get(g);if(k)return k;let O=!1;const m=new Proxy(g,{get(v,A,k){if(A===e)return!0;if(A===r)return g;let O;try{O=Reflect.get(v,A,k)}catch{O=Reflect.get(v,A)}if(!h(A)&&void 0!==O){if(y(O))return K(O,w,b);if("function"==typeof O){const e=function(t,e,r,n){return{conflictArrayHandler:G(F,t,r,e,n),mutationArrayHandler:G(x,t,r,e,n),producerArrayHandler:G(I,t,r,e,n),iterationHandler:G(L,t,r,e,n),iteratorHandler:G(D,t,r,e,n),lookupArrayHandler:G(j,t,r,e),pickingArrayHandler:G(C,t,r,e,n),getHandler:G(R,t,r,n),setHandler:G(_,t,r,n),addHandler:G(V,t,r,n),hasHandler:G(M,t,r),deleteHandler:G(P,t,r,n),clearHandler:G(W,t,r,n),defaultHandler:G(E,t,r,e)}}(v,A,w,b);if(Array.isArray(v)){if(u.has(A))return e.conflictArrayHandler;if(n.has(A))return e.mutationArrayHandler;if(a.has(A))return e.producerArrayHandler;if(i.has(A))return e.iterationHandler;if(o.has(A))return e.iteratorHandler;if(s.has(A))return e.lookupArrayHandler;if(c.has(A))return e.pickingArrayHandler}if(p(v)&&l.has(A))return e.mutationArrayHandler;if(H(v)){if(A===t.Get)return e.getHandler;if(A===t.Set)return e.setHandler}if(S(v)&&A===t.Add)return e.addHandler;if(v instanceof Map&&f.has(A)||v instanceof Set&&d.has(A))return e.iterationHandler;if(function(t){return t instanceof Map||t instanceof Set}(v)){if(A===t.Clear)return e.clearHandler;if(o.has(A))return e.iteratorHandler}if(function(t){return H(t)||S(t)}(v)){if(A===t.Has)return e.hasHandler;if(A===t.Delete)return e.deleteHandler}return e.defaultHandler}}return O},set(t,e,r,n){if(h(e))return!0;const a=t[e];if(!Object.is(a,r)){O=!0;const i=Reflect.set(t,e,r,n);return O=!1,i&&b({target:m,action:"set",key:e,value:r,prevValue:a}),i}return!0},deleteProperty(t,e){if(h(e))return!0;if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e],n=Reflect.deleteProperty(t,e);return n&&b({target:m,action:"delete",key:e,value:void 0,prevValue:r}),n}return!0},defineProperty(t,e,r){if(h(e))return!0;const n=t[e],a=Reflect.defineProperty(t,e,r);if(!O&&a){const t=r.value;Object.is(n,t)||b({target:m,action:"define",key:e,value:t,prevValue:n})}return a},setPrototypeOf:()=>!0});return(A??1)&&w.set(g,m),m}exports.default=function(t,e,r){const n=r?.cache??new WeakMap;return K(Object.preventExtensions({value:t}),n,e)},exports.getRaw=b,exports.isRef=g;
package/dist/index.d.ts CHANGED
@@ -70,7 +70,8 @@ type Ref<T> = {
70
70
  */
71
71
  declare function ref<T>(initial: T, onchange: OnChangeHandler, options?: RefOptions): Ref<T>;
72
72
 
73
+ declare function isProxyTry(value: any): boolean;
73
74
  declare function getRawTry(value: any): any;
74
75
 
75
- export { ref as default, getRawTry as getRaw };
76
+ export { ref as default, getRawTry as getRaw, isProxyTry as isRef };
76
77
  export type { ChangeEvent, OnChangeHandler, Ref, RefOptions };
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"]),i=new Set(["every","findIndex","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some"]),o=new Set(["entries","keys","values",Symbol.iterator]),s=new Set(["includes","indexOf","lastIndexOf"]),c=new Set(["at"]),u=new Set(["filter","find","findLast","pop","shift","sort","splice","toSorted"]),l=new Set(["copyWithin","fill","reverse","set","sort"]),f=new Set(["forEach"]),d=new Set(["forEach"]);function h(e){return t.ForbiddenKeys.has(e)}function p(t){return"object"==typeof t&&null!==t}function y(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function v(t){return Array.isArray(t)||y(t)}function g(t){return t[e]??!1}function H(t){return t instanceof Map||t instanceof WeakMap}function S(t){return t instanceof Set||t instanceof WeakSet}function w(t){return t[r]}function b(t){return p(t)&&g(t)?w(t):t}function A(...t){const[e]=t;return p(e)?K(...t):e}function k(t){return t.map(t=>b(t))}function j(t,e,r){return t.map(t=>A(t,e,r,!1))}function m(t,e,...r){if(r.length>0){const[n,...a]=r;if("function"==typeof n){function i(...r){const a=r.map(r=>A(r,t,e));return n.apply(this,a)}return[i,...a]}}return r}function O(t,e,r,...n){const a=e.has(this)?k(n):n;return t[r].apply(this,a)}function V(t,e,r,n,...a){const i=e.get(this),o=i?k(a):a,s=t[r].apply(this,o);return i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),s}function x(t,e,r,...n){const a=e.get(this),[i]=n,o=a?b(i):i;return t.has.call(this,o)||(t.add.call(this,o),a&&r({target:a,action:"add",key:i,value:i,prevValue:void 0})),a??this}function P(t,e,r,...n){const a=e.get(this),[i]=n,o=a?b(i):i,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&&a&&r({target:a,action:"delete",key:i,value:void 0,prevValue:s}),c}function R(t,e,r,...n){const a=e.has(this),[i]=n,o=a?b(i):i,s=t.get.call(this,o);return a?A(s,e,r):s}function M(t,e,...r){const n=e.has(this),[a]=r,i=n?b(a):a;return t.has.call(this,i)}function W(t,e,r,...n){const a=e.get(this),[i,o]=n,s=a?b(i):i,c=a?b(o):o,u=t.get.call(this,s);return Object.is(c,u)||(t.set.call(this,s,c),a&&r({target:a,action:"set",key:i,value:o,prevValue:u})),a??this}function _(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 E(t,e,r,...n){const a=g(this)||e.has(this)?k(n):n;return t[r].apply(this,a)}function L(t,e,r,n,...a){const i=e.has(this)?m(e,n,...a):a;return t[r].apply(this,i)}function D(t,e,r,n){const a=e.get(this),i=t[r].call(this);return a?function(t,...e){const[r,n,a,i]=e,o=Array.isArray(r),s="entries"===a||H(r)&&a===Symbol.iterator,c={next(e){const r=b(this===c?t:this),a=t.next.call(r,e);if(!a.done)if(s)if(o){const[,t]=a.value;a.value[1]=A(t,n,i)}else a.value=a.value.map(t=>A(t,n,i));else a.value=A(a.value,n,i);return a},[Symbol.iterator](){return b(this)}};return c}(i,this,e,r,n):i}function I(t,e,r,n,...a){const i=e.has(this),o=i?k(a):a,s=t[r].apply(this,o);return i?j(s,e,n):s}function C(t,e,r,n,...a){const i=e.has(this),o=i?k(a):a,s=t[r].apply(this,o);return i?A(s,e,n):s}function F(t,e,r,n,...a){const i=e.get(this);let o;switch(r){case"filter":case"find":case"findLast":case"sort":case"toSorted":const s=i?m(e,n,...a):a;switch(o=t[r].apply(this,s),r){case"filter":case"toSorted":return i?j(o,e,n):o;case"find":case"findLast":return i?A(o,e,n):o;case"sort":return i&&n({target:i,action:"sort",key:void 0,value:a,prevValue:void 0}),i??this}case"pop":case"shift":case"splice":const c=i?k(a):a;switch(o=t[r].apply(this,c),i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),r){case"pop":case"shift":return i?A(o,e,n,!1):o;case"splice":return i?j(o,e,n):o}}}function G(t,...e){return function(...r){const[n,a]=e;let i;var o;return o=n,i="[object Object]"!==Object.prototype.toString.call(o)||Object.getPrototypeOf(o)!==Object.prototype&&!o.constructor?b(this):this,function(t,e){p(t)&&g(t)&&e.set(w(t),t)}(this,a),t.apply(i,e.concat(r))}}function K(p,w,b,A){if(g(p))return p;const k=w.get(p);if(k)return k;let j=!1;const m=new Proxy(p,{get(g,A,k){if(A===e)return!0;if(A===r)return p;let j;try{j=Reflect.get(g,A,k)}catch{j=Reflect.get(g,A)}if(!h(A)&&null!=j&&(v(j)||"object"==typeof j||"function"==typeof j)){if(v(j)||"object"==typeof j)return K(j,w,b);const e=function(t,e,r,n){return{conflictArrayHandler:G(F,t,r,e,n),mutationArrayHandler:G(V,t,r,e,n),producerArrayHandler:G(I,t,r,e,n),iterationHandler:G(L,t,r,e,n),iteratorHandler:G(D,t,r,e,n),lookupArrayHandler:G(O,t,r,e),pickingArrayHandler:G(C,t,r,e,n),getHandler:G(R,t,r,n),setHandler:G(W,t,r,n),addHandler:G(x,t,r,n),hasHandler:G(M,t,r),deleteHandler:G(P,t,r,n),clearHandler:G(_,t,r,n),defaultHandler:G(E,t,r,e)}}(g,A,w,b);if(Array.isArray(g)){if(u.has(A))return e.conflictArrayHandler;if(n.has(A))return e.mutationArrayHandler;if(a.has(A))return e.producerArrayHandler;if(i.has(A))return e.iterationHandler;if(o.has(A))return e.iteratorHandler;if(s.has(A))return e.lookupArrayHandler;if(c.has(A))return e.pickingArrayHandler}if(y(g)&&l.has(A))return e.mutationArrayHandler;if(H(g)){if(A===t.Get)return e.getHandler;if(A===t.Set)return e.setHandler}if(S(g)&&A===t.Add)return e.addHandler;if(g instanceof Map&&f.has(A)||g instanceof Set&&d.has(A))return e.iterationHandler;if(function(t){return t instanceof Map||t instanceof Set}(g)){if(A===t.Clear)return e.clearHandler;if(o.has(A))return e.iteratorHandler}if(function(t){return H(t)||S(t)}(g)){if(A===t.Has)return e.hasHandler;if(A===t.Delete)return e.deleteHandler}return e.defaultHandler}return j},set(t,e,r,n){if(h(e))return!0;const a=t[e];if(!Object.is(a,r)){j=!0;const i=Reflect.set(t,e,r,n);return j=!1,i&&b({target:m,action:"set",key:e,value:r,prevValue:a}),i}return!0},deleteProperty(t,e){if(h(e))return!0;if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e],n=Reflect.deleteProperty(t,e);return n&&b({target:m,action:"delete",key:e,value:void 0,prevValue:r}),n}return!0},defineProperty(t,e,r){if(h(e))return!0;const n=t[e],a=Reflect.defineProperty(t,e,r);if(!j&&a){const t=r.value;Object.is(n,t)||b({target:m,action:"define",key:e,value:t,prevValue:n})}return a},setPrototypeOf:()=>!0});return(A??1)&&w.set(p,m),m}function z(t,e,r){const n=r?.cache??new WeakMap;return K(Object.preventExtensions({value:t}),n,e)}export{z as default,b as getRaw};
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"]),i=new Set(["every","findIndex","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some"]),s=new Set(["entries","keys","values",Symbol.iterator]),o=new Set(["includes","indexOf","lastIndexOf"]),c=new Set(["at"]),u=new Set(["filter","find","findLast","pop","shift","sort","splice","toSorted"]),l=new Set(["copyWithin","fill","reverse","set","sort"]),f=new Set(["forEach"]),d=new Set(["forEach"]);function h(e){return t.ForbiddenKeys.has(e)}function p(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function y(t){return function(t){return"object"==typeof t&&null!==t}(t)||function(t){return Array.isArray(t)||p(t)}(t)}function v(t){return t[e]??!1}function g(t){return y(t)&&v(t)}function H(t){return t instanceof Map||t instanceof WeakMap}function S(t){return t instanceof Set||t instanceof WeakSet}function w(t){return t[r]}function A(t){return g(t)?w(t):t}function b(...t){const[e]=t;return y(e)?K(...t):e}function k(t){return t.map(t=>A(t))}function m(t,e,r){return t.map(t=>b(t,e,r,!1))}function O(t,e,...r){if(r.length>0){const[n,...a]=r;if("function"==typeof n){function i(...r){const a=r.map(r=>b(r,t,e));return n.apply(this,a)}return[i,...a]}}return r}function j(t,e,r,...n){const a=e.has(this)?k(n):n;return t[r].apply(this,a)}function V(t,e,r,n,...a){const i=e.get(this),s=i?k(a):a,o=t[r].apply(this,s);return i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),o}function x(t,e,r,...n){const a=e.get(this),[i]=n,s=a?A(i):i;return t.has.call(this,s)||(t.add.call(this,s),a&&r({target:a,action:"add",key:i,value:i,prevValue:void 0})),a??this}function R(t,e,r,...n){const a=e.get(this),[i]=n,s=a?A(i):i,o=function(t,e){return t instanceof WeakMap?t.get(e):t.has(e)?e:void 0}(this,s),c=t.delete.call(this,s);return c&&a&&r({target:a,action:"delete",key:i,value:void 0,prevValue:o}),c}function P(t,e,r,...n){const a=e.has(this),[i]=n,s=a?A(i):i,o=t.get.call(this,s);return a?b(o,e,r):o}function M(t,e,...r){const n=e.has(this),[a]=r,i=n?A(a):a;return t.has.call(this,i)}function W(t,e,r,...n){const a=e.get(this),[i,s]=n,o=a?A(i):i,c=a?A(s):s,u=t.get.call(this,o);return Object.is(c,u)||(t.set.call(this,o,c),a&&r({target:a,action:"set",key:i,value:s,prevValue:u})),a??this}function _(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 E(t,e,r,...n){const a=v(this)||e.has(this)?k(n):n;return t[r].apply(this,a)}function L(t,e,r,n,...a){const i=e.has(this)?O(e,n,...a):a;return t[r].apply(this,i)}function D(t,e,r,n){const a=e.get(this),i=t[r].call(this);return a?function(t,...e){const[r,n,a,i]=e,s=Array.isArray(r),o="entries"===a||H(r)&&a===Symbol.iterator,c={next(e){const r=A(this===c?t:this),a=t.next.call(r,e);if(!a.done)if(o)if(s){const[,t]=a.value;a.value[1]=b(t,n,i)}else a.value=a.value.map(t=>b(t,n,i));else a.value=b(a.value,n,i);return a},[Symbol.iterator](){return A(this)}};return c}(i,this,e,r,n):i}function I(t,e,r,n,...a){const i=e.has(this),s=i?k(a):a,o=t[r].apply(this,s);return i?m(o,e,n):o}function C(t,e,r,n,...a){const i=e.has(this),s=i?k(a):a,o=t[r].apply(this,s);return i?b(o,e,n):o}function F(t,e,r,n,...a){const i=e.get(this);let s;switch(r){case"filter":case"find":case"findLast":case"sort":case"toSorted":const o=i?O(e,n,...a):a;switch(s=t[r].apply(this,o),r){case"filter":case"toSorted":return i?m(s,e,n):s;case"find":case"findLast":return i?b(s,e,n):s;case"sort":return i&&n({target:i,action:"sort",key:void 0,value:a,prevValue:void 0}),i??this}case"pop":case"shift":case"splice":const c=i?k(a):a;switch(s=t[r].apply(this,c),i&&n({target:i,action:r,key:void 0,value:a,prevValue:void 0}),r){case"pop":case"shift":return i?b(s,e,n,!1):s;case"splice":return i?m(s,e,n):s}}}function G(t,...e){return function(...r){const[n,a]=e;let i;var s;return s=n,i="[object Object]"!==Object.prototype.toString.call(s)||Object.getPrototypeOf(s)!==Object.prototype&&!s.constructor?A(this):this,function(t,e){g(t)&&e.set(w(t),t)}(this,a),t.apply(i,e.concat(r))}}function K(g,w,A,b){if(v(g))return g;const k=w.get(g);if(k)return k;let m=!1;const O=new Proxy(g,{get(v,b,k){if(b===e)return!0;if(b===r)return g;let m;try{m=Reflect.get(v,b,k)}catch{m=Reflect.get(v,b)}if(!h(b)&&void 0!==m){if(y(m))return K(m,w,A);if("function"==typeof m){const e=function(t,e,r,n){return{conflictArrayHandler:G(F,t,r,e,n),mutationArrayHandler:G(V,t,r,e,n),producerArrayHandler:G(I,t,r,e,n),iterationHandler:G(L,t,r,e,n),iteratorHandler:G(D,t,r,e,n),lookupArrayHandler:G(j,t,r,e),pickingArrayHandler:G(C,t,r,e,n),getHandler:G(P,t,r,n),setHandler:G(W,t,r,n),addHandler:G(x,t,r,n),hasHandler:G(M,t,r),deleteHandler:G(R,t,r,n),clearHandler:G(_,t,r,n),defaultHandler:G(E,t,r,e)}}(v,b,w,A);if(Array.isArray(v)){if(u.has(b))return e.conflictArrayHandler;if(n.has(b))return e.mutationArrayHandler;if(a.has(b))return e.producerArrayHandler;if(i.has(b))return e.iterationHandler;if(s.has(b))return e.iteratorHandler;if(o.has(b))return e.lookupArrayHandler;if(c.has(b))return e.pickingArrayHandler}if(p(v)&&l.has(b))return e.mutationArrayHandler;if(H(v)){if(b===t.Get)return e.getHandler;if(b===t.Set)return e.setHandler}if(S(v)&&b===t.Add)return e.addHandler;if(v instanceof Map&&f.has(b)||v instanceof Set&&d.has(b))return e.iterationHandler;if(function(t){return t instanceof Map||t instanceof Set}(v)){if(b===t.Clear)return e.clearHandler;if(s.has(b))return e.iteratorHandler}if(function(t){return H(t)||S(t)}(v)){if(b===t.Has)return e.hasHandler;if(b===t.Delete)return e.deleteHandler}return e.defaultHandler}}return m},set(t,e,r,n){if(h(e))return!0;const a=t[e];if(!Object.is(a,r)){m=!0;const i=Reflect.set(t,e,r,n);return m=!1,i&&A({target:O,action:"set",key:e,value:r,prevValue:a}),i}return!0},deleteProperty(t,e){if(h(e))return!0;if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e],n=Reflect.deleteProperty(t,e);return n&&A({target:O,action:"delete",key:e,value:void 0,prevValue:r}),n}return!0},defineProperty(t,e,r){if(h(e))return!0;const n=t[e],a=Reflect.defineProperty(t,e,r);if(!m&&a){const t=r.value;Object.is(n,t)||A({target:O,action:"define",key:e,value:t,prevValue:n})}return a},setPrototypeOf:()=>!0});return(b??1)&&w.set(g,O),O}function z(t,e,r){const n=r?.cache??new WeakMap;return K(Object.preventExtensions({value:t}),n,e)}export{z as default,A as getRaw,g as isRef};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vref",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "author": "John Soatra",
6
6
  "description": "A Javascript library for reactive state management.",