Comparing version 1.10.6 to 1.10.7
@@ -8,3 +8,4 @@ type AnyFunction = (...args: any[]) => any; | ||
type Listener = (op: Op, nextVersion: number) => void; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction; | ||
type Primitive = string | number | boolean | null | undefined | symbol | bigint; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction | Primitive; | ||
type Snapshot<T> = T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { | ||
@@ -11,0 +12,0 @@ readonly [K in keyof T]: Snapshot<T[K]>; |
@@ -52,3 +52,3 @@ import { markToTrack, getUntracked } from 'proxy-compare'; | ||
}); | ||
return snap; | ||
return Object.preventExtensions(snap); | ||
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { | ||
@@ -55,0 +55,0 @@ if (!isObject(initialObject)) { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
Object.keys(vanilla).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -16,3 +16,3 @@ get: function () { return vanilla[k]; } | ||
Object.keys(react).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -19,0 +19,0 @@ get: function () { return react[k]; } |
@@ -33,10 +33,10 @@ 'use strict'; | ||
(_references$useProxy = references.useProxy) == null ? void 0 : _references$useProxy.forEach(function (path) { | ||
var _path$parentPath, _path$parentPath$get, _path$parentPath2, _path$parentPath2$par, _path$parentPath3, _path$parentPath3$get; | ||
var _path$parentPath, _path$parentPath2, _path$parentPath3; | ||
var hook = helperModuleImports.addNamed(path, 'useSnapshot', 'valtio'); | ||
var proxy = (_path$parentPath = path.parentPath) == null ? void 0 : (_path$parentPath$get = _path$parentPath.get('arguments.0')) == null ? void 0 : _path$parentPath$get.node; | ||
var proxy = (_path$parentPath = path.parentPath) == null || (_path$parentPath = _path$parentPath.get('arguments.0')) == null ? void 0 : _path$parentPath.node; | ||
if (!t__namespace.isIdentifier(proxy)) throw new babelPluginMacros.MacroError('no proxy object'); | ||
var snap = t__namespace.identifier("valtio_macro_snap_" + proxy.name); | ||
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$par = _path$parentPath2.parentPath) == null ? void 0 : _path$parentPath2$par.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))])); | ||
(_path$parentPath2 = path.parentPath) == null || (_path$parentPath2 = _path$parentPath2.parentPath) == null ? void 0 : _path$parentPath2.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))])); | ||
var inFunction = 0; | ||
(_path$parentPath3 = path.parentPath) == null ? void 0 : (_path$parentPath3$get = _path$parentPath3.getFunctionParent()) == null ? void 0 : _path$parentPath3$get.traverse({ | ||
(_path$parentPath3 = path.parentPath) == null || (_path$parentPath3 = _path$parentPath3.getFunctionParent()) == null ? void 0 : _path$parentPath3.traverse({ | ||
Identifier: function Identifier(p) { | ||
@@ -43,0 +43,0 @@ if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) { |
@@ -37,3 +37,3 @@ 'use strict'; | ||
var valtioMacro = defineMacro("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler(function (ctx) { | ||
var _args$, _path$parentPath, _path$parentPath2, _path$parentPath2$get; | ||
var _args$, _path$parentPath, _path$parentPath2; | ||
var path = ctx.path, | ||
@@ -49,3 +49,3 @@ args = ctx.args; | ||
var inFunction = 0; | ||
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$get = _path$parentPath2.getFunctionParent()) == null ? void 0 : _path$parentPath2$get.traverse({ | ||
(_path$parentPath2 = path.parentPath) == null || (_path$parentPath2 = _path$parentPath2.getFunctionParent()) == null ? void 0 : _path$parentPath2.traverse({ | ||
Identifier: function Identifier(p) { | ||
@@ -52,0 +52,0 @@ if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) { |
{ | ||
"name": "valtio", | ||
"private": false, | ||
"version": "1.10.6", | ||
"version": "1.10.7", | ||
"description": "💊 Valtio makes proxy-state simple for React and Vanilla", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
@@ -68,3 +68,3 @@ System.register(['proxy-compare'], (function (exports) { | ||
}); | ||
return snap; | ||
return Object.preventExtensions(snap); | ||
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { | ||
@@ -71,0 +71,0 @@ if (!isObject(initialObject)) { |
@@ -1,1 +0,1 @@ | ||
System.register(["proxy-compare"],function(D){"use strict";var x,K;return{setters:[function(v){x=v.markToTrack,K=v.getUntracked}],execute:function(){D({getVersion:_,proxy:U,ref:L,snapshot:B,subscribe:q});const v=c=>typeof c=="object"&&c!==null,f=new WeakMap,m=new WeakSet,T=(c=Object.is,l=(t,w)=>new Proxy(t,w),O=t=>v(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),P=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},u=new WeakMap,g=(t,w,b=P)=>{const s=u.get(t);if((s==null?void 0:s[0])===w)return s[1];const a=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return x(a,!0),u.set(t,[w,a]),Reflect.ownKeys(t).forEach(k=>{if(Object.getOwnPropertyDescriptor(a,k))return;const y=Reflect.get(t,k),j={value:y,enumerable:!0,configurable:!0};if(m.has(y))x(y,!1);else if(y instanceof Promise)delete j.value,j.get=()=>b(y);else if(f.has(y)){const[i,W]=f.get(y);j.value=g(i,W(),b)}Object.defineProperty(a,k,j)}),a},h=new WeakMap,d=[1,1],E=t=>{if(!v(t))throw new Error("object required");const w=h.get(t);if(w)return w;let b=d[0];const s=new Set,a=(n,e=++d[0])=>{b!==e&&(b=e,s.forEach(r=>r(n,e)))};let k=d[1];const y=(n=++d[1])=>(k!==n&&!s.size&&(k=n,i.forEach(([e])=>{const r=e[1](n);r>b&&(b=r)})),b),j=n=>(e,r)=>{const o=[...e];o[1]=[n,...o[1]],a(o,r)},i=new Map,W=(n,e)=>{if(s.size){const r=e[3](j(n));i.set(n,[e,r])}else i.set(n,[e])},V=n=>{var e;const r=i.get(n);r&&(i.delete(n),(e=r[1])==null||e.call(r))},N=n=>(s.add(n),s.size===1&&i.forEach(([e,r],o)=>{const M=e[3](j(o));i.set(o,[e,M])}),()=>{s.delete(n),s.size===0&&i.forEach(([e,r],o)=>{r&&(r(),i.set(o,[e]))})}),z=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),R=l(z,{deleteProperty(n,e){const r=Reflect.get(n,e);V(e);const o=Reflect.deleteProperty(n,e);return o&&a(["delete",[e],r]),o},set(n,e,r,o){const M=Reflect.has(n,e),S=Reflect.get(n,e,o);if(M&&(c(S,r)||h.has(r)&&c(S,h.get(r))))return!0;V(e),v(r)&&(r=K(r)||r);let A=r;if(r instanceof Promise)r.then(p=>{r.status="fulfilled",r.value=p,a(["resolve",[e],p])}).catch(p=>{r.status="rejected",r.reason=p,a(["reject",[e],p])});else{!f.has(r)&&O(r)&&(A=E(r));const p=!m.has(A)&&f.get(A);p&&W(e,p)}return Reflect.set(n,e,A,o),a(["set",[e],r,S]),!0}});h.set(t,R);const C=[z,y,g,N];return f.set(R,C),Reflect.ownKeys(t).forEach(n=>{const e=Object.getOwnPropertyDescriptor(t,n);"value"in e&&(R[n]=t[n],delete e.value,delete e.writable),Object.defineProperty(z,n,e)}),R})=>[E,f,m,c,l,O,P,u,g,h,d],[F]=T();function U(c={}){return F(c)}function _(c){const l=f.get(c);return l==null?void 0:l[1]()}function q(c,l,O){const P=f.get(c);let u;const g=[],h=P[3];let d=!1;const E=h(t=>{if(g.push(t),O){l(g.splice(0));return}u||(u=Promise.resolve().then(()=>{u=void 0,d&&l(g.splice(0))}))});return d=!0,()=>{d=!1,E()}}function B(c,l){const O=f.get(c),[P,u,g]=O;return g(P,u(),l)}function L(c){return m.add(c),c}const G=D("unstable_buildProxyFunction",T)}}}); | ||
System.register(["proxy-compare"],function(D){"use strict";var W,K;return{setters:[function(O){W=O.markToTrack,K=O.getUntracked}],execute:function(){D({getVersion:_,proxy:U,ref:L,snapshot:B,subscribe:q});const O=c=>typeof c=="object"&&c!==null,f=new WeakMap,E=new WeakSet,T=(c=Object.is,l=(t,w)=>new Proxy(t,w),v=t=>O(t)&&!E.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),P=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},u=new WeakMap,d=(t,w,g=P)=>{const s=u.get(t);if((s==null?void 0:s[0])===w)return s[1];const a=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return W(a,!0),u.set(t,[w,a]),Reflect.ownKeys(t).forEach(k=>{if(Object.getOwnPropertyDescriptor(a,k))return;const y=Reflect.get(t,k),j={value:y,enumerable:!0,configurable:!0};if(E.has(y))W(y,!1);else if(y instanceof Promise)delete j.value,j.get=()=>g(y);else if(f.has(y)){const[i,m]=f.get(y);j.value=d(i,m(),g)}Object.defineProperty(a,k,j)}),Object.preventExtensions(a)},p=new WeakMap,b=[1,1],x=t=>{if(!O(t))throw new Error("object required");const w=p.get(t);if(w)return w;let g=b[0];const s=new Set,a=(n,e=++b[0])=>{g!==e&&(g=e,s.forEach(r=>r(n,e)))};let k=b[1];const y=(n=++b[1])=>(k!==n&&!s.size&&(k=n,i.forEach(([e])=>{const r=e[1](n);r>g&&(g=r)})),g),j=n=>(e,r)=>{const o=[...e];o[1]=[n,...o[1]],a(o,r)},i=new Map,m=(n,e)=>{if(s.size){const r=e[3](j(n));i.set(n,[e,r])}else i.set(n,[e])},V=n=>{var e;const r=i.get(n);r&&(i.delete(n),(e=r[1])==null||e.call(r))},N=n=>(s.add(n),s.size===1&&i.forEach(([e,r],o)=>{const M=e[3](j(o));i.set(o,[e,M])}),()=>{s.delete(n),s.size===0&&i.forEach(([e,r],o)=>{r&&(r(),i.set(o,[e]))})}),z=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),R=l(z,{deleteProperty(n,e){const r=Reflect.get(n,e);V(e);const o=Reflect.deleteProperty(n,e);return o&&a(["delete",[e],r]),o},set(n,e,r,o){const M=Reflect.has(n,e),S=Reflect.get(n,e,o);if(M&&(c(S,r)||p.has(r)&&c(S,p.get(r))))return!0;V(e),O(r)&&(r=K(r)||r);let A=r;if(r instanceof Promise)r.then(h=>{r.status="fulfilled",r.value=h,a(["resolve",[e],h])}).catch(h=>{r.status="rejected",r.reason=h,a(["reject",[e],h])});else{!f.has(r)&&v(r)&&(A=x(r));const h=!E.has(A)&&f.get(A);h&&m(e,h)}return Reflect.set(n,e,A,o),a(["set",[e],r,S]),!0}});p.set(t,R);const C=[z,y,d,N];return f.set(R,C),Reflect.ownKeys(t).forEach(n=>{const e=Object.getOwnPropertyDescriptor(t,n);"value"in e&&(R[n]=t[n],delete e.value,delete e.writable),Object.defineProperty(z,n,e)}),R})=>[x,f,E,c,l,v,P,u,d,p,b],[F]=T();function U(c={}){return F(c)}function _(c){const l=f.get(c);return l==null?void 0:l[1]()}function q(c,l,v){const P=f.get(c);let u;const d=[],p=P[3];let b=!1;const x=p(t=>{if(d.push(t),v){l(d.splice(0));return}u||(u=Promise.resolve().then(()=>{u=void 0,b&&l(d.splice(0))}))});return b=!0,()=>{b=!1,x()}}function B(c,l){const v=f.get(c),[P,u,d]=v;return d(P,u(),l)}function L(c){return E.add(c),c}const G=D("unstable_buildProxyFunction",T)}}}); |
@@ -25,3 +25,4 @@ type AnyFunction = (...args: any[]) => any; | ||
type Listener = (op: Op, nextVersion: number) => void; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction; | ||
type Primitive = string | number | boolean | null | undefined | symbol | bigint; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction | Primitive; | ||
type Snapshot<T> = T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { | ||
@@ -28,0 +29,0 @@ readonly [K in keyof T]: Snapshot<T[K]>; |
@@ -25,3 +25,4 @@ type AnyFunction = (...args: any[]) => any; | ||
type Listener = (op: Op, nextVersion: number) => void; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction; | ||
type Primitive = string | number | boolean | null | undefined | symbol | bigint; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction | Primitive; | ||
type Snapshot<T> = T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { | ||
@@ -28,0 +29,0 @@ readonly [K in keyof T]: Snapshot<T[K]>; |
@@ -8,3 +8,3 @@ (function (global, factory) { | ||
Object.keys(vanilla).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -15,3 +15,3 @@ get: function () { return vanilla[k]; } | ||
Object.keys(react).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -18,0 +18,0 @@ get: function () { return react[k]; } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("valtio/vanilla"),require("valtio/react")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla","valtio/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.valtioVanilla,e.valtioReact)}(this,(function(e,t,n){"use strict";Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})}))})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("valtio/vanilla"),require("valtio/react")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla","valtio/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.valtioVanilla,e.valtioReact)}(this,(function(e,t,o){"use strict";Object.keys(t).forEach((function(o){"default"===o||Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[o]}})})),Object.keys(o).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})}))})); |
@@ -33,10 +33,10 @@ (function (global, factory) { | ||
(_references$useProxy = references.useProxy) == null ? void 0 : _references$useProxy.forEach(function (path) { | ||
var _path$parentPath, _path$parentPath$get, _path$parentPath2, _path$parentPath2$par, _path$parentPath3, _path$parentPath3$get; | ||
var _path$parentPath, _path$parentPath2, _path$parentPath3; | ||
var hook = helperModuleImports.addNamed(path, 'useSnapshot', 'valtio'); | ||
var proxy = (_path$parentPath = path.parentPath) == null ? void 0 : (_path$parentPath$get = _path$parentPath.get('arguments.0')) == null ? void 0 : _path$parentPath$get.node; | ||
var proxy = (_path$parentPath = path.parentPath) == null || (_path$parentPath = _path$parentPath.get('arguments.0')) == null ? void 0 : _path$parentPath.node; | ||
if (!t__namespace.isIdentifier(proxy)) throw new babelPluginMacros.MacroError('no proxy object'); | ||
var snap = t__namespace.identifier("valtio_macro_snap_" + proxy.name); | ||
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$par = _path$parentPath2.parentPath) == null ? void 0 : _path$parentPath2$par.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))])); | ||
(_path$parentPath2 = path.parentPath) == null || (_path$parentPath2 = _path$parentPath2.parentPath) == null ? void 0 : _path$parentPath2.replaceWith(t__namespace.variableDeclaration('const', [t__namespace.variableDeclarator(snap, t__namespace.callExpression(hook, [proxy]))])); | ||
var inFunction = 0; | ||
(_path$parentPath3 = path.parentPath) == null ? void 0 : (_path$parentPath3$get = _path$parentPath3.getFunctionParent()) == null ? void 0 : _path$parentPath3$get.traverse({ | ||
(_path$parentPath3 = path.parentPath) == null || (_path$parentPath3 = _path$parentPath3.getFunctionParent()) == null ? void 0 : _path$parentPath3.traverse({ | ||
Identifier: function Identifier(p) { | ||
@@ -43,0 +43,0 @@ if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) { |
@@ -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).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(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=e.addNamed(n,"useSnapshot","valtio"),u=null==(r=n.parentPath)||null==(r=r.get("arguments.0"))?void 0:r.node;if(!a.isIdentifier(u))throw new t.MacroError("no proxy object");var c=a.identifier("valtio_macro_snap_"+u.name);null==(o=n.parentPath)||null==(o=o.parentPath)||o.replaceWith(a.variableDeclaration("const",[a.variableDeclarator(c,a.callExpression(l,[u]))]));var f=0;null==(i=n.parentPath)||null==(i=i.getFunctionParent())||i.traverse({Identifier:function(e){0===f&&e.node!==u&&e.node.name===u.name&&(e.node.name=c.name)},Function:{enter:function(){++f},exit:function(){--f}}})}))}),{configName:"valtio"})})); |
@@ -34,3 +34,3 @@ (function (global, factory) { | ||
var valtioMacro = defineMacro("useProxy").withSignature("<T extends object>(proxyObject: T): void").withHandler(function (ctx) { | ||
var _args$, _path$parentPath, _path$parentPath2, _path$parentPath2$get; | ||
var _args$, _path$parentPath, _path$parentPath2; | ||
var path = ctx.path, | ||
@@ -46,3 +46,3 @@ args = ctx.args; | ||
var inFunction = 0; | ||
(_path$parentPath2 = path.parentPath) == null ? void 0 : (_path$parentPath2$get = _path$parentPath2.getFunctionParent()) == null ? void 0 : _path$parentPath2$get.traverse({ | ||
(_path$parentPath2 = path.parentPath) == null || (_path$parentPath2 = _path$parentPath2.getFunctionParent()) == null ? void 0 : _path$parentPath2.traverse({ | ||
Identifier: function Identifier(p) { | ||
@@ -49,0 +49,0 @@ if (inFunction === 0 && p.node !== proxy && p.node.name === proxy.name) { |
@@ -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).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(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=e.path,n=e.args,u=i.addNamed(o,"useSnapshot","valtio"),d=null==(t=n[0])?void 0:t.node;if(!l.isIdentifier(d))throw new c.MacroError("no proxy object");var f=l.identifier("valtio_macro_snap_"+d.name);null==(r=o.parentPath)||r.replaceWith(l.variableDeclaration("const",[l.variableDeclarator(f,l.callExpression(u,[d]))]));var s=0;null==(a=o.parentPath)||null==(a=a.getFunctionParent())||a.traverse({Identifier:function(e){0===s&&e.node!==d&&e.node.name===d.name&&(e.node.name=f.name)},Function:{enter:function(){++s},exit:function(){--s}}})}));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})})); |
@@ -8,3 +8,3 @@ (function (global, factory) { | ||
Object.keys(utils).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -15,3 +15,3 @@ get: function () { return utils[k]; } | ||
Object.keys(utils$1).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -18,0 +18,0 @@ get: function () { return utils$1[k]; } |
@@ -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).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(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||Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[i]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}})}))})); |
@@ -86,3 +86,3 @@ (function (global, factory) { | ||
}); | ||
return snap; | ||
return Object.preventExtensions(snap); | ||
}); | ||
@@ -89,0 +89,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).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);"value"in t&&(m[e]=c[e],delete t.value,delete t.writable),Object.defineProperty(j,e,t)})),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(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)}})),Object.preventExtensions(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)),O=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,O);var m=[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(O,m),Reflect.ownKeys(c).forEach((function(e){var t=Object.getOwnPropertyDescriptor(c,e);"value"in t&&(O[e]=c[e],delete t.value,delete t.writable),Object.defineProperty(j,e,t)})),O}),[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})); |
@@ -361,4 +361,4 @@ (function (global, factory) { | ||
dependencies.forEach(function (entry, p) { | ||
var _lastDependencies, _lastDependencies$get; | ||
var lastSubscription = (_lastDependencies = lastDependencies) == null ? void 0 : (_lastDependencies$get = _lastDependencies.get(p)) == null ? void 0 : _lastDependencies$get.s; | ||
var _lastDependencies; | ||
var lastSubscription = (_lastDependencies = lastDependencies) == null || (_lastDependencies = _lastDependencies.get(p)) == null ? void 0 : _lastDependencies.s; | ||
if (lastSubscription) { | ||
@@ -365,0 +365,0 @@ entry.s = lastSubscription; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).valtioVanillaUtils={},t.valtioVanilla)}(this,(function(t,n){"use strict";var e;function r(t,n,e,r){var i={configurable:!0,enumerable:!0};return i[t]=r,Object.defineProperty(n,e,i)}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(this,arguments)}var a=["enabled","name"],o=Symbol();var u=new WeakMap,s=new WeakMap,c=function t(n,e){var r=u.get(n);r&&(r[0].forEach((function(e){var r=e.d;n!==r&&t(r)})),++r[2],e&&r[3].add(e))},f=function(t,n){var e=u.get(t);return!(null==e||!e[2])&&(e[3].add(n),!0)},l=function t(n){var e=u.get(n);e&&(--e[2],e[2]||(e[3].forEach((function(t){return t()})),e[3].clear()),e[0].forEach((function(e){var r=e.d;n!==r&&t(r)})))},d=function(t){var e=t.s,r=t.d,i=s.get(r);i||(i=[new Set],s.set(t.d,i)),i[0].add(t);var a=u.get(e);if(!a){var o=new Set,f=n.subscribe(e,(function(t){o.forEach((function(n){var r=n.d,i=n.c,a=n.n,o=n.i;e===r&&t.every((function(t){return 1===t[1].length&&o.includes(t[1][0])}))||n.p||(c(e,i),a?l(e):n.p=Promise.resolve().then((function(){delete n.p,l(e)})))}))}),!0);a=[o,f,0,new Set],u.set(e,a)}a[0].add(t)},p=function(t){var n=t.s,e=t.d,r=s.get(e);null==r||r[0].delete(t),0===(null==r?void 0:r[0].size)&&s.delete(e);var i=u.get(n);if(i){var a=i[0],o=i[1];a.delete(t),a.size||(o(),u.delete(n))}},h=function(t){var n=s.get(t);return n?Array.from(n[0]):[]},v={add:d,remove:p,list:h};function y(t,e){var r=(null==e?void 0:e.proxy)||n.proxy({}),i=!(null==e||!e.sync),a=Object.keys(t);return a.forEach((function(e){if(Object.getOwnPropertyDescriptor(r,e))throw new Error("object property already defined");var o=t[e],u=null;!function t(){if(u){if(Array.from(u).map((function(n){var e=n[0];return f(e,t)})).some((function(t){return t})))return;if(Array.from(u).every((function(t){var e=t[0],r=t[1];return n.getVersion(e)===r.v})))return}var s=new Map,c=o((function(t){return s.set(t,{v:n.getVersion(t)}),t})),l=function(){var n;s.forEach((function(n,o){var s,c,f=null==(s=u)||null==(c=s.get(o))?void 0:c.s;if(f)n.s=f;else{var l={s:o,d:r,k:e,c:t,n:i,i:a};d(l),n.s=l}})),null==(n=u)||n.forEach((function(t,n){!s.has(n)&&t.s&&p(t.s)})),u=s};c instanceof Promise?c.finally(l):l(),r[e]=c}()})),r}var b,O=function t(e){if(b||(b=n.unstable_buildProxyFunction()[2]),"object"!=typeof(r=e)||null===r||b.has(e))return e;var r,i=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((function(n){i[n]=t(e[n])})),i};t.addComputed=function(t,n,e){void 0===e&&(e=t);var r={};return Object.keys(n).forEach((function(e){r[e]=function(r){return n[e](r(t))}})),y(r,{proxy:e})},t.derive=y,t.devtools=function(t,e){"string"==typeof e&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),e={name:e});var r,u=e||{},s=u.enabled,c=u.name,f=void 0===c?"":c,l=function(t,n){if(null==t)return{};var e,r,i={},a=Object.keys(t);for(r=0;r<a.length;r++)e=a[r],n.indexOf(e)>=0||(i[e]=t[e]);return i}(u,a);try{r=null!=s&&s&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(r){var d=!1,p=r.connect(i({name:f},l)),h=n.subscribe(t,(function(e){var r=e.filter((function(t){return t[0],t[1][0]!==o})).map((function(t){return t[0]+":"+t[1].map(String).join(".")})).join(", ");if(r)if(d)d=!1;else{var i=Object.assign({},n.snapshot(t));delete i[o],p.send({type:r,updatedAt:(new Date).toLocaleString()},i)}})),v=p.subscribe((function(e){var r,i;if("ACTION"===e.type&&e.payload)try{Object.assign(t,JSON.parse(e.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===e.type&&e.state){var a,u;if("JUMP_TO_ACTION"===(null==(a=e.payload)?void 0:a.type)||"JUMP_TO_STATE"===(null==(u=e.payload)?void 0:u.type)){d=!0;var s=JSON.parse(e.state);Object.assign(t,s)}t[o]=e}else if("DISPATCH"===e.type&&"COMMIT"===(null==(r=e.payload)?void 0:r.type))p.init(n.snapshot(t));else if("DISPATCH"===e.type&&"IMPORT_STATE"===(null==(i=e.payload)?void 0:i.type)){var c,f,l=null==(c=e.payload.nextLiftedState)?void 0:c.actionsById,h=(null==(f=e.payload.nextLiftedState)?void 0:f.computedStates)||[];d=!0,h.forEach((function(e,r){var i=e.state,a=l[r]||"No action found";Object.assign(t,i),0===r?p.init(n.snapshot(t)):p.send(a,n.snapshot(t))}))}}));return p.init(n.snapshot(t)),function(){h(),null==v||v()}}},t.proxyMap=function(t){var e,i=n.proxy((r("get",e={data:Array.from(t||[]),has:function(t){return this.data.some((function(n){return n[0]===t}))},set:function(t,n){var e=this.data.find((function(n){return n[0]===t}));return e?e[1]=n:this.data.push([t,n]),this},get:function(t){var n;return null==(n=this.data.find((function(n){return n[0]===t})))?void 0:n[1]},delete:function(t){var n=this.data.findIndex((function(n){return n[0]===t}));return-1!==n&&(this.data.splice(n,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 n=this;this.data.forEach((function(e){t(e[1],e[0],n)}))},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"})),e[Symbol.iterator]=function(){return this.entries()},e));return Object.defineProperties(i,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(i),i},t.proxySet=function(t){var e,i=n.proxy((r("get",e={data:Array.from(new Set(t)),has:function(t){return-1!==this.data.indexOf(t)},add:function(t){var e=!1;return"object"==typeof t&&null!==t&&(e=-1!==this.data.indexOf(n.proxy(t))),-1!==this.data.indexOf(t)||e||this.data.push(t),this},delete:function(t){var n=this.data.indexOf(t);return-1!==n&&(this.data.splice(n,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},forEach:function(t){var n=this;this.data.forEach((function(e){t(e,e,n)}))}},Symbol.toStringTag,(function(){return"Set"})),e.toJSON=function(){return new Set(this.data)},e[Symbol.iterator]=function(){return this.data[Symbol.iterator]()},e.values=function(){return this.data.values()},e.keys=function(){return this.data.values()},e.entries=function(){return new Set(this.data).entries()},e));return Object.defineProperties(i,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(i),i},t.proxyWithComputed=function(t,e){Object.keys(e).forEach((function(i){if(Object.getOwnPropertyDescriptor(t,i))throw new Error("object property already defined");var a=e[i],o="function"==typeof a?{get:a}:a,u=o.get,s=o.set,c={get:function(){return u(n.snapshot(r))}};s&&(c.set=function(t){return s(r,t)}),Object.defineProperty(t,i,c)}));var r=n.proxy(t);return r},t.proxyWithHistory=function(t,e){void 0===e&&(e=!1);var r=n.proxy({value:t,history:n.ref({wip:void 0,snapshots:[],index:-1}),clone:O,canUndo:function(){return r.history.index>0},undo:function(){r.canUndo()&&(r.value=r.history.wip=r.clone(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=r.clone(r.history.snapshots[++r.history.index]))},saveHistory:function(){r.history.snapshots.splice(r.history.index+1),r.history.snapshots.push(n.snapshot(r).value),++r.history.index},subscribe:function(){return n.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(),e||r.subscribe(),r},t.subscribeKey=function(t,e,r,i){var a=t[e];return n.subscribe(t,(function(){var n=t[e];Object.is(a,n)||r(a=n)}),i)},t.underive=function(t,n){var e=null!=n&&n.delete?new Set:null;h(t).forEach((function(t){var r=t.k;null!=n&&n.keys&&!n.keys.includes(r)||(p(t),e&&e.add(r))})),e&&e.forEach((function(n){delete t[n]}))},t.unstable_deriveSubscriptions=v,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 e&&e.add(u),function u(){if(i){a.forEach((function(t){return t()})),a.clear();var s=new Set,c=e;e=a;try{var f=t((function(t){return s.add(t),t}));f&&a.add(f)}finally{e=c}o.forEach((function(t,n){s.has(n)?s.delete(n):(o.delete(n),t())})),s.forEach((function(t){var e=n.subscribe(t,u,null==r?void 0:r.sync);o.set(t,e)}))}}(),u}})); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).valtioVanillaUtils={},t.valtioVanilla)}(this,(function(t,n){"use strict";var e;function r(t,n,e,r){var i={configurable:!0,enumerable:!0};return i[t]=r,Object.defineProperty(n,e,i)}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(this,arguments)}var a=["enabled","name"],o=Symbol();var u=new WeakMap,s=new WeakMap,c=function t(n,e){var r=u.get(n);r&&(r[0].forEach((function(e){var r=e.d;n!==r&&t(r)})),++r[2],e&&r[3].add(e))},f=function(t,n){var e=u.get(t);return!(null==e||!e[2])&&(e[3].add(n),!0)},l=function t(n){var e=u.get(n);e&&(--e[2],e[2]||(e[3].forEach((function(t){return t()})),e[3].clear()),e[0].forEach((function(e){var r=e.d;n!==r&&t(r)})))},d=function(t){var e=t.s,r=t.d,i=s.get(r);i||(i=[new Set],s.set(t.d,i)),i[0].add(t);var a=u.get(e);if(!a){var o=new Set,f=n.subscribe(e,(function(t){o.forEach((function(n){var r=n.d,i=n.c,a=n.n,o=n.i;e===r&&t.every((function(t){return 1===t[1].length&&o.includes(t[1][0])}))||n.p||(c(e,i),a?l(e):n.p=Promise.resolve().then((function(){delete n.p,l(e)})))}))}),!0);a=[o,f,0,new Set],u.set(e,a)}a[0].add(t)},p=function(t){var n=t.s,e=t.d,r=s.get(e);null==r||r[0].delete(t),0===(null==r?void 0:r[0].size)&&s.delete(e);var i=u.get(n);if(i){var a=i[0],o=i[1];a.delete(t),a.size||(o(),u.delete(n))}},h=function(t){var n=s.get(t);return n?Array.from(n[0]):[]},v={add:d,remove:p,list:h};function y(t,e){var r=(null==e?void 0:e.proxy)||n.proxy({}),i=!(null==e||!e.sync),a=Object.keys(t);return a.forEach((function(e){if(Object.getOwnPropertyDescriptor(r,e))throw new Error("object property already defined");var o=t[e],u=null;!function t(){if(u){if(Array.from(u).map((function(n){var e=n[0];return f(e,t)})).some((function(t){return t})))return;if(Array.from(u).every((function(t){var e=t[0],r=t[1];return n.getVersion(e)===r.v})))return}var s=new Map,c=o((function(t){return s.set(t,{v:n.getVersion(t)}),t})),l=function(){var n;s.forEach((function(n,o){var s,c=null==(s=u)||null==(s=s.get(o))?void 0:s.s;if(c)n.s=c;else{var f={s:o,d:r,k:e,c:t,n:i,i:a};d(f),n.s=f}})),null==(n=u)||n.forEach((function(t,n){!s.has(n)&&t.s&&p(t.s)})),u=s};c instanceof Promise?c.finally(l):l(),r[e]=c}()})),r}var b,O=function t(e){if(b||(b=n.unstable_buildProxyFunction()[2]),"object"!=typeof(r=e)||null===r||b.has(e))return e;var r,i=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((function(n){i[n]=t(e[n])})),i};t.addComputed=function(t,n,e){void 0===e&&(e=t);var r={};return Object.keys(n).forEach((function(e){r[e]=function(r){return n[e](r(t))}})),y(r,{proxy:e})},t.derive=y,t.devtools=function(t,e){"string"==typeof e&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),e={name:e});var r,u=e||{},s=u.enabled,c=u.name,f=void 0===c?"":c,l=function(t,n){if(null==t)return{};var e,r,i={},a=Object.keys(t);for(r=0;r<a.length;r++)e=a[r],n.indexOf(e)>=0||(i[e]=t[e]);return i}(u,a);try{r=null!=s&&s&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(r){var d=!1,p=r.connect(i({name:f},l)),h=n.subscribe(t,(function(e){var r=e.filter((function(t){return t[0],t[1][0]!==o})).map((function(t){return t[0]+":"+t[1].map(String).join(".")})).join(", ");if(r)if(d)d=!1;else{var i=Object.assign({},n.snapshot(t));delete i[o],p.send({type:r,updatedAt:(new Date).toLocaleString()},i)}})),v=p.subscribe((function(e){var r,i;if("ACTION"===e.type&&e.payload)try{Object.assign(t,JSON.parse(e.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===e.type&&e.state){var a,u;if("JUMP_TO_ACTION"===(null==(a=e.payload)?void 0:a.type)||"JUMP_TO_STATE"===(null==(u=e.payload)?void 0:u.type)){d=!0;var s=JSON.parse(e.state);Object.assign(t,s)}t[o]=e}else if("DISPATCH"===e.type&&"COMMIT"===(null==(r=e.payload)?void 0:r.type))p.init(n.snapshot(t));else if("DISPATCH"===e.type&&"IMPORT_STATE"===(null==(i=e.payload)?void 0:i.type)){var c,f,l=null==(c=e.payload.nextLiftedState)?void 0:c.actionsById,h=(null==(f=e.payload.nextLiftedState)?void 0:f.computedStates)||[];d=!0,h.forEach((function(e,r){var i=e.state,a=l[r]||"No action found";Object.assign(t,i),0===r?p.init(n.snapshot(t)):p.send(a,n.snapshot(t))}))}}));return p.init(n.snapshot(t)),function(){h(),null==v||v()}}},t.proxyMap=function(t){var e,i=n.proxy((r("get",e={data:Array.from(t||[]),has:function(t){return this.data.some((function(n){return n[0]===t}))},set:function(t,n){var e=this.data.find((function(n){return n[0]===t}));return e?e[1]=n:this.data.push([t,n]),this},get:function(t){var n;return null==(n=this.data.find((function(n){return n[0]===t})))?void 0:n[1]},delete:function(t){var n=this.data.findIndex((function(n){return n[0]===t}));return-1!==n&&(this.data.splice(n,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 n=this;this.data.forEach((function(e){t(e[1],e[0],n)}))},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"})),e[Symbol.iterator]=function(){return this.entries()},e));return Object.defineProperties(i,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(i),i},t.proxySet=function(t){var e,i=n.proxy((r("get",e={data:Array.from(new Set(t)),has:function(t){return-1!==this.data.indexOf(t)},add:function(t){var e=!1;return"object"==typeof t&&null!==t&&(e=-1!==this.data.indexOf(n.proxy(t))),-1!==this.data.indexOf(t)||e||this.data.push(t),this},delete:function(t){var n=this.data.indexOf(t);return-1!==n&&(this.data.splice(n,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},forEach:function(t){var n=this;this.data.forEach((function(e){t(e,e,n)}))}},Symbol.toStringTag,(function(){return"Set"})),e.toJSON=function(){return new Set(this.data)},e[Symbol.iterator]=function(){return this.data[Symbol.iterator]()},e.values=function(){return this.data.values()},e.keys=function(){return this.data.values()},e.entries=function(){return new Set(this.data).entries()},e));return Object.defineProperties(i,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(i),i},t.proxyWithComputed=function(t,e){Object.keys(e).forEach((function(i){if(Object.getOwnPropertyDescriptor(t,i))throw new Error("object property already defined");var a=e[i],o="function"==typeof a?{get:a}:a,u=o.get,s=o.set,c={get:function(){return u(n.snapshot(r))}};s&&(c.set=function(t){return s(r,t)}),Object.defineProperty(t,i,c)}));var r=n.proxy(t);return r},t.proxyWithHistory=function(t,e){void 0===e&&(e=!1);var r=n.proxy({value:t,history:n.ref({wip:void 0,snapshots:[],index:-1}),clone:O,canUndo:function(){return r.history.index>0},undo:function(){r.canUndo()&&(r.value=r.history.wip=r.clone(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=r.clone(r.history.snapshots[++r.history.index]))},saveHistory:function(){r.history.snapshots.splice(r.history.index+1),r.history.snapshots.push(n.snapshot(r).value),++r.history.index},subscribe:function(){return n.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(),e||r.subscribe(),r},t.subscribeKey=function(t,e,r,i){var a=t[e];return n.subscribe(t,(function(){var n=t[e];Object.is(a,n)||r(a=n)}),i)},t.underive=function(t,n){var e=null!=n&&n.delete?new Set:null;h(t).forEach((function(t){var r=t.k;null!=n&&n.keys&&!n.keys.includes(r)||(p(t),e&&e.add(r))})),e&&e.forEach((function(n){delete t[n]}))},t.unstable_deriveSubscriptions=v,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 e&&e.add(u),function u(){if(i){a.forEach((function(t){return t()})),a.clear();var s=new Set,c=e;e=a;try{var f=t((function(t){return s.add(t),t}));f&&a.add(f)}finally{e=c}o.forEach((function(t,n){s.has(n)?s.delete(n):(o.delete(n),t())})),s.forEach((function(t){var e=n.subscribe(t,u,null==r?void 0:r.sync);o.set(t,e)}))}}(),u}})); |
@@ -9,3 +9,3 @@ 'use strict'; | ||
Object.keys(utils).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -16,3 +16,3 @@ get: function () { return utils[k]; } | ||
Object.keys(utils$1).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
@@ -19,0 +19,0 @@ get: function () { return utils$1[k]; } |
@@ -8,3 +8,4 @@ type AnyFunction = (...args: any[]) => any; | ||
type Listener = (op: Op, nextVersion: number) => void; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction; | ||
type Primitive = string | number | boolean | null | undefined | symbol | bigint; | ||
type SnapshotIgnore = Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | AsRef | Error | RegExp | AnyFunction | Primitive; | ||
type Snapshot<T> = T extends SnapshotIgnore ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { | ||
@@ -11,0 +12,0 @@ readonly [K in keyof T]: Snapshot<T[K]>; |
@@ -84,3 +84,3 @@ 'use strict'; | ||
}); | ||
return snap; | ||
return Object.preventExtensions(snap); | ||
}); | ||
@@ -87,0 +87,0 @@ } |
@@ -359,4 +359,4 @@ 'use strict'; | ||
dependencies.forEach(function (entry, p) { | ||
var _lastDependencies, _lastDependencies$get; | ||
var lastSubscription = (_lastDependencies = lastDependencies) == null ? void 0 : (_lastDependencies$get = _lastDependencies.get(p)) == null ? void 0 : _lastDependencies$get.s; | ||
var _lastDependencies; | ||
var lastSubscription = (_lastDependencies = lastDependencies) == null || (_lastDependencies = _lastDependencies.get(p)) == null ? void 0 : _lastDependencies.s; | ||
if (lastSubscription) { | ||
@@ -363,0 +363,0 @@ entry.s = lastSubscription; |
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
320027
7538