Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

valtio

Package Overview
Dependencies
Maintainers
2
Versions
112
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.11.1 to 1.11.2

6

esm/vanilla/utils/devtools.d.ts

@@ -1,6 +0,8 @@

type EnhancerOptions = Parameters<NonNullable<(typeof window)['__REDUX_DEVTOOLS_EXTENSION__']>['connect']>[0];
type Config = Parameters<(Window extends {
__REDUX_DEVTOOLS_EXTENSION__?: infer T;
} ? T : any)['connect']>[0];
type Options = {
enabled?: boolean;
name?: string;
} & EnhancerOptions;
} & Config;
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;

@@ -7,0 +9,0 @@ /**

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

@@ -71,5 +71,9 @@ "main": "./index.js",

"peerDependencies": {
"@types/react": ">=16.8",
"react": ">=16.8"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"react": {

@@ -76,0 +80,0 @@ "optional": true

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

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

@@ -1,6 +0,8 @@

type EnhancerOptions = Parameters<NonNullable<(typeof window)['__REDUX_DEVTOOLS_EXTENSION__']>['connect']>[0];
type Config = Parameters<(Window extends {
__REDUX_DEVTOOLS_EXTENSION__?: infer T;
} ? T : any)['connect']>[0];
type Options = {
enabled?: boolean;
name?: string;
} & EnhancerOptions;
} & Config;
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;

@@ -7,0 +9,0 @@ /**

@@ -1,6 +0,8 @@

type EnhancerOptions = Parameters<NonNullable<(typeof window)['__REDUX_DEVTOOLS_EXTENSION__']>['connect']>[0];
type Config = Parameters<(Window extends {
__REDUX_DEVTOOLS_EXTENSION__?: infer T;
} ? T : any)['connect']>[0];
type Options = {
enabled?: boolean;
name?: string;
} & EnhancerOptions;
} & Config;
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;

@@ -7,0 +9,0 @@ /**

@@ -1,6 +0,8 @@

type EnhancerOptions = Parameters<NonNullable<(typeof window)['__REDUX_DEVTOOLS_EXTENSION__']>['connect']>[0];
type Config = Parameters<(Window extends {
__REDUX_DEVTOOLS_EXTENSION__?: infer T;
} ? T : any)['connect']>[0];
type Options = {
enabled?: boolean;
name?: string;
} & EnhancerOptions;
} & Config;
export declare function devtools<T extends object>(proxyObject: T, options?: Options): (() => void) | undefined;

@@ -7,0 +9,0 @@ /**

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