@mhmo91/schmancy 0.2.140 → 0.2.142
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/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/context-array-BrljBA5R.cjs +2 -0
- package/dist/context-array-BrljBA5R.cjs.map +1 -0
- package/dist/context-array-CSGdoQ1W.js +923 -0
- package/dist/context-array-CSGdoQ1W.js.map +1 -0
- package/dist/extra.cjs +1 -1
- package/dist/extra.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +102 -92
- package/dist/mixins/tailwind.css +5 -0
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/selector-hook-0691Losv.js +323 -0
- package/dist/selector-hook-0691Losv.js.map +1 -0
- package/dist/selector-hook-SzNTYQII.cjs +2 -0
- package/dist/selector-hook-SzNTYQII.cjs.map +1 -0
- package/dist/store.cjs +1 -1
- package/dist/store.js +33 -23
- package/dist/teleport.cjs +1 -1
- package/dist/{teleport.component-CqG_93Gb.js → teleport.component-Du14Yyxz.js} +3 -3
- package/dist/{teleport.component-CqG_93Gb.js.map → teleport.component-Du14Yyxz.js.map} +1 -1
- package/dist/{teleport.component-C6QSf6Kd.cjs → teleport.component-Vicu2fPa.cjs} +2 -2
- package/dist/{teleport.component-C6QSf6Kd.cjs.map → teleport.component-Vicu2fPa.cjs.map} +1 -1
- package/dist/teleport.js +1 -1
- package/dist/{timezone-Bh92BXoh.cjs → timezone-2Eb26kSx.cjs} +1 -3
- package/dist/timezone-2Eb26kSx.cjs.map +1 -0
- package/dist/{timezone-95O0-5pe.js → timezone-C8cbkh7P.js} +1 -3
- package/dist/timezone-C8cbkh7P.js.map +1 -0
- package/package.json +2 -1
- package/types/src/store/context-array.d.ts +83 -0
- package/types/src/store/context-collection.d.ts +20 -41
- package/types/src/store/context-create.d.ts +31 -9
- package/types/src/store/context-object.d.ts +14 -43
- package/types/src/store/filter-directive.d.ts +62 -5
- package/types/src/store/immer-integration.d.ts +60 -0
- package/types/src/store/selector-hook.d.ts +4 -0
- package/types/src/store/selectors.d.ts +29 -20
- package/types/src/store/store.class.d.ts +67 -0
- package/types/src/store/types.d.ts +102 -0
- package/dist/context-object-BDXZ5EKJ.js +0 -306
- package/dist/context-object-BDXZ5EKJ.js.map +0 -1
- package/dist/context-object-BIywslrO.cjs +0 -2
- package/dist/context-object-BIywslrO.cjs.map +0 -1
- package/dist/selector-hook-C6VCezv7.js +0 -273
- package/dist/selector-hook-C6VCezv7.js.map +0 -1
- package/dist/selector-hook-DDaYMsHs.cjs +0 -2
- package/dist/selector-hook-DDaYMsHs.cjs.map +0 -1
- package/dist/timezone-95O0-5pe.js.map +0 -1
- package/dist/timezone-Bh92BXoh.cjs.map +0 -1
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
import { Subject as ue, BehaviorSubject as q, throttleTime as ie } from "rxjs";
|
|
2
|
+
var oe = Symbol.for("immer-nothing"), H = Symbol.for("immer-draftable"), u = Symbol.for("immer-state"), le = process.env.NODE_ENV !== "production" ? [function(t) {
|
|
3
|
+
return `The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`;
|
|
4
|
+
}, function(t) {
|
|
5
|
+
return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`;
|
|
6
|
+
}, "This object has been frozen and should not be mutated", function(t) {
|
|
7
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + t;
|
|
8
|
+
}, "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", "Immer forbids circular references", "The first or second argument to `produce` must be a function", "The third argument to `produce` must be a function or undefined", "First argument to `createDraft` must be a plain object, an array, or an immerable object", "First argument to `finishDraft` must be a draft returned by `createDraft`", function(t) {
|
|
9
|
+
return `'current' expects a draft, got: ${t}`;
|
|
10
|
+
}, "Object.defineProperty() cannot be used on an Immer draft", "Object.setPrototypeOf() cannot be used on an Immer draft", "Immer only supports deleting array indices", "Immer only supports setting array indices and the 'length' property", function(t) {
|
|
11
|
+
return `'original' expects a draft, got: ${t}`;
|
|
12
|
+
}] : [];
|
|
13
|
+
function _(t, ...e) {
|
|
14
|
+
if (process.env.NODE_ENV !== "production") {
|
|
15
|
+
const r = le[t], s = typeof r == "function" ? r.apply(null, e) : r;
|
|
16
|
+
throw new Error(`[Immer] ${s}`);
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`);
|
|
19
|
+
}
|
|
20
|
+
var $ = Object.getPrototypeOf;
|
|
21
|
+
function w(t) {
|
|
22
|
+
return !!t && !!t[u];
|
|
23
|
+
}
|
|
24
|
+
function v(t) {
|
|
25
|
+
var e;
|
|
26
|
+
return !!t && (ae(t) || Array.isArray(t) || !!t[H] || !!((e = t.constructor) != null && e[H]) || I(t) || A(t));
|
|
27
|
+
}
|
|
28
|
+
var de = Object.prototype.constructor.toString();
|
|
29
|
+
function ae(t) {
|
|
30
|
+
if (!t || typeof t != "object") return !1;
|
|
31
|
+
const e = $(t);
|
|
32
|
+
if (e === null) return !0;
|
|
33
|
+
const r = Object.hasOwnProperty.call(e, "constructor") && e.constructor;
|
|
34
|
+
return r === Object || typeof r == "function" && Function.toString.call(r) === de;
|
|
35
|
+
}
|
|
36
|
+
function P(t, e) {
|
|
37
|
+
M(t) === 0 ? Reflect.ownKeys(t).forEach((r) => {
|
|
38
|
+
e(r, t[r], t);
|
|
39
|
+
}) : t.forEach((r, s) => e(s, r, t));
|
|
40
|
+
}
|
|
41
|
+
function M(t) {
|
|
42
|
+
const e = t[u];
|
|
43
|
+
return e ? e.type_ : Array.isArray(t) ? 1 : I(t) ? 2 : A(t) ? 3 : 0;
|
|
44
|
+
}
|
|
45
|
+
function B(t, e) {
|
|
46
|
+
return M(t) === 2 ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
|
|
47
|
+
}
|
|
48
|
+
function ce(t, e, r) {
|
|
49
|
+
const s = M(t);
|
|
50
|
+
s === 2 ? t.set(e, r) : s === 3 ? t.add(r) : t[e] = r;
|
|
51
|
+
}
|
|
52
|
+
function I(t) {
|
|
53
|
+
return t instanceof Map;
|
|
54
|
+
}
|
|
55
|
+
function A(t) {
|
|
56
|
+
return t instanceof Set;
|
|
57
|
+
}
|
|
58
|
+
function f(t) {
|
|
59
|
+
return t.copy_ || t.base_;
|
|
60
|
+
}
|
|
61
|
+
function C(t, e) {
|
|
62
|
+
if (I(t)) return new Map(t);
|
|
63
|
+
if (A(t)) return new Set(t);
|
|
64
|
+
if (Array.isArray(t)) return Array.prototype.slice.call(t);
|
|
65
|
+
const r = ae(t);
|
|
66
|
+
if (e === !0 || e === "class_only" && !r) {
|
|
67
|
+
const s = Object.getOwnPropertyDescriptors(t);
|
|
68
|
+
delete s[u];
|
|
69
|
+
let n = Reflect.ownKeys(s);
|
|
70
|
+
for (let a = 0; a < n.length; a++) {
|
|
71
|
+
const h = n[a], c = s[h];
|
|
72
|
+
c.writable === !1 && (c.writable = !0, c.configurable = !0), (c.get || c.set) && (s[h] = { configurable: !0, writable: !0, enumerable: c.enumerable, value: t[h] });
|
|
73
|
+
}
|
|
74
|
+
return Object.create($(t), s);
|
|
75
|
+
}
|
|
76
|
+
{
|
|
77
|
+
const s = $(t);
|
|
78
|
+
if (s !== null && r) return { ...t };
|
|
79
|
+
const n = Object.create(s);
|
|
80
|
+
return Object.assign(n, t);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function G(t, e = !1) {
|
|
84
|
+
return R(t) || w(t) || !v(t) || (M(t) > 1 && (t.set = t.add = t.clear = t.delete = pe), Object.freeze(t), e && Object.entries(t).forEach(([r, s]) => G(s, !0))), t;
|
|
85
|
+
}
|
|
86
|
+
function pe() {
|
|
87
|
+
_(2);
|
|
88
|
+
}
|
|
89
|
+
function R(t) {
|
|
90
|
+
return Object.isFrozen(t);
|
|
91
|
+
}
|
|
92
|
+
var N, J = {};
|
|
93
|
+
function S(t) {
|
|
94
|
+
const e = J[t];
|
|
95
|
+
return e || _(0, t), e;
|
|
96
|
+
}
|
|
97
|
+
function D() {
|
|
98
|
+
return N;
|
|
99
|
+
}
|
|
100
|
+
function Y(t, e) {
|
|
101
|
+
e && (S("Patches"), t.patches_ = [], t.inversePatches_ = [], t.patchListener_ = e);
|
|
102
|
+
}
|
|
103
|
+
function U(t) {
|
|
104
|
+
K(t), t.drafts_.forEach(fe), t.drafts_ = null;
|
|
105
|
+
}
|
|
106
|
+
function K(t) {
|
|
107
|
+
t === N && (N = t.parent_);
|
|
108
|
+
}
|
|
109
|
+
function Z(t) {
|
|
110
|
+
return N = { drafts_: [], parent_: N, immer_: t, canAutoFreeze_: !0, unfinalizedDrafts_: 0 };
|
|
111
|
+
}
|
|
112
|
+
function fe(t) {
|
|
113
|
+
const e = t[u];
|
|
114
|
+
e.type_ === 0 || e.type_ === 1 ? e.revoke_() : e.revoked_ = !0;
|
|
115
|
+
}
|
|
116
|
+
function Q(t, e) {
|
|
117
|
+
e.unfinalizedDrafts_ = e.drafts_.length;
|
|
118
|
+
const r = e.drafts_[0];
|
|
119
|
+
return t !== void 0 && t !== r ? (r[u].modified_ && (U(e), _(4)), v(t) && (t = T(e, t), e.parent_ || j(e, t)), e.patches_ && S("Patches").generateReplacementPatches_(r[u].base_, t, e.patches_, e.inversePatches_)) : t = T(e, r, []), U(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== oe ? t : void 0;
|
|
120
|
+
}
|
|
121
|
+
function T(t, e, r) {
|
|
122
|
+
if (R(e)) return e;
|
|
123
|
+
const s = e[u];
|
|
124
|
+
if (!s) return P(e, (n, a) => ee(t, s, e, n, a, r)), e;
|
|
125
|
+
if (s.scope_ !== t) return e;
|
|
126
|
+
if (!s.modified_) return j(t, s.base_, !0), s.base_;
|
|
127
|
+
if (!s.finalized_) {
|
|
128
|
+
s.finalized_ = !0, s.scope_.unfinalizedDrafts_--;
|
|
129
|
+
const n = s.copy_;
|
|
130
|
+
let a = n, h = !1;
|
|
131
|
+
s.type_ === 3 && (a = new Set(n), n.clear(), h = !0), P(a, (c, i) => ee(t, s, n, c, i, r, h)), j(t, n, !1), r && t.patches_ && S("Patches").generatePatches_(s, r, t.patches_, t.inversePatches_);
|
|
132
|
+
}
|
|
133
|
+
return s.copy_;
|
|
134
|
+
}
|
|
135
|
+
function ee(t, e, r, s, n, a, h) {
|
|
136
|
+
if (process.env.NODE_ENV !== "production" && n === r && _(5), w(n)) {
|
|
137
|
+
const c = T(t, n, a && e && e.type_ !== 3 && !B(e.assigned_, s) ? a.concat(s) : void 0);
|
|
138
|
+
if (ce(r, s, c), !w(c)) return;
|
|
139
|
+
t.canAutoFreeze_ = !1;
|
|
140
|
+
} else h && r.add(n);
|
|
141
|
+
if (v(n) && !R(n)) {
|
|
142
|
+
if (!t.immer_.autoFreeze_ && t.unfinalizedDrafts_ < 1) return;
|
|
143
|
+
T(t, n), e && e.scope_.parent_ || typeof s == "symbol" || !Object.prototype.propertyIsEnumerable.call(r, s) || j(t, n);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function j(t, e, r = !1) {
|
|
147
|
+
!t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && G(e, r);
|
|
148
|
+
}
|
|
149
|
+
var L = { get(t, e) {
|
|
150
|
+
if (e === u) return t;
|
|
151
|
+
const r = f(t);
|
|
152
|
+
if (!B(r, e)) return function(n, a, h) {
|
|
153
|
+
var i;
|
|
154
|
+
const c = te(a, h);
|
|
155
|
+
return c ? "value" in c ? c.value : (i = c.get) == null ? void 0 : i.call(n.draft_) : void 0;
|
|
156
|
+
}(t, r, e);
|
|
157
|
+
const s = r[e];
|
|
158
|
+
return t.finalized_ || !v(s) ? s : s === F(t.base_, e) ? (V(t), t.copy_[e] = z(s, t)) : s;
|
|
159
|
+
}, has: (t, e) => e in f(t), ownKeys: (t) => Reflect.ownKeys(f(t)), set(t, e, r) {
|
|
160
|
+
const s = te(f(t), e);
|
|
161
|
+
if (s != null && s.set) return s.set.call(t.draft_, r), !0;
|
|
162
|
+
if (!t.modified_) {
|
|
163
|
+
const h = F(f(t), e), c = h == null ? void 0 : h[u];
|
|
164
|
+
if (c && c.base_ === r) return t.copy_[e] = r, t.assigned_[e] = !1, !0;
|
|
165
|
+
if (((n = r) === (a = h) ? n !== 0 || 1 / n == 1 / a : n != n && a != a) && (r !== void 0 || B(t.base_, e))) return !0;
|
|
166
|
+
V(t), m(t);
|
|
167
|
+
}
|
|
168
|
+
var n, a;
|
|
169
|
+
return t.copy_[e] === r && (r !== void 0 || e in t.copy_) || Number.isNaN(r) && Number.isNaN(t.copy_[e]) || (t.copy_[e] = r, t.assigned_[e] = !0), !0;
|
|
170
|
+
}, deleteProperty: (t, e) => (F(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_[e] = !1, V(t), m(t)) : delete t.assigned_[e], t.copy_ && delete t.copy_[e], !0), getOwnPropertyDescriptor(t, e) {
|
|
171
|
+
const r = f(t), s = Reflect.getOwnPropertyDescriptor(r, e);
|
|
172
|
+
return s && { writable: !0, configurable: t.type_ !== 1 || e !== "length", enumerable: s.enumerable, value: r[e] };
|
|
173
|
+
}, defineProperty() {
|
|
174
|
+
_(11);
|
|
175
|
+
}, getPrototypeOf: (t) => $(t.base_), setPrototypeOf() {
|
|
176
|
+
_(12);
|
|
177
|
+
} }, E = {};
|
|
178
|
+
function F(t, e) {
|
|
179
|
+
const r = t[u];
|
|
180
|
+
return (r ? f(r) : t)[e];
|
|
181
|
+
}
|
|
182
|
+
function te(t, e) {
|
|
183
|
+
if (!(e in t)) return;
|
|
184
|
+
let r = $(t);
|
|
185
|
+
for (; r; ) {
|
|
186
|
+
const s = Object.getOwnPropertyDescriptor(r, e);
|
|
187
|
+
if (s) return s;
|
|
188
|
+
r = $(r);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function m(t) {
|
|
192
|
+
t.modified_ || (t.modified_ = !0, t.parent_ && m(t.parent_));
|
|
193
|
+
}
|
|
194
|
+
function V(t) {
|
|
195
|
+
t.copy_ || (t.copy_ = C(t.base_, t.scope_.immer_.useStrictShallowCopy_));
|
|
196
|
+
}
|
|
197
|
+
P(L, (t, e) => {
|
|
198
|
+
E[t] = function() {
|
|
199
|
+
return arguments[0] = arguments[0][0], e.apply(this, arguments);
|
|
200
|
+
};
|
|
201
|
+
}), E.deleteProperty = function(t, e) {
|
|
202
|
+
return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && _(13), E.set.call(this, t, e, void 0);
|
|
203
|
+
}, E.set = function(t, e, r) {
|
|
204
|
+
return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) && _(14), L.set.call(this, t[0], e, r, t[0]);
|
|
205
|
+
};
|
|
206
|
+
function z(t, e) {
|
|
207
|
+
const r = I(t) ? S("MapSet").proxyMap_(t, e) : A(t) ? S("MapSet").proxySet_(t, e) : function(s, n) {
|
|
208
|
+
const a = Array.isArray(s), h = { type_: a ? 1 : 0, scope_: n ? n.scope_ : D(), modified_: !1, finalized_: !1, assigned_: {}, parent_: n, base_: s, draft_: null, copy_: null, revoke_: null, isManual_: !1 };
|
|
209
|
+
let c = h, i = L;
|
|
210
|
+
a && (c = [h], i = E);
|
|
211
|
+
const { revoke: o, proxy: p } = Proxy.revocable(c, i);
|
|
212
|
+
return h.draft_ = p, h.revoke_ = o, p;
|
|
213
|
+
}(t, e);
|
|
214
|
+
return (e ? e.scope_ : D()).drafts_.push(r), r;
|
|
215
|
+
}
|
|
216
|
+
function he(t) {
|
|
217
|
+
if (!v(t) || R(t)) return t;
|
|
218
|
+
const e = t[u];
|
|
219
|
+
let r;
|
|
220
|
+
if (e) {
|
|
221
|
+
if (!e.modified_) return e.base_;
|
|
222
|
+
e.finalized_ = !0, r = C(t, e.scope_.immer_.useStrictShallowCopy_);
|
|
223
|
+
} else r = C(t, !0);
|
|
224
|
+
return P(r, (s, n) => {
|
|
225
|
+
ce(r, s, he(n));
|
|
226
|
+
}), e && (e.finalized_ = !1), r;
|
|
227
|
+
}
|
|
228
|
+
var g = new class {
|
|
229
|
+
constructor(t) {
|
|
230
|
+
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.produce = (e, r, s) => {
|
|
231
|
+
if (typeof e == "function" && typeof r != "function") {
|
|
232
|
+
const a = r;
|
|
233
|
+
r = e;
|
|
234
|
+
const h = this;
|
|
235
|
+
return function(c = a, ...i) {
|
|
236
|
+
return h.produce(c, (o) => r.call(this, o, ...i));
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
let n;
|
|
240
|
+
if (typeof r != "function" && _(6), s !== void 0 && typeof s != "function" && _(7), v(e)) {
|
|
241
|
+
const a = Z(this), h = z(e, void 0);
|
|
242
|
+
let c = !0;
|
|
243
|
+
try {
|
|
244
|
+
n = r(h), c = !1;
|
|
245
|
+
} finally {
|
|
246
|
+
c ? U(a) : K(a);
|
|
247
|
+
}
|
|
248
|
+
return Y(a, s), Q(n, a);
|
|
249
|
+
}
|
|
250
|
+
if (!e || typeof e != "object") {
|
|
251
|
+
if (n = r(e), n === void 0 && (n = e), n === oe && (n = void 0), this.autoFreeze_ && G(n, !0), s) {
|
|
252
|
+
const a = [], h = [];
|
|
253
|
+
S("Patches").generateReplacementPatches_(e, n, a, h), s(a, h);
|
|
254
|
+
}
|
|
255
|
+
return n;
|
|
256
|
+
}
|
|
257
|
+
_(1, e);
|
|
258
|
+
}, this.produceWithPatches = (e, r) => {
|
|
259
|
+
if (typeof e == "function") return (a, ...h) => this.produceWithPatches(a, (c) => e(c, ...h));
|
|
260
|
+
let s, n;
|
|
261
|
+
return [this.produce(e, r, (a, h) => {
|
|
262
|
+
s = a, n = h;
|
|
263
|
+
}), s, n];
|
|
264
|
+
}, typeof (t == null ? void 0 : t.autoFreeze) == "boolean" && this.setAutoFreeze(t.autoFreeze), typeof (t == null ? void 0 : t.useStrictShallowCopy) == "boolean" && this.setUseStrictShallowCopy(t.useStrictShallowCopy);
|
|
265
|
+
}
|
|
266
|
+
createDraft(t) {
|
|
267
|
+
v(t) || _(8), w(t) && (t = function(s) {
|
|
268
|
+
return w(s) || _(10, s), he(s);
|
|
269
|
+
}(t));
|
|
270
|
+
const e = Z(this), r = z(t, void 0);
|
|
271
|
+
return r[u].isManual_ = !0, K(e), r;
|
|
272
|
+
}
|
|
273
|
+
finishDraft(t, e) {
|
|
274
|
+
const r = t && t[u];
|
|
275
|
+
r && r.isManual_ || _(9);
|
|
276
|
+
const { scope_: s } = r;
|
|
277
|
+
return Y(s, e), Q(void 0, s);
|
|
278
|
+
}
|
|
279
|
+
setAutoFreeze(t) {
|
|
280
|
+
this.autoFreeze_ = t;
|
|
281
|
+
}
|
|
282
|
+
setUseStrictShallowCopy(t) {
|
|
283
|
+
this.useStrictShallowCopy_ = t;
|
|
284
|
+
}
|
|
285
|
+
applyPatches(t, e) {
|
|
286
|
+
let r;
|
|
287
|
+
for (r = e.length - 1; r >= 0; r--) {
|
|
288
|
+
const n = e[r];
|
|
289
|
+
if (n.path.length === 0 && n.op === "replace") {
|
|
290
|
+
t = n.value;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
r > -1 && (e = e.slice(r + 1));
|
|
295
|
+
const s = S("Patches").applyPatches_;
|
|
296
|
+
return w(t) ? s(t, e) : this.produce(t, (n) => s(n, e));
|
|
297
|
+
}
|
|
298
|
+
}(), d = g.produce;
|
|
299
|
+
g.produceWithPatches.bind(g), g.setAutoFreeze.bind(g), g.setUseStrictShallowCopy.bind(g), g.applyPatches.bind(g), g.createDraft.bind(g), g.finishDraft.bind(g);
|
|
300
|
+
class l extends Error {
|
|
301
|
+
constructor(e, r, s) {
|
|
302
|
+
super(e), this.name = "StoreError", this.cause = r, this.context = s, this.timestamp = /* @__PURE__ */ new Date(), Error.captureStackTrace && Error.captureStackTrace(this, l);
|
|
303
|
+
}
|
|
304
|
+
toJSON() {
|
|
305
|
+
return { name: this.name, message: this.message, cause: this.cause, context: this.context, timestamp: this.timestamp.toISOString(), stack: this.stack };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
class ye {
|
|
309
|
+
constructor() {
|
|
310
|
+
this.data = null;
|
|
311
|
+
}
|
|
312
|
+
async load() {
|
|
313
|
+
return this.data;
|
|
314
|
+
}
|
|
315
|
+
async save(e) {
|
|
316
|
+
this.data = e;
|
|
317
|
+
}
|
|
318
|
+
async clear() {
|
|
319
|
+
this.data = null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
class _e {
|
|
323
|
+
constructor(e) {
|
|
324
|
+
this.key = e;
|
|
325
|
+
}
|
|
326
|
+
async load() {
|
|
327
|
+
try {
|
|
328
|
+
const e = localStorage.getItem(this.key);
|
|
329
|
+
return e ? JSON.parse(e) : null;
|
|
330
|
+
} catch {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async save(e) {
|
|
335
|
+
try {
|
|
336
|
+
localStorage.setItem(this.key, JSON.stringify(e));
|
|
337
|
+
} catch (r) {
|
|
338
|
+
throw new l(`Failed to save to localStorage (${this.key})`, r);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async clear() {
|
|
342
|
+
localStorage.removeItem(this.key);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
class ge {
|
|
346
|
+
constructor(e) {
|
|
347
|
+
this.key = e;
|
|
348
|
+
}
|
|
349
|
+
async load() {
|
|
350
|
+
try {
|
|
351
|
+
const e = sessionStorage.getItem(this.key);
|
|
352
|
+
return e ? JSON.parse(e) : null;
|
|
353
|
+
} catch {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async save(e) {
|
|
358
|
+
try {
|
|
359
|
+
sessionStorage.setItem(this.key, JSON.stringify(e));
|
|
360
|
+
} catch (r) {
|
|
361
|
+
throw new l(`Failed to save to sessionStorage (${this.key})`, r);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
async clear() {
|
|
365
|
+
sessionStorage.removeItem(this.key);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const y = class y {
|
|
369
|
+
constructor(e) {
|
|
370
|
+
this.key = e;
|
|
371
|
+
}
|
|
372
|
+
openDB() {
|
|
373
|
+
return new Promise((e, r) => {
|
|
374
|
+
const s = indexedDB.open(y.DB_NAME, y.DB_VERSION);
|
|
375
|
+
s.onupgradeneeded = () => {
|
|
376
|
+
const n = s.result;
|
|
377
|
+
n.objectStoreNames.contains(y.STORE_NAME) || n.createObjectStore(y.STORE_NAME);
|
|
378
|
+
}, s.onsuccess = () => e(s.result), s.onerror = () => r(s.error);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
async load() {
|
|
382
|
+
try {
|
|
383
|
+
const e = await this.openDB();
|
|
384
|
+
return new Promise((r, s) => {
|
|
385
|
+
const n = e.transaction(y.STORE_NAME, "readonly").objectStore(y.STORE_NAME).get(this.key);
|
|
386
|
+
n.onsuccess = () => {
|
|
387
|
+
e.close(), r(n.result || null);
|
|
388
|
+
}, n.onerror = () => {
|
|
389
|
+
e.close(), s(n.error);
|
|
390
|
+
};
|
|
391
|
+
});
|
|
392
|
+
} catch {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async save(e) {
|
|
397
|
+
try {
|
|
398
|
+
const r = await this.openDB();
|
|
399
|
+
return new Promise((s, n) => {
|
|
400
|
+
const a = r.transaction(y.STORE_NAME, "readwrite").objectStore(y.STORE_NAME).put(e, this.key);
|
|
401
|
+
a.onsuccess = () => {
|
|
402
|
+
r.close(), s();
|
|
403
|
+
}, a.onerror = () => {
|
|
404
|
+
r.close(), n(a.error);
|
|
405
|
+
};
|
|
406
|
+
});
|
|
407
|
+
} catch (r) {
|
|
408
|
+
throw new l(`Failed to save to IndexedDB (${this.key})`, r);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
async clear() {
|
|
412
|
+
try {
|
|
413
|
+
const e = await this.openDB();
|
|
414
|
+
return new Promise((r, s) => {
|
|
415
|
+
const n = e.transaction(y.STORE_NAME, "readwrite").objectStore(y.STORE_NAME).delete(this.key);
|
|
416
|
+
n.onsuccess = () => {
|
|
417
|
+
e.close(), r();
|
|
418
|
+
}, n.onerror = () => {
|
|
419
|
+
e.close(), s(n.error);
|
|
420
|
+
};
|
|
421
|
+
});
|
|
422
|
+
} catch (e) {
|
|
423
|
+
throw new l(`Failed to clear from IndexedDB (${this.key})`, e);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
y.DB_NAME = "StoreDB", y.STORE_NAME = "states", y.DB_VERSION = 1;
|
|
428
|
+
let W = y;
|
|
429
|
+
function be(t, e) {
|
|
430
|
+
switch (t) {
|
|
431
|
+
case "local":
|
|
432
|
+
return new _e(e);
|
|
433
|
+
case "session":
|
|
434
|
+
return new ge(e);
|
|
435
|
+
case "indexeddb":
|
|
436
|
+
return new W(e);
|
|
437
|
+
default:
|
|
438
|
+
return new ye();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
(function() {
|
|
442
|
+
class t extends Map {
|
|
443
|
+
constructor(i, o) {
|
|
444
|
+
super(), this[u] = { type_: 2, parent_: o, scope_: o ? o.scope_ : D(), modified_: !1, finalized_: !1, copy_: void 0, assigned_: void 0, base_: i, draft_: this, isManual_: !1, revoked_: !1 };
|
|
445
|
+
}
|
|
446
|
+
get size() {
|
|
447
|
+
return f(this[u]).size;
|
|
448
|
+
}
|
|
449
|
+
has(i) {
|
|
450
|
+
return f(this[u]).has(i);
|
|
451
|
+
}
|
|
452
|
+
set(i, o) {
|
|
453
|
+
const p = this[u];
|
|
454
|
+
return n(p), f(p).has(i) && f(p).get(i) === o || (e(p), m(p), p.assigned_.set(i, !0), p.copy_.set(i, o), p.assigned_.set(i, !0)), this;
|
|
455
|
+
}
|
|
456
|
+
delete(i) {
|
|
457
|
+
if (!this.has(i)) return !1;
|
|
458
|
+
const o = this[u];
|
|
459
|
+
return n(o), e(o), m(o), o.base_.has(i) ? o.assigned_.set(i, !1) : o.assigned_.delete(i), o.copy_.delete(i), !0;
|
|
460
|
+
}
|
|
461
|
+
clear() {
|
|
462
|
+
const i = this[u];
|
|
463
|
+
n(i), f(i).size && (e(i), m(i), i.assigned_ = /* @__PURE__ */ new Map(), P(i.base_, (o) => {
|
|
464
|
+
i.assigned_.set(o, !1);
|
|
465
|
+
}), i.copy_.clear());
|
|
466
|
+
}
|
|
467
|
+
forEach(i, o) {
|
|
468
|
+
f(this[u]).forEach((p, b, me) => {
|
|
469
|
+
i.call(o, this.get(b), b, this);
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
get(i) {
|
|
473
|
+
const o = this[u];
|
|
474
|
+
n(o);
|
|
475
|
+
const p = f(o).get(i);
|
|
476
|
+
if (o.finalized_ || !v(p) || p !== o.base_.get(i)) return p;
|
|
477
|
+
const b = z(p, o);
|
|
478
|
+
return e(o), o.copy_.set(i, b), b;
|
|
479
|
+
}
|
|
480
|
+
keys() {
|
|
481
|
+
return f(this[u]).keys();
|
|
482
|
+
}
|
|
483
|
+
values() {
|
|
484
|
+
const i = this.keys();
|
|
485
|
+
return { [Symbol.iterator]: () => this.values(), next: () => {
|
|
486
|
+
const o = i.next();
|
|
487
|
+
return o.done ? o : { done: !1, value: this.get(o.value) };
|
|
488
|
+
} };
|
|
489
|
+
}
|
|
490
|
+
entries() {
|
|
491
|
+
const i = this.keys();
|
|
492
|
+
return { [Symbol.iterator]: () => this.entries(), next: () => {
|
|
493
|
+
const o = i.next();
|
|
494
|
+
if (o.done) return o;
|
|
495
|
+
const p = this.get(o.value);
|
|
496
|
+
return { done: !1, value: [o.value, p] };
|
|
497
|
+
} };
|
|
498
|
+
}
|
|
499
|
+
[Symbol.iterator]() {
|
|
500
|
+
return this.entries();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function e(c) {
|
|
504
|
+
c.copy_ || (c.assigned_ = /* @__PURE__ */ new Map(), c.copy_ = new Map(c.base_));
|
|
505
|
+
}
|
|
506
|
+
class r extends Set {
|
|
507
|
+
constructor(i, o) {
|
|
508
|
+
super(), this[u] = { type_: 3, parent_: o, scope_: o ? o.scope_ : D(), modified_: !1, finalized_: !1, copy_: void 0, base_: i, draft_: this, drafts_: /* @__PURE__ */ new Map(), revoked_: !1, isManual_: !1 };
|
|
509
|
+
}
|
|
510
|
+
get size() {
|
|
511
|
+
return f(this[u]).size;
|
|
512
|
+
}
|
|
513
|
+
has(i) {
|
|
514
|
+
const o = this[u];
|
|
515
|
+
return n(o), o.copy_ ? !!o.copy_.has(i) || !(!o.drafts_.has(i) || !o.copy_.has(o.drafts_.get(i))) : o.base_.has(i);
|
|
516
|
+
}
|
|
517
|
+
add(i) {
|
|
518
|
+
const o = this[u];
|
|
519
|
+
return n(o), this.has(i) || (s(o), m(o), o.copy_.add(i)), this;
|
|
520
|
+
}
|
|
521
|
+
delete(i) {
|
|
522
|
+
if (!this.has(i)) return !1;
|
|
523
|
+
const o = this[u];
|
|
524
|
+
return n(o), s(o), m(o), o.copy_.delete(i) || !!o.drafts_.has(i) && o.copy_.delete(o.drafts_.get(i));
|
|
525
|
+
}
|
|
526
|
+
clear() {
|
|
527
|
+
const i = this[u];
|
|
528
|
+
n(i), f(i).size && (s(i), m(i), i.copy_.clear());
|
|
529
|
+
}
|
|
530
|
+
values() {
|
|
531
|
+
const i = this[u];
|
|
532
|
+
return n(i), s(i), i.copy_.values();
|
|
533
|
+
}
|
|
534
|
+
entries() {
|
|
535
|
+
const i = this[u];
|
|
536
|
+
return n(i), s(i), i.copy_.entries();
|
|
537
|
+
}
|
|
538
|
+
keys() {
|
|
539
|
+
return this.values();
|
|
540
|
+
}
|
|
541
|
+
[Symbol.iterator]() {
|
|
542
|
+
return this.values();
|
|
543
|
+
}
|
|
544
|
+
forEach(i, o) {
|
|
545
|
+
const p = this.values();
|
|
546
|
+
let b = p.next();
|
|
547
|
+
for (; !b.done; ) i.call(o, b.value, b.value, this), b = p.next();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function s(c) {
|
|
551
|
+
c.copy_ || (c.copy_ = /* @__PURE__ */ new Set(), c.base_.forEach((i) => {
|
|
552
|
+
if (v(i)) {
|
|
553
|
+
const o = z(i, c);
|
|
554
|
+
c.drafts_.set(i, o), c.copy_.add(o);
|
|
555
|
+
} else c.copy_.add(i);
|
|
556
|
+
}));
|
|
557
|
+
}
|
|
558
|
+
function n(c) {
|
|
559
|
+
c.revoked_ && _(3, JSON.stringify(f(c)));
|
|
560
|
+
}
|
|
561
|
+
var a, h;
|
|
562
|
+
h = { proxyMap_: function(c, i) {
|
|
563
|
+
return new t(c, i);
|
|
564
|
+
}, proxySet_: function(c, i) {
|
|
565
|
+
return new r(c, i);
|
|
566
|
+
} }, J[a = "MapSet"] || (J[a] = h);
|
|
567
|
+
})();
|
|
568
|
+
class X {
|
|
569
|
+
constructor(e, r, s) {
|
|
570
|
+
this.storageType = e, this.key = r, this._ready = !1, this._destroy$ = new ue(), this.error$ = new q(null), this.defaultValue = d(s, (n) => n), this.$ = new q(this.defaultValue), this.storage = be(e, r), e === "memory" ? this._ready = !0 : this.initializeFromStorage();
|
|
571
|
+
}
|
|
572
|
+
get ready() {
|
|
573
|
+
return this._ready;
|
|
574
|
+
}
|
|
575
|
+
set ready(e) {
|
|
576
|
+
this._ready = e, this.updateState(this.$.value);
|
|
577
|
+
}
|
|
578
|
+
get value() {
|
|
579
|
+
return this.$.getValue();
|
|
580
|
+
}
|
|
581
|
+
destroy() {
|
|
582
|
+
this._destroy$.next(), this._destroy$.complete(), this.$.complete(), this.error$.complete();
|
|
583
|
+
}
|
|
584
|
+
replace(e) {
|
|
585
|
+
const r = d(e, (s) => s);
|
|
586
|
+
this.updateState(r);
|
|
587
|
+
}
|
|
588
|
+
updateState(e) {
|
|
589
|
+
try {
|
|
590
|
+
const r = d(e, (s) => s);
|
|
591
|
+
this.$.next(r), this.storageType !== "memory" && this.persistToStorage(r).catch((s) => {
|
|
592
|
+
const n = new l(`Error saving to ${this.storageType} storage for ${this.key}`, s);
|
|
593
|
+
this.error$.next(n);
|
|
594
|
+
});
|
|
595
|
+
} catch (r) {
|
|
596
|
+
const s = new l(`Error updating state in ${this.key}`, r);
|
|
597
|
+
this.error$.next(s);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async initializeFromStorage() {
|
|
601
|
+
try {
|
|
602
|
+
const e = await this.storage.load();
|
|
603
|
+
if (e) {
|
|
604
|
+
const r = this.processStoredValue(e), s = d(r, (n) => n);
|
|
605
|
+
this.updateState(s);
|
|
606
|
+
}
|
|
607
|
+
this._ready = !0;
|
|
608
|
+
} catch (e) {
|
|
609
|
+
const r = new l(`Error loading from ${this.storageType} storage for ${this.key}`, e);
|
|
610
|
+
this.error$.next(r), this._ready = !0;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
processStoredValue(e) {
|
|
614
|
+
return e;
|
|
615
|
+
}
|
|
616
|
+
async persistToStorage(e) {
|
|
617
|
+
return this.storage.save(e);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const x = class x extends X {
|
|
621
|
+
static getInstance(e, r, s) {
|
|
622
|
+
const n = `${e}:${r}`;
|
|
623
|
+
return this.instances.has(n) || this.instances.set(n, new x(e, r, s)), this.instances.get(n);
|
|
624
|
+
}
|
|
625
|
+
set(e, r) {
|
|
626
|
+
try {
|
|
627
|
+
const s = d(this.value, (n) => {
|
|
628
|
+
n.set(e, r);
|
|
629
|
+
});
|
|
630
|
+
this.updateState(s), this.error$.next(null);
|
|
631
|
+
} catch (s) {
|
|
632
|
+
const n = new l(`Error setting value for key ${e} in ${this.key}`, s);
|
|
633
|
+
this.error$.next(n);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
delete(e) {
|
|
637
|
+
try {
|
|
638
|
+
const r = d(this.value, (s) => {
|
|
639
|
+
s.delete(e);
|
|
640
|
+
});
|
|
641
|
+
this.updateState(r), this.error$.next(null);
|
|
642
|
+
} catch (r) {
|
|
643
|
+
const s = new l(`Error deleting key ${e} from ${this.key}`, r);
|
|
644
|
+
this.error$.next(s);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
clear() {
|
|
648
|
+
this.updateState(/* @__PURE__ */ new Map());
|
|
649
|
+
}
|
|
650
|
+
batchUpdate(e) {
|
|
651
|
+
try {
|
|
652
|
+
const r = d(this.value, (s) => {
|
|
653
|
+
Object.entries(e).forEach(([n, a]) => {
|
|
654
|
+
s.set(n, a);
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
this.updateState(r), this.error$.next(null);
|
|
658
|
+
} catch (r) {
|
|
659
|
+
const s = new l(`Error batch updating in ${this.key}`, r);
|
|
660
|
+
this.error$.next(s);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
update(e, r) {
|
|
664
|
+
try {
|
|
665
|
+
const s = d(this.value, (n) => {
|
|
666
|
+
const a = n.get(e);
|
|
667
|
+
a !== void 0 && r(a);
|
|
668
|
+
});
|
|
669
|
+
this.updateState(s), this.error$.next(null);
|
|
670
|
+
} catch (s) {
|
|
671
|
+
const n = new l(`Error updating item ${e} in ${this.key}`, s);
|
|
672
|
+
this.error$.next(n);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
constructor(e, r, s) {
|
|
676
|
+
super(e, r, s), e !== "memory" && this.setupPersistence();
|
|
677
|
+
}
|
|
678
|
+
setupPersistence() {
|
|
679
|
+
this.$.pipe(ie(100, void 0, { leading: !0, trailing: !0 })).subscribe((e) => {
|
|
680
|
+
this.storage.save(e).catch((r) => {
|
|
681
|
+
const s = new l(`Error saving to ${this.storageType} storage for ${this.key}`, r);
|
|
682
|
+
this.error$.next(s);
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
setupDevTools() {
|
|
687
|
+
typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, set: this.set.bind(this), delete: this.delete.bind(this), clear: this.clear.bind(this), batchUpdate: this.batchUpdate.bind(this), update: this.update.bind(this), subscribe: (e) => {
|
|
688
|
+
const r = this.$.subscribe(e);
|
|
689
|
+
return () => r.unsubscribe();
|
|
690
|
+
} });
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
x.type = "collection", x.instances = /* @__PURE__ */ new Map();
|
|
694
|
+
let re = x;
|
|
695
|
+
const k = class k extends X {
|
|
696
|
+
static getInstance(e, r, s) {
|
|
697
|
+
const n = `${e}:${r}`;
|
|
698
|
+
return this.instances.has(n) || this.instances.set(n, new k(e, r, s)), this.instances.get(n);
|
|
699
|
+
}
|
|
700
|
+
set(e, r = !0) {
|
|
701
|
+
try {
|
|
702
|
+
const s = d(this.value, (n) => {
|
|
703
|
+
if (!r) return e;
|
|
704
|
+
Object.assign(n, e);
|
|
705
|
+
});
|
|
706
|
+
this.updateState(s), this.error$.next(null);
|
|
707
|
+
} catch (s) {
|
|
708
|
+
const n = new l(`Error updating store: ${this.key}`, s, { value: e, merge: r });
|
|
709
|
+
this.error$.next(n);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
clear() {
|
|
713
|
+
const e = d(this.defaultValue, (r) => r);
|
|
714
|
+
this.set(e, !1);
|
|
715
|
+
}
|
|
716
|
+
delete(e) {
|
|
717
|
+
const r = d(this.value, (s) => {
|
|
718
|
+
delete s[e];
|
|
719
|
+
});
|
|
720
|
+
this.updateState(r);
|
|
721
|
+
}
|
|
722
|
+
setPath(e, r) {
|
|
723
|
+
try {
|
|
724
|
+
const s = d(this.value, (n) => {
|
|
725
|
+
const a = e.split(".");
|
|
726
|
+
let h = n;
|
|
727
|
+
for (let c = 0; c < a.length - 1; c++) {
|
|
728
|
+
const i = a[c];
|
|
729
|
+
(h[i] === void 0 || typeof h[i] != "object") && (h[i] = {}), h = h[i];
|
|
730
|
+
}
|
|
731
|
+
h[a[a.length - 1]] = r;
|
|
732
|
+
});
|
|
733
|
+
this.updateState(s), this.error$.next(null);
|
|
734
|
+
} catch (s) {
|
|
735
|
+
const n = new l(`Error setting path ${e} in ${this.key}`, s);
|
|
736
|
+
this.error$.next(n);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
processStoredValue(e) {
|
|
740
|
+
return d(this.defaultValue, (r) => {
|
|
741
|
+
Object.assign(r, e);
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
setupDevTools() {
|
|
745
|
+
typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, set: this.set.bind(this), delete: this.delete.bind(this), clear: this.clear.bind(this), setPath: this.setPath.bind(this), subscribe: (e) => {
|
|
746
|
+
const r = this.$.subscribe(e);
|
|
747
|
+
return () => r.unsubscribe();
|
|
748
|
+
} });
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
k.type = "object", k.instances = /* @__PURE__ */ new Map();
|
|
752
|
+
let se = k;
|
|
753
|
+
const O = class O extends X {
|
|
754
|
+
static getInstance(e, r, s = []) {
|
|
755
|
+
const n = `${e}:${r}`;
|
|
756
|
+
return this.instances.has(n) || this.instances.set(n, new O(e, r, s)), this.instances.get(n);
|
|
757
|
+
}
|
|
758
|
+
constructor(e, r, s = []) {
|
|
759
|
+
super(e, r, s), e !== "memory" && this.setupPersistence();
|
|
760
|
+
}
|
|
761
|
+
setupPersistence() {
|
|
762
|
+
this.$.pipe(ie(100, void 0, { leading: !0, trailing: !0 })).subscribe((e) => {
|
|
763
|
+
this.storage.save(e).catch((r) => {
|
|
764
|
+
const s = new l(`Error saving to ${this.storageType} storage for ${this.key}`, r);
|
|
765
|
+
this.error$.next(s);
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
push(...e) {
|
|
770
|
+
try {
|
|
771
|
+
const r = d(this.value, (s) => {
|
|
772
|
+
s.push(...e.map((n) => n));
|
|
773
|
+
});
|
|
774
|
+
this.updateState(r), this.error$.next(null);
|
|
775
|
+
} catch (r) {
|
|
776
|
+
const s = new l(`Error pushing items in ${this.key}`, r);
|
|
777
|
+
this.error$.next(s);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
pop() {
|
|
781
|
+
try {
|
|
782
|
+
const e = this.value.length > 0 ? this.value[this.value.length - 1] : void 0, r = d(this.value, (s) => {
|
|
783
|
+
s.pop();
|
|
784
|
+
});
|
|
785
|
+
return this.updateState(r), this.error$.next(null), e;
|
|
786
|
+
} catch (e) {
|
|
787
|
+
const r = new l(`Error popping item from ${this.key}`, e);
|
|
788
|
+
return void this.error$.next(r);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
unshift(...e) {
|
|
792
|
+
try {
|
|
793
|
+
const r = d(this.value, (s) => {
|
|
794
|
+
s.unshift(...e.map((n) => n));
|
|
795
|
+
});
|
|
796
|
+
this.updateState(r), this.error$.next(null);
|
|
797
|
+
} catch (r) {
|
|
798
|
+
const s = new l(`Error unshifting items in ${this.key}`, r);
|
|
799
|
+
this.error$.next(s);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
shift() {
|
|
803
|
+
try {
|
|
804
|
+
const e = this.value.length > 0 ? this.value[0] : void 0, r = d(this.value, (s) => {
|
|
805
|
+
s.shift();
|
|
806
|
+
});
|
|
807
|
+
return this.updateState(r), this.error$.next(null), e;
|
|
808
|
+
} catch (e) {
|
|
809
|
+
const r = new l(`Error shifting item from ${this.key}`, e);
|
|
810
|
+
return void this.error$.next(r);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
set(e, r) {
|
|
814
|
+
try {
|
|
815
|
+
const s = d(this.value, (n) => {
|
|
816
|
+
if (!(e >= 0 && e < n.length)) throw new Error(`Index ${e} out of bounds (length: ${n.length})`);
|
|
817
|
+
n[e] = r;
|
|
818
|
+
});
|
|
819
|
+
this.updateState(s), this.error$.next(null);
|
|
820
|
+
} catch (s) {
|
|
821
|
+
const n = new l(`Error setting item at index ${e} in ${this.key}`, s);
|
|
822
|
+
this.error$.next(n);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
get(e) {
|
|
826
|
+
return this.value[e];
|
|
827
|
+
}
|
|
828
|
+
splice(e, r, ...s) {
|
|
829
|
+
try {
|
|
830
|
+
const n = [...this.value].splice(e, r ?? 0, ...s), a = d(this.value, (h) => {
|
|
831
|
+
h.splice(e, r ?? 0, ...s.map((c) => c));
|
|
832
|
+
});
|
|
833
|
+
return this.updateState(a), this.error$.next(null), n;
|
|
834
|
+
} catch (n) {
|
|
835
|
+
const a = new l(`Error splicing items in ${this.key}`, n);
|
|
836
|
+
return this.error$.next(a), [];
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
remove(e, r) {
|
|
840
|
+
try {
|
|
841
|
+
const s = r || ((a, h) => a === h), n = this.value.findIndex((a) => s(a, e));
|
|
842
|
+
if (n !== -1) {
|
|
843
|
+
const a = d(this.value, (h) => {
|
|
844
|
+
h.splice(n, 1);
|
|
845
|
+
});
|
|
846
|
+
return this.updateState(a), this.error$.next(null), !0;
|
|
847
|
+
}
|
|
848
|
+
return this.error$.next(null), !1;
|
|
849
|
+
} catch (s) {
|
|
850
|
+
const n = new l(`Error removing item in ${this.key}`, s);
|
|
851
|
+
return this.error$.next(n), !1;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
replace(e) {
|
|
855
|
+
try {
|
|
856
|
+
const r = d(e, (s) => s);
|
|
857
|
+
this.updateState(r), this.error$.next(null);
|
|
858
|
+
} catch (r) {
|
|
859
|
+
const s = new l(`Error replacing array in ${this.key}`, r);
|
|
860
|
+
this.error$.next(s);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
filter(e) {
|
|
864
|
+
try {
|
|
865
|
+
const r = this.value.filter(e), s = d(this.value, (n) => {
|
|
866
|
+
n.length = 0, n.push(...r.map((a) => a));
|
|
867
|
+
});
|
|
868
|
+
this.updateState(s), this.error$.next(null);
|
|
869
|
+
} catch (r) {
|
|
870
|
+
const s = new l(`Error filtering array in ${this.key}`, r);
|
|
871
|
+
this.error$.next(s);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
map(e) {
|
|
875
|
+
return this.value.map(e);
|
|
876
|
+
}
|
|
877
|
+
sort(e) {
|
|
878
|
+
try {
|
|
879
|
+
const r = [...this.value].sort(e), s = d(this.value, (n) => {
|
|
880
|
+
n.length = 0, n.push(...r.map((a) => a));
|
|
881
|
+
});
|
|
882
|
+
this.updateState(s), this.error$.next(null);
|
|
883
|
+
} catch (r) {
|
|
884
|
+
const s = new l(`Error sorting array in ${this.key}`, r);
|
|
885
|
+
this.error$.next(s);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
update(e, r) {
|
|
889
|
+
try {
|
|
890
|
+
const s = d(this.value, (n) => {
|
|
891
|
+
if (!(e >= 0 && e < n.length)) throw new Error(`Index ${e} out of bounds (length: ${n.length})`);
|
|
892
|
+
r(n[e]);
|
|
893
|
+
});
|
|
894
|
+
this.updateState(s), this.error$.next(null);
|
|
895
|
+
} catch (s) {
|
|
896
|
+
const n = new l(`Error updating item at index ${e} in ${this.key}`, s);
|
|
897
|
+
this.error$.next(n);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
clear() {
|
|
901
|
+
this.updateState([]);
|
|
902
|
+
}
|
|
903
|
+
setupDevTools() {
|
|
904
|
+
typeof window < "u" && (window.__STORES__ = window.__STORES__ || {}, window.__STORES__[this.key] = { getState: () => this.value, push: this.push.bind(this), pop: this.pop.bind(this), unshift: this.unshift.bind(this), shift: this.shift.bind(this), set: this.set.bind(this), get: this.get.bind(this), splice: this.splice.bind(this), remove: this.remove.bind(this), replace: this.replace.bind(this), filter: this.filter.bind(this), map: this.map.bind(this), sort: this.sort.bind(this), update: this.update.bind(this), clear: this.clear.bind(this), subscribe: (e) => {
|
|
905
|
+
const r = this.$.subscribe(e);
|
|
906
|
+
return () => r.unsubscribe();
|
|
907
|
+
} });
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
O.type = "array", O.instances = /* @__PURE__ */ new Map();
|
|
911
|
+
let ne = O;
|
|
912
|
+
export {
|
|
913
|
+
W as I,
|
|
914
|
+
_e as L,
|
|
915
|
+
ye as M,
|
|
916
|
+
se as S,
|
|
917
|
+
ge as a,
|
|
918
|
+
l as b,
|
|
919
|
+
be as c,
|
|
920
|
+
re as d,
|
|
921
|
+
ne as e
|
|
922
|
+
};
|
|
923
|
+
//# sourceMappingURL=context-array-CSGdoQ1W.js.map
|