@storix-js/vuex 0.1.0 → 0.1.2

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