@storix-js/vuex 0.2.0 → 0.2.1
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 +100 -654
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@storix-js/core"),d=e=>e!==null&&typeof e=="object";function R(e){if(!d(e))return e;const n=new WeakSet,o=i=>{if(!d(i))return;const a=i;if(n.has(a))return;n.add(a);const y=Reflect.ownKeys(a);for(const g of y){const h=Reflect.get(a,g);o(h)}Object.freeze(a)};return o(e),e}function q(e,n){for(const[o,i]of Object.entries(n))e[o]=i}const T=e=>Object.keys(e).length>0,k=e=>e?Array.isArray(e)?e:[e]:[],z=e=>{const n=[e];if(e.includes(".")){const o=e.split(".",1)[0];o&&o!==e&&n.push(o)}return n},A=(e,n)=>{if(!n||!d(e))return e;try{Object.defineProperty(e,n,{value:!0,enumerable:!1,configurable:!0})}catch{return e}return e};function C(e){const n=e.mutationType??"storix/APPLY_PATCH",o=e.immutable??!0,i=e.clone??b.isolateSnapshot,a=e.equals??b.deepEqual,y=e.projectVuexToStorix??(t=>t),g=e.projectStorixToVuex??(t=>t),h=e.suppressBridgeEcho??!1,S=e.bridgeOriginKey??"__storixBridge",w=e.outboundDefault??{mode:"patch",type:n},l=t=>{const r=i(t);return o?R(r):r};let x=!1,m=!1,j=!1;const f=new Map,P=t=>{if(h)for(const r of t){const s=f.get(r)??0;f.set(r,s+1)}},O=t=>{if(!h||!d(t))return!1;const r=Reflect.get(t,"payload");if(S&&d(r)&&Reflect.get(r,S))return!0;const s=Reflect.get(t,"type");if(typeof s!="string")return!1;const c=f.get(s)??0;return c<=0?!1:(c===1?f.delete(s):f.set(s,c-1),!0)},v=()=>{if(x||j)return;const t=l(y(e.vuex.state)),r=e.store.$snapshot(),s=b.createPatchFromSnapshot(r,t,a,l);if(T(s)){m=!0;try{e.store.$patch(s,e.externalMutationOrigin??"local")}finally{m=!1}}},E=t=>{const s=z(t.storixMutation.key).flatMap(c=>{var u;return k((u=e.outboundRoutes)==null?void 0:u[c])});return s.push(...k(w)),s.find(c=>c.when?c.when(t):!0)},B=(t,r)=>{var p;if(t.mode==="custom"){(p=t.handler)==null||p.call(t,r),P(t.suppressMutationTypes??[]);return}const s=r.projectedPatch,c=A(l(t.mapPayload?t.mapPayload(r):s),S);if(t.mode==="dispatch"){if(typeof e.vuex.dispatch!="function")throw new Error('Vuex bridge route mode "dispatch" requires vuex.dispatch to be available.');if(!t.type)throw new Error('Vuex bridge dispatch route requires a "type".');e.vuex.dispatch(t.type,c),P(t.suppressMutationTypes??[]);return}const u=t.type??n;e.vuex.commit(u,c),P(t.suppressMutationTypes??[u])},M=t=>{if(x||m)return;const r=e.store.$snapshot(),s=l(g(r)),c=l(y(e.vuex.state)),u=b.createPatchFromSnapshot(c,s,a,l);if(!T(u))return;const p={storixMutation:t??{namespace:e.store.$namespace,scopeId:e.store.$scopeId,storeId:e.store.$id,key:Object.keys(u)[0]??"*",oldValue:void 0,newValue:void 0,origin:"local"},storixSnapshot:r,vuexState:e.vuex.state,projectedPatch:u,projectedVuexState:s,origin:"storix"},V=E(p);if(V){j=!0;try{B(V,p)}finally{j=!1}}},F=e.vuex.subscribe(t=>{O(t)||v()}),$=e.store.$subscribe(t=>{M(t)});return v(),{dispose(){x||(x=!0,F(),$())},syncFromExternal:v,syncFromStore(){M()}}}exports.applyVuexPatchMutation=q;exports.createVuexBridge=C;exports.deepFreeze=R;
|
package/dist/index.js
CHANGED
|
@@ -1,702 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var a = r.u;
|
|
15
|
-
if (r.u = void 0, r.f &= -3, !(8 & r.f) && vt(r)) try {
|
|
16
|
-
r.c();
|
|
17
|
-
} catch (h) {
|
|
18
|
-
e || (t = h, e = !0);
|
|
19
|
-
}
|
|
20
|
-
r = a;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (Y = 0, z--, e) throw t;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function K(t) {
|
|
27
|
-
if (z > 0) return t();
|
|
28
|
-
et = ++wt, z++;
|
|
29
|
-
try {
|
|
30
|
-
return t();
|
|
31
|
-
} finally {
|
|
32
|
-
X();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
var p = void 0;
|
|
36
|
-
function nt(t) {
|
|
37
|
-
var e = p;
|
|
38
|
-
p = void 0;
|
|
39
|
-
try {
|
|
40
|
-
return t();
|
|
41
|
-
} finally {
|
|
42
|
-
p = e;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
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) {
|
|
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;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
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;
|
|
57
|
-
}
|
|
58
|
-
k.prototype.brand = bt;
|
|
59
|
-
k.prototype.h = function() {
|
|
60
|
-
return !0;
|
|
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);
|
|
67
|
-
}));
|
|
68
|
-
};
|
|
69
|
-
k.prototype.U = function(t) {
|
|
70
|
-
var e = this;
|
|
71
|
-
if (this.t !== void 0) {
|
|
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() {
|
|
74
|
-
var h;
|
|
75
|
-
(h = e.Z) == null || h.call(e);
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
k.prototype.subscribe = function(t) {
|
|
80
|
-
var e = this;
|
|
81
|
-
return xt(function() {
|
|
82
|
-
var r = e.value, a = p;
|
|
83
|
-
p = void 0;
|
|
84
|
-
try {
|
|
85
|
-
t(r);
|
|
86
|
-
} finally {
|
|
87
|
-
p = a;
|
|
88
|
-
}
|
|
89
|
-
}, { name: "sub" });
|
|
90
|
-
};
|
|
91
|
-
k.prototype.valueOf = function() {
|
|
92
|
-
return this.value;
|
|
93
|
-
};
|
|
94
|
-
k.prototype.toString = function() {
|
|
95
|
-
return this.value + "";
|
|
96
|
-
};
|
|
97
|
-
k.prototype.toJSON = function() {
|
|
98
|
-
return this.value;
|
|
99
|
-
};
|
|
100
|
-
k.prototype.peek = function() {
|
|
101
|
-
var t = this;
|
|
102
|
-
return nt(function() {
|
|
103
|
-
return t.value;
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
Object.defineProperty(k.prototype, "value", { get: function() {
|
|
107
|
-
var t = ht(this);
|
|
108
|
-
return t !== void 0 && (t.i = this.i), this.v;
|
|
109
|
-
}, set: function(t) {
|
|
110
|
-
if (t !== this.v) {
|
|
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++;
|
|
115
|
-
try {
|
|
116
|
-
for (var e = this.t; e !== void 0; e = e.x) e.t.N();
|
|
117
|
-
} finally {
|
|
118
|
-
X();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} });
|
|
122
|
-
function tt(t, e) {
|
|
123
|
-
return new k(t, e);
|
|
124
|
-
}
|
|
125
|
-
function vt(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;
|
|
127
|
-
return !1;
|
|
128
|
-
}
|
|
129
|
-
function dt(t) {
|
|
130
|
-
for (var e = t.s; e !== void 0; e = e.n) {
|
|
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) {
|
|
133
|
-
t.s = e;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
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;
|
|
142
|
-
}
|
|
143
|
-
t.s = r;
|
|
144
|
-
}
|
|
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;
|
|
147
|
-
}
|
|
148
|
-
W.prototype = new k();
|
|
149
|
-
W.prototype.h = function() {
|
|
150
|
-
if (this.f &= -3, 1 & this.f) return !1;
|
|
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))
|
|
153
|
-
return this.f &= -2, !0;
|
|
154
|
-
var t = p;
|
|
155
|
-
try {
|
|
156
|
-
dt(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 (r) {
|
|
160
|
-
this.v = r, this.f |= 16, this.i++;
|
|
161
|
-
}
|
|
162
|
-
return p = t, pt(this), this.f &= -2, !0;
|
|
163
|
-
};
|
|
164
|
-
W.prototype.S = function(t) {
|
|
165
|
-
if (this.t === void 0) {
|
|
166
|
-
this.f |= 36;
|
|
167
|
-
for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
|
|
168
|
-
}
|
|
169
|
-
k.prototype.S.call(this, t);
|
|
170
|
-
};
|
|
171
|
-
W.prototype.U = function(t) {
|
|
172
|
-
if (this.t !== void 0 && (k.prototype.U.call(this, t), this.t === void 0)) {
|
|
173
|
-
this.f &= -33;
|
|
174
|
-
for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
W.prototype.N = function() {
|
|
178
|
-
if (!(2 & this.f)) {
|
|
179
|
-
this.f |= 6;
|
|
180
|
-
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
Object.defineProperty(W.prototype, "value", { get: function() {
|
|
184
|
-
if (1 & this.f) throw new Error("Cycle detected");
|
|
185
|
-
var t = ht(this);
|
|
186
|
-
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f) throw this.v;
|
|
187
|
-
return this.v;
|
|
188
|
-
} });
|
|
189
|
-
function at(t, e) {
|
|
190
|
-
return new W(t, e);
|
|
191
|
-
}
|
|
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;
|
|
198
|
-
try {
|
|
199
|
-
e();
|
|
200
|
-
} catch (a) {
|
|
201
|
-
throw t.f &= -2, t.f |= 8, ot(t), a;
|
|
202
|
-
} finally {
|
|
203
|
-
p = r, X();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function ot(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, yt(t);
|
|
210
|
-
}
|
|
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();
|
|
214
|
-
}
|
|
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;
|
|
217
|
-
}
|
|
218
|
-
J.prototype.c = function() {
|
|
219
|
-
var t = this.S();
|
|
220
|
-
try {
|
|
221
|
-
if (8 & this.f || this.x === void 0) return;
|
|
222
|
-
var e = this.x();
|
|
223
|
-
typeof e == "function" && (this.m = e);
|
|
224
|
-
} finally {
|
|
225
|
-
t();
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
J.prototype.S = function() {
|
|
229
|
-
if (1 & this.f) throw new Error("Cycle detected");
|
|
230
|
-
this.f |= 1, this.f &= -9, yt(this), dt(this), z++;
|
|
231
|
-
var t = p;
|
|
232
|
-
return p = this, mt.bind(this, t);
|
|
233
|
-
};
|
|
234
|
-
J.prototype.N = function() {
|
|
235
|
-
2 & this.f || (this.f |= 2, this.u = _, _ = this);
|
|
236
|
-
};
|
|
237
|
-
J.prototype.d = function() {
|
|
238
|
-
this.f |= 8, 1 & this.f || ot(this);
|
|
239
|
-
};
|
|
240
|
-
J.prototype.dispose = function() {
|
|
241
|
-
this.d();
|
|
242
|
-
};
|
|
243
|
-
function xt(t, e) {
|
|
244
|
-
var r = new J(t, e);
|
|
245
|
-
try {
|
|
246
|
-
r.c();
|
|
247
|
-
} catch (h) {
|
|
248
|
-
throw r.d(), h;
|
|
249
|
-
}
|
|
250
|
-
var a = r.d.bind(r);
|
|
251
|
-
return a[Symbol.dispose] = a, a;
|
|
252
|
-
}
|
|
253
|
-
const ut = (t) => t !== null && typeof t == "object" && !Array.isArray(t);
|
|
254
|
-
function rt(t, e) {
|
|
255
|
-
if (Object.is(t, e)) return !0;
|
|
256
|
-
if (t instanceof Date && e instanceof Date)
|
|
257
|
-
return t.getTime() === e.getTime();
|
|
258
|
-
if (Array.isArray(t) && Array.isArray(e)) {
|
|
259
|
-
if (t.length !== e.length) return !1;
|
|
260
|
-
for (let r = 0; r < t.length; r += 1)
|
|
261
|
-
if (!rt(t[r], e[r])) return !1;
|
|
262
|
-
return !0;
|
|
263
|
-
}
|
|
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;
|
|
269
|
-
return !0;
|
|
270
|
-
}
|
|
271
|
-
return !1;
|
|
272
|
-
}
|
|
273
|
-
function gt(t) {
|
|
274
|
-
if (typeof structuredClone == "function")
|
|
275
|
-
return structuredClone(t);
|
|
276
|
-
try {
|
|
277
|
-
return JSON.parse(JSON.stringify(t));
|
|
278
|
-
} catch {
|
|
279
|
-
return t;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
function ct(t, e, r = Object.is, a = gt) {
|
|
283
|
-
const h = {};
|
|
284
|
-
for (const [A, b] of Object.entries(e)) {
|
|
285
|
-
const x = t[A];
|
|
286
|
-
r(x, b, A) || (h[A] = a(b));
|
|
287
|
-
}
|
|
288
|
-
return h;
|
|
289
|
-
}
|
|
290
|
-
function St(t = {}) {
|
|
291
|
-
const e = (t.namespace ?? "default").trim() || "default", r = t.plugins ?? [], a = /* @__PURE__ */ new Map();
|
|
292
|
-
function h(b, x) {
|
|
293
|
-
return function() {
|
|
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
|
|
304
|
-
};
|
|
305
|
-
}, O = new Proxy(
|
|
306
|
-
{},
|
|
307
|
-
{
|
|
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];
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
);
|
|
318
|
-
for (const [i, o] of Object.entries(x.getters ?? {}))
|
|
319
|
-
M.set(
|
|
320
|
-
i,
|
|
321
|
-
at(() => o(y.value, O))
|
|
322
|
-
);
|
|
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(
|
|
334
|
-
{
|
|
335
|
-
namespace: e,
|
|
336
|
-
scopeId: U,
|
|
337
|
-
storeId: b,
|
|
338
|
-
key: i,
|
|
339
|
-
oldValue: m,
|
|
340
|
-
newValue: o,
|
|
341
|
-
origin: f
|
|
342
|
-
},
|
|
343
|
-
v
|
|
344
|
-
));
|
|
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(
|
|
351
|
-
{
|
|
352
|
-
namespace: e,
|
|
353
|
-
scopeId: U,
|
|
354
|
-
storeId: b,
|
|
355
|
-
key: `${i}.${o}`,
|
|
356
|
-
oldValue: c,
|
|
357
|
-
newValue: f,
|
|
358
|
-
origin: v
|
|
359
|
-
},
|
|
360
|
-
m
|
|
361
|
-
));
|
|
362
|
-
}, F = {
|
|
363
|
-
$id: b,
|
|
364
|
-
$namespace: e,
|
|
365
|
-
$scopeId: U,
|
|
366
|
-
$subscribe(i) {
|
|
367
|
-
return s.add(i), () => s.delete(i);
|
|
368
|
-
},
|
|
369
|
-
$dispose() {
|
|
370
|
-
var i;
|
|
371
|
-
s.clear();
|
|
372
|
-
for (const o of r)
|
|
373
|
-
(i = o.onDispose) == null || i.call(o, N);
|
|
374
|
-
a.delete(b);
|
|
375
|
-
},
|
|
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);
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
|
-
if (f.includes(".")) {
|
|
385
|
-
const [$, c] = f.split(".", 2);
|
|
386
|
-
if (S[$]) {
|
|
387
|
-
q($, c, v, o, N);
|
|
388
|
-
continue;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
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);
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
396
|
-
B(f, v, o, N);
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
},
|
|
400
|
-
$snapshot() {
|
|
401
|
-
return { ...y.value };
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
for (const [i, o] of Object.entries(S)) {
|
|
405
|
-
const f = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), m = new Proxy(
|
|
406
|
-
{},
|
|
407
|
-
{
|
|
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];
|
|
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))
|
|
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(
|
|
428
|
-
{},
|
|
429
|
-
{
|
|
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];
|
|
436
|
-
},
|
|
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;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
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);
|
|
450
|
-
}
|
|
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];
|
|
461
|
-
},
|
|
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);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
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;
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
return {
|
|
548
|
-
defineStore: h,
|
|
549
|
-
defineMachine: A,
|
|
550
|
-
use(b) {
|
|
551
|
-
r.push(b);
|
|
1
|
+
import { isolateSnapshot as q, deepEqual as F, createPatchFromSnapshot as T } from "@storix-js/core";
|
|
2
|
+
const d = (e) => e !== null && typeof e == "object";
|
|
3
|
+
function z(e) {
|
|
4
|
+
if (!d(e)) return e;
|
|
5
|
+
const n = /* @__PURE__ */ new WeakSet(), o = (i) => {
|
|
6
|
+
if (!d(i)) return;
|
|
7
|
+
const a = i;
|
|
8
|
+
if (n.has(a)) return;
|
|
9
|
+
n.add(a);
|
|
10
|
+
const y = Reflect.ownKeys(a);
|
|
11
|
+
for (const b of y) {
|
|
12
|
+
const h = Reflect.get(a, b);
|
|
13
|
+
o(h);
|
|
552
14
|
}
|
|
15
|
+
Object.freeze(a);
|
|
553
16
|
};
|
|
17
|
+
return o(e), e;
|
|
554
18
|
}
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
if (!H(t)) return t;
|
|
559
|
-
const e = /* @__PURE__ */ new WeakSet(), r = (a) => {
|
|
560
|
-
if (!H(a)) return;
|
|
561
|
-
const h = a;
|
|
562
|
-
if (e.has(h)) return;
|
|
563
|
-
e.add(h);
|
|
564
|
-
const A = Reflect.ownKeys(h);
|
|
565
|
-
for (const b of A) {
|
|
566
|
-
const x = Reflect.get(h, b);
|
|
567
|
-
r(x);
|
|
568
|
-
}
|
|
569
|
-
Object.freeze(h);
|
|
570
|
-
};
|
|
571
|
-
return r(t), t;
|
|
572
|
-
}
|
|
573
|
-
function kt(t, e) {
|
|
574
|
-
for (const [r, a] of Object.entries(e))
|
|
575
|
-
t[r] = a;
|
|
19
|
+
function I(e, n) {
|
|
20
|
+
for (const [o, i] of Object.entries(n))
|
|
21
|
+
e[o] = i;
|
|
576
22
|
}
|
|
577
|
-
const
|
|
578
|
-
const
|
|
579
|
-
if (
|
|
580
|
-
const
|
|
581
|
-
|
|
23
|
+
const V = (e) => Object.keys(e).length > 0, k = (e) => e ? Array.isArray(e) ? e : [e] : [], A = (e) => {
|
|
24
|
+
const n = [e];
|
|
25
|
+
if (e.includes(".")) {
|
|
26
|
+
const o = e.split(".", 1)[0];
|
|
27
|
+
o && o !== e && n.push(o);
|
|
582
28
|
}
|
|
583
|
-
return
|
|
584
|
-
},
|
|
585
|
-
if (!
|
|
29
|
+
return n;
|
|
30
|
+
}, C = (e, n) => {
|
|
31
|
+
if (!n || !d(e)) return e;
|
|
586
32
|
try {
|
|
587
|
-
Object.defineProperty(
|
|
33
|
+
Object.defineProperty(e, n, {
|
|
588
34
|
value: !0,
|
|
589
35
|
enumerable: !1,
|
|
590
36
|
configurable: !0
|
|
591
37
|
});
|
|
592
38
|
} catch {
|
|
593
|
-
return
|
|
39
|
+
return e;
|
|
594
40
|
}
|
|
595
|
-
return
|
|
41
|
+
return e;
|
|
596
42
|
};
|
|
597
|
-
function
|
|
598
|
-
const
|
|
43
|
+
function K(e) {
|
|
44
|
+
const n = e.mutationType ?? "storix/APPLY_PATCH", o = e.immutable ?? !0, i = e.clone ?? q, a = e.equals ?? F, y = e.projectVuexToStorix ?? ((t) => t), b = e.projectStorixToVuex ?? ((t) => t), h = e.suppressBridgeEcho ?? !1, g = e.bridgeOriginKey ?? "__storixBridge", R = e.outboundDefault ?? {
|
|
599
45
|
mode: "patch",
|
|
600
|
-
type:
|
|
601
|
-
},
|
|
602
|
-
const
|
|
603
|
-
return
|
|
46
|
+
type: n
|
|
47
|
+
}, l = (t) => {
|
|
48
|
+
const r = i(t);
|
|
49
|
+
return o ? z(r) : r;
|
|
604
50
|
};
|
|
605
|
-
let
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
608
|
-
for (const
|
|
609
|
-
const
|
|
610
|
-
|
|
51
|
+
let x = !1, S = !1, m = !1;
|
|
52
|
+
const f = /* @__PURE__ */ new Map(), j = (t) => {
|
|
53
|
+
if (h)
|
|
54
|
+
for (const r of t) {
|
|
55
|
+
const s = f.get(r) ?? 0;
|
|
56
|
+
f.set(r, s + 1);
|
|
611
57
|
}
|
|
612
|
-
},
|
|
613
|
-
if (!
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
58
|
+
}, w = (t) => {
|
|
59
|
+
if (!h || !d(t)) return !1;
|
|
60
|
+
const r = Reflect.get(t, "payload");
|
|
61
|
+
if (g && d(r) && Reflect.get(r, g))
|
|
616
62
|
return !0;
|
|
617
|
-
const
|
|
618
|
-
if (typeof
|
|
619
|
-
const
|
|
620
|
-
return
|
|
621
|
-
},
|
|
622
|
-
if (
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
63
|
+
const s = Reflect.get(t, "type");
|
|
64
|
+
if (typeof s != "string") return !1;
|
|
65
|
+
const c = f.get(s) ?? 0;
|
|
66
|
+
return c <= 0 ? !1 : (c === 1 ? f.delete(s) : f.set(s, c - 1), !0);
|
|
67
|
+
}, v = () => {
|
|
68
|
+
if (x || m) return;
|
|
69
|
+
const t = l(y(e.vuex.state)), r = e.store.$snapshot(), s = T(r, t, a, l);
|
|
70
|
+
if (V(s)) {
|
|
625
71
|
S = !0;
|
|
626
72
|
try {
|
|
627
|
-
|
|
73
|
+
e.store.$patch(s, e.externalMutationOrigin ?? "local");
|
|
628
74
|
} finally {
|
|
629
75
|
S = !1;
|
|
630
76
|
}
|
|
631
77
|
}
|
|
632
|
-
}, E = (
|
|
633
|
-
const
|
|
634
|
-
var
|
|
635
|
-
return
|
|
78
|
+
}, E = (t) => {
|
|
79
|
+
const s = A(t.storixMutation.key).flatMap((c) => {
|
|
80
|
+
var u;
|
|
81
|
+
return k((u = e.outboundRoutes) == null ? void 0 : u[c]);
|
|
636
82
|
});
|
|
637
|
-
return
|
|
638
|
-
},
|
|
639
|
-
var
|
|
640
|
-
if (
|
|
641
|
-
(
|
|
83
|
+
return s.push(...k(R)), s.find((c) => c.when ? c.when(t) : !0);
|
|
84
|
+
}, O = (t, r) => {
|
|
85
|
+
var p;
|
|
86
|
+
if (t.mode === "custom") {
|
|
87
|
+
(p = t.handler) == null || p.call(t, r), j(t.suppressMutationTypes ?? []);
|
|
642
88
|
return;
|
|
643
89
|
}
|
|
644
|
-
const
|
|
645
|
-
if (
|
|
646
|
-
if (typeof
|
|
90
|
+
const s = r.projectedPatch, c = C(l(t.mapPayload ? t.mapPayload(r) : s), g);
|
|
91
|
+
if (t.mode === "dispatch") {
|
|
92
|
+
if (typeof e.vuex.dispatch != "function")
|
|
647
93
|
throw new Error('Vuex bridge route mode "dispatch" requires vuex.dispatch to be available.');
|
|
648
|
-
if (!
|
|
94
|
+
if (!t.type)
|
|
649
95
|
throw new Error('Vuex bridge dispatch route requires a "type".');
|
|
650
|
-
|
|
96
|
+
e.vuex.dispatch(t.type, c), j(t.suppressMutationTypes ?? []);
|
|
651
97
|
return;
|
|
652
98
|
}
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
},
|
|
656
|
-
if (
|
|
657
|
-
const
|
|
658
|
-
if (!
|
|
659
|
-
const
|
|
660
|
-
storixMutation:
|
|
661
|
-
namespace:
|
|
662
|
-
scopeId:
|
|
663
|
-
storeId:
|
|
664
|
-
key: Object.keys(
|
|
99
|
+
const u = t.type ?? n;
|
|
100
|
+
e.vuex.commit(u, c), j(t.suppressMutationTypes ?? [u]);
|
|
101
|
+
}, M = (t) => {
|
|
102
|
+
if (x || S) return;
|
|
103
|
+
const r = e.store.$snapshot(), s = l(b(r)), c = l(y(e.vuex.state)), u = T(c, s, a, l);
|
|
104
|
+
if (!V(u)) return;
|
|
105
|
+
const p = {
|
|
106
|
+
storixMutation: t ?? {
|
|
107
|
+
namespace: e.store.$namespace,
|
|
108
|
+
scopeId: e.store.$scopeId,
|
|
109
|
+
storeId: e.store.$id,
|
|
110
|
+
key: Object.keys(u)[0] ?? "*",
|
|
665
111
|
oldValue: void 0,
|
|
666
112
|
newValue: void 0,
|
|
667
113
|
origin: "local"
|
|
668
114
|
},
|
|
669
|
-
storixSnapshot:
|
|
670
|
-
vuexState:
|
|
671
|
-
projectedPatch:
|
|
672
|
-
projectedVuexState:
|
|
115
|
+
storixSnapshot: r,
|
|
116
|
+
vuexState: e.vuex.state,
|
|
117
|
+
projectedPatch: u,
|
|
118
|
+
projectedVuexState: s,
|
|
673
119
|
origin: "storix"
|
|
674
|
-
},
|
|
675
|
-
if (
|
|
676
|
-
|
|
120
|
+
}, P = E(p);
|
|
121
|
+
if (P) {
|
|
122
|
+
m = !0;
|
|
677
123
|
try {
|
|
678
|
-
|
|
124
|
+
O(P, p);
|
|
679
125
|
} finally {
|
|
680
|
-
|
|
126
|
+
m = !1;
|
|
681
127
|
}
|
|
682
128
|
}
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
}),
|
|
686
|
-
|
|
129
|
+
}, $ = e.vuex.subscribe((t) => {
|
|
130
|
+
w(t) || v();
|
|
131
|
+
}), B = e.store.$subscribe((t) => {
|
|
132
|
+
M(t);
|
|
687
133
|
});
|
|
688
|
-
return
|
|
134
|
+
return v(), {
|
|
689
135
|
dispose() {
|
|
690
|
-
|
|
136
|
+
x || (x = !0, $(), B());
|
|
691
137
|
},
|
|
692
|
-
syncFromExternal:
|
|
138
|
+
syncFromExternal: v,
|
|
693
139
|
syncFromStore() {
|
|
694
|
-
|
|
140
|
+
M();
|
|
695
141
|
}
|
|
696
142
|
};
|
|
697
143
|
}
|
|
698
144
|
export {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
145
|
+
I as applyVuexPatchMutation,
|
|
146
|
+
K as createVuexBridge,
|
|
147
|
+
z as deepFreeze
|
|
702
148
|
};
|
package/package.json
CHANGED