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