atomaric 0.0.64 → 0.0.65

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 CHANGED
@@ -1,367 +1,363 @@
1
- var u = /* @__PURE__ */ ((e) => (e[e.None = 0] = "None", e[e.Simple = 1] = "Simple", e[e.Middle = 2] = "Middle", e[e.Strong = 3] = "Strong", e))(u || {});
2
- let te = () => {
1
+ let ee = () => {
3
2
  throw "call configureAtomaric() before all!";
4
3
  };
5
- const I = {}, pe = (e) => {
6
- I.useSyncExternalStore = te = e.useSyncExternalStore, I.keyPathSeparator = e.keyPathSeparator, I.securifyKeyLevel = e.securifyKeyLevel, I.securifyValueLevel = e.securifyValueLevel;
7
- }, ce = (e) => te(e.subscribe, e.get), oe = (e) => e.set, he = (e) => e.setDeferred, we = (e) => e.get, Se = (e) => e.do, Ae = (e) => [ce(e), oe(e)], be = (e, t) => new fe(e, t), ie = (e, t) => {
8
- const c = (f, p, A) => new Proxy(f, {
9
- get: (s, n, o) => {
10
- const l = A === 0 && t.get != null ? t.get(s, n, o) : s[n];
11
- return typeof l == "object" && l !== null ? c(
12
- Array.isArray(l) ? l.slice(0) : { ...l },
13
- p.concat(Array.isArray(s) ? +n : n),
14
- A + 1
15
- ) : l;
4
+ const C = {}, ge = (e) => {
5
+ C.useSyncExternalStore = ee = e.useSyncExternalStore, C.keyPathSeparator = e.keyPathSeparator, C.securifyKeyLevel = e.securifyKeyLevel, C.securifyValueLevel = e.securifyValueLevel;
6
+ }, ne = (e) => ee(e.subscribe, e.get), ce = (e) => e.set, he = (e) => e.setDeferred, pe = (e) => e.get, we = (e) => e.do, Se = (e) => [ne(e), ce(e)], Ae = (e, t) => new le(e, t), ie = (e, t) => {
7
+ const c = (l, g, S) => new Proxy(l, {
8
+ get: (n, s, i) => {
9
+ const u = S === 0 && t.get != null ? t.get(n, s, i) : n[s];
10
+ return typeof u == "object" && u !== null ? c(
11
+ Array.isArray(u) ? u.slice(0) : { ...u },
12
+ g.concat(Array.isArray(n) ? +s : s),
13
+ S + 1
14
+ ) : u;
16
15
  },
17
- set: (s, n, o) => (t.onSet(s, p, n, o, s[n]) && (s[n] = o), !0)
16
+ set: (n, s, i) => (t.onSet(n, g, s, i, n[s]) && (n[s] = i), !0)
18
17
  });
19
18
  return c(e, [], 0);
20
- }, le = (e, t, c) => {
21
- let f = null;
19
+ }, oe = (e, t, c) => {
20
+ let l = null;
22
21
  if (typeof e == "number")
23
- f = R(
22
+ l = q(
24
23
  t,
25
- (s) => ({
26
- increment: (n) => {
27
- s.set(+s.get() + (n ?? 0));
24
+ (n) => ({
25
+ increment: (s) => {
26
+ n.set(+n.get() + (s ?? 0));
28
27
  }
29
28
  })
30
29
  );
31
30
  else if (typeof e == "boolean")
32
- f = R(
31
+ l = q(
33
32
  t,
34
- (s) => ({
33
+ (n) => ({
35
34
  toggle: () => {
36
- s.set(!s.get());
35
+ n.set(!n.get());
37
36
  }
38
37
  })
39
38
  );
40
39
  else if (Array.isArray(e))
41
- f = R(
40
+ l = q(
42
41
  t,
43
- (s) => ({
44
- push: (...n) => {
45
- s.set(s.get().concat(n));
42
+ (n) => ({
43
+ push: (...s) => {
44
+ n.set(n.get().concat(s));
46
45
  },
47
- unshift: (...n) => {
48
- s.set(n.concat(s.get()));
46
+ unshift: (...s) => {
47
+ n.set(s.concat(n.get()));
49
48
  },
50
- update: (n) => {
51
- const o = s.get(), l = O(o, n);
52
- l !== o && s.set(l);
49
+ update: (s) => {
50
+ const i = n.get(), u = Z(i, s);
51
+ u !== i && n.set(u);
53
52
  },
54
- filter: (n) => {
55
- s.set(s.get().filter(n ?? ue));
53
+ filter: (s) => {
54
+ n.set(n.get().filter(s ?? ue));
56
55
  },
57
- add: (n) => {
58
- s.get().includes(n) || s.set(s.get().concat([n]));
56
+ add: (s) => {
57
+ n.get().includes(s) || n.set(n.get().concat([s]));
59
58
  },
60
- remove: (n) => {
61
- const o = s.get().indexOf(n);
62
- if (o < 0) return;
63
- const l = s.get().slice(0);
64
- l.splice(o, 1), s.set(l);
59
+ remove: (s) => {
60
+ const i = n.get().indexOf(s);
61
+ if (i < 0) return;
62
+ const u = n.get().slice(0);
63
+ u.splice(i, 1), n.set(u);
65
64
  },
66
- toggle: (n, o) => {
67
- const l = s.get().slice(), g = l.indexOf(n);
68
- g < 0 ? o ? l.unshift(n) : l.push(n) : l.splice(g, 1), s.set(l);
65
+ toggle: (s, i) => {
66
+ const u = n.get().slice(), d = u.indexOf(s);
67
+ d < 0 ? i ? u.unshift(s) : u.push(s) : u.splice(d, 1), n.set(u);
69
68
  }
70
69
  })
71
70
  );
72
71
  else if (e instanceof Set)
73
- f = R(
72
+ l = q(
74
73
  t,
75
- (s) => ({
76
- add: (n) => {
77
- s.set(new Set(s.get()).add(n));
74
+ (n) => ({
75
+ add: (s) => {
76
+ n.set(new Set(n.get()).add(s));
78
77
  },
79
- delete: (n) => {
80
- const o = new Set(s.get());
81
- o.delete(n), s.set(o);
78
+ delete: (s) => {
79
+ const i = new Set(n.get());
80
+ i.delete(s), n.set(i);
82
81
  },
83
- toggle: (n) => {
84
- const o = new Set(s.get());
85
- o.has(n) ? o.delete(n) : o.add(n), s.set(o);
82
+ toggle: (s) => {
83
+ const i = new Set(n.get());
84
+ i.has(s) ? i.delete(s) : i.add(s), n.set(i);
86
85
  },
87
86
  clear: () => {
88
- s.set(/* @__PURE__ */ new Set());
87
+ n.set(/* @__PURE__ */ new Set());
89
88
  }
90
89
  })
91
90
  );
92
91
  else if (e instanceof Object) {
93
- const s = I.keyPathSeparator || ".";
94
- f = R(
92
+ const n = C.keyPathSeparator || ".";
93
+ l = q(
95
94
  t,
96
- (n) => ({
97
- setPartial: (o) => n.set((l) => ({
98
- ...l,
99
- ...typeof o == "function" ? o(n.get()) : o
95
+ (s) => ({
96
+ setPartial: (i) => s.set((u) => ({
97
+ ...u,
98
+ ...typeof i == "function" ? i(s.get()) : i
100
99
  })),
101
- update: (o) => {
102
- const l = n.get(), g = O(l, o);
103
- g !== l && n.set(g);
100
+ update: (i) => {
101
+ const u = s.get(), d = Z(u, i);
102
+ d !== u && s.set(d);
104
103
  },
105
- setDeepPartial: (o, l, g, x = s) => {
106
- if (!x) return;
107
- if (o.includes(x)) {
108
- let N = o.split(x);
109
- const S = N[N.length - 1];
110
- N = N.slice(0, -1);
111
- const q = { ...n.get() };
112
- let y = q, V = g;
113
- for (const $ of N) {
114
- V = V == null ? void 0 : V[Array.isArray(V) ? "0" : $];
115
- const D = y[ee(y, $)] ?? (Array.isArray(V) ? [] : {});
116
- if (D == null || typeof D != "object") {
117
- if (g == null) throw "Incorrect path for setDeepPartial";
118
- const _ = typeof l == "function" ? l(void 0) : l;
119
- n.get()[o] !== _ && n.do.setPartial({ [o]: _ });
104
+ setDeepPartial: (i, u, d, b = n) => {
105
+ if (!b) return;
106
+ if (i.includes(b)) {
107
+ let D = i.split(b);
108
+ const w = D[D.length - 1];
109
+ D = D.slice(0, -1);
110
+ const v = { ...s.get() };
111
+ let y = v, V = d;
112
+ for (const x of D) {
113
+ V = V == null ? void 0 : V[Array.isArray(V) ? "0" : x];
114
+ const $ = y[O(y, x)] ?? (Array.isArray(V) ? [] : {});
115
+ if ($ == null || typeof $ != "object") {
116
+ if (d == null) throw "Incorrect path for setDeepPartial";
117
+ const I = typeof u == "function" ? u(void 0) : u;
118
+ s.get()[i] !== I && s.do.setPartial({ [i]: I });
120
119
  return;
121
120
  }
122
- y = y[ee(y, $)] = Array.isArray(D) ? [...D] : { ...D };
121
+ y = y[O(y, x)] = Array.isArray($) ? [...$] : { ...$ };
123
122
  }
124
- const w = y[S];
125
- y[S] = typeof l == "function" ? l(y[S]) : l, w !== y[S] && n.set(q);
123
+ const p = y[w];
124
+ y[w] = typeof u == "function" ? u(y[w]) : u, p !== y[w] && s.set(v);
126
125
  return;
127
126
  }
128
- const h = n.get()[o], b = typeof l == "function" ? l(h) : l;
129
- b !== h && n.do.setPartial({ [o]: b });
127
+ const h = s.get()[i], A = typeof u == "function" ? u(h) : u;
128
+ A !== h && s.do.setPartial({ [i]: A });
130
129
  }
131
130
  })
132
131
  );
133
132
  }
134
- const p = typeof c == "object" && c != null && "do" in c ? c.do(
135
- (s, n) => t.set(s, n),
133
+ const g = typeof c == "object" && c != null && "do" in c ? c.do(
134
+ (n, s) => t.set(n, s),
136
135
  () => t.get(),
137
136
  t,
138
- (s, n, o) => t.setDeferred(s, n, o)
139
- ) : null, A = {};
140
- return p && Object.keys(p).forEach((s) => Object.defineProperty(A, s, { get: () => p[s] })), f && Object.keys(f).forEach(
141
- (s) => Object.defineProperty(A, s, { get: () => f[s] })
142
- ), A;
143
- }, ue = (e) => e, R = (e, t, c) => t(e), O = (e, t) => {
137
+ (n, s, i) => t.setDeferred(n, s, i)
138
+ ) : null, S = {};
139
+ return g && Object.keys(g).forEach((n) => Object.defineProperty(S, n, { get: () => g[n] })), l && Object.keys(l).forEach(
140
+ (n) => Object.defineProperty(S, n, { get: () => l[n] })
141
+ ), S;
142
+ }, ue = (e) => e, q = (e, t, c) => t(e), Z = (e, t) => {
144
143
  const c = Array.isArray(e) ? e.slice(0) : { ...e };
145
- let f = !1;
146
- const p = ie(e, {
147
- onSet: (A, s, n, o, l) => {
148
- if (o === l) return !0;
149
- let g = c;
150
- f = !0;
151
- for (const x of s) {
152
- const h = g[x];
153
- g = g[x] = Array.isArray(h) ? h.slice(0) : { ...h };
144
+ let l = !1;
145
+ const g = ie(e, {
146
+ onSet: (S, n, s, i, u) => {
147
+ if (i === u) return !0;
148
+ let d = c;
149
+ l = !0;
150
+ for (const b of n) {
151
+ const h = d[b];
152
+ d = d[b] = Array.isArray(h) ? h.slice(0) : { ...h };
154
153
  }
155
- return g[n] = o, !0;
154
+ return d[s] = i, !0;
156
155
  }
157
156
  });
158
- return t(p), f ? c : e;
159
- }, ee = (e, t) => Array.isArray(e) ? `${+t}` : t;
160
- class fe {
157
+ return t(g), l ? c : e;
158
+ }, O = (e, t) => Array.isArray(e) ? `${+t}` : t;
159
+ class le {
161
160
  constructor(t, c) {
162
- const f = (r) => l = r, p = () => l, A = /* @__PURE__ */ new Set(), s = (r) => r(h());
163
- let n = !0, o = !1, l = t, g, x = () => {
164
- }, h = () => p(), b = null, N = () => {
165
- const r = le(t, S, c);
166
- return N = () => r, r;
161
+ const l = (r) => u = r, g = () => u, S = /* @__PURE__ */ new Set(), n = (r) => r(h());
162
+ let s = !0, i = !1, u = t, d, b = () => {
163
+ }, h = () => g(), A = null, D = () => {
164
+ const r = oe(t, w, c);
165
+ return D = () => r, r;
167
166
  };
168
- const S = new Proxy(this, {
169
- get: (r, d) => d === "do" ? N() : r[d],
170
- set: ae
171
- }), q = () => {
172
- n = !0, o !== !0 && x(h()), o = !1;
167
+ const w = new Proxy(this, {
168
+ get: (r, a) => a === "do" ? D() : r[a],
169
+ set: fe
170
+ }), v = () => {
171
+ s = !0, i !== !0 && b(h()), i = !1;
173
172
  try {
174
- G.postMessage({ key: a, value: p() });
173
+ N.postMessage({ key: f, value: g() });
175
174
  } catch {
176
175
  }
177
- }, y = (r, d) => {
178
- const T = typeof r == "function" ? r(h()) : r;
179
- T !== h() && (f(T), o = d, n && (n = !1, A.forEach(s), queueMicrotask(q)));
176
+ }, y = (r, a) => {
177
+ const P = typeof r == "function" ? r(h()) : r;
178
+ P !== h() && (l(P), i = a, s && (s = !1, S.forEach(n), queueMicrotask(v)));
180
179
  };
181
- this.set = (r, d) => y(r, d), this.get = () => h(), this.initialValue = t, this.isInitialValue = () => t === p(), this.subscribe = (r) => (A.add(r), () => {
182
- A.delete(r);
180
+ this.set = (r, a) => y(r, a), this.get = () => h(), this.initialValue = t, this.isInitialValue = () => t === g(), this.subscribe = (r) => (S.add(r), () => {
181
+ S.delete(r);
183
182
  }), this.reset = () => {
184
183
  y(t, !0);
185
184
  };
186
- const V = (r, d) => {
187
- y(r, d), g = void 0;
185
+ const V = (r, a) => {
186
+ y(r, a), d = void 0;
188
187
  };
189
- if (this.setDeferred = (r, d = 500, T, C = !0) => {
190
- C && g === void 0 && y(r, T), clearTimeout(g), g = setTimeout(V, d, r, T);
191
- }, c == null) return S;
192
- let w = null, $ = null, D = !0, _ = !0, H = !1, P = u.None, j = u.None, X = -1, m = t instanceof Set ? (r) => new Set(r) : (r) => r, M = t instanceof Set ? (r) => {
188
+ if (this.setDeferred = (r, a = 500, P, T = !0) => {
189
+ T && d === void 0 && y(r, P), clearTimeout(d), d = setTimeout(V, a, r, P);
190
+ }, c == null) return w;
191
+ let p = null, x = null, $ = !0, I = !0, W = !1, L = 0, _ = 0, k = -1, j = t instanceof Set ? (r) => new Set(r) : (r) => r, m = t instanceof Set ? (r) => {
193
192
  if (r instanceof Set) return Array.from(r);
194
193
  throw console.error(r), "The value is not Set instance";
195
194
  } : (r) => r;
196
195
  if (typeof c == "string")
197
- w = c;
196
+ p = c;
198
197
  else if ("storeKey" in c)
199
- D = c.warnOnDuplicateStoreKey ?? D, _ = c.listenStorageChanges ?? _, w = c.storeKey, m = c.unzipValue ?? m, M = c.zipValue ?? M, H = c.unchangable ?? H, P = c.securifyKeyLevel ?? I.securifyKeyLevel ?? P, j = c.securifyValueLevel ?? I.securifyValueLevel ?? j, $ = c.exp ?? $;
200
- else return S;
201
- const J = P ? E(w, P) : w, a = `${j ? Q : L}${J}`;
202
- if (P) {
203
- const r = `${L}${w}`;
204
- r in i && (i[a] = i[r], delete i[r]);
198
+ $ = c.warnOnDuplicateStoreKey ?? $, I = c.listenStorageChanges ?? I, p = c.storeKey, j = c.unzipValue ?? j, m = c.zipValue ?? m, W = c.unchangable ?? W, L = c.securifyKeyLevel ?? C.securifyKeyLevel ?? L, _ = c.securifyValueLevel ?? C.securifyValueLevel ?? _, x = c.exp ?? x;
199
+ else return w;
200
+ const H = L ? E(p, L) : p, f = `${_ ? B : z}${H}`;
201
+ if (L) {
202
+ const r = `${z}${p}`;
203
+ r in o && (o[f] = o[r], delete o[r]);
205
204
  } else {
206
- const r = `${L}${E(w, P)}`;
207
- r in i && (i[a] = i[r], delete i[r]);
205
+ const r = `${z}${E(p, L)}`;
206
+ r in o && (o[f] = o[r], delete o[r]);
208
207
  }
209
- const B = $ === null || !($(S, a in i) instanceof Date) ? (r) => E([M(r)], u.None) : (r) => (b ?? (b = {}), b.exp = $(S, a in i).getTime(), b.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout(X), clearTimeout(re[a]), X = setTimeout(() => this.reset(), b.exp - Date.now())), b.exp = Math.trunc(b.exp / 1e3), E([M(r), b], u.None));
210
- if (j) {
211
- const r = `${L}${J}`, d = M, T = m;
212
- if (M = (C) => {
208
+ const J = x === null || !(x(w, f in o) instanceof Date) ? (r) => E([m(r)], 0) : (r) => (A ?? (A = {}), A.exp = x(w, f in o).getTime(), A.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout(k), clearTimeout(te[f]), k = setTimeout(() => this.reset(), A.exp - Date.now())), A.exp = Math.trunc(A.exp / 1e3), E([m(r), A], 0));
209
+ if (_) {
210
+ const r = `${z}${H}`, a = m, P = j;
211
+ if (m = (T) => {
213
212
  try {
214
- return E([d(C)], j);
213
+ return E([a(T)], _);
215
214
  } catch {
216
- return delete i[a], "";
215
+ return delete o[f], "";
217
216
  }
218
- }, r in i) {
219
- const C = `${L}${E(w, P)}`;
217
+ }, r in o) {
218
+ const T = `${z}${E(p, L)}`;
220
219
  try {
221
- i[C] = B(
222
- m(U(i[r], u.None)[0])
223
- ), delete i[r];
220
+ o[T] = J(j(M(o[r], 0)[0])), delete o[r];
224
221
  } catch {
225
222
  }
226
223
  }
227
- m = (C) => {
224
+ j = (T) => {
228
225
  try {
229
- return T(U(C, j)[0]);
226
+ return P(M(T, _)[0]);
230
227
  } catch {
231
- return delete i[a], "";
228
+ return delete o[f], "";
232
229
  }
233
230
  };
234
- } else delete i[`${Q}${J}`];
235
- const Y = (r) => {
236
- const d = U(r, u.None);
237
- return b = d[1], m(d[0]);
231
+ } else delete o[`${B}${H}`];
232
+ const K = (r) => {
233
+ const a = M(r, 0);
234
+ return A = a[1], j(a[0]);
238
235
  };
239
- let Z = !0;
240
- if (k[a] = S, i[`atom/${w}`] && (i[a] || (i[a] = `[${i[`atom/${w}`]}]`), delete i[`atom/${w}`]), h = () => {
241
- if (h = p, Z) {
242
- Z = !1;
236
+ let X = !0;
237
+ if (G[f] = w, o[`atom/${p}`] && (o[f] || (o[f] = `[${o[`atom/${p}`]}]`), delete o[`atom/${p}`]), h = () => {
238
+ if (h = g, X) {
239
+ X = !1;
243
240
  try {
244
- f(a in i ? Y(i[a]) : t);
241
+ l(f in o ? K(o[f]) : t);
245
242
  } catch {
246
- console.warn("Invalid json value", i[a]);
243
+ console.warn("Invalid json value", o[f]);
247
244
  }
248
245
  }
249
- return p();
250
- }, x = (r) => {
246
+ return g();
247
+ }, b = (r) => {
251
248
  if (r === t) {
252
249
  this.reset();
253
250
  return;
254
251
  }
255
- i[a] = B(r);
252
+ o[f] = J(r);
256
253
  }, this.reset = () => {
257
- delete i[a], y(t, !0);
258
- }, D && z[a] !== void 0 && console.warn("Duplicate Atom key", w), _)
259
- if (H) {
260
- let r = !1, d;
261
- W[a] = this, z[a] = () => {
262
- clearTimeout(d), d = setTimeout(() => r = !1, 10), !r && (r = !0, i[a] = B(p()));
254
+ delete o[f], y(t, !0);
255
+ }, $ && R[f] !== void 0 && console.warn("Duplicate Atom key", p), I)
256
+ if (W) {
257
+ let r = !1, a;
258
+ F[f] = this, R[f] = () => {
259
+ clearTimeout(a), a = setTimeout(() => r = !1, 10), !r && (r = !0, o[f] = J(g()));
263
260
  };
264
261
  } else
265
- z[a] = (r) => {
262
+ R[f] = (r) => {
266
263
  if (r.newValue === null) {
267
264
  this.reset();
268
265
  return;
269
266
  }
270
267
  try {
271
- y(Y(r.newValue));
268
+ y(K(r.newValue));
272
269
  } catch {
273
270
  console.warn("Invalid json value", r.newValue);
274
271
  }
275
272
  };
276
- return S;
273
+ return w;
277
274
  }
278
275
  }
279
- let G;
276
+ let N;
280
277
  try {
281
- G = new BroadcastChannel("updateHere"), G.addEventListener("message", (e) => {
278
+ N = new BroadcastChannel("updateHere"), N.addEventListener("message", (e) => {
282
279
  var t;
283
- (t = W[e.data.key]) == null || t.set(e.data.value, !0);
280
+ (t = F[e.data.key]) == null || t.set(e.data.value, !0);
284
281
  });
285
282
  } catch {
286
283
  }
287
- const i = localStorage, z = {}, W = {}, ae = (e, t) => {
284
+ const o = localStorage, R = {}, F = {}, fe = (e, t) => {
288
285
  throw `${t} is readonly property`;
289
286
  };
290
287
  window.addEventListener("storage", (e) => {
291
288
  var t;
292
- e.key === null || e.newValue === e.oldValue || (t = z[e.key]) == null || t.call(z, e);
289
+ e.key === null || e.newValue === e.oldValue || (t = R[e.key]) == null || t.call(R, e);
293
290
  });
294
- const de = i.setItem.bind(i), ge = i.removeItem.bind(i);
295
- i.setItem = (e, t) => {
296
- W[e] === void 0 && de.call(i, e, t);
291
+ const ae = o.setItem.bind(o), de = o.removeItem.bind(o);
292
+ o.setItem = (e, t) => {
293
+ F[e] === void 0 && ae.call(o, e, t);
297
294
  };
298
- i.removeItem = (e) => {
299
- W[e] === void 0 && ge.call(i, e);
295
+ o.removeItem = (e) => {
296
+ F[e] === void 0 && de.call(o, e);
300
297
  };
301
- const ye = /"exp":\s*(\d+)/, L = "atom\\", Q = "atom`s\\", k = {}, re = {}, ne = /[a-z]/gi, F = 5, K = {};
298
+ const ye = /"exp":\s*(\d+)/, z = "atom\\", B = "atom`s\\", G = {}, te = {}, re = /[a-z]/gi, U = 5, Q = {};
302
299
  for (let e = 54; e < 80; e++) {
303
300
  if (e === 68 || e === 72 || e === 55) continue;
304
301
  const t = String.fromCharCode(e + 43).toUpperCase(), c = String.fromCharCode(e + 43).toLowerCase();
305
- K[t] = c, K[c] = t;
302
+ Q[t] = c, Q[c] = t;
306
303
  }
307
- const se = (e) => K[e] ?? e, E = (() => {
308
- const e = {
309
- [u.None]: (t) => JSON.stringify(t),
310
- [u.Simple]: (t) => btoa(encodeURI(e[u.None](t))),
311
- [u.Middle]: (t) => {
312
- const c = e[u.Simple](t);
313
- return `${c.slice(0, F)}${c.slice(F).replace(ne, se)}`;
304
+ const se = (e) => Q[e] ?? e, E = /* @__PURE__ */ (() => {
305
+ const e = [
306
+ (t) => JSON.stringify(t),
307
+ (t) => btoa(encodeURI(e[0](t))),
308
+ (t) => {
309
+ const c = e[1](t);
310
+ return `${c.slice(0, U)}${c.slice(U).replace(re, se)}`;
314
311
  },
315
- [u.Strong]: (t) => btoa(e[u.Middle](t))
316
- };
312
+ (t) => btoa(e[2](t))
313
+ ];
317
314
  return (t, c) => {
318
315
  try {
319
316
  return e[c](t);
320
- } catch (f) {
321
- if (c === u.None) throw f;
322
- return e[u.None](t);
317
+ } catch (l) {
318
+ if (c === 0) throw l;
319
+ return e[0](t);
323
320
  }
324
321
  };
325
- })(), U = (() => {
326
- const e = {
327
- [u.None]: (t) => JSON.parse(t),
328
- [u.Simple]: (t) => e[u.None](decodeURI(atob(t))),
329
- [u.Middle]: (t) => e[u.Simple](
330
- `${t.slice(0, F)}${t.slice(F).replace(ne, se)}`
322
+ })(), M = /* @__PURE__ */ (() => {
323
+ const e = [
324
+ (t) => JSON.parse(t),
325
+ (t) => e[0](decodeURI(atob(t))),
326
+ (t) => e[1](
327
+ `${t.slice(0, U)}${t.slice(U).replace(re, se)}`
331
328
  ),
332
- [u.Strong]: (t) => e[u.Middle](atob(t))
333
- };
329
+ (t) => e[2](atob(t))
330
+ ];
334
331
  return (t, c) => {
335
332
  try {
336
333
  return e[c](t);
337
- } catch (f) {
338
- if (c === u.None) throw f;
339
- return e[u.None](t);
334
+ } catch (l) {
335
+ if (c === 0) throw l;
336
+ return e[0](t);
340
337
  }
341
338
  };
342
339
  })();
343
340
  setTimeout(() => {
344
- Object.keys(i).forEach((e) => {
345
- var f;
346
- if (typeof i[e] != "string" || !e.startsWith(L) && !e.startsWith(Q)) return;
347
- const t = +((f = i[e].match(ye)) == null ? void 0 : f[1]);
341
+ Object.keys(o).forEach((e) => {
342
+ var l;
343
+ if (typeof o[e] != "string" || !e.startsWith(z) && !e.startsWith(B)) return;
344
+ const t = +((l = o[e].match(ye)) == null ? void 0 : l[1]);
348
345
  if (!t || t * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
349
- const c = U(i[e], u.None);
350
- !Array.isArray(c) || c[1] == null || !("exp" in c[1]) || c[1].exp !== t || (re[e] = setTimeout(() => {
351
- k[e] ? k[e].reset() : delete i[e];
346
+ const c = M(o[e], 0);
347
+ !Array.isArray(c) || c[1] == null || !("exp" in c[1]) || c[1].exp !== t || (te[e] = setTimeout(() => {
348
+ G[e] ? G[e].reset() : delete o[e];
352
349
  }, t * 1e3 - Date.now()));
353
350
  });
354
351
  }, 1e3);
355
352
  export {
356
- fe as Atom,
357
- u as AtomSecureLevel,
358
- be as atom,
359
- pe as configureAtomaric,
360
- I as configuredOptions,
361
- Ae as useAtom,
362
- Se as useAtomDo,
363
- we as useAtomGet,
364
- oe as useAtomSet,
353
+ le as Atom,
354
+ Ae as atom,
355
+ ge as configureAtomaric,
356
+ C as configuredOptions,
357
+ Se as useAtom,
358
+ we as useAtomDo,
359
+ pe as useAtomGet,
360
+ ce as useAtomSet,
365
361
  he as useAtomSetDeferred,
366
- ce as useAtomValue
362
+ ne as useAtomValue
367
363
  };
@@ -1 +1 @@
1
- (function(y,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(y=typeof globalThis<"u"?globalThis:y||self,l(y.atomaric={}))})(this,function(y){"use strict";var l=(e=>(e[e.None=0]="None",e[e.Simple=1]="Simple",e[e.Middle=2]="Middle",e[e.Strong=3]="Strong",e))(l||{});let X=()=>{throw"call configureAtomaric() before all!"};const N={},le=e=>{N.useSyncExternalStore=X=e.useSyncExternalStore,N.keyPathSeparator=e.keyPathSeparator,N.securifyKeyLevel=e.securifyKeyLevel,N.securifyValueLevel=e.securifyValueLevel},Y=e=>X(e.subscribe,e.get),Z=e=>e.set,fe=e=>e.setDeferred,ae=e=>e.get,de=e=>e.do,ge=e=>[Y(e),Z(e)],ye=(e,t)=>new te(e,t),he=(e,t)=>{const c=(f,p,b)=>new Proxy(f,{get:(s,r,o)=>{const u=b===0&&t.get!=null?t.get(s,r,o):s[r];return typeof u=="object"&&u!==null?c(Array.isArray(u)?u.slice(0):{...u},p.concat(Array.isArray(s)?+r:r),b+1):u},set:(s,r,o)=>(t.onSet(s,p,r,o,s[r])&&(s[r]=o),!0)});return c(e,[],0)},pe=(e,t,c)=>{let f=null;if(typeof e=="number")f=q(t,s=>({increment:r=>{s.set(+s.get()+(r??0))}}));else if(typeof e=="boolean")f=q(t,s=>({toggle:()=>{s.set(!s.get())}}));else if(Array.isArray(e))f=q(t,s=>({push:(...r)=>{s.set(s.get().concat(r))},unshift:(...r)=>{s.set(r.concat(s.get()))},update:r=>{const o=s.get(),u=O(o,r);u!==o&&s.set(u)},filter:r=>{s.set(s.get().filter(r??Se))},add:r=>{s.get().includes(r)||s.set(s.get().concat([r]))},remove:r=>{const o=s.get().indexOf(r);if(o<0)return;const u=s.get().slice(0);u.splice(o,1),s.set(u)},toggle:(r,o)=>{const u=s.get().slice(),g=u.indexOf(r);g<0?o?u.unshift(r):u.push(r):u.splice(g,1),s.set(u)}}));else if(e instanceof Set)f=q(t,s=>({add:r=>{s.set(new Set(s.get()).add(r))},delete:r=>{const o=new Set(s.get());o.delete(r),s.set(o)},toggle:r=>{const o=new Set(s.get());o.has(r)?o.delete(r):o.add(r),s.set(o)},clear:()=>{s.set(new Set)}}));else if(e instanceof Object){const s=N.keyPathSeparator||".";f=q(t,r=>({setPartial:o=>r.set(u=>({...u,...typeof o=="function"?o(r.get()):o})),update:o=>{const u=r.get(),g=O(u,o);g!==u&&r.set(g)},setDeepPartial:(o,u,g,$=s)=>{if(!$)return;if(o.includes($)){let T=o.split($);const A=T[T.length-1];T=T.slice(0,-1);const G={...r.get()};let h=G,V=g;for(const x of T){V=V==null?void 0:V[Array.isArray(V)?"0":x];const D=h[ee(h,x)]??(Array.isArray(V)?[]:{});if(D==null||typeof D!="object"){if(g==null)throw"Incorrect path for setDeepPartial";const L=typeof u=="function"?u(void 0):u;r.get()[o]!==L&&r.do.setPartial({[o]:L});return}h=h[ee(h,x)]=Array.isArray(D)?[...D]:{...D}}const w=h[A];h[A]=typeof u=="function"?u(h[A]):u,w!==h[A]&&r.set(G);return}const S=r.get()[o],m=typeof u=="function"?u(S):u;m!==S&&r.do.setPartial({[o]:m})}}))}const p=typeof c=="object"&&c!=null&&"do"in c?c.do((s,r)=>t.set(s,r),()=>t.get(),t,(s,r,o)=>t.setDeferred(s,r,o)):null,b={};return p&&Object.keys(p).forEach(s=>Object.defineProperty(b,s,{get:()=>p[s]})),f&&Object.keys(f).forEach(s=>Object.defineProperty(b,s,{get:()=>f[s]})),b},Se=e=>e,q=(e,t,c)=>t(e),O=(e,t)=>{const c=Array.isArray(e)?e.slice(0):{...e};let f=!1;const p=he(e,{onSet:(b,s,r,o,u)=>{if(o===u)return!0;let g=c;f=!0;for(const $ of s){const S=g[$];g=g[$]=Array.isArray(S)?S.slice(0):{...S}}return g[r]=o,!0}});return t(p),f?c:e},ee=(e,t)=>Array.isArray(e)?`${+t}`:t;class te{constructor(t,c){const f=n=>u=n,p=()=>u,b=new Set,s=n=>n(S());let r=!0,o=!1,u=t,g,$=()=>{},S=()=>p(),m=null,T=()=>{const n=pe(t,A,c);return T=()=>n,n};const A=new Proxy(this,{get:(n,d)=>d==="do"?T():n[d],set:we}),G=()=>{r=!0,o!==!0&&$(S()),o=!1;try{H.postMessage({key:a,value:p()})}catch{}},h=(n,d)=>{const j=typeof n=="function"?n(S()):n;j!==S()&&(f(j),o=d,r&&(r=!1,b.forEach(s),queueMicrotask(G)))};this.set=(n,d)=>h(n,d),this.get=()=>S(),this.initialValue=t,this.isInitialValue=()=>t===p(),this.subscribe=n=>(b.add(n),()=>{b.delete(n)}),this.reset=()=>{h(t,!0)};const V=(n,d)=>{h(n,d),g=void 0};if(this.setDeferred=(n,d=500,j,C=!0)=>{C&&g===void 0&&h(n,j),clearTimeout(g),g=setTimeout(V,d,n,j)},c==null)return A;let w=null,x=null,D=!0,L=!0,k=!1,P=l.None,E=l.None,ce=-1,z=t instanceof Set?n=>new Set(n):n=>n,R=t instanceof Set?n=>{if(n instanceof Set)return Array.from(n);throw console.error(n),"The value is not Set instance"}:n=>n;if(typeof c=="string")w=c;else if("storeKey"in c)D=c.warnOnDuplicateStoreKey??D,L=c.listenStorageChanges??L,w=c.storeKey,z=c.unzipValue??z,R=c.zipValue??R,k=c.unchangable??k,P=c.securifyKeyLevel??N.securifyKeyLevel??P,E=c.securifyValueLevel??N.securifyValueLevel??E,x=c.exp??x;else return A;const v=P?M(w,P):w,a=`${E?J:_}${v}`;if(P){const n=`${_}${w}`;n in i&&(i[a]=i[n],delete i[n])}else{const n=`${_}${M(w,P)}`;n in i&&(i[a]=i[n],delete i[n])}const K=x===null||!(x(A,a in i)instanceof Date)?n=>M([R(n)],l.None):n=>(m??(m={}),m.exp=x(A,a in i).getTime(),m.exp-Date.now()<24*60*60*1e3&&(clearTimeout(ce),clearTimeout(ne[a]),ce=setTimeout(()=>this.reset(),m.exp-Date.now())),m.exp=Math.trunc(m.exp/1e3),M([R(n),m],l.None));if(E){const n=`${_}${v}`,d=R,j=z;if(R=C=>{try{return M([d(C)],E)}catch{return delete i[a],""}},n in i){const C=`${_}${M(w,P)}`;try{i[C]=K(z(W(i[n],l.None)[0])),delete i[n]}catch{}}z=C=>{try{return j(W(C,E)[0])}catch{return delete i[a],""}}}else delete i[`${J}${v}`];const ie=n=>{const d=W(n,l.None);return m=d[1],z(d[0])};let oe=!0;if(B[a]=A,i[`atom/${w}`]&&(i[a]||(i[a]=`[${i[`atom/${w}`]}]`),delete i[`atom/${w}`]),S=()=>{if(S=p,oe){oe=!1;try{f(a in i?ie(i[a]):t)}catch{console.warn("Invalid json value",i[a])}}return p()},$=n=>{if(n===t){this.reset();return}i[a]=K(n)},this.reset=()=>{delete i[a],h(t,!0)},D&&I[a]!==void 0&&console.warn("Duplicate Atom key",w),L)if(k){let n=!1,d;U[a]=this,I[a]=()=>{clearTimeout(d),d=setTimeout(()=>n=!1,10),!n&&(n=!0,i[a]=K(p()))}}else I[a]=n=>{if(n.newValue===null){this.reset();return}try{h(ie(n.newValue))}catch{console.warn("Invalid json value",n.newValue)}};return A}}let H;try{H=new BroadcastChannel("updateHere"),H.addEventListener("message",e=>{var t;(t=U[e.data.key])==null||t.set(e.data.value,!0)})}catch{}const i=localStorage,I={},U={},we=(e,t)=>{throw`${t} is readonly property`};window.addEventListener("storage",e=>{var t;e.key===null||e.newValue===e.oldValue||(t=I[e.key])==null||t.call(I,e)});const Ae=i.setItem.bind(i),be=i.removeItem.bind(i);i.setItem=(e,t)=>{U[e]===void 0&&Ae.call(i,e,t)},i.removeItem=e=>{U[e]===void 0&&be.call(i,e)};const me=/"exp":\s*(\d+)/,_="atom\\",J="atom`s\\",B={},ne={},re=/[a-z]/gi,F=5,Q={};for(let e=54;e<80;e++){if(e===68||e===72||e===55)continue;const t=String.fromCharCode(e+43).toUpperCase(),c=String.fromCharCode(e+43).toLowerCase();Q[t]=c,Q[c]=t}const se=e=>Q[e]??e,M=(()=>{const e={[l.None]:t=>JSON.stringify(t),[l.Simple]:t=>btoa(encodeURI(e[l.None](t))),[l.Middle]:t=>{const c=e[l.Simple](t);return`${c.slice(0,F)}${c.slice(F).replace(re,se)}`},[l.Strong]:t=>btoa(e[l.Middle](t))};return(t,c)=>{try{return e[c](t)}catch(f){if(c===l.None)throw f;return e[l.None](t)}}})(),W=(()=>{const e={[l.None]:t=>JSON.parse(t),[l.Simple]:t=>e[l.None](decodeURI(atob(t))),[l.Middle]:t=>e[l.Simple](`${t.slice(0,F)}${t.slice(F).replace(re,se)}`),[l.Strong]:t=>e[l.Middle](atob(t))};return(t,c)=>{try{return e[c](t)}catch(f){if(c===l.None)throw f;return e[l.None](t)}}})();setTimeout(()=>{Object.keys(i).forEach(e=>{var f;if(typeof i[e]!="string"||!e.startsWith(_)&&!e.startsWith(J))return;const t=+((f=i[e].match(me))==null?void 0:f[1]);if(!t||t*1e3-Date.now()>24*60*60*1e3)return;const c=W(i[e],l.None);!Array.isArray(c)||c[1]==null||!("exp"in c[1])||c[1].exp!==t||(ne[e]=setTimeout(()=>{B[e]?B[e].reset():delete i[e]},t*1e3-Date.now()))})},1e3),y.Atom=te,y.AtomSecureLevel=l,y.atom=ye,y.configureAtomaric=le,y.configuredOptions=N,y.useAtom=ge,y.useAtomDo=de,y.useAtomGet=ae,y.useAtomSet=Z,y.useAtomSetDeferred=fe,y.useAtomValue=Y,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
1
+ (function(g,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(g=typeof globalThis<"u"?globalThis:g||self,C(g.atomaric={}))})(this,function(g){"use strict";let C=()=>{throw"call configureAtomaric() before all!"};const D={},ue=e=>{D.useSyncExternalStore=C=e.useSyncExternalStore,D.keyPathSeparator=e.keyPathSeparator,D.securifyKeyLevel=e.securifyKeyLevel,D.securifyValueLevel=e.securifyValueLevel},X=e=>C(e.subscribe,e.get),Y=e=>e.set,le=e=>e.setDeferred,fe=e=>e.get,ae=e=>e.do,de=e=>[X(e),Y(e)],ye=(e,t)=>new ee(e,t),ge=(e,t)=>{const c=(l,h,S)=>new Proxy(l,{get:(s,n,o)=>{const u=S===0&&t.get!=null?t.get(s,n,o):s[n];return typeof u=="object"&&u!==null?c(Array.isArray(u)?u.slice(0):{...u},h.concat(Array.isArray(s)?+n:n),S+1):u},set:(s,n,o)=>(t.onSet(s,h,n,o,s[n])&&(s[n]=o),!0)});return c(e,[],0)},he=(e,t,c)=>{let l=null;if(typeof e=="number")l=q(t,s=>({increment:n=>{s.set(+s.get()+(n??0))}}));else if(typeof e=="boolean")l=q(t,s=>({toggle:()=>{s.set(!s.get())}}));else if(Array.isArray(e))l=q(t,s=>({push:(...n)=>{s.set(s.get().concat(n))},unshift:(...n)=>{s.set(n.concat(s.get()))},update:n=>{const o=s.get(),u=Z(o,n);u!==o&&s.set(u)},filter:n=>{s.set(s.get().filter(n??Ae))},add:n=>{s.get().includes(n)||s.set(s.get().concat([n]))},remove:n=>{const o=s.get().indexOf(n);if(o<0)return;const u=s.get().slice(0);u.splice(o,1),s.set(u)},toggle:(n,o)=>{const u=s.get().slice(),d=u.indexOf(n);d<0?o?u.unshift(n):u.push(n):u.splice(d,1),s.set(u)}}));else if(e instanceof Set)l=q(t,s=>({add:n=>{s.set(new Set(s.get()).add(n))},delete:n=>{const o=new Set(s.get());o.delete(n),s.set(o)},toggle:n=>{const o=new Set(s.get());o.has(n)?o.delete(n):o.add(n),s.set(o)},clear:()=>{s.set(new Set)}}));else if(e instanceof Object){const s=D.keyPathSeparator||".";l=q(t,n=>({setPartial:o=>n.set(u=>({...u,...typeof o=="function"?o(n.get()):o})),update:o=>{const u=n.get(),d=Z(u,o);d!==u&&n.set(d)},setDeepPartial:(o,u,d,m=s)=>{if(!m)return;if(o.includes(m)){let T=o.split(m);const w=T[T.length-1];T=T.slice(0,-1);const G={...n.get()};let y=G,V=d;for(const x of T){V=V==null?void 0:V[Array.isArray(V)?"0":x];const $=y[O(y,x)]??(Array.isArray(V)?[]:{});if($==null||typeof $!="object"){if(d==null)throw"Incorrect path for setDeepPartial";const z=typeof u=="function"?u(void 0):u;n.get()[o]!==z&&n.do.setPartial({[o]:z});return}y=y[O(y,x)]=Array.isArray($)?[...$]:{...$}}const p=y[w];y[w]=typeof u=="function"?u(y[w]):u,p!==y[w]&&n.set(G);return}const A=n.get()[o],b=typeof u=="function"?u(A):u;b!==A&&n.do.setPartial({[o]:b})}}))}const h=typeof c=="object"&&c!=null&&"do"in c?c.do((s,n)=>t.set(s,n),()=>t.get(),t,(s,n,o)=>t.setDeferred(s,n,o)):null,S={};return h&&Object.keys(h).forEach(s=>Object.defineProperty(S,s,{get:()=>h[s]})),l&&Object.keys(l).forEach(s=>Object.defineProperty(S,s,{get:()=>l[s]})),S},Ae=e=>e,q=(e,t,c)=>t(e),Z=(e,t)=>{const c=Array.isArray(e)?e.slice(0):{...e};let l=!1;const h=ge(e,{onSet:(S,s,n,o,u)=>{if(o===u)return!0;let d=c;l=!0;for(const m of s){const A=d[m];d=d[m]=Array.isArray(A)?A.slice(0):{...A}}return d[n]=o,!0}});return t(h),l?c:e},O=(e,t)=>Array.isArray(e)?`${+t}`:t;class ee{constructor(t,c){const l=r=>u=r,h=()=>u,S=new Set,s=r=>r(A());let n=!0,o=!1,u=t,d,m=()=>{},A=()=>h(),b=null,T=()=>{const r=he(t,w,c);return T=()=>r,r};const w=new Proxy(this,{get:(r,a)=>a==="do"?T():r[a],set:pe}),G=()=>{n=!0,o!==!0&&m(A()),o=!1;try{H.postMessage({key:f,value:h()})}catch{}},y=(r,a)=>{const j=typeof r=="function"?r(A()):r;j!==A()&&(l(j),o=a,n&&(n=!1,S.forEach(s),queueMicrotask(G)))};this.set=(r,a)=>y(r,a),this.get=()=>A(),this.initialValue=t,this.isInitialValue=()=>t===h(),this.subscribe=r=>(S.add(r),()=>{S.delete(r)}),this.reset=()=>{y(t,!0)};const V=(r,a)=>{y(r,a),d=void 0};if(this.setDeferred=(r,a=500,j,L=!0)=>{L&&d===void 0&&y(r,j),clearTimeout(d),d=setTimeout(V,a,r,j)},c==null)return w;let p=null,x=null,$=!0,z=!0,Q=!1,P=0,R=0,se=-1,v=t instanceof Set?r=>new Set(r):r=>r,M=t instanceof Set?r=>{if(r instanceof Set)return Array.from(r);throw console.error(r),"The value is not Set instance"}:r=>r;if(typeof c=="string")p=c;else if("storeKey"in c)$=c.warnOnDuplicateStoreKey??$,z=c.listenStorageChanges??z,p=c.storeKey,v=c.unzipValue??v,M=c.zipValue??M,Q=c.unchangable??Q,P=c.securifyKeyLevel??D.securifyKeyLevel??P,R=c.securifyValueLevel??D.securifyValueLevel??R,x=c.exp??x;else return w;const k=P?E(p,P):p,f=`${R?J:_}${k}`;if(P){const r=`${_}${p}`;r in i&&(i[f]=i[r],delete i[r])}else{const r=`${_}${E(p,P)}`;r in i&&(i[f]=i[r],delete i[r])}const K=x===null||!(x(w,f in i)instanceof Date)?r=>E([M(r)],0):r=>(b??(b={}),b.exp=x(w,f in i).getTime(),b.exp-Date.now()<24*60*60*1e3&&(clearTimeout(se),clearTimeout(te[f]),se=setTimeout(()=>this.reset(),b.exp-Date.now())),b.exp=Math.trunc(b.exp/1e3),E([M(r),b],0));if(R){const r=`${_}${k}`,a=M,j=v;if(M=L=>{try{return E([a(L)],R)}catch{return delete i[f],""}},r in i){const L=`${_}${E(p,P)}`;try{i[L]=K(v(W(i[r],0)[0])),delete i[r]}catch{}}v=L=>{try{return j(W(L,R)[0])}catch{return delete i[f],""}}}else delete i[`${J}${k}`];const ce=r=>{const a=W(r,0);return b=a[1],v(a[0])};let ie=!0;if(N[f]=w,i[`atom/${p}`]&&(i[f]||(i[f]=`[${i[`atom/${p}`]}]`),delete i[`atom/${p}`]),A=()=>{if(A=h,ie){ie=!1;try{l(f in i?ce(i[f]):t)}catch{console.warn("Invalid json value",i[f])}}return h()},m=r=>{if(r===t){this.reset();return}i[f]=K(r)},this.reset=()=>{delete i[f],y(t,!0)},$&&I[f]!==void 0&&console.warn("Duplicate Atom key",p),z)if(Q){let r=!1,a;U[f]=this,I[f]=()=>{clearTimeout(a),a=setTimeout(()=>r=!1,10),!r&&(r=!0,i[f]=K(h()))}}else I[f]=r=>{if(r.newValue===null){this.reset();return}try{y(ce(r.newValue))}catch{console.warn("Invalid json value",r.newValue)}};return w}}let H;try{H=new BroadcastChannel("updateHere"),H.addEventListener("message",e=>{var t;(t=U[e.data.key])==null||t.set(e.data.value,!0)})}catch{}const i=localStorage,I={},U={},pe=(e,t)=>{throw`${t} is readonly property`};window.addEventListener("storage",e=>{var t;e.key===null||e.newValue===e.oldValue||(t=I[e.key])==null||t.call(I,e)});const we=i.setItem.bind(i),Se=i.removeItem.bind(i);i.setItem=(e,t)=>{U[e]===void 0&&we.call(i,e,t)},i.removeItem=e=>{U[e]===void 0&&Se.call(i,e)};const be=/"exp":\s*(\d+)/,_="atom\\",J="atom`s\\",N={},te={},re=/[a-z]/gi,F=5,B={};for(let e=54;e<80;e++){if(e===68||e===72||e===55)continue;const t=String.fromCharCode(e+43).toUpperCase(),c=String.fromCharCode(e+43).toLowerCase();B[t]=c,B[c]=t}const ne=e=>B[e]??e,E=(()=>{const e=[t=>JSON.stringify(t),t=>btoa(encodeURI(e[0](t))),t=>{const c=e[1](t);return`${c.slice(0,F)}${c.slice(F).replace(re,ne)}`},t=>btoa(e[2](t))];return(t,c)=>{try{return e[c](t)}catch(l){if(c===0)throw l;return e[0](t)}}})(),W=(()=>{const e=[t=>JSON.parse(t),t=>e[0](decodeURI(atob(t))),t=>e[1](`${t.slice(0,F)}${t.slice(F).replace(re,ne)}`),t=>e[2](atob(t))];return(t,c)=>{try{return e[c](t)}catch(l){if(c===0)throw l;return e[0](t)}}})();setTimeout(()=>{Object.keys(i).forEach(e=>{var l;if(typeof i[e]!="string"||!e.startsWith(_)&&!e.startsWith(J))return;const t=+((l=i[e].match(be))==null?void 0:l[1]);if(!t||t*1e3-Date.now()>24*60*60*1e3)return;const c=W(i[e],0);!Array.isArray(c)||c[1]==null||!("exp"in c[1])||c[1].exp!==t||(te[e]=setTimeout(()=>{N[e]?N[e].reset():delete i[e]},t*1e3-Date.now()))})},1e3),g.Atom=ee,g.atom=ye,g.configureAtomaric=ue,g.configuredOptions=D,g.useAtom=de,g.useAtomDo=ae,g.useAtomGet=fe,g.useAtomSet=Y,g.useAtomSetDeferred=le,g.useAtomValue=X,Object.defineProperty(g,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.64",
4
+ "version": "0.0.65",
5
5
  "type": "module",
6
6
  "main": "./build/atomaric.umd.cjs",
7
7
  "module": "./build/atomaric.js",
package/types/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { useSyncExternalStore } from 'react';
2
- import { AtomSecureLevel } from '../src/enums';
3
2
  import { Path, PathValue, PathValueDonor } from './paths';
4
3
 
4
+ export type AtomSecureLevel = 0 | 1 | 2 | 3;
5
+
5
6
  export interface Register {}
6
7
 
7
8
  export type ObjectActionsSetDeepPartial = Register extends {