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