@storix-js/sync 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +402 -326
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var at=Symbol.for("preact-signals");function W(){if(k>1)k--;else{for(var e,t=!1;D!==void 0;){var o=D;for(D=void 0,B++;o!==void 0;){var l=o.o;if(o.o=void 0,o.f&=-3,!(8&o.f)&&nt(o))try{o.c()}catch(x){t||(e=x,t=!0)}o=l}}if(B=0,k--,t)throw e}}function Z(e){if(k>0)return e();k++;try{return e()}finally{W()}}var u=void 0;function tt(e){var t=u;u=void 0;try{return e()}finally{u=t}}var D=void 0,k=0,B=0,J=0;function et(e){if(u!==void 0){var t=e.n;if(t===void 0||t.t!==u)return t={i:0,S:e,p:u.s,n:void 0,t:u,e:void 0,x:void 0,r:t},u.s!==void 0&&(u.s.n=t),u.s=t,e.n=t,32&u.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=u.s,t.n=void 0,u.s.n=t,u.s=t),t}}function m(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}m.prototype.brand=at;m.prototype.h=function(){return!0};m.prototype.S=function(e){var t=this,o=this.t;o!==e&&e.e===void 0&&(e.x=o,this.t=e,o!==void 0?o.e=e:tt(function(){var l;(l=t.W)==null||l.call(t)}))};m.prototype.U=function(e){var t=this;if(this.t!==void 0){var o=e.e,l=e.x;o!==void 0&&(o.x=l,e.e=void 0),l!==void 0&&(l.e=o,e.x=void 0),e===this.t&&(this.t=l,l===void 0&&tt(function(){var x;(x=t.Z)==null||x.call(t)}))}};m.prototype.subscribe=function(e){var t=this;return ut(function(){var o=t.value,l=u;u=void 0;try{e(o)}finally{u=l}},{name:"sub"})};m.prototype.valueOf=function(){return this.value};m.prototype.toString=function(){return this.value+""};m.prototype.toJSON=function(){return this.value};m.prototype.peek=function(){var e=u;u=void 0;try{return this.value}finally{u=e}};Object.defineProperty(m.prototype,"value",{get:function(){var e=et(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(B>100)throw new Error("Cycle detected");this.v=e,this.i++,J++,k++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{W()}}}});function ft(e,t){return new m(e,t)}function nt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function it(e){for(var t=e.s;t!==void 0;t=t.n){var o=t.S.n;if(o!==void 0&&(t.r=o),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ot(e){for(var t=e.s,o=void 0;t!==void 0;){var l=t.p;t.i===-1?(t.S.U(t),l!==void 0&&(l.n=t.n),t.n!==void 0&&(t.n.p=l)):o=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=l}e.s=o}function R(e,t){m.call(this,void 0),this.x=e,this.s=void 0,this.g=J-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}R.prototype=new m;R.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===J))return!0;if(this.g=J,this.f|=1,this.i>0&&!nt(this))return this.f&=-2,!0;var e=u;try{it(this),u=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(o){this.v=o,this.f|=16,this.i++}return u=e,ot(this),this.f&=-2,!0};R.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}m.prototype.S.call(this,e)};R.prototype.U=function(e){if(this.t!==void 0&&(m.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};R.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(R.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=et(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Y(e,t){return new R(e,t)}function st(e){var t=e.u;if(e.u=void 0,typeof t=="function"){k++;var o=u;u=void 0;try{t()}catch(l){throw e.f&=-2,e.f|=8,K(e),l}finally{u=o,W()}}}function K(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,st(e)}function ct(e){if(u!==this)throw new Error("Out-of-order effect");ot(this),u=e,this.f&=-2,8&this.f&&K(this),W()}function C(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t==null?void 0:t.name}C.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};C.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,st(this),it(this),k++;var e=u;return u=this,ct.bind(this,e)};C.prototype.N=function(){2&this.f||(this.f|=2,this.o=D,D=this)};C.prototype.d=function(){this.f|=8,1&this.f||K(this)};C.prototype.dispose=function(){this.d()};function ut(e,t){var o=new C(e,t);try{o.c()}catch(x){throw o.d(),x}var l=o.d.bind(o);return l[Symbol.dispose]=l,l}function lt(e={}){const t=(e.namespace??"default").trim()||"default",o=e.plugins??[],l=new Map;function x(S,j){return function(){var _;const N=`${t}:${S}`,E=l.get(S);if(E)return E;const U=j.state(),I=j.modules??{},H={...U};for(const[i,n]of Object.entries(I))H[i]=n.state();const h=ft(H),y=new Map,A=new Map,L=new Map,M=new Map,b=new Map,T=new Set,d=new Set(Object.keys(U)),a=new Set(Object.keys(j.getters??{})),p=new Set(Object.keys(j.actions??{})),w=i=>h.value[i]??{},q=(i,n)=>{h.value={...h.value,[i]:n}},rt=new Proxy({},{get(i,n){var r,f;if(y.has(n))return(r=y.get(n))==null?void 0:r.value;if(b.has(n))return(f=b.get(n))==null?void 0:f.value;if(d.has(n))return h.value[n];const v=M.get(n);return v?w(v.moduleName)[v.key]:h.value[n]}});for(const[i,n]of Object.entries(j.getters??{}))y.set(i,Y(()=>n(h.value,rt)));const F=(i,n)=>{var r;for(const f of T)f(i);for(const f of o)(r=f.onMutation)==null||r.call(f,n,i)},G=(i,n,r,f)=>{const v=h.value[i];Object.is(v,n)||(h.value={...h.value,[i]:n},F({namespace:t,scopeId:N,storeId:S,key:i,oldValue:v,newValue:n,origin:r},f))},z=(i,n,r,f,v)=>{const g=w(i),s=g[n];Object.is(s,r)||(q(i,{...g,[n]:r}),F({namespace:t,scopeId:N,storeId:S,key:`${i}.${n}`,oldValue:s,newValue:r,origin:f},v))},P={$id:S,$namespace:t,$scopeId:N,$subscribe(i){return T.add(i),()=>T.delete(i)},$dispose(){var i;T.clear();for(const n of o)(i=n.onDispose)==null||i.call(n,$);l.delete(S)},$patch(i,n="local"){Z(()=>{for(const[r,f]of Object.entries(i)){const v=M.get(r);if(v){z(v.moduleName,v.key,f,n,$);continue}if(r.includes(".")){const[g,s]=r.split(".",2);if(I[g]){z(g,s,f,n,$);continue}}if(I[r]&&f&&typeof f=="object"&&!Array.isArray(f)){for(const[g,s]of Object.entries(f))z(r,g,s,n,$);continue}G(r,f,n,$)}})},$snapshot(){return{...h.value}}};for(const[i,n]of Object.entries(I)){const r=new Map,f=new Map,v=new Proxy({},{get(s,c){var O,V,Q;if(r.has(c))return(O=r.get(c))==null?void 0:O.value;if(y.has(c))return(V=y.get(c))==null?void 0:V.value;if(b.has(c))return(Q=b.get(c))==null?void 0:Q.value;const X=w(i);if(c in X)return X[c];if(d.has(c))return h.value[c]}});for(const[s,c]of Object.entries(n.getters??{}))r.set(s,Y(()=>c(w(i),h.value,v)));let g;for(const[s,c]of Object.entries(n.actions??{}))f.set(s,(...O)=>Z(()=>c.apply(g,O)));g=new Proxy({},{get(s,c){var O;if(f.has(c))return f.get(c);if(r.has(c))return(O=r.get(c))==null?void 0:O.value;const V=w(i);return c in V?V[c]:$[c]},set(s,c,O){if(f.has(c)||r.has(c))return!1;const V=w(i);return c in V?z(i,c,O,"local",$):$[c]=O,!0}}),L.set(i,g),A.set(i,r);for(const s of Object.keys(w(i)))!(d.has(s)||a.has(s)||p.has(s)||Reflect.has(P,s)||I[s]!==void 0)&&!M.has(s)&&M.set(s,{moduleName:i,key:s});for(const[s,c]of r.entries())!(d.has(s)||a.has(s)||p.has(s)||Reflect.has(P,s)||I[s]!==void 0)&&!b.has(s)&&b.set(s,c);for(const[s,c]of f.entries())!(d.has(s)||a.has(s)||p.has(s)||Reflect.has(P,s)||I[s]!==void 0)&&!Reflect.has(P,s)&&(P[s]=c)}const $=new Proxy(P,{get(i,n,r){var f,v;if(Reflect.has(i,n))return Reflect.get(i,n,r);if(L.has(n))return L.get(n);if(y.has(n))return(f=y.get(n))==null?void 0:f.value;if(b.has(n))return(v=b.get(n))==null?void 0:v.value;if(d.has(n))return h.value[n];const g=M.get(n);return g?w(g.moduleName)[g.key]:h.value[n]},set(i,n,r,f){if(Reflect.has(i,n))return Reflect.set(i,n,r,f);const v=M.get(n);return v?(z(v.moduleName,v.key,r,"local",f),!0):(G(n,r,"local",f),!0)}});for(const[i,n]of Object.entries(j.actions??{}))P[i]=(...r)=>Z(()=>n.apply($,r));for(const i of o)(_=i.onInit)==null||_.call(i,$);return l.set(S,$),$}}return{defineStore:x,use(S){o.push(S)}}}lt();function dt(e={}){const t=e.channelName??"storix-sync",o=new Set(e.include??[]),l=new Set(e.exclude??[]),x=e.namespaces??[],S=x==="*"?null:new Set(x),j=e.debounce??16,_=crypto.randomUUID(),N=`__storix_sync__:${t}`,E=new Map,U=new Set,I=new Map,H=new Map;let h=null;const y=typeof window<"u"&&"BroadcastChannel"in window?new BroadcastChannel(t):null,A=d=>{const a=[d.$id,d.$scopeId];return!(a.some(p=>l.has(p))||o.size>0&&!a.some(p=>o.has(p)))},L=(d,a)=>a===d||S===null?!0:S.has(a),M=(d,a)=>{!a||a.originTabId===_||L(d.$namespace,a.namespace)&&a.storeId===d.$id&&A(d)&&d.$patch({[a.key]:a.newValue},"remote")},b=()=>{if(h=null,E.size===0)return;const d=Array.from(E.values());E.clear();for(const a of d){const p={...a,originTabId:_};if(y&&y.postMessage(p),typeof window<"u"&&"localStorage"in window)try{window.localStorage.setItem(N,JSON.stringify(p)),window.localStorage.removeItem(N)}catch{}}},T=d=>{if(E.set(`${d.scopeId}:${d.key}`,d),j<=0){b();return}h||(h=setTimeout(b,j))};return{name:"sync",onInit(d){const a=d;if(A(a)){if(U.add(a.$scopeId),y){const p=w=>{M(a,w.data)};I.set(a.$scopeId,p),y.addEventListener("message",p)}if(typeof window<"u"){const p=w=>{if(!(w.key!==N||!w.newValue))try{const q=JSON.parse(w.newValue);M(a,q)}catch{}};H.set(a.$scopeId,p),window.addEventListener("storage",p)}}},onMutation(d,a){a.origin!=="remote"&&A(d)&&T(a)},onDispose(d){const a=d;U.delete(a.$scopeId);const p=I.get(a.$scopeId);y&&p&&(y.removeEventListener("message",p),I.delete(a.$scopeId));const w=H.get(a.$scopeId);typeof window<"u"&&w&&(window.removeEventListener("storage",w),H.delete(a.$scopeId)),h&&(clearTimeout(h),h=null),b(),U.size===0&&(y==null||y.close())}}}exports.syncPlugin=dt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var fe=Symbol.for("preact-signals");function G(){if(H>1)H--;else{var t,e=!1;for((function(){var w=K;for(K=void 0;w!==void 0;)w.S.v===w.v&&(w.S.i=w.i),w=w.o})();Z!==void 0;){var s=Z;for(Z=void 0,B++;s!==void 0;){var l=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&ae(s))try{s.c()}catch(w){e||(t=w,e=!0)}s=l}}if(B=0,H--,e)throw t}}function L(t){if(H>0)return t();X=++ve,H++;try{return t()}finally{G()}}var p=void 0;function Y(t){var e=p;p=void 0;try{return t()}finally{p=e}}var Z=void 0,H=0,B=0,ve=0,X=0,K=void 0,F=0;function re(t){if(p!==void 0){var e=t.n;if(e===void 0||e.t!==p)return e={i:0,S:t,p:p.s,n:void 0,t:p,e:void 0,x:void 0,r:e},p.s!==void 0&&(p.s.n=e),p.s=e,t.n=e,32&p.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=p.s,e.n=void 0,p.s.n=e,p.s=e),e}}function x(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}x.prototype.brand=fe;x.prototype.h=function(){return!0};x.prototype.S=function(t){var e=this,s=this.t;s!==t&&t.e===void 0&&(t.x=s,this.t=t,s!==void 0?s.e=t:Y(function(){var l;(l=e.W)==null||l.call(e)}))};x.prototype.U=function(t){var e=this;if(this.t!==void 0){var s=t.e,l=t.x;s!==void 0&&(s.x=l,t.e=void 0),l!==void 0&&(l.e=s,t.x=void 0),t===this.t&&(this.t=l,l===void 0&&Y(function(){var w;(w=e.Z)==null||w.call(e)}))}};x.prototype.subscribe=function(t){var e=this;return he(function(){var s=e.value,l=p;p=void 0;try{t(s)}finally{p=l}},{name:"sub"})};x.prototype.valueOf=function(){return this.value};x.prototype.toString=function(){return this.value+""};x.prototype.toJSON=function(){return this.value};x.prototype.peek=function(){var t=this;return Y(function(){return t.value})};Object.defineProperty(x.prototype,"value",{get:function(){var t=re(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(B>100)throw new Error("Cycle detected");(function(s){H!==0&&B===0&&s.l!==X&&(s.l=X,K={S:s,v:s.v,i:s.i,o:K})})(this),this.v=t,this.i++,F++,H++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{G()}}}});function Q(t,e){return new x(t,e)}function ae(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function ce(t){for(var e=t.s;e!==void 0;e=e.n){var s=e.S.n;if(s!==void 0&&(e.r=s),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function ue(t){for(var e=t.s,s=void 0;e!==void 0;){var l=e.p;e.i===-1?(e.S.U(e),l!==void 0&&(l.n=e.n),e.n!==void 0&&(e.n.p=l)):s=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=l}t.s=s}function A(t,e){x.call(this,void 0),this.x=t,this.s=void 0,this.g=F-1,this.f=4,this.W=e==null?void 0:e.watched,this.Z=e==null?void 0:e.unwatched,this.name=e==null?void 0:e.name}A.prototype=new x;A.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===F))return!0;if(this.g=F,this.f|=1,this.i>0&&!ae(this))return this.f&=-2,!0;var t=p;try{ce(this),p=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return p=t,ue(this),this.f&=-2,!0};A.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}x.prototype.S.call(this,t)};A.prototype.U=function(t){if(this.t!==void 0&&(x.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};A.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(A.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=re(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function se(t,e){return new A(t,e)}function le(t){var e=t.m;if(t.m=void 0,typeof e=="function"){H++;var s=p;p=void 0;try{e()}catch(l){throw t.f&=-2,t.f|=8,ee(t),l}finally{p=s,G()}}}function ee(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,le(t)}function de(t){if(p!==this)throw new Error("Out-of-order effect");ue(this),p=t,this.f&=-2,8&this.f&&ee(this),G()}function _(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e==null?void 0:e.name}_.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};_.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,le(this),ce(this),H++;var t=p;return p=this,de.bind(this,t)};_.prototype.N=function(){2&this.f||(this.f|=2,this.u=Z,Z=this)};_.prototype.d=function(){this.f|=8,1&this.f||ee(this)};_.prototype.dispose=function(){this.d()};function he(t,e){var s=new _(t,e);try{s.c()}catch(w){throw s.d(),w}var l=s.d.bind(s);return l[Symbol.dispose]=l,l}function pe(t={}){const e=(t.namespace??"default").trim()||"default",s=t.plugins??[],l=new Map;function w(S,I){return function(){var E;const M=`${e}:${S}`,P=l.get(S);if(P)return P;const R=I.state(),g=I.modules??{},b={...R};for(const[r,o]of Object.entries(g))b[r]=o.state();const h=Q(b),j=new Map,T=new Map,U=new Map,N=new Map,m=new Map,i=new Set,n=new Set(Object.keys(R)),c=new Set(Object.keys(I.getters??{})),d=new Set(Object.keys(I.actions??{})),$=r=>h.value[r]??{},W=(r,o)=>{h.value={...h.value,[r]:o}},q=new Proxy({},{get(r,o){var u,f;if(j.has(o))return(u=j.get(o))==null?void 0:u.value;if(m.has(o))return(f=m.get(o))==null?void 0:f.value;if(n.has(o))return h.value[o];const y=N.get(o);return y?$(y.moduleName)[y.key]:h.value[o]}});for(const[r,o]of Object.entries(I.getters??{}))j.set(r,se(()=>o(h.value,q)));const te=(r,o)=>{var u;for(const f of i)f(r);for(const f of s)(u=f.onMutation)==null||u.call(f,o,r)},ne=(r,o,u,f)=>{const y=h.value[r];Object.is(y,o)||(h.value={...h.value,[r]:o},te({namespace:e,scopeId:M,storeId:S,key:r,oldValue:y,newValue:o,origin:u},f))},C=(r,o,u,f,y)=>{const O=$(r),a=O[o];Object.is(a,u)||(W(r,{...O,[o]:u}),te({namespace:e,scopeId:M,storeId:S,key:`${r}.${o}`,oldValue:a,newValue:u,origin:f},y))},D={$id:S,$namespace:e,$scopeId:M,$subscribe(r){return i.add(r),()=>i.delete(r)},$dispose(){var r;i.clear();for(const o of s)(r=o.onDispose)==null||r.call(o,k);l.delete(S)},$patch(r,o="local"){L(()=>{for(const[u,f]of Object.entries(r)){const y=N.get(u);if(y){C(y.moduleName,y.key,f,o,k);continue}if(u.includes(".")){const[O,a]=u.split(".",2);if(g[O]){C(O,a,f,o,k);continue}}if(g[u]&&f&&typeof f=="object"&&!Array.isArray(f)){for(const[O,a]of Object.entries(f))C(u,O,a,o,k);continue}ne(u,f,o,k)}})},$snapshot(){return{...h.value}}};for(const[r,o]of Object.entries(g)){const u=new Map,f=new Map,y=new Proxy({},{get(a,v){var V,z,ie;if(u.has(v))return(V=u.get(v))==null?void 0:V.value;if(j.has(v))return(z=j.get(v))==null?void 0:z.value;if(m.has(v))return(ie=m.get(v))==null?void 0:ie.value;const oe=$(r);if(v in oe)return oe[v];if(n.has(v))return h.value[v]}});for(const[a,v]of Object.entries(o.getters??{}))u.set(a,se(()=>v($(r),h.value,y)));let O;for(const[a,v]of Object.entries(o.actions??{}))f.set(a,(...V)=>L(()=>v.apply(O,V)));O=new Proxy({},{get(a,v){var V;if(f.has(v))return f.get(v);if(u.has(v))return(V=u.get(v))==null?void 0:V.value;const z=$(r);return v in z?z[v]:k[v]},set(a,v,V){if(f.has(v)||u.has(v))return!1;const z=$(r);return v in z?C(r,v,V,"local",k):k[v]=V,!0}}),U.set(r,O),T.set(r,u);for(const a of Object.keys($(r)))!(n.has(a)||c.has(a)||d.has(a)||Reflect.has(D,a)||g[a]!==void 0)&&!N.has(a)&&N.set(a,{moduleName:r,key:a});for(const[a,v]of u.entries())!(n.has(a)||c.has(a)||d.has(a)||Reflect.has(D,a)||g[a]!==void 0)&&!m.has(a)&&m.set(a,v);for(const[a,v]of f.entries())!(n.has(a)||c.has(a)||d.has(a)||Reflect.has(D,a)||g[a]!==void 0)&&!Reflect.has(D,a)&&(D[a]=v)}const k=new Proxy(D,{get(r,o,u){var f,y;if(Reflect.has(r,o))return Reflect.get(r,o,u);if(U.has(o))return U.get(o);if(j.has(o))return(f=j.get(o))==null?void 0:f.value;if(m.has(o))return(y=m.get(o))==null?void 0:y.value;if(n.has(o))return h.value[o];const O=N.get(o);return O?$(O.moduleName)[O.key]:h.value[o]},set(r,o,u,f){if(Reflect.has(r,o))return Reflect.set(r,o,u,f);const y=N.get(o);return y?(C(y.moduleName,y.key,u,"local",f),!0):(ne(o,u,"local",f),!0)}});for(const[r,o]of Object.entries(I.actions??{}))D[r]=(...u)=>L(()=>o.apply(k,u));for(const r of s)(E=r.onInit)==null||E.call(r,k);return l.set(S,k),k}}function J(S,I){return function(){var E;const M=`\0machine:${S}`,P=l.get(M);if(P)return P;const R=`${e}:${S}`,g=Q(I.initial),b=Q((I.context??(()=>({})))()),h=new Set,j=(i,n)=>{var c;for(const d of h)d(i);for(const d of s)(c=d.onMutation)==null||c.call(d,n,i)},T=(i,n,c,d)=>{const $=b.value[i];Object.is($,n)||(b.value={...b.value,[i]:n},j({namespace:e,scopeId:R,storeId:S,key:i,oldValue:$,newValue:n,origin:c},d))},U=(i,n,c)=>{const d=g.value;Object.is(d,i)||(g.value=i,j({namespace:e,scopeId:R,storeId:S,key:"$state",oldValue:d,newValue:i,origin:n},c))},N={$id:S,$namespace:e,$scopeId:R,$subscribe(i){return h.add(i),()=>h.delete(i)},$dispose(){var i;h.clear();for(const n of s)(i=n.onDispose)==null||i.call(n,m);l.delete(M)},$patch(i,n="local"){L(()=>{for(const[c,d]of Object.entries(i))c==="$state"?U(d,n,m):T(c,d,n,m)})},$snapshot(){return{$state:g.value,...b.value}},send(i,n){L(()=>{var c,d,$;const W=(c=I.actions)==null?void 0:c[i];W&&W.call(m,n);const q=($=(d=I.states[g.value])==null?void 0:d.on)==null?void 0:$[i];q!==void 0&&U(q,"local",m)})},matches(i){return g.value===i},can(i){const n=I.states[g.value];return!!(n!=null&&n.on&&i in n.on)}},m=new Proxy(N,{get(i,n,c){return n==="state"?g.value:Reflect.has(i,n)?Reflect.get(i,n,c):b.value[n]},set(i,n,c,d){return n==="state"?!1:Reflect.has(i,n)?Reflect.set(i,n,c,d):(T(n,c,"local",d),!0)}});for(const i of s)(E=i.onInit)==null||E.call(i,m);return l.set(M,m),m}}return{defineStore:w,defineMachine:J,use(S){s.push(S)}}}pe();function ye(t={}){const e=t.channelName??"storix-sync",s=new Set(t.include??[]),l=new Set(t.exclude??[]),w=t.namespaces??[],J=w==="*"?null:new Set(w),S=t.debounce??16,I=crypto.randomUUID(),E=`__storix_sync__:${e}`,M=new Map,P=new Set,R=new Map,g=new Map;let b=null;const h=typeof window<"u"&&"BroadcastChannel"in window?new BroadcastChannel(e):null,j=i=>{const n=[i.$id,i.$scopeId];return!(n.some(c=>l.has(c))||s.size>0&&!n.some(c=>s.has(c)))},T=(i,n)=>n===i||J===null?!0:J.has(n),U=(i,n)=>{!n||n.originTabId===I||T(i.$namespace,n.namespace)&&n.storeId===i.$id&&j(i)&&i.$patch({[n.key]:n.newValue},"remote")},N=()=>{if(b=null,M.size===0)return;const i=Array.from(M.values());M.clear();for(const n of i){const c={...n,originTabId:I};if(h&&h.postMessage(c),typeof window<"u"&&"localStorage"in window)try{window.localStorage.setItem(E,JSON.stringify(c)),window.localStorage.removeItem(E)}catch{}}},m=i=>{if(M.set(`${i.scopeId}:${i.key}`,i),S<=0){N();return}b||(b=setTimeout(N,S))};return{name:"sync",onInit(i){const n=i;if(j(n)){if(P.add(n.$scopeId),h){const c=d=>{U(n,d.data)};R.set(n.$scopeId,c),h.addEventListener("message",c)}if(typeof window<"u"){const c=d=>{if(!(d.key!==E||!d.newValue))try{const $=JSON.parse(d.newValue);U(n,$)}catch{}};g.set(n.$scopeId,c),window.addEventListener("storage",c)}}},onMutation(i,n){n.origin!=="remote"&&j(i)&&m(n)},onDispose(i){const n=i;P.delete(n.$scopeId);const c=R.get(n.$scopeId);h&&c&&(h.removeEventListener("message",c),R.delete(n.$scopeId));const d=g.get(n.$scopeId);typeof window<"u"&&d&&(window.removeEventListener("storage",d),g.delete(n.$scopeId)),b&&(clearTimeout(b),b=null),N(),P.size===0&&(h==null||h.close())}}}exports.syncPlugin=ye;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export interface SyncPluginOptions {
|
|
|
3
3
|
include?: string[];
|
|
4
4
|
exclude?: string[];
|
|
5
5
|
namespaces?: string[] | '*';
|
|
6
|
-
conflict?: 'last-write-wins';
|
|
7
6
|
debounce?: number;
|
|
8
7
|
}
|
|
9
8
|
export declare function syncPlugin(options?: SyncPluginOptions): import("@storix-js/core").StorePlugin;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC5B,QAAQ,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,yCA8IzD"}
|
package/dist/index.js
CHANGED
|
@@ -1,358 +1,362 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
|
|
1
|
+
var fe = Symbol.for("preact-signals");
|
|
2
|
+
function G() {
|
|
3
|
+
if (H > 1)
|
|
4
|
+
H--;
|
|
5
5
|
else {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
var t, e = !1;
|
|
7
|
+
for ((function() {
|
|
8
|
+
var w = K;
|
|
9
|
+
for (K = void 0; w !== void 0; )
|
|
10
|
+
w.S.v === w.v && (w.S.i = w.i), w = w.o;
|
|
11
|
+
})(); Z !== void 0; ) {
|
|
12
|
+
var s = Z;
|
|
13
|
+
for (Z = void 0, B++; s !== void 0; ) {
|
|
14
|
+
var l = s.u;
|
|
15
|
+
if (s.u = void 0, s.f &= -3, !(8 & s.f) && ae(s)) try {
|
|
16
|
+
s.c();
|
|
17
|
+
} catch (w) {
|
|
18
|
+
e || (t = w, e = !0);
|
|
14
19
|
}
|
|
15
|
-
|
|
20
|
+
s = l;
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
|
-
if (B = 0,
|
|
23
|
+
if (B = 0, H--, e) throw t;
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
|
-
function
|
|
22
|
-
if (
|
|
23
|
-
|
|
26
|
+
function T(t) {
|
|
27
|
+
if (H > 0) return t();
|
|
28
|
+
X = ++ve, H++;
|
|
24
29
|
try {
|
|
25
|
-
return
|
|
30
|
+
return t();
|
|
26
31
|
} finally {
|
|
27
|
-
|
|
32
|
+
G();
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
var
|
|
31
|
-
function
|
|
32
|
-
var
|
|
33
|
-
|
|
35
|
+
var p = void 0;
|
|
36
|
+
function Y(t) {
|
|
37
|
+
var e = p;
|
|
38
|
+
p = void 0;
|
|
34
39
|
try {
|
|
35
|
-
return
|
|
40
|
+
return t();
|
|
36
41
|
} finally {
|
|
37
|
-
|
|
42
|
+
p = e;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
if (
|
|
43
|
-
var
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
46
|
-
if (
|
|
47
|
-
return
|
|
45
|
+
var Z = void 0, H = 0, B = 0, ve = 0, X = 0, K = void 0, F = 0;
|
|
46
|
+
function re(t) {
|
|
47
|
+
if (p !== void 0) {
|
|
48
|
+
var e = t.n;
|
|
49
|
+
if (e === void 0 || e.t !== p)
|
|
50
|
+
return e = { i: 0, S: t, p: p.s, n: void 0, t: p, e: void 0, x: void 0, r: e }, p.s !== void 0 && (p.s.n = e), p.s = e, t.n = e, 32 & p.f && t.S(e), e;
|
|
51
|
+
if (e.i === -1)
|
|
52
|
+
return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = p.s, e.n = void 0, p.s.n = e, p.s = e), e;
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
|
-
function
|
|
51
|
-
this.v =
|
|
55
|
+
function O(t, e) {
|
|
56
|
+
this.v = t, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
O.prototype.brand = fe;
|
|
59
|
+
O.prototype.h = function() {
|
|
55
60
|
return !0;
|
|
56
61
|
};
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
62
|
+
O.prototype.S = function(t) {
|
|
63
|
+
var e = this, s = this.t;
|
|
64
|
+
s !== t && t.e === void 0 && (t.x = s, this.t = t, s !== void 0 ? s.e = t : Y(function() {
|
|
60
65
|
var l;
|
|
61
|
-
(l =
|
|
66
|
+
(l = e.W) == null || l.call(e);
|
|
62
67
|
}));
|
|
63
68
|
};
|
|
64
|
-
|
|
65
|
-
var
|
|
69
|
+
O.prototype.U = function(t) {
|
|
70
|
+
var e = this;
|
|
66
71
|
if (this.t !== void 0) {
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
var
|
|
70
|
-
(
|
|
72
|
+
var s = t.e, l = t.x;
|
|
73
|
+
s !== void 0 && (s.x = l, t.e = void 0), l !== void 0 && (l.e = s, t.x = void 0), t === this.t && (this.t = l, l === void 0 && Y(function() {
|
|
74
|
+
var w;
|
|
75
|
+
(w = e.Z) == null || w.call(e);
|
|
71
76
|
}));
|
|
72
77
|
}
|
|
73
78
|
};
|
|
74
|
-
|
|
75
|
-
var
|
|
76
|
-
return
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
+
O.prototype.subscribe = function(t) {
|
|
80
|
+
var e = this;
|
|
81
|
+
return he(function() {
|
|
82
|
+
var s = e.value, l = p;
|
|
83
|
+
p = void 0;
|
|
79
84
|
try {
|
|
80
|
-
|
|
85
|
+
t(s);
|
|
81
86
|
} finally {
|
|
82
|
-
|
|
87
|
+
p = l;
|
|
83
88
|
}
|
|
84
89
|
}, { name: "sub" });
|
|
85
90
|
};
|
|
86
|
-
|
|
91
|
+
O.prototype.valueOf = function() {
|
|
87
92
|
return this.value;
|
|
88
93
|
};
|
|
89
|
-
|
|
94
|
+
O.prototype.toString = function() {
|
|
90
95
|
return this.value + "";
|
|
91
96
|
};
|
|
92
|
-
|
|
97
|
+
O.prototype.toJSON = function() {
|
|
93
98
|
return this.value;
|
|
94
99
|
};
|
|
95
|
-
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} finally {
|
|
101
|
-
u = e;
|
|
102
|
-
}
|
|
100
|
+
O.prototype.peek = function() {
|
|
101
|
+
var t = this;
|
|
102
|
+
return Y(function() {
|
|
103
|
+
return t.value;
|
|
104
|
+
});
|
|
103
105
|
};
|
|
104
|
-
Object.defineProperty(
|
|
105
|
-
var
|
|
106
|
-
return
|
|
107
|
-
}, set: function(
|
|
108
|
-
if (
|
|
106
|
+
Object.defineProperty(O.prototype, "value", { get: function() {
|
|
107
|
+
var t = re(this);
|
|
108
|
+
return t !== void 0 && (t.i = this.i), this.v;
|
|
109
|
+
}, set: function(t) {
|
|
110
|
+
if (t !== this.v) {
|
|
109
111
|
if (B > 100) throw new Error("Cycle detected");
|
|
110
|
-
|
|
112
|
+
(function(s) {
|
|
113
|
+
H !== 0 && B === 0 && s.l !== X && (s.l = X, K = { S: s, v: s.v, i: s.i, o: K });
|
|
114
|
+
})(this), this.v = t, this.i++, F++, H++;
|
|
111
115
|
try {
|
|
112
|
-
for (var
|
|
116
|
+
for (var e = this.t; e !== void 0; e = e.x) e.t.N();
|
|
113
117
|
} finally {
|
|
114
|
-
|
|
118
|
+
G();
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
} });
|
|
118
|
-
function
|
|
119
|
-
return new
|
|
122
|
+
function Q(t, e) {
|
|
123
|
+
return new O(t, e);
|
|
120
124
|
}
|
|
121
|
-
function
|
|
122
|
-
for (var
|
|
125
|
+
function ae(t) {
|
|
126
|
+
for (var e = t.s; e !== void 0; e = e.n) if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i) return !0;
|
|
123
127
|
return !1;
|
|
124
128
|
}
|
|
125
|
-
function
|
|
126
|
-
for (var
|
|
127
|
-
var
|
|
128
|
-
if (
|
|
129
|
-
|
|
129
|
+
function ce(t) {
|
|
130
|
+
for (var e = t.s; e !== void 0; e = e.n) {
|
|
131
|
+
var s = e.S.n;
|
|
132
|
+
if (s !== void 0 && (e.r = s), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
133
|
+
t.s = e;
|
|
130
134
|
break;
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
|
-
function
|
|
135
|
-
for (var
|
|
136
|
-
var l =
|
|
137
|
-
|
|
138
|
+
function ue(t) {
|
|
139
|
+
for (var e = t.s, s = void 0; e !== void 0; ) {
|
|
140
|
+
var l = e.p;
|
|
141
|
+
e.i === -1 ? (e.S.U(e), l !== void 0 && (l.n = e.n), e.n !== void 0 && (e.n.p = l)) : s = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = l;
|
|
138
142
|
}
|
|
139
|
-
|
|
143
|
+
t.s = s;
|
|
140
144
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
145
|
+
function A(t, e) {
|
|
146
|
+
O.call(this, void 0), this.x = t, this.s = void 0, this.g = F - 1, this.f = 4, this.W = e == null ? void 0 : e.watched, this.Z = e == null ? void 0 : e.unwatched, this.name = e == null ? void 0 : e.name;
|
|
143
147
|
}
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
A.prototype = new O();
|
|
149
|
+
A.prototype.h = function() {
|
|
146
150
|
if (this.f &= -3, 1 & this.f) return !1;
|
|
147
|
-
if ((36 & this.f) == 32 || (this.f &= -5, this.g ===
|
|
148
|
-
if (this.g =
|
|
151
|
+
if ((36 & this.f) == 32 || (this.f &= -5, this.g === F)) return !0;
|
|
152
|
+
if (this.g = F, this.f |= 1, this.i > 0 && !ae(this))
|
|
149
153
|
return this.f &= -2, !0;
|
|
150
|
-
var
|
|
154
|
+
var t = p;
|
|
151
155
|
try {
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
(16 & this.f || this.v !==
|
|
155
|
-
} catch (
|
|
156
|
-
this.v =
|
|
156
|
+
ce(this), p = this;
|
|
157
|
+
var e = this.x();
|
|
158
|
+
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
159
|
+
} catch (s) {
|
|
160
|
+
this.v = s, this.f |= 16, this.i++;
|
|
157
161
|
}
|
|
158
|
-
return
|
|
162
|
+
return p = t, ue(this), this.f &= -2, !0;
|
|
159
163
|
};
|
|
160
|
-
|
|
164
|
+
A.prototype.S = function(t) {
|
|
161
165
|
if (this.t === void 0) {
|
|
162
166
|
this.f |= 36;
|
|
163
|
-
for (var
|
|
167
|
+
for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
|
|
164
168
|
}
|
|
165
|
-
|
|
169
|
+
O.prototype.S.call(this, t);
|
|
166
170
|
};
|
|
167
|
-
|
|
168
|
-
if (this.t !== void 0 && (
|
|
171
|
+
A.prototype.U = function(t) {
|
|
172
|
+
if (this.t !== void 0 && (O.prototype.U.call(this, t), this.t === void 0)) {
|
|
169
173
|
this.f &= -33;
|
|
170
|
-
for (var
|
|
174
|
+
for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
|
|
171
175
|
}
|
|
172
176
|
};
|
|
173
|
-
|
|
177
|
+
A.prototype.N = function() {
|
|
174
178
|
if (!(2 & this.f)) {
|
|
175
179
|
this.f |= 6;
|
|
176
|
-
for (var
|
|
180
|
+
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
|
|
177
181
|
}
|
|
178
182
|
};
|
|
179
|
-
Object.defineProperty(
|
|
183
|
+
Object.defineProperty(A.prototype, "value", { get: function() {
|
|
180
184
|
if (1 & this.f) throw new Error("Cycle detected");
|
|
181
|
-
var
|
|
182
|
-
if (this.h(),
|
|
185
|
+
var t = re(this);
|
|
186
|
+
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
|
|
183
187
|
return this.v;
|
|
184
188
|
} });
|
|
185
|
-
function
|
|
186
|
-
return new
|
|
189
|
+
function se(t, e) {
|
|
190
|
+
return new A(t, e);
|
|
187
191
|
}
|
|
188
|
-
function
|
|
189
|
-
var
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
var
|
|
193
|
-
|
|
192
|
+
function le(t) {
|
|
193
|
+
var e = t.m;
|
|
194
|
+
if (t.m = void 0, typeof e == "function") {
|
|
195
|
+
H++;
|
|
196
|
+
var s = p;
|
|
197
|
+
p = void 0;
|
|
194
198
|
try {
|
|
195
|
-
|
|
199
|
+
e();
|
|
196
200
|
} catch (l) {
|
|
197
|
-
throw
|
|
201
|
+
throw t.f &= -2, t.f |= 8, ee(t), l;
|
|
198
202
|
} finally {
|
|
199
|
-
|
|
203
|
+
p = s, G();
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
|
-
function
|
|
204
|
-
for (var
|
|
205
|
-
|
|
207
|
+
function ee(t) {
|
|
208
|
+
for (var e = t.s; e !== void 0; e = e.n) e.S.U(e);
|
|
209
|
+
t.x = void 0, t.s = void 0, le(t);
|
|
206
210
|
}
|
|
207
|
-
function
|
|
208
|
-
if (
|
|
209
|
-
|
|
211
|
+
function de(t) {
|
|
212
|
+
if (p !== this) throw new Error("Out-of-order effect");
|
|
213
|
+
ue(this), p = t, this.f &= -2, 8 & this.f && ee(this), G();
|
|
210
214
|
}
|
|
211
|
-
function
|
|
212
|
-
this.x =
|
|
215
|
+
function C(t, e) {
|
|
216
|
+
this.x = t, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = e == null ? void 0 : e.name;
|
|
213
217
|
}
|
|
214
|
-
|
|
215
|
-
var
|
|
218
|
+
C.prototype.c = function() {
|
|
219
|
+
var t = this.S();
|
|
216
220
|
try {
|
|
217
221
|
if (8 & this.f || this.x === void 0) return;
|
|
218
|
-
var
|
|
219
|
-
typeof
|
|
222
|
+
var e = this.x();
|
|
223
|
+
typeof e == "function" && (this.m = e);
|
|
220
224
|
} finally {
|
|
221
|
-
|
|
225
|
+
t();
|
|
222
226
|
}
|
|
223
227
|
};
|
|
224
|
-
|
|
228
|
+
C.prototype.S = function() {
|
|
225
229
|
if (1 & this.f) throw new Error("Cycle detected");
|
|
226
|
-
this.f |= 1, this.f &= -9,
|
|
227
|
-
var
|
|
228
|
-
return
|
|
230
|
+
this.f |= 1, this.f &= -9, le(this), ce(this), H++;
|
|
231
|
+
var t = p;
|
|
232
|
+
return p = this, de.bind(this, t);
|
|
229
233
|
};
|
|
230
|
-
|
|
231
|
-
2 & this.f || (this.f |= 2, this.
|
|
234
|
+
C.prototype.N = function() {
|
|
235
|
+
2 & this.f || (this.f |= 2, this.u = Z, Z = this);
|
|
232
236
|
};
|
|
233
|
-
|
|
234
|
-
this.f |= 8, 1 & this.f ||
|
|
237
|
+
C.prototype.d = function() {
|
|
238
|
+
this.f |= 8, 1 & this.f || ee(this);
|
|
235
239
|
};
|
|
236
|
-
|
|
240
|
+
C.prototype.dispose = function() {
|
|
237
241
|
this.d();
|
|
238
242
|
};
|
|
239
|
-
function
|
|
240
|
-
var
|
|
243
|
+
function he(t, e) {
|
|
244
|
+
var s = new C(t, e);
|
|
241
245
|
try {
|
|
242
|
-
|
|
243
|
-
} catch (
|
|
244
|
-
throw
|
|
246
|
+
s.c();
|
|
247
|
+
} catch (w) {
|
|
248
|
+
throw s.d(), w;
|
|
245
249
|
}
|
|
246
|
-
var l =
|
|
250
|
+
var l = s.d.bind(s);
|
|
247
251
|
return l[Symbol.dispose] = l, l;
|
|
248
252
|
}
|
|
249
|
-
function
|
|
250
|
-
const
|
|
251
|
-
function
|
|
253
|
+
function pe(t = {}) {
|
|
254
|
+
const e = (t.namespace ?? "default").trim() || "default", s = t.plugins ?? [], l = /* @__PURE__ */ new Map();
|
|
255
|
+
function w(S, I) {
|
|
252
256
|
return function() {
|
|
253
|
-
var
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
const
|
|
257
|
-
for (const [
|
|
258
|
-
|
|
259
|
-
const h =
|
|
257
|
+
var E;
|
|
258
|
+
const M = `${e}:${S}`, U = l.get(S);
|
|
259
|
+
if (U) return U;
|
|
260
|
+
const R = I.state(), m = I.modules ?? {}, b = { ...R };
|
|
261
|
+
for (const [r, i] of Object.entries(m))
|
|
262
|
+
b[r] = i.state();
|
|
263
|
+
const h = Q(b), j = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), n = new Set(Object.keys(R)), c = new Set(Object.keys(I.getters ?? {})), d = new Set(Object.keys(I.actions ?? {})), $ = (r) => h.value[r] ?? {}, W = (r, i) => {
|
|
260
264
|
h.value = {
|
|
261
265
|
...h.value,
|
|
262
|
-
[
|
|
266
|
+
[r]: i
|
|
263
267
|
};
|
|
264
|
-
},
|
|
268
|
+
}, q = new Proxy(
|
|
265
269
|
{},
|
|
266
270
|
{
|
|
267
|
-
get(
|
|
268
|
-
var
|
|
269
|
-
if (
|
|
270
|
-
if (
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
return
|
|
271
|
+
get(r, i) {
|
|
272
|
+
var u, f;
|
|
273
|
+
if (j.has(i)) return (u = j.get(i)) == null ? void 0 : u.value;
|
|
274
|
+
if (g.has(i)) return (f = g.get(i)) == null ? void 0 : f.value;
|
|
275
|
+
if (n.has(i)) return h.value[i];
|
|
276
|
+
const y = N.get(i);
|
|
277
|
+
return y ? $(y.moduleName)[y.key] : h.value[i];
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
280
|
);
|
|
277
|
-
for (const [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
+
for (const [r, i] of Object.entries(I.getters ?? {}))
|
|
282
|
+
j.set(
|
|
283
|
+
r,
|
|
284
|
+
se(() => i(h.value, q))
|
|
281
285
|
);
|
|
282
|
-
const
|
|
283
|
-
var
|
|
284
|
-
for (const f of
|
|
285
|
-
for (const f of
|
|
286
|
-
(
|
|
287
|
-
},
|
|
288
|
-
const
|
|
289
|
-
Object.is(
|
|
286
|
+
const te = (r, i) => {
|
|
287
|
+
var u;
|
|
288
|
+
for (const f of o) f(r);
|
|
289
|
+
for (const f of s)
|
|
290
|
+
(u = f.onMutation) == null || u.call(f, i, r);
|
|
291
|
+
}, ne = (r, i, u, f) => {
|
|
292
|
+
const y = h.value[r];
|
|
293
|
+
Object.is(y, i) || (h.value = {
|
|
290
294
|
...h.value,
|
|
291
|
-
[
|
|
292
|
-
},
|
|
295
|
+
[r]: i
|
|
296
|
+
}, te(
|
|
293
297
|
{
|
|
294
|
-
namespace:
|
|
295
|
-
scopeId:
|
|
298
|
+
namespace: e,
|
|
299
|
+
scopeId: M,
|
|
296
300
|
storeId: S,
|
|
297
|
-
key:
|
|
298
|
-
oldValue:
|
|
299
|
-
newValue:
|
|
300
|
-
origin:
|
|
301
|
+
key: r,
|
|
302
|
+
oldValue: y,
|
|
303
|
+
newValue: i,
|
|
304
|
+
origin: u
|
|
301
305
|
},
|
|
302
306
|
f
|
|
303
307
|
));
|
|
304
|
-
},
|
|
305
|
-
const
|
|
306
|
-
Object.is(
|
|
307
|
-
...
|
|
308
|
-
[
|
|
309
|
-
}),
|
|
308
|
+
}, L = (r, i, u, f, y) => {
|
|
309
|
+
const x = $(r), a = x[i];
|
|
310
|
+
Object.is(a, u) || (W(r, {
|
|
311
|
+
...x,
|
|
312
|
+
[i]: u
|
|
313
|
+
}), te(
|
|
310
314
|
{
|
|
311
|
-
namespace:
|
|
312
|
-
scopeId:
|
|
315
|
+
namespace: e,
|
|
316
|
+
scopeId: M,
|
|
313
317
|
storeId: S,
|
|
314
|
-
key: `${
|
|
315
|
-
oldValue:
|
|
316
|
-
newValue:
|
|
318
|
+
key: `${r}.${i}`,
|
|
319
|
+
oldValue: a,
|
|
320
|
+
newValue: u,
|
|
317
321
|
origin: f
|
|
318
322
|
},
|
|
319
|
-
|
|
323
|
+
y
|
|
320
324
|
));
|
|
321
|
-
},
|
|
325
|
+
}, D = {
|
|
322
326
|
$id: S,
|
|
323
|
-
$namespace:
|
|
324
|
-
$scopeId:
|
|
325
|
-
$subscribe(
|
|
326
|
-
return
|
|
327
|
+
$namespace: e,
|
|
328
|
+
$scopeId: M,
|
|
329
|
+
$subscribe(r) {
|
|
330
|
+
return o.add(r), () => o.delete(r);
|
|
327
331
|
},
|
|
328
332
|
$dispose() {
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
for (const
|
|
332
|
-
(
|
|
333
|
+
var r;
|
|
334
|
+
o.clear();
|
|
335
|
+
for (const i of s)
|
|
336
|
+
(r = i.onDispose) == null || r.call(i, k);
|
|
333
337
|
l.delete(S);
|
|
334
338
|
},
|
|
335
|
-
$patch(
|
|
336
|
-
|
|
337
|
-
for (const [
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
|
|
339
|
+
$patch(r, i = "local") {
|
|
340
|
+
T(() => {
|
|
341
|
+
for (const [u, f] of Object.entries(r)) {
|
|
342
|
+
const y = N.get(u);
|
|
343
|
+
if (y) {
|
|
344
|
+
L(y.moduleName, y.key, f, i, k);
|
|
341
345
|
continue;
|
|
342
346
|
}
|
|
343
|
-
if (
|
|
344
|
-
const [
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
+
if (u.includes(".")) {
|
|
348
|
+
const [x, a] = u.split(".", 2);
|
|
349
|
+
if (m[x]) {
|
|
350
|
+
L(x, a, f, i, k);
|
|
347
351
|
continue;
|
|
348
352
|
}
|
|
349
353
|
}
|
|
350
|
-
if (
|
|
351
|
-
for (const [
|
|
352
|
-
|
|
354
|
+
if (m[u] && f && typeof f == "object" && !Array.isArray(f)) {
|
|
355
|
+
for (const [x, a] of Object.entries(f))
|
|
356
|
+
L(u, x, a, i, k);
|
|
353
357
|
continue;
|
|
354
358
|
}
|
|
355
|
-
|
|
359
|
+
ne(u, f, i, k);
|
|
356
360
|
}
|
|
357
361
|
});
|
|
358
362
|
},
|
|
@@ -360,153 +364,225 @@ function lt(e = {}) {
|
|
|
360
364
|
return { ...h.value };
|
|
361
365
|
}
|
|
362
366
|
};
|
|
363
|
-
for (const [
|
|
364
|
-
const
|
|
367
|
+
for (const [r, i] of Object.entries(m)) {
|
|
368
|
+
const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), y = new Proxy(
|
|
365
369
|
{},
|
|
366
370
|
{
|
|
367
|
-
get(
|
|
368
|
-
var
|
|
369
|
-
if (
|
|
370
|
-
if (
|
|
371
|
-
if (
|
|
372
|
-
const
|
|
373
|
-
if (
|
|
374
|
-
if (
|
|
371
|
+
get(a, v) {
|
|
372
|
+
var V, z, oe;
|
|
373
|
+
if (u.has(v)) return (V = u.get(v)) == null ? void 0 : V.value;
|
|
374
|
+
if (j.has(v)) return (z = j.get(v)) == null ? void 0 : z.value;
|
|
375
|
+
if (g.has(v)) return (oe = g.get(v)) == null ? void 0 : oe.value;
|
|
376
|
+
const ie = $(r);
|
|
377
|
+
if (v in ie) return ie[v];
|
|
378
|
+
if (n.has(v)) return h.value[v];
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
381
|
);
|
|
378
|
-
for (const [
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
+
for (const [a, v] of Object.entries(i.getters ?? {}))
|
|
383
|
+
u.set(
|
|
384
|
+
a,
|
|
385
|
+
se(() => v($(r), h.value, y))
|
|
382
386
|
);
|
|
383
|
-
let
|
|
384
|
-
for (const [
|
|
385
|
-
f.set(
|
|
386
|
-
|
|
387
|
+
let x;
|
|
388
|
+
for (const [a, v] of Object.entries(i.actions ?? {}))
|
|
389
|
+
f.set(a, (...V) => T(() => v.apply(x, V)));
|
|
390
|
+
x = new Proxy(
|
|
387
391
|
{},
|
|
388
392
|
{
|
|
389
|
-
get(
|
|
390
|
-
var
|
|
391
|
-
if (f.has(
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
return
|
|
393
|
+
get(a, v) {
|
|
394
|
+
var V;
|
|
395
|
+
if (f.has(v)) return f.get(v);
|
|
396
|
+
if (u.has(v)) return (V = u.get(v)) == null ? void 0 : V.value;
|
|
397
|
+
const z = $(r);
|
|
398
|
+
return v in z ? z[v] : k[v];
|
|
395
399
|
},
|
|
396
|
-
set(
|
|
397
|
-
if (f.has(
|
|
398
|
-
const
|
|
399
|
-
return
|
|
400
|
+
set(a, v, V) {
|
|
401
|
+
if (f.has(v) || u.has(v)) return !1;
|
|
402
|
+
const z = $(r);
|
|
403
|
+
return v in z ? L(r, v, V, "local", k) : k[v] = V, !0;
|
|
400
404
|
}
|
|
401
405
|
}
|
|
402
|
-
),
|
|
403
|
-
for (const
|
|
404
|
-
!(
|
|
405
|
-
for (const [
|
|
406
|
-
!(
|
|
407
|
-
for (const [
|
|
408
|
-
!(
|
|
406
|
+
), P.set(r, x), _.set(r, u);
|
|
407
|
+
for (const a of Object.keys($(r)))
|
|
408
|
+
!(n.has(a) || c.has(a) || d.has(a) || Reflect.has(D, a) || m[a] !== void 0) && !N.has(a) && N.set(a, { moduleName: r, key: a });
|
|
409
|
+
for (const [a, v] of u.entries())
|
|
410
|
+
!(n.has(a) || c.has(a) || d.has(a) || Reflect.has(D, a) || m[a] !== void 0) && !g.has(a) && g.set(a, v);
|
|
411
|
+
for (const [a, v] of f.entries())
|
|
412
|
+
!(n.has(a) || c.has(a) || d.has(a) || Reflect.has(D, a) || m[a] !== void 0) && !Reflect.has(D, a) && (D[a] = v);
|
|
409
413
|
}
|
|
410
|
-
const
|
|
411
|
-
get(
|
|
412
|
-
var f,
|
|
413
|
-
if (Reflect.has(
|
|
414
|
-
if (
|
|
415
|
-
if (
|
|
416
|
-
if (
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
419
|
-
return
|
|
414
|
+
const k = new Proxy(D, {
|
|
415
|
+
get(r, i, u) {
|
|
416
|
+
var f, y;
|
|
417
|
+
if (Reflect.has(r, i)) return Reflect.get(r, i, u);
|
|
418
|
+
if (P.has(i)) return P.get(i);
|
|
419
|
+
if (j.has(i)) return (f = j.get(i)) == null ? void 0 : f.value;
|
|
420
|
+
if (g.has(i)) return (y = g.get(i)) == null ? void 0 : y.value;
|
|
421
|
+
if (n.has(i)) return h.value[i];
|
|
422
|
+
const x = N.get(i);
|
|
423
|
+
return x ? $(x.moduleName)[x.key] : h.value[i];
|
|
424
|
+
},
|
|
425
|
+
set(r, i, u, f) {
|
|
426
|
+
if (Reflect.has(r, i))
|
|
427
|
+
return Reflect.set(r, i, u, f);
|
|
428
|
+
const y = N.get(i);
|
|
429
|
+
return y ? (L(y.moduleName, y.key, u, "local", f), !0) : (ne(i, u, "local", f), !0);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
for (const [r, i] of Object.entries(I.actions ?? {}))
|
|
433
|
+
D[r] = (...u) => T(() => i.apply(k, u));
|
|
434
|
+
for (const r of s)
|
|
435
|
+
(E = r.onInit) == null || E.call(r, k);
|
|
436
|
+
return l.set(S, k), k;
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function J(S, I) {
|
|
440
|
+
return function() {
|
|
441
|
+
var E;
|
|
442
|
+
const M = `\0machine:${S}`, U = l.get(M);
|
|
443
|
+
if (U) return U;
|
|
444
|
+
const R = `${e}:${S}`, m = Q(I.initial), b = Q((I.context ?? (() => ({})))()), h = /* @__PURE__ */ new Set(), j = (o, n) => {
|
|
445
|
+
var c;
|
|
446
|
+
for (const d of h) d(o);
|
|
447
|
+
for (const d of s)
|
|
448
|
+
(c = d.onMutation) == null || c.call(d, n, o);
|
|
449
|
+
}, _ = (o, n, c, d) => {
|
|
450
|
+
const $ = b.value[o];
|
|
451
|
+
Object.is($, n) || (b.value = { ...b.value, [o]: n }, j({ namespace: e, scopeId: R, storeId: S, key: o, oldValue: $, newValue: n, origin: c }, d));
|
|
452
|
+
}, P = (o, n, c) => {
|
|
453
|
+
const d = m.value;
|
|
454
|
+
Object.is(d, o) || (m.value = o, j(
|
|
455
|
+
{ namespace: e, scopeId: R, storeId: S, key: "$state", oldValue: d, newValue: o, origin: n },
|
|
456
|
+
c
|
|
457
|
+
));
|
|
458
|
+
}, N = {
|
|
459
|
+
$id: S,
|
|
460
|
+
$namespace: e,
|
|
461
|
+
$scopeId: R,
|
|
462
|
+
$subscribe(o) {
|
|
463
|
+
return h.add(o), () => h.delete(o);
|
|
464
|
+
},
|
|
465
|
+
$dispose() {
|
|
466
|
+
var o;
|
|
467
|
+
h.clear();
|
|
468
|
+
for (const n of s)
|
|
469
|
+
(o = n.onDispose) == null || o.call(n, g);
|
|
470
|
+
l.delete(M);
|
|
471
|
+
},
|
|
472
|
+
$patch(o, n = "local") {
|
|
473
|
+
T(() => {
|
|
474
|
+
for (const [c, d] of Object.entries(o))
|
|
475
|
+
c === "$state" ? P(d, n, g) : _(c, d, n, g);
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
$snapshot() {
|
|
479
|
+
return { $state: m.value, ...b.value };
|
|
480
|
+
},
|
|
481
|
+
send(o, n) {
|
|
482
|
+
T(() => {
|
|
483
|
+
var c, d, $;
|
|
484
|
+
const W = (c = I.actions) == null ? void 0 : c[o];
|
|
485
|
+
W && W.call(g, n);
|
|
486
|
+
const q = ($ = (d = I.states[m.value]) == null ? void 0 : d.on) == null ? void 0 : $[o];
|
|
487
|
+
q !== void 0 && P(q, "local", g);
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
matches(o) {
|
|
491
|
+
return m.value === o;
|
|
492
|
+
},
|
|
493
|
+
can(o) {
|
|
494
|
+
const n = I.states[m.value];
|
|
495
|
+
return !!(n != null && n.on && o in n.on);
|
|
496
|
+
}
|
|
497
|
+
}, g = new Proxy(N, {
|
|
498
|
+
get(o, n, c) {
|
|
499
|
+
return n === "state" ? m.value : Reflect.has(o, n) ? Reflect.get(o, n, c) : b.value[n];
|
|
420
500
|
},
|
|
421
|
-
set(
|
|
422
|
-
|
|
423
|
-
return Reflect.set(i, n, r, f);
|
|
424
|
-
const v = k.get(n);
|
|
425
|
-
return v ? (z(v.moduleName, v.key, r, "local", f), !0) : (G(n, r, "local", f), !0);
|
|
501
|
+
set(o, n, c, d) {
|
|
502
|
+
return n === "state" ? !1 : Reflect.has(o, n) ? Reflect.set(o, n, c, d) : (_(n, c, "local", d), !0);
|
|
426
503
|
}
|
|
427
504
|
});
|
|
428
|
-
for (const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
(_ = i.onInit) == null || _.call(i, $);
|
|
432
|
-
return l.set(S, $), $;
|
|
505
|
+
for (const o of s)
|
|
506
|
+
(E = o.onInit) == null || E.call(o, g);
|
|
507
|
+
return l.set(M, g), g;
|
|
433
508
|
};
|
|
434
509
|
}
|
|
435
510
|
return {
|
|
436
|
-
defineStore:
|
|
511
|
+
defineStore: w,
|
|
512
|
+
defineMachine: J,
|
|
437
513
|
use(S) {
|
|
438
|
-
|
|
514
|
+
s.push(S);
|
|
439
515
|
}
|
|
440
516
|
};
|
|
441
517
|
}
|
|
442
|
-
|
|
443
|
-
function
|
|
444
|
-
const
|
|
445
|
-
let
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
return !(
|
|
449
|
-
},
|
|
450
|
-
!
|
|
451
|
-
},
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
for (const
|
|
456
|
-
const
|
|
457
|
-
...
|
|
458
|
-
originTabId:
|
|
518
|
+
pe();
|
|
519
|
+
function ye(t = {}) {
|
|
520
|
+
const e = t.channelName ?? "storix-sync", s = new Set(t.include ?? []), l = new Set(t.exclude ?? []), w = t.namespaces ?? [], J = w === "*" ? null : new Set(w), S = t.debounce ?? 16, I = crypto.randomUUID(), E = `__storix_sync__:${e}`, M = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
521
|
+
let b = null;
|
|
522
|
+
const h = typeof window < "u" && "BroadcastChannel" in window ? new BroadcastChannel(e) : null, j = (o) => {
|
|
523
|
+
const n = [o.$id, o.$scopeId];
|
|
524
|
+
return !(n.some((c) => l.has(c)) || s.size > 0 && !n.some((c) => s.has(c)));
|
|
525
|
+
}, _ = (o, n) => n === o || J === null ? !0 : J.has(n), P = (o, n) => {
|
|
526
|
+
!n || n.originTabId === I || _(o.$namespace, n.namespace) && n.storeId === o.$id && j(o) && o.$patch({ [n.key]: n.newValue }, "remote");
|
|
527
|
+
}, N = () => {
|
|
528
|
+
if (b = null, M.size === 0) return;
|
|
529
|
+
const o = Array.from(M.values());
|
|
530
|
+
M.clear();
|
|
531
|
+
for (const n of o) {
|
|
532
|
+
const c = {
|
|
533
|
+
...n,
|
|
534
|
+
originTabId: I
|
|
459
535
|
};
|
|
460
|
-
if (
|
|
536
|
+
if (h && h.postMessage(c), typeof window < "u" && "localStorage" in window)
|
|
461
537
|
try {
|
|
462
|
-
window.localStorage.setItem(
|
|
538
|
+
window.localStorage.setItem(E, JSON.stringify(c)), window.localStorage.removeItem(E);
|
|
463
539
|
} catch {
|
|
464
540
|
}
|
|
465
541
|
}
|
|
466
|
-
},
|
|
467
|
-
if (
|
|
468
|
-
|
|
542
|
+
}, g = (o) => {
|
|
543
|
+
if (M.set(`${o.scopeId}:${o.key}`, o), S <= 0) {
|
|
544
|
+
N();
|
|
469
545
|
return;
|
|
470
546
|
}
|
|
471
|
-
|
|
547
|
+
b || (b = setTimeout(N, S));
|
|
472
548
|
};
|
|
473
549
|
return {
|
|
474
550
|
name: "sync",
|
|
475
|
-
onInit(
|
|
476
|
-
const
|
|
477
|
-
if (
|
|
478
|
-
if (
|
|
479
|
-
const
|
|
480
|
-
|
|
551
|
+
onInit(o) {
|
|
552
|
+
const n = o;
|
|
553
|
+
if (j(n)) {
|
|
554
|
+
if (U.add(n.$scopeId), h) {
|
|
555
|
+
const c = (d) => {
|
|
556
|
+
P(n, d.data);
|
|
481
557
|
};
|
|
482
|
-
|
|
558
|
+
R.set(n.$scopeId, c), h.addEventListener("message", c);
|
|
483
559
|
}
|
|
484
560
|
if (typeof window < "u") {
|
|
485
|
-
const
|
|
486
|
-
if (!(
|
|
561
|
+
const c = (d) => {
|
|
562
|
+
if (!(d.key !== E || !d.newValue))
|
|
487
563
|
try {
|
|
488
|
-
const
|
|
489
|
-
|
|
564
|
+
const $ = JSON.parse(d.newValue);
|
|
565
|
+
P(n, $);
|
|
490
566
|
} catch {
|
|
491
567
|
}
|
|
492
568
|
};
|
|
493
|
-
|
|
569
|
+
m.set(n.$scopeId, c), window.addEventListener("storage", c);
|
|
494
570
|
}
|
|
495
571
|
}
|
|
496
572
|
},
|
|
497
|
-
onMutation(
|
|
498
|
-
|
|
573
|
+
onMutation(o, n) {
|
|
574
|
+
n.origin !== "remote" && j(o) && g(n);
|
|
499
575
|
},
|
|
500
|
-
onDispose(
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
typeof window < "u" &&
|
|
576
|
+
onDispose(o) {
|
|
577
|
+
const n = o;
|
|
578
|
+
U.delete(n.$scopeId);
|
|
579
|
+
const c = R.get(n.$scopeId);
|
|
580
|
+
h && c && (h.removeEventListener("message", c), R.delete(n.$scopeId));
|
|
581
|
+
const d = m.get(n.$scopeId);
|
|
582
|
+
typeof window < "u" && d && (window.removeEventListener("storage", d), m.delete(n.$scopeId)), b && (clearTimeout(b), b = null), N(), U.size === 0 && (h == null || h.close());
|
|
507
583
|
}
|
|
508
584
|
};
|
|
509
585
|
}
|
|
510
586
|
export {
|
|
511
|
-
|
|
587
|
+
ye as syncPlugin
|
|
512
588
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storix-js/sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
24
24
|
"dev": "vite build --watch",
|
|
25
|
-
"test": "vitest run",
|
|
25
|
+
"test": "vitest run --passWithNoTests",
|
|
26
26
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@storix-js/core": "
|
|
29
|
+
"@storix-js/core": "workspace:*"
|
|
30
30
|
}
|
|
31
31
|
}
|