atomaric 0.0.87 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +498 -8
- package/build/atomaric.js +282 -811
- package/build/atomaric.umd.cjs +1 -1
- package/package.json +5 -2
- package/types/do.classes.model/IObject.ts +2 -1
- package/types/index.d.ts +69 -6
package/build/atomaric.js
CHANGED
|
@@ -1,702 +1,146 @@
|
|
|
1
|
-
let
|
|
1
|
+
let re = () => {
|
|
2
|
+
throw "call configureAtomaric() before all!";
|
|
3
|
+
}, F = () => {
|
|
2
4
|
throw "call configureAtomaric() before all!";
|
|
3
5
|
};
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
class
|
|
6
|
+
const w = {}, Me = (s) => {
|
|
7
|
+
w.useSyncExternalStore = re = s.useSyncExternalStore, w.produce = F = s.produce, w.keyPathSeparator = s.keyPathSeparator, w.securifyKeyLevel = s.securifyKeyLevel, w.securifyValueLevel = s.securifyValueLevel, w.storage = s.storage, be(s.storage);
|
|
8
|
+
}, le = (s) => re(s.subscribe, s.get), ue = (s) => s.set, _e = (s) => s.setDeferred, $e = (s) => s.get, Le = (s) => s.do, Pe = (s) => [le(s), ue(s)], Te = (s, t) => new Se(s, t);
|
|
9
|
+
class M {
|
|
8
10
|
constructor(t) {
|
|
9
11
|
if (t)
|
|
10
12
|
return new Proxy(this, {
|
|
11
|
-
get: (
|
|
13
|
+
get: (a, e) => e in this ? a[e] : t[e]
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
28
|
-
"Immer forbids circular references",
|
|
29
|
-
"The first or second argument to `produce` must be a function",
|
|
30
|
-
"The third argument to `produce` must be a function or undefined",
|
|
31
|
-
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
32
|
-
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
33
|
-
function(e) {
|
|
34
|
-
return `'current' expects a draft, got: ${e}`;
|
|
35
|
-
},
|
|
36
|
-
"Object.defineProperty() cannot be used on an Immer draft",
|
|
37
|
-
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
38
|
-
"Immer only supports deleting array indices",
|
|
39
|
-
"Immer only supports setting array indices and the 'length' property",
|
|
40
|
-
function(e) {
|
|
41
|
-
return `'original' expects a draft, got: ${e}`;
|
|
42
|
-
}
|
|
43
|
-
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
44
|
-
// See Patches.ts for additional errors
|
|
45
|
-
] : [];
|
|
46
|
-
function w(e, ...t) {
|
|
47
|
-
if (process.env.NODE_ENV !== "production") {
|
|
48
|
-
const r = dt[e], n = v(r) ? r.apply(null, t) : r;
|
|
49
|
-
throw new Error(`[Immer] ${n}`);
|
|
50
|
-
}
|
|
51
|
-
throw new Error(
|
|
52
|
-
`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
var S = Object, K = S.getPrototypeOf, Z = "constructor", oe = "prototype", Pe = "configurable", ee = "enumerable", Y = "writable", B = "value", V = (e) => !!e && !!e[m];
|
|
56
|
-
function M(e) {
|
|
57
|
-
var t;
|
|
58
|
-
return e ? Xe(e) || ae(e) || !!e[Le] || !!((t = e[Z]) != null && t[Le]) || ue(e) || fe(e) : !1;
|
|
59
|
-
}
|
|
60
|
-
var _t = S[oe][Z].toString(), Ke = /* @__PURE__ */ new WeakMap();
|
|
61
|
-
function Xe(e) {
|
|
62
|
-
if (!e || !Te(e))
|
|
63
|
-
return !1;
|
|
64
|
-
const t = K(e);
|
|
65
|
-
if (t === null || t === S[oe])
|
|
66
|
-
return !0;
|
|
67
|
-
const r = S.hasOwnProperty.call(t, Z) && t[Z];
|
|
68
|
-
if (r === Object)
|
|
69
|
-
return !0;
|
|
70
|
-
if (!v(r))
|
|
71
|
-
return !1;
|
|
72
|
-
let n = Ke.get(r);
|
|
73
|
-
return n === void 0 && (n = Function.toString.call(r), Ke.set(r, n)), n === _t;
|
|
74
|
-
}
|
|
75
|
-
function ce(e, t, r = !0) {
|
|
76
|
-
G(e) === 0 ? (r ? Reflect.ownKeys(e) : S.keys(e)).forEach((i) => {
|
|
77
|
-
t(i, e[i], e);
|
|
78
|
-
}) : e.forEach((n, i) => t(i, n, e));
|
|
79
|
-
}
|
|
80
|
-
function G(e) {
|
|
81
|
-
const t = e[m];
|
|
82
|
-
return t ? t.type_ : ae(e) ? 1 : ue(e) ? 2 : fe(e) ? 3 : 0;
|
|
83
|
-
}
|
|
84
|
-
var Ue = (e, t, r = G(e)) => r === 2 ? e.has(t) : S[oe].hasOwnProperty.call(e, t), Ae = (e, t, r = G(e)) => (
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
r === 2 ? e.get(t) : e[t]
|
|
87
|
-
), te = (e, t, r, n = G(e)) => {
|
|
88
|
-
n === 2 ? e.set(t, r) : n === 3 ? e.add(r) : e[t] = r;
|
|
89
|
-
};
|
|
90
|
-
function yt(e, t) {
|
|
91
|
-
return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
|
|
92
|
-
}
|
|
93
|
-
var ae = Array.isArray, ue = (e) => e instanceof Map, fe = (e) => e instanceof Set, Te = (e) => typeof e == "object", v = (e) => typeof e == "function", we = (e) => typeof e == "boolean";
|
|
94
|
-
function pt(e) {
|
|
95
|
-
const t = +e;
|
|
96
|
-
return Number.isInteger(t) && String(t) === e;
|
|
97
|
-
}
|
|
98
|
-
var D = (e) => e.copy_ || e.base_, Ee = (e) => e.modified_ ? e.copy_ : e.base_;
|
|
99
|
-
function be(e, t) {
|
|
100
|
-
if (ue(e))
|
|
101
|
-
return new Map(e);
|
|
102
|
-
if (fe(e))
|
|
103
|
-
return new Set(e);
|
|
104
|
-
if (ae(e))
|
|
105
|
-
return Array[oe].slice.call(e);
|
|
106
|
-
const r = Xe(e);
|
|
107
|
-
if (t === !0 || t === "class_only" && !r) {
|
|
108
|
-
const n = S.getOwnPropertyDescriptors(e);
|
|
109
|
-
delete n[m];
|
|
110
|
-
let i = Reflect.ownKeys(n);
|
|
111
|
-
for (let s = 0; s < i.length; s++) {
|
|
112
|
-
const c = i[s], u = n[c];
|
|
113
|
-
u[Y] === !1 && (u[Y] = !0, u[Pe] = !0), (u.get || u.set) && (n[c] = {
|
|
114
|
-
[Pe]: !0,
|
|
115
|
-
[Y]: !0,
|
|
116
|
-
// could live with !!desc.set as well here...
|
|
117
|
-
[ee]: u[ee],
|
|
118
|
-
[B]: e[c]
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return S.create(K(e), n);
|
|
122
|
-
} else {
|
|
123
|
-
const n = K(e);
|
|
124
|
-
if (n !== null && r)
|
|
125
|
-
return { ...e };
|
|
126
|
-
const i = S.create(n);
|
|
127
|
-
return S.assign(i, e);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function Fe(e, t = !1) {
|
|
131
|
-
return le(e) || V(e) || !M(e) || (G(e) > 1 && S.defineProperties(e, {
|
|
132
|
-
set: J,
|
|
133
|
-
add: J,
|
|
134
|
-
clear: J,
|
|
135
|
-
delete: J
|
|
136
|
-
}), S.freeze(e), t && ce(
|
|
137
|
-
e,
|
|
138
|
-
(r, n) => {
|
|
139
|
-
Fe(n, !0);
|
|
140
|
-
},
|
|
141
|
-
!1
|
|
142
|
-
)), e;
|
|
143
|
-
}
|
|
144
|
-
function mt() {
|
|
145
|
-
w(2);
|
|
146
|
-
}
|
|
147
|
-
var J = {
|
|
148
|
-
[B]: mt
|
|
149
|
-
};
|
|
150
|
-
function le(e) {
|
|
151
|
-
return e === null || !Te(e) ? !0 : S.isFrozen(e);
|
|
152
|
-
}
|
|
153
|
-
var re = "MapSet", Ie = "Patches", je = "ArrayMethods", Ze = {};
|
|
154
|
-
function T(e) {
|
|
155
|
-
const t = Ze[e];
|
|
156
|
-
return t || w(0, e), t;
|
|
157
|
-
}
|
|
158
|
-
var Be = (e) => !!Ze[e], W, et = () => W, gt = (e, t) => ({
|
|
159
|
-
drafts_: [],
|
|
160
|
-
parent_: e,
|
|
161
|
-
immer_: t,
|
|
162
|
-
// Whenever the modified draft contains a draft from another scope, we
|
|
163
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
164
|
-
canAutoFreeze_: !0,
|
|
165
|
-
unfinalizedDrafts_: 0,
|
|
166
|
-
handledSet_: /* @__PURE__ */ new Set(),
|
|
167
|
-
processedForPatches_: /* @__PURE__ */ new Set(),
|
|
168
|
-
mapSetPlugin_: Be(re) ? T(re) : void 0,
|
|
169
|
-
arrayMethodsPlugin_: Be(je) ? T(je) : void 0
|
|
170
|
-
});
|
|
171
|
-
function We(e, t) {
|
|
172
|
-
t && (e.patchPlugin_ = T(Ie), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
|
|
173
|
-
}
|
|
174
|
-
function De(e) {
|
|
175
|
-
Me(e), e.drafts_.forEach(wt), e.drafts_ = null;
|
|
176
|
-
}
|
|
177
|
-
function Me(e) {
|
|
178
|
-
e === W && (W = e.parent_);
|
|
179
|
-
}
|
|
180
|
-
var qe = (e) => W = gt(W, e);
|
|
181
|
-
function wt(e) {
|
|
182
|
-
const t = e[m];
|
|
183
|
-
t.type_ === 0 || t.type_ === 1 ? t.revoke_() : t.revoked_ = !0;
|
|
184
|
-
}
|
|
185
|
-
function Ge(e, t) {
|
|
186
|
-
t.unfinalizedDrafts_ = t.drafts_.length;
|
|
187
|
-
const r = t.drafts_[0];
|
|
188
|
-
if (e !== void 0 && e !== r) {
|
|
189
|
-
r[m].modified_ && (De(t), w(4)), M(e) && (e = He(t, e));
|
|
190
|
-
const { patchPlugin_: i } = t;
|
|
191
|
-
i && i.generateReplacementPatches_(
|
|
192
|
-
r[m].base_,
|
|
193
|
-
e,
|
|
194
|
-
t
|
|
195
|
-
);
|
|
196
|
-
} else
|
|
197
|
-
e = He(t, r);
|
|
198
|
-
return St(t, e, !0), De(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_), e !== Qe ? e : void 0;
|
|
199
|
-
}
|
|
200
|
-
function He(e, t) {
|
|
201
|
-
if (le(t))
|
|
202
|
-
return t;
|
|
203
|
-
const r = t[m];
|
|
204
|
-
if (!r)
|
|
205
|
-
return ne(t, e.handledSet_, e);
|
|
206
|
-
if (!he(r, e))
|
|
207
|
-
return t;
|
|
208
|
-
if (!r.modified_)
|
|
209
|
-
return r.base_;
|
|
210
|
-
if (!r.finalized_) {
|
|
211
|
-
const { callbacks_: n } = r;
|
|
212
|
-
if (n)
|
|
213
|
-
for (; n.length > 0; )
|
|
214
|
-
n.pop()(e);
|
|
215
|
-
nt(r, e);
|
|
216
|
-
}
|
|
217
|
-
return r.copy_;
|
|
218
|
-
}
|
|
219
|
-
function St(e, t, r = !1) {
|
|
220
|
-
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && Fe(t, r);
|
|
221
|
-
}
|
|
222
|
-
function tt(e) {
|
|
223
|
-
e.finalized_ = !0, e.scope_.unfinalizedDrafts_--;
|
|
224
|
-
}
|
|
225
|
-
var he = (e, t) => e.scope_ === t, Pt = [];
|
|
226
|
-
function rt(e, t, r, n) {
|
|
227
|
-
const i = D(e), s = e.type_;
|
|
228
|
-
if (n !== void 0 && Ae(i, n, s) === t) {
|
|
229
|
-
te(i, n, r, s);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (!e.draftLocations_) {
|
|
233
|
-
const u = e.draftLocations_ = /* @__PURE__ */ new Map();
|
|
234
|
-
ce(i, (y, d) => {
|
|
235
|
-
if (V(d)) {
|
|
236
|
-
const _ = u.get(d) || [];
|
|
237
|
-
_.push(y), u.set(d, _);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
const c = e.draftLocations_.get(t) ?? Pt;
|
|
242
|
-
for (const u of c)
|
|
243
|
-
te(i, u, r, s);
|
|
244
|
-
}
|
|
245
|
-
function At(e, t, r) {
|
|
246
|
-
e.callbacks_.push(function(i) {
|
|
247
|
-
var u;
|
|
248
|
-
const s = t;
|
|
249
|
-
if (!s || !he(s, i))
|
|
250
|
-
return;
|
|
251
|
-
(u = i.mapSetPlugin_) == null || u.fixSetContents(s);
|
|
252
|
-
const c = Ee(s);
|
|
253
|
-
rt(e, s.draft_ ?? s, c, r), nt(s, i);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function nt(e, t) {
|
|
257
|
-
var n;
|
|
258
|
-
if (e.modified_ && !e.finalized_ && (e.type_ === 3 || e.type_ === 1 && e.allIndicesReassigned_ || (((n = e.assigned_) == null ? void 0 : n.size) ?? 0) > 0)) {
|
|
259
|
-
const { patchPlugin_: i } = t;
|
|
260
|
-
if (i) {
|
|
261
|
-
const s = i.getPath(e);
|
|
262
|
-
s && i.generatePatches_(e, s, t);
|
|
263
|
-
}
|
|
264
|
-
tt(e);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
function bt(e, t, r) {
|
|
268
|
-
const { scope_: n } = e;
|
|
269
|
-
if (V(r)) {
|
|
270
|
-
const i = r[m];
|
|
271
|
-
he(i, n) && i.callbacks_.push(function() {
|
|
272
|
-
Q(e);
|
|
273
|
-
const c = Ee(i);
|
|
274
|
-
rt(e, r, c, t);
|
|
275
|
-
});
|
|
276
|
-
} else M(r) && e.callbacks_.push(function() {
|
|
277
|
-
const s = D(e);
|
|
278
|
-
e.type_ === 3 ? s.has(r) && ne(r, n.handledSet_, n) : Ae(s, t, e.type_) === r && n.drafts_.length > 1 && (e.assigned_.get(t) ?? !1) === !0 && e.copy_ && ne(
|
|
279
|
-
Ae(e.copy_, t, e.type_),
|
|
280
|
-
n.handledSet_,
|
|
281
|
-
n
|
|
282
|
-
);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
function ne(e, t, r) {
|
|
286
|
-
return !r.immer_.autoFreeze_ && r.unfinalizedDrafts_ < 1 || V(e) || t.has(e) || !M(e) || le(e) || (t.add(e), ce(e, (n, i) => {
|
|
287
|
-
if (V(i)) {
|
|
288
|
-
const s = i[m];
|
|
289
|
-
if (he(s, r)) {
|
|
290
|
-
const c = Ee(s);
|
|
291
|
-
te(e, n, c, e.type_), tt(s);
|
|
292
|
-
}
|
|
293
|
-
} else M(i) && ne(i, t, r);
|
|
294
|
-
})), e;
|
|
295
|
-
}
|
|
296
|
-
function It(e, t) {
|
|
297
|
-
const r = ae(e), n = {
|
|
298
|
-
type_: r ? 1 : 0,
|
|
299
|
-
// Track which produce call this is associated with.
|
|
300
|
-
scope_: t ? t.scope_ : et(),
|
|
301
|
-
// True for both shallow and deep changes.
|
|
302
|
-
modified_: !1,
|
|
303
|
-
// Used during finalization.
|
|
304
|
-
finalized_: !1,
|
|
305
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
306
|
-
// actually instantiated in `prepareCopy()`
|
|
307
|
-
assigned_: void 0,
|
|
308
|
-
// The parent draft state.
|
|
309
|
-
parent_: t,
|
|
310
|
-
// The base state.
|
|
311
|
-
base_: e,
|
|
312
|
-
// The base proxy.
|
|
313
|
-
draft_: null,
|
|
314
|
-
// set below
|
|
315
|
-
// The base copy with any updated values.
|
|
316
|
-
copy_: null,
|
|
317
|
-
// Called by the `produce` function.
|
|
318
|
-
revoke_: null,
|
|
319
|
-
isManual_: !1,
|
|
320
|
-
// `callbacks` actually gets assigned in `createProxy`
|
|
321
|
-
callbacks_: void 0
|
|
322
|
-
};
|
|
323
|
-
let i = n, s = ie;
|
|
324
|
-
r && (i = [n], s = q);
|
|
325
|
-
const { revoke: c, proxy: u } = Proxy.revocable(i, s);
|
|
326
|
-
return n.draft_ = u, n.revoke_ = c, [u, n];
|
|
327
|
-
}
|
|
328
|
-
var ie = {
|
|
329
|
-
get(e, t) {
|
|
330
|
-
if (t === m)
|
|
331
|
-
return e;
|
|
332
|
-
let r = e.scope_.arrayMethodsPlugin_;
|
|
333
|
-
const n = e.type_ === 1 && typeof t == "string";
|
|
334
|
-
if (n && r != null && r.isArrayOperationMethod(t))
|
|
335
|
-
return r.createMethodInterceptor(e, t);
|
|
336
|
-
const i = D(e);
|
|
337
|
-
if (!Ue(i, t, e.type_))
|
|
338
|
-
return Dt(e, i, t);
|
|
339
|
-
const s = i[t];
|
|
340
|
-
if (e.finalized_ || !M(s) || n && e.operationMethod && (r != null && r.isMutatingArrayMethod(
|
|
341
|
-
e.operationMethod
|
|
342
|
-
)) && pt(t))
|
|
343
|
-
return s;
|
|
344
|
-
if (s === Se(e.base_, t)) {
|
|
345
|
-
Q(e);
|
|
346
|
-
const c = e.type_ === 1 ? +t : t, u = Ce(e.scope_, s, e, c);
|
|
347
|
-
return e.copy_[c] = u;
|
|
348
|
-
}
|
|
349
|
-
return s;
|
|
350
|
-
},
|
|
351
|
-
has(e, t) {
|
|
352
|
-
return t in D(e);
|
|
353
|
-
},
|
|
354
|
-
ownKeys(e) {
|
|
355
|
-
return Reflect.ownKeys(D(e));
|
|
356
|
-
},
|
|
357
|
-
set(e, t, r) {
|
|
358
|
-
const n = it(D(e), t);
|
|
359
|
-
if (n != null && n.set)
|
|
360
|
-
return n.set.call(e.draft_, r), !0;
|
|
361
|
-
if (!e.modified_) {
|
|
362
|
-
const i = Se(D(e), t), s = i == null ? void 0 : i[m];
|
|
363
|
-
if (s && s.base_ === r)
|
|
364
|
-
return e.copy_[t] = r, e.assigned_.set(t, !1), !0;
|
|
365
|
-
if (yt(r, i) && (r !== void 0 || Ue(e.base_, t, e.type_)))
|
|
366
|
-
return !0;
|
|
367
|
-
Q(e), Ve(e);
|
|
368
|
-
}
|
|
369
|
-
return e.copy_[t] === r && // special case: handle new props with value 'undefined'
|
|
370
|
-
(r !== void 0 || t in e.copy_) || // special case: NaN
|
|
371
|
-
Number.isNaN(r) && Number.isNaN(e.copy_[t]) || (e.copy_[t] = r, e.assigned_.set(t, !0), bt(e, t, r)), !0;
|
|
372
|
-
},
|
|
373
|
-
deleteProperty(e, t) {
|
|
374
|
-
return Q(e), Se(e.base_, t) !== void 0 || t in e.base_ ? (e.assigned_.set(t, !1), Ve(e)) : e.assigned_.delete(t), e.copy_ && delete e.copy_[t], !0;
|
|
375
|
-
},
|
|
376
|
-
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
377
|
-
// the same guarantee in ES5 mode.
|
|
378
|
-
getOwnPropertyDescriptor(e, t) {
|
|
379
|
-
const r = D(e), n = Reflect.getOwnPropertyDescriptor(r, t);
|
|
380
|
-
return n && {
|
|
381
|
-
[Y]: !0,
|
|
382
|
-
[Pe]: e.type_ !== 1 || t !== "length",
|
|
383
|
-
[ee]: n[ee],
|
|
384
|
-
[B]: r[t]
|
|
385
|
-
};
|
|
386
|
-
},
|
|
387
|
-
defineProperty() {
|
|
388
|
-
w(11);
|
|
389
|
-
},
|
|
390
|
-
getPrototypeOf(e) {
|
|
391
|
-
return K(e.base_);
|
|
392
|
-
},
|
|
393
|
-
setPrototypeOf() {
|
|
394
|
-
w(12);
|
|
395
|
-
}
|
|
396
|
-
}, q = {};
|
|
397
|
-
for (let e in ie) {
|
|
398
|
-
let t = ie[e];
|
|
399
|
-
q[e] = function() {
|
|
400
|
-
const r = arguments;
|
|
401
|
-
return r[0] = r[0][0], t.apply(this, r);
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
q.deleteProperty = function(e, t) {
|
|
405
|
-
return process.env.NODE_ENV !== "production" && isNaN(parseInt(t)) && w(13), q.set.call(this, e, t, void 0);
|
|
406
|
-
};
|
|
407
|
-
q.set = function(e, t, r) {
|
|
408
|
-
return process.env.NODE_ENV !== "production" && t !== "length" && isNaN(parseInt(t)) && w(14), ie.set.call(this, e[0], t, r, e[0]);
|
|
409
|
-
};
|
|
410
|
-
function Se(e, t) {
|
|
411
|
-
const r = e[m];
|
|
412
|
-
return (r ? D(r) : e)[t];
|
|
413
|
-
}
|
|
414
|
-
function Dt(e, t, r) {
|
|
415
|
-
var i;
|
|
416
|
-
const n = it(t, r);
|
|
417
|
-
return n ? B in n ? n[B] : (
|
|
418
|
-
// This is a very special case, if the prop is a getter defined by the
|
|
419
|
-
// prototype, we should invoke it with the draft as context!
|
|
420
|
-
(i = n.get) == null ? void 0 : i.call(e.draft_)
|
|
421
|
-
) : void 0;
|
|
422
|
-
}
|
|
423
|
-
function it(e, t) {
|
|
424
|
-
if (!(t in e))
|
|
425
|
-
return;
|
|
426
|
-
let r = K(e);
|
|
427
|
-
for (; r; ) {
|
|
428
|
-
const n = Object.getOwnPropertyDescriptor(r, t);
|
|
429
|
-
if (n)
|
|
430
|
-
return n;
|
|
431
|
-
r = K(r);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
function Ve(e) {
|
|
435
|
-
e.modified_ || (e.modified_ = !0, e.parent_ && Ve(e.parent_));
|
|
436
|
-
}
|
|
437
|
-
function Q(e) {
|
|
438
|
-
e.copy_ || (e.assigned_ = /* @__PURE__ */ new Map(), e.copy_ = be(
|
|
439
|
-
e.base_,
|
|
440
|
-
e.scope_.immer_.useStrictShallowCopy_
|
|
441
|
-
));
|
|
442
|
-
}
|
|
443
|
-
var Mt = class {
|
|
444
|
-
constructor(e) {
|
|
445
|
-
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1, this.produce = (t, r, n) => {
|
|
446
|
-
if (v(t) && !v(r)) {
|
|
447
|
-
const s = r;
|
|
448
|
-
r = t;
|
|
449
|
-
const c = this;
|
|
450
|
-
return function(y = s, ...d) {
|
|
451
|
-
return c.produce(y, (_) => r.call(this, _, ...d));
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
v(r) || w(6), n !== void 0 && !v(n) && w(7);
|
|
455
|
-
let i;
|
|
456
|
-
if (M(t)) {
|
|
457
|
-
const s = qe(this), c = Ce(s, t, void 0);
|
|
458
|
-
let u = !0;
|
|
459
|
-
try {
|
|
460
|
-
i = r(c), u = !1;
|
|
461
|
-
} finally {
|
|
462
|
-
u ? De(s) : Me(s);
|
|
463
|
-
}
|
|
464
|
-
return We(s, n), Ge(i, s);
|
|
465
|
-
} else if (!t || !Te(t)) {
|
|
466
|
-
if (i = r(t), i === void 0 && (i = t), i === Qe && (i = void 0), this.autoFreeze_ && Fe(i, !0), n) {
|
|
467
|
-
const s = [], c = [];
|
|
468
|
-
T(Ie).generateReplacementPatches_(t, i, {
|
|
469
|
-
patches_: s,
|
|
470
|
-
inversePatches_: c
|
|
471
|
-
}), n(s, c);
|
|
472
|
-
}
|
|
473
|
-
return i;
|
|
474
|
-
} else
|
|
475
|
-
w(1, t);
|
|
476
|
-
}, this.produceWithPatches = (t, r) => {
|
|
477
|
-
if (v(t))
|
|
478
|
-
return (c, ...u) => this.produceWithPatches(c, (y) => t(y, ...u));
|
|
479
|
-
let n, i;
|
|
480
|
-
return [this.produce(t, r, (c, u) => {
|
|
481
|
-
n = c, i = u;
|
|
482
|
-
}), n, i];
|
|
483
|
-
}, we(e == null ? void 0 : e.autoFreeze) && this.setAutoFreeze(e.autoFreeze), we(e == null ? void 0 : e.useStrictShallowCopy) && this.setUseStrictShallowCopy(e.useStrictShallowCopy), we(e == null ? void 0 : e.useStrictIteration) && this.setUseStrictIteration(e.useStrictIteration);
|
|
484
|
-
}
|
|
485
|
-
createDraft(e) {
|
|
486
|
-
M(e) || w(8), V(e) && (e = Vt(e));
|
|
487
|
-
const t = qe(this), r = Ce(t, e, void 0);
|
|
488
|
-
return r[m].isManual_ = !0, Me(t), r;
|
|
489
|
-
}
|
|
490
|
-
finishDraft(e, t) {
|
|
491
|
-
const r = e && e[m];
|
|
492
|
-
(!r || !r.isManual_) && w(9);
|
|
493
|
-
const { scope_: n } = r;
|
|
494
|
-
return We(n, t), Ge(void 0, n);
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
498
|
-
*
|
|
499
|
-
* By default, auto-freezing is enabled.
|
|
500
|
-
*/
|
|
501
|
-
setAutoFreeze(e) {
|
|
502
|
-
this.autoFreeze_ = e;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Pass true to enable strict shallow copy.
|
|
506
|
-
*
|
|
507
|
-
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
508
|
-
*/
|
|
509
|
-
setUseStrictShallowCopy(e) {
|
|
510
|
-
this.useStrictShallowCopy_ = e;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Pass false to use faster iteration that skips non-enumerable properties
|
|
514
|
-
* but still handles symbols for compatibility.
|
|
515
|
-
*
|
|
516
|
-
* By default, strict iteration is enabled (includes all own properties).
|
|
517
|
-
*/
|
|
518
|
-
setUseStrictIteration(e) {
|
|
519
|
-
this.useStrictIteration_ = e;
|
|
520
|
-
}
|
|
521
|
-
shouldUseStrictIteration() {
|
|
522
|
-
return this.useStrictIteration_;
|
|
523
|
-
}
|
|
524
|
-
applyPatches(e, t) {
|
|
525
|
-
let r;
|
|
526
|
-
for (r = t.length - 1; r >= 0; r--) {
|
|
527
|
-
const i = t[r];
|
|
528
|
-
if (i.path.length === 0 && i.op === "replace") {
|
|
529
|
-
e = i.value;
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
r > -1 && (t = t.slice(r + 1));
|
|
534
|
-
const n = T(Ie).applyPatches_;
|
|
535
|
-
return V(e) ? n(e, t) : this.produce(
|
|
536
|
-
e,
|
|
537
|
-
(i) => n(i, t)
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
function Ce(e, t, r, n) {
|
|
542
|
-
const [i, s] = ue(t) ? T(re).proxyMap_(t, r) : fe(t) ? T(re).proxySet_(t, r) : It(t, r);
|
|
543
|
-
return ((r == null ? void 0 : r.scope_) ?? et()).drafts_.push(i), s.callbacks_ = (r == null ? void 0 : r.callbacks_) ?? [], s.key_ = n, r && n !== void 0 ? At(r, s, n) : s.callbacks_.push(function(y) {
|
|
544
|
-
var _;
|
|
545
|
-
(_ = y.mapSetPlugin_) == null || _.fixSetContents(s);
|
|
546
|
-
const { patchPlugin_: d } = y;
|
|
547
|
-
s.modified_ && d && d.generatePatches_(s, [], y);
|
|
548
|
-
}), i;
|
|
549
|
-
}
|
|
550
|
-
function Vt(e) {
|
|
551
|
-
return V(e) || w(10, e), st(e);
|
|
552
|
-
}
|
|
553
|
-
function st(e) {
|
|
554
|
-
if (!M(e) || le(e))
|
|
555
|
-
return e;
|
|
556
|
-
const t = e[m];
|
|
557
|
-
let r, n = !0;
|
|
558
|
-
if (t) {
|
|
559
|
-
if (!t.modified_)
|
|
560
|
-
return t.base_;
|
|
561
|
-
t.finalized_ = !0, r = be(e, t.scope_.immer_.useStrictShallowCopy_), n = t.scope_.immer_.shouldUseStrictIteration();
|
|
562
|
-
} else
|
|
563
|
-
r = be(e, !0);
|
|
564
|
-
return ce(
|
|
565
|
-
r,
|
|
566
|
-
(i, s) => {
|
|
567
|
-
te(r, i, st(s));
|
|
568
|
-
},
|
|
569
|
-
n
|
|
570
|
-
), t && (t.finalized_ = !1), r;
|
|
571
|
-
}
|
|
572
|
-
var Ct = new Mt(), ot = Ct.produce;
|
|
573
|
-
class zt extends E {
|
|
574
|
-
constructor(t, r) {
|
|
575
|
-
super(r), this.a = t, this.push = (...n) => {
|
|
576
|
-
n.length !== 0 && this.a.set(this.a.get().concat(n));
|
|
577
|
-
}, this.unshift = (...n) => {
|
|
578
|
-
n.length !== 0 && this.a.set(n.concat(this.a.get()));
|
|
579
|
-
}, this.update = (n) => {
|
|
580
|
-
const i = this.a.get(), s = ot(i, (c) => void n(c));
|
|
581
|
-
s !== i && this.a.set(s);
|
|
582
|
-
}, this.filter = (n) => {
|
|
583
|
-
const i = this.a.get().filter(n ?? Ot);
|
|
17
|
+
class he extends M {
|
|
18
|
+
constructor(t, a) {
|
|
19
|
+
super(a), this.a = t, this.push = (...e) => {
|
|
20
|
+
e.length !== 0 && this.a.set(this.a.get().concat(e));
|
|
21
|
+
}, this.unshift = (...e) => {
|
|
22
|
+
e.length !== 0 && this.a.set(e.concat(this.a.get()));
|
|
23
|
+
}, this.update = (e) => {
|
|
24
|
+
const i = this.a.get(), n = F(i, (u) => void e(u));
|
|
25
|
+
n !== i && this.a.set(n);
|
|
26
|
+
}, this.filter = (e) => {
|
|
27
|
+
const i = this.a.get().filter(e ?? fe);
|
|
584
28
|
i.length !== this.a.get().length && this.a.set(i);
|
|
585
|
-
}, this.add = (
|
|
586
|
-
this.a.get().includes(
|
|
587
|
-
}, this.removeFirst = (
|
|
588
|
-
const i = this.a.get().indexOf(
|
|
29
|
+
}, this.add = (e) => {
|
|
30
|
+
this.a.get().includes(e) || this.a.set(this.a.get().concat([e]));
|
|
31
|
+
}, this.removeFirst = (e) => {
|
|
32
|
+
const i = this.a.get().indexOf(e);
|
|
589
33
|
if (i < 0) return;
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
}, this.toggle = (
|
|
593
|
-
const
|
|
594
|
-
|
|
34
|
+
const n = this.a.get().slice(0);
|
|
35
|
+
n.splice(i, 1), this.a.set(n);
|
|
36
|
+
}, this.toggle = (e, i) => {
|
|
37
|
+
const n = this.a.get().slice(), u = n.indexOf(e);
|
|
38
|
+
u < 0 ? i ? n.unshift(e) : n.push(e) : n.splice(u, 1), this.a.set(n);
|
|
595
39
|
};
|
|
596
40
|
}
|
|
597
41
|
}
|
|
598
|
-
const
|
|
599
|
-
class
|
|
600
|
-
constructor(t,
|
|
601
|
-
super(
|
|
42
|
+
const fe = (s) => s;
|
|
43
|
+
class ge extends M {
|
|
44
|
+
constructor(t, a) {
|
|
45
|
+
super(a), this.a = t, this.toggle = () => {
|
|
602
46
|
this.a.set(!this.a.get());
|
|
603
47
|
};
|
|
604
48
|
}
|
|
605
49
|
}
|
|
606
|
-
class
|
|
607
|
-
constructor(t,
|
|
608
|
-
super(
|
|
609
|
-
if (this.a.get().get(
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
}, this.setIfNo = (
|
|
613
|
-
if (this.a.get().has(
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
}, this.delete = (
|
|
617
|
-
if (!this.a.get().has(
|
|
50
|
+
class de extends M {
|
|
51
|
+
constructor(t, a) {
|
|
52
|
+
super(a), this.a = t, this.setValue = (e, i) => {
|
|
53
|
+
if (this.a.get().get(e) === i) return;
|
|
54
|
+
const n = new Map(this.a.get());
|
|
55
|
+
n.set(e, i), this.a.set(n);
|
|
56
|
+
}, this.setIfNo = (e, i) => {
|
|
57
|
+
if (this.a.get().has(e)) return;
|
|
58
|
+
const n = new Map(this.a.get());
|
|
59
|
+
n.set(e, i), this.a.set(n);
|
|
60
|
+
}, this.delete = (e) => {
|
|
61
|
+
if (!this.a.get().has(e)) return;
|
|
618
62
|
const i = new Map(this.a.get());
|
|
619
|
-
i.delete(
|
|
620
|
-
}, this.toggle = (
|
|
621
|
-
const
|
|
622
|
-
|
|
63
|
+
i.delete(e), this.a.set(i);
|
|
64
|
+
}, this.toggle = (e, i) => {
|
|
65
|
+
const n = new Map(this.a.get());
|
|
66
|
+
n.has(e) ? n.delete(e) : n.set(e, i), this.a.set(n);
|
|
623
67
|
}, this.clear = () => {
|
|
624
68
|
this.a.set(/* @__PURE__ */ new Map());
|
|
625
69
|
}, this.a = t;
|
|
626
70
|
}
|
|
627
71
|
}
|
|
628
|
-
class
|
|
629
|
-
constructor(t,
|
|
630
|
-
super(
|
|
631
|
-
this.a.set(+this.a.get() + (
|
|
72
|
+
class pe extends M {
|
|
73
|
+
constructor(t, a) {
|
|
74
|
+
super(a), this.a = t, this.increment = (e) => {
|
|
75
|
+
this.a.set(+this.a.get() + (e ?? 1));
|
|
632
76
|
};
|
|
633
77
|
}
|
|
634
78
|
}
|
|
635
|
-
class
|
|
636
|
-
constructor(t,
|
|
637
|
-
super(
|
|
79
|
+
class we extends M {
|
|
80
|
+
constructor(t, a) {
|
|
81
|
+
super(a), this.a = t, this.setPartial = (e) => this.a.set((i) => ({
|
|
638
82
|
...i,
|
|
639
|
-
...typeof
|
|
640
|
-
})), this.update = (
|
|
641
|
-
const i = this.a.get(),
|
|
642
|
-
|
|
643
|
-
}, this.setDeepPartial = (
|
|
644
|
-
if (!
|
|
645
|
-
if (
|
|
646
|
-
let
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
const
|
|
650
|
-
let h =
|
|
651
|
-
for (const
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
655
|
-
if (
|
|
656
|
-
const
|
|
657
|
-
this.a.get()[
|
|
83
|
+
...typeof e == "function" ? e(this.a.get()) : e
|
|
84
|
+
})), this.update = (e) => {
|
|
85
|
+
const i = this.a.get(), n = F(i, (u) => void e(u));
|
|
86
|
+
n !== i && this.a.set(n);
|
|
87
|
+
}, this.setDeepPartial = (e, i, n, u = w.keyPathSeparator || ".") => {
|
|
88
|
+
if (!u) return;
|
|
89
|
+
if (e.includes(u)) {
|
|
90
|
+
let V = e.split(u);
|
|
91
|
+
const m = V[V.length - 1];
|
|
92
|
+
V = V.slice(0, -1);
|
|
93
|
+
const C = { ...this.a.get() };
|
|
94
|
+
let h = C, f = n;
|
|
95
|
+
for (const c of V) {
|
|
96
|
+
f = f == null ? void 0 : f[Array.isArray(f) ? "0" : c];
|
|
97
|
+
const x = h[Z(h, c)] ?? (Array.isArray(f) ? [] : {});
|
|
98
|
+
if (x == null || typeof x != "object") {
|
|
99
|
+
if (n == null) throw "Incorrect path for setDeepPartial";
|
|
100
|
+
const y = typeof i == "function" ? i(void 0) : i;
|
|
101
|
+
this.a.get()[e] !== y && this.setPartial({ [e]: y });
|
|
658
102
|
return;
|
|
659
103
|
}
|
|
660
|
-
h = h[
|
|
104
|
+
h = h[Z(h, c)] = Array.isArray(x) ? [...x] : { ...x };
|
|
661
105
|
}
|
|
662
|
-
const
|
|
663
|
-
h[
|
|
106
|
+
const O = h[m];
|
|
107
|
+
h[m] = typeof i == "function" ? i(h[m]) : i, O !== h[m] && this.a.set(C);
|
|
664
108
|
return;
|
|
665
109
|
}
|
|
666
|
-
const
|
|
667
|
-
|
|
110
|
+
const A = this.a.get()[e], b = typeof i == "function" ? i(A) : i;
|
|
111
|
+
b !== A && this.setPartial({ [e]: b });
|
|
668
112
|
};
|
|
669
113
|
}
|
|
670
114
|
}
|
|
671
|
-
const
|
|
672
|
-
class
|
|
673
|
-
constructor(t,
|
|
674
|
-
super(
|
|
675
|
-
this.a.get().has(
|
|
676
|
-
}, this.delete = (
|
|
677
|
-
if (!this.a.get().has(
|
|
115
|
+
const Z = (s, t) => Array.isArray(s) ? `${+t}` : t;
|
|
116
|
+
class me extends M {
|
|
117
|
+
constructor(t, a) {
|
|
118
|
+
super(a), this.a = t, this.add = (e) => {
|
|
119
|
+
this.a.get().has(e) || this.a.set(new Set(this.a.get()).add(e));
|
|
120
|
+
}, this.delete = (e) => {
|
|
121
|
+
if (!this.a.get().has(e)) return;
|
|
678
122
|
const i = new Set(this.a.get());
|
|
679
|
-
i.delete(
|
|
680
|
-
}, this.toggle = (
|
|
123
|
+
i.delete(e), this.a.set(i);
|
|
124
|
+
}, this.toggle = (e) => {
|
|
681
125
|
const i = new Set(this.a.get());
|
|
682
|
-
i.has(
|
|
126
|
+
i.has(e) ? i.delete(e) : i.add(e), this.a.set(i);
|
|
683
127
|
}, this.clear = () => {
|
|
684
128
|
this.a.set(/* @__PURE__ */ new Set());
|
|
685
129
|
}, this.a = t;
|
|
686
130
|
}
|
|
687
131
|
}
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
(
|
|
132
|
+
const ye = (s, t, a) => {
|
|
133
|
+
const e = typeof a == "object" && a != null && "do" in a ? a.do(
|
|
134
|
+
(n, u) => t.set(n, u),
|
|
691
135
|
() => t.get(),
|
|
692
136
|
t,
|
|
693
|
-
(
|
|
137
|
+
(n, u, A, b) => t.setDeferred(n, u, A, b)
|
|
694
138
|
) : null, i = {};
|
|
695
|
-
return
|
|
139
|
+
return e && Object.keys(e).forEach((n) => Object.defineProperty(i, n, { get: () => e[n] })), typeof s == "number" ? new pe(t, e) : typeof s == "boolean" ? new ge(t, e) : Array.isArray(s) ? new he(t, e) : s instanceof Set ? new me(t, e) : s instanceof Map ? new de(t, e) : s instanceof Object ? new we(t, e) : new M(e);
|
|
696
140
|
};
|
|
697
|
-
class
|
|
698
|
-
constructor(t,
|
|
699
|
-
this.isInited = !1, this.rawInitialValue = t, this.rawOptions =
|
|
141
|
+
class Se {
|
|
142
|
+
constructor(t, a) {
|
|
143
|
+
this.isInited = !1, this.rawInitialValue = t, this.rawOptions = a;
|
|
700
144
|
}
|
|
701
145
|
get initialValue() {
|
|
702
146
|
return this.init(), this.initialValue;
|
|
@@ -720,226 +164,253 @@ class $t {
|
|
|
720
164
|
return this.init(), this.isInitialValue;
|
|
721
165
|
}
|
|
722
166
|
get do() {
|
|
723
|
-
return this.init(), this.doActions ?? (this.doActions =
|
|
167
|
+
return this.init(), this.doActions ?? (this.doActions = ye(this.initialValue, this, this.rawOptions));
|
|
724
168
|
}
|
|
725
169
|
init() {
|
|
170
|
+
var X;
|
|
726
171
|
if (this.isInited) return;
|
|
727
172
|
this.isInited = !0;
|
|
728
|
-
const t = typeof this.rawInitialValue == "function" ? this.rawInitialValue() : this.rawInitialValue,
|
|
729
|
-
let
|
|
730
|
-
}, h = () =>
|
|
731
|
-
|
|
732
|
-
},
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
173
|
+
const t = typeof this.rawInitialValue == "function" ? this.rawInitialValue() : this.rawInitialValue, a = (r) => V = r, e = () => V, i = /* @__PURE__ */ new Set(), n = (r) => r(h());
|
|
174
|
+
let u = !0, A = !1, b = (r) => r, V = t, m, C = () => {
|
|
175
|
+
}, h = () => e(), f = null, O = () => {
|
|
176
|
+
y(t, !0);
|
|
177
|
+
}, c = "";
|
|
178
|
+
const x = () => {
|
|
179
|
+
if (u = !0, A !== !0 && C(h()), A = !1, !!c)
|
|
735
180
|
try {
|
|
736
|
-
|
|
181
|
+
W.postMessage({ key: c, value: e() });
|
|
737
182
|
} catch {
|
|
738
183
|
}
|
|
739
|
-
},
|
|
740
|
-
let
|
|
741
|
-
|
|
742
|
-
},
|
|
743
|
-
|
|
184
|
+
}, y = (r, l) => {
|
|
185
|
+
let d = typeof r == "function" ? r(h()) : r;
|
|
186
|
+
d = b(d, h()), d !== h() && (a(d), A = l, u && (u = !1, i.forEach(n), queueMicrotask(x)));
|
|
187
|
+
}, I = (r, l) => Object.defineProperty(this, r, { value: l, writable: !1, configurable: !0, enumerable: !0 });
|
|
188
|
+
I("initialValue", t), I("get", () => h()), I(
|
|
744
189
|
"set",
|
|
745
|
-
(
|
|
746
|
-
),
|
|
747
|
-
i.delete(
|
|
748
|
-
})),
|
|
749
|
-
const
|
|
750
|
-
|
|
190
|
+
(r, l) => y(r, l)
|
|
191
|
+
), I("isInitialValue", () => t === e()), I("subscribe", (r) => (i.add(r), () => {
|
|
192
|
+
i.delete(r);
|
|
193
|
+
})), I("reset", () => O());
|
|
194
|
+
const ce = (r, l) => {
|
|
195
|
+
y(r, l), m = void 0;
|
|
751
196
|
};
|
|
752
|
-
|
|
197
|
+
I(
|
|
753
198
|
"setDeferred",
|
|
754
|
-
(
|
|
755
|
-
|
|
199
|
+
(r, l = 500, d, S = !0) => {
|
|
200
|
+
S && m === void 0 && y(r, d), clearTimeout(m), m = setTimeout(ce, l, r, d);
|
|
756
201
|
}
|
|
757
202
|
);
|
|
758
203
|
const g = this.rawOptions;
|
|
759
204
|
if (g == null) return;
|
|
760
|
-
let
|
|
761
|
-
if (
|
|
762
|
-
throw console.error(
|
|
763
|
-
} : t instanceof Map ? (
|
|
764
|
-
if (
|
|
205
|
+
let p = null, K = null, R = !0, D = 0, _ = 0, H = -1, $ = t instanceof Set ? (r) => new Set(r) : t instanceof Map ? (r) => new Map(r) : (r) => r, L = t instanceof Set ? (r) => {
|
|
206
|
+
if (r instanceof Set) return Array.from(r);
|
|
207
|
+
throw console.error(r), "The value is not Set instance";
|
|
208
|
+
} : t instanceof Map ? (r) => {
|
|
209
|
+
if (r instanceof Map) {
|
|
765
210
|
const l = [];
|
|
766
|
-
return
|
|
211
|
+
return r.forEach((d, S) => l.push([S, d])), l;
|
|
767
212
|
}
|
|
768
|
-
throw console.error(
|
|
769
|
-
} : (
|
|
213
|
+
throw console.error(r), "The value is not Set instance";
|
|
214
|
+
} : (r) => r;
|
|
770
215
|
if (typeof g == "string")
|
|
771
|
-
|
|
216
|
+
p = g;
|
|
772
217
|
else {
|
|
773
|
-
if (
|
|
774
|
-
|
|
218
|
+
if (b = g.map ?? b, !("storageKey" in g)) return;
|
|
219
|
+
R = g.warnOnDuplicateStorageKey ?? R, p = g.storageKey, $ = g.unzipValue ?? $, L = g.zipValue ?? L, D = g.securifyKeyLevel ?? w.securifyKeyLevel ?? D, _ = g.securifyValueLevel ?? w.securifyValueLevel ?? _, K = g.exp ?? K;
|
|
775
220
|
}
|
|
776
|
-
const
|
|
777
|
-
if (
|
|
778
|
-
|
|
779
|
-
|
|
221
|
+
const o = w.storage;
|
|
222
|
+
if (!o) throw "call configureAtomaric({storage: new AtomaricLocalStorage()}) before all!";
|
|
223
|
+
const z = D ? P(p, D) : p;
|
|
224
|
+
if (c = `${_ ? q : T}${z}`, D) {
|
|
225
|
+
const r = `${T}${p}`;
|
|
226
|
+
o.has(r) && (o.set(c, o.get(r)), o.rem(r));
|
|
780
227
|
} else {
|
|
781
|
-
const
|
|
782
|
-
o
|
|
228
|
+
const r = `${T}${P(p, D)}`;
|
|
229
|
+
o.has(r) && (o.set(c, o.get(r)), o.rem(r));
|
|
783
230
|
}
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
231
|
+
const U = K === null || !(K(this, o.has(c)) instanceof Date) ? (r) => P([L(r)], 0) : (r) => (f ?? (f = {}), f.exp = K(this, o.has(c)).getTime(), f.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout(H), clearTimeout(ne[c]), H = setTimeout(() => this.reset(), f.exp - Date.now())), f.exp = Math.trunc(f.exp / 1e3), P([L(r), f], 0));
|
|
232
|
+
if (_) {
|
|
233
|
+
const r = `${T}${z}`, l = L, d = $;
|
|
234
|
+
if (L = (S) => {
|
|
788
235
|
try {
|
|
789
|
-
return
|
|
236
|
+
return P([l(S)], _);
|
|
790
237
|
} catch {
|
|
791
|
-
return
|
|
238
|
+
return o.rem(c), "";
|
|
792
239
|
}
|
|
793
|
-
}, o
|
|
794
|
-
const
|
|
240
|
+
}, o.has(r)) {
|
|
241
|
+
const S = `${T}${P(p, D)}`;
|
|
795
242
|
try {
|
|
796
|
-
|
|
243
|
+
o.set(S, U($(j(o.get(r), 0)[0]))), o.rem(r);
|
|
797
244
|
} catch {
|
|
798
245
|
}
|
|
799
246
|
}
|
|
800
|
-
|
|
247
|
+
$ = (S) => {
|
|
801
248
|
try {
|
|
802
|
-
return
|
|
249
|
+
return d(j(S, _)[0]);
|
|
803
250
|
} catch {
|
|
804
|
-
return
|
|
251
|
+
return o.rem(c), "";
|
|
805
252
|
}
|
|
806
253
|
};
|
|
807
|
-
} else
|
|
808
|
-
const
|
|
809
|
-
const l =
|
|
810
|
-
return
|
|
254
|
+
} else o.rem(`${q}${z}`);
|
|
255
|
+
const J = (r) => {
|
|
256
|
+
const l = j(r, 0);
|
|
257
|
+
return f = l[1], $(l[0]);
|
|
811
258
|
};
|
|
812
|
-
let
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
259
|
+
let G = !0;
|
|
260
|
+
N[c] = this;
|
|
261
|
+
const Q = o.get(`atom/${p}`);
|
|
262
|
+
if (Q !== void 0 && (o.get(c) || o.set(c, `[${Q}]`), o.rem(`atom/${p}`)), h = () => {
|
|
263
|
+
if (h = e, G) {
|
|
264
|
+
G = !1;
|
|
816
265
|
try {
|
|
817
|
-
r
|
|
266
|
+
const r = o.get(c);
|
|
267
|
+
a(r !== void 0 ? J(r) : t);
|
|
818
268
|
} catch {
|
|
819
|
-
console.warn("Invalid json value",
|
|
269
|
+
console.warn("Invalid json value", o.get(c));
|
|
820
270
|
}
|
|
821
271
|
}
|
|
822
|
-
return
|
|
823
|
-
},
|
|
824
|
-
if (
|
|
272
|
+
return e();
|
|
273
|
+
}, C = (r) => {
|
|
274
|
+
if (r === t) {
|
|
825
275
|
this.reset();
|
|
826
276
|
return;
|
|
827
277
|
}
|
|
828
|
-
|
|
829
|
-
},
|
|
830
|
-
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
278
|
+
o.set(c, U(r));
|
|
279
|
+
}, O = () => {
|
|
280
|
+
o.rem(c), y(t, !0);
|
|
281
|
+
}, R && ee.has(c) && console.warn("Duplicate Atom key", p), ee.add(c), o.unchangable ?? !1) {
|
|
282
|
+
(X = o.protect) == null || X.call(o, c);
|
|
283
|
+
let r = !1, l;
|
|
284
|
+
ie[c] = this, o.listen(c, () => {
|
|
285
|
+
clearTimeout(l), l = setTimeout(() => r = !1, 10), !r && (r = !0, o.set(c, U(e())));
|
|
286
|
+
});
|
|
287
|
+
} else
|
|
288
|
+
o.listen(c, (r) => {
|
|
289
|
+
if (r.newValue === null) {
|
|
290
|
+
this.reset();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
y(J(r.newValue));
|
|
295
|
+
} catch {
|
|
296
|
+
console.warn("Invalid json value", r.newValue);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
849
299
|
}
|
|
850
300
|
}
|
|
851
|
-
let
|
|
301
|
+
let W;
|
|
852
302
|
try {
|
|
853
|
-
|
|
303
|
+
W = new BroadcastChannel("updateHere"), W.addEventListener("message", (s) => {
|
|
854
304
|
var t;
|
|
855
|
-
(t =
|
|
305
|
+
(t = ie[s.data.key]) == null || t.set(s.data.value, !0);
|
|
856
306
|
});
|
|
857
307
|
} catch {
|
|
858
308
|
}
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
const Rt = a.setItem.bind(a), kt = a.removeItem.bind(a);
|
|
865
|
-
a.setItem = (e, t) => {
|
|
866
|
-
de[e] === void 0 && Rt.call(a, e, t);
|
|
867
|
-
};
|
|
868
|
-
a.removeItem = (e) => {
|
|
869
|
-
de[e] === void 0 && kt.call(a, e);
|
|
870
|
-
};
|
|
871
|
-
const Lt = /"exp":\s*(\d+)/, k = "atom\\", Oe = "atom`s\\", ve = {}, ct = {}, at = /[a-z]/gi, se = 5, xe = {};
|
|
872
|
-
for (let e = 54; e < 80; e++) {
|
|
873
|
-
if (e === 68 || e === 72 || e === 55) continue;
|
|
874
|
-
const t = String.fromCharCode(e + 43).toUpperCase(), r = String.fromCharCode(e + 43).toLowerCase();
|
|
875
|
-
xe[t] = r, xe[r] = t;
|
|
309
|
+
const ee = /* @__PURE__ */ new Set(), ie = {}, Ae = /"exp":\s*(\d+)/, T = "atom\\", q = "atom`s\\", N = {}, ne = {}, ae = /[a-z]/gi, E = 5, k = {};
|
|
310
|
+
for (let s = 54; s < 80; s++) {
|
|
311
|
+
if (s === 68 || s === 72 || s === 55) continue;
|
|
312
|
+
const t = String.fromCharCode(s + 43).toUpperCase(), a = String.fromCharCode(s + 43).toLowerCase();
|
|
313
|
+
k[t] = a, k[a] = t;
|
|
876
314
|
}
|
|
877
|
-
const
|
|
878
|
-
const
|
|
315
|
+
const oe = (s) => k[s] ?? s, P = /* @__PURE__ */ (() => {
|
|
316
|
+
const s = [
|
|
879
317
|
(t) => JSON.stringify(t),
|
|
880
|
-
(t) => btoa(encodeURI(
|
|
318
|
+
(t) => btoa(encodeURI(s[0](t))),
|
|
881
319
|
(t) => {
|
|
882
|
-
const
|
|
883
|
-
return `${
|
|
320
|
+
const a = s[1](t);
|
|
321
|
+
return `${a.slice(0, E)}${a.slice(E).replace(ae, oe)}`;
|
|
884
322
|
},
|
|
885
|
-
(t) => btoa(
|
|
323
|
+
(t) => btoa(s[2](t))
|
|
886
324
|
];
|
|
887
|
-
return (t,
|
|
325
|
+
return (t, a) => {
|
|
888
326
|
try {
|
|
889
|
-
return
|
|
890
|
-
} catch (
|
|
891
|
-
if (
|
|
892
|
-
return
|
|
327
|
+
return s[a](t);
|
|
328
|
+
} catch (e) {
|
|
329
|
+
if (a === 0) throw e;
|
|
330
|
+
return s[0](t);
|
|
893
331
|
}
|
|
894
332
|
};
|
|
895
|
-
})(),
|
|
896
|
-
const
|
|
333
|
+
})(), j = /* @__PURE__ */ (() => {
|
|
334
|
+
const s = [
|
|
897
335
|
(t) => JSON.parse(t),
|
|
898
|
-
(t) =>
|
|
899
|
-
(t) =>
|
|
900
|
-
`${t.slice(0,
|
|
336
|
+
(t) => s[0](decodeURI(atob(t))),
|
|
337
|
+
(t) => s[1](
|
|
338
|
+
`${t.slice(0, E)}${t.slice(E).replace(ae, oe)}`
|
|
901
339
|
),
|
|
902
|
-
(t) =>
|
|
340
|
+
(t) => s[2](atob(t))
|
|
903
341
|
];
|
|
904
|
-
return (t,
|
|
342
|
+
return (t, a) => {
|
|
905
343
|
try {
|
|
906
|
-
return
|
|
907
|
-
} catch (
|
|
908
|
-
if (
|
|
909
|
-
return
|
|
344
|
+
return s[a](t);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
if (a === 0) throw e;
|
|
347
|
+
return s[0](t);
|
|
910
348
|
}
|
|
911
349
|
};
|
|
912
350
|
})();
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
()
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
351
|
+
let te = !1;
|
|
352
|
+
const be = (s) => {
|
|
353
|
+
te || (te = !0, setTimeout(() => {
|
|
354
|
+
s.keys().forEach((t) => {
|
|
355
|
+
var i, n;
|
|
356
|
+
if (!t.startsWith(T) && !t.startsWith(q)) return;
|
|
357
|
+
const a = (n = (i = s.get(t)) == null ? void 0 : i.match(Ae)) == null ? void 0 : n[1];
|
|
358
|
+
if (!a || +a * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
|
|
359
|
+
const e = j(s.get(t), 0);
|
|
360
|
+
!Array.isArray(e) || e[1] == null || !("exp" in e[1]) || e[1].exp !== a || (ne[t] = setTimeout(
|
|
361
|
+
() => {
|
|
362
|
+
N[t] ? N[t].reset() : s.rem(t);
|
|
363
|
+
},
|
|
364
|
+
+a * 1e3 - Date.now()
|
|
365
|
+
));
|
|
366
|
+
});
|
|
367
|
+
}, 1e3));
|
|
368
|
+
}, Ve = localStorage.setItem.bind(localStorage), xe = localStorage.removeItem.bind(localStorage), v = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Set();
|
|
369
|
+
let se = !1;
|
|
370
|
+
function Ie() {
|
|
371
|
+
if (se) return;
|
|
372
|
+
se = !0;
|
|
373
|
+
const s = Object.getPrototypeOf(localStorage), t = s.setItem, a = s.removeItem;
|
|
374
|
+
s.setItem = function(e, i) {
|
|
375
|
+
B.has(e) || t.call(this, e, i);
|
|
376
|
+
}, s.removeItem = function(e) {
|
|
377
|
+
B.has(e) || a.call(this, e);
|
|
378
|
+
}, window.addEventListener("storage", (e) => {
|
|
379
|
+
var i;
|
|
380
|
+
e.key === null || e.newValue === e.oldValue || (i = v.get(e.key)) == null || i.forEach((n) => n({ newValue: e.newValue }));
|
|
926
381
|
});
|
|
927
|
-
}
|
|
382
|
+
}
|
|
383
|
+
class Ce {
|
|
384
|
+
constructor({ listenStorageChanges: t = !0, unchangable: a = !1 } = {}) {
|
|
385
|
+
this.set = (e, i) => Ve(e, i), this.get = (e) => localStorage.getItem(e) ?? void 0, this.rem = (e) => xe(e), this.has = (e) => localStorage.getItem(e) !== null, this.keys = () => Array.from({ length: localStorage.length }, (e, i) => localStorage.key(i)).filter(
|
|
386
|
+
(e) => e !== null
|
|
387
|
+
), this.listen = (e, i) => {
|
|
388
|
+
if (!this.listenStorageChanges) return () => {
|
|
389
|
+
};
|
|
390
|
+
let n = v.get(e);
|
|
391
|
+
return n || v.set(e, n = /* @__PURE__ */ new Set()), n.add(i), () => n.delete(i);
|
|
392
|
+
}, this.protect = (e) => {
|
|
393
|
+
this.listenStorageChanges && B.add(e);
|
|
394
|
+
}, this.listenStorageChanges = t, this.unchangable = a, t && Ie();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
928
397
|
export {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
398
|
+
Se as Atom,
|
|
399
|
+
he as AtomArrayDoActions,
|
|
400
|
+
ge as AtomBooleanDoActions,
|
|
401
|
+
de as AtomMapDoActions,
|
|
402
|
+
pe as AtomNumberDoActions,
|
|
403
|
+
we as AtomObjectDoActions,
|
|
404
|
+
me as AtomSetDoActions,
|
|
405
|
+
Ce as AtomaricLocalStorage,
|
|
406
|
+
Te as atom,
|
|
407
|
+
Me as configureAtomaric,
|
|
408
|
+
w as configuredOptions,
|
|
409
|
+
be as initExpWatcher,
|
|
410
|
+
Pe as useAtom,
|
|
411
|
+
Le as useAtomDo,
|
|
412
|
+
$e as useAtomGet,
|
|
413
|
+
ue as useAtomSet,
|
|
414
|
+
_e as useAtomSetDeferred,
|
|
415
|
+
le as useAtomValue
|
|
945
416
|
};
|