Socket
Socket
Sign inDemoInstall

valtio

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valtio - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

14

esm/utils.js
import { subscribe, snapshot, proxy, getVersion, ref } from 'valtio/vanilla';
import { createProxy, isChanged } from 'proxy-compare';

@@ -349,15 +348,4 @@ function subscribeKey(proxyObject, key, callback, notifyInSync) {

const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
let computedValue;
let prevSnapshot;
let affected = /* @__PURE__ */ new WeakMap();
const desc = {};
desc.get = () => {
const nextSnapshot = snapshot(proxyObject);
if (!prevSnapshot || isChanged(prevSnapshot, nextSnapshot, affected)) {
affected = /* @__PURE__ */ new WeakMap();
computedValue = get(createProxy(nextSnapshot, affected));
prevSnapshot = nextSnapshot;
}
return computedValue;
};
desc.get = () => get(snapshot(proxyObject));
if (set) {

@@ -364,0 +352,0 @@ desc.set = (newValue) => set(proxyObject, newValue);

2

esm/utils/derive.d.ts

@@ -19,3 +19,3 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*
* This creates derived properties and attatches them
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.

@@ -22,0 +22,0 @@ *

@@ -10,3 +10,3 @@ /**

* - canUndo: a function to return true if undo is available
* - undo: a function to go back hisotry
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available

@@ -13,0 +13,0 @@ * - redo: a function to go forward history

import { getUntracked, markToTrack } from 'proxy-compare';
const VERSION = Symbol();
const LISTENERS = Symbol();
const SNAPSHOT = Symbol();
const HANDLER = Symbol();
const PROMISE_RESULT = Symbol();
const PROMISE_ERROR = Symbol();
const VERSION = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("VERSION") : Symbol();
const LISTENERS = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("LISTENERS") : Symbol();
const SNAPSHOT = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("SNAPSHOT") : Symbol();
const HANDLER = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("HANDLER") : Symbol();
const PROMISE_RESULT = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("PROMISE_RESULT") : Symbol();
const PROMISE_ERROR = (import.meta.env && import.meta.env.MODE) !== "production" ? Symbol("PROMISE_ERROR") : Symbol();
const refSet = /* @__PURE__ */ new WeakSet();

@@ -122,4 +122,5 @@ function ref(o) {

var _a;
const hasPrevValue = Reflect.has(target, prop);
const prevValue = Reflect.get(target, prop, receiver);
if (this.is(prevValue, value)) {
if (hasPrevValue && this.is(prevValue, value)) {
return true;

@@ -126,0 +127,0 @@ }

{
"name": "valtio",
"private": false,
"version": "1.5.2",
"version": "1.6.0",
"description": "💊 Valtio makes proxy-state simple for React and Vanilla",

@@ -82,2 +82,5 @@ "main": "./index.js",

},
"resolutions": {
"date-fns": "2.27.0"
},
"peerDependencies": {

@@ -84,0 +87,0 @@ "@babel/helper-module-imports": ">=7.12",

@@ -35,3 +35,3 @@ <img src="logo.svg" alt="valtio">

Create a local snapshot that catches changes. Rule of thumb: read from snapshots, mutate the source. The component will only re-render when the parts of the state you access have changed, it is render-optimized.
Create a local snapshot that catches changes. Rule of thumb: read from snapshots in render function, otherwise use the source. The component will only re-render when the parts of the state you access have changed, it is render-optimized.

@@ -330,8 +330,13 @@ ```jsx

You can have computed values with dependency tracking with property access.
Dependency tracking in `proxyWithComputed` overlaps the work in `useSnapshot`.
React users should prefer using `derive`.
`proxyWithComputed` works well for some edge cases and for vanilla-js users.
You can define own computed properties within a proxy.
By combining with a memoization library such as
[proxy-memoize](https://github.com/dai-shi/proxy-memoize),
optimizing function calls is possible.
Be careful not to overuse `proxy-memoize`
because `proxy-memoize` and `useSnapshot` do similar optimization
and double optimization may lead to less performance.
```js
import memoize from 'proxy-memoize'
import { proxyWithComputed } from 'valtio/utils'

@@ -342,3 +347,3 @@

}, {
doubled: snap => snap.count * 2
doubled: memoize((snap) => snap.count * 2)
})

@@ -352,3 +357,3 @@

fullName: {
get: (snap) => snap.firstName + ' ' + snap.lastName,
get: memoize((snap) => snap.firstName + ' ' + snap.lastName),
set: (state, newValue) => { [state.firstName, state.lastName] = newValue.split(' ') },

@@ -362,4 +367,4 @@ }

}, {
doubled: snap => snap.count * 2,
quadrupled: snap => snap.doubled * 2
doubled: memoize((snap) => snap.count * 2),
quadrupled: memoize((snap) => snap.doubled * 2)
})

@@ -366,0 +371,0 @@ ```

@@ -1,4 +0,4 @@

System.register(['valtio/vanilla', 'proxy-compare'], (function (exports) {
System.register(['valtio/vanilla'], (function (exports) {
'use strict';
var subscribe, snapshot, proxy, getVersion, ref, createProxy, isChanged;
var subscribe, snapshot, proxy, getVersion, ref;
return {

@@ -11,5 +11,2 @@ setters: [function (module) {

ref = module.ref;
}, function (module) {
createProxy = module.createProxy;
isChanged = module.isChanged;
}],

@@ -376,15 +373,4 @@ execute: (function () {

const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
let computedValue;
let prevSnapshot;
let affected = /* @__PURE__ */ new WeakMap();
const desc = {};
desc.get = () => {
const nextSnapshot = snapshot(proxyObject);
if (!prevSnapshot || isChanged(prevSnapshot, nextSnapshot, affected)) {
affected = /* @__PURE__ */ new WeakMap();
computedValue = get(createProxy(nextSnapshot, affected));
prevSnapshot = nextSnapshot;
}
return computedValue;
};
desc.get = () => get(snapshot(proxyObject));
if (set) {

@@ -391,0 +377,0 @@ desc.set = (newValue) => set(proxyObject, newValue);

@@ -1,2 +0,2 @@

System.register(["valtio/vanilla","proxy-compare"],function(k){"use strict";var S,y,b,E,C,M,A;return{setters:[function(f){S=f.subscribe,y=f.snapshot,b=f.proxy,E=f.getVersion,C=f.ref},function(f){M=f.createProxy,A=f.isChanged}],execute:function(){k({addComputed:U,derive:I,devtools:H,proxyMap:X,proxySet:K,proxyWithComputed:L,proxyWithHistory:V,subscribeKey:f,underive:R,watch:W});function f(n,s,e,t){return S(n,r=>{r.some(o=>o[1][0]===s)&&e(n[s])},t)}let O;function W(n,s){let e=!0;const t=new Set,r=new Map,o=()=>{e&&(e=!1,t.forEach(i=>i()),t.clear(),r.forEach(i=>i()),r.clear())},u=()=>{if(!e)return;t.forEach(a=>a()),t.clear();const i=new Set,h=O;O=t;try{const a=n(c=>(i.add(c),c));a&&t.add(a)}finally{O=h}r.forEach((a,c)=>{i.has(c)?i.delete(c):(r.delete(c),a())}),i.forEach(a=>{const c=S(a,u,s==null?void 0:s.sync);r.set(a,c)})};return O&&O.add(o),u(),o}const j=Symbol();function H(n,s){typeof s=="string"&&(console.warn("[Deprecated] Please use option object instead of name string"),s={name:s});const{enabled:e,name:t=""}=s||{};let r;try{r=(e!=null?e:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!r)return;let o=!1;const u=r.connect({name:t}),i=S(n,a=>{const c=a.filter(([l,d])=>d[0]!==j).map(([l,d])=>`${l}:${d.map(String).join(".")}`).join(", ");if(c)if(o)o=!1;else{const l=Object.assign({},y(n));delete l[j],u.send({type:c,updatedAt:new Date().toLocaleString()},l)}}),h=u.subscribe(a=>{var c,l,d,p,x,w;if(a.type==="ACTION"&&a.payload)try{Object.assign(n,JSON.parse(a.payload))}catch(v){console.error(`please dispatch a serializable value that JSON.parse() and proxy() support
`,v)}if(a.type==="DISPATCH"&&a.state){if(((c=a.payload)==null?void 0:c.type)==="JUMP_TO_ACTION"||((l=a.payload)==null?void 0:l.type)==="JUMP_TO_STATE"){o=!0;const v=JSON.parse(a.state);Object.assign(n,v)}n[j]=a}else if(a.type==="DISPATCH"&&((d=a.payload)==null?void 0:d.type)==="COMMIT")u.init(y(n));else if(a.type==="DISPATCH"&&((p=a.payload)==null?void 0:p.type)==="IMPORT_STATE"){const v=(x=a.payload.nextLiftedState)==null?void 0:x.actionsById,$=((w=a.payload.nextLiftedState)==null?void 0:w.computedStates)||[];o=!0,$.forEach(({state:B},J)=>{const F=v[J]||"No action found";Object.assign(n,B),J===0?u.init(y(n)):u.send(F,y(n))})}});return u.init(y(n)),()=>{i(),h==null||h()}}const g=new WeakMap,m=new WeakMap,_=(n,s)=>{const e=g.get(n);e&&(e[0].forEach(t=>{const{d:r}=t;n!==r&&_(r)}),++e[2],s&&e[3].add(s))},z=(n,s)=>{const e=g.get(n);return e!=null&&e[2]?(e[3].add(s),!0):!1},T=n=>{const s=g.get(n);s&&(--s[2],s[2]||(s[3].forEach(e=>e()),s[3].clear()),s[0].forEach(e=>{const{d:t}=e;n!==t&&T(t)}))},D=n=>{const{s,d:e}=n;let t=m.get(e);t||(t=[new Set],m.set(n.d,t)),t[0].add(n);let r=g.get(s);if(!r){const o=new Set,u=S(s,i=>{o.forEach(h=>{const{d:a,c,n:l,i:d}=h;s===a&&i.every(p=>p[1].length===1&&d.includes(p[1][0]))||h.p||(_(s,c),l?T(s):h.p=Promise.resolve().then(()=>{delete h.p,T(s)}))})},!0);r=[o,u,0,new Set],g.set(s,r)}r[0].add(n)},P=n=>{const{s,d:e}=n,t=m.get(e);t==null||t[0].delete(n),(t==null?void 0:t[0].size)===0&&m.delete(e);const r=g.get(s);if(r){const[o,u]=r;o.delete(n),o.size||(u(),g.delete(s))}},N=n=>{const s=m.get(n);return s?Array.from(s[0]):[]},q=k("unstable_deriveSubscriptions",{add:D,remove:P,list:N});function I(n,s){const e=(s==null?void 0:s.proxy)||b({}),t=!!(s!=null&&s.sync),r=Object.keys(n);return r.forEach(o=>{if(Object.getOwnPropertyDescriptor(e,o))throw new Error("object property already defined");const u=n[o];let i=null;const h=()=>{if(i&&(Array.from(i).map(([d])=>z(d,h)).some(d=>d)||Array.from(i).every(([d,p])=>E(d)===p.v)))return;const a=new Map,c=u(d=>(a.set(d,{v:E(d)}),d)),l=()=>{a.forEach((d,p)=>{var x;const w=(x=i==null?void 0:i.get(p))==null?void 0:x.s;if(w)d.s=w;else{const v={s:p,d:e,k:o,c:h,n:t,i:r};D(v),d.s=v}}),i==null||i.forEach((d,p)=>{!a.has(p)&&d.s&&P(d.s)}),i=a};c instanceof Promise?c.finally(l):l(),e[o]=c};h()}),e}function R(n,s){const e=s!=null&&s.delete?new Set:null;N(n).forEach(t=>{const{k:r}=t;(!(s!=null&&s.keys)||s.keys.includes(r))&&(P(t),e&&e.add(r))}),e&&e.forEach(t=>{delete n[t]})}function U(n,s,e=n){console.warn("addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive.");const t={};return Object.keys(s).forEach(r=>{t[r]=o=>s[r](o(n))}),I(t,{proxy:e})}function L(n,s){Object.keys(s).forEach(t=>{if(Object.getOwnPropertyDescriptor(n,t))throw new Error("object property already defined");const r=s[t],{get:o,set:u}=typeof r=="function"?{get:r}:r;let i,h,a=new WeakMap;const c={};c.get=()=>{const l=y(e);return(!h||A(h,l,a))&&(a=new WeakMap,i=o(M(l,a)),h=l),i},u&&(c.set=l=>u(e,l)),Object.defineProperty(n,t,c)});const e=b(n);return e}function V(n,s=!1){const e=b({value:n,history:C({wip:n,snapshots:[],index:-1}),canUndo:()=>e.history.index>0,undo:()=>{e.canUndo()&&(e.value=e.history.wip=e.history.snapshots[--e.history.index],e.history.snapshots[e.history.index]=y(e).value)},canRedo:()=>e.history.index<e.history.snapshots.length-1,redo:()=>{e.canRedo()&&(e.value=e.history.wip=e.history.snapshots[++e.history.index],e.history.snapshots[e.history.index]=y(e).value)},saveHistory:()=>{e.history.snapshots.splice(e.history.index+1),e.history.snapshots.push(y(e).value),++e.history.index},subscribe:()=>S(e,t=>{t.every(r=>r[1][0]==="value"&&(r[0]!=="set"||r[2]!==e.history.wip))&&e.saveHistory()})});return e.saveHistory(),s||e.subscribe(),e}function K(n){const s=b({data:Array.from(new Set(n)),has(e){return this.data.indexOf(e)!==-1},add(e){let t=!1;return typeof e=="object"&&e!==null&&(t=this.data.indexOf(b(e))!==-1),this.data.indexOf(e)===-1&&!t&&this.data.push(e),this},delete(e){const t=this.data.indexOf(e);return t===-1?!1:(this.data.splice(t,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},forEach(e){this.data.forEach(t=>{e(t,t,this)})},get[Symbol.toStringTag](){return"Set"},toJSON(){return{}},[Symbol.iterator](){return this.data[Symbol.iterator]()},values(){return this.data.values()},keys(){return this.data.values()},entries(){return new Set(this.data).entries()}});return Object.defineProperties(s,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(s),s}function X(n){const s=b({data:Array.from(n||[]),has(e){return this.data.some(t=>t[0]===e)},set(e,t){const r=this.data.find(o=>o[0]===e);return r?r[1]=t:this.data.push([e,t]),this},get(e){var t;return(t=this.data.find(r=>r[0]===e))==null?void 0:t[1]},delete(e){const t=this.data.findIndex(r=>r[0]===e);return t===-1?!1:(this.data.splice(t,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return{}},forEach(e){this.data.forEach(t=>{e(t[1],t[0],this)})},keys(){return this.data.map(e=>e[0]).values()},values(){return this.data.map(e=>e[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(s,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(s),s}}}});
System.register(["valtio/vanilla"],function(A){"use strict";var g,y,v,x,k;return{setters:[function(b){g=b.subscribe,y=b.snapshot,v=b.proxy,x=b.getVersion,k=b.ref}],execute:function(){A({addComputed:W,derive:D,devtools:J,proxyMap:V,proxySet:L,proxyWithComputed:R,proxyWithHistory:U,subscribeKey:b,underive:z,watch:I});function b(n,s,e,t){return g(n,r=>{r.some(o=>o[1][0]===s)&&e(n[s])},t)}let O;function I(n,s){let e=!0;const t=new Set,r=new Map,o=()=>{e&&(e=!1,t.forEach(i=>i()),t.clear(),r.forEach(i=>i()),r.clear())},l=()=>{if(!e)return;t.forEach(a=>a()),t.clear();const i=new Set,u=O;O=t;try{const a=n(c=>(i.add(c),c));a&&t.add(a)}finally{O=u}r.forEach((a,c)=>{i.has(c)?i.delete(c):(r.delete(c),a())}),i.forEach(a=>{const c=g(a,l,s==null?void 0:s.sync);r.set(a,c)})};return O&&O.add(o),l(),o}const j=Symbol();function J(n,s){typeof s=="string"&&(console.warn("[Deprecated] Please use option object instead of name string"),s={name:s});const{enabled:e,name:t=""}=s||{};let r;try{r=(e!=null?e:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!r)return;let o=!1;const l=r.connect({name:t}),i=g(n,a=>{const c=a.filter(([h,d])=>d[0]!==j).map(([h,d])=>`${h}:${d.map(String).join(".")}`).join(", ");if(c)if(o)o=!1;else{const h=Object.assign({},y(n));delete h[j],l.send({type:c,updatedAt:new Date().toLocaleString()},h)}}),u=l.subscribe(a=>{var c,h,d,p,E,w;if(a.type==="ACTION"&&a.payload)try{Object.assign(n,JSON.parse(a.payload))}catch(f){console.error(`please dispatch a serializable value that JSON.parse() and proxy() support
`,f)}if(a.type==="DISPATCH"&&a.state){if(((c=a.payload)==null?void 0:c.type)==="JUMP_TO_ACTION"||((h=a.payload)==null?void 0:h.type)==="JUMP_TO_STATE"){o=!0;const f=JSON.parse(a.state);Object.assign(n,f)}n[j]=a}else if(a.type==="DISPATCH"&&((d=a.payload)==null?void 0:d.type)==="COMMIT")l.init(y(n));else if(a.type==="DISPATCH"&&((p=a.payload)==null?void 0:p.type)==="IMPORT_STATE"){const f=(E=a.payload.nextLiftedState)==null?void 0:E.actionsById,K=((w=a.payload.nextLiftedState)==null?void 0:w.computedStates)||[];o=!0,K.forEach(({state:X},N)=>{const $=f[N]||"No action found";Object.assign(n,X),N===0?l.init(y(n)):l.send($,y(n))})}});return l.init(y(n)),()=>{i(),u==null||u()}}const S=new WeakMap,m=new WeakMap,C=(n,s)=>{const e=S.get(n);e&&(e[0].forEach(t=>{const{d:r}=t;n!==r&&C(r)}),++e[2],s&&e[3].add(s))},H=(n,s)=>{const e=S.get(n);return e!=null&&e[2]?(e[3].add(s),!0):!1},T=n=>{const s=S.get(n);s&&(--s[2],s[2]||(s[3].forEach(e=>e()),s[3].clear()),s[0].forEach(e=>{const{d:t}=e;n!==t&&T(t)}))},M=n=>{const{s,d:e}=n;let t=m.get(e);t||(t=[new Set],m.set(n.d,t)),t[0].add(n);let r=S.get(s);if(!r){const o=new Set,l=g(s,i=>{o.forEach(u=>{const{d:a,c,n:h,i:d}=u;s===a&&i.every(p=>p[1].length===1&&d.includes(p[1][0]))||u.p||(C(s,c),h?T(s):u.p=Promise.resolve().then(()=>{delete u.p,T(s)}))})},!0);r=[o,l,0,new Set],S.set(s,r)}r[0].add(n)},P=n=>{const{s,d:e}=n,t=m.get(e);t==null||t[0].delete(n),(t==null?void 0:t[0].size)===0&&m.delete(e);const r=S.get(s);if(r){const[o,l]=r;o.delete(n),o.size||(l(),S.delete(s))}},_=n=>{const s=m.get(n);return s?Array.from(s[0]):[]},B=A("unstable_deriveSubscriptions",{add:M,remove:P,list:_});function D(n,s){const e=(s==null?void 0:s.proxy)||v({}),t=!!(s!=null&&s.sync),r=Object.keys(n);return r.forEach(o=>{if(Object.getOwnPropertyDescriptor(e,o))throw new Error("object property already defined");const l=n[o];let i=null;const u=()=>{if(i&&(Array.from(i).map(([d])=>H(d,u)).some(d=>d)||Array.from(i).every(([d,p])=>x(d)===p.v)))return;const a=new Map,c=l(d=>(a.set(d,{v:x(d)}),d)),h=()=>{a.forEach((d,p)=>{var E;const w=(E=i==null?void 0:i.get(p))==null?void 0:E.s;if(w)d.s=w;else{const f={s:p,d:e,k:o,c:u,n:t,i:r};M(f),d.s=f}}),i==null||i.forEach((d,p)=>{!a.has(p)&&d.s&&P(d.s)}),i=a};c instanceof Promise?c.finally(h):h(),e[o]=c};u()}),e}function z(n,s){const e=s!=null&&s.delete?new Set:null;_(n).forEach(t=>{const{k:r}=t;(!(s!=null&&s.keys)||s.keys.includes(r))&&(P(t),e&&e.add(r))}),e&&e.forEach(t=>{delete n[t]})}function W(n,s,e=n){console.warn("addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive.");const t={};return Object.keys(s).forEach(r=>{t[r]=o=>s[r](o(n))}),D(t,{proxy:e})}function R(n,s){Object.keys(s).forEach(t=>{if(Object.getOwnPropertyDescriptor(n,t))throw new Error("object property already defined");const r=s[t],{get:o,set:l}=typeof r=="function"?{get:r}:r,i={};i.get=()=>o(y(e)),l&&(i.set=u=>l(e,u)),Object.defineProperty(n,t,i)});const e=v(n);return e}function U(n,s=!1){const e=v({value:n,history:k({wip:n,snapshots:[],index:-1}),canUndo:()=>e.history.index>0,undo:()=>{e.canUndo()&&(e.value=e.history.wip=e.history.snapshots[--e.history.index],e.history.snapshots[e.history.index]=y(e).value)},canRedo:()=>e.history.index<e.history.snapshots.length-1,redo:()=>{e.canRedo()&&(e.value=e.history.wip=e.history.snapshots[++e.history.index],e.history.snapshots[e.history.index]=y(e).value)},saveHistory:()=>{e.history.snapshots.splice(e.history.index+1),e.history.snapshots.push(y(e).value),++e.history.index},subscribe:()=>g(e,t=>{t.every(r=>r[1][0]==="value"&&(r[0]!=="set"||r[2]!==e.history.wip))&&e.saveHistory()})});return e.saveHistory(),s||e.subscribe(),e}function L(n){const s=v({data:Array.from(new Set(n)),has(e){return this.data.indexOf(e)!==-1},add(e){let t=!1;return typeof e=="object"&&e!==null&&(t=this.data.indexOf(v(e))!==-1),this.data.indexOf(e)===-1&&!t&&this.data.push(e),this},delete(e){const t=this.data.indexOf(e);return t===-1?!1:(this.data.splice(t,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},forEach(e){this.data.forEach(t=>{e(t,t,this)})},get[Symbol.toStringTag](){return"Set"},toJSON(){return{}},[Symbol.iterator](){return this.data[Symbol.iterator]()},values(){return this.data.values()},keys(){return this.data.values()},entries(){return new Set(this.data).entries()}});return Object.defineProperties(s,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(s),s}function V(n){const s=v({data:Array.from(n||[]),has(e){return this.data.some(t=>t[0]===e)},set(e,t){const r=this.data.find(o=>o[0]===e);return r?r[1]=t:this.data.push([e,t]),this},get(e){var t;return(t=this.data.find(r=>r[0]===e))==null?void 0:t[1]},delete(e){const t=this.data.findIndex(r=>r[0]===e);return t===-1?!1:(this.data.splice(t,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return{}},forEach(e){this.data.forEach(t=>{e(t[1],t[0],this)})},keys(){return this.data.map(e=>e[0]).values()},values(){return this.data.map(e=>e[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(s,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(s),s}}}});

@@ -20,8 +20,8 @@ System.register(['proxy-compare'], (function (exports) {

const VERSION = Symbol();
const LISTENERS = Symbol();
const SNAPSHOT = Symbol();
const HANDLER = Symbol();
const PROMISE_RESULT = Symbol();
const PROMISE_ERROR = Symbol();
const VERSION = Symbol("VERSION") ;
const LISTENERS = Symbol("LISTENERS") ;
const SNAPSHOT = Symbol("SNAPSHOT") ;
const HANDLER = Symbol("HANDLER") ;
const PROMISE_RESULT = Symbol("PROMISE_RESULT") ;
const PROMISE_ERROR = Symbol("PROMISE_ERROR") ;
const refSet = /* @__PURE__ */ new WeakSet();

@@ -140,4 +140,5 @@ function ref(o) {

var _a;
const hasPrevValue = Reflect.has(target, prop);
const prevValue = Reflect.get(target, prop, receiver);
if (this.is(prevValue, value)) {
if (hasPrevValue && this.is(prevValue, value)) {
return true;

@@ -144,0 +145,0 @@ }

@@ -1,1 +0,1 @@

System.register(["proxy-compare"],function(H){"use strict";var k,P;return{setters:[function(p){k=p.getUntracked,P=p.markToTrack}],execute:function(){H({getHandler:z,getVersion:U,proxy:T,ref:K,snapshot:q,subscribe:V});const p=Symbol(),a=Symbol(),j=Symbol(),R=Symbol(),b=Symbol(),v=Symbol(),w=new WeakSet;function K(t){return w.add(t),t}const h=t=>typeof t=="object"&&t!==null,N=t=>h(t)&&!w.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),x=new WeakMap;let A=1;const E=new WeakMap;function T(t={}){if(!h(t))throw new Error("object required");const g=x.get(t);if(g)return g;let f=A;const y=new Set,l=(n,e=++A)=>{f!==e&&(f=e,y.forEach(r=>r(n,e)))},u=new Map,m=n=>{let e=u.get(n);return e||(e=(r,c)=>{const i=[...r];i[1]=[n,...i[1]],l(i,c)},u.set(n,e)),e},W=n=>{const e=u.get(n);return u.delete(n),e},B=(n,e)=>{const r=E.get(e);if((r==null?void 0:r[0])===f)return r[1];const c=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return P(c,!0),E.set(e,[f,c]),Reflect.ownKeys(n).forEach(i=>{const o=Reflect.get(n,i,e);if(w.has(o))P(o,!1),c[i]=o;else if(o instanceof Promise)if(b in o)c[i]=o[b];else{const O=o[v]||o;Object.defineProperty(c,i,{get(){if(b in o)return o[b];throw O}})}else o!=null&&o[a]?c[i]=o[j]:c[i]=o}),Object.freeze(c),c},D=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),M={get(n,e,r){return e===p?f:e===a?y:e===j?B(n,r):e===R?M:Reflect.get(n,e,r)},deleteProperty(n,e){const r=Reflect.get(n,e),c=r==null?void 0:r[a];c&&c.delete(W(e));const i=Reflect.deleteProperty(n,e);return i&&l(["delete",[e],r]),i},is:Object.is,canProxy:N,set(n,e,r,c){var i;const o=Reflect.get(n,e,c);if(this.is(o,r))return!0;const O=o==null?void 0:o[a];O&&O.delete(W(e)),h(r)&&(r=k(r)||r);let s;return(i=Object.getOwnPropertyDescriptor(n,e))!=null&&i.set?s=r:r instanceof Promise?s=r.then(d=>(s[b]=d,l(["resolve",[e],d]),d)).catch(d=>{s[v]=d,l(["reject",[e],d])}):r!=null&&r[a]?(s=r,s[a].add(m(e))):this.canProxy(r)?(s=T(r),s[a].add(m(e))):s=r,Reflect.set(n,e,s,c),l(["set",[e],r,o]),!0}},S=new Proxy(D,M);return x.set(t,S),Reflect.ownKeys(t).forEach(n=>{const e=Object.getOwnPropertyDescriptor(t,n);e.get||e.set?Object.defineProperty(D,n,e):S[n]=t[n]}),S}function U(t){return h(t)?t[p]:void 0}function V(t,g,f){let y;const l=[],u=m=>{if(l.push(m),f){g(l.splice(0));return}y||(y=Promise.resolve().then(()=>{y=void 0,g(l.splice(0))}))};return t[a].add(u),()=>{t[a].delete(u)}}function q(t){return t[j]}function z(t){return t[R]}}}});
System.register(["proxy-compare"],function(K){"use strict";var k,O;return{setters:[function(g){k=g.getUntracked,O=g.markToTrack}],execute:function(){K({getHandler:B,getVersion:V,proxy:M,ref:N,snapshot:z,subscribe:q});const g=Symbol(),a=Symbol(),j=Symbol(),R=Symbol(),d=Symbol(),v=Symbol(),w=new WeakSet;function N(t){return w.add(t),t}const P=t=>typeof t=="object"&&t!==null,U=t=>P(t)&&!w.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),x=new WeakMap;let A=1;const E=new WeakMap;function M(t={}){if(!P(t))throw new Error("object required");const h=x.get(t);if(h)return h;let l=A;const y=new Set,f=(n,e=++A)=>{l!==e&&(l=e,y.forEach(r=>r(n,e)))},u=new Map,m=n=>{let e=u.get(n);return e||(e=(r,o)=>{const c=[...r];c[1]=[n,...c[1]],f(c,o)},u.set(n,e)),e},T=n=>{const e=u.get(n);return u.delete(n),e},I=(n,e)=>{const r=E.get(e);if((r==null?void 0:r[0])===l)return r[1];const o=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return O(o,!0),E.set(e,[l,o]),Reflect.ownKeys(n).forEach(c=>{const i=Reflect.get(n,c,e);if(w.has(i))O(i,!1),o[c]=i;else if(i instanceof Promise)if(d in i)o[c]=i[d];else{const b=i[v]||i;Object.defineProperty(o,c,{get(){if(d in i)return i[d];throw b}})}else i!=null&&i[a]?o[c]=i[j]:o[c]=i}),Object.freeze(o),o},W=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),D={get(n,e,r){return e===g?l:e===a?y:e===j?I(n,r):e===R?D:Reflect.get(n,e,r)},deleteProperty(n,e){const r=Reflect.get(n,e),o=r==null?void 0:r[a];o&&o.delete(T(e));const c=Reflect.deleteProperty(n,e);return c&&f(["delete",[e],r]),c},is:Object.is,canProxy:U,set(n,e,r,o){var c;const i=Reflect.has(n,e),b=Reflect.get(n,e,o);if(i&&this.is(b,r))return!0;const H=b==null?void 0:b[a];H&&H.delete(T(e)),P(r)&&(r=k(r)||r);let s;return(c=Object.getOwnPropertyDescriptor(n,e))!=null&&c.set?s=r:r instanceof Promise?s=r.then(p=>(s[d]=p,f(["resolve",[e],p]),p)).catch(p=>{s[v]=p,f(["reject",[e],p])}):r!=null&&r[a]?(s=r,s[a].add(m(e))):this.canProxy(r)?(s=M(r),s[a].add(m(e))):s=r,Reflect.set(n,e,s,o),f(["set",[e],r,b]),!0}},S=new Proxy(W,D);return x.set(t,S),Reflect.ownKeys(t).forEach(n=>{const e=Object.getOwnPropertyDescriptor(t,n);e.get||e.set?Object.defineProperty(W,n,e):S[n]=t[n]}),S}function V(t){return P(t)?t[g]:void 0}function q(t,h,l){let y;const f=[],u=m=>{if(f.push(m),l){h(f.splice(0));return}y||(y=Promise.resolve().then(()=>{y=void 0,h(f.splice(0))}))};return t[a].add(u),()=>{t[a].delete(u)}}function z(t){return t[j]}function B(t){return t[R]}}}});

@@ -19,3 +19,3 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*
* This creates derived properties and attatches them
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.

@@ -22,0 +22,0 @@ *

@@ -10,3 +10,3 @@ /**

* - canUndo: a function to return true if undo is available
* - undo: a function to go back hisotry
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available

@@ -13,0 +13,0 @@ * - redo: a function to go forward history

@@ -19,3 +19,3 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*
* This creates derived properties and attatches them
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.

@@ -22,0 +22,0 @@ *

@@ -10,3 +10,3 @@ /**

* - canUndo: a function to return true if undo is available
* - undo: a function to go back hisotry
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available

@@ -13,0 +13,0 @@ * - redo: a function to go forward history

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('valtio/vanilla'), require('proxy-compare')) :
typeof define === 'function' && define.amd ? define(['exports', 'valtio/vanilla', 'proxy-compare'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.valtioUtils = {}, global.valtioVanilla, global.proxyCompare));
})(this, (function (exports, vanilla, proxyCompare) { 'use strict';
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));
})(this, (function (exports, vanilla) { 'use strict';

@@ -480,17 +480,6 @@ function subscribeKey(proxyObject, key, callback, notifyInSync) {

var computedValue;
var prevSnapshot;
var affected = new WeakMap();
var desc = {};
desc.get = function () {
var nextSnapshot = vanilla.snapshot(proxyObject);
if (!prevSnapshot || proxyCompare.isChanged(prevSnapshot, nextSnapshot, affected)) {
affected = new WeakMap();
computedValue = get(proxyCompare.createProxy(nextSnapshot, affected));
prevSnapshot = nextSnapshot;
}
return computedValue;
return get(vanilla.snapshot(proxyObject));
};

@@ -497,0 +486,0 @@

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("valtio/vanilla"),require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioUtils={},e.valtioVanilla,e.proxyCompare)}(this,(function(e,t,n){"use strict";var r;var i=Symbol();var a=new WeakMap,o=new WeakMap,s=function e(t,n){var r=a.get(t);r&&(r[0].forEach((function(n){var r=n.d;t!==r&&e(r)})),++r[2],n&&r[3].add(n))},u=function e(t){var n=a.get(t);n&&(--n[2],n[2]||(n[3].forEach((function(e){return e()})),n[3].clear()),n[0].forEach((function(n){var r=n.d;t!==r&&e(r)})))},c=function(e){var n=e.s,r=e.d,i=o.get(r);i||(i=[new Set],o.set(e.d,i)),i[0].add(e);var c=a.get(n);if(!c){var f=new Set,d=t.subscribe(n,(function(e){f.forEach((function(t){var r=t.d,i=t.c,a=t.n,o=t.i;n===r&&e.every((function(e){return 1===e[1].length&&o.includes(e[1][0])}))||t.p||(s(n,i),a?u(n):t.p=Promise.resolve().then((function(){delete t.p,u(n)})))}))}),!0);c=[f,d,0,new Set],a.set(n,c)}c[0].add(e)},f=function(e){var t=e.s,n=e.d,r=o.get(n);null==r||r[0].delete(e),0===(null==r?void 0:r[0].size)&&o.delete(n);var i=a.get(t);if(i){var s=i[0],u=i[1];s.delete(e),s.size||(u(),a.delete(t))}},d=function(e){var t=o.get(e);return t?Array.from(t[0]):[]},l={add:c,remove:f,list:d};function p(e,n){var r=(null==n?void 0:n.proxy)||t.proxy({}),i=!(null==n||!n.sync),o=Object.keys(e);return o.forEach((function(n){if(Object.getOwnPropertyDescriptor(r,n))throw new Error("object property already defined");var s=e[n],u=null;!function e(){if(u){if(Array.from(u).map((function(t){var n,r,i,o=t[0];return n=o,r=e,!(null==(i=a.get(n))||!i[2]||(i[3].add(r),0))})).some((function(e){return e})))return;if(Array.from(u).every((function(e){var n=e[0],r=e[1];return t.getVersion(n)===r.v})))return}var d=new Map,l=s((function(e){return d.set(e,{v:t.getVersion(e)}),e})),p=function(){var t;d.forEach((function(t,a){var s,f,d=null==(s=u)||null==(f=s.get(a))?void 0:f.s;if(d)t.s=d;else{var l={s:a,d:r,k:n,c:e,n:i,i:o};c(l),t.s=l}})),null==(t=u)||t.forEach((function(e,t){!d.has(t)&&e.s&&f(e.s)})),u=d};l instanceof Promise?l.finally(p):p(),r[n]=l}()})),r}function h(e,t){for(var n in t){(a=t[n]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,n,a)}if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(t),i=0;i<r.length;i++){var a,o=r[i];(a=t[o]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,o,a)}return e}e.addComputed=function(e,t,n){void 0===n&&(n=e),console.warn("addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive.");var r={};return Object.keys(t).forEach((function(n){r[n]=function(r){return t[n](r(e))}})),p(r,{proxy:n})},e.derive=p,e.devtools=function(e,n){"string"==typeof n&&(console.warn("[Deprecated] Please use option object instead of name string"),n={name:n});var r,a=n||{},o=a.enabled,s=a.name,u=void 0===s?"":s;try{r=null!=o&&o&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(r){var c=!1,f=r.connect({name:u}),d=t.subscribe(e,(function(n){var r=n.filter((function(e){return e[0],e[1][0]!==i})).map((function(e){return e[0]+":"+e[1].map(String).join(".")})).join(", ");if(r)if(c)c=!1;else{var a=Object.assign({},t.snapshot(e));delete a[i],f.send({type:r,updatedAt:(new Date).toLocaleString()},a)}})),l=f.subscribe((function(n){var r,a;if("ACTION"===n.type&&n.payload)try{Object.assign(e,JSON.parse(n.payload))}catch(e){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",e)}if("DISPATCH"===n.type&&n.state){var o,s;if("JUMP_TO_ACTION"===(null==(o=n.payload)?void 0:o.type)||"JUMP_TO_STATE"===(null==(s=n.payload)?void 0:s.type)){c=!0;var u=JSON.parse(n.state);Object.assign(e,u)}e[i]=n}else if("DISPATCH"===n.type&&"COMMIT"===(null==(r=n.payload)?void 0:r.type))f.init(t.snapshot(e));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(e,i),0===r?f.init(t.snapshot(e)):f.send(a,t.snapshot(e))}))}}));return f.init(t.snapshot(e)),function(){d(),null==l||l()}}},e.proxyMap=function(e){var n,r,i,a=t.proxy((r={data:Array.from(e||[]),has:function(e){return this.data.some((function(t){return t[0]===e}))},set:function(e,t){var n=this.data.find((function(t){return t[0]===e}));return n?n[1]=t:this.data.push([e,t]),this},get:function(e){var t;return null==(t=this.data.find((function(t){return t[0]===e})))?void 0:t[1]},delete:function(e){var t=this.data.findIndex((function(t){return t[0]===e}));return-1!==t&&(this.data.splice(t,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},toJSON:function(){return{}},forEach:function(e){var t=this;this.data.forEach((function(n){e(n[1],n[0],t)}))},keys:function(){return this.data.map((function(e){return e[0]})).values()},values:function(){return this.data.map((function(e){return e[1]})).values()},entries:function(){return new Map(this.data).entries()}},(i={})[n=Symbol.toStringTag]=i[n]||{},i[n].get=function(){return"Map"},r[Symbol.iterator]=function(){return this.entries()},h(r,i),r));return Object.defineProperties(a,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(a),a},e.proxySet=function(e){var n,r,i,a=t.proxy((r={data:Array.from(new Set(e)),has:function(e){return-1!==this.data.indexOf(e)},add:function(e){var n=!1;return"object"==typeof e&&null!==e&&(n=-1!==this.data.indexOf(t.proxy(e))),-1!==this.data.indexOf(e)||n||this.data.push(e),this},delete:function(e){var t=this.data.indexOf(e);return-1!==t&&(this.data.splice(t,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},forEach:function(e){var t=this;this.data.forEach((function(n){e(n,n,t)}))}},(i={})[n=Symbol.toStringTag]=i[n]||{},i[n].get=function(){return"Set"},r.toJSON=function(){return{}},r[Symbol.iterator]=function(){return this.data[Symbol.iterator]()},r.values=function(){return this.data.values()},r.keys=function(){return this.data.values()},r.entries=function(){return new Set(this.data).entries()},h(r,i),r));return Object.defineProperties(a,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(a),a},e.proxyWithComputed=function(e,r){Object.keys(r).forEach((function(a){if(Object.getOwnPropertyDescriptor(e,a))throw new Error("object property already defined");var o,s,u=r[a],c="function"==typeof u?{get:u}:u,f=c.get,d=c.set,l=new WeakMap,p={get:function(){var e=t.snapshot(i);return s&&!n.isChanged(s,e,l)||(l=new WeakMap,o=f(n.createProxy(e,l)),s=e),o}};d&&(p.set=function(e){return d(i,e)}),Object.defineProperty(e,a,p)}));var i=t.proxy(e);return i},e.proxyWithHistory=function(e,n){void 0===n&&(n=!1);var r=t.proxy({value:e,history:t.ref({wip:e,snapshots:[],index:-1}),canUndo:function(){return r.history.index>0},undo:function(){r.canUndo()&&(r.value=r.history.wip=r.history.snapshots[--r.history.index],r.history.snapshots[r.history.index]=t.snapshot(r).value)},canRedo:function(){return r.history.index<r.history.snapshots.length-1},redo:function(){r.canRedo()&&(r.value=r.history.wip=r.history.snapshots[++r.history.index],r.history.snapshots[r.history.index]=t.snapshot(r).value)},saveHistory:function(){r.history.snapshots.splice(r.history.index+1),r.history.snapshots.push(t.snapshot(r).value),++r.history.index},subscribe:function(){return t.subscribe(r,(function(e){e.every((function(e){return"value"===e[1][0]&&("set"!==e[0]||e[2]!==r.history.wip)}))&&r.saveHistory()}))}});return r.saveHistory(),n||r.subscribe(),r},e.subscribeKey=function(e,n,r,i){return t.subscribe(e,(function(t){t.some((function(e){return e[1][0]===n}))&&r(e[n])}),i)},e.underive=function(e,t){var n=null!=t&&t.delete?new Set:null;d(e).forEach((function(e){var r=e.k;null!=t&&t.keys&&!t.keys.includes(r)||(f(e),n&&n.add(r))})),n&&n.forEach((function(t){delete e[t]}))},e.unstable_deriveSubscriptions=l,e.watch=function(e,n){var i=!0,a=new Set,o=new Map,s=function(){i&&(i=!1,a.forEach((function(e){return e()})),a.clear(),o.forEach((function(e){return e()})),o.clear())};return r&&r.add(s),function s(){if(i){a.forEach((function(e){return e()})),a.clear();var u=new Set,c=r;r=a;try{var f=e((function(e){return u.add(e),e}));f&&a.add(f)}finally{r=c}o.forEach((function(e,t){u.has(t)?u.delete(t):(o.delete(t),e())})),u.forEach((function(e){var r=t.subscribe(e,s,null==n?void 0:n.sync);o.set(e,r)}))}}(),s},Object.defineProperty(e,"__esModule",{value:!0})}));
!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))},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)})))},u=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)},c=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 s=o[0],u=o[1];s.delete(t),s.size||(u(),i.delete(e))}},f=function(t){var e=a.get(t);return e?Array.from(e[0]):[]},d={add:u,remove:c,list:f};function l(t,n){var r=(null==n?void 0:n.proxy)||e.proxy({}),a=!(null==n||!n.sync),o=Object.keys(t);return o.forEach((function(n){if(Object.getOwnPropertyDescriptor(r,n))throw new Error("object property already defined");var s=t[n],f=null;!function t(){if(f){if(Array.from(f).map((function(e){var n,r,a,o=e[0];return n=o,r=t,!(null==(a=i.get(n))||!a[2]||(a[3].add(r),0))})).some((function(t){return t})))return;if(Array.from(f).every((function(t){var n=t[0],r=t[1];return e.getVersion(n)===r.v})))return}var d=new Map,l=s((function(t){return d.set(t,{v:e.getVersion(t)}),t})),p=function(){var e;d.forEach((function(e,i){var s,c,d=null==(s=f)||null==(c=s.get(i))?void 0:c.s;if(d)e.s=d;else{var l={s:i,d:r,k:n,c:t,n:a,i:o};u(l),e.s=l}})),null==(e=f)||e.forEach((function(t,e){!d.has(e)&&t.s&&c(t.s)})),f=d};l instanceof Promise?l.finally(p):p(),r[n]=l}()})),r}function p(t,e){for(var n in e){(a=e[n]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,n,a)}if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(e),i=0;i<r.length;i++){var a,o=r[i];(a=e[o]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,o,a)}return t}t.addComputed=function(t,e,n){void 0===n&&(n=t),console.warn("addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive.");var r={};return Object.keys(e).forEach((function(n){r[n]=function(r){return e[n](r(t))}})),l(r,{proxy:n})},t.derive=l,t.devtools=function(t,n){"string"==typeof n&&(console.warn("[Deprecated] Please use option object instead of name string"),n={name:n});var i,a=n||{},o=a.enabled,s=a.name,u=void 0===s?"":s;try{i=null!=o&&o&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(i){var c=!1,f=i.connect({name:u}),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,s;if("JUMP_TO_ACTION"===(null==(o=n.payload)?void 0:o.type)||"JUMP_TO_STATE"===(null==(s=n.payload)?void 0:s.type)){c=!0;var u=JSON.parse(n.state);Object.assign(t,u)}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,i,a=e.proxy((r={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{}},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()}},(i={})[n=Symbol.toStringTag]=i[n]||{},i[n].get=function(){return"Map"},r[Symbol.iterator]=function(){return this.entries()},p(r,i),r));return Object.defineProperties(a,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(a),a},t.proxySet=function(t){var n,r,i,a=e.proxy((r={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)}))}},(i={})[n=Symbol.toStringTag]=i[n]||{},i[n].get=function(){return"Set"},r.toJSON=function(){return{}},r[Symbol.iterator]=function(){return this.data[Symbol.iterator]()},r.values=function(){return this.data.values()},r.keys=function(){return this.data.values()},r.entries=function(){return new Set(this.data).entries()},p(r,i),r));return Object.defineProperties(a,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(a),a},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,s=o.get,u=o.set,c={get:function(){return s(e.snapshot(r))}};u&&(c.set=function(t){return u(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:t,snapshots:[],index:-1}),canUndo:function(){return r.history.index>0},undo:function(){r.canUndo()&&(r.value=r.history.wip=r.history.snapshots[--r.history.index],r.history.snapshots[r.history.index]=e.snapshot(r).value)},canRedo:function(){return r.history.index<r.history.snapshots.length-1},redo:function(){r.canRedo()&&(r.value=r.history.wip=r.history.snapshots[++r.history.index],r.history.snapshots[r.history.index]=e.snapshot(r).value)},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){return e.subscribe(t,(function(e){e.some((function(t){return t[1][0]===n}))&&r(t[n])}),i)},t.underive=function(t,e){var n=null!=e&&e.delete?new Set:null;f(t).forEach((function(t){var r=t.k;null!=e&&e.keys&&!e.keys.includes(r)||(c(t),n&&n.add(r))})),n&&n.forEach((function(e){delete t[e]}))},t.unstable_deriveSubscriptions=d,t.watch=function(t,r){var i=!0,a=new Set,o=new Map,s=function(){i&&(i=!1,a.forEach((function(t){return t()})),a.clear(),o.forEach((function(t){return t()})),o.clear())};return n&&n.add(s),function s(){if(i){a.forEach((function(t){return t()})),a.clear();var u=new Set,c=n;n=a;try{var f=t((function(t){return u.add(t),t}));f&&a.add(f)}finally{n=c}o.forEach((function(t,e){u.has(e)?u.delete(e):(o.delete(e),t())})),u.forEach((function(t){var n=e.subscribe(t,s,null==r?void 0:r.sync);o.set(t,n)}))}}(),s},Object.defineProperty(t,"__esModule",{value:!0})}));

@@ -7,8 +7,8 @@ (function (global, factory) {

var VERSION = Symbol();
var LISTENERS = Symbol();
var SNAPSHOT = Symbol();
var HANDLER = Symbol();
var PROMISE_RESULT = Symbol();
var PROMISE_ERROR = Symbol();
var VERSION = Symbol('VERSION') ;
var LISTENERS = Symbol('LISTENERS') ;
var SNAPSHOT = Symbol('SNAPSHOT') ;
var HANDLER = Symbol('HANDLER') ;
var PROMISE_RESULT = Symbol('PROMISE_RESULT') ;
var PROMISE_ERROR = Symbol('PROMISE_ERROR') ;
var refSet = new WeakSet();

@@ -169,5 +169,6 @@ function ref(o) {

var hasPrevValue = Reflect.has(target, prop);
var prevValue = Reflect.get(target, prop, receiver);
if (this.is(prevValue, value)) {
if (hasPrevValue && this.is(prevValue, value)) {
return true;

@@ -174,0 +175,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 r=Symbol(),n=Symbol(),o=Symbol(),i=Symbol(),c=Symbol(),a=Symbol(),f=new WeakSet;var u=function(e){return"object"==typeof e&&null!==e},s=function(e){return u(e)&&!f.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)},l=new WeakMap,d=1,y=new WeakMap;e.getHandler=function(e){return e[i]},e.getVersion=function(e){return u(e)?e[r]:void 0},e.proxy=function e(p){if(void 0===p&&(p={}),!u(p))throw new Error("object required");var v=l.get(p);if(v)return v;var b=d,g=new Set,m=function(e,t){void 0===t&&(t=++d),b!==t&&(b=t,g.forEach((function(r){return r(e,t)})))},h=new Map,j=function(e){var t=h.get(e);return t||(t=function(t,r){var n=[].concat(t);n[1]=[e].concat(n[1]),m(n,r)},h.set(e,t)),t},O=function(e){var t=h.get(e);return h.delete(e),t},P=Array.isArray(p)?[]:Object.create(Object.getPrototypeOf(p)),w={get:function(e,u,s){return u===r?b:u===n?g:u===o?function(e,r){var i=y.get(r);if((null==i?void 0:i[0])===b)return i[1];var u=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(u,!0),y.set(r,[b,u]),Reflect.ownKeys(e).forEach((function(i){var s=Reflect.get(e,i,r);if(f.has(s))t.markToTrack(s,!1),u[i]=s;else if(s instanceof Promise)if(c in s)u[i]=s[c];else{var l=s[a]||s;Object.defineProperty(u,i,{get:function(){if(c in s)return s[c];throw l}})}else null!=s&&s[n]?u[i]=s[o]:u[i]=s})),Object.freeze(u),u}(e,s):u===i?w:Reflect.get(e,u,s)},deleteProperty:function(e,t){var r=Reflect.get(e,t),o=null==r?void 0:r[n];o&&o.delete(O(t));var i=Reflect.deleteProperty(e,t);return i&&m(["delete",[t],r]),i},is:Object.is,canProxy:s,set:function(r,o,i,f){var s,l,d=Reflect.get(r,o,f);if(this.is(d,i))return!0;var y,p=null==d?void 0:d[n];return p&&p.delete(O(o)),u(i)&&(i=t.getUntracked(i)||i),null!=(s=Object.getOwnPropertyDescriptor(r,o))&&s.set?y=i:i instanceof Promise?y=i.then((function(e){return y[c]=e,m(["resolve",[o],e]),e})).catch((function(e){y[a]=e,m(["reject",[o],e])})):null!=(l=i)&&l[n]?(y=i)[n].add(j(o)):this.canProxy(i)?(y=e(i))[n].add(j(o)):y=i,Reflect.set(r,o,y,f),m(["set",[o],i,d]),!0}},x=new Proxy(P,w);return l.set(p,x),Reflect.ownKeys(p).forEach((function(e){var t=Object.getOwnPropertyDescriptor(p,e);t.get||t.set?Object.defineProperty(P,e,t):x[e]=p[e]})),x},e.ref=function(e){return f.add(e),e},e.snapshot=function(e){return e[o]},e.subscribe=function(e,t,r){var o,i=[],c=function(e){i.push(e),r?t(i.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,t(i.splice(0))})))};return e[n].add(c),function(){e[n].delete(c)}},Object.defineProperty(e,"__esModule",{value:!0})}));
!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 r=Symbol(),n=Symbol(),o=Symbol(),i=Symbol(),c=Symbol(),a=Symbol(),f=new WeakSet;var u=function(e){return"object"==typeof e&&null!==e},s=function(e){return u(e)&&!f.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)},l=new WeakMap,d=1,y=new WeakMap;e.getHandler=function(e){return e[i]},e.getVersion=function(e){return u(e)?e[r]:void 0},e.proxy=function e(p){if(void 0===p&&(p={}),!u(p))throw new Error("object required");var v=l.get(p);if(v)return v;var b=d,g=new Set,h=function(e,t){void 0===t&&(t=++d),b!==t&&(b=t,g.forEach((function(r){return r(e,t)})))},m=new Map,j=function(e){var t=m.get(e);return t||(t=function(t,r){var n=[].concat(t);n[1]=[e].concat(n[1]),h(n,r)},m.set(e,t)),t},O=function(e){var t=m.get(e);return m.delete(e),t},P=Array.isArray(p)?[]:Object.create(Object.getPrototypeOf(p)),w={get:function(e,u,s){return u===r?b:u===n?g:u===o?function(e,r){var i=y.get(r);if((null==i?void 0:i[0])===b)return i[1];var u=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(u,!0),y.set(r,[b,u]),Reflect.ownKeys(e).forEach((function(i){var s=Reflect.get(e,i,r);if(f.has(s))t.markToTrack(s,!1),u[i]=s;else if(s instanceof Promise)if(c in s)u[i]=s[c];else{var l=s[a]||s;Object.defineProperty(u,i,{get:function(){if(c in s)return s[c];throw l}})}else null!=s&&s[n]?u[i]=s[o]:u[i]=s})),Object.freeze(u),u}(e,s):u===i?w:Reflect.get(e,u,s)},deleteProperty:function(e,t){var r=Reflect.get(e,t),o=null==r?void 0:r[n];o&&o.delete(O(t));var i=Reflect.deleteProperty(e,t);return i&&h(["delete",[t],r]),i},is:Object.is,canProxy:s,set:function(r,o,i,f){var s,l,d=Reflect.has(r,o),y=Reflect.get(r,o,f);if(d&&this.is(y,i))return!0;var p,v=null==y?void 0:y[n];return v&&v.delete(O(o)),u(i)&&(i=t.getUntracked(i)||i),null!=(s=Object.getOwnPropertyDescriptor(r,o))&&s.set?p=i:i instanceof Promise?p=i.then((function(e){return p[c]=e,h(["resolve",[o],e]),e})).catch((function(e){p[a]=e,h(["reject",[o],e])})):null!=(l=i)&&l[n]?(p=i)[n].add(j(o)):this.canProxy(i)?(p=e(i))[n].add(j(o)):p=i,Reflect.set(r,o,p,f),h(["set",[o],i,y]),!0}},x=new Proxy(P,w);return l.set(p,x),Reflect.ownKeys(p).forEach((function(e){var t=Object.getOwnPropertyDescriptor(p,e);t.get||t.set?Object.defineProperty(P,e,t):x[e]=p[e]})),x},e.ref=function(e){return f.add(e),e},e.snapshot=function(e){return e[o]},e.subscribe=function(e,t,r){var o,i=[],c=function(e){i.push(e),r?t(i.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,t(i.splice(0))})))};return e[n].add(c),function(){e[n].delete(c)}},Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -6,3 +6,2 @@ 'use strict';

var vanilla = require('valtio/vanilla');
var proxyCompare = require('proxy-compare');

@@ -482,17 +481,6 @@ function subscribeKey(proxyObject, key, callback, notifyInSync) {

var computedValue;
var prevSnapshot;
var affected = new WeakMap();
var desc = {};
desc.get = function () {
var nextSnapshot = vanilla.snapshot(proxyObject);
if (!prevSnapshot || proxyCompare.isChanged(prevSnapshot, nextSnapshot, affected)) {
affected = new WeakMap();
computedValue = get(proxyCompare.createProxy(nextSnapshot, affected));
prevSnapshot = nextSnapshot;
}
return computedValue;
return get(vanilla.snapshot(proxyObject));
};

@@ -499,0 +487,0 @@

@@ -19,3 +19,3 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*
* This creates derived properties and attatches them
* This creates derived properties and attaches them
* to a new proxy object or an existing proxy object.

@@ -22,0 +22,0 @@ *

@@ -10,3 +10,3 @@ /**

* - canUndo: a function to return true if undo is available
* - undo: a function to go back hisotry
* - undo: a function to go back history
* - canRedo: a function to return true if redo is available

@@ -13,0 +13,0 @@ * - redo: a function to go forward history

@@ -7,8 +7,8 @@ 'use strict';

var VERSION = Symbol();
var LISTENERS = Symbol();
var SNAPSHOT = Symbol();
var HANDLER = Symbol();
var PROMISE_RESULT = Symbol();
var PROMISE_ERROR = Symbol();
var VERSION = process.env.NODE_ENV !== "production" ? Symbol('VERSION') : Symbol();
var LISTENERS = process.env.NODE_ENV !== "production" ? Symbol('LISTENERS') : Symbol();
var SNAPSHOT = process.env.NODE_ENV !== "production" ? Symbol('SNAPSHOT') : Symbol();
var HANDLER = process.env.NODE_ENV !== "production" ? Symbol('HANDLER') : Symbol();
var PROMISE_RESULT = process.env.NODE_ENV !== "production" ? Symbol('PROMISE_RESULT') : Symbol();
var PROMISE_ERROR = process.env.NODE_ENV !== "production" ? Symbol('PROMISE_ERROR') : Symbol();
var refSet = new WeakSet();

@@ -169,5 +169,6 @@ function ref(o) {

var hasPrevValue = Reflect.has(target, prop);
var prevValue = Reflect.get(target, prop, receiver);
if (this.is(prevValue, value)) {
if (hasPrevValue && this.is(prevValue, value)) {
return true;

@@ -174,0 +175,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc