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