@storix-js/vuex 0.1.3 → 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.js +436 -360
- package/package.json +2 -2
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var pt=Symbol.for("preact-signals");function H(){if(E>1)E--;else{for(var t,e=!1;J!==void 0;){var r=J;for(J=void 0,G++;r!==void 0;){var s=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&ct(r))try{r.c()}catch(h){e||(t=h,e=!0)}r=s}}if(G=0,E--,e)throw t}}function Y(t){if(E>0)return t();E++;try{return t()}finally{H()}}var l=void 0;function at(t){var e=l;l=void 0;try{return t()}finally{l=e}}var J=void 0,E=0,G=0,Z=0;function ut(t){if(l!==void 0){var e=t.n;if(e===void 0||e.t!==l)return e={i:0,S:t,p:l.s,n:void 0,t:l,e:void 0,x:void 0,r:e},l.s!==void 0&&(l.s.n=e),l.s=e,t.n=e,32&l.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=l.s,e.n=void 0,l.s.n=e,l.s=e),e}}function S(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 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}S.prototype.brand=pt;S.prototype.h=function(){return!0};S.prototype.S=function(t){var e=this,r=this.t;r!==t&&t.e===void 0&&(t.x=r,this.t=t,r!==void 0?r.e=t:at(function(){var s;(s=e.W)==null||s.call(e)}))};S.prototype.U=function(t){var e=this;if(this.t!==void 0){var r=t.e,s=t.x;r!==void 0&&(r.x=s,t.e=void 0),s!==void 0&&(s.e=r,t.x=void 0),t===this.t&&(this.t=s,s===void 0&&at(function(){var h;(h=e.Z)==null||h.call(e)}))}};S.prototype.subscribe=function(t){var e=this;return bt(function(){var r=e.value,s=l;l=void 0;try{t(r)}finally{l=s}},{name:"sub"})};S.prototype.valueOf=function(){return this.value};S.prototype.toString=function(){return this.value+""};S.prototype.toJSON=function(){return this.value};S.prototype.peek=function(){var t=l;l=void 0;try{return this.value}finally{l=t}};Object.defineProperty(S.prototype,"value",{get:function(){var t=ut(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(G>100)throw new Error("Cycle detected");this.v=t,this.i++,Z++,E++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{H()}}}});function yt(t,e){return new S(t,e)}function ct(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 ft(t){for(var e=t.s;e!==void 0;e=e.n){var r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function lt(t){for(var e=t.s,r=void 0;e!==void 0;){var s=e.p;e.i===-1?(e.S.U(e),s!==void 0&&(s.n=e.n),e.n!==void 0&&(e.n.p=s)):r=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=s}t.s=r}function B(t,e){S.call(this,void 0),this.x=t,this.s=void 0,this.g=Z-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}B.prototype=new S;B.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Z))return!0;if(this.g=Z,this.f|=1,this.i>0&&!ct(this))return this.f&=-2,!0;var t=l;try{ft(this),l=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return l=t,lt(this),this.f&=-2,!0};B.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)}S.prototype.S.call(this,t)};B.prototype.U=function(t){if(this.t!==void 0&&(S.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)}};B.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(B.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=ut(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function rt(t,e){return new B(t,e)}function ht(t){var e=t.u;if(t.u=void 0,typeof e=="function"){E++;var r=l;l=void 0;try{e()}catch(s){throw t.f&=-2,t.f|=8,X(t),s}finally{l=r,H()}}}function X(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ht(t)}function gt(t){if(l!==this)throw new Error("Out-of-order effect");lt(this),l=t,this.f&=-2,8&this.f&&X(this),H()}function D(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e==null?void 0:e.name}D.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.u=e)}finally{t()}};D.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ht(this),ft(this),E++;var t=l;return l=this,gt.bind(this,t)};D.prototype.N=function(){2&this.f||(this.f|=2,this.o=J,J=this)};D.prototype.d=function(){this.f|=8,1&this.f||X(this)};D.prototype.dispose=function(){this.d()};function bt(t,e){var r=new D(t,e);try{r.c()}catch(h){throw r.d(),h}var s=r.d.bind(r);return s[Symbol.dispose]=s,s}const nt=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);function Q(t,e){if(Object.is(t,e))return!0;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Q(t[r],e[r]))return!1;return!0}if(nt(t)&&nt(e)){const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;for(const h of r)if(!(h in e)||!Q(t[h],e[h]))return!1;return!0}return!1}function dt(t){if(typeof structuredClone=="function")return structuredClone(t);try{return JSON.parse(JSON.stringify(t))}catch{return t}}function it(t,e,r=Object.is,s=dt){const h={};for(const[y,w]of Object.entries(e)){const T=t[y];r(T,w,y)||(h[y]=s(w))}return h}function xt(t={}){const e=(t.namespace??"default").trim()||"default",r=t.plugins??[],s=new Map;function h(y,w){return function(){var T;const C=`${e}:${y}`,_=s.get(y);if(_)return _;const A=w.state(),j=w.modules??{},U={...A};for(const[i,n]of Object.entries(j))U[i]=n.state();const g=yt(U),m=new Map,F=new Map,q=new Map,$=new Map,V=new Map,z=new Set,N=new Set(Object.keys(A)),L=new Set(Object.keys(w.getters??{})),W=new Set(Object.keys(w.actions??{})),o=i=>g.value[i]??{},v=(i,n)=>{g.value={...g.value,[i]:n}},p=new Proxy({},{get(i,n){var u,c;if(m.has(n))return(u=m.get(n))==null?void 0:u.value;if(V.has(n))return(c=V.get(n))==null?void 0:c.value;if(N.has(n))return g.value[n];const d=$.get(n);return d?o(d.moduleName)[d.key]:g.value[n]}});for(const[i,n]of Object.entries(w.getters??{}))m.set(i,rt(()=>n(g.value,p)));const b=(i,n)=>{var u;for(const c of z)c(i);for(const c of r)(u=c.onMutation)==null||u.call(c,n,i)},O=(i,n,u,c)=>{const d=g.value[i];Object.is(d,n)||(g.value={...g.value,[i]:n},b({namespace:e,scopeId:C,storeId:y,key:i,oldValue:d,newValue:n,origin:u},c))},M=(i,n,u,c,d)=>{const x=o(i),a=x[n];Object.is(a,u)||(v(i,{...x,[n]:u}),b({namespace:e,scopeId:C,storeId:y,key:`${i}.${n}`,oldValue:a,newValue:u,origin:c},d))},P={$id:y,$namespace:e,$scopeId:C,$subscribe(i){return z.add(i),()=>z.delete(i)},$dispose(){var i;z.clear();for(const n of r)(i=n.onDispose)==null||i.call(n,k);s.delete(y)},$patch(i,n="local"){Y(()=>{for(const[u,c]of Object.entries(i)){const d=$.get(u);if(d){M(d.moduleName,d.key,c,n,k);continue}if(u.includes(".")){const[x,a]=u.split(".",2);if(j[x]){M(x,a,c,n,k);continue}}if(j[u]&&c&&typeof c=="object"&&!Array.isArray(c)){for(const[x,a]of Object.entries(c))M(u,x,a,n,k);continue}O(u,c,n,k)}})},$snapshot(){return{...g.value}}};for(const[i,n]of Object.entries(j)){const u=new Map,c=new Map,d=new Proxy({},{get(a,f){var R,I,tt;if(u.has(f))return(R=u.get(f))==null?void 0:R.value;if(m.has(f))return(I=m.get(f))==null?void 0:I.value;if(V.has(f))return(tt=V.get(f))==null?void 0:tt.value;const et=o(i);if(f in et)return et[f];if(N.has(f))return g.value[f]}});for(const[a,f]of Object.entries(n.getters??{}))u.set(a,rt(()=>f(o(i),g.value,d)));let x;for(const[a,f]of Object.entries(n.actions??{}))c.set(a,(...R)=>Y(()=>f.apply(x,R)));x=new Proxy({},{get(a,f){var R;if(c.has(f))return c.get(f);if(u.has(f))return(R=u.get(f))==null?void 0:R.value;const I=o(i);return f in I?I[f]:k[f]},set(a,f,R){if(c.has(f)||u.has(f))return!1;const I=o(i);return f in I?M(i,f,R,"local",k):k[f]=R,!0}}),q.set(i,x),F.set(i,u);for(const a of Object.keys(o(i)))!(N.has(a)||L.has(a)||W.has(a)||Reflect.has(P,a)||j[a]!==void 0)&&!$.has(a)&&$.set(a,{moduleName:i,key:a});for(const[a,f]of u.entries())!(N.has(a)||L.has(a)||W.has(a)||Reflect.has(P,a)||j[a]!==void 0)&&!V.has(a)&&V.set(a,f);for(const[a,f]of c.entries())!(N.has(a)||L.has(a)||W.has(a)||Reflect.has(P,a)||j[a]!==void 0)&&!Reflect.has(P,a)&&(P[a]=f)}const k=new Proxy(P,{get(i,n,u){var c,d;if(Reflect.has(i,n))return Reflect.get(i,n,u);if(q.has(n))return q.get(n);if(m.has(n))return(c=m.get(n))==null?void 0:c.value;if(V.has(n))return(d=V.get(n))==null?void 0:d.value;if(N.has(n))return g.value[n];const x=$.get(n);return x?o(x.moduleName)[x.key]:g.value[n]},set(i,n,u,c){if(Reflect.has(i,n))return Reflect.set(i,n,u,c);const d=$.get(n);return d?(M(d.moduleName,d.key,u,"local",c),!0):(O(n,u,"local",c),!0)}});for(const[i,n]of Object.entries(w.actions??{}))P[i]=(...u)=>Y(()=>n.apply(k,u));for(const i of r)(T=i.onInit)==null||T.call(i,k);return s.set(y,k),k}}return{defineStore:h,use(y){r.push(y)}}}xt();const K=t=>t!==null&&typeof t=="object";function vt(t){if(!K(t))return t;const e=new WeakSet,r=s=>{if(!K(s))return;const h=s;if(e.has(h))return;e.add(h);const y=Reflect.ownKeys(h);for(const w of y){const T=Reflect.get(h,w);r(T)}Object.freeze(h)};return r(t),t}function St(t,e){for(const[r,s]of Object.entries(e))t[r]=s}const ot=t=>Object.keys(t).length>0,st=t=>t?Array.isArray(t)?t:[t]:[],wt=t=>{const e=[t];if(t.includes(".")){const r=t.split(".",1)[0];r&&r!==t&&e.push(r)}return e},mt=(t,e)=>{if(!e||!K(t))return t;try{Object.defineProperty(t,e,{value:!0,enumerable:!1,configurable:!0})}catch{return t}return t};function jt(t){const e=t.mutationType??"storix/APPLY_PATCH",r=t.immutable??!0,s=t.clone??dt,h=t.equals??Q,y=t.projectVuexToStorix??(o=>o),w=t.projectStorixToVuex??(o=>o),T=t.suppressBridgeEcho??!1,C=t.bridgeOriginKey??"__storixBridge",_=t.outboundDefault??{mode:"patch",type:e},A=o=>{const v=s(o);return r?vt(v):v};let j=!1,U=!1,g=!1;const m=new Map,F=o=>{if(T)for(const v of o){const p=m.get(v)??0;m.set(v,p+1)}},q=o=>{if(!T||!K(o))return!1;const v=Reflect.get(o,"payload");if(C&&K(v)&&Reflect.get(v,C))return!0;const p=Reflect.get(o,"type");if(typeof p!="string")return!1;const b=m.get(p)??0;return b<=0?!1:(b===1?m.delete(p):m.set(p,b-1),!0)},$=()=>{if(j||g)return;const o=A(y(t.vuex.state)),v=t.store.$snapshot(),p=it(v,o,h,A);if(ot(p)){U=!0;try{t.store.$patch(p,t.externalMutationOrigin??"local")}finally{U=!1}}},V=o=>{const p=wt(o.storixMutation.key).flatMap(b=>{var O;return st((O=t.outboundRoutes)==null?void 0:O[b])});return p.push(...st(_)),p.find(b=>b.when?b.when(o):!0)},z=(o,v)=>{var M;if(o.mode==="custom"){(M=o.handler)==null||M.call(o,v),F(o.suppressMutationTypes??[]);return}const p=v.projectedPatch,b=mt(A(o.mapPayload?o.mapPayload(v):p),C);if(o.mode==="dispatch"){if(typeof t.vuex.dispatch!="function")throw new Error('Vuex bridge route mode "dispatch" requires vuex.dispatch to be available.');if(!o.type)throw new Error('Vuex bridge dispatch route requires a "type".');t.vuex.dispatch(o.type,b),F(o.suppressMutationTypes??[]);return}const O=o.type??e;t.vuex.commit(O,b),F(o.suppressMutationTypes??[O])},N=o=>{if(j||U)return;const v=t.store.$snapshot(),p=A(w(v)),b=A(y(t.vuex.state)),O=it(b,p,h,A);if(!ot(O))return;const M={storixMutation:o??{namespace:t.store.$namespace,scopeId:t.store.$scopeId,storeId:t.store.$id,key:Object.keys(O)[0]??"*",oldValue:void 0,newValue:void 0,origin:"local"},storixSnapshot:v,vuexState:t.vuex.state,projectedPatch:O,projectedVuexState:p,origin:"storix"},P=V(M);if(P){g=!0;try{z(P,M)}finally{g=!1}}},L=t.vuex.subscribe(o=>{q(o)||$()}),W=t.store.$subscribe(o=>{N(o)});return $(),{dispose(){j||(j=!0,L(),W())},syncFromExternal:$,syncFromStore(){N()}}}exports.applyVuexPatchMutation=St;exports.createVuexBridge=jt;exports.deepFreeze=vt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var we=Symbol.for("preact-signals");function X(){if(B>1)B--;else{var e,t=!1;for((function(){var h=G;for(G=void 0;h!==void 0;)h.S.v===h.v&&(h.S.i=h.i),h=h.o})();_!==void 0;){var r=_;for(_=void 0,Y++;r!==void 0;){var a=r.u;if(r.u=void 0,r.f&=-3,!(8&r.f)&&ve(r))try{r.c()}catch(h){t||(e=h,t=!0)}r=a}}if(Y=0,B--,t)throw e}}function K(e){if(B>0)return e();te=++me,B++;try{return e()}finally{X()}}var p=void 0;function ne(e){var t=p;p=void 0;try{return e()}finally{p=t}}var _=void 0,B=0,Y=0,me=0,te=0,G=void 0,Q=0;function he(e){if(p!==void 0){var t=e.n;if(t===void 0||t.t!==p)return t={i:0,S:e,p:p.s,n:void 0,t:p,e:void 0,x:void 0,r:t},p.s!==void 0&&(p.s.n=t),p.s=t,e.n=t,32&p.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=p.s,t.n=void 0,p.s.n=t,p.s=t),t}}function k(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=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}k.prototype.brand=we;k.prototype.h=function(){return!0};k.prototype.S=function(e){var t=this,r=this.t;r!==e&&e.e===void 0&&(e.x=r,this.t=e,r!==void 0?r.e=e:ne(function(){var a;(a=t.W)==null||a.call(t)}))};k.prototype.U=function(e){var t=this;if(this.t!==void 0){var r=e.e,a=e.x;r!==void 0&&(r.x=a,e.e=void 0),a!==void 0&&(a.e=r,e.x=void 0),e===this.t&&(this.t=a,a===void 0&&ne(function(){var h;(h=t.Z)==null||h.call(t)}))}};k.prototype.subscribe=function(e){var t=this;return Se(function(){var r=t.value,a=p;p=void 0;try{e(r)}finally{p=a}},{name:"sub"})};k.prototype.valueOf=function(){return this.value};k.prototype.toString=function(){return this.value+""};k.prototype.toJSON=function(){return this.value};k.prototype.peek=function(){var e=this;return ne(function(){return e.value})};Object.defineProperty(k.prototype,"value",{get:function(){var e=he(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Y>100)throw new Error("Cycle detected");(function(r){B!==0&&Y===0&&r.l!==te&&(r.l=te,G={S:r,v:r.v,i:r.i,o:G})})(this),this.v=e,this.i++,Q++,B++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{X()}}}});function ee(e,t){return new k(e,t)}function ve(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 de(e){for(var t=e.s;t!==void 0;t=t.n){var r=t.S.n;if(r!==void 0&&(t.r=r),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function pe(e){for(var t=e.s,r=void 0;t!==void 0;){var a=t.p;t.i===-1?(t.S.U(t),a!==void 0&&(a.n=t.n),t.n!==void 0&&(t.n.p=a)):r=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=a}e.s=r}function W(e,t){k.call(this,void 0),this.x=e,this.s=void 0,this.g=Q-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}W.prototype=new k;W.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Q))return!0;if(this.g=Q,this.f|=1,this.i>0&&!ve(this))return this.f&=-2,!0;var e=p;try{de(this),p=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return p=e,pe(this),this.f&=-2,!0};W.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)}k.prototype.S.call(this,e)};W.prototype.U=function(e){if(this.t!==void 0&&(k.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)}};W.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(W.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=he(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ae(e,t){return new W(e,t)}function ye(e){var t=e.m;if(e.m=void 0,typeof t=="function"){B++;var r=p;p=void 0;try{t()}catch(a){throw e.f&=-2,e.f|=8,oe(e),a}finally{p=r,X()}}}function oe(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ye(e)}function xe(e){if(p!==this)throw new Error("Out-of-order effect");pe(this),p=e,this.f&=-2,8&this.f&&oe(this),X()}function J(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}J.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.m=t)}finally{e()}};J.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ye(this),de(this),B++;var e=p;return p=this,xe.bind(this,e)};J.prototype.N=function(){2&this.f||(this.f|=2,this.u=_,_=this)};J.prototype.d=function(){this.f|=8,1&this.f||oe(this)};J.prototype.dispose=function(){this.d()};function Se(e,t){var r=new J(e,t);try{r.c()}catch(h){throw r.d(),h}var a=r.d.bind(r);return a[Symbol.dispose]=a,a}const ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function re(e,t){if(Object.is(e,t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(!re(e[r],t[r]))return!1;return!0}if(ue(e)&&ue(t)){const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const h of r)if(!(h in t)||!re(e[h],t[h]))return!1;return!0}return!1}function ge(e){if(typeof structuredClone=="function")return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ce(e,t,r=Object.is,a=ge){const h={};for(const[T,b]of Object.entries(t)){const x=e[T];r(x,b,T)||(h[T]=a(b))}return h}function je(e={}){const t=(e.namespace??"default").trim()||"default",r=e.plugins??[],a=new Map;function h(b,x){return function(){var D;const z=`${t}:${b}`,R=a.get(b);if(R)return R;const I=x.state(),S=x.modules??{},V={...I};for(const[i,o]of Object.entries(S))V[i]=o.state();const y=ee(V),M=new Map,Z=new Map,A=new Map,E=new Map,j=new Map,s=new Set,u=new Set(Object.keys(I)),g=new Set(Object.keys(x.getters??{})),n=new Set(Object.keys(x.actions??{})),l=i=>y.value[i]??{},w=(i,o)=>{y.value={...y.value,[i]:o}},O=new Proxy({},{get(i,o){var f,v;if(M.has(o))return(f=M.get(o))==null?void 0:f.value;if(j.has(o))return(v=j.get(o))==null?void 0:v.value;if(u.has(o))return y.value[o];const m=E.get(o);return m?l(m.moduleName)[m.key]:y.value[o]}});for(const[i,o]of Object.entries(x.getters??{}))M.set(i,ae(()=>o(y.value,O)));const P=(i,o)=>{var f;for(const v of s)v(i);for(const v of r)(f=v.onMutation)==null||f.call(v,o,i)},U=(i,o,f,v)=>{const m=y.value[i];Object.is(m,o)||(y.value={...y.value,[i]:o},P({namespace:t,scopeId:z,storeId:b,key:i,oldValue:m,newValue:o,origin:f},v))},F=(i,o,f,v,m)=>{const $=l(i),c=$[o];Object.is(c,f)||(w(i,{...$,[o]:f}),P({namespace:t,scopeId:z,storeId:b,key:`${i}.${o}`,oldValue:c,newValue:f,origin:v},m))},q={$id:b,$namespace:t,$scopeId:z,$subscribe(i){return s.add(i),()=>s.delete(i)},$dispose(){var i;s.clear();for(const o of r)(i=o.onDispose)==null||i.call(o,N);a.delete(b)},$patch(i,o="local"){K(()=>{for(const[f,v]of Object.entries(i)){const m=E.get(f);if(m){F(m.moduleName,m.key,v,o,N);continue}if(f.includes(".")){const[$,c]=f.split(".",2);if(S[$]){F($,c,v,o,N);continue}}if(S[f]&&v&&typeof v=="object"&&!Array.isArray(v)){for(const[$,c]of Object.entries(v))F(f,$,c,o,N);continue}U(f,v,o,N)}})},$snapshot(){return{...y.value}}};for(const[i,o]of Object.entries(S)){const f=new Map,v=new Map,m=new Proxy({},{get(c,d){var C,L,ie;if(f.has(d))return(C=f.get(d))==null?void 0:C.value;if(M.has(d))return(L=M.get(d))==null?void 0:L.value;if(j.has(d))return(ie=j.get(d))==null?void 0:ie.value;const se=l(i);if(d in se)return se[d];if(u.has(d))return y.value[d]}});for(const[c,d]of Object.entries(o.getters??{}))f.set(c,ae(()=>d(l(i),y.value,m)));let $;for(const[c,d]of Object.entries(o.actions??{}))v.set(c,(...C)=>K(()=>d.apply($,C)));$=new Proxy({},{get(c,d){var C;if(v.has(d))return v.get(d);if(f.has(d))return(C=f.get(d))==null?void 0:C.value;const L=l(i);return d in L?L[d]:N[d]},set(c,d,C){if(v.has(d)||f.has(d))return!1;const L=l(i);return d in L?F(i,d,C,"local",N):N[d]=C,!0}}),A.set(i,$),Z.set(i,f);for(const c of Object.keys(l(i)))!(u.has(c)||g.has(c)||n.has(c)||Reflect.has(q,c)||S[c]!==void 0)&&!E.has(c)&&E.set(c,{moduleName:i,key:c});for(const[c,d]of f.entries())!(u.has(c)||g.has(c)||n.has(c)||Reflect.has(q,c)||S[c]!==void 0)&&!j.has(c)&&j.set(c,d);for(const[c,d]of v.entries())!(u.has(c)||g.has(c)||n.has(c)||Reflect.has(q,c)||S[c]!==void 0)&&!Reflect.has(q,c)&&(q[c]=d)}const N=new Proxy(q,{get(i,o,f){var v,m;if(Reflect.has(i,o))return Reflect.get(i,o,f);if(A.has(o))return A.get(o);if(M.has(o))return(v=M.get(o))==null?void 0:v.value;if(j.has(o))return(m=j.get(o))==null?void 0:m.value;if(u.has(o))return y.value[o];const $=E.get(o);return $?l($.moduleName)[$.key]:y.value[o]},set(i,o,f,v){if(Reflect.has(i,o))return Reflect.set(i,o,f,v);const m=E.get(o);return m?(F(m.moduleName,m.key,f,"local",v),!0):(U(o,f,"local",v),!0)}});for(const[i,o]of Object.entries(x.actions??{}))q[i]=(...f)=>K(()=>o.apply(N,f));for(const i of r)(D=i.onInit)==null||D.call(i,N);return a.set(b,N),N}}function T(b,x){return function(){var D;const z=`\0machine:${b}`,R=a.get(z);if(R)return R;const I=`${t}:${b}`,S=ee(x.initial),V=ee((x.context??(()=>({})))()),y=new Set,M=(s,u)=>{var g;for(const n of y)n(s);for(const n of r)(g=n.onMutation)==null||g.call(n,u,s)},Z=(s,u,g,n)=>{const l=V.value[s];Object.is(l,u)||(V.value={...V.value,[s]:u},M({namespace:t,scopeId:I,storeId:b,key:s,oldValue:l,newValue:u,origin:g},n))},A=(s,u,g)=>{const n=S.value;Object.is(n,s)||(S.value=s,M({namespace:t,scopeId:I,storeId:b,key:"$state",oldValue:n,newValue:s,origin:u},g))},E={$id:b,$namespace:t,$scopeId:I,$subscribe(s){return y.add(s),()=>y.delete(s)},$dispose(){var s;y.clear();for(const u of r)(s=u.onDispose)==null||s.call(u,j);a.delete(z)},$patch(s,u="local"){K(()=>{for(const[g,n]of Object.entries(s))g==="$state"?A(n,u,j):Z(g,n,u,j)})},$snapshot(){return{$state:S.value,...V.value}},send(s,u){K(()=>{var g,n,l;const w=(g=x.actions)==null?void 0:g[s];w&&w.call(j,u);const O=(l=(n=x.states[S.value])==null?void 0:n.on)==null?void 0:l[s];O!==void 0&&A(O,"local",j)})},matches(s){return S.value===s},can(s){const u=x.states[S.value];return!!(u!=null&&u.on&&s in u.on)}},j=new Proxy(E,{get(s,u,g){return u==="state"?S.value:Reflect.has(s,u)?Reflect.get(s,u,g):V.value[u]},set(s,u,g,n){return u==="state"?!1:Reflect.has(s,u)?Reflect.set(s,u,g,n):(Z(u,g,"local",n),!0)}});for(const s of r)(D=s.onInit)==null||D.call(s,j);return a.set(z,j),j}}return{defineStore:h,defineMachine:T,use(b){r.push(b)}}}je();const H=e=>e!==null&&typeof e=="object";function be(e){if(!H(e))return e;const t=new WeakSet,r=a=>{if(!H(a))return;const h=a;if(t.has(h))return;t.add(h);const T=Reflect.ownKeys(h);for(const b of T){const x=Reflect.get(h,b);r(x)}Object.freeze(h)};return r(e),e}function Oe(e,t){for(const[r,a]of Object.entries(t))e[r]=a}const fe=e=>Object.keys(e).length>0,le=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=[e];if(e.includes(".")){const r=e.split(".",1)[0];r&&r!==e&&t.push(r)}return t},ke=(e,t)=>{if(!t||!H(e))return e;try{Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0})}catch{return e}return e};function Me(e){const t=e.mutationType??"storix/APPLY_PATCH",r=e.immutable??!0,a=e.clone??ge,h=e.equals??re,T=e.projectVuexToStorix??(n=>n),b=e.projectStorixToVuex??(n=>n),x=e.suppressBridgeEcho??!1,D=e.bridgeOriginKey??"__storixBridge",z=e.outboundDefault??{mode:"patch",type:t},R=n=>{const l=a(n);return r?be(l):l};let I=!1,S=!1,V=!1;const y=new Map,M=n=>{if(x)for(const l of n){const w=y.get(l)??0;y.set(l,w+1)}},Z=n=>{if(!x||!H(n))return!1;const l=Reflect.get(n,"payload");if(D&&H(l)&&Reflect.get(l,D))return!0;const w=Reflect.get(n,"type");if(typeof w!="string")return!1;const O=y.get(w)??0;return O<=0?!1:(O===1?y.delete(w):y.set(w,O-1),!0)},A=()=>{if(I||V)return;const n=R(T(e.vuex.state)),l=e.store.$snapshot(),w=ce(l,n,h,R);if(fe(w)){S=!0;try{e.store.$patch(w,e.externalMutationOrigin??"local")}finally{S=!1}}},E=n=>{const w=$e(n.storixMutation.key).flatMap(O=>{var P;return le((P=e.outboundRoutes)==null?void 0:P[O])});return w.push(...le(z)),w.find(O=>O.when?O.when(n):!0)},j=(n,l)=>{var U;if(n.mode==="custom"){(U=n.handler)==null||U.call(n,l),M(n.suppressMutationTypes??[]);return}const w=l.projectedPatch,O=ke(R(n.mapPayload?n.mapPayload(l):w),D);if(n.mode==="dispatch"){if(typeof e.vuex.dispatch!="function")throw new Error('Vuex bridge route mode "dispatch" requires vuex.dispatch to be available.');if(!n.type)throw new Error('Vuex bridge dispatch route requires a "type".');e.vuex.dispatch(n.type,O),M(n.suppressMutationTypes??[]);return}const P=n.type??t;e.vuex.commit(P,O),M(n.suppressMutationTypes??[P])},s=n=>{if(I||S)return;const l=e.store.$snapshot(),w=R(b(l)),O=R(T(e.vuex.state)),P=ce(O,w,h,R);if(!fe(P))return;const U={storixMutation:n??{namespace:e.store.$namespace,scopeId:e.store.$scopeId,storeId:e.store.$id,key:Object.keys(P)[0]??"*",oldValue:void 0,newValue:void 0,origin:"local"},storixSnapshot:l,vuexState:e.vuex.state,projectedPatch:P,projectedVuexState:w,origin:"storix"},F=E(U);if(F){V=!0;try{j(F,U)}finally{V=!1}}},u=e.vuex.subscribe(n=>{Z(n)||A()}),g=e.store.$subscribe(n=>{s(n)});return A(),{dispose(){I||(I=!0,u(),g())},syncFromExternal:A,syncFromStore(){s()}}}exports.applyVuexPatchMutation=Oe;exports.createVuexBridge=Me;exports.deepFreeze=be;
|
package/dist/index.js
CHANGED
|
@@ -1,272 +1,276 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
|
|
1
|
+
var bt = Symbol.for("preact-signals");
|
|
2
|
+
function X() {
|
|
3
|
+
if (z > 1)
|
|
4
|
+
z--;
|
|
5
5
|
else {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var t, e = !1;
|
|
7
|
+
for ((function() {
|
|
8
|
+
var h = G;
|
|
9
|
+
for (G = void 0; h !== void 0; )
|
|
10
|
+
h.S.v === h.v && (h.S.i = h.i), h = h.o;
|
|
11
|
+
})(); _ !== void 0; ) {
|
|
12
|
+
var r = _;
|
|
13
|
+
for (_ = void 0, Y++; r !== void 0; ) {
|
|
14
|
+
var a = r.u;
|
|
15
|
+
if (r.u = void 0, r.f &= -3, !(8 & r.f) && vt(r)) try {
|
|
16
|
+
r.c();
|
|
12
17
|
} catch (h) {
|
|
13
18
|
e || (t = h, e = !0);
|
|
14
19
|
}
|
|
15
|
-
|
|
20
|
+
r = a;
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
|
-
if (
|
|
23
|
+
if (Y = 0, z--, e) throw t;
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
|
-
function
|
|
22
|
-
if (
|
|
23
|
-
|
|
26
|
+
function K(t) {
|
|
27
|
+
if (z > 0) return t();
|
|
28
|
+
et = ++wt, z++;
|
|
24
29
|
try {
|
|
25
30
|
return t();
|
|
26
31
|
} finally {
|
|
27
|
-
|
|
32
|
+
X();
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
var
|
|
31
|
-
function
|
|
32
|
-
var e =
|
|
33
|
-
|
|
35
|
+
var p = void 0;
|
|
36
|
+
function nt(t) {
|
|
37
|
+
var e = p;
|
|
38
|
+
p = void 0;
|
|
34
39
|
try {
|
|
35
40
|
return t();
|
|
36
41
|
} finally {
|
|
37
|
-
|
|
42
|
+
p = e;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
if (
|
|
45
|
+
var _ = void 0, z = 0, Y = 0, wt = 0, et = 0, G = void 0, Q = 0;
|
|
46
|
+
function ht(t) {
|
|
47
|
+
if (p !== void 0) {
|
|
43
48
|
var e = t.n;
|
|
44
|
-
if (e === void 0 || e.t !==
|
|
45
|
-
return e = { i: 0, S: t, p:
|
|
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;
|
|
46
51
|
if (e.i === -1)
|
|
47
|
-
return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p =
|
|
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 = t, this.i = 0, this.n = void 0, this.t = void 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;
|
|
55
|
+
function k(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
|
+
k.prototype.brand = bt;
|
|
59
|
+
k.prototype.h = function() {
|
|
55
60
|
return !0;
|
|
56
61
|
};
|
|
57
|
-
|
|
58
|
-
var e = this,
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
(
|
|
62
|
+
k.prototype.S = function(t) {
|
|
63
|
+
var e = this, r = this.t;
|
|
64
|
+
r !== t && t.e === void 0 && (t.x = r, this.t = t, r !== void 0 ? r.e = t : nt(function() {
|
|
65
|
+
var a;
|
|
66
|
+
(a = e.W) == null || a.call(e);
|
|
62
67
|
}));
|
|
63
68
|
};
|
|
64
|
-
|
|
69
|
+
k.prototype.U = function(t) {
|
|
65
70
|
var e = this;
|
|
66
71
|
if (this.t !== void 0) {
|
|
67
|
-
var
|
|
68
|
-
|
|
72
|
+
var r = t.e, a = t.x;
|
|
73
|
+
r !== void 0 && (r.x = a, t.e = void 0), a !== void 0 && (a.e = r, t.x = void 0), t === this.t && (this.t = a, a === void 0 && nt(function() {
|
|
69
74
|
var h;
|
|
70
75
|
(h = e.Z) == null || h.call(e);
|
|
71
76
|
}));
|
|
72
77
|
}
|
|
73
78
|
};
|
|
74
|
-
|
|
79
|
+
k.prototype.subscribe = function(t) {
|
|
75
80
|
var e = this;
|
|
76
|
-
return
|
|
77
|
-
var
|
|
78
|
-
|
|
81
|
+
return xt(function() {
|
|
82
|
+
var r = e.value, a = p;
|
|
83
|
+
p = void 0;
|
|
79
84
|
try {
|
|
80
|
-
t(
|
|
85
|
+
t(r);
|
|
81
86
|
} finally {
|
|
82
|
-
|
|
87
|
+
p = a;
|
|
83
88
|
}
|
|
84
89
|
}, { name: "sub" });
|
|
85
90
|
};
|
|
86
|
-
|
|
91
|
+
k.prototype.valueOf = function() {
|
|
87
92
|
return this.value;
|
|
88
93
|
};
|
|
89
|
-
|
|
94
|
+
k.prototype.toString = function() {
|
|
90
95
|
return this.value + "";
|
|
91
96
|
};
|
|
92
|
-
|
|
97
|
+
k.prototype.toJSON = function() {
|
|
93
98
|
return this.value;
|
|
94
99
|
};
|
|
95
|
-
|
|
96
|
-
var t =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} finally {
|
|
101
|
-
l = t;
|
|
102
|
-
}
|
|
100
|
+
k.prototype.peek = function() {
|
|
101
|
+
var t = this;
|
|
102
|
+
return nt(function() {
|
|
103
|
+
return t.value;
|
|
104
|
+
});
|
|
103
105
|
};
|
|
104
|
-
Object.defineProperty(
|
|
105
|
-
var t =
|
|
106
|
+
Object.defineProperty(k.prototype, "value", { get: function() {
|
|
107
|
+
var t = ht(this);
|
|
106
108
|
return t !== void 0 && (t.i = this.i), this.v;
|
|
107
109
|
}, set: function(t) {
|
|
108
110
|
if (t !== this.v) {
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
+
if (Y > 100) throw new Error("Cycle detected");
|
|
112
|
+
(function(r) {
|
|
113
|
+
z !== 0 && Y === 0 && r.l !== et && (r.l = et, G = { S: r, v: r.v, i: r.i, o: G });
|
|
114
|
+
})(this), this.v = t, this.i++, Q++, z++;
|
|
111
115
|
try {
|
|
112
116
|
for (var e = this.t; e !== void 0; e = e.x) e.t.N();
|
|
113
117
|
} finally {
|
|
114
|
-
|
|
118
|
+
X();
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
} });
|
|
118
|
-
function
|
|
119
|
-
return new
|
|
122
|
+
function tt(t, e) {
|
|
123
|
+
return new k(t, e);
|
|
120
124
|
}
|
|
121
|
-
function
|
|
125
|
+
function vt(t) {
|
|
122
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
|
|
129
|
+
function dt(t) {
|
|
126
130
|
for (var e = t.s; e !== void 0; e = e.n) {
|
|
127
|
-
var
|
|
128
|
-
if (
|
|
131
|
+
var r = e.S.n;
|
|
132
|
+
if (r !== void 0 && (e.r = r), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
129
133
|
t.s = e;
|
|
130
134
|
break;
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
|
-
function
|
|
135
|
-
for (var e = t.s,
|
|
136
|
-
var
|
|
137
|
-
e.i === -1 ? (e.S.U(e),
|
|
138
|
+
function pt(t) {
|
|
139
|
+
for (var e = t.s, r = void 0; e !== void 0; ) {
|
|
140
|
+
var a = e.p;
|
|
141
|
+
e.i === -1 ? (e.S.U(e), a !== void 0 && (a.n = e.n), e.n !== void 0 && (e.n.p = a)) : r = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = a;
|
|
138
142
|
}
|
|
139
|
-
t.s =
|
|
143
|
+
t.s = r;
|
|
140
144
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
145
|
+
function W(t, e) {
|
|
146
|
+
k.call(this, void 0), this.x = t, this.s = void 0, this.g = Q - 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
|
+
W.prototype = new k();
|
|
149
|
+
W.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 === Q)) return !0;
|
|
152
|
+
if (this.g = Q, this.f |= 1, this.i > 0 && !vt(this))
|
|
149
153
|
return this.f &= -2, !0;
|
|
150
|
-
var t =
|
|
154
|
+
var t = p;
|
|
151
155
|
try {
|
|
152
|
-
|
|
156
|
+
dt(this), p = this;
|
|
153
157
|
var e = this.x();
|
|
154
158
|
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
155
|
-
} catch (
|
|
156
|
-
this.v =
|
|
159
|
+
} catch (r) {
|
|
160
|
+
this.v = r, this.f |= 16, this.i++;
|
|
157
161
|
}
|
|
158
|
-
return
|
|
162
|
+
return p = t, pt(this), this.f &= -2, !0;
|
|
159
163
|
};
|
|
160
|
-
|
|
164
|
+
W.prototype.S = function(t) {
|
|
161
165
|
if (this.t === void 0) {
|
|
162
166
|
this.f |= 36;
|
|
163
167
|
for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
|
|
164
168
|
}
|
|
165
|
-
|
|
169
|
+
k.prototype.S.call(this, t);
|
|
166
170
|
};
|
|
167
|
-
|
|
168
|
-
if (this.t !== void 0 && (
|
|
171
|
+
W.prototype.U = function(t) {
|
|
172
|
+
if (this.t !== void 0 && (k.prototype.U.call(this, t), this.t === void 0)) {
|
|
169
173
|
this.f &= -33;
|
|
170
174
|
for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
|
|
171
175
|
}
|
|
172
176
|
};
|
|
173
|
-
|
|
177
|
+
W.prototype.N = function() {
|
|
174
178
|
if (!(2 & this.f)) {
|
|
175
179
|
this.f |= 6;
|
|
176
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(W.prototype, "value", { get: function() {
|
|
180
184
|
if (1 & this.f) throw new Error("Cycle detected");
|
|
181
|
-
var t =
|
|
185
|
+
var t = ht(this);
|
|
182
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 at(t, e) {
|
|
190
|
+
return new W(t, e);
|
|
187
191
|
}
|
|
188
|
-
function
|
|
189
|
-
var e = t.
|
|
190
|
-
if (t.
|
|
191
|
-
|
|
192
|
-
var
|
|
193
|
-
|
|
192
|
+
function yt(t) {
|
|
193
|
+
var e = t.m;
|
|
194
|
+
if (t.m = void 0, typeof e == "function") {
|
|
195
|
+
z++;
|
|
196
|
+
var r = p;
|
|
197
|
+
p = void 0;
|
|
194
198
|
try {
|
|
195
199
|
e();
|
|
196
|
-
} catch (
|
|
197
|
-
throw t.f &= -2, t.f |= 8,
|
|
200
|
+
} catch (a) {
|
|
201
|
+
throw t.f &= -2, t.f |= 8, ot(t), a;
|
|
198
202
|
} finally {
|
|
199
|
-
|
|
203
|
+
p = r, X();
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
|
-
function
|
|
207
|
+
function ot(t) {
|
|
204
208
|
for (var e = t.s; e !== void 0; e = e.n) e.S.U(e);
|
|
205
|
-
t.x = void 0, t.s = void 0,
|
|
209
|
+
t.x = void 0, t.s = void 0, yt(t);
|
|
206
210
|
}
|
|
207
|
-
function
|
|
208
|
-
if (
|
|
209
|
-
|
|
211
|
+
function mt(t) {
|
|
212
|
+
if (p !== this) throw new Error("Out-of-order effect");
|
|
213
|
+
pt(this), p = t, this.f &= -2, 8 & this.f && ot(this), X();
|
|
210
214
|
}
|
|
211
|
-
function
|
|
212
|
-
this.x = t, this.
|
|
215
|
+
function J(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
|
-
|
|
218
|
+
J.prototype.c = function() {
|
|
215
219
|
var t = this.S();
|
|
216
220
|
try {
|
|
217
221
|
if (8 & this.f || this.x === void 0) return;
|
|
218
222
|
var e = this.x();
|
|
219
|
-
typeof e == "function" && (this.
|
|
223
|
+
typeof e == "function" && (this.m = e);
|
|
220
224
|
} finally {
|
|
221
225
|
t();
|
|
222
226
|
}
|
|
223
227
|
};
|
|
224
|
-
|
|
228
|
+
J.prototype.S = function() {
|
|
225
229
|
if (1 & this.f) throw new Error("Cycle detected");
|
|
226
|
-
this.f |= 1, this.f &= -9,
|
|
227
|
-
var t =
|
|
228
|
-
return
|
|
230
|
+
this.f |= 1, this.f &= -9, yt(this), dt(this), z++;
|
|
231
|
+
var t = p;
|
|
232
|
+
return p = this, mt.bind(this, t);
|
|
229
233
|
};
|
|
230
|
-
|
|
231
|
-
2 & this.f || (this.f |= 2, this.
|
|
234
|
+
J.prototype.N = function() {
|
|
235
|
+
2 & this.f || (this.f |= 2, this.u = _, _ = this);
|
|
232
236
|
};
|
|
233
|
-
|
|
234
|
-
this.f |= 8, 1 & this.f ||
|
|
237
|
+
J.prototype.d = function() {
|
|
238
|
+
this.f |= 8, 1 & this.f || ot(this);
|
|
235
239
|
};
|
|
236
|
-
|
|
240
|
+
J.prototype.dispose = function() {
|
|
237
241
|
this.d();
|
|
238
242
|
};
|
|
239
|
-
function
|
|
240
|
-
var
|
|
243
|
+
function xt(t, e) {
|
|
244
|
+
var r = new J(t, e);
|
|
241
245
|
try {
|
|
242
|
-
|
|
246
|
+
r.c();
|
|
243
247
|
} catch (h) {
|
|
244
|
-
throw
|
|
248
|
+
throw r.d(), h;
|
|
245
249
|
}
|
|
246
|
-
var
|
|
247
|
-
return
|
|
250
|
+
var a = r.d.bind(r);
|
|
251
|
+
return a[Symbol.dispose] = a, a;
|
|
248
252
|
}
|
|
249
|
-
const
|
|
250
|
-
function
|
|
253
|
+
const ut = (t) => t !== null && typeof t == "object" && !Array.isArray(t);
|
|
254
|
+
function rt(t, e) {
|
|
251
255
|
if (Object.is(t, e)) return !0;
|
|
252
256
|
if (t instanceof Date && e instanceof Date)
|
|
253
257
|
return t.getTime() === e.getTime();
|
|
254
258
|
if (Array.isArray(t) && Array.isArray(e)) {
|
|
255
259
|
if (t.length !== e.length) return !1;
|
|
256
|
-
for (let
|
|
257
|
-
if (!
|
|
260
|
+
for (let r = 0; r < t.length; r += 1)
|
|
261
|
+
if (!rt(t[r], e[r])) return !1;
|
|
258
262
|
return !0;
|
|
259
263
|
}
|
|
260
|
-
if (
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
263
|
-
for (const h of
|
|
264
|
-
if (!(h in e) || !
|
|
264
|
+
if (ut(t) && ut(e)) {
|
|
265
|
+
const r = Object.keys(t), a = Object.keys(e);
|
|
266
|
+
if (r.length !== a.length) return !1;
|
|
267
|
+
for (const h of r)
|
|
268
|
+
if (!(h in e) || !rt(t[h], e[h])) return !1;
|
|
265
269
|
return !0;
|
|
266
270
|
}
|
|
267
271
|
return !1;
|
|
268
272
|
}
|
|
269
|
-
function
|
|
273
|
+
function gt(t) {
|
|
270
274
|
if (typeof structuredClone == "function")
|
|
271
275
|
return structuredClone(t);
|
|
272
276
|
try {
|
|
@@ -275,238 +279,310 @@ function dt(t) {
|
|
|
275
279
|
return t;
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
|
-
function
|
|
282
|
+
function ct(t, e, r = Object.is, a = gt) {
|
|
279
283
|
const h = {};
|
|
280
|
-
for (const [
|
|
281
|
-
const
|
|
282
|
-
|
|
284
|
+
for (const [A, b] of Object.entries(e)) {
|
|
285
|
+
const x = t[A];
|
|
286
|
+
r(x, b, A) || (h[A] = a(b));
|
|
283
287
|
}
|
|
284
288
|
return h;
|
|
285
289
|
}
|
|
286
|
-
function
|
|
287
|
-
const e = (t.namespace ?? "default").trim() || "default",
|
|
288
|
-
function h(
|
|
290
|
+
function St(t = {}) {
|
|
291
|
+
const e = (t.namespace ?? "default").trim() || "default", r = t.plugins ?? [], a = /* @__PURE__ */ new Map();
|
|
292
|
+
function h(b, x) {
|
|
289
293
|
return function() {
|
|
290
|
-
var
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
for (const [i,
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
...
|
|
299
|
-
[i]:
|
|
294
|
+
var D;
|
|
295
|
+
const U = `${e}:${b}`, R = a.get(b);
|
|
296
|
+
if (R) return R;
|
|
297
|
+
const I = x.state(), S = x.modules ?? {}, V = { ...I };
|
|
298
|
+
for (const [i, o] of Object.entries(S))
|
|
299
|
+
V[i] = o.state();
|
|
300
|
+
const y = tt(V), M = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), u = new Set(Object.keys(I)), g = new Set(Object.keys(x.getters ?? {})), n = new Set(Object.keys(x.actions ?? {})), l = (i) => y.value[i] ?? {}, w = (i, o) => {
|
|
301
|
+
y.value = {
|
|
302
|
+
...y.value,
|
|
303
|
+
[i]: o
|
|
300
304
|
};
|
|
301
|
-
},
|
|
305
|
+
}, O = new Proxy(
|
|
302
306
|
{},
|
|
303
307
|
{
|
|
304
|
-
get(i,
|
|
305
|
-
var
|
|
306
|
-
if (
|
|
307
|
-
if (
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
return
|
|
308
|
+
get(i, o) {
|
|
309
|
+
var f, v;
|
|
310
|
+
if (M.has(o)) return (f = M.get(o)) == null ? void 0 : f.value;
|
|
311
|
+
if (j.has(o)) return (v = j.get(o)) == null ? void 0 : v.value;
|
|
312
|
+
if (u.has(o)) return y.value[o];
|
|
313
|
+
const m = E.get(o);
|
|
314
|
+
return m ? l(m.moduleName)[m.key] : y.value[o];
|
|
311
315
|
}
|
|
312
316
|
}
|
|
313
317
|
);
|
|
314
|
-
for (const [i,
|
|
315
|
-
|
|
318
|
+
for (const [i, o] of Object.entries(x.getters ?? {}))
|
|
319
|
+
M.set(
|
|
316
320
|
i,
|
|
317
|
-
|
|
321
|
+
at(() => o(y.value, O))
|
|
318
322
|
);
|
|
319
|
-
const
|
|
320
|
-
var
|
|
321
|
-
for (const
|
|
322
|
-
for (const
|
|
323
|
-
(
|
|
324
|
-
},
|
|
325
|
-
const
|
|
326
|
-
Object.is(
|
|
327
|
-
...
|
|
328
|
-
[i]:
|
|
329
|
-
},
|
|
323
|
+
const P = (i, o) => {
|
|
324
|
+
var f;
|
|
325
|
+
for (const v of s) v(i);
|
|
326
|
+
for (const v of r)
|
|
327
|
+
(f = v.onMutation) == null || f.call(v, o, i);
|
|
328
|
+
}, B = (i, o, f, v) => {
|
|
329
|
+
const m = y.value[i];
|
|
330
|
+
Object.is(m, o) || (y.value = {
|
|
331
|
+
...y.value,
|
|
332
|
+
[i]: o
|
|
333
|
+
}, P(
|
|
330
334
|
{
|
|
331
335
|
namespace: e,
|
|
332
|
-
scopeId:
|
|
333
|
-
storeId:
|
|
336
|
+
scopeId: U,
|
|
337
|
+
storeId: b,
|
|
334
338
|
key: i,
|
|
335
|
-
oldValue:
|
|
336
|
-
newValue:
|
|
337
|
-
origin:
|
|
339
|
+
oldValue: m,
|
|
340
|
+
newValue: o,
|
|
341
|
+
origin: f
|
|
338
342
|
},
|
|
339
|
-
|
|
343
|
+
v
|
|
340
344
|
));
|
|
341
|
-
},
|
|
342
|
-
const
|
|
343
|
-
Object.is(
|
|
344
|
-
|
|
345
|
-
[
|
|
346
|
-
}),
|
|
345
|
+
}, q = (i, o, f, v, m) => {
|
|
346
|
+
const $ = l(i), c = $[o];
|
|
347
|
+
Object.is(c, f) || (w(i, {
|
|
348
|
+
...$,
|
|
349
|
+
[o]: f
|
|
350
|
+
}), P(
|
|
347
351
|
{
|
|
348
352
|
namespace: e,
|
|
349
|
-
scopeId:
|
|
350
|
-
storeId:
|
|
351
|
-
key: `${i}.${
|
|
352
|
-
oldValue:
|
|
353
|
-
newValue:
|
|
354
|
-
origin:
|
|
353
|
+
scopeId: U,
|
|
354
|
+
storeId: b,
|
|
355
|
+
key: `${i}.${o}`,
|
|
356
|
+
oldValue: c,
|
|
357
|
+
newValue: f,
|
|
358
|
+
origin: v
|
|
355
359
|
},
|
|
356
|
-
|
|
360
|
+
m
|
|
357
361
|
));
|
|
358
|
-
},
|
|
359
|
-
$id:
|
|
362
|
+
}, F = {
|
|
363
|
+
$id: b,
|
|
360
364
|
$namespace: e,
|
|
361
|
-
$scopeId:
|
|
365
|
+
$scopeId: U,
|
|
362
366
|
$subscribe(i) {
|
|
363
|
-
return
|
|
367
|
+
return s.add(i), () => s.delete(i);
|
|
364
368
|
},
|
|
365
369
|
$dispose() {
|
|
366
370
|
var i;
|
|
367
|
-
|
|
368
|
-
for (const
|
|
369
|
-
(i =
|
|
370
|
-
|
|
371
|
+
s.clear();
|
|
372
|
+
for (const o of r)
|
|
373
|
+
(i = o.onDispose) == null || i.call(o, N);
|
|
374
|
+
a.delete(b);
|
|
371
375
|
},
|
|
372
|
-
$patch(i,
|
|
373
|
-
|
|
374
|
-
for (const [
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
377
|
-
|
|
376
|
+
$patch(i, o = "local") {
|
|
377
|
+
K(() => {
|
|
378
|
+
for (const [f, v] of Object.entries(i)) {
|
|
379
|
+
const m = E.get(f);
|
|
380
|
+
if (m) {
|
|
381
|
+
q(m.moduleName, m.key, v, o, N);
|
|
378
382
|
continue;
|
|
379
383
|
}
|
|
380
|
-
if (
|
|
381
|
-
const [
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
+
if (f.includes(".")) {
|
|
385
|
+
const [$, c] = f.split(".", 2);
|
|
386
|
+
if (S[$]) {
|
|
387
|
+
q($, c, v, o, N);
|
|
384
388
|
continue;
|
|
385
389
|
}
|
|
386
390
|
}
|
|
387
|
-
if (
|
|
388
|
-
for (const [
|
|
389
|
-
|
|
391
|
+
if (S[f] && v && typeof v == "object" && !Array.isArray(v)) {
|
|
392
|
+
for (const [$, c] of Object.entries(v))
|
|
393
|
+
q(f, $, c, o, N);
|
|
390
394
|
continue;
|
|
391
395
|
}
|
|
392
|
-
|
|
396
|
+
B(f, v, o, N);
|
|
393
397
|
}
|
|
394
398
|
});
|
|
395
399
|
},
|
|
396
400
|
$snapshot() {
|
|
397
|
-
return { ...
|
|
401
|
+
return { ...y.value };
|
|
398
402
|
}
|
|
399
403
|
};
|
|
400
|
-
for (const [i,
|
|
401
|
-
const
|
|
404
|
+
for (const [i, o] of Object.entries(S)) {
|
|
405
|
+
const f = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), m = new Proxy(
|
|
402
406
|
{},
|
|
403
407
|
{
|
|
404
|
-
get(
|
|
405
|
-
var
|
|
406
|
-
if (
|
|
407
|
-
if (
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
411
|
-
if (
|
|
408
|
+
get(c, d) {
|
|
409
|
+
var C, L, it;
|
|
410
|
+
if (f.has(d)) return (C = f.get(d)) == null ? void 0 : C.value;
|
|
411
|
+
if (M.has(d)) return (L = M.get(d)) == null ? void 0 : L.value;
|
|
412
|
+
if (j.has(d)) return (it = j.get(d)) == null ? void 0 : it.value;
|
|
413
|
+
const st = l(i);
|
|
414
|
+
if (d in st) return st[d];
|
|
415
|
+
if (u.has(d)) return y.value[d];
|
|
412
416
|
}
|
|
413
417
|
}
|
|
414
418
|
);
|
|
415
|
-
for (const [
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
+
for (const [c, d] of Object.entries(o.getters ?? {}))
|
|
420
|
+
f.set(
|
|
421
|
+
c,
|
|
422
|
+
at(() => d(l(i), y.value, m))
|
|
419
423
|
);
|
|
420
|
-
let
|
|
421
|
-
for (const [
|
|
422
|
-
|
|
423
|
-
|
|
424
|
+
let $;
|
|
425
|
+
for (const [c, d] of Object.entries(o.actions ?? {}))
|
|
426
|
+
v.set(c, (...C) => K(() => d.apply($, C)));
|
|
427
|
+
$ = new Proxy(
|
|
424
428
|
{},
|
|
425
429
|
{
|
|
426
|
-
get(
|
|
427
|
-
var
|
|
428
|
-
if (
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
431
|
-
return
|
|
430
|
+
get(c, d) {
|
|
431
|
+
var C;
|
|
432
|
+
if (v.has(d)) return v.get(d);
|
|
433
|
+
if (f.has(d)) return (C = f.get(d)) == null ? void 0 : C.value;
|
|
434
|
+
const L = l(i);
|
|
435
|
+
return d in L ? L[d] : N[d];
|
|
432
436
|
},
|
|
433
|
-
set(
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
return
|
|
437
|
+
set(c, d, C) {
|
|
438
|
+
if (v.has(d) || f.has(d)) return !1;
|
|
439
|
+
const L = l(i);
|
|
440
|
+
return d in L ? q(i, d, C, "local", N) : N[d] = C, !0;
|
|
437
441
|
}
|
|
438
442
|
}
|
|
439
|
-
),
|
|
440
|
-
for (const
|
|
441
|
-
!(
|
|
442
|
-
for (const [
|
|
443
|
-
!(
|
|
444
|
-
for (const [
|
|
445
|
-
!(
|
|
443
|
+
), T.set(i, $), Z.set(i, f);
|
|
444
|
+
for (const c of Object.keys(l(i)))
|
|
445
|
+
!(u.has(c) || g.has(c) || n.has(c) || Reflect.has(F, c) || S[c] !== void 0) && !E.has(c) && E.set(c, { moduleName: i, key: c });
|
|
446
|
+
for (const [c, d] of f.entries())
|
|
447
|
+
!(u.has(c) || g.has(c) || n.has(c) || Reflect.has(F, c) || S[c] !== void 0) && !j.has(c) && j.set(c, d);
|
|
448
|
+
for (const [c, d] of v.entries())
|
|
449
|
+
!(u.has(c) || g.has(c) || n.has(c) || Reflect.has(F, c) || S[c] !== void 0) && !Reflect.has(F, c) && (F[c] = d);
|
|
446
450
|
}
|
|
447
|
-
const
|
|
448
|
-
get(i,
|
|
449
|
-
var
|
|
450
|
-
if (Reflect.has(i,
|
|
451
|
-
if (
|
|
452
|
-
if (
|
|
453
|
-
if (
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
return
|
|
451
|
+
const N = new Proxy(F, {
|
|
452
|
+
get(i, o, f) {
|
|
453
|
+
var v, m;
|
|
454
|
+
if (Reflect.has(i, o)) return Reflect.get(i, o, f);
|
|
455
|
+
if (T.has(o)) return T.get(o);
|
|
456
|
+
if (M.has(o)) return (v = M.get(o)) == null ? void 0 : v.value;
|
|
457
|
+
if (j.has(o)) return (m = j.get(o)) == null ? void 0 : m.value;
|
|
458
|
+
if (u.has(o)) return y.value[o];
|
|
459
|
+
const $ = E.get(o);
|
|
460
|
+
return $ ? l($.moduleName)[$.key] : y.value[o];
|
|
457
461
|
},
|
|
458
|
-
set(i,
|
|
459
|
-
if (Reflect.has(i,
|
|
460
|
-
return Reflect.set(i,
|
|
461
|
-
const
|
|
462
|
-
return
|
|
462
|
+
set(i, o, f, v) {
|
|
463
|
+
if (Reflect.has(i, o))
|
|
464
|
+
return Reflect.set(i, o, f, v);
|
|
465
|
+
const m = E.get(o);
|
|
466
|
+
return m ? (q(m.moduleName, m.key, f, "local", v), !0) : (B(o, f, "local", v), !0);
|
|
463
467
|
}
|
|
464
468
|
});
|
|
465
|
-
for (const [i,
|
|
466
|
-
|
|
467
|
-
for (const i of
|
|
468
|
-
(
|
|
469
|
-
return
|
|
469
|
+
for (const [i, o] of Object.entries(x.actions ?? {}))
|
|
470
|
+
F[i] = (...f) => K(() => o.apply(N, f));
|
|
471
|
+
for (const i of r)
|
|
472
|
+
(D = i.onInit) == null || D.call(i, N);
|
|
473
|
+
return a.set(b, N), N;
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function A(b, x) {
|
|
477
|
+
return function() {
|
|
478
|
+
var D;
|
|
479
|
+
const U = `\0machine:${b}`, R = a.get(U);
|
|
480
|
+
if (R) return R;
|
|
481
|
+
const I = `${e}:${b}`, S = tt(x.initial), V = tt((x.context ?? (() => ({})))()), y = /* @__PURE__ */ new Set(), M = (s, u) => {
|
|
482
|
+
var g;
|
|
483
|
+
for (const n of y) n(s);
|
|
484
|
+
for (const n of r)
|
|
485
|
+
(g = n.onMutation) == null || g.call(n, u, s);
|
|
486
|
+
}, Z = (s, u, g, n) => {
|
|
487
|
+
const l = V.value[s];
|
|
488
|
+
Object.is(l, u) || (V.value = { ...V.value, [s]: u }, M({ namespace: e, scopeId: I, storeId: b, key: s, oldValue: l, newValue: u, origin: g }, n));
|
|
489
|
+
}, T = (s, u, g) => {
|
|
490
|
+
const n = S.value;
|
|
491
|
+
Object.is(n, s) || (S.value = s, M(
|
|
492
|
+
{ namespace: e, scopeId: I, storeId: b, key: "$state", oldValue: n, newValue: s, origin: u },
|
|
493
|
+
g
|
|
494
|
+
));
|
|
495
|
+
}, E = {
|
|
496
|
+
$id: b,
|
|
497
|
+
$namespace: e,
|
|
498
|
+
$scopeId: I,
|
|
499
|
+
$subscribe(s) {
|
|
500
|
+
return y.add(s), () => y.delete(s);
|
|
501
|
+
},
|
|
502
|
+
$dispose() {
|
|
503
|
+
var s;
|
|
504
|
+
y.clear();
|
|
505
|
+
for (const u of r)
|
|
506
|
+
(s = u.onDispose) == null || s.call(u, j);
|
|
507
|
+
a.delete(U);
|
|
508
|
+
},
|
|
509
|
+
$patch(s, u = "local") {
|
|
510
|
+
K(() => {
|
|
511
|
+
for (const [g, n] of Object.entries(s))
|
|
512
|
+
g === "$state" ? T(n, u, j) : Z(g, n, u, j);
|
|
513
|
+
});
|
|
514
|
+
},
|
|
515
|
+
$snapshot() {
|
|
516
|
+
return { $state: S.value, ...V.value };
|
|
517
|
+
},
|
|
518
|
+
send(s, u) {
|
|
519
|
+
K(() => {
|
|
520
|
+
var g, n, l;
|
|
521
|
+
const w = (g = x.actions) == null ? void 0 : g[s];
|
|
522
|
+
w && w.call(j, u);
|
|
523
|
+
const O = (l = (n = x.states[S.value]) == null ? void 0 : n.on) == null ? void 0 : l[s];
|
|
524
|
+
O !== void 0 && T(O, "local", j);
|
|
525
|
+
});
|
|
526
|
+
},
|
|
527
|
+
matches(s) {
|
|
528
|
+
return S.value === s;
|
|
529
|
+
},
|
|
530
|
+
can(s) {
|
|
531
|
+
const u = x.states[S.value];
|
|
532
|
+
return !!(u != null && u.on && s in u.on);
|
|
533
|
+
}
|
|
534
|
+
}, j = new Proxy(E, {
|
|
535
|
+
get(s, u, g) {
|
|
536
|
+
return u === "state" ? S.value : Reflect.has(s, u) ? Reflect.get(s, u, g) : V.value[u];
|
|
537
|
+
},
|
|
538
|
+
set(s, u, g, n) {
|
|
539
|
+
return u === "state" ? !1 : Reflect.has(s, u) ? Reflect.set(s, u, g, n) : (Z(u, g, "local", n), !0);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
for (const s of r)
|
|
543
|
+
(D = s.onInit) == null || D.call(s, j);
|
|
544
|
+
return a.set(U, j), j;
|
|
470
545
|
};
|
|
471
546
|
}
|
|
472
547
|
return {
|
|
473
548
|
defineStore: h,
|
|
474
|
-
|
|
475
|
-
|
|
549
|
+
defineMachine: A,
|
|
550
|
+
use(b) {
|
|
551
|
+
r.push(b);
|
|
476
552
|
}
|
|
477
553
|
};
|
|
478
554
|
}
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
function
|
|
482
|
-
if (!
|
|
483
|
-
const e = /* @__PURE__ */ new WeakSet(),
|
|
484
|
-
if (!
|
|
485
|
-
const h =
|
|
555
|
+
St();
|
|
556
|
+
const H = (t) => t !== null && typeof t == "object";
|
|
557
|
+
function jt(t) {
|
|
558
|
+
if (!H(t)) return t;
|
|
559
|
+
const e = /* @__PURE__ */ new WeakSet(), r = (a) => {
|
|
560
|
+
if (!H(a)) return;
|
|
561
|
+
const h = a;
|
|
486
562
|
if (e.has(h)) return;
|
|
487
563
|
e.add(h);
|
|
488
|
-
const
|
|
489
|
-
for (const
|
|
490
|
-
const
|
|
491
|
-
|
|
564
|
+
const A = Reflect.ownKeys(h);
|
|
565
|
+
for (const b of A) {
|
|
566
|
+
const x = Reflect.get(h, b);
|
|
567
|
+
r(x);
|
|
492
568
|
}
|
|
493
569
|
Object.freeze(h);
|
|
494
570
|
};
|
|
495
|
-
return
|
|
571
|
+
return r(t), t;
|
|
496
572
|
}
|
|
497
|
-
function
|
|
498
|
-
for (const [
|
|
499
|
-
t[
|
|
573
|
+
function kt(t, e) {
|
|
574
|
+
for (const [r, a] of Object.entries(e))
|
|
575
|
+
t[r] = a;
|
|
500
576
|
}
|
|
501
|
-
const
|
|
577
|
+
const ft = (t) => Object.keys(t).length > 0, lt = (t) => t ? Array.isArray(t) ? t : [t] : [], Ot = (t) => {
|
|
502
578
|
const e = [t];
|
|
503
579
|
if (t.includes(".")) {
|
|
504
|
-
const
|
|
505
|
-
|
|
580
|
+
const r = t.split(".", 1)[0];
|
|
581
|
+
r && r !== t && e.push(r);
|
|
506
582
|
}
|
|
507
583
|
return e;
|
|
508
|
-
},
|
|
509
|
-
if (!e || !
|
|
584
|
+
}, $t = (t, e) => {
|
|
585
|
+
if (!e || !H(t)) return t;
|
|
510
586
|
try {
|
|
511
587
|
Object.defineProperty(t, e, {
|
|
512
588
|
value: !0,
|
|
@@ -518,109 +594,109 @@ const ot = (t) => Object.keys(t).length > 0, st = (t) => t ? Array.isArray(t) ?
|
|
|
518
594
|
}
|
|
519
595
|
return t;
|
|
520
596
|
};
|
|
521
|
-
function
|
|
522
|
-
const e = t.mutationType ?? "storix/APPLY_PATCH",
|
|
597
|
+
function Mt(t) {
|
|
598
|
+
const e = t.mutationType ?? "storix/APPLY_PATCH", r = t.immutable ?? !0, a = t.clone ?? gt, h = t.equals ?? rt, A = t.projectVuexToStorix ?? ((n) => n), b = t.projectStorixToVuex ?? ((n) => n), x = t.suppressBridgeEcho ?? !1, D = t.bridgeOriginKey ?? "__storixBridge", U = t.outboundDefault ?? {
|
|
523
599
|
mode: "patch",
|
|
524
600
|
type: e
|
|
525
|
-
},
|
|
526
|
-
const
|
|
527
|
-
return
|
|
601
|
+
}, R = (n) => {
|
|
602
|
+
const l = a(n);
|
|
603
|
+
return r ? jt(l) : l;
|
|
528
604
|
};
|
|
529
|
-
let
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
-
for (const
|
|
533
|
-
const
|
|
534
|
-
|
|
605
|
+
let I = !1, S = !1, V = !1;
|
|
606
|
+
const y = /* @__PURE__ */ new Map(), M = (n) => {
|
|
607
|
+
if (x)
|
|
608
|
+
for (const l of n) {
|
|
609
|
+
const w = y.get(l) ?? 0;
|
|
610
|
+
y.set(l, w + 1);
|
|
535
611
|
}
|
|
536
|
-
},
|
|
537
|
-
if (!
|
|
538
|
-
const
|
|
539
|
-
if (
|
|
612
|
+
}, Z = (n) => {
|
|
613
|
+
if (!x || !H(n)) return !1;
|
|
614
|
+
const l = Reflect.get(n, "payload");
|
|
615
|
+
if (D && H(l) && Reflect.get(l, D))
|
|
540
616
|
return !0;
|
|
541
|
-
const
|
|
542
|
-
if (typeof
|
|
543
|
-
const
|
|
544
|
-
return
|
|
545
|
-
},
|
|
546
|
-
if (
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
549
|
-
|
|
617
|
+
const w = Reflect.get(n, "type");
|
|
618
|
+
if (typeof w != "string") return !1;
|
|
619
|
+
const O = y.get(w) ?? 0;
|
|
620
|
+
return O <= 0 ? !1 : (O === 1 ? y.delete(w) : y.set(w, O - 1), !0);
|
|
621
|
+
}, T = () => {
|
|
622
|
+
if (I || V) return;
|
|
623
|
+
const n = R(A(t.vuex.state)), l = t.store.$snapshot(), w = ct(l, n, h, R);
|
|
624
|
+
if (ft(w)) {
|
|
625
|
+
S = !0;
|
|
550
626
|
try {
|
|
551
|
-
t.store.$patch(
|
|
627
|
+
t.store.$patch(w, t.externalMutationOrigin ?? "local");
|
|
552
628
|
} finally {
|
|
553
|
-
|
|
629
|
+
S = !1;
|
|
554
630
|
}
|
|
555
631
|
}
|
|
556
|
-
},
|
|
557
|
-
const
|
|
558
|
-
var
|
|
559
|
-
return
|
|
632
|
+
}, E = (n) => {
|
|
633
|
+
const w = Ot(n.storixMutation.key).flatMap((O) => {
|
|
634
|
+
var P;
|
|
635
|
+
return lt((P = t.outboundRoutes) == null ? void 0 : P[O]);
|
|
560
636
|
});
|
|
561
|
-
return
|
|
562
|
-
},
|
|
563
|
-
var
|
|
564
|
-
if (
|
|
565
|
-
(
|
|
637
|
+
return w.push(...lt(U)), w.find((O) => O.when ? O.when(n) : !0);
|
|
638
|
+
}, j = (n, l) => {
|
|
639
|
+
var B;
|
|
640
|
+
if (n.mode === "custom") {
|
|
641
|
+
(B = n.handler) == null || B.call(n, l), M(n.suppressMutationTypes ?? []);
|
|
566
642
|
return;
|
|
567
643
|
}
|
|
568
|
-
const
|
|
569
|
-
if (
|
|
644
|
+
const w = l.projectedPatch, O = $t(R(n.mapPayload ? n.mapPayload(l) : w), D);
|
|
645
|
+
if (n.mode === "dispatch") {
|
|
570
646
|
if (typeof t.vuex.dispatch != "function")
|
|
571
647
|
throw new Error('Vuex bridge route mode "dispatch" requires vuex.dispatch to be available.');
|
|
572
|
-
if (!
|
|
648
|
+
if (!n.type)
|
|
573
649
|
throw new Error('Vuex bridge dispatch route requires a "type".');
|
|
574
|
-
t.vuex.dispatch(
|
|
650
|
+
t.vuex.dispatch(n.type, O), M(n.suppressMutationTypes ?? []);
|
|
575
651
|
return;
|
|
576
652
|
}
|
|
577
|
-
const
|
|
578
|
-
t.vuex.commit(
|
|
579
|
-
},
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
if (!
|
|
583
|
-
const
|
|
584
|
-
storixMutation:
|
|
653
|
+
const P = n.type ?? e;
|
|
654
|
+
t.vuex.commit(P, O), M(n.suppressMutationTypes ?? [P]);
|
|
655
|
+
}, s = (n) => {
|
|
656
|
+
if (I || S) return;
|
|
657
|
+
const l = t.store.$snapshot(), w = R(b(l)), O = R(A(t.vuex.state)), P = ct(O, w, h, R);
|
|
658
|
+
if (!ft(P)) return;
|
|
659
|
+
const B = {
|
|
660
|
+
storixMutation: n ?? {
|
|
585
661
|
namespace: t.store.$namespace,
|
|
586
662
|
scopeId: t.store.$scopeId,
|
|
587
663
|
storeId: t.store.$id,
|
|
588
|
-
key: Object.keys(
|
|
664
|
+
key: Object.keys(P)[0] ?? "*",
|
|
589
665
|
oldValue: void 0,
|
|
590
666
|
newValue: void 0,
|
|
591
667
|
origin: "local"
|
|
592
668
|
},
|
|
593
|
-
storixSnapshot:
|
|
669
|
+
storixSnapshot: l,
|
|
594
670
|
vuexState: t.vuex.state,
|
|
595
|
-
projectedPatch:
|
|
596
|
-
projectedVuexState:
|
|
671
|
+
projectedPatch: P,
|
|
672
|
+
projectedVuexState: w,
|
|
597
673
|
origin: "storix"
|
|
598
|
-
},
|
|
599
|
-
if (
|
|
600
|
-
|
|
674
|
+
}, q = E(B);
|
|
675
|
+
if (q) {
|
|
676
|
+
V = !0;
|
|
601
677
|
try {
|
|
602
|
-
|
|
678
|
+
j(q, B);
|
|
603
679
|
} finally {
|
|
604
|
-
|
|
680
|
+
V = !1;
|
|
605
681
|
}
|
|
606
682
|
}
|
|
607
|
-
},
|
|
608
|
-
|
|
609
|
-
}),
|
|
610
|
-
|
|
683
|
+
}, u = t.vuex.subscribe((n) => {
|
|
684
|
+
Z(n) || T();
|
|
685
|
+
}), g = t.store.$subscribe((n) => {
|
|
686
|
+
s(n);
|
|
611
687
|
});
|
|
612
|
-
return
|
|
688
|
+
return T(), {
|
|
613
689
|
dispose() {
|
|
614
|
-
|
|
690
|
+
I || (I = !0, u(), g());
|
|
615
691
|
},
|
|
616
|
-
syncFromExternal:
|
|
692
|
+
syncFromExternal: T,
|
|
617
693
|
syncFromStore() {
|
|
618
|
-
|
|
694
|
+
s();
|
|
619
695
|
}
|
|
620
696
|
};
|
|
621
697
|
}
|
|
622
698
|
export {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
699
|
+
kt as applyVuexPatchMutation,
|
|
700
|
+
Mt as createVuexBridge,
|
|
701
|
+
jt as deepFreeze
|
|
626
702
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storix-js/vuex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -26,6 +26,6 @@
|
|
|
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
|
}
|
package/dist/index.test.d.ts
DELETED
package/dist/index.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|