Comparing version 1.10.1 to 1.10.2
@@ -15,2 +15,3 @@ import ReactExports, { useRef, useCallback, useEffect, useMemo, useDebugValue } from 'react'; | ||
}; | ||
const targetCache = /* @__PURE__ */ new WeakMap(); | ||
function useSnapshot(proxyObject, options) { | ||
@@ -57,5 +58,10 @@ const notifyInSync = options == null ? void 0 : options.sync; | ||
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []); | ||
return createProxy(currSnapshot, currAffected, proxyCache); | ||
return createProxy( | ||
currSnapshot, | ||
currAffected, | ||
proxyCache, | ||
targetCache | ||
); | ||
} | ||
export { useSnapshot }; |
@@ -30,3 +30,6 @@ import { markToTrack, getUntracked } from 'proxy-compare'; | ||
value, | ||
enumerable: true | ||
enumerable: true, | ||
// This is intentional to avoid copying with proxy-compare. | ||
// It's still non-writable, so it avoids assigning a value. | ||
configurable: true | ||
}; | ||
@@ -39,3 +42,10 @@ if (refSet.has(value)) { | ||
} else if (proxyStateMap.has(value)) { | ||
desc.value = snapshot(value, handlePromise); | ||
const [target2, ensureVersion] = proxyStateMap.get( | ||
value | ||
); | ||
desc.value = createSnapshot( | ||
target2, | ||
ensureVersion(), | ||
handlePromise | ||
); | ||
} | ||
@@ -45,3 +55,3 @@ Object.defineProperty(snap, key, desc); | ||
return snap; | ||
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = function proxyFunction3(initialObject) { | ||
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { | ||
if (!isObject(initialObject)) { | ||
@@ -158,3 +168,3 @@ throw new Error("object required"); | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction3(value); | ||
nextValue = proxyFunction(value); | ||
} | ||
@@ -195,3 +205,3 @@ const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
// public functions | ||
proxyFunction2, | ||
proxyFunction, | ||
// shared state | ||
@@ -210,5 +220,5 @@ proxyStateMap, | ||
]; | ||
const [proxyFunction] = buildProxyFunction(); | ||
const [defaultProxyFunction] = buildProxyFunction(); | ||
function proxy(initialObject = {}) { | ||
return proxyFunction(initialObject); | ||
return defaultProxyFunction(initialObject); | ||
} | ||
@@ -215,0 +225,0 @@ function getVersion(proxyObject) { |
{ | ||
"name": "valtio", | ||
"private": false, | ||
"version": "1.10.1", | ||
"version": "1.10.2", | ||
"description": "💊 Valtio makes proxy-state simple for React and Vanilla", | ||
@@ -67,3 +67,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"proxy-compare": "2.4.1", | ||
"proxy-compare": "2.5.0", | ||
"use-sync-external-store": "1.2.0" | ||
@@ -70,0 +70,0 @@ }, |
@@ -17,2 +17,3 @@ 'use strict'; | ||
}; | ||
var targetCache = new WeakMap(); | ||
function useSnapshot(proxyObject, options) { | ||
@@ -50,5 +51,5 @@ var notifyInSync = options == null ? void 0 : options.sync; | ||
}, []); | ||
return proxyCompare.createProxy(currSnapshot, currAffected, proxyCache); | ||
return proxyCompare.createProxy(currSnapshot, currAffected, proxyCache, targetCache); | ||
} | ||
exports.useSnapshot = useSnapshot; |
@@ -35,2 +35,3 @@ System.register(['react', 'proxy-compare', 'use-sync-external-store/shim', 'valtio/vanilla'], (function (exports) { | ||
}; | ||
const targetCache = /* @__PURE__ */ new WeakMap(); | ||
function useSnapshot(proxyObject, options) { | ||
@@ -77,3 +78,8 @@ const notifyInSync = options == null ? void 0 : options.sync; | ||
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []); | ||
return createProxy(currSnapshot, currAffected, proxyCache); | ||
return createProxy( | ||
currSnapshot, | ||
currAffected, | ||
proxyCache, | ||
targetCache | ||
); | ||
} | ||
@@ -80,0 +86,0 @@ |
@@ -1,1 +0,1 @@ | ||
System.register(["react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],function(v){"use strict";var s,a,o,i,f,p,l,h,y,c;return{setters:[function(e){s=e.useRef,a=e.useCallback,o=e.useEffect,i=e.useMemo,f=e.default},function(e){p=e.isChanged,l=e.createProxy},function(e){h=e.default},function(e){y=e.subscribe,c=e.snapshot}],execute:function(){v("useSnapshot",g);const{use:e}=f,{useSyncExternalStore:C}=h;function g(n,b){const x=b==null?void 0:b.sync,r=s(),u=s();let M=!0;const S=C(a(t=>{const E=y(n,t,x);return t(),E},[n,x]),()=>{const t=c(n,e);try{if(!M&&r.current&&u.current&&!p(r.current,t,u.current,new WeakMap))return r.current}catch{}return t},()=>c(n,e));M=!1;const k=new WeakMap;o(()=>{r.current=S,u.current=k});const w=i(()=>new WeakMap,[]);return l(S,k,w)}}}}); | ||
System.register(["react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],function(w){"use strict";var s,a,o,i,f,p,l,h,y,c;return{setters:[function(e){s=e.useRef,a=e.useCallback,o=e.useEffect,i=e.useMemo,f=e.default},function(e){p=e.isChanged,l=e.createProxy},function(e){h=e.default},function(e){y=e.subscribe,c=e.snapshot}],execute:function(){w("useSnapshot",W);const{use:e}=f,{useSyncExternalStore:v}=h,C=new WeakMap;function W(t,b){const k=b==null?void 0:b.sync,r=s(),u=s();let x=!0;const M=v(a(n=>{const E=y(t,n,k);return n(),E},[t,k]),()=>{const n=c(t,e);try{if(!x&&r.current&&u.current&&!p(r.current,n,u.current,new WeakMap))return r.current}catch{}return n},()=>c(t,e));x=!1;const S=new WeakMap;o(()=>{r.current=M,u.current=S});const g=i(()=>new WeakMap,[]);return l(M,S,g,C)}}}}); |
@@ -46,3 +46,6 @@ System.register(['proxy-compare'], (function (exports) { | ||
value, | ||
enumerable: true | ||
enumerable: true, | ||
// This is intentional to avoid copying with proxy-compare. | ||
// It's still non-writable, so it avoids assigning a value. | ||
configurable: true | ||
}; | ||
@@ -55,3 +58,10 @@ if (refSet.has(value)) { | ||
} else if (proxyStateMap.has(value)) { | ||
desc.value = snapshot(value, handlePromise); | ||
const [target2, ensureVersion] = proxyStateMap.get( | ||
value | ||
); | ||
desc.value = createSnapshot( | ||
target2, | ||
ensureVersion(), | ||
handlePromise | ||
); | ||
} | ||
@@ -61,3 +71,3 @@ Object.defineProperty(snap, key, desc); | ||
return snap; | ||
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = function proxyFunction3(initialObject) { | ||
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { | ||
if (!isObject(initialObject)) { | ||
@@ -174,3 +184,3 @@ throw new Error("object required"); | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction3(value); | ||
nextValue = proxyFunction(value); | ||
} | ||
@@ -211,3 +221,3 @@ const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
// public functions | ||
proxyFunction2, | ||
proxyFunction, | ||
// shared state | ||
@@ -226,5 +236,5 @@ proxyStateMap, | ||
]; | ||
const [proxyFunction] = buildProxyFunction(); | ||
const [defaultProxyFunction] = buildProxyFunction(); | ||
function proxy(initialObject = {}) { | ||
return proxyFunction(initialObject); | ||
return defaultProxyFunction(initialObject); | ||
} | ||
@@ -231,0 +241,0 @@ function getVersion(proxyObject) { |
@@ -1,1 +0,1 @@ | ||
System.register(["proxy-compare"],function(z){"use strict";var A,T;return{setters:[function(j){A=j.markToTrack,T=j.getUntracked}],execute:function(){z({getVersion:_,proxy:U,ref:B,snapshot:V,subscribe:q});const j=c=>typeof c=="object"&&c!==null,b=new WeakMap,k=new WeakSet,D=(c=Object.is,i=(r,s)=>new Proxy(r,s),v=r=>j(r)&&!k.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer),O=r=>{switch(r.status){case"fulfilled":return r.value;case"rejected":throw r.reason;default:throw r}},l=new WeakMap,p=(r,s,E=O)=>{const d=l.get(r);if((d==null?void 0:d[0])===s)return d[1];const a=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r));return A(a,!0),l.set(r,[s,a]),Reflect.ownKeys(r).forEach(g=>{if(Object.getOwnPropertyDescriptor(a,g))return;const f=Reflect.get(r,g),P={value:f,enumerable:!0};k.has(f)?A(f,!1):f instanceof Promise?(delete P.value,P.get=()=>E(f)):b.has(f)&&(P.value=V(f,E)),Object.defineProperty(a,g,P)}),a},w=new WeakMap,u=[1,1],x=function r(s){if(!j(s))throw new Error("object required");const E=w.get(s);if(E)return E;let d=u[0];const a=new Set,g=(n,t=++u[0])=>{d!==t&&(d=t,a.forEach(e=>e(n,t)))};let f=u[1];const P=(n=++u[1])=>(f!==n&&!a.size&&(f=n,y.forEach(([t])=>{const e=t[1](n);e>d&&(d=e)})),d),F=n=>(t,e)=>{const o=[...t];o[1]=[n,...o[1]],g(o,e)},y=new Map,L=(n,t)=>{if(a.size){const e=t[3](F(n));y.set(n,[t,e])}else y.set(n,[t])},K=n=>{var t;const e=y.get(n);e&&(y.delete(n),(t=e[1])==null||t.call(e))},C=n=>(a.add(n),a.size===1&&y.forEach(([t,e],o)=>{const M=t[3](F(o));y.set(o,[t,M])}),()=>{a.delete(n),a.size===0&&y.forEach(([t,e],o)=>{e&&(e(),y.set(o,[t]))})}),W=Array.isArray(s)?[]:Object.create(Object.getPrototypeOf(s)),R=i(W,{deleteProperty(n,t){const e=Reflect.get(n,t);K(t);const o=Reflect.deleteProperty(n,t);return o&&g(["delete",[t],e]),o},set(n,t,e,o){const M=Reflect.has(n,t),S=Reflect.get(n,t,o);if(M&&(c(S,e)||w.has(e)&&c(S,w.get(e))))return!0;K(t),j(e)&&(e=T(e)||e);let m=e;if(e instanceof Promise)e.then(h=>{e.status="fulfilled",e.value=h,g(["resolve",[t],h])}).catch(h=>{e.status="rejected",e.reason=h,g(["reject",[t],h])});else{!b.has(e)&&v(e)&&(m=r(e));const h=!k.has(m)&&b.get(m);h&&L(t,h)}return Reflect.set(n,t,m,o),g(["set",[t],e,S]),!0}});w.set(s,R);const G=[W,P,p,C];return b.set(R,G),Reflect.ownKeys(s).forEach(n=>{const t=Object.getOwnPropertyDescriptor(s,n),e="value"in t;delete t.value,Object.defineProperty(W,n,t),e&&(R[n]=s[n])}),R})=>[x,b,k,c,i,v,O,l,p,w,u],[N]=D();function U(c={}){return N(c)}function _(c){const i=b.get(c);return i==null?void 0:i[1]()}function q(c,i,v){const O=b.get(c);let l;const p=[],w=O[3];let u=!1;const x=w(r=>{if(p.push(r),v){i(p.splice(0));return}l||(l=Promise.resolve().then(()=>{l=void 0,u&&i(p.splice(0))}))});return u=!0,()=>{u=!1,x()}}function V(c,i){const v=b.get(c),[O,l,p]=v;return p(O,l(),i)}function B(c){return k.add(c),c}const H=z("unstable_buildProxyFunction",D)}}}); | ||
System.register(["proxy-compare"],function(D){"use strict";var W,K;return{setters:[function(j){W=j.markToTrack,K=j.getUntracked}],execute:function(){D({getVersion:_,proxy:U,ref:L,snapshot:B,subscribe:q});const j=c=>typeof c=="object"&&c!==null,l=new WeakMap,m=new WeakSet,T=(c=Object.is,f=(t,v)=>new Proxy(t,v),P=t=>j(t)&&!m.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),k=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},u=new WeakMap,g=(t,v,b=k)=>{const s=u.get(t);if((s==null?void 0:s[0])===v)return s[1];const a=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return W(a,!0),u.set(t,[v,a]),Reflect.ownKeys(t).forEach(O=>{if(Object.getOwnPropertyDescriptor(a,O))return;const d=Reflect.get(t,O),w={value:d,enumerable:!0,configurable:!0};if(m.has(d))W(d,!1);else if(d instanceof Promise)delete w.value,w.get=()=>b(d);else if(l.has(d)){const[i,x]=l.get(d);w.value=g(i,x(),b)}Object.defineProperty(a,O,w)}),a},h=new WeakMap,y=[1,1],E=t=>{if(!j(t))throw new Error("object required");const v=h.get(t);if(v)return v;let b=y[0];const s=new Set,a=(n,r=++y[0])=>{b!==r&&(b=r,s.forEach(e=>e(n,r)))};let O=y[1];const d=(n=++y[1])=>(O!==n&&!s.size&&(O=n,i.forEach(([r])=>{const e=r[1](n);e>b&&(b=e)})),b),w=n=>(r,e)=>{const o=[...r];o[1]=[n,...o[1]],a(o,e)},i=new Map,x=(n,r)=>{if(s.size){const e=r[3](w(n));i.set(n,[r,e])}else i.set(n,[r])},V=n=>{var r;const e=i.get(n);e&&(i.delete(n),(r=e[1])==null||r.call(e))},N=n=>(s.add(n),s.size===1&&i.forEach(([r,e],o)=>{const z=r[3](w(o));i.set(o,[r,z])}),()=>{s.delete(n),s.size===0&&i.forEach(([r,e],o)=>{e&&(e(),i.set(o,[r]))})}),S=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),R=f(S,{deleteProperty(n,r){const e=Reflect.get(n,r);V(r);const o=Reflect.deleteProperty(n,r);return o&&a(["delete",[r],e]),o},set(n,r,e,o){const z=Reflect.has(n,r),M=Reflect.get(n,r,o);if(z&&(c(M,e)||h.has(e)&&c(M,h.get(e))))return!0;V(r),j(e)&&(e=K(e)||e);let A=e;if(e instanceof Promise)e.then(p=>{e.status="fulfilled",e.value=p,a(["resolve",[r],p])}).catch(p=>{e.status="rejected",e.reason=p,a(["reject",[r],p])});else{!l.has(e)&&P(e)&&(A=E(e));const p=!m.has(A)&&l.get(A);p&&x(r,p)}return Reflect.set(n,r,A,o),a(["set",[r],e,M]),!0}});h.set(t,R);const C=[S,d,g,N];return l.set(R,C),Reflect.ownKeys(t).forEach(n=>{const r=Object.getOwnPropertyDescriptor(t,n),e="value"in r;delete r.value,Object.defineProperty(S,n,r),e&&(R[n]=t[n])}),R})=>[E,l,m,c,f,P,k,u,g,h,y],[F]=T();function U(c={}){return F(c)}function _(c){const f=l.get(c);return f==null?void 0:f[1]()}function q(c,f,P){const k=l.get(c);let u;const g=[],h=k[3];let y=!1;const E=h(t=>{if(g.push(t),P){f(g.splice(0));return}u||(u=Promise.resolve().then(()=>{u=void 0,y&&f(g.splice(0))}))});return y=!0,()=>{y=!1,E()}}function B(c,f){const P=l.get(c),[k,u,g]=P;return g(k,u(),f)}function L(c){return m.add(c),c}const G=D("unstable_buildProxyFunction",T)}}}); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@babel/helper-module-imports'), require('@babel/types'), require('babel-plugin-macros')) : | ||
typeof define === 'function' && define.amd ? define(['@babel/helper-module-imports', '@babel/types', 'babel-plugin-macros'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.valtio = factory(global.helperModuleImports, global.t, global.babelPluginMacros)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.valtioMacro = factory(global.helperModuleImports, global.t, global.babelPluginMacros)); | ||
})(this, (function (helperModuleImports, t, babelPluginMacros) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("@babel/helper-module-imports"),require("@babel/types"),require("babel-plugin-macros")):"function"==typeof define&&define.amd?define(["@babel/helper-module-imports","@babel/types","babel-plugin-macros"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).valtio=n(e.helperModuleImports,e.t,e.babelPluginMacros)}(this,(function(e,n,t){"use strict";function r(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var a=r(n);return t.createMacro((function(n){var r;null==(r=n.references.useProxy)||r.forEach((function(n){var r,o,i,l,u,c,f=e.addNamed(n,"useSnapshot","valtio"),s=null==(r=n.parentPath)||null==(o=r.get("arguments.0"))?void 0:o.node;if(!a.isIdentifier(s))throw new t.MacroError("no proxy object");var p=a.identifier("valtio_macro_snap_"+s.name);null==(i=n.parentPath)||null==(l=i.parentPath)||l.replaceWith(a.variableDeclaration("const",[a.variableDeclarator(p,a.callExpression(f,[s]))]));var d=0;null==(u=n.parentPath)||null==(c=u.getFunctionParent())||c.traverse({Identifier:function(e){0===d&&e.node!==s&&e.node.name===s.name&&(e.node.name=p.name)},Function:{enter:function(){++d},exit:function(){--d}}})}))}),{configName:"valtio"})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("@babel/helper-module-imports"),require("@babel/types"),require("babel-plugin-macros")):"function"==typeof define&&define.amd?define(["@babel/helper-module-imports","@babel/types","babel-plugin-macros"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).valtioMacro=n(e.helperModuleImports,e.t,e.babelPluginMacros)}(this,(function(e,n,t){"use strict";function r(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var a=r(n);return t.createMacro((function(n){var r;null==(r=n.references.useProxy)||r.forEach((function(n){var r,o,i,l,u,c,f=e.addNamed(n,"useSnapshot","valtio"),s=null==(r=n.parentPath)||null==(o=r.get("arguments.0"))?void 0:o.node;if(!a.isIdentifier(s))throw new t.MacroError("no proxy object");var p=a.identifier("valtio_macro_snap_"+s.name);null==(i=n.parentPath)||null==(l=i.parentPath)||l.replaceWith(a.variableDeclaration("const",[a.variableDeclarator(p,a.callExpression(f,[s]))]));var d=0;null==(u=n.parentPath)||null==(c=u.getFunctionParent())||c.traverse({Identifier:function(e){0===d&&e.node!==s&&e.node.name===s.name&&(e.node.name=p.name)},Function:{enter:function(){++d},exit:function(){--d}}})}))}),{configName:"valtio"})})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/helper-module-imports'), require('@babel/types'), require('aslemammad-vite-plugin-macro'), require('babel-plugin-macros')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@babel/helper-module-imports', '@babel/types', 'aslemammad-vite-plugin-macro', 'babel-plugin-macros'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioVite = {}, global.babelModuleImports, global.t, global.plugin, global.babelMacro)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioMacroVite = {}, global.babelModuleImports, global.t, global.plugin, global.babelMacro)); | ||
})(this, (function (exports, babelModuleImports, t, plugin, babelMacro) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/helper-module-imports"),require("@babel/types"),require("aslemammad-vite-plugin-macro"),require("babel-plugin-macros")):"function"==typeof define&&define.amd?define(["exports","@babel/helper-module-imports","@babel/types","aslemammad-vite-plugin-macro","babel-plugin-macros"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioVite={},e.babelModuleImports,e.t,e.plugin,e.babelMacro)}(this,(function(e,t,r,a,n){"use strict";function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=o(t),l=o(r),u=o(a),c=o(n),d="default"in u?u.default:u,f=d.defineMacro,s=d.defineMacroProvider,p=d.createMacroPlugin,b=f("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler((function(e){var t,r,a,n,o=e.path,u=e.args,d=i.addNamed(o,"useSnapshot","valtio"),f=null==(t=u[0])?void 0:t.node;if(!l.isIdentifier(f))throw new c.MacroError("no proxy object");var s=l.identifier("valtio_macro_snap_"+f.name);null==(r=o.parentPath)||r.replaceWith(l.variableDeclaration("const",[l.variableDeclarator(s,l.callExpression(d,[f]))]));var p=0;null==(a=o.parentPath)||null==(n=a.getFunctionParent())||n.traverse({Identifier:function(e){0===p&&e.node!==f&&e.node.name===f.name&&(e.node.name=s.name)},Function:{enter:function(){++p},exit:function(){--p}}})}));function m(){return s({id:"valtio/macro",exports:{"valtio/macro":{macros:[b]}}})}var v=p({}).use(m());e.default=v,e.provideValtioMacro=m,e.valtioMacro=b,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/helper-module-imports"),require("@babel/types"),require("aslemammad-vite-plugin-macro"),require("babel-plugin-macros")):"function"==typeof define&&define.amd?define(["exports","@babel/helper-module-imports","@babel/types","aslemammad-vite-plugin-macro","babel-plugin-macros"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioMacroVite={},e.babelModuleImports,e.t,e.plugin,e.babelMacro)}(this,(function(e,t,r,a,o){"use strict";function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=n(t),l=n(r),u=n(a),c=n(o),d="default"in u?u.default:u,f=d.defineMacro,s=d.defineMacroProvider,p=d.createMacroPlugin,b=f("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler((function(e){var t,r,a,o,n=e.path,u=e.args,d=i.addNamed(n,"useSnapshot","valtio"),f=null==(t=u[0])?void 0:t.node;if(!l.isIdentifier(f))throw new c.MacroError("no proxy object");var s=l.identifier("valtio_macro_snap_"+f.name);null==(r=n.parentPath)||r.replaceWith(l.variableDeclaration("const",[l.variableDeclarator(s,l.callExpression(d,[f]))]));var p=0;null==(a=n.parentPath)||null==(o=a.getFunctionParent())||o.traverse({Identifier:function(e){0===p&&e.node!==f&&e.node.name===f.name&&(e.node.name=s.name)},Function:{enter:function(){++p},exit:function(){--p}}})}));function m(){return s({id:"valtio/macro",exports:{"valtio/macro":{macros:[b]}}})}var v=p({}).use(m());e.default=v,e.provideValtioMacro=m,e.valtioMacro=b,Object.defineProperty(e,"__esModule",{value:!0})})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('proxy-compare'), require('use-sync-external-store/shim'), require('valtio/vanilla')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'proxy-compare', 'use-sync-external-store/shim', 'valtio/vanilla'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtio = {}, global.React, global.proxyCompare, global.useSyncExternalStoreExports, global.valtioVanilla)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioReact = {}, global.React, global.proxyCompare, global.useSyncExternalStoreExports, global.valtioVanilla)); | ||
})(this, (function (exports, ReactExports, proxyCompare, useSyncExternalStoreExports, vanilla) { 'use strict'; | ||
@@ -16,2 +16,3 @@ | ||
}; | ||
var targetCache = new WeakMap(); | ||
function useSnapshot(proxyObject, options) { | ||
@@ -49,3 +50,3 @@ var notifyInSync = options == null ? void 0 : options.sync; | ||
}, []); | ||
return proxyCompare.createProxy(currSnapshot, currAffected, proxyCache); | ||
return proxyCompare.createProxy(currSnapshot, currAffected, proxyCache, targetCache); | ||
} | ||
@@ -52,0 +53,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("proxy-compare"),require("use-sync-external-store/shim"),require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.React,e.proxyCompare,e.useSyncExternalStoreExports,e.valtioVanilla)}(this,(function(e,r,n,t,a){"use strict";var u=r.use,o=t.useSyncExternalStore;e.useSnapshot=function(e,t){var s=null==t?void 0:t.sync,i=r.useRef(),c=r.useRef(),f=!0,l=o(r.useCallback((function(r){var n=a.subscribe(e,r,s);return r(),n}),[e,s]),(function(){var r=a.snapshot(e,u);try{if(!f&&i.current&&c.current&&!n.isChanged(i.current,r,c.current,new WeakMap))return i.current}catch(e){}return r}),(function(){return a.snapshot(e,u)}));f=!1;var p=new WeakMap;r.useEffect((function(){i.current=l,c.current=p}));var y=r.useMemo((function(){return new WeakMap}),[]);return n.createProxy(l,p,y)}})); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("proxy-compare"),require("use-sync-external-store/shim"),require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).valtioReact={},e.React,e.proxyCompare,e.useSyncExternalStoreExports,e.valtioVanilla)}(this,(function(e,r,n,t,a){"use strict";var u=r.use,o=t.useSyncExternalStore,s=new WeakMap;e.useSnapshot=function(e,t){var c=null==t?void 0:t.sync,i=r.useRef(),f=r.useRef(),l=!0,p=o(r.useCallback((function(r){var n=a.subscribe(e,r,c);return r(),n}),[e,c]),(function(){var r=a.snapshot(e,u);try{if(!l&&i.current&&f.current&&!n.isChanged(i.current,r,f.current,new WeakMap))return i.current}catch(e){}return r}),(function(){return a.snapshot(e,u)}));l=!1;var y=new WeakMap;r.useEffect((function(){i.current=p,f.current=y}));var v=r.useMemo((function(){return new WeakMap}),[]);return n.createProxy(p,y,v,s)}})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('valtio/react')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'valtio/react'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioUtils = {}, global.React, global.valtioReact)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioReactUtils = {}, global.React, global.valtioReact)); | ||
})(this, (function (exports, react$1, react) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("valtio/react")):"function"==typeof define&&define.amd?define(["exports","react","valtio/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioUtils={},e.React,e.valtioReact)}(this,(function(e,t,o){"use strict";e.useProxy=function(e){var n=o.useSnapshot(e),i=!0;return t.useLayoutEffect((function(){i=!1})),new Proxy(e,{get:function(e,t){return i?n[t]:e[t]}})}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("valtio/react")):"function"==typeof define&&define.amd?define(["exports","react","valtio/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioReactUtils={},e.React,e.valtioReact)}(this,(function(e,t,o){"use strict";e.useProxy=function(e){var n=o.useSnapshot(e),i=!0;return t.useLayoutEffect((function(){i=!1})),new Proxy(e,{get:function(e,t){return i?n[t]:e[t]}})}})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('valtio/vanilla/utils'), require('valtio/react/utils')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'valtio/vanilla/utils', 'valtio/react/utils'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtio = {}, global.valtioVanillaUtils, global.valtioReactUtils)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioUtils = {}, global.valtioVanillaUtils, global.valtioReactUtils)); | ||
})(this, (function (exports, utils, utils$1) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("valtio/vanilla/utils"),require("valtio/react/utils")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla/utils","valtio/react/utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.valtioVanillaUtils,e.valtioReactUtils)}(this,(function(e,t,i){"use strict";Object.keys(t).forEach((function(i){"default"===i||e.hasOwnProperty(i)||Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[i]}})})),Object.keys(i).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}})}))})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("valtio/vanilla/utils"),require("valtio/react/utils")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla/utils","valtio/react/utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioUtils={},e.valtioVanillaUtils,e.valtioReactUtils)}(this,(function(e,t,i){"use strict";Object.keys(t).forEach((function(i){"default"===i||e.hasOwnProperty(i)||Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[i]}})})),Object.keys(i).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}})}))})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('proxy-compare')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'proxy-compare'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtio = {}, global.proxyCompare)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioVanilla = {}, global.proxyCompare)); | ||
})(this, (function (exports, proxyCompare) { 'use strict'; | ||
@@ -12,3 +12,3 @@ | ||
var refSet = new WeakSet(); | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, proxyFunction) { | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, _proxyFunction) { | ||
if (objectIs === void 0) { | ||
@@ -43,3 +43,11 @@ objectIs = Object.is; | ||
if (createSnapshot === void 0) { | ||
createSnapshot = function createSnapshot(target, version, handlePromise) { | ||
createSnapshot = function (_createSnapshot) { | ||
function createSnapshot(_x, _x2, _x3) { | ||
return _createSnapshot.apply(this, arguments); | ||
} | ||
createSnapshot.toString = function () { | ||
return _createSnapshot.toString(); | ||
}; | ||
return createSnapshot; | ||
}(function (target, version, handlePromise) { | ||
if (handlePromise === void 0) { | ||
@@ -62,3 +70,4 @@ handlePromise = defaultHandlePromise; | ||
value: value, | ||
enumerable: true | ||
enumerable: true, | ||
configurable: true | ||
}; | ||
@@ -73,3 +82,6 @@ if (refSet.has(value)) { | ||
} else if (proxyStateMap.has(value)) { | ||
desc.value = snapshot(value, handlePromise); | ||
var _ref = proxyStateMap.get(value), | ||
_target = _ref[0], | ||
_ensureVersion = _ref[1]; | ||
desc.value = createSnapshot(_target, _ensureVersion(), handlePromise); | ||
} | ||
@@ -79,3 +91,3 @@ Object.defineProperty(snap, key, desc); | ||
return snap; | ||
}; | ||
}); | ||
} | ||
@@ -88,4 +100,4 @@ if (proxyCache === void 0) { | ||
} | ||
if (proxyFunction === void 0) { | ||
proxyFunction = function proxyFunction(initialObject) { | ||
if (_proxyFunction === void 0) { | ||
_proxyFunction = function proxyFunction(initialObject) { | ||
if (!isObject(initialObject)) { | ||
@@ -118,4 +130,4 @@ throw new Error('object required'); | ||
checkVersion = nextCheckVersion; | ||
propProxyStates.forEach(function (_ref) { | ||
var propProxyState = _ref[0]; | ||
propProxyStates.forEach(function (_ref2) { | ||
var propProxyState = _ref2[0]; | ||
var propVersion = propProxyState[1](nextCheckVersion); | ||
@@ -159,5 +171,5 @@ if (propVersion > version) { | ||
if (listeners.size === 1) { | ||
propProxyStates.forEach(function (_ref2, prop) { | ||
var propProxyState = _ref2[0], | ||
prevRemove = _ref2[1]; | ||
propProxyStates.forEach(function (_ref3, prop) { | ||
var propProxyState = _ref3[0], | ||
prevRemove = _ref3[1]; | ||
if (prevRemove) { | ||
@@ -173,5 +185,5 @@ throw new Error('remove already exists'); | ||
if (listeners.size === 0) { | ||
propProxyStates.forEach(function (_ref3, prop) { | ||
var propProxyState = _ref3[0], | ||
remove = _ref3[1]; | ||
propProxyStates.forEach(function (_ref4, prop) { | ||
var propProxyState = _ref4[0], | ||
remove = _ref4[1]; | ||
if (remove) { | ||
@@ -220,3 +232,3 @@ remove(); | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction(value); | ||
nextValue = _proxyFunction(value); | ||
} | ||
@@ -249,6 +261,6 @@ var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
} | ||
return [proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
return [_proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
}; | ||
var _buildProxyFunction = buildProxyFunction(), | ||
proxyFunction = _buildProxyFunction[0]; | ||
defaultProxyFunction = _buildProxyFunction[0]; | ||
function proxy(initialObject) { | ||
@@ -258,3 +270,3 @@ if (initialObject === void 0) { | ||
} | ||
return proxyFunction(initialObject); | ||
return defaultProxyFunction(initialObject); | ||
} | ||
@@ -301,6 +313,6 @@ function getVersion(proxyObject) { | ||
} | ||
var _ref4 = proxyState, | ||
target = _ref4[0], | ||
ensureVersion = _ref4[1], | ||
createSnapshot = _ref4[2]; | ||
var _ref5 = proxyState, | ||
target = _ref5[0], | ||
ensureVersion = _ref5[1], | ||
createSnapshot = _ref5[2]; | ||
return createSnapshot(target, ensureVersion(), handlePromise); | ||
@@ -307,0 +319,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.proxyCompare)}(this,(function(e,t){"use strict";var r=function(e){return"object"==typeof e&&null!==e},n=new WeakMap,o=new WeakSet,i=function(e,i,a,f,u,s,l,v,d){return void 0===e&&(e=Object.is),void 0===i&&(i=function(e,t){return new Proxy(e,t)}),void 0===a&&(a=function(e){return r(e)&&!o.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)}),void 0===f&&(f=function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),void 0===u&&(u=new WeakMap),void 0===s&&(s=function(e,r,i){void 0===i&&(i=f);var a=u.get(e);if((null==a?void 0:a[0])===r)return a[1];var s=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(s,!0),u.set(e,[r,s]),Reflect.ownKeys(e).forEach((function(r){if(!Object.getOwnPropertyDescriptor(s,r)){var a=Reflect.get(e,r),f={value:a,enumerable:!0};o.has(a)?t.markToTrack(a,!1):a instanceof Promise?(delete f.value,f.get=function(){return i(a)}):n.has(a)&&(f.value=c(a,i)),Object.defineProperty(s,r,f)}})),s}),void 0===l&&(l=new WeakMap),void 0===v&&(v=[1,1]),void 0===d&&(d=function c(f){if(!r(f))throw new Error("object required");var u=l.get(f);if(u)return u;var d=v[0],p=new Set,y=function(e,t){void 0===t&&(t=++v[0]),d!==t&&(d=t,p.forEach((function(r){return r(e,t)})))},h=v[1],g=function(e){return function(t,r){var n=[].concat(t);n[1]=[e].concat(n[1]),y(n,r)}},b=new Map,w=function(e){var t,r=b.get(e);r&&(b.delete(e),null==(t=r[1])||t.call(r))},j=Array.isArray(f)?[]:Object.create(Object.getPrototypeOf(f)),m=i(j,{deleteProperty:function(e,t){var r=Reflect.get(e,t);w(t);var n=Reflect.deleteProperty(e,t);return n&&y(["delete",[t],r]),n},set:function(i,f,u,s){var v=Reflect.has(i,f),d=Reflect.get(i,f,s);if(v&&(e(d,u)||l.has(u)&&e(d,l.get(u))))return!0;w(f),r(u)&&(u=t.getUntracked(u)||u);var h=u;if(u instanceof Promise)u.then((function(e){u.status="fulfilled",u.value=e,y(["resolve",[f],e])})).catch((function(e){u.status="rejected",u.reason=e,y(["reject",[f],e])}));else{!n.has(u)&&a(u)&&(h=c(u));var j=!o.has(h)&&n.get(h);j&&function(e,t){if(p.size){var r=t[3](g(e));b.set(e,[t,r])}else b.set(e,[t])}(f,j)}return Reflect.set(i,f,h,s),y(["set",[f],u,d]),!0}});l.set(f,m);var O=[j,function(e){return void 0===e&&(e=++v[1]),h===e||p.size||(h=e,b.forEach((function(t){var r=t[0][1](e);r>d&&(d=r)}))),d},s,function(e){p.add(e),1===p.size&&b.forEach((function(e,t){var r=e[0];e[1];var n=r[3](g(t));b.set(t,[r,n])}));return function(){p.delete(e),0===p.size&&b.forEach((function(e,t){var r=e[0],n=e[1];n&&(n(),b.set(t,[r]))}))}}];return n.set(m,O),Reflect.ownKeys(f).forEach((function(e){var t=Object.getOwnPropertyDescriptor(f,e),r="value"in t;delete t.value,Object.defineProperty(j,e,t),r&&(m[e]=f[e])})),m}),[d,n,o,e,i,a,f,u,s,l,v]},a=i()[0];function c(e,t){var r=n.get(e),o=r[0],i=r[1];return(0,r[2])(o,i(),t)}var f=i;e.getVersion=function(e){var t=n.get(e);return null==t?void 0:t[1]()},e.proxy=function(e){return void 0===e&&(e={}),a(e)},e.ref=function(e){return o.add(e),e},e.snapshot=c,e.subscribe=function(e,t,r){var o,i=n.get(e),a=[],c=i[3],f=!1,u=c((function(e){a.push(e),r?t(a.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,f&&t(a.splice(0))})))}));return f=!0,function(){f=!1,u()}},e.unstable_buildProxyFunction=f})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioVanilla={},e.proxyCompare)}(this,(function(e,t){"use strict";var n=function(e){return"object"==typeof e&&null!==e},r=new WeakMap,o=new WeakSet,i=function(e,i,a,c,f,u,s,l,v){return void 0===e&&(e=Object.is),void 0===i&&(i=function(e,t){return new Proxy(e,t)}),void 0===a&&(a=function(e){return n(e)&&!o.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)}),void 0===c&&(c=function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),void 0===f&&(f=new WeakMap),void 0===u&&(u=function(e){function t(t,n,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,n,i){void 0===i&&(i=c);var a=f.get(e);if((null==a?void 0:a[0])===n)return a[1];var s=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(s,!0),f.set(e,[n,s]),Reflect.ownKeys(e).forEach((function(n){if(!Object.getOwnPropertyDescriptor(s,n)){var a=Reflect.get(e,n),c={value:a,enumerable:!0,configurable:!0};if(o.has(a))t.markToTrack(a,!1);else if(a instanceof Promise)delete c.value,c.get=function(){return i(a)};else if(r.has(a)){var f=r.get(a),l=f[0],v=f[1];c.value=u(l,v(),i)}Object.defineProperty(s,n,c)}})),s}))),void 0===s&&(s=new WeakMap),void 0===l&&(l=[1,1]),void 0===v&&(v=function(c){if(!n(c))throw new Error("object required");var f=s.get(c);if(f)return f;var d=l[0],p=new Set,y=function(e,t){void 0===t&&(t=++l[0]),d!==t&&(d=t,p.forEach((function(n){return n(e,t)})))},g=l[1],h=function(e){return function(t,n){var r=[].concat(t);r[1]=[e].concat(r[1]),y(r,n)}},b=new Map,w=function(e){var t,n=b.get(e);n&&(b.delete(e),null==(t=n[1])||t.call(n))},j=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c)),m=i(j,{deleteProperty:function(e,t){var n=Reflect.get(e,t);w(t);var r=Reflect.deleteProperty(e,t);return r&&y(["delete",[t],n]),r},set:function(i,c,f,u){var l=Reflect.has(i,c),d=Reflect.get(i,c,u);if(l&&(e(d,f)||s.has(f)&&e(d,s.get(f))))return!0;w(c),n(f)&&(f=t.getUntracked(f)||f);var g=f;if(f instanceof Promise)f.then((function(e){f.status="fulfilled",f.value=e,y(["resolve",[c],e])})).catch((function(e){f.status="rejected",f.reason=e,y(["reject",[c],e])}));else{!r.has(f)&&a(f)&&(g=v(f));var j=!o.has(g)&&r.get(g);j&&function(e,t){if(p.size){var n=t[3](h(e));b.set(e,[t,n])}else b.set(e,[t])}(c,j)}return Reflect.set(i,c,g,u),y(["set",[c],f,d]),!0}});s.set(c,m);var O=[j,function(e){return void 0===e&&(e=++l[1]),g===e||p.size||(g=e,b.forEach((function(t){var n=t[0][1](e);n>d&&(d=n)}))),d},u,function(e){p.add(e),1===p.size&&b.forEach((function(e,t){var n=e[0];e[1];var r=n[3](h(t));b.set(t,[n,r])}));return function(){p.delete(e),0===p.size&&b.forEach((function(e,t){var n=e[0],r=e[1];r&&(r(),b.set(t,[n]))}))}}];return r.set(m,O),Reflect.ownKeys(c).forEach((function(e){var t=Object.getOwnPropertyDescriptor(c,e),n="value"in t;delete t.value,Object.defineProperty(j,e,t),n&&(m[e]=c[e])})),m}),[v,r,o,e,i,a,c,f,u,s,l]},a=i()[0];var c=i;e.getVersion=function(e){var t=r.get(e);return null==t?void 0:t[1]()},e.proxy=function(e){return void 0===e&&(e={}),a(e)},e.ref=function(e){return o.add(e),e},e.snapshot=function(e,t){var n=r.get(e),o=n[0],i=n[1];return(0,n[2])(o,i(),t)},e.subscribe=function(e,t,n){var o,i=r.get(e),a=[],c=i[3],f=!1,u=c((function(e){a.push(e),n?t(a.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,f&&t(a.splice(0))})))}));return f=!0,function(){f=!1,u()}},e.unstable_buildProxyFunction=c})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('valtio/vanilla')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'valtio/vanilla'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioUtils = {}, global.valtioVanilla)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioVanillaUtils = {}, global.valtioVanilla)); | ||
})(this, (function (exports, vanilla) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).valtioUtils={},t.valtioVanilla)}(this,(function(t,e){"use strict";var n;var r=Symbol();var i=new WeakMap,a=new WeakMap,o=function t(e,n){var r=i.get(e);r&&(r[0].forEach((function(n){var r=n.d;e!==r&&t(r)})),++r[2],n&&r[3].add(n))},u=function(t,e){var n=i.get(t);return!(null==n||!n[2])&&(n[3].add(e),!0)},s=function t(e){var n=i.get(e);n&&(--n[2],n[2]||(n[3].forEach((function(t){return t()})),n[3].clear()),n[0].forEach((function(n){var r=n.d;e!==r&&t(r)})))},c=function(t){var n=t.s,r=t.d,u=a.get(r);u||(u=[new Set],a.set(t.d,u)),u[0].add(t);var c=i.get(n);if(!c){var f=new Set,d=e.subscribe(n,(function(t){f.forEach((function(e){var r=e.d,i=e.c,a=e.n,u=e.i;n===r&&t.every((function(t){return 1===t[1].length&&u.includes(t[1][0])}))||e.p||(o(n,i),a?s(n):e.p=Promise.resolve().then((function(){delete e.p,s(n)})))}))}),!0);c=[f,d,0,new Set],i.set(n,c)}c[0].add(t)},f=function(t){var e=t.s,n=t.d,r=a.get(n);null==r||r[0].delete(t),0===(null==r?void 0:r[0].size)&&a.delete(n);var o=i.get(e);if(o){var u=o[0],s=o[1];u.delete(t),u.size||(s(),i.delete(e))}},d=function(t){var e=a.get(t);return e?Array.from(e[0]):[]},l={add:c,remove:f,list:d};function p(t,n){var r=(null==n?void 0:n.proxy)||e.proxy({}),i=!(null==n||!n.sync),a=Object.keys(t);return a.forEach((function(n){if(Object.getOwnPropertyDescriptor(r,n))throw new Error("object property already defined");var o=t[n],s=null;!function t(){if(s){if(Array.from(s).map((function(e){var n=e[0];return u(n,t)})).some((function(t){return t})))return;if(Array.from(s).every((function(t){var n=t[0],r=t[1];return e.getVersion(n)===r.v})))return}var d=new Map,l=o((function(t){return d.set(t,{v:e.getVersion(t)}),t})),p=function(){var e;d.forEach((function(e,o){var u,f,d=null==(u=s)||null==(f=u.get(o))?void 0:f.s;if(d)e.s=d;else{var l={s:o,d:r,k:n,c:t,n:i,i:a};c(l),e.s=l}})),null==(e=s)||e.forEach((function(t,e){!d.has(e)&&t.s&&f(t.s)})),s=d};l instanceof Promise?l.finally(p):p(),r[n]=l}()})),r}var h=function t(e){if("object"!=typeof(n=e)||null===n)return e;var n,r=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((function(n){r[n]=t(e[n])})),r};function v(t,e,n,r){var i={configurable:!0,enumerable:!0};return i[t]=r,Object.defineProperty(e,n,i)}t.addComputed=function(t,e,n){void 0===n&&(n=t);var r={};return Object.keys(e).forEach((function(n){r[n]=function(r){return e[n](r(t))}})),p(r,{proxy:n})},t.derive=p,t.devtools=function(t,n){"string"==typeof n&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),n={name:n});var i,a=n||{},o=a.enabled,u=a.name,s=void 0===u?"":u;try{i=null!=o&&o&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(i){var c=!1,f=i.connect({name:s}),d=e.subscribe(t,(function(n){var i=n.filter((function(t){return t[0],t[1][0]!==r})).map((function(t){return t[0]+":"+t[1].map(String).join(".")})).join(", ");if(i)if(c)c=!1;else{var a=Object.assign({},e.snapshot(t));delete a[r],f.send({type:i,updatedAt:(new Date).toLocaleString()},a)}})),l=f.subscribe((function(n){var i,a;if("ACTION"===n.type&&n.payload)try{Object.assign(t,JSON.parse(n.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===n.type&&n.state){var o,u;if("JUMP_TO_ACTION"===(null==(o=n.payload)?void 0:o.type)||"JUMP_TO_STATE"===(null==(u=n.payload)?void 0:u.type)){c=!0;var s=JSON.parse(n.state);Object.assign(t,s)}t[r]=n}else if("DISPATCH"===n.type&&"COMMIT"===(null==(i=n.payload)?void 0:i.type))f.init(e.snapshot(t));else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(a=n.payload)?void 0:a.type)){var d,l,p=null==(d=n.payload.nextLiftedState)?void 0:d.actionsById,h=(null==(l=n.payload.nextLiftedState)?void 0:l.computedStates)||[];c=!0,h.forEach((function(n,r){var i=n.state,a=p[r]||"No action found";Object.assign(t,i),0===r?f.init(e.snapshot(t)):f.send(a,e.snapshot(t))}))}}));return f.init(e.snapshot(t)),function(){d(),null==l||l()}}},t.proxyMap=function(t){var n,r=e.proxy((v("get",n={data:Array.from(t||[]),has:function(t){return this.data.some((function(e){return e[0]===t}))},set:function(t,e){var n=this.data.find((function(e){return e[0]===t}));return n?n[1]=e:this.data.push([t,e]),this},get:function(t){var e;return null==(e=this.data.find((function(e){return e[0]===t})))?void 0:e[1]},delete:function(t){var e=this.data.findIndex((function(e){return e[0]===t}));return-1!==e&&(this.data.splice(e,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},toJSON:function(){return new Map(this.data)},forEach:function(t){var e=this;this.data.forEach((function(n){t(n[1],n[0],e)}))},keys:function(){return this.data.map((function(t){return t[0]})).values()},values:function(){return this.data.map((function(t){return t[1]})).values()},entries:function(){return new Map(this.data).entries()}},Symbol.toStringTag,(function(){return"Map"})),n[Symbol.iterator]=function(){return this.entries()},n));return Object.defineProperties(r,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(r),r},t.proxySet=function(t){var n,r=e.proxy((v("get",n={data:Array.from(new Set(t)),has:function(t){return-1!==this.data.indexOf(t)},add:function(t){var n=!1;return"object"==typeof t&&null!==t&&(n=-1!==this.data.indexOf(e.proxy(t))),-1!==this.data.indexOf(t)||n||this.data.push(t),this},delete:function(t){var e=this.data.indexOf(t);return-1!==e&&(this.data.splice(e,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},forEach:function(t){var e=this;this.data.forEach((function(n){t(n,n,e)}))}},Symbol.toStringTag,(function(){return"Set"})),n.toJSON=function(){return new Set(this.data)},n[Symbol.iterator]=function(){return this.data[Symbol.iterator]()},n.values=function(){return this.data.values()},n.keys=function(){return this.data.values()},n.entries=function(){return new Set(this.data).entries()},n));return Object.defineProperties(r,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(r),r},t.proxyWithComputed=function(t,n){Object.keys(n).forEach((function(i){if(Object.getOwnPropertyDescriptor(t,i))throw new Error("object property already defined");var a=n[i],o="function"==typeof a?{get:a}:a,u=o.get,s=o.set,c={get:function(){return u(e.snapshot(r))}};s&&(c.set=function(t){return s(r,t)}),Object.defineProperty(t,i,c)}));var r=e.proxy(t);return r},t.proxyWithHistory=function(t,n){void 0===n&&(n=!1);var r=e.proxy({value:t,history:e.ref({wip:void 0,snapshots:[],index:-1}),canUndo:function(){return r.history.index>0},undo:function(){r.canUndo()&&(r.value=r.history.wip=h(r.history.snapshots[--r.history.index]))},canRedo:function(){return r.history.index<r.history.snapshots.length-1},redo:function(){r.canRedo()&&(r.value=r.history.wip=h(r.history.snapshots[++r.history.index]))},saveHistory:function(){r.history.snapshots.splice(r.history.index+1),r.history.snapshots.push(e.snapshot(r).value),++r.history.index},subscribe:function(){return e.subscribe(r,(function(t){t.every((function(t){return"value"===t[1][0]&&("set"!==t[0]||t[2]!==r.history.wip)}))&&r.saveHistory()}))}});return r.saveHistory(),n||r.subscribe(),r},t.subscribeKey=function(t,n,r,i){var a=t[n];return e.subscribe(t,(function(){var e=t[n];Object.is(a,e)||r(a=e)}),i)},t.underive=function(t,e){var n=null!=e&&e.delete?new Set:null;d(t).forEach((function(t){var r=t.k;null!=e&&e.keys&&!e.keys.includes(r)||(f(t),n&&n.add(r))})),n&&n.forEach((function(e){delete t[e]}))},t.unstable_deriveSubscriptions=l,t.watch=function(t,r){var i=!0,a=new Set,o=new Map,u=function(){i&&(i=!1,a.forEach((function(t){return t()})),a.clear(),o.forEach((function(t){return t()})),o.clear())};return n&&n.add(u),function u(){if(i){a.forEach((function(t){return t()})),a.clear();var s=new Set,c=n;n=a;try{var f=t((function(t){return s.add(t),t}));f&&a.add(f)}finally{n=c}o.forEach((function(t,e){s.has(e)?s.delete(e):(o.delete(e),t())})),s.forEach((function(t){var n=e.subscribe(t,u,null==r?void 0:r.sync);o.set(t,n)}))}}(),u}})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).valtioVanillaUtils={},t.valtioVanilla)}(this,(function(t,e){"use strict";var n;var r=Symbol();var i=new WeakMap,a=new WeakMap,o=function t(e,n){var r=i.get(e);r&&(r[0].forEach((function(n){var r=n.d;e!==r&&t(r)})),++r[2],n&&r[3].add(n))},u=function(t,e){var n=i.get(t);return!(null==n||!n[2])&&(n[3].add(e),!0)},s=function t(e){var n=i.get(e);n&&(--n[2],n[2]||(n[3].forEach((function(t){return t()})),n[3].clear()),n[0].forEach((function(n){var r=n.d;e!==r&&t(r)})))},c=function(t){var n=t.s,r=t.d,u=a.get(r);u||(u=[new Set],a.set(t.d,u)),u[0].add(t);var c=i.get(n);if(!c){var f=new Set,d=e.subscribe(n,(function(t){f.forEach((function(e){var r=e.d,i=e.c,a=e.n,u=e.i;n===r&&t.every((function(t){return 1===t[1].length&&u.includes(t[1][0])}))||e.p||(o(n,i),a?s(n):e.p=Promise.resolve().then((function(){delete e.p,s(n)})))}))}),!0);c=[f,d,0,new Set],i.set(n,c)}c[0].add(t)},f=function(t){var e=t.s,n=t.d,r=a.get(n);null==r||r[0].delete(t),0===(null==r?void 0:r[0].size)&&a.delete(n);var o=i.get(e);if(o){var u=o[0],s=o[1];u.delete(t),u.size||(s(),i.delete(e))}},d=function(t){var e=a.get(t);return e?Array.from(e[0]):[]},l={add:c,remove:f,list:d};function p(t,n){var r=(null==n?void 0:n.proxy)||e.proxy({}),i=!(null==n||!n.sync),a=Object.keys(t);return a.forEach((function(n){if(Object.getOwnPropertyDescriptor(r,n))throw new Error("object property already defined");var o=t[n],s=null;!function t(){if(s){if(Array.from(s).map((function(e){var n=e[0];return u(n,t)})).some((function(t){return t})))return;if(Array.from(s).every((function(t){var n=t[0],r=t[1];return e.getVersion(n)===r.v})))return}var d=new Map,l=o((function(t){return d.set(t,{v:e.getVersion(t)}),t})),p=function(){var e;d.forEach((function(e,o){var u,f,d=null==(u=s)||null==(f=u.get(o))?void 0:f.s;if(d)e.s=d;else{var l={s:o,d:r,k:n,c:t,n:i,i:a};c(l),e.s=l}})),null==(e=s)||e.forEach((function(t,e){!d.has(e)&&t.s&&f(t.s)})),s=d};l instanceof Promise?l.finally(p):p(),r[n]=l}()})),r}var h=function t(e){if("object"!=typeof(n=e)||null===n)return e;var n,r=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((function(n){r[n]=t(e[n])})),r};function v(t,e,n,r){var i={configurable:!0,enumerable:!0};return i[t]=r,Object.defineProperty(e,n,i)}t.addComputed=function(t,e,n){void 0===n&&(n=t);var r={};return Object.keys(e).forEach((function(n){r[n]=function(r){return e[n](r(t))}})),p(r,{proxy:n})},t.derive=p,t.devtools=function(t,n){"string"==typeof n&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),n={name:n});var i,a=n||{},o=a.enabled,u=a.name,s=void 0===u?"":u;try{i=null!=o&&o&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(i){var c=!1,f=i.connect({name:s}),d=e.subscribe(t,(function(n){var i=n.filter((function(t){return t[0],t[1][0]!==r})).map((function(t){return t[0]+":"+t[1].map(String).join(".")})).join(", ");if(i)if(c)c=!1;else{var a=Object.assign({},e.snapshot(t));delete a[r],f.send({type:i,updatedAt:(new Date).toLocaleString()},a)}})),l=f.subscribe((function(n){var i,a;if("ACTION"===n.type&&n.payload)try{Object.assign(t,JSON.parse(n.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===n.type&&n.state){var o,u;if("JUMP_TO_ACTION"===(null==(o=n.payload)?void 0:o.type)||"JUMP_TO_STATE"===(null==(u=n.payload)?void 0:u.type)){c=!0;var s=JSON.parse(n.state);Object.assign(t,s)}t[r]=n}else if("DISPATCH"===n.type&&"COMMIT"===(null==(i=n.payload)?void 0:i.type))f.init(e.snapshot(t));else if("DISPATCH"===n.type&&"IMPORT_STATE"===(null==(a=n.payload)?void 0:a.type)){var d,l,p=null==(d=n.payload.nextLiftedState)?void 0:d.actionsById,h=(null==(l=n.payload.nextLiftedState)?void 0:l.computedStates)||[];c=!0,h.forEach((function(n,r){var i=n.state,a=p[r]||"No action found";Object.assign(t,i),0===r?f.init(e.snapshot(t)):f.send(a,e.snapshot(t))}))}}));return f.init(e.snapshot(t)),function(){d(),null==l||l()}}},t.proxyMap=function(t){var n,r=e.proxy((v("get",n={data:Array.from(t||[]),has:function(t){return this.data.some((function(e){return e[0]===t}))},set:function(t,e){var n=this.data.find((function(e){return e[0]===t}));return n?n[1]=e:this.data.push([t,e]),this},get:function(t){var e;return null==(e=this.data.find((function(e){return e[0]===t})))?void 0:e[1]},delete:function(t){var e=this.data.findIndex((function(e){return e[0]===t}));return-1!==e&&(this.data.splice(e,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},toJSON:function(){return new Map(this.data)},forEach:function(t){var e=this;this.data.forEach((function(n){t(n[1],n[0],e)}))},keys:function(){return this.data.map((function(t){return t[0]})).values()},values:function(){return this.data.map((function(t){return t[1]})).values()},entries:function(){return new Map(this.data).entries()}},Symbol.toStringTag,(function(){return"Map"})),n[Symbol.iterator]=function(){return this.entries()},n));return Object.defineProperties(r,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(r),r},t.proxySet=function(t){var n,r=e.proxy((v("get",n={data:Array.from(new Set(t)),has:function(t){return-1!==this.data.indexOf(t)},add:function(t){var n=!1;return"object"==typeof t&&null!==t&&(n=-1!==this.data.indexOf(e.proxy(t))),-1!==this.data.indexOf(t)||n||this.data.push(t),this},delete:function(t){var e=this.data.indexOf(t);return-1!==e&&(this.data.splice(e,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},forEach:function(t){var e=this;this.data.forEach((function(n){t(n,n,e)}))}},Symbol.toStringTag,(function(){return"Set"})),n.toJSON=function(){return new Set(this.data)},n[Symbol.iterator]=function(){return this.data[Symbol.iterator]()},n.values=function(){return this.data.values()},n.keys=function(){return this.data.values()},n.entries=function(){return new Set(this.data).entries()},n));return Object.defineProperties(r,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(r),r},t.proxyWithComputed=function(t,n){Object.keys(n).forEach((function(i){if(Object.getOwnPropertyDescriptor(t,i))throw new Error("object property already defined");var a=n[i],o="function"==typeof a?{get:a}:a,u=o.get,s=o.set,c={get:function(){return u(e.snapshot(r))}};s&&(c.set=function(t){return s(r,t)}),Object.defineProperty(t,i,c)}));var r=e.proxy(t);return r},t.proxyWithHistory=function(t,n){void 0===n&&(n=!1);var r=e.proxy({value:t,history:e.ref({wip:void 0,snapshots:[],index:-1}),canUndo:function(){return r.history.index>0},undo:function(){r.canUndo()&&(r.value=r.history.wip=h(r.history.snapshots[--r.history.index]))},canRedo:function(){return r.history.index<r.history.snapshots.length-1},redo:function(){r.canRedo()&&(r.value=r.history.wip=h(r.history.snapshots[++r.history.index]))},saveHistory:function(){r.history.snapshots.splice(r.history.index+1),r.history.snapshots.push(e.snapshot(r).value),++r.history.index},subscribe:function(){return e.subscribe(r,(function(t){t.every((function(t){return"value"===t[1][0]&&("set"!==t[0]||t[2]!==r.history.wip)}))&&r.saveHistory()}))}});return r.saveHistory(),n||r.subscribe(),r},t.subscribeKey=function(t,n,r,i){var a=t[n];return e.subscribe(t,(function(){var e=t[n];Object.is(a,e)||r(a=e)}),i)},t.underive=function(t,e){var n=null!=e&&e.delete?new Set:null;d(t).forEach((function(t){var r=t.k;null!=e&&e.keys&&!e.keys.includes(r)||(f(t),n&&n.add(r))})),n&&n.forEach((function(e){delete t[e]}))},t.unstable_deriveSubscriptions=l,t.watch=function(t,r){var i=!0,a=new Set,o=new Map,u=function(){i&&(i=!1,a.forEach((function(t){return t()})),a.clear(),o.forEach((function(t){return t()})),o.clear())};return n&&n.add(u),function u(){if(i){a.forEach((function(t){return t()})),a.clear();var s=new Set,c=n;n=a;try{var f=t((function(t){return s.add(t),t}));f&&a.add(f)}finally{n=c}o.forEach((function(t,e){s.has(e)?s.delete(e):(o.delete(e),t())})),s.forEach((function(t){var n=e.subscribe(t,u,null==r?void 0:r.sync);o.set(t,n)}))}}(),u}})); |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var refSet = new WeakSet(); | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, proxyFunction) { | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, _proxyFunction) { | ||
if (objectIs === void 0) { | ||
@@ -41,3 +41,11 @@ objectIs = Object.is; | ||
if (createSnapshot === void 0) { | ||
createSnapshot = function createSnapshot(target, version, handlePromise) { | ||
createSnapshot = function (_createSnapshot) { | ||
function createSnapshot(_x, _x2, _x3) { | ||
return _createSnapshot.apply(this, arguments); | ||
} | ||
createSnapshot.toString = function () { | ||
return _createSnapshot.toString(); | ||
}; | ||
return createSnapshot; | ||
}(function (target, version, handlePromise) { | ||
if (handlePromise === void 0) { | ||
@@ -60,3 +68,4 @@ handlePromise = defaultHandlePromise; | ||
value: value, | ||
enumerable: true | ||
enumerable: true, | ||
configurable: true | ||
}; | ||
@@ -71,3 +80,6 @@ if (refSet.has(value)) { | ||
} else if (proxyStateMap.has(value)) { | ||
desc.value = snapshot(value, handlePromise); | ||
var _ref = proxyStateMap.get(value), | ||
_target = _ref[0], | ||
_ensureVersion = _ref[1]; | ||
desc.value = createSnapshot(_target, _ensureVersion(), handlePromise); | ||
} | ||
@@ -77,3 +89,3 @@ Object.defineProperty(snap, key, desc); | ||
return snap; | ||
}; | ||
}); | ||
} | ||
@@ -86,4 +98,4 @@ if (proxyCache === void 0) { | ||
} | ||
if (proxyFunction === void 0) { | ||
proxyFunction = function proxyFunction(initialObject) { | ||
if (_proxyFunction === void 0) { | ||
_proxyFunction = function proxyFunction(initialObject) { | ||
if (!isObject(initialObject)) { | ||
@@ -116,4 +128,4 @@ throw new Error('object required'); | ||
checkVersion = nextCheckVersion; | ||
propProxyStates.forEach(function (_ref) { | ||
var propProxyState = _ref[0]; | ||
propProxyStates.forEach(function (_ref2) { | ||
var propProxyState = _ref2[0]; | ||
var propVersion = propProxyState[1](nextCheckVersion); | ||
@@ -157,5 +169,5 @@ if (propVersion > version) { | ||
if (listeners.size === 1) { | ||
propProxyStates.forEach(function (_ref2, prop) { | ||
var propProxyState = _ref2[0], | ||
prevRemove = _ref2[1]; | ||
propProxyStates.forEach(function (_ref3, prop) { | ||
var propProxyState = _ref3[0], | ||
prevRemove = _ref3[1]; | ||
if (process.env.NODE_ENV !== 'production' && prevRemove) { | ||
@@ -171,5 +183,5 @@ throw new Error('remove already exists'); | ||
if (listeners.size === 0) { | ||
propProxyStates.forEach(function (_ref3, prop) { | ||
var propProxyState = _ref3[0], | ||
remove = _ref3[1]; | ||
propProxyStates.forEach(function (_ref4, prop) { | ||
var propProxyState = _ref4[0], | ||
remove = _ref4[1]; | ||
if (remove) { | ||
@@ -218,3 +230,3 @@ remove(); | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction(value); | ||
nextValue = _proxyFunction(value); | ||
} | ||
@@ -247,6 +259,6 @@ var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
} | ||
return [proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
return [_proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
}; | ||
var _buildProxyFunction = buildProxyFunction(), | ||
proxyFunction = _buildProxyFunction[0]; | ||
defaultProxyFunction = _buildProxyFunction[0]; | ||
function proxy(initialObject) { | ||
@@ -256,3 +268,3 @@ if (initialObject === void 0) { | ||
} | ||
return proxyFunction(initialObject); | ||
return defaultProxyFunction(initialObject); | ||
} | ||
@@ -299,6 +311,6 @@ function getVersion(proxyObject) { | ||
} | ||
var _ref4 = proxyState, | ||
target = _ref4[0], | ||
ensureVersion = _ref4[1], | ||
createSnapshot = _ref4[2]; | ||
var _ref5 = proxyState, | ||
target = _ref5[0], | ||
ensureVersion = _ref5[1], | ||
createSnapshot = _ref5[2]; | ||
return createSnapshot(target, ensureVersion(), handlePromise); | ||
@@ -305,0 +317,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314167
7438
+ Addedproxy-compare@2.5.0(transitive)
- Removedproxy-compare@2.4.1(transitive)
Updatedproxy-compare@2.5.0