atomaric 0.0.78 → 0.0.79
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/build/atomaric.js +809 -287
- package/build/atomaric.umd.cjs +1 -1
- package/package.json +2 -1
package/build/atomaric.js
CHANGED
|
@@ -1,392 +1,914 @@
|
|
|
1
|
-
let
|
|
1
|
+
let Je = () => {
|
|
2
2
|
throw "call configureAtomaric() before all!";
|
|
3
3
|
};
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
class
|
|
8
|
-
constructor(
|
|
9
|
-
if (
|
|
4
|
+
const T = {}, Ot = (e) => {
|
|
5
|
+
T.useSyncExternalStore = Je = e.useSyncExternalStore, T.keyPathSeparator = e.keyPathSeparator, T.securifyKeyLevel = e.securifyKeyLevel, T.securifyValueLevel = e.securifyValueLevel;
|
|
6
|
+
}, ft = (e) => Je(e.subscribe, e.get), lt = (e) => e.set, jt = (e) => e.setDeferred, Bt = (e) => e.get, Wt = (e) => e.do, qt = (e) => [ft(e), lt(e)], Gt = (e, t) => new Rt(e, t);
|
|
7
|
+
class F {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
if (t)
|
|
10
10
|
return new Proxy(this, {
|
|
11
|
-
get: (
|
|
11
|
+
get: (r, n) => n in this ? r[n] : t[n]
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
var Ye = Symbol.for("immer-nothing"), Ve = Symbol.for("immer-draftable"), m = Symbol.for("immer-state"), dt = process.env.NODE_ENV !== "production" ? [
|
|
16
|
+
// All error codes, starting by 0:
|
|
17
|
+
function(e) {
|
|
18
|
+
return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`;
|
|
19
|
+
},
|
|
20
|
+
function(e) {
|
|
21
|
+
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 '${e}'`;
|
|
22
|
+
},
|
|
23
|
+
"This object has been frozen and should not be mutated",
|
|
24
|
+
function(e) {
|
|
25
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e;
|
|
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 g(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 w = Object, U = w.getPrototypeOf, X = "constructor", ie = "prototype", Se = "configurable", Z = "enumerable", J = "writable", B = "value", M = (e) => !!e && !!e[m];
|
|
56
|
+
function C(e) {
|
|
57
|
+
var t;
|
|
58
|
+
return e ? Qe(e) || ce(e) || !!e[Ve] || !!((t = e[X]) != null && t[Ve]) || ae(e) || ue(e) : !1;
|
|
59
|
+
}
|
|
60
|
+
var ht = w[ie][X].toString(), Ue = /* @__PURE__ */ new WeakMap();
|
|
61
|
+
function Qe(e) {
|
|
62
|
+
if (!e || !Ee(e))
|
|
63
|
+
return !1;
|
|
64
|
+
const t = U(e);
|
|
65
|
+
if (t === null || t === w[ie])
|
|
66
|
+
return !0;
|
|
67
|
+
const r = w.hasOwnProperty.call(t, X) && t[X];
|
|
68
|
+
if (r === Object)
|
|
69
|
+
return !0;
|
|
70
|
+
if (!v(r))
|
|
71
|
+
return !1;
|
|
72
|
+
let n = Ue.get(r);
|
|
73
|
+
return n === void 0 && (n = Function.toString.call(r), Ue.set(r, n)), n === ht;
|
|
74
|
+
}
|
|
75
|
+
function oe(e, t, r = !0) {
|
|
76
|
+
G(e) === 0 ? (r ? Reflect.ownKeys(e) : w.keys(e)).forEach((s) => {
|
|
77
|
+
t(s, e[s], e);
|
|
78
|
+
}) : e.forEach((n, s) => t(s, n, e));
|
|
79
|
+
}
|
|
80
|
+
function G(e) {
|
|
81
|
+
const t = e[m];
|
|
82
|
+
return t ? t.type_ : ce(e) ? 1 : ae(e) ? 2 : ue(e) ? 3 : 0;
|
|
83
|
+
}
|
|
84
|
+
var Oe = (e, t, r = G(e)) => r === 2 ? e.has(t) : w[ie].hasOwnProperty.call(e, t), Pe = (e, t, r = G(e)) => (
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
r === 2 ? e.get(t) : e[t]
|
|
87
|
+
), ee = (e, t, r, n = G(e)) => {
|
|
88
|
+
n === 2 ? e.set(t, r) : n === 3 ? e.add(r) : e[t] = r;
|
|
89
|
+
};
|
|
90
|
+
function _t(e, t) {
|
|
91
|
+
return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
|
|
92
|
+
}
|
|
93
|
+
var ce = Array.isArray, ae = (e) => e instanceof Map, ue = (e) => e instanceof Set, Ee = (e) => typeof e == "object", v = (e) => typeof e == "function", ge = (e) => typeof e == "boolean";
|
|
94
|
+
function yt(e) {
|
|
95
|
+
const t = +e;
|
|
96
|
+
return Number.isInteger(t) && String(t) === e;
|
|
97
|
+
}
|
|
98
|
+
var I = (e) => e.copy_ || e.base_, Fe = (e) => e.modified_ ? e.copy_ : e.base_;
|
|
99
|
+
function Ae(e, t) {
|
|
100
|
+
if (ae(e))
|
|
101
|
+
return new Map(e);
|
|
102
|
+
if (ue(e))
|
|
103
|
+
return new Set(e);
|
|
104
|
+
if (ce(e))
|
|
105
|
+
return Array[ie].slice.call(e);
|
|
106
|
+
const r = Qe(e);
|
|
107
|
+
if (t === !0 || t === "class_only" && !r) {
|
|
108
|
+
const n = w.getOwnPropertyDescriptors(e);
|
|
109
|
+
delete n[m];
|
|
110
|
+
let s = Reflect.ownKeys(n);
|
|
111
|
+
for (let i = 0; i < s.length; i++) {
|
|
112
|
+
const c = s[i], u = n[c];
|
|
113
|
+
u[J] === !1 && (u[J] = !0, u[Se] = !0), (u.get || u.set) && (n[c] = {
|
|
114
|
+
[Se]: !0,
|
|
115
|
+
[J]: !0,
|
|
116
|
+
// could live with !!desc.set as well here...
|
|
117
|
+
[Z]: u[Z],
|
|
118
|
+
[B]: e[c]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return w.create(U(e), n);
|
|
122
|
+
} else {
|
|
123
|
+
const n = U(e);
|
|
124
|
+
if (n !== null && r)
|
|
125
|
+
return { ...e };
|
|
126
|
+
const s = w.create(n);
|
|
127
|
+
return w.assign(s, e);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function Ne(e, t = !1) {
|
|
131
|
+
return fe(e) || M(e) || !C(e) || (G(e) > 1 && w.defineProperties(e, {
|
|
132
|
+
set: K,
|
|
133
|
+
add: K,
|
|
134
|
+
clear: K,
|
|
135
|
+
delete: K
|
|
136
|
+
}), w.freeze(e), t && oe(
|
|
137
|
+
e,
|
|
138
|
+
(r, n) => {
|
|
139
|
+
Ne(n, !0);
|
|
24
140
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
141
|
+
!1
|
|
142
|
+
)), e;
|
|
143
|
+
}
|
|
144
|
+
function pt() {
|
|
145
|
+
g(2);
|
|
146
|
+
}
|
|
147
|
+
var K = {
|
|
148
|
+
[B]: pt
|
|
28
149
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
150
|
+
function fe(e) {
|
|
151
|
+
return e === null || !Ee(e) ? !0 : w.isFrozen(e);
|
|
152
|
+
}
|
|
153
|
+
var te = "MapSet", be = "Patches", je = "ArrayMethods", Xe = {};
|
|
154
|
+
function E(e) {
|
|
155
|
+
const t = Xe[e];
|
|
156
|
+
return t || g(0, e), t;
|
|
157
|
+
}
|
|
158
|
+
var Be = (e) => !!Xe[e], W, Ze = () => W, mt = (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(te) ? E(te) : void 0,
|
|
169
|
+
arrayMethodsPlugin_: Be(je) ? E(je) : void 0
|
|
170
|
+
});
|
|
171
|
+
function We(e, t) {
|
|
172
|
+
t && (e.patchPlugin_ = E(be), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
|
|
173
|
+
}
|
|
174
|
+
function De(e) {
|
|
175
|
+
Ie(e), e.drafts_.forEach(gt), e.drafts_ = null;
|
|
176
|
+
}
|
|
177
|
+
function Ie(e) {
|
|
178
|
+
e === W && (W = e.parent_);
|
|
179
|
+
}
|
|
180
|
+
var qe = (e) => W = mt(W, e);
|
|
181
|
+
function gt(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), g(4)), C(e) && (e = He(t, e));
|
|
190
|
+
const { patchPlugin_: s } = t;
|
|
191
|
+
s && s.generateReplacementPatches_(
|
|
192
|
+
r[m].base_,
|
|
193
|
+
e,
|
|
194
|
+
t
|
|
195
|
+
);
|
|
196
|
+
} else
|
|
197
|
+
e = He(t, r);
|
|
198
|
+
return wt(t, e, !0), De(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_), e !== Ye ? e : void 0;
|
|
199
|
+
}
|
|
200
|
+
function He(e, t) {
|
|
201
|
+
if (fe(t))
|
|
202
|
+
return t;
|
|
203
|
+
const r = t[m];
|
|
204
|
+
if (!r)
|
|
205
|
+
return re(t, e.handledSet_, e);
|
|
206
|
+
if (!le(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
|
+
rt(r, e);
|
|
216
|
+
}
|
|
217
|
+
return r.copy_;
|
|
218
|
+
}
|
|
219
|
+
function wt(e, t, r = !1) {
|
|
220
|
+
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && Ne(t, r);
|
|
221
|
+
}
|
|
222
|
+
function et(e) {
|
|
223
|
+
e.finalized_ = !0, e.scope_.unfinalizedDrafts_--;
|
|
224
|
+
}
|
|
225
|
+
var le = (e, t) => e.scope_ === t, St = [];
|
|
226
|
+
function tt(e, t, r, n) {
|
|
227
|
+
const s = I(e), i = e.type_;
|
|
228
|
+
if (n !== void 0 && Pe(s, n, i) === t) {
|
|
229
|
+
ee(s, n, r, i);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (!e.draftLocations_) {
|
|
233
|
+
const u = e.draftLocations_ = /* @__PURE__ */ new Map();
|
|
234
|
+
oe(s, (y, d) => {
|
|
235
|
+
if (M(d)) {
|
|
236
|
+
const h = u.get(d) || [];
|
|
237
|
+
h.push(y), u.set(d, h);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const c = e.draftLocations_.get(t) ?? St;
|
|
242
|
+
for (const u of c)
|
|
243
|
+
ee(s, u, r, i);
|
|
244
|
+
}
|
|
245
|
+
function Pt(e, t, r) {
|
|
246
|
+
e.callbacks_.push(function(s) {
|
|
247
|
+
var u;
|
|
248
|
+
const i = t;
|
|
249
|
+
if (!i || !le(i, s))
|
|
250
|
+
return;
|
|
251
|
+
(u = s.mapSetPlugin_) == null || u.fixSetContents(i);
|
|
252
|
+
const c = Fe(i);
|
|
253
|
+
tt(e, i.draft_ ?? i, c, r), rt(i, s);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function rt(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_: s } = t;
|
|
260
|
+
if (s) {
|
|
261
|
+
const i = s.getPath(e);
|
|
262
|
+
i && s.generatePatches_(e, i, t);
|
|
263
|
+
}
|
|
264
|
+
et(e);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function At(e, t, r) {
|
|
268
|
+
const { scope_: n } = e;
|
|
269
|
+
if (M(r)) {
|
|
270
|
+
const s = r[m];
|
|
271
|
+
le(s, n) && s.callbacks_.push(function() {
|
|
272
|
+
Y(e);
|
|
273
|
+
const c = Fe(s);
|
|
274
|
+
tt(e, r, c, t);
|
|
275
|
+
});
|
|
276
|
+
} else C(r) && e.callbacks_.push(function() {
|
|
277
|
+
const i = I(e);
|
|
278
|
+
e.type_ === 3 ? i.has(r) && re(r, n.handledSet_, n) : Pe(i, t, e.type_) === r && n.drafts_.length > 1 && (e.assigned_.get(t) ?? !1) === !0 && e.copy_ && re(
|
|
279
|
+
Pe(e.copy_, t, e.type_),
|
|
280
|
+
n.handledSet_,
|
|
281
|
+
n
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function re(e, t, r) {
|
|
286
|
+
return !r.immer_.autoFreeze_ && r.unfinalizedDrafts_ < 1 || M(e) || t.has(e) || !C(e) || fe(e) || (t.add(e), oe(e, (n, s) => {
|
|
287
|
+
if (M(s)) {
|
|
288
|
+
const i = s[m];
|
|
289
|
+
if (le(i, r)) {
|
|
290
|
+
const c = Fe(i);
|
|
291
|
+
ee(e, n, c, e.type_), et(i);
|
|
292
|
+
}
|
|
293
|
+
} else C(s) && re(s, t, r);
|
|
294
|
+
})), e;
|
|
295
|
+
}
|
|
296
|
+
function bt(e, t) {
|
|
297
|
+
const r = ce(e), n = {
|
|
298
|
+
type_: r ? 1 : 0,
|
|
299
|
+
// Track which produce call this is associated with.
|
|
300
|
+
scope_: t ? t.scope_ : Ze(),
|
|
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 s = n, i = ne;
|
|
324
|
+
r && (s = [n], i = q);
|
|
325
|
+
const { revoke: c, proxy: u } = Proxy.revocable(s, i);
|
|
326
|
+
return n.draft_ = u, n.revoke_ = c, [u, n];
|
|
327
|
+
}
|
|
328
|
+
var ne = {
|
|
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 s = I(e);
|
|
337
|
+
if (!Oe(s, t, e.type_))
|
|
338
|
+
return Dt(e, s, t);
|
|
339
|
+
const i = s[t];
|
|
340
|
+
if (e.finalized_ || !C(i) || n && e.operationMethod && (r != null && r.isMutatingArrayMethod(
|
|
341
|
+
e.operationMethod
|
|
342
|
+
)) && yt(t))
|
|
343
|
+
return i;
|
|
344
|
+
if (i === we(e.base_, t)) {
|
|
345
|
+
Y(e);
|
|
346
|
+
const c = e.type_ === 1 ? +t : t, u = Me(e.scope_, i, e, c);
|
|
347
|
+
return e.copy_[c] = u;
|
|
348
|
+
}
|
|
349
|
+
return i;
|
|
350
|
+
},
|
|
351
|
+
has(e, t) {
|
|
352
|
+
return t in I(e);
|
|
353
|
+
},
|
|
354
|
+
ownKeys(e) {
|
|
355
|
+
return Reflect.ownKeys(I(e));
|
|
356
|
+
},
|
|
357
|
+
set(e, t, r) {
|
|
358
|
+
const n = nt(I(e), t);
|
|
359
|
+
if (n != null && n.set)
|
|
360
|
+
return n.set.call(e.draft_, r), !0;
|
|
361
|
+
if (!e.modified_) {
|
|
362
|
+
const s = we(I(e), t), i = s == null ? void 0 : s[m];
|
|
363
|
+
if (i && i.base_ === r)
|
|
364
|
+
return e.copy_[t] = r, e.assigned_.set(t, !1), !0;
|
|
365
|
+
if (_t(r, s) && (r !== void 0 || Oe(e.base_, t, e.type_)))
|
|
366
|
+
return !0;
|
|
367
|
+
Y(e), Ce(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), At(e, t, r)), !0;
|
|
372
|
+
},
|
|
373
|
+
deleteProperty(e, t) {
|
|
374
|
+
return Y(e), we(e.base_, t) !== void 0 || t in e.base_ ? (e.assigned_.set(t, !1), Ce(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 = I(e), n = Reflect.getOwnPropertyDescriptor(r, t);
|
|
380
|
+
return n && {
|
|
381
|
+
[J]: !0,
|
|
382
|
+
[Se]: e.type_ !== 1 || t !== "length",
|
|
383
|
+
[Z]: n[Z],
|
|
384
|
+
[B]: r[t]
|
|
48
385
|
};
|
|
386
|
+
},
|
|
387
|
+
defineProperty() {
|
|
388
|
+
g(11);
|
|
389
|
+
},
|
|
390
|
+
getPrototypeOf(e) {
|
|
391
|
+
return U(e.base_);
|
|
392
|
+
},
|
|
393
|
+
setPrototypeOf() {
|
|
394
|
+
g(12);
|
|
49
395
|
}
|
|
396
|
+
}, q = {};
|
|
397
|
+
for (let e in ne) {
|
|
398
|
+
let t = ne[e];
|
|
399
|
+
q[e] = function() {
|
|
400
|
+
const r = arguments;
|
|
401
|
+
return r[0] = r[0][0], t.apply(this, r);
|
|
402
|
+
};
|
|
50
403
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
404
|
+
q.deleteProperty = function(e, t) {
|
|
405
|
+
return process.env.NODE_ENV !== "production" && isNaN(parseInt(t)) && g(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)) && g(14), ne.set.call(this, e[0], t, r, e[0]);
|
|
409
|
+
};
|
|
410
|
+
function we(e, t) {
|
|
411
|
+
const r = e[m];
|
|
412
|
+
return (r ? I(r) : e)[t];
|
|
413
|
+
}
|
|
414
|
+
function Dt(e, t, r) {
|
|
415
|
+
var s;
|
|
416
|
+
const n = nt(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
|
+
(s = n.get) == null ? void 0 : s.call(e.draft_)
|
|
421
|
+
) : void 0;
|
|
422
|
+
}
|
|
423
|
+
function nt(e, t) {
|
|
424
|
+
if (!(t in e))
|
|
425
|
+
return;
|
|
426
|
+
let r = U(e);
|
|
427
|
+
for (; r; ) {
|
|
428
|
+
const n = Object.getOwnPropertyDescriptor(r, t);
|
|
429
|
+
if (n)
|
|
430
|
+
return n;
|
|
431
|
+
r = U(r);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function Ce(e) {
|
|
435
|
+
e.modified_ || (e.modified_ = !0, e.parent_ && Ce(e.parent_));
|
|
436
|
+
}
|
|
437
|
+
function Y(e) {
|
|
438
|
+
e.copy_ || (e.assigned_ = /* @__PURE__ */ new Map(), e.copy_ = Ae(
|
|
439
|
+
e.base_,
|
|
440
|
+
e.scope_.immer_.useStrictShallowCopy_
|
|
441
|
+
));
|
|
442
|
+
}
|
|
443
|
+
var It = 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 i = r;
|
|
448
|
+
r = t;
|
|
449
|
+
const c = this;
|
|
450
|
+
return function(y = i, ...d) {
|
|
451
|
+
return c.produce(y, (h) => r.call(this, h, ...d));
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
v(r) || g(6), n !== void 0 && !v(n) && g(7);
|
|
455
|
+
let s;
|
|
456
|
+
if (C(t)) {
|
|
457
|
+
const i = qe(this), c = Me(i, t, void 0);
|
|
458
|
+
let u = !0;
|
|
459
|
+
try {
|
|
460
|
+
s = r(c), u = !1;
|
|
461
|
+
} finally {
|
|
462
|
+
u ? De(i) : Ie(i);
|
|
463
|
+
}
|
|
464
|
+
return We(i, n), Ge(s, i);
|
|
465
|
+
} else if (!t || !Ee(t)) {
|
|
466
|
+
if (s = r(t), s === void 0 && (s = t), s === Ye && (s = void 0), this.autoFreeze_ && Ne(s, !0), n) {
|
|
467
|
+
const i = [], c = [];
|
|
468
|
+
E(be).generateReplacementPatches_(t, s, {
|
|
469
|
+
patches_: i,
|
|
470
|
+
inversePatches_: c
|
|
471
|
+
}), n(i, c);
|
|
472
|
+
}
|
|
473
|
+
return s;
|
|
474
|
+
} else
|
|
475
|
+
g(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, s;
|
|
480
|
+
return [this.produce(t, r, (c, u) => {
|
|
481
|
+
n = c, s = u;
|
|
482
|
+
}), n, s];
|
|
483
|
+
}, ge(e == null ? void 0 : e.autoFreeze) && this.setAutoFreeze(e.autoFreeze), ge(e == null ? void 0 : e.useStrictShallowCopy) && this.setUseStrictShallowCopy(e.useStrictShallowCopy), ge(e == null ? void 0 : e.useStrictIteration) && this.setUseStrictIteration(e.useStrictIteration);
|
|
484
|
+
}
|
|
485
|
+
createDraft(e) {
|
|
486
|
+
C(e) || g(8), M(e) && (e = Ct(e));
|
|
487
|
+
const t = qe(this), r = Me(t, e, void 0);
|
|
488
|
+
return r[m].isManual_ = !0, Ie(t), r;
|
|
489
|
+
}
|
|
490
|
+
finishDraft(e, t) {
|
|
491
|
+
const r = e && e[m];
|
|
492
|
+
(!r || !r.isManual_) && g(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 s = t[r];
|
|
528
|
+
if (s.path.length === 0 && s.op === "replace") {
|
|
529
|
+
e = s.value;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
r > -1 && (t = t.slice(r + 1));
|
|
534
|
+
const n = E(be).applyPatches_;
|
|
535
|
+
return M(e) ? n(e, t) : this.produce(
|
|
536
|
+
e,
|
|
537
|
+
(s) => n(s, t)
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
function Me(e, t, r, n) {
|
|
542
|
+
const [s, i] = ae(t) ? E(te).proxyMap_(t, r) : ue(t) ? E(te).proxySet_(t, r) : bt(t, r);
|
|
543
|
+
return ((r == null ? void 0 : r.scope_) ?? Ze()).drafts_.push(s), i.callbacks_ = (r == null ? void 0 : r.callbacks_) ?? [], i.key_ = n, r && n !== void 0 ? Pt(r, i, n) : i.callbacks_.push(function(y) {
|
|
544
|
+
var h;
|
|
545
|
+
(h = y.mapSetPlugin_) == null || h.fixSetContents(i);
|
|
546
|
+
const { patchPlugin_: d } = y;
|
|
547
|
+
i.modified_ && d && d.generatePatches_(i, [], y);
|
|
548
|
+
}), s;
|
|
549
|
+
}
|
|
550
|
+
function Ct(e) {
|
|
551
|
+
return M(e) || g(10, e), st(e);
|
|
552
|
+
}
|
|
553
|
+
function st(e) {
|
|
554
|
+
if (!C(e) || fe(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 = Ae(e, t.scope_.immer_.useStrictShallowCopy_), n = t.scope_.immer_.shouldUseStrictIteration();
|
|
562
|
+
} else
|
|
563
|
+
r = Ae(e, !0);
|
|
564
|
+
return oe(
|
|
565
|
+
r,
|
|
566
|
+
(s, i) => {
|
|
567
|
+
ee(r, s, st(i));
|
|
568
|
+
},
|
|
569
|
+
n
|
|
570
|
+
), t && (t.finalized_ = !1), r;
|
|
571
|
+
}
|
|
572
|
+
var Mt = new It(), it = Mt.produce;
|
|
573
|
+
class zt extends F {
|
|
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 s = this.a.get(), i = it(s, (c) => void n(c));
|
|
581
|
+
i !== s && this.a.set(i);
|
|
582
|
+
}, this.filter = (n) => {
|
|
583
|
+
const s = this.a.get().filter(n ?? xt);
|
|
584
|
+
s.length !== this.a.get().length && this.a.set(s);
|
|
585
|
+
}, this.add = (n) => {
|
|
586
|
+
this.a.get().includes(n) || this.a.set(this.a.get().concat([n]));
|
|
587
|
+
}, this.removeFirst = (n) => {
|
|
588
|
+
const s = this.a.get().indexOf(n);
|
|
589
|
+
if (s < 0) return;
|
|
590
|
+
const i = this.a.get().slice(0);
|
|
591
|
+
i.splice(s, 1), this.a.set(i);
|
|
592
|
+
}, this.toggle = (n, s) => {
|
|
593
|
+
const i = this.a.get().slice(), c = i.indexOf(n);
|
|
594
|
+
c < 0 ? s ? i.unshift(n) : i.push(n) : i.splice(c, 1), this.a.set(i);
|
|
73
595
|
};
|
|
74
596
|
}
|
|
75
597
|
}
|
|
76
|
-
const
|
|
77
|
-
class
|
|
78
|
-
constructor(
|
|
79
|
-
super(
|
|
598
|
+
const xt = (e) => e;
|
|
599
|
+
class vt extends F {
|
|
600
|
+
constructor(t, r) {
|
|
601
|
+
super(r), this.a = t, this.toggle = () => {
|
|
80
602
|
this.a.set(!this.a.get());
|
|
81
603
|
};
|
|
82
604
|
}
|
|
83
605
|
}
|
|
84
|
-
class
|
|
85
|
-
constructor(
|
|
86
|
-
super(
|
|
87
|
-
if (this.a.get().get(
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
}, this.setIfNo = (
|
|
91
|
-
if (this.a.get().has(
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
}, this.delete = (
|
|
95
|
-
if (!this.a.get().has(
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
}, this.toggle = (
|
|
99
|
-
const
|
|
100
|
-
|
|
606
|
+
class Tt extends F {
|
|
607
|
+
constructor(t, r) {
|
|
608
|
+
super(r), this.a = t, this.setValue = (n, s) => {
|
|
609
|
+
if (this.a.get().get(n) === s) return;
|
|
610
|
+
const i = new Map(this.a.get());
|
|
611
|
+
i.set(n, s), this.a.set(i);
|
|
612
|
+
}, this.setIfNo = (n, s) => {
|
|
613
|
+
if (this.a.get().has(n)) return;
|
|
614
|
+
const i = new Map(this.a.get());
|
|
615
|
+
i.set(n, s), this.a.set(i);
|
|
616
|
+
}, this.delete = (n) => {
|
|
617
|
+
if (!this.a.get().has(n)) return;
|
|
618
|
+
const s = new Map(this.a.get());
|
|
619
|
+
s.delete(n), this.a.set(s);
|
|
620
|
+
}, this.toggle = (n, s) => {
|
|
621
|
+
const i = new Map(this.a.get());
|
|
622
|
+
i.has(n) ? i.delete(n) : i.set(n, s), this.a.set(i);
|
|
101
623
|
}, this.clear = () => {
|
|
102
624
|
this.a.set(/* @__PURE__ */ new Map());
|
|
103
|
-
}, this.a =
|
|
625
|
+
}, this.a = t;
|
|
104
626
|
}
|
|
105
627
|
}
|
|
106
|
-
class
|
|
107
|
-
constructor(
|
|
108
|
-
super(
|
|
109
|
-
this.a.set(+this.a.get() + (
|
|
628
|
+
class Et extends F {
|
|
629
|
+
constructor(t, r) {
|
|
630
|
+
super(r), this.a = t, this.increment = (n) => {
|
|
631
|
+
this.a.set(+this.a.get() + (n ?? 1));
|
|
110
632
|
};
|
|
111
633
|
}
|
|
112
634
|
}
|
|
113
|
-
class
|
|
114
|
-
constructor(
|
|
115
|
-
super(
|
|
116
|
-
...
|
|
117
|
-
...typeof
|
|
118
|
-
})), this.update = (
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
}, this.setDeepPartial = (s,
|
|
122
|
-
if (!
|
|
123
|
-
if (
|
|
124
|
-
let
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
let
|
|
129
|
-
for (const
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
this.a.get()[
|
|
635
|
+
class Ft extends F {
|
|
636
|
+
constructor(t, r) {
|
|
637
|
+
super(r), this.a = t, this.setPartial = (n) => this.a.set((s) => ({
|
|
638
|
+
...s,
|
|
639
|
+
...typeof n == "function" ? n(this.a.get()) : n
|
|
640
|
+
})), this.update = (n) => {
|
|
641
|
+
const s = this.a.get(), i = it(s, (c) => void n(c));
|
|
642
|
+
i !== s && this.a.set(i);
|
|
643
|
+
}, this.setDeepPartial = (n, s, i, c = T.keyPathSeparator || ".") => {
|
|
644
|
+
if (!c) return;
|
|
645
|
+
if (n.includes(c)) {
|
|
646
|
+
let d = n.split(c);
|
|
647
|
+
const h = d[d.length - 1];
|
|
648
|
+
d = d.slice(0, -1);
|
|
649
|
+
const O = { ...this.a.get() };
|
|
650
|
+
let _ = O, p = i;
|
|
651
|
+
for (const S of d) {
|
|
652
|
+
p = p == null ? void 0 : p[Array.isArray(p) ? "0" : S];
|
|
653
|
+
const z = _[Ke(_, S)] ?? (Array.isArray(p) ? [] : {});
|
|
654
|
+
if (z == null || typeof z != "object") {
|
|
655
|
+
if (i == null) throw "Incorrect path for setDeepPartial";
|
|
656
|
+
const A = typeof s == "function" ? s(void 0) : s;
|
|
657
|
+
this.a.get()[n] !== A && this.setPartial({ [n]: A });
|
|
136
658
|
return;
|
|
137
659
|
}
|
|
138
|
-
|
|
660
|
+
_ = _[Ke(_, S)] = Array.isArray(z) ? [...z] : { ...z };
|
|
139
661
|
}
|
|
140
|
-
const
|
|
141
|
-
h
|
|
662
|
+
const H = _[h];
|
|
663
|
+
_[h] = typeof s == "function" ? s(_[h]) : s, H !== _[h] && this.a.set(O);
|
|
142
664
|
return;
|
|
143
665
|
}
|
|
144
|
-
const
|
|
145
|
-
|
|
666
|
+
const u = this.a.get()[n], y = typeof s == "function" ? s(u) : s;
|
|
667
|
+
y !== u && this.setPartial({ [n]: y });
|
|
146
668
|
};
|
|
147
669
|
}
|
|
148
670
|
}
|
|
149
|
-
const
|
|
150
|
-
class
|
|
151
|
-
constructor(
|
|
152
|
-
super(
|
|
153
|
-
this.a.get().has(
|
|
154
|
-
}, this.delete = (
|
|
155
|
-
if (!this.a.get().has(
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
}, this.toggle = (
|
|
159
|
-
const
|
|
160
|
-
|
|
671
|
+
const Ke = (e, t) => Array.isArray(e) ? `${+t}` : t;
|
|
672
|
+
class Nt extends F {
|
|
673
|
+
constructor(t, r) {
|
|
674
|
+
super(r), this.a = t, this.add = (n) => {
|
|
675
|
+
this.a.get().has(n) || this.a.set(new Set(this.a.get()).add(n));
|
|
676
|
+
}, this.delete = (n) => {
|
|
677
|
+
if (!this.a.get().has(n)) return;
|
|
678
|
+
const s = new Set(this.a.get());
|
|
679
|
+
s.delete(n), this.a.set(s);
|
|
680
|
+
}, this.toggle = (n) => {
|
|
681
|
+
const s = new Set(this.a.get());
|
|
682
|
+
s.has(n) ? s.delete(n) : s.add(n), this.a.set(s);
|
|
161
683
|
}, this.clear = () => {
|
|
162
684
|
this.a.set(/* @__PURE__ */ new Set());
|
|
163
|
-
}, this.a =
|
|
685
|
+
}, this.a = t;
|
|
164
686
|
}
|
|
165
687
|
}
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
(
|
|
169
|
-
() =>
|
|
170
|
-
|
|
171
|
-
(
|
|
172
|
-
) : null,
|
|
173
|
-
return
|
|
688
|
+
const $t = (e, t, r) => {
|
|
689
|
+
const n = typeof r == "object" && r != null && "do" in r ? r.do(
|
|
690
|
+
(i, c) => t.set(i, c),
|
|
691
|
+
() => t.get(),
|
|
692
|
+
t,
|
|
693
|
+
(i, c, u) => t.setDeferred(i, c, u)
|
|
694
|
+
) : null, s = {};
|
|
695
|
+
return n && Object.keys(n).forEach((i) => Object.defineProperty(s, i, { get: () => n[i] })), typeof e == "number" ? new Et(t, n) : typeof e == "boolean" ? new vt(t, n) : Array.isArray(e) ? new zt(t, n) : e instanceof Set ? new Nt(t, n) : e instanceof Map ? new Tt(t, n) : e instanceof Object ? new Ft(t, n) : new F(n);
|
|
174
696
|
};
|
|
175
|
-
class
|
|
176
|
-
constructor(
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
let
|
|
180
|
-
},
|
|
181
|
-
const
|
|
182
|
-
return
|
|
697
|
+
class Rt {
|
|
698
|
+
constructor(t, r) {
|
|
699
|
+
t = typeof t == "function" ? t() : t;
|
|
700
|
+
const n = (o) => d = o, s = () => d, i = /* @__PURE__ */ new Set(), c = (o) => o(_());
|
|
701
|
+
let u = !0, y = !1, d = t, h, O = () => {
|
|
702
|
+
}, _ = () => s(), p = null, H = () => {
|
|
703
|
+
const o = $t(t, S, r);
|
|
704
|
+
return H = () => o, o;
|
|
183
705
|
};
|
|
184
|
-
const
|
|
185
|
-
get: (
|
|
186
|
-
set:
|
|
187
|
-
}),
|
|
188
|
-
|
|
706
|
+
const S = new Proxy(this, {
|
|
707
|
+
get: (o, l) => l === "do" ? H() : o[l],
|
|
708
|
+
set: kt
|
|
709
|
+
}), z = () => {
|
|
710
|
+
u = !0, y !== !0 && O(_()), y = !1;
|
|
189
711
|
try {
|
|
190
|
-
|
|
712
|
+
ze.postMessage({ key: f, value: s() });
|
|
191
713
|
} catch {
|
|
192
714
|
}
|
|
193
|
-
},
|
|
194
|
-
const
|
|
195
|
-
|
|
715
|
+
}, A = (o, l) => {
|
|
716
|
+
const b = typeof o == "function" ? o(_()) : o;
|
|
717
|
+
b !== _() && (n(b), y = l, u && (u = !1, i.forEach(c), queueMicrotask(z)));
|
|
196
718
|
};
|
|
197
|
-
this.set = (
|
|
198
|
-
|
|
719
|
+
this.set = (o, l) => A(o, l), this.get = () => _(), this.initialValue = t, this.isInitialValue = () => t === s(), this.subscribe = (o) => (i.add(o), () => {
|
|
720
|
+
i.delete(o);
|
|
199
721
|
}), this.reset = () => {
|
|
200
|
-
|
|
722
|
+
A(t, !0);
|
|
201
723
|
};
|
|
202
|
-
const
|
|
203
|
-
|
|
724
|
+
const ut = (o, l) => {
|
|
725
|
+
A(o, l), h = void 0;
|
|
204
726
|
};
|
|
205
|
-
if (this.setDeferred = (
|
|
206
|
-
|
|
207
|
-
},
|
|
208
|
-
let
|
|
209
|
-
if (
|
|
210
|
-
throw console.error(
|
|
211
|
-
} :
|
|
212
|
-
if (
|
|
727
|
+
if (this.setDeferred = (o, l = 500, b, D = !0) => {
|
|
728
|
+
D && h === void 0 && A(o, b), clearTimeout(h), h = setTimeout(ut, l, o, b);
|
|
729
|
+
}, r == null) return S;
|
|
730
|
+
let P = null, j = null, he = !0, _e = !0, ye = !1, x = 0, N = 0, $e = -1, $ = t instanceof Set ? (o) => new Set(o) : t instanceof Map ? (o) => new Map(o) : (o) => o, R = t instanceof Set ? (o) => {
|
|
731
|
+
if (o instanceof Set) return Array.from(o);
|
|
732
|
+
throw console.error(o), "The value is not Set instance";
|
|
733
|
+
} : t instanceof Map ? (o) => {
|
|
734
|
+
if (o instanceof Map) {
|
|
213
735
|
const l = [];
|
|
214
|
-
return
|
|
736
|
+
return o.forEach((b, D) => l.push([D, b])), l;
|
|
215
737
|
}
|
|
216
|
-
throw console.error(
|
|
217
|
-
} : (
|
|
218
|
-
if (typeof
|
|
219
|
-
|
|
220
|
-
else if ("storeKey" in
|
|
221
|
-
|
|
222
|
-
else return
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
|
|
738
|
+
throw console.error(o), "The value is not Set instance";
|
|
739
|
+
} : (o) => o;
|
|
740
|
+
if (typeof r == "string")
|
|
741
|
+
P = r;
|
|
742
|
+
else if ("storeKey" in r)
|
|
743
|
+
he = r.warnOnDuplicateStoreKey ?? he, _e = r.listenStorageChanges ?? _e, P = r.storeKey, $ = r.unzipValue ?? $, R = r.zipValue ?? R, ye = r.unchangable ?? ye, x = r.securifyKeyLevel ?? T.securifyKeyLevel ?? x, N = r.securifyValueLevel ?? T.securifyValueLevel ?? N, j = r.exp ?? j;
|
|
744
|
+
else return S;
|
|
745
|
+
const pe = x ? k(P, x) : P, f = `${N ? xe : L}${pe}`;
|
|
746
|
+
if (x) {
|
|
747
|
+
const o = `${L}${P}`;
|
|
748
|
+
o in a && (a[f] = a[o], delete a[o]);
|
|
227
749
|
} else {
|
|
228
|
-
const
|
|
229
|
-
|
|
750
|
+
const o = `${L}${k(P, x)}`;
|
|
751
|
+
o in a && (a[f] = a[o], delete a[o]);
|
|
230
752
|
}
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
753
|
+
const me = j === null || !(j(S, f in a) instanceof Date) ? (o) => k([R(o)], 0) : (o) => (p ?? (p = {}), p.exp = j(S, f in a).getTime(), p.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout($e), clearTimeout(ot[f]), $e = setTimeout(() => this.reset(), p.exp - Date.now())), p.exp = Math.trunc(p.exp / 1e3), k([R(o), p], 0));
|
|
754
|
+
if (N) {
|
|
755
|
+
const o = `${L}${pe}`, l = R, b = $;
|
|
756
|
+
if (R = (D) => {
|
|
235
757
|
try {
|
|
236
|
-
return
|
|
758
|
+
return k([l(D)], N);
|
|
237
759
|
} catch {
|
|
238
|
-
return delete
|
|
760
|
+
return delete a[f], "";
|
|
239
761
|
}
|
|
240
|
-
},
|
|
241
|
-
const
|
|
762
|
+
}, o in a) {
|
|
763
|
+
const D = `${L}${k(P, x)}`;
|
|
242
764
|
try {
|
|
243
|
-
|
|
765
|
+
a[D] = me($(Q(a[o], 0)[0])), delete a[o];
|
|
244
766
|
} catch {
|
|
245
767
|
}
|
|
246
768
|
}
|
|
247
|
-
|
|
769
|
+
$ = (D) => {
|
|
248
770
|
try {
|
|
249
|
-
return
|
|
771
|
+
return b(Q(D, N)[0]);
|
|
250
772
|
} catch {
|
|
251
|
-
return delete
|
|
773
|
+
return delete a[f], "";
|
|
252
774
|
}
|
|
253
775
|
};
|
|
254
|
-
} else delete
|
|
255
|
-
const
|
|
256
|
-
const l =
|
|
257
|
-
return
|
|
776
|
+
} else delete a[`${xe}${pe}`];
|
|
777
|
+
const Re = (o) => {
|
|
778
|
+
const l = Q(o, 0);
|
|
779
|
+
return p = l[1], $(l[0]);
|
|
258
780
|
};
|
|
259
|
-
let
|
|
260
|
-
if (
|
|
261
|
-
if (
|
|
262
|
-
|
|
781
|
+
let ke = !0;
|
|
782
|
+
if (ve[f] = S, a[`atom/${P}`] && (a[f] || (a[f] = `[${a[`atom/${P}`]}]`), delete a[`atom/${P}`]), _ = () => {
|
|
783
|
+
if (_ = s, ke) {
|
|
784
|
+
ke = !1;
|
|
263
785
|
try {
|
|
264
|
-
|
|
786
|
+
n(f in a ? Re(a[f]) : t);
|
|
265
787
|
} catch {
|
|
266
|
-
console.warn("Invalid json value",
|
|
788
|
+
console.warn("Invalid json value", a[f]);
|
|
267
789
|
}
|
|
268
790
|
}
|
|
269
|
-
return
|
|
270
|
-
},
|
|
271
|
-
if (
|
|
791
|
+
return s();
|
|
792
|
+
}, O = (o) => {
|
|
793
|
+
if (o === t) {
|
|
272
794
|
this.reset();
|
|
273
795
|
return;
|
|
274
796
|
}
|
|
275
|
-
|
|
797
|
+
a[f] = me(o);
|
|
276
798
|
}, this.reset = () => {
|
|
277
|
-
delete
|
|
278
|
-
},
|
|
279
|
-
if (
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
clearTimeout(l), l = setTimeout(() =>
|
|
799
|
+
delete a[f], A(t, !0);
|
|
800
|
+
}, he && V[f] !== void 0 && console.warn("Duplicate Atom key", P), _e)
|
|
801
|
+
if (ye) {
|
|
802
|
+
let o = !1, l;
|
|
803
|
+
de[f] = this, V[f] = () => {
|
|
804
|
+
clearTimeout(l), l = setTimeout(() => o = !1, 10), !o && (o = !0, a[f] = me(s()));
|
|
283
805
|
};
|
|
284
806
|
} else
|
|
285
|
-
|
|
286
|
-
if (
|
|
807
|
+
V[f] = (o) => {
|
|
808
|
+
if (o.newValue === null) {
|
|
287
809
|
this.reset();
|
|
288
810
|
return;
|
|
289
811
|
}
|
|
290
812
|
try {
|
|
291
|
-
|
|
813
|
+
A(Re(o.newValue));
|
|
292
814
|
} catch {
|
|
293
|
-
console.warn("Invalid json value",
|
|
815
|
+
console.warn("Invalid json value", o.newValue);
|
|
294
816
|
}
|
|
295
817
|
};
|
|
296
|
-
return
|
|
818
|
+
return S;
|
|
297
819
|
}
|
|
298
820
|
}
|
|
299
|
-
let
|
|
821
|
+
let ze;
|
|
300
822
|
try {
|
|
301
|
-
|
|
302
|
-
var
|
|
303
|
-
(
|
|
823
|
+
ze = new BroadcastChannel("updateHere"), ze.addEventListener("message", (e) => {
|
|
824
|
+
var t;
|
|
825
|
+
(t = de[e.data.key]) == null || t.set(e.data.value, !0);
|
|
304
826
|
});
|
|
305
827
|
} catch {
|
|
306
828
|
}
|
|
307
|
-
const
|
|
308
|
-
throw `${
|
|
829
|
+
const a = localStorage, V = {}, de = {}, kt = (e, t) => {
|
|
830
|
+
throw `${t} is readonly property`;
|
|
309
831
|
};
|
|
310
|
-
window.addEventListener("storage", (
|
|
311
|
-
var
|
|
312
|
-
|
|
832
|
+
window.addEventListener("storage", (e) => {
|
|
833
|
+
var t;
|
|
834
|
+
e.key === null || e.newValue === e.oldValue || (t = V[e.key]) == null || t.call(V, e);
|
|
313
835
|
});
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
836
|
+
const Lt = a.setItem.bind(a), Vt = a.removeItem.bind(a);
|
|
837
|
+
a.setItem = (e, t) => {
|
|
838
|
+
de[e] === void 0 && Lt.call(a, e, t);
|
|
317
839
|
};
|
|
318
|
-
|
|
319
|
-
|
|
840
|
+
a.removeItem = (e) => {
|
|
841
|
+
de[e] === void 0 && Vt.call(a, e);
|
|
320
842
|
};
|
|
321
|
-
const
|
|
322
|
-
for (let
|
|
323
|
-
if (
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
(
|
|
330
|
-
(
|
|
331
|
-
(
|
|
332
|
-
const
|
|
333
|
-
return `${
|
|
843
|
+
const Ut = /"exp":\s*(\d+)/, L = "atom\\", xe = "atom`s\\", ve = {}, ot = {}, ct = /[a-z]/gi, se = 5, Te = {};
|
|
844
|
+
for (let e = 54; e < 80; e++) {
|
|
845
|
+
if (e === 68 || e === 72 || e === 55) continue;
|
|
846
|
+
const t = String.fromCharCode(e + 43).toUpperCase(), r = String.fromCharCode(e + 43).toLowerCase();
|
|
847
|
+
Te[t] = r, Te[r] = t;
|
|
848
|
+
}
|
|
849
|
+
const at = (e) => Te[e] ?? e, k = /* @__PURE__ */ (() => {
|
|
850
|
+
const e = [
|
|
851
|
+
(t) => JSON.stringify(t),
|
|
852
|
+
(t) => btoa(encodeURI(e[0](t))),
|
|
853
|
+
(t) => {
|
|
854
|
+
const r = e[1](t);
|
|
855
|
+
return `${r.slice(0, se)}${r.slice(se).replace(ct, at)}`;
|
|
334
856
|
},
|
|
335
|
-
(
|
|
857
|
+
(t) => btoa(e[2](t))
|
|
336
858
|
];
|
|
337
|
-
return (
|
|
859
|
+
return (t, r) => {
|
|
338
860
|
try {
|
|
339
|
-
return
|
|
340
|
-
} catch (
|
|
341
|
-
if (
|
|
342
|
-
return
|
|
861
|
+
return e[r](t);
|
|
862
|
+
} catch (n) {
|
|
863
|
+
if (r === 0) throw n;
|
|
864
|
+
return e[0](t);
|
|
343
865
|
}
|
|
344
866
|
};
|
|
345
|
-
})(),
|
|
346
|
-
const
|
|
347
|
-
(
|
|
348
|
-
(
|
|
349
|
-
(
|
|
350
|
-
`${
|
|
867
|
+
})(), Q = /* @__PURE__ */ (() => {
|
|
868
|
+
const e = [
|
|
869
|
+
(t) => JSON.parse(t),
|
|
870
|
+
(t) => e[0](decodeURI(atob(t))),
|
|
871
|
+
(t) => e[1](
|
|
872
|
+
`${t.slice(0, se)}${t.slice(se).replace(ct, at)}`
|
|
351
873
|
),
|
|
352
|
-
(
|
|
874
|
+
(t) => e[2](atob(t))
|
|
353
875
|
];
|
|
354
|
-
return (
|
|
876
|
+
return (t, r) => {
|
|
355
877
|
try {
|
|
356
|
-
return
|
|
357
|
-
} catch (
|
|
358
|
-
if (
|
|
359
|
-
return
|
|
878
|
+
return e[r](t);
|
|
879
|
+
} catch (n) {
|
|
880
|
+
if (r === 0) throw n;
|
|
881
|
+
return e[0](t);
|
|
360
882
|
}
|
|
361
883
|
};
|
|
362
884
|
})();
|
|
363
885
|
setTimeout(() => {
|
|
364
|
-
Object.keys(
|
|
365
|
-
var
|
|
366
|
-
if (typeof
|
|
367
|
-
const
|
|
368
|
-
if (!
|
|
369
|
-
const
|
|
370
|
-
!Array.isArray(
|
|
371
|
-
|
|
372
|
-
}, +
|
|
886
|
+
Object.keys(a).forEach((e) => {
|
|
887
|
+
var n;
|
|
888
|
+
if (typeof a[e] != "string" || !e.startsWith(L) && !e.startsWith(xe)) return;
|
|
889
|
+
const t = (n = a[e].match(Ut)) == null ? void 0 : n[1];
|
|
890
|
+
if (!t || +t * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
|
|
891
|
+
const r = Q(a[e], 0);
|
|
892
|
+
!Array.isArray(r) || r[1] == null || !("exp" in r[1]) || r[1].exp !== t || (ot[e] = setTimeout(() => {
|
|
893
|
+
ve[e] ? ve[e].reset() : delete a[e];
|
|
894
|
+
}, +t * 1e3 - Date.now()));
|
|
373
895
|
});
|
|
374
896
|
}, 1e3);
|
|
375
897
|
export {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
898
|
+
Rt as Atom,
|
|
899
|
+
zt as AtomArrayDoActions,
|
|
900
|
+
vt as AtomBooleanDoActions,
|
|
901
|
+
Tt as AtomMapDoActions,
|
|
902
|
+
Et as AtomNumberDoActions,
|
|
903
|
+
Ft as AtomObjectDoActions,
|
|
904
|
+
Nt as AtomSetDoActions,
|
|
905
|
+
Gt as atom,
|
|
906
|
+
Ot as configureAtomaric,
|
|
907
|
+
T as configuredOptions,
|
|
908
|
+
qt as useAtom,
|
|
909
|
+
Wt as useAtomDo,
|
|
910
|
+
Bt as useAtomGet,
|
|
911
|
+
lt as useAtomSet,
|
|
912
|
+
jt as useAtomSetDeferred,
|
|
913
|
+
ft as useAtomValue
|
|
392
914
|
};
|
package/build/atomaric.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(f=typeof globalThis<"u"?globalThis:f||self,_(f.atomaric={}))})(this,function(f){"use strict";let _=()=>{throw"call configureAtomaric() before all!"};const x={},de=t=>{x.useSyncExternalStore=_=t.useSyncExternalStore,x.keyPathSeparator=t.keyPathSeparator,x.securifyKeyLevel=t.securifyKeyLevel,x.securifyValueLevel=t.securifyValueLevel},Y=t=>_(t.subscribe,t.get),Z=t=>t.set,ge=t=>t.setDeferred,Ae=t=>t.get,me=t=>t.do,ye=t=>[Y(t),Z(t)],we=(t,e)=>new ie(t,e);class j{constructor(e){if(e)return new Proxy(this,{get:(i,s)=>s in this?i[s]:e[s]})}}const pe=(t,e)=>{const i=(s,r,o)=>new Proxy(s,{get:(a,g,m)=>{const y=o===0&&e.get!=null?e.get(a,g,m):a[g],h=y??(Array.isArray(a)?[]:{});return typeof h=="object"&&h!==null?i(Array.isArray(h)?h.slice(0):{...h},r.concat(Array.isArray(a)?+g:g),o+1):h},set:(a,g,m)=>(e.onSet(a,r,g,m,a[g])&&(a[g]=m),!0)});return i(t,[],0)};class v extends j{constructor(){super(...arguments),this.updateValue=(e,i)=>{const s=Array.isArray(e)?e.slice(0):{...e};let r=!1;return i(pe(s,{onSet:(o,a,g,m,y)=>{if(m===y)return!0;let h=s;r=!0;for(const $ of a){const d=h[$];h=h[$]=Array.isArray(d)?d.slice():{...d}}return h[g]=m,!0}})),r?s:e}}}class k extends v{constructor(e,i){super(i),this.a=e,this.push=(...s)=>{s.length!==0&&this.a.set(this.a.get().concat(s))},this.unshift=(...s)=>{s.length!==0&&this.a.set(s.concat(this.a.get()))},this.update=s=>{const r=this.a.get(),o=this.updateValue(r,s);o!==r&&this.a.set(o)},this.filter=s=>{const r=this.a.get().filter(s??Se);r.length!==this.a.get().length&&this.a.set(r)},this.add=s=>{this.a.get().includes(s)||this.a.set(this.a.get().concat([s]))},this.removeFirst=s=>{const r=this.a.get().indexOf(s);if(r<0)return;const o=this.a.get().slice(0);o.splice(r,1),this.a.set(o)},this.toggle=(s,r)=>{const o=this.a.get().slice(),a=o.indexOf(s);a<0?r?o.unshift(s):o.push(s):o.splice(a,1),this.a.set(o)}}}const Se=t=>t;class O extends j{constructor(e,i){super(i),this.a=e,this.toggle=()=>{this.a.set(!this.a.get())}}}class ee extends j{constructor(e,i){super(i),this.a=e,this.setValue=(s,r)=>{if(this.a.get().get(s)===r)return;const o=new Map(this.a.get());o.set(s,r),this.a.set(o)},this.setIfNo=(s,r)=>{if(this.a.get().has(s))return;const o=new Map(this.a.get());o.set(s,r),this.a.set(o)},this.delete=s=>{if(!this.a.get().has(s))return;const r=new Map(this.a.get());r.delete(s),this.a.set(r)},this.toggle=(s,r)=>{const o=new Map(this.a.get());o.has(s)?o.delete(s):o.set(s,r),this.a.set(o)},this.clear=()=>{this.a.set(new Map)},this.a=e}}class te extends j{constructor(e,i){super(i),this.a=e,this.increment=s=>{this.a.set(+this.a.get()+(s??1))}}}class se extends v{constructor(e,i){super(i),this.a=e,this.setPartial=s=>this.a.set(r=>({...r,...typeof s=="function"?s(this.a.get()):s})),this.update=s=>{const r=this.a.get(),o=this.updateValue(r,s);o!==r&&this.a.set(o)},this.setDeepPartial=(s,r,o,a=x.keyPathSeparator||".")=>{if(!a)return;if(s.includes(a)){let y=s.split(a);const h=y[y.length-1];y=y.slice(0,-1);const $={...this.a.get()};let d=$,A=o;for(const w of y){A=A==null?void 0:A[Array.isArray(A)?"0":w];const M=d[ne(d,w)]??(Array.isArray(A)?[]:{});if(M==null||typeof M!="object"){if(o==null)throw"Incorrect path for setDeepPartial";const S=typeof r=="function"?r(void 0):r;this.a.get()[s]!==S&&this.setPartial({[s]:S});return}d=d[ne(d,w)]=Array.isArray(M)?[...M]:{...M}}const q=d[h];d[h]=typeof r=="function"?r(d[h]):r,q!==d[h]&&this.a.set($);return}const g=this.a.get()[s],m=typeof r=="function"?r(g):r;m!==g&&this.setPartial({[s]:m})}}}const ne=(t,e)=>Array.isArray(t)?`${+e}`:e;class re extends j{constructor(e,i){super(i),this.a=e,this.add=s=>{this.a.get().has(s)||this.a.set(new Set(this.a.get()).add(s))},this.delete=s=>{if(!this.a.get().has(s))return;const r=new Set(this.a.get());r.delete(s),this.a.set(r)},this.toggle=s=>{const r=new Set(this.a.get());r.has(s)?r.delete(s):r.add(s),this.a.set(r)},this.clear=()=>{this.a.set(new Set)},this.a=e}}const be=(t,e,i)=>{const s=typeof i=="object"&&i!=null&&"do"in i?i.do((o,a)=>e.set(o,a),()=>e.get(),e,(o,a,g)=>e.setDeferred(o,a,g)):null,r={};return s&&Object.keys(s).forEach(o=>Object.defineProperty(r,o,{get:()=>s[o]})),typeof t=="number"?new te(e,s):typeof t=="boolean"?new O(e,s):Array.isArray(t)?new k(e,s):t instanceof Set?new re(e,s):t instanceof Map?new ee(e,s):t instanceof Object?new se(e,s):new j(s)};class ie{constructor(e,i){e=typeof e=="function"?e():e;const s=n=>y=n,r=()=>y,o=new Set,a=n=>n(d());let g=!0,m=!1,y=e,h,$=()=>{},d=()=>r(),A=null,q=()=>{const n=be(e,w,i);return q=()=>n,n};const w=new Proxy(this,{get:(n,l)=>l==="do"?q():n[l],set:De}),M=()=>{g=!0,m!==!0&&$(d()),m=!1;try{B.postMessage({key:u,value:r()})}catch{}},S=(n,l)=>{const b=typeof n=="function"?n(d()):n;b!==d()&&(s(b),m=l,g&&(g=!1,o.forEach(a),queueMicrotask(M)))};this.set=(n,l)=>S(n,l),this.get=()=>d(),this.initialValue=e,this.isInitialValue=()=>e===r(),this.subscribe=n=>(o.add(n),()=>{o.delete(n)}),this.reset=()=>{S(e,!0)};const Te=(n,l)=>{S(n,l),h=void 0};if(this.setDeferred=(n,l=500,b,D=!0)=>{D&&h===void 0&&S(n,b),clearTimeout(h),h=setTimeout(Te,l,n,b)},i==null)return w;let p=null,z=null,H=!0,J=!0,Q=!1,T=0,V=0,ue=-1,C=e instanceof Set?n=>new Set(n):e instanceof Map?n=>new Map(n):n=>n,E=e instanceof Set?n=>{if(n instanceof Set)return Array.from(n);throw console.error(n),"The value is not Set instance"}:e instanceof Map?n=>{if(n instanceof Map){const l=[];return n.forEach((b,D)=>l.push([D,b])),l}throw console.error(n),"The value is not Set instance"}:n=>n;if(typeof i=="string")p=i;else if("storeKey"in i)H=i.warnOnDuplicateStoreKey??H,J=i.listenStorageChanges??J,p=i.storeKey,C=i.unzipValue??C,E=i.zipValue??E,Q=i.unchangable??Q,T=i.securifyKeyLevel??x.securifyKeyLevel??T,V=i.securifyValueLevel??x.securifyValueLevel??V,z=i.exp??z;else return w;const K=T?P(p,T):p,u=`${V?F:L}${K}`;if(T){const n=`${L}${p}`;n in c&&(c[u]=c[n],delete c[n])}else{const n=`${L}${P(p,T)}`;n in c&&(c[u]=c[n],delete c[n])}const X=z===null||!(z(w,u in c)instanceof Date)?n=>P([E(n)],0):n=>(A??(A={}),A.exp=z(w,u in c).getTime(),A.exp-Date.now()<24*60*60*1e3&&(clearTimeout(ue),clearTimeout(oe[u]),ue=setTimeout(()=>this.reset(),A.exp-Date.now())),A.exp=Math.trunc(A.exp/1e3),P([E(n),A],0));if(V){const n=`${L}${K}`,l=E,b=C;if(E=D=>{try{return P([l(D)],V)}catch{return delete c[u],""}},n in c){const D=`${L}${P(p,T)}`;try{c[D]=X(C(U(c[n],0)[0])),delete c[n]}catch{}}C=D=>{try{return b(U(D,V)[0])}catch{return delete c[u],""}}}else delete c[`${F}${K}`];const le=n=>{const l=U(n,0);return A=l[1],C(l[0])};let fe=!0;if(W[u]=w,c[`atom/${p}`]&&(c[u]||(c[u]=`[${c[`atom/${p}`]}]`),delete c[`atom/${p}`]),d=()=>{if(d=r,fe){fe=!1;try{s(u in c?le(c[u]):e)}catch{console.warn("Invalid json value",c[u])}}return r()},$=n=>{if(n===e){this.reset();return}c[u]=X(n)},this.reset=()=>{delete c[u],S(e,!0)},H&&I[u]!==void 0&&console.warn("Duplicate Atom key",p),J)if(Q){let n=!1,l;R[u]=this,I[u]=()=>{clearTimeout(l),l=setTimeout(()=>n=!1,10),!n&&(n=!0,c[u]=X(r()))}}else I[u]=n=>{if(n.newValue===null){this.reset();return}try{S(le(n.newValue))}catch{console.warn("Invalid json value",n.newValue)}};return w}}let B;try{B=new BroadcastChannel("updateHere"),B.addEventListener("message",t=>{var e;(e=R[t.data.key])==null||e.set(t.data.value,!0)})}catch{}const c=localStorage,I={},R={},De=(t,e)=>{throw`${e} is readonly property`};window.addEventListener("storage",t=>{var e;t.key===null||t.newValue===t.oldValue||(e=I[t.key])==null||e.call(I,t)});const xe=c.setItem.bind(c),$e=c.removeItem.bind(c);c.setItem=(t,e)=>{R[t]===void 0&&xe.call(c,t,e)},c.removeItem=t=>{R[t]===void 0&&$e.call(c,t)};const Me=/"exp":\s*(\d+)/,L="atom\\",F="atom`s\\",W={},oe={},ce=/[a-z]/gi,N=5,G={};for(let t=54;t<80;t++){if(t===68||t===72||t===55)continue;const e=String.fromCharCode(t+43).toUpperCase(),i=String.fromCharCode(t+43).toLowerCase();G[e]=i,G[i]=e}const ae=t=>G[t]??t,P=(()=>{const t=[e=>JSON.stringify(e),e=>btoa(encodeURI(t[0](e))),e=>{const i=t[1](e);return`${i.slice(0,N)}${i.slice(N).replace(ce,ae)}`},e=>btoa(t[2](e))];return(e,i)=>{try{return t[i](e)}catch(s){if(i===0)throw s;return t[0](e)}}})(),U=(()=>{const t=[e=>JSON.parse(e),e=>t[0](decodeURI(atob(e))),e=>t[1](`${e.slice(0,N)}${e.slice(N).replace(ce,ae)}`),e=>t[2](atob(e))];return(e,i)=>{try{return t[i](e)}catch(s){if(i===0)throw s;return t[0](e)}}})();setTimeout(()=>{Object.keys(c).forEach(t=>{var s;if(typeof c[t]!="string"||!t.startsWith(L)&&!t.startsWith(F))return;const e=(s=c[t].match(Me))==null?void 0:s[1];if(!e||+e*1e3-Date.now()>24*60*60*1e3)return;const i=U(c[t],0);!Array.isArray(i)||i[1]==null||!("exp"in i[1])||i[1].exp!==e||(oe[t]=setTimeout(()=>{W[t]?W[t].reset():delete c[t]},+e*1e3-Date.now()))})},1e3),f.Atom=ie,f.AtomArrayDoActions=k,f.AtomBooleanDoActions=O,f.AtomMapDoActions=ee,f.AtomNumberDoActions=te,f.AtomObjectDoActions=se,f.AtomSetDoActions=re,f.atom=we,f.configureAtomaric=de,f.configuredOptions=x,f.useAtom=ye,f.useAtomDo=me,f.useAtomGet=Ae,f.useAtomSet=Z,f.useAtomSetDeferred=ge,f.useAtomValue=Y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(d=typeof globalThis<"u"?globalThis:d||self,$(d.atomaric={}))})(this,function(d){"use strict";let $=()=>{throw"call configureAtomaric() before all!"};const z={},wt=e=>{z.useSyncExternalStore=$=e.useSyncExternalStore,z.keyPathSeparator=e.keyPathSeparator,z.securifyKeyLevel=e.securifyKeyLevel,z.securifyValueLevel=e.securifyValueLevel},ke=e=>$(e.subscribe,e.get),Le=e=>e.set,St=e=>e.setDeferred,At=e=>e.get,Pt=e=>e.do,bt=e=>[ke(e),Le(e)],Dt=(e,t)=>new lt(e,t);class T{constructor(t){if(t)return new Proxy(this,{get:(r,n)=>n in this?r[n]:t[n]})}}var Ve=Symbol.for("immer-nothing"),Oe=Symbol.for("immer-draftable"),p=Symbol.for("immer-state"),It=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){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 '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"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(e){return`'current' expects a draft, got: ${e}`},"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(e){return`'original' expects a draft, got: ${e}`}]:[];function w(e,...t){if(process.env.NODE_ENV!=="production"){const r=It[e],n=E(r)?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var S=Object,R=S.getPrototypeOf,J="constructor",Y="prototype",ye="configurable",Q="enumerable",X="writable",B="value",v=e=>!!e&&!!e[p];function b(e){var t;return e?Ue(e)||te(e)||!!e[Oe]||!!((t=e[J])!=null&&t[Oe])||re(e)||ne(e):!1}var Mt=S[Y][J].toString(),je=new WeakMap;function Ue(e){if(!e||!pe(e))return!1;const t=R(e);if(t===null||t===S[Y])return!0;const r=S.hasOwnProperty.call(t,J)&&t[J];if(r===Object)return!0;if(!E(r))return!1;let n=je.get(r);return n===void 0&&(n=Function.toString.call(r),je.set(r,n)),n===Mt}function Z(e,t,r=!0){W(e)===0?(r?Reflect.ownKeys(e):S.keys(e)).forEach(s=>{t(s,e[s],e)}):e.forEach((n,s)=>t(s,n,e))}function W(e){const t=e[p];return t?t.type_:te(e)?1:re(e)?2:ne(e)?3:0}var Be=(e,t,r=W(e))=>r===2?e.has(t):S[Y].hasOwnProperty.call(e,t),me=(e,t,r=W(e))=>r===2?e.get(t):e[t],ee=(e,t,r,n=W(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function Ct(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var te=Array.isArray,re=e=>e instanceof Map,ne=e=>e instanceof Set,pe=e=>typeof e=="object",E=e=>typeof e=="function",ge=e=>typeof e=="boolean";function zt(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var D=e=>e.copy_||e.base_,we=e=>e.modified_?e.copy_:e.base_;function Se(e,t){if(re(e))return new Map(e);if(ne(e))return new Set(e);if(te(e))return Array[Y].slice.call(e);const r=Ue(e);if(t===!0||t==="class_only"&&!r){const n=S.getOwnPropertyDescriptors(e);delete n[p];let s=Reflect.ownKeys(n);for(let i=0;i<s.length;i++){const c=s[i],u=n[c];u[X]===!1&&(u[X]=!0,u[ye]=!0),(u.get||u.set)&&(n[c]={[ye]:!0,[X]:!0,[Q]:u[Q],[B]:e[c]})}return S.create(R(e),n)}else{const n=R(e);if(n!==null&&r)return{...e};const s=S.create(n);return S.assign(s,e)}}function Ae(e,t=!1){return ie(e)||v(e)||!b(e)||(W(e)>1&&S.defineProperties(e,{set:se,add:se,clear:se,delete:se}),S.freeze(e),t&&Z(e,(r,n)=>{Ae(n,!0)},!1)),e}function vt(){w(2)}var se={[B]:vt};function ie(e){return e===null||!pe(e)?!0:S.isFrozen(e)}var oe="MapSet",Pe="Patches",We="ArrayMethods",Ge={};function F(e){const t=Ge[e];return t||w(0,e),t}var qe=e=>!!Ge[e],G,He=()=>G,Tt=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:qe(oe)?F(oe):void 0,arrayMethodsPlugin_:qe(We)?F(We):void 0});function Ke(e,t){t&&(e.patchPlugin_=F(Pe),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function be(e){De(e),e.drafts_.forEach(Et),e.drafts_=null}function De(e){e===G&&(G=e.parent_)}var Je=e=>G=Tt(G,e);function Et(e){const t=e[p];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ye(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[p].modified_&&(be(t),w(4)),b(e)&&(e=Qe(t,e));const{patchPlugin_:s}=t;s&&s.generateReplacementPatches_(r[p].base_,e,t)}else e=Qe(t,r);return Ft(t,e,!0),be(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ve?e:void 0}function Qe(e,t){if(ie(t))return t;const r=t[p];if(!r)return ae(t,e.handledSet_,e);if(!ce(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);et(r,e)}return r.copy_}function Ft(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ae(t,r)}function Xe(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var ce=(e,t)=>e.scope_===t,xt=[];function Ze(e,t,r,n){const s=D(e),i=e.type_;if(n!==void 0&&me(s,n,i)===t){ee(s,n,r,i);return}if(!e.draftLocations_){const u=e.draftLocations_=new Map;Z(s,(m,h)=>{if(v(h)){const _=u.get(h)||[];_.push(m),u.set(h,_)}})}const c=e.draftLocations_.get(t)??xt;for(const u of c)ee(s,u,r,i)}function Nt(e,t,r){e.callbacks_.push(function(s){var u;const i=t;if(!i||!ce(i,s))return;(u=s.mapSetPlugin_)==null||u.fixSetContents(i);const c=we(i);Ze(e,i.draft_??i,c,r),et(i,s)})}function et(e,t){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:s}=t;if(s){const i=s.getPath(e);i&&s.generatePatches_(e,i,t)}Xe(e)}}function $t(e,t,r){const{scope_:n}=e;if(v(r)){const s=r[p];ce(s,n)&&s.callbacks_.push(function(){fe(e);const c=we(s);Ze(e,r,c,t)})}else b(r)&&e.callbacks_.push(function(){const i=D(e);e.type_===3?i.has(r)&&ae(r,n.handledSet_,n):me(i,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&ae(me(e.copy_,t,e.type_),n.handledSet_,n)})}function ae(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||v(e)||t.has(e)||!b(e)||ie(e)||(t.add(e),Z(e,(n,s)=>{if(v(s)){const i=s[p];if(ce(i,r)){const c=we(i);ee(e,n,c,e.type_),Xe(i)}}else b(s)&&ae(s,t,r)})),e}function Rt(e,t){const r=te(e),n={type_:r?1:0,scope_:t?t.scope_:He(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let s=n,i=ue;r&&(s=[n],i=q);const{revoke:c,proxy:u}=Proxy.revocable(s,i);return n.draft_=u,n.revoke_=c,[u,n]}var ue={get(e,t){if(t===p)return e;let r=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof t=="string";if(n&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const s=D(e);if(!Be(s,t,e.type_))return kt(e,s,t);const i=s[t];if(e.finalized_||!b(i)||n&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&zt(t))return i;if(i===Ie(e.base_,t)){fe(e);const c=e.type_===1?+t:t,u=Ce(e.scope_,i,e,c);return e.copy_[c]=u}return i},has(e,t){return t in D(e)},ownKeys(e){return Reflect.ownKeys(D(e))},set(e,t,r){const n=tt(D(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const s=Ie(D(e),t),i=s==null?void 0:s[p];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(Ct(r,s)&&(r!==void 0||Be(e.base_,t,e.type_)))return!0;fe(e),Me(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),$t(e,t,r)),!0},deleteProperty(e,t){return fe(e),Ie(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Me(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=D(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[X]:!0,[ye]:e.type_!==1||t!=="length",[Q]:n[Q],[B]:r[t]}},defineProperty(){w(11)},getPrototypeOf(e){return R(e.base_)},setPrototypeOf(){w(12)}},q={};for(let e in ue){let t=ue[e];q[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}q.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&w(13),q.set.call(this,e,t,void 0)},q.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&w(14),ue.set.call(this,e[0],t,r,e[0])};function Ie(e,t){const r=e[p];return(r?D(r):e)[t]}function kt(e,t,r){var s;const n=tt(t,r);return n?B in n?n[B]:(s=n.get)==null?void 0:s.call(e.draft_):void 0}function tt(e,t){if(!(t in e))return;let r=R(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=R(r)}}function Me(e){e.modified_||(e.modified_=!0,e.parent_&&Me(e.parent_))}function fe(e){e.copy_||(e.assigned_=new Map,e.copy_=Se(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Lt=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(E(t)&&!E(r)){const i=r;r=t;const c=this;return function(m=i,...h){return c.produce(m,_=>r.call(this,_,...h))}}E(r)||w(6),n!==void 0&&!E(n)&&w(7);let s;if(b(t)){const i=Je(this),c=Ce(i,t,void 0);let u=!0;try{s=r(c),u=!1}finally{u?be(i):De(i)}return Ke(i,n),Ye(s,i)}else if(!t||!pe(t)){if(s=r(t),s===void 0&&(s=t),s===Ve&&(s=void 0),this.autoFreeze_&&Ae(s,!0),n){const i=[],c=[];F(Pe).generateReplacementPatches_(t,s,{patches_:i,inversePatches_:c}),n(i,c)}return s}else w(1,t)},this.produceWithPatches=(t,r)=>{if(E(t))return(c,...u)=>this.produceWithPatches(c,m=>t(m,...u));let n,s;return[this.produce(t,r,(c,u)=>{n=c,s=u}),n,s]},ge(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),ge(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),ge(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){b(e)||w(8),v(e)&&(e=Vt(e));const t=Je(this),r=Ce(t,e,void 0);return r[p].isManual_=!0,De(t),r}finishDraft(e,t){const r=e&&e[p];(!r||!r.isManual_)&&w(9);const{scope_:n}=r;return Ke(n,t),Ye(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const s=t[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(t=t.slice(r+1));const n=F(Pe).applyPatches_;return v(e)?n(e,t):this.produce(e,s=>n(s,t))}};function Ce(e,t,r,n){const[s,i]=re(t)?F(oe).proxyMap_(t,r):ne(t)?F(oe).proxySet_(t,r):Rt(t,r);return((r==null?void 0:r.scope_)??He()).drafts_.push(s),i.callbacks_=(r==null?void 0:r.callbacks_)??[],i.key_=n,r&&n!==void 0?Nt(r,i,n):i.callbacks_.push(function(m){var _;(_=m.mapSetPlugin_)==null||_.fixSetContents(i);const{patchPlugin_:h}=m;i.modified_&&h&&h.generatePatches_(i,[],m)}),s}function Vt(e){return v(e)||w(10,e),rt(e)}function rt(e){if(!b(e)||ie(e))return e;const t=e[p];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Se(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=Se(e,!0);return Z(r,(s,i)=>{ee(r,s,rt(i))},n),t&&(t.finalized_=!1),r}var Ot=new Lt,nt=Ot.produce;class st extends T{constructor(t,r){super(r),this.a=t,this.push=(...n)=>{n.length!==0&&this.a.set(this.a.get().concat(n))},this.unshift=(...n)=>{n.length!==0&&this.a.set(n.concat(this.a.get()))},this.update=n=>{const s=this.a.get(),i=nt(s,c=>void n(c));i!==s&&this.a.set(i)},this.filter=n=>{const s=this.a.get().filter(n??jt);s.length!==this.a.get().length&&this.a.set(s)},this.add=n=>{this.a.get().includes(n)||this.a.set(this.a.get().concat([n]))},this.removeFirst=n=>{const s=this.a.get().indexOf(n);if(s<0)return;const i=this.a.get().slice(0);i.splice(s,1),this.a.set(i)},this.toggle=(n,s)=>{const i=this.a.get().slice(),c=i.indexOf(n);c<0?s?i.unshift(n):i.push(n):i.splice(c,1),this.a.set(i)}}}const jt=e=>e;class it extends T{constructor(t,r){super(r),this.a=t,this.toggle=()=>{this.a.set(!this.a.get())}}}class ot extends T{constructor(t,r){super(r),this.a=t,this.setValue=(n,s)=>{if(this.a.get().get(n)===s)return;const i=new Map(this.a.get());i.set(n,s),this.a.set(i)},this.setIfNo=(n,s)=>{if(this.a.get().has(n))return;const i=new Map(this.a.get());i.set(n,s),this.a.set(i)},this.delete=n=>{if(!this.a.get().has(n))return;const s=new Map(this.a.get());s.delete(n),this.a.set(s)},this.toggle=(n,s)=>{const i=new Map(this.a.get());i.has(n)?i.delete(n):i.set(n,s),this.a.set(i)},this.clear=()=>{this.a.set(new Map)},this.a=t}}class ct extends T{constructor(t,r){super(r),this.a=t,this.increment=n=>{this.a.set(+this.a.get()+(n??1))}}}class at extends T{constructor(t,r){super(r),this.a=t,this.setPartial=n=>this.a.set(s=>({...s,...typeof n=="function"?n(this.a.get()):n})),this.update=n=>{const s=this.a.get(),i=nt(s,c=>void n(c));i!==s&&this.a.set(i)},this.setDeepPartial=(n,s,i,c=z.keyPathSeparator||".")=>{if(!c)return;if(n.includes(c)){let h=n.split(c);const _=h[h.length-1];h=h.slice(0,-1);const H={...this.a.get()};let y=H,g=i;for(const A of h){g=g==null?void 0:g[Array.isArray(g)?"0":A];const x=y[ut(y,A)]??(Array.isArray(g)?[]:{});if(x==null||typeof x!="object"){if(i==null)throw"Incorrect path for setDeepPartial";const I=typeof s=="function"?s(void 0):s;this.a.get()[n]!==I&&this.setPartial({[n]:I});return}y=y[ut(y,A)]=Array.isArray(x)?[...x]:{...x}}const _e=y[_];y[_]=typeof s=="function"?s(y[_]):s,_e!==y[_]&&this.a.set(H);return}const u=this.a.get()[n],m=typeof s=="function"?s(u):s;m!==u&&this.setPartial({[n]:m})}}}const ut=(e,t)=>Array.isArray(e)?`${+t}`:t;class ft extends T{constructor(t,r){super(r),this.a=t,this.add=n=>{this.a.get().has(n)||this.a.set(new Set(this.a.get()).add(n))},this.delete=n=>{if(!this.a.get().has(n))return;const s=new Set(this.a.get());s.delete(n),this.a.set(s)},this.toggle=n=>{const s=new Set(this.a.get());s.has(n)?s.delete(n):s.add(n),this.a.set(s)},this.clear=()=>{this.a.set(new Set)},this.a=t}}const Ut=(e,t,r)=>{const n=typeof r=="object"&&r!=null&&"do"in r?r.do((i,c)=>t.set(i,c),()=>t.get(),t,(i,c,u)=>t.setDeferred(i,c,u)):null,s={};return n&&Object.keys(n).forEach(i=>Object.defineProperty(s,i,{get:()=>n[i]})),typeof e=="number"?new ct(t,n):typeof e=="boolean"?new it(t,n):Array.isArray(e)?new st(t,n):e instanceof Set?new ft(t,n):e instanceof Map?new ot(t,n):e instanceof Object?new at(t,n):new T(n)};class lt{constructor(t,r){t=typeof t=="function"?t():t;const n=o=>h=o,s=()=>h,i=new Set,c=o=>o(y());let u=!0,m=!1,h=t,_,H=()=>{},y=()=>s(),g=null,_e=()=>{const o=Ut(t,A,r);return _e=()=>o,o};const A=new Proxy(this,{get:(o,l)=>l==="do"?_e():o[l],set:Bt}),x=()=>{u=!0,m!==!0&&H(y()),m=!1;try{ze.postMessage({key:f,value:s()})}catch{}},I=(o,l)=>{const M=typeof o=="function"?o(y()):o;M!==y()&&(n(M),m=l,u&&(u=!1,i.forEach(c),queueMicrotask(x)))};this.set=(o,l)=>I(o,l),this.get=()=>y(),this.initialValue=t,this.isInitialValue=()=>t===s(),this.subscribe=o=>(i.add(o),()=>{i.delete(o)}),this.reset=()=>{I(t,!0)};const Ht=(o,l)=>{I(o,l),_=void 0};if(this.setDeferred=(o,l=500,M,C=!0)=>{C&&_===void 0&&I(o,M),clearTimeout(_),_=setTimeout(Ht,l,o,M)},r==null)return A;let P=null,K=null,Fe=!0,xe=!0,Ne=!1,N=0,O=0,yt=-1,j=t instanceof Set?o=>new Set(o):t instanceof Map?o=>new Map(o):o=>o,U=t instanceof Set?o=>{if(o instanceof Set)return Array.from(o);throw console.error(o),"The value is not Set instance"}:t instanceof Map?o=>{if(o instanceof Map){const l=[];return o.forEach((M,C)=>l.push([C,M])),l}throw console.error(o),"The value is not Set instance"}:o=>o;if(typeof r=="string")P=r;else if("storeKey"in r)Fe=r.warnOnDuplicateStoreKey??Fe,xe=r.listenStorageChanges??xe,P=r.storeKey,j=r.unzipValue??j,U=r.zipValue??U,Ne=r.unchangable??Ne,N=r.securifyKeyLevel??z.securifyKeyLevel??N,O=r.securifyValueLevel??z.securifyValueLevel??O,K=r.exp??K;else return A;const $e=N?V(P,N):P,f=`${O?ve:L}${$e}`;if(N){const o=`${L}${P}`;o in a&&(a[f]=a[o],delete a[o])}else{const o=`${L}${V(P,N)}`;o in a&&(a[f]=a[o],delete a[o])}const Re=K===null||!(K(A,f in a)instanceof Date)?o=>V([U(o)],0):o=>(g??(g={}),g.exp=K(A,f in a).getTime(),g.exp-Date.now()<24*60*60*1e3&&(clearTimeout(yt),clearTimeout(dt[f]),yt=setTimeout(()=>this.reset(),g.exp-Date.now())),g.exp=Math.trunc(g.exp/1e3),V([U(o),g],0));if(O){const o=`${L}${$e}`,l=U,M=j;if(U=C=>{try{return V([l(C)],O)}catch{return delete a[f],""}},o in a){const C=`${L}${V(P,N)}`;try{a[C]=Re(j(he(a[o],0)[0])),delete a[o]}catch{}}j=C=>{try{return M(he(C,O)[0])}catch{return delete a[f],""}}}else delete a[`${ve}${$e}`];const mt=o=>{const l=he(o,0);return g=l[1],j(l[0])};let pt=!0;if(Te[f]=A,a[`atom/${P}`]&&(a[f]||(a[f]=`[${a[`atom/${P}`]}]`),delete a[`atom/${P}`]),y=()=>{if(y=s,pt){pt=!1;try{n(f in a?mt(a[f]):t)}catch{console.warn("Invalid json value",a[f])}}return s()},H=o=>{if(o===t){this.reset();return}a[f]=Re(o)},this.reset=()=>{delete a[f],I(t,!0)},Fe&&k[f]!==void 0&&console.warn("Duplicate Atom key",P),xe)if(Ne){let o=!1,l;le[f]=this,k[f]=()=>{clearTimeout(l),l=setTimeout(()=>o=!1,10),!o&&(o=!0,a[f]=Re(s()))}}else k[f]=o=>{if(o.newValue===null){this.reset();return}try{I(mt(o.newValue))}catch{console.warn("Invalid json value",o.newValue)}};return A}}let ze;try{ze=new BroadcastChannel("updateHere"),ze.addEventListener("message",e=>{var t;(t=le[e.data.key])==null||t.set(e.data.value,!0)})}catch{}const a=localStorage,k={},le={},Bt=(e,t)=>{throw`${t} is readonly property`};window.addEventListener("storage",e=>{var t;e.key===null||e.newValue===e.oldValue||(t=k[e.key])==null||t.call(k,e)});const Wt=a.setItem.bind(a),Gt=a.removeItem.bind(a);a.setItem=(e,t)=>{le[e]===void 0&&Wt.call(a,e,t)},a.removeItem=e=>{le[e]===void 0&&Gt.call(a,e)};const qt=/"exp":\s*(\d+)/,L="atom\\",ve="atom`s\\",Te={},dt={},ht=/[a-z]/gi,de=5,Ee={};for(let e=54;e<80;e++){if(e===68||e===72||e===55)continue;const t=String.fromCharCode(e+43).toUpperCase(),r=String.fromCharCode(e+43).toLowerCase();Ee[t]=r,Ee[r]=t}const _t=e=>Ee[e]??e,V=(()=>{const e=[t=>JSON.stringify(t),t=>btoa(encodeURI(e[0](t))),t=>{const r=e[1](t);return`${r.slice(0,de)}${r.slice(de).replace(ht,_t)}`},t=>btoa(e[2](t))];return(t,r)=>{try{return e[r](t)}catch(n){if(r===0)throw n;return e[0](t)}}})(),he=(()=>{const e=[t=>JSON.parse(t),t=>e[0](decodeURI(atob(t))),t=>e[1](`${t.slice(0,de)}${t.slice(de).replace(ht,_t)}`),t=>e[2](atob(t))];return(t,r)=>{try{return e[r](t)}catch(n){if(r===0)throw n;return e[0](t)}}})();setTimeout(()=>{Object.keys(a).forEach(e=>{var n;if(typeof a[e]!="string"||!e.startsWith(L)&&!e.startsWith(ve))return;const t=(n=a[e].match(qt))==null?void 0:n[1];if(!t||+t*1e3-Date.now()>24*60*60*1e3)return;const r=he(a[e],0);!Array.isArray(r)||r[1]==null||!("exp"in r[1])||r[1].exp!==t||(dt[e]=setTimeout(()=>{Te[e]?Te[e].reset():delete a[e]},+t*1e3-Date.now()))})},1e3),d.Atom=lt,d.AtomArrayDoActions=st,d.AtomBooleanDoActions=it,d.AtomMapDoActions=ot,d.AtomNumberDoActions=ct,d.AtomObjectDoActions=at,d.AtomSetDoActions=ft,d.atom=Dt,d.configureAtomaric=wt,d.configuredOptions=z,d.useAtom=bt,d.useAtomDo=Pt,d.useAtomGet=At,d.useAtomSet=Le,d.useAtomSetDeferred=St,d.useAtomValue=ke,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atomaric",
|
|
3
3
|
"description": "Manage your project state",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.79",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/atomaric.umd.cjs",
|
|
7
7
|
"module": "./build/atomaric.js",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"vite-plugin-eslint": "^1.8.1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
+
"immer": "^11.1.4",
|
|
52
53
|
"typescript": "~5.7.2"
|
|
53
54
|
}
|
|
54
55
|
}
|