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.10.0 to 1.10.1

36

esm/vanilla.js

@@ -24,20 +24,22 @@ import { markToTrack, getUntracked } from 'proxy-compare';

Reflect.ownKeys(target).forEach((key) => {
if (Object.getOwnPropertyDescriptor(snap, key)) {
return;
}
const value = Reflect.get(target, key);
const desc = {
value,
enumerable: true
};
if (refSet.has(value)) {
markToTrack(value, false);
snap[key] = value;
} else if (value instanceof Promise) {
Object.defineProperty(snap, key, {
get() {
return handlePromise(value);
}
});
delete desc.value;
desc.get = () => handlePromise(value);
} else if (proxyStateMap.has(value)) {
snap[key] = snapshot(value, handlePromise);
} else {
snap[key] = value;
desc.value = snapshot(value, handlePromise);
}
Object.defineProperty(snap, key, desc);
});
return Object.freeze(snap);
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => {
return snap;
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = function proxyFunction3(initialObject) {
if (!isObject(initialObject)) {

@@ -132,3 +134,2 @@ throw new Error("object required");

set(target, prop, value, receiver) {
var _a;
const hasPrevValue = Reflect.has(target, prop);

@@ -144,3 +145,3 @@ const prevValue = Reflect.get(target, prop, receiver);

let nextValue = value;
if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) ; else if (value instanceof Promise) {
if (value instanceof Promise) {
value.then((v) => {

@@ -157,3 +158,3 @@ value.status = "fulfilled";

if (!proxyStateMap.has(value) && canProxy(value)) {
nextValue = proxy(value);
nextValue = proxyFunction3(value);
}

@@ -184,5 +185,6 @@ const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);

);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
const hasValue = "value" in desc;
delete desc.value;
Object.defineProperty(baseObject, key, desc);
if (hasValue) {
proxyObject[key] = initialObject[key];

@@ -189,0 +191,0 @@ }

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

@@ -21,2 +21,3 @@ "main": "./index.js",

".": {
"types": "./index.d.ts",
"import": {

@@ -26,3 +27,2 @@ "types": "./esm/index.d.mts",

},
"types": "./index.d.ts",
"module": "./esm/index.js",

@@ -32,2 +32,3 @@ "default": "./index.js"

"./*": {
"types": "./*.d.ts",
"import": {

@@ -37,3 +38,2 @@ "types": "./esm/*.d.mts",

},
"types": "./*.d.ts",
"module": "./esm/*.js",

@@ -71,3 +71,3 @@ "default": "./*.js"

"dependencies": {
"proxy-compare": "2.4.0",
"proxy-compare": "2.4.1",
"use-sync-external-store": "1.2.0"

@@ -74,0 +74,0 @@ },

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

Reflect.ownKeys(target).forEach((key) => {
if (Object.getOwnPropertyDescriptor(snap, key)) {
return;
}
const value = Reflect.get(target, key);
const desc = {
value,
enumerable: true
};
if (refSet.has(value)) {
markToTrack(value, false);
snap[key] = value;
} else if (value instanceof Promise) {
Object.defineProperty(snap, key, {
get() {
return handlePromise(value);
}
});
delete desc.value;
desc.get = () => handlePromise(value);
} else if (proxyStateMap.has(value)) {
snap[key] = snapshot(value, handlePromise);
} else {
snap[key] = value;
desc.value = snapshot(value, handlePromise);
}
Object.defineProperty(snap, key, desc);
});
return Object.freeze(snap);
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => {
return snap;
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = function proxyFunction3(initialObject) {
if (!isObject(initialObject)) {

@@ -148,3 +150,2 @@ throw new Error("object required");

set(target, prop, value, receiver) {
var _a;
const hasPrevValue = Reflect.has(target, prop);

@@ -160,3 +161,3 @@ const prevValue = Reflect.get(target, prop, receiver);

let nextValue = value;
if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) ; else if (value instanceof Promise) {
if (value instanceof Promise) {
value.then((v) => {

@@ -173,3 +174,3 @@ value.status = "fulfilled";

if (!proxyStateMap.has(value) && canProxy(value)) {
nextValue = proxy(value);
nextValue = proxyFunction3(value);
}

@@ -200,5 +201,6 @@ const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);

);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
const hasValue = "value" in desc;
delete desc.value;
Object.defineProperty(baseObject, key, desc);
if (hasValue) {
proxyObject[key] = initialObject[key];

@@ -205,0 +207,0 @@ }

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

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

@@ -54,19 +54,23 @@ (function (global, factory) {

Reflect.ownKeys(target).forEach(function (key) {
if (Object.getOwnPropertyDescriptor(snap, key)) {
return;
}
var value = Reflect.get(target, key);
var desc = {
value: value,
enumerable: true
};
if (refSet.has(value)) {
proxyCompare.markToTrack(value, false);
snap[key] = value;
} else if (value instanceof Promise) {
Object.defineProperty(snap, key, {
get: function get() {
return handlePromise(value);
}
});
delete desc.value;
desc.get = function () {
return handlePromise(value);
};
} else if (proxyStateMap.has(value)) {
snap[key] = snapshot(value, handlePromise);
} else {
snap[key] = value;
desc.value = snapshot(value, handlePromise);
}
Object.defineProperty(snap, key, desc);
});
return Object.freeze(snap);
return snap;
};

@@ -186,3 +190,2 @@ }

set: function set(target, prop, value, receiver) {
var _Object$getOwnPropert;
var hasPrevValue = Reflect.has(target, prop);

@@ -198,3 +201,3 @@ var prevValue = Reflect.get(target, prop, receiver);

var nextValue = value;
if ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(target, prop)) != null && _Object$getOwnPropert.set) ; else if (value instanceof Promise) {
if (value instanceof Promise) {
value.then(function (v) {

@@ -211,3 +214,3 @@ value.status = 'fulfilled';

if (!proxyStateMap.has(value) && canProxy(value)) {
nextValue = proxy(value);
nextValue = proxyFunction(value);
}

@@ -230,5 +233,6 @@ var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);

var desc = Object.getOwnPropertyDescriptor(initialObject, key);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
var hasValue = ('value' in desc);
delete desc.value;
Object.defineProperty(baseObject, key, desc);
if (hasValue) {
proxyObject[key] = initialObject[key];

@@ -235,0 +239,0 @@ }

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.proxyCompare)}(this,(function(e,t){"use strict";var r=function(e){return"object"==typeof e&&null!==e},n=new WeakMap,o=new WeakSet,i=function(e,i,c,u,s,l,v,d,p){return void 0===e&&(e=Object.is),void 0===i&&(i=function(e,t){return new Proxy(e,t)}),void 0===c&&(c=function(e){return r(e)&&!o.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)}),void 0===u&&(u=function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),void 0===s&&(s=new WeakMap),void 0===l&&(l=function(e,r,i){void 0===i&&(i=u);var c=s.get(e);if((null==c?void 0:c[0])===r)return c[1];var a=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(a,!0),s.set(e,[r,a]),Reflect.ownKeys(e).forEach((function(r){var c=Reflect.get(e,r);o.has(c)?(t.markToTrack(c,!1),a[r]=c):c instanceof Promise?Object.defineProperty(a,r,{get:function(){return i(c)}}):n.has(c)?a[r]=f(c,i):a[r]=c})),Object.freeze(a)}),void 0===v&&(v=new WeakMap),void 0===d&&(d=[1,1]),void 0===p&&(p=function(f){if(!r(f))throw new Error("object required");var u=v.get(f);if(u)return u;var s=d[0],p=new Set,y=function(e,t){void 0===t&&(t=++d[0]),s!==t&&(s=t,p.forEach((function(r){return r(e,t)})))},h=d[1],g=function(e){return function(t,r){var n=[].concat(t);n[1]=[e].concat(n[1]),y(n,r)}},b=new Map,j=function(e){var t,r=b.get(e);r&&(b.delete(e),null==(t=r[1])||t.call(r))},w=Array.isArray(f)?[]:Object.create(Object.getPrototypeOf(f)),O=i(w,{deleteProperty:function(e,t){var r=Reflect.get(e,t);j(t);var n=Reflect.deleteProperty(e,t);return n&&y(["delete",[t],r]),n},set:function(i,f,u,s){var l,d=Reflect.has(i,f),h=Reflect.get(i,f,s);if(d&&(e(h,u)||v.has(u)&&e(h,v.get(u))))return!0;j(f),r(u)&&(u=t.getUntracked(u)||u);var w=u;if(null!=(l=Object.getOwnPropertyDescriptor(i,f))&&l.set);else if(u instanceof Promise)u.then((function(e){u.status="fulfilled",u.value=e,y(["resolve",[f],e])})).catch((function(e){u.status="rejected",u.reason=e,y(["reject",[f],e])}));else{!n.has(u)&&c(u)&&(w=a(u));var O=!o.has(w)&&n.get(w);O&&function(e,t){if(p.size){var r=t[3](g(e));b.set(e,[t,r])}else b.set(e,[t])}(f,O)}return Reflect.set(i,f,w,s),y(["set",[f],u,h]),!0}});v.set(f,O);var P=[w,function(e){return void 0===e&&(e=++d[1]),h===e||p.size||(h=e,b.forEach((function(t){var r=t[0][1](e);r>s&&(s=r)}))),s},l,function(e){p.add(e),1===p.size&&b.forEach((function(e,t){var r=e[0];e[1];var n=r[3](g(t));b.set(t,[r,n])}));return function(){p.delete(e),0===p.size&&b.forEach((function(e,t){var r=e[0],n=e[1];n&&(n(),b.set(t,[r]))}))}}];return n.set(O,P),Reflect.ownKeys(f).forEach((function(e){var t=Object.getOwnPropertyDescriptor(f,e);t.get||t.set?Object.defineProperty(w,e,t):O[e]=f[e]})),O}),[p,n,o,e,i,c,u,s,l,v,d]},c=i()[0];function a(e){return void 0===e&&(e={}),c(e)}function f(e,t){var r=n.get(e),o=r[0],i=r[1];return(0,r[2])(o,i(),t)}var u=i;e.getVersion=function(e){var t=n.get(e);return null==t?void 0:t[1]()},e.proxy=a,e.ref=function(e){return o.add(e),e},e.snapshot=f,e.subscribe=function(e,t,r){var o,i=n.get(e),c=[],a=i[3],f=!1,u=a((function(e){c.push(e),r?t(c.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,f&&t(c.splice(0))})))}));return f=!0,function(){f=!1,u()}},e.unstable_buildProxyFunction=u}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtio={},e.proxyCompare)}(this,(function(e,t){"use strict";var r=function(e){return"object"==typeof e&&null!==e},n=new WeakMap,o=new WeakSet,i=function(e,i,a,f,u,s,l,v,d){return void 0===e&&(e=Object.is),void 0===i&&(i=function(e,t){return new Proxy(e,t)}),void 0===a&&(a=function(e){return r(e)&&!o.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)}),void 0===f&&(f=function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),void 0===u&&(u=new WeakMap),void 0===s&&(s=function(e,r,i){void 0===i&&(i=f);var a=u.get(e);if((null==a?void 0:a[0])===r)return a[1];var s=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(s,!0),u.set(e,[r,s]),Reflect.ownKeys(e).forEach((function(r){if(!Object.getOwnPropertyDescriptor(s,r)){var a=Reflect.get(e,r),f={value:a,enumerable:!0};o.has(a)?t.markToTrack(a,!1):a instanceof Promise?(delete f.value,f.get=function(){return i(a)}):n.has(a)&&(f.value=c(a,i)),Object.defineProperty(s,r,f)}})),s}),void 0===l&&(l=new WeakMap),void 0===v&&(v=[1,1]),void 0===d&&(d=function c(f){if(!r(f))throw new Error("object required");var u=l.get(f);if(u)return u;var d=v[0],p=new Set,y=function(e,t){void 0===t&&(t=++v[0]),d!==t&&(d=t,p.forEach((function(r){return r(e,t)})))},h=v[1],g=function(e){return function(t,r){var n=[].concat(t);n[1]=[e].concat(n[1]),y(n,r)}},b=new Map,w=function(e){var t,r=b.get(e);r&&(b.delete(e),null==(t=r[1])||t.call(r))},j=Array.isArray(f)?[]:Object.create(Object.getPrototypeOf(f)),m=i(j,{deleteProperty:function(e,t){var r=Reflect.get(e,t);w(t);var n=Reflect.deleteProperty(e,t);return n&&y(["delete",[t],r]),n},set:function(i,f,u,s){var v=Reflect.has(i,f),d=Reflect.get(i,f,s);if(v&&(e(d,u)||l.has(u)&&e(d,l.get(u))))return!0;w(f),r(u)&&(u=t.getUntracked(u)||u);var h=u;if(u instanceof Promise)u.then((function(e){u.status="fulfilled",u.value=e,y(["resolve",[f],e])})).catch((function(e){u.status="rejected",u.reason=e,y(["reject",[f],e])}));else{!n.has(u)&&a(u)&&(h=c(u));var j=!o.has(h)&&n.get(h);j&&function(e,t){if(p.size){var r=t[3](g(e));b.set(e,[t,r])}else b.set(e,[t])}(f,j)}return Reflect.set(i,f,h,s),y(["set",[f],u,d]),!0}});l.set(f,m);var O=[j,function(e){return void 0===e&&(e=++v[1]),h===e||p.size||(h=e,b.forEach((function(t){var r=t[0][1](e);r>d&&(d=r)}))),d},s,function(e){p.add(e),1===p.size&&b.forEach((function(e,t){var r=e[0];e[1];var n=r[3](g(t));b.set(t,[r,n])}));return function(){p.delete(e),0===p.size&&b.forEach((function(e,t){var r=e[0],n=e[1];n&&(n(),b.set(t,[r]))}))}}];return n.set(m,O),Reflect.ownKeys(f).forEach((function(e){var t=Object.getOwnPropertyDescriptor(f,e),r="value"in t;delete t.value,Object.defineProperty(j,e,t),r&&(m[e]=f[e])})),m}),[d,n,o,e,i,a,f,u,s,l,v]},a=i()[0];function c(e,t){var r=n.get(e),o=r[0],i=r[1];return(0,r[2])(o,i(),t)}var f=i;e.getVersion=function(e){var t=n.get(e);return null==t?void 0:t[1]()},e.proxy=function(e){return void 0===e&&(e={}),a(e)},e.ref=function(e){return o.add(e),e},e.snapshot=c,e.subscribe=function(e,t,r){var o,i=n.get(e),a=[],c=i[3],f=!1,u=c((function(e){a.push(e),r?t(a.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,f&&t(a.splice(0))})))}));return f=!0,function(){f=!1,u()}},e.unstable_buildProxyFunction=f}));

@@ -52,19 +52,23 @@ 'use strict';

Reflect.ownKeys(target).forEach(function (key) {
if (Object.getOwnPropertyDescriptor(snap, key)) {
return;
}
var value = Reflect.get(target, key);
var desc = {
value: value,
enumerable: true
};
if (refSet.has(value)) {
proxyCompare.markToTrack(value, false);
snap[key] = value;
} else if (value instanceof Promise) {
Object.defineProperty(snap, key, {
get: function get() {
return handlePromise(value);
}
});
delete desc.value;
desc.get = function () {
return handlePromise(value);
};
} else if (proxyStateMap.has(value)) {
snap[key] = snapshot(value, handlePromise);
} else {
snap[key] = value;
desc.value = snapshot(value, handlePromise);
}
Object.defineProperty(snap, key, desc);
});
return Object.freeze(snap);
return snap;
};

@@ -184,3 +188,2 @@ }

set: function set(target, prop, value, receiver) {
var _Object$getOwnPropert;
var hasPrevValue = Reflect.has(target, prop);

@@ -196,3 +199,3 @@ var prevValue = Reflect.get(target, prop, receiver);

var nextValue = value;
if ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(target, prop)) != null && _Object$getOwnPropert.set) ; else if (value instanceof Promise) {
if (value instanceof Promise) {
value.then(function (v) {

@@ -209,3 +212,3 @@ value.status = 'fulfilled';

if (!proxyStateMap.has(value) && canProxy(value)) {
nextValue = proxy(value);
nextValue = proxyFunction(value);
}

@@ -228,5 +231,6 @@ var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);

var desc = Object.getOwnPropertyDescriptor(initialObject, key);
if (desc.get || desc.set) {
Object.defineProperty(baseObject, key, desc);
} else {
var hasValue = ('value' in desc);
delete desc.value;
Object.defineProperty(baseObject, key, desc);
if (hasValue) {
proxyObject[key] = initialObject[key];

@@ -233,0 +237,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