@biglogic/rgs 3.9.6 → 3.9.8
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/core/ssr.d.ts +73 -0
- package/core/thunk.d.ts +75 -0
- package/docs/README.md +479 -0
- package/docs/SUMMARY.md +55 -0
- package/docs/_config.yml +1 -0
- package/docs/markdown/api.md +381 -0
- package/docs/markdown/case-studies.md +69 -0
- package/docs/markdown/faq.md +53 -0
- package/docs/markdown/getting-started.md +68 -0
- package/docs/markdown/local-first-sync.md +146 -0
- package/docs/markdown/migration-guide.md +284 -0
- package/docs/markdown/persistence-and-safety.md +125 -0
- package/docs/markdown/philosophy.md +54 -0
- package/docs/markdown/plugin-sdk.md +161 -0
- package/docs/markdown/plugins-and-extensibility.md +82 -0
- package/docs/markdown/security-architecture.md +50 -0
- package/docs/markdown/the-magnetar-way.md +69 -0
- package/index.cjs +1004 -276
- package/index.d.ts +4 -0
- package/index.js +1206 -485
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo as e, useSyncExternalStore as t, useCallback as n, useDebugValue as r, useState as s, useEffect as o } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var a, i, c, l, u = Object.defineProperty, d = Object.getOwnPropertyNames, f = (e => "undefined" != typeof require ? require : "undefined" != typeof Proxy ? new Proxy(e, {
|
|
4
|
+
get: (e, t) => ("undefined" != typeof require ? require : e)[t]
|
|
5
|
+
}) : e)(function(e) {
|
|
6
|
+
if ("undefined" != typeof require) return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + e + '" is not supported');
|
|
8
|
+
}), y = (e, t) => function() {
|
|
9
|
+
return e && (t = (0, e[d(e)[0]])(e = 0)), t;
|
|
10
|
+
}, p = y({
|
|
8
11
|
"core/utils.ts"() {
|
|
9
|
-
|
|
12
|
+
a = e => {
|
|
10
13
|
if (null === e || "object" != typeof e) return e;
|
|
11
14
|
if ("function" == typeof structuredClone) try {
|
|
12
15
|
return structuredClone(e);
|
|
@@ -18,53 +21,53 @@ var c, l, u, y, d = Object.defineProperty, g = Object.getOwnPropertyNames, f = (
|
|
|
18
21
|
if (e instanceof Date) return new Date(e.getTime());
|
|
19
22
|
if (e instanceof RegExp) return new RegExp(e.source, e.flags);
|
|
20
23
|
if (e instanceof Map) {
|
|
21
|
-
const
|
|
22
|
-
return t.set(e,
|
|
24
|
+
const r = new Map;
|
|
25
|
+
return t.set(e, r), e.forEach((e, t) => r.set(n(t), n(e))), r;
|
|
23
26
|
}
|
|
24
27
|
if (e instanceof Set) {
|
|
25
|
-
const
|
|
26
|
-
return t.set(e,
|
|
28
|
+
const r = new Set;
|
|
29
|
+
return t.set(e, r), e.forEach(e => r.add(n(e))), r;
|
|
27
30
|
}
|
|
28
|
-
const
|
|
29
|
-
t.set(e,
|
|
30
|
-
const
|
|
31
|
-
for (const t of
|
|
32
|
-
return
|
|
31
|
+
const r = Array.isArray(e) ? [] : Object.create(Object.getPrototypeOf(e));
|
|
32
|
+
t.set(e, r);
|
|
33
|
+
const s = [ ...Object.keys(e), ...Object.getOwnPropertySymbols(e) ];
|
|
34
|
+
for (const t of s) r[t] = n(e[t]);
|
|
35
|
+
return r;
|
|
33
36
|
};
|
|
34
37
|
return n(e);
|
|
35
|
-
},
|
|
38
|
+
}, i = (e, t) => {
|
|
36
39
|
if (e === t) return !0;
|
|
37
40
|
if (null === e || null === t) return e === t;
|
|
38
41
|
if ("object" != typeof e || "object" != typeof t) return e === t;
|
|
39
42
|
if (Array.isArray(e) && Array.isArray(t)) {
|
|
40
43
|
if (e.length !== t.length) return !1;
|
|
41
|
-
for (let n = 0; n < e.length; n++) if (!
|
|
44
|
+
for (let n = 0; n < e.length; n++) if (!i(e[n], t[n])) return !1;
|
|
42
45
|
return !0;
|
|
43
46
|
}
|
|
44
|
-
const n = Object.keys(e),
|
|
45
|
-
if (n.length !==
|
|
46
|
-
for (let
|
|
47
|
-
const
|
|
48
|
-
if (!(
|
|
47
|
+
const n = Object.keys(e), r = Object.keys(t);
|
|
48
|
+
if (n.length !== r.length) return !1;
|
|
49
|
+
for (let r = 0; r < n.length; r++) {
|
|
50
|
+
const s = n[r];
|
|
51
|
+
if (!(s in t) || !i(e[s], t[s])) return !1;
|
|
49
52
|
}
|
|
50
53
|
return !0;
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
|
-
}),
|
|
56
|
+
}), h = {};
|
|
54
57
|
|
|
55
58
|
((e, t) => {
|
|
56
|
-
for (var n in t)
|
|
59
|
+
for (var n in t) u(e, n, {
|
|
57
60
|
get: t[n],
|
|
58
61
|
enumerable: !0
|
|
59
62
|
});
|
|
60
|
-
})(
|
|
61
|
-
SyncEngine: () =>
|
|
62
|
-
createSyncEngine: () =>
|
|
63
|
+
})(h, {
|
|
64
|
+
SyncEngine: () => c,
|
|
65
|
+
createSyncEngine: () => l
|
|
63
66
|
});
|
|
64
67
|
|
|
65
|
-
var
|
|
68
|
+
var g = y({
|
|
66
69
|
"core/sync.ts"() {
|
|
67
|
-
|
|
70
|
+
p(), c = class {
|
|
68
71
|
store;
|
|
69
72
|
config;
|
|
70
73
|
pendingQueue=new Map;
|
|
@@ -121,7 +124,7 @@ var m = f({
|
|
|
121
124
|
const n = this.store._getVersion(e) || 1;
|
|
122
125
|
this.pendingQueue.set(e, {
|
|
123
126
|
key: e,
|
|
124
|
-
value:
|
|
127
|
+
value: a(t),
|
|
125
128
|
timestamp: Date.now(),
|
|
126
129
|
version: n
|
|
127
130
|
}), this._notifyStateChange(), this.syncTimer && clearTimeout(this.syncTimer), this.syncTimer = setTimeout(() => {
|
|
@@ -138,10 +141,10 @@ var m = f({
|
|
|
138
141
|
duration: 0
|
|
139
142
|
};
|
|
140
143
|
this._isSyncing = !0, this._notifyStateChange();
|
|
141
|
-
const e = Date.now(), t = [], n = [],
|
|
144
|
+
const e = Date.now(), t = [], n = [], r = [];
|
|
142
145
|
try {
|
|
143
|
-
const
|
|
144
|
-
if (0 ===
|
|
146
|
+
const s = Array.from(this.pendingQueue.values());
|
|
147
|
+
if (0 === s.length) return this._isSyncing = !1, this._notifyStateChange(), {
|
|
145
148
|
success: !0,
|
|
146
149
|
syncedKeys: [],
|
|
147
150
|
conflicts: [],
|
|
@@ -149,42 +152,42 @@ var m = f({
|
|
|
149
152
|
timestamp: Date.now(),
|
|
150
153
|
duration: Date.now() - e
|
|
151
154
|
};
|
|
152
|
-
await this._fetchRemoteVersions(
|
|
153
|
-
for (const e of
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
155
|
+
await this._fetchRemoteVersions(s.map(e => e.key));
|
|
156
|
+
for (const e of s) try {
|
|
157
|
+
const r = this.remoteVersions.get(e.key);
|
|
158
|
+
if (r) if (r.version >= e.version) {
|
|
159
|
+
const s = {
|
|
157
160
|
key: e.key,
|
|
158
161
|
localValue: e.value,
|
|
159
|
-
remoteValue:
|
|
162
|
+
remoteValue: r.value,
|
|
160
163
|
localVersion: e.version,
|
|
161
|
-
remoteVersion:
|
|
164
|
+
remoteVersion: r.version,
|
|
162
165
|
timestamp: e.timestamp
|
|
163
166
|
};
|
|
164
|
-
n.push(
|
|
165
|
-
const o = this.config.onConflict(
|
|
166
|
-
await this._resolveConflict(e,
|
|
167
|
+
n.push(s);
|
|
168
|
+
const o = this.config.onConflict(s);
|
|
169
|
+
await this._resolveConflict(e, r, o), t.push(e.key), this.pendingQueue.delete(e.key);
|
|
167
170
|
} else await this._pushChange(e), t.push(e.key), this.pendingQueue.delete(e.key); else await this._pushChange(e),
|
|
168
171
|
t.push(e.key), this.pendingQueue.delete(e.key);
|
|
169
172
|
} catch (t) {
|
|
170
|
-
|
|
173
|
+
r.push(`Failed to sync "${e.key}": ${t}`);
|
|
171
174
|
}
|
|
172
175
|
const o = {
|
|
173
|
-
success: 0 ===
|
|
176
|
+
success: 0 === r.length,
|
|
174
177
|
syncedKeys: t,
|
|
175
178
|
conflicts: n,
|
|
176
|
-
errors:
|
|
179
|
+
errors: r,
|
|
177
180
|
timestamp: Date.now(),
|
|
178
181
|
duration: Date.now() - e
|
|
179
182
|
};
|
|
180
183
|
return this.config.onSync(o), o;
|
|
181
|
-
} catch (
|
|
182
|
-
const o = `Sync failed: ${
|
|
183
|
-
return
|
|
184
|
+
} catch (s) {
|
|
185
|
+
const o = `Sync failed: ${s}`;
|
|
186
|
+
return r.push(o), {
|
|
184
187
|
success: !1,
|
|
185
188
|
syncedKeys: t,
|
|
186
189
|
conflicts: n,
|
|
187
|
-
errors:
|
|
190
|
+
errors: r,
|
|
188
191
|
timestamp: Date.now(),
|
|
189
192
|
duration: Date.now() - e
|
|
190
193
|
};
|
|
@@ -215,7 +218,7 @@ var m = f({
|
|
|
215
218
|
async _pushChange(e) {
|
|
216
219
|
let t = 0;
|
|
217
220
|
for (;t < this.config.maxRetries; ) try {
|
|
218
|
-
const n = this._getAuthToken(),
|
|
221
|
+
const n = this._getAuthToken(), r = await this.config.fetch(`${this.config.endpoint}/sync`, {
|
|
219
222
|
method: "POST",
|
|
220
223
|
headers: {
|
|
221
224
|
"Content-Type": "application/json",
|
|
@@ -230,8 +233,8 @@ var m = f({
|
|
|
230
233
|
timestamp: e.timestamp
|
|
231
234
|
})
|
|
232
235
|
});
|
|
233
|
-
if (
|
|
234
|
-
const t = await
|
|
236
|
+
if (r.ok) {
|
|
237
|
+
const t = await r.json();
|
|
235
238
|
return void (t.version && this.remoteVersions.set(e.key, {
|
|
236
239
|
version: t.version,
|
|
237
240
|
timestamp: t.timestamp || Date.now(),
|
|
@@ -288,9 +291,479 @@ var m = f({
|
|
|
288
291
|
this.syncTimer && clearTimeout(this.syncTimer), this.pendingQueue.clear(), this.onlineStatusListeners.clear(),
|
|
289
292
|
this.syncStateListeners.clear();
|
|
290
293
|
}
|
|
291
|
-
},
|
|
294
|
+
}, l = (e, t) => new c(e, t);
|
|
295
|
+
}
|
|
296
|
+
}), m = Symbol.for("immer-nothing"), _ = Symbol.for("immer-draftable"), S = Symbol.for("immer-state"), w = [ function(e) {
|
|
297
|
+
return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`;
|
|
298
|
+
}, function(e) {
|
|
299
|
+
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}'`;
|
|
300
|
+
}, "This object has been frozen and should not be mutated", function(e) {
|
|
301
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e;
|
|
302
|
+
}, "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) {
|
|
303
|
+
return `'current' expects a draft, got: ${e}`;
|
|
304
|
+
}, "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) {
|
|
305
|
+
return `'original' expects a draft, got: ${e}`;
|
|
306
|
+
} ];
|
|
307
|
+
|
|
308
|
+
function b(e, ...t) {
|
|
309
|
+
{
|
|
310
|
+
const n = w[e], r = J(n) ? n.apply(null, t) : n;
|
|
311
|
+
throw new Error(`[Immer] ${r}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
var v = Object, E = v.getPrototypeOf, k = "constructor", O = "prototype", C = "configurable", D = "enumerable", M = "writable", A = "value", j = e => !!e && !!e[S];
|
|
316
|
+
|
|
317
|
+
function R(e) {
|
|
318
|
+
return !!e && (I(e) || U(e) || !!e[_] || !!e[k]?.[_] || L(e) || F(e));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
var P = v[O][k].toString(), T = new WeakMap;
|
|
322
|
+
|
|
323
|
+
function I(e) {
|
|
324
|
+
if (!e || !K(e)) return !1;
|
|
325
|
+
const t = E(e);
|
|
326
|
+
if (null === t || t === v[O]) return !0;
|
|
327
|
+
const n = v.hasOwnProperty.call(t, k) && t[k];
|
|
328
|
+
if (n === Object) return !0;
|
|
329
|
+
if (!J(n)) return !1;
|
|
330
|
+
let r = T.get(n);
|
|
331
|
+
return void 0 === r && (r = Function.toString.call(n), T.set(n, r)), r === P;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function z(e, t, n = !0) {
|
|
335
|
+
if (0 === x(e)) {
|
|
336
|
+
(n ? Reflect.ownKeys(e) : v.keys(e)).forEach(n => {
|
|
337
|
+
t(n, e[n], e);
|
|
338
|
+
});
|
|
339
|
+
} else e.forEach((n, r) => t(r, n, e));
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function x(e) {
|
|
343
|
+
const t = e[S];
|
|
344
|
+
return t ? t.type_ : U(e) ? 1 : L(e) ? 2 : F(e) ? 3 : 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var $ = (e, t, n = x(e)) => 2 === n ? e.has(t) : v[O].hasOwnProperty.call(e, t), V = (e, t, n = x(e)) => 2 === n ? e.get(t) : e[t], N = (e, t, n, r = x(e)) => {
|
|
348
|
+
2 === r ? e.set(t, n) : 3 === r ? e.add(n) : e[t] = n;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
var U = Array.isArray, L = e => e instanceof Map, F = e => e instanceof Set, K = e => "object" == typeof e, J = e => "function" == typeof e, B = e => "boolean" == typeof e;
|
|
352
|
+
|
|
353
|
+
var W = e => e.copy_ || e.base_, Q = e => e.modified_ ? e.copy_ : e.base_;
|
|
354
|
+
|
|
355
|
+
function q(e, t) {
|
|
356
|
+
if (L(e)) return new Map(e);
|
|
357
|
+
if (F(e)) return new Set(e);
|
|
358
|
+
if (U(e)) return Array[O].slice.call(e);
|
|
359
|
+
const n = I(e);
|
|
360
|
+
if (!0 === t || "class_only" === t && !n) {
|
|
361
|
+
const t = v.getOwnPropertyDescriptors(e);
|
|
362
|
+
delete t[S];
|
|
363
|
+
let n = Reflect.ownKeys(t);
|
|
364
|
+
for (let r = 0; r < n.length; r++) {
|
|
365
|
+
const s = n[r], o = t[s];
|
|
366
|
+
!1 === o[M] && (o[M] = !0, o[C] = !0), (o.get || o.set) && (t[s] = {
|
|
367
|
+
[C]: !0,
|
|
368
|
+
[M]: !0,
|
|
369
|
+
[D]: o[D],
|
|
370
|
+
[A]: e[s]
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return v.create(E(e), t);
|
|
374
|
+
}
|
|
375
|
+
{
|
|
376
|
+
const t = E(e);
|
|
377
|
+
if (null !== t && n) return {
|
|
378
|
+
...e
|
|
379
|
+
};
|
|
380
|
+
const r = v.create(t);
|
|
381
|
+
return v.assign(r, e);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function H(e, t = !1) {
|
|
386
|
+
return X(e) || j(e) || !R(e) || (x(e) > 1 && v.defineProperties(e, {
|
|
387
|
+
set: G,
|
|
388
|
+
add: G,
|
|
389
|
+
clear: G,
|
|
390
|
+
delete: G
|
|
391
|
+
}), v.freeze(e), t && z(e, (e, t) => {
|
|
392
|
+
H(t, !0);
|
|
393
|
+
}, !1)), e;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
var G = {
|
|
397
|
+
[A]: function() {
|
|
398
|
+
b(2);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
function X(e) {
|
|
403
|
+
return null === e || !K(e) || v.isFrozen(e);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
var Z = "MapSet", Y = "Patches", ee = "ArrayMethods", te = {};
|
|
407
|
+
|
|
408
|
+
function ne(e) {
|
|
409
|
+
const t = te[e];
|
|
410
|
+
return t || b(0, e), t;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var re, se = e => !!te[e], oe = () => re;
|
|
414
|
+
|
|
415
|
+
function ae(e, t) {
|
|
416
|
+
t && (e.patchPlugin_ = ne(Y), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function ie(e) {
|
|
420
|
+
ce(e), e.drafts_.forEach(ue), e.drafts_ = null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function ce(e) {
|
|
424
|
+
e === re && (re = e.parent_);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
var le = e => re = {
|
|
428
|
+
drafts_: [],
|
|
429
|
+
parent_: re,
|
|
430
|
+
immer_: e,
|
|
431
|
+
canAutoFreeze_: !0,
|
|
432
|
+
unfinalizedDrafts_: 0,
|
|
433
|
+
handledSet_: new Set,
|
|
434
|
+
processedForPatches_: new Set,
|
|
435
|
+
mapSetPlugin_: se(Z) ? ne(Z) : void 0,
|
|
436
|
+
arrayMethodsPlugin_: se(ee) ? ne(ee) : void 0
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
function ue(e) {
|
|
440
|
+
const t = e[S];
|
|
441
|
+
0 === t.type_ || 1 === t.type_ ? t.revoke_() : t.revoked_ = !0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function de(e, t) {
|
|
445
|
+
t.unfinalizedDrafts_ = t.drafts_.length;
|
|
446
|
+
const n = t.drafts_[0];
|
|
447
|
+
if (void 0 !== e && e !== n) {
|
|
448
|
+
n[S].modified_ && (ie(t), b(4)), R(e) && (e = fe(t, e));
|
|
449
|
+
const {patchPlugin_: r} = t;
|
|
450
|
+
r && r.generateReplacementPatches_(n[S].base_, e, t);
|
|
451
|
+
} else e = fe(t, n);
|
|
452
|
+
return function(e, t, n = !1) {
|
|
453
|
+
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && H(t, n);
|
|
454
|
+
}(t, e, !0), ie(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_),
|
|
455
|
+
e !== m ? e : void 0;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function fe(e, t) {
|
|
459
|
+
if (X(t)) return t;
|
|
460
|
+
const n = t[S];
|
|
461
|
+
if (!n) {
|
|
462
|
+
return _e(t, e.handledSet_, e);
|
|
463
|
+
}
|
|
464
|
+
if (!pe(n, e)) return t;
|
|
465
|
+
if (!n.modified_) return n.base_;
|
|
466
|
+
if (!n.finalized_) {
|
|
467
|
+
const {callbacks_: t} = n;
|
|
468
|
+
if (t) for (;t.length > 0; ) {
|
|
469
|
+
t.pop()(e);
|
|
470
|
+
}
|
|
471
|
+
me(n, e);
|
|
472
|
+
}
|
|
473
|
+
return n.copy_;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function ye(e) {
|
|
477
|
+
e.finalized_ = !0, e.scope_.unfinalizedDrafts_--;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
var pe = (e, t) => e.scope_ === t, he = [];
|
|
481
|
+
|
|
482
|
+
function ge(e, t, n, r) {
|
|
483
|
+
const s = W(e), o = e.type_;
|
|
484
|
+
if (void 0 !== r) {
|
|
485
|
+
if (V(s, r, o) === t) return void N(s, r, n, o);
|
|
486
|
+
}
|
|
487
|
+
if (!e.draftLocations_) {
|
|
488
|
+
const t = e.draftLocations_ = new Map;
|
|
489
|
+
z(s, (e, n) => {
|
|
490
|
+
if (j(n)) {
|
|
491
|
+
const r = t.get(n) || [];
|
|
492
|
+
r.push(e), t.set(n, r);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
const a = e.draftLocations_.get(t) ?? he;
|
|
497
|
+
for (const e of a) N(s, e, n, o);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function me(e, t) {
|
|
501
|
+
if (e.modified_ && !e.finalized_ && (3 === e.type_ || 1 === e.type_ && e.allIndicesReassigned_ || (e.assigned_?.size ?? 0) > 0)) {
|
|
502
|
+
const {patchPlugin_: n} = t;
|
|
503
|
+
if (n) {
|
|
504
|
+
const r = n.getPath(e);
|
|
505
|
+
r && n.generatePatches_(e, r, t);
|
|
506
|
+
}
|
|
507
|
+
ye(e);
|
|
292
508
|
}
|
|
293
|
-
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function _e(e, t, n) {
|
|
512
|
+
return !n.immer_.autoFreeze_ && n.unfinalizedDrafts_ < 1 || j(e) || t.has(e) || !R(e) || X(e) || (t.add(e),
|
|
513
|
+
z(e, (r, s) => {
|
|
514
|
+
if (j(s)) {
|
|
515
|
+
const t = s[S];
|
|
516
|
+
if (pe(t, n)) {
|
|
517
|
+
const n = Q(t);
|
|
518
|
+
N(e, r, n, e.type_), ye(t);
|
|
519
|
+
}
|
|
520
|
+
} else R(s) && _e(s, t, n);
|
|
521
|
+
})), e;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var Se = {
|
|
525
|
+
get(e, t) {
|
|
526
|
+
if (t === S) return e;
|
|
527
|
+
let n = e.scope_.arrayMethodsPlugin_;
|
|
528
|
+
const r = 1 === e.type_ && "string" == typeof t;
|
|
529
|
+
if (r && n?.isArrayOperationMethod(t)) return n.createMethodInterceptor(e, t);
|
|
530
|
+
const s = W(e);
|
|
531
|
+
if (!$(s, t, e.type_)) return function(e, t, n) {
|
|
532
|
+
const r = ve(t, n);
|
|
533
|
+
return r ? A in r ? r[A] : r.get?.call(e.draft_) : void 0;
|
|
534
|
+
}(e, s, t);
|
|
535
|
+
const o = s[t];
|
|
536
|
+
if (e.finalized_ || !R(o)) return o;
|
|
537
|
+
if (r && e.operationMethod && n?.isMutatingArrayMethod(e.operationMethod) && function(e) {
|
|
538
|
+
const t = +e;
|
|
539
|
+
return Number.isInteger(t) && String(t) === e;
|
|
540
|
+
}(t)) return o;
|
|
541
|
+
if (o === be(e.base_, t)) {
|
|
542
|
+
ke(e);
|
|
543
|
+
const n = 1 === e.type_ ? +t : t, r = Oe(e.scope_, o, e, n);
|
|
544
|
+
return e.copy_[n] = r;
|
|
545
|
+
}
|
|
546
|
+
return o;
|
|
547
|
+
},
|
|
548
|
+
has: (e, t) => t in W(e),
|
|
549
|
+
ownKeys: e => Reflect.ownKeys(W(e)),
|
|
550
|
+
set(e, t, n) {
|
|
551
|
+
const r = ve(W(e), t);
|
|
552
|
+
if (r?.set) return r.set.call(e.draft_, n), !0;
|
|
553
|
+
if (!e.modified_) {
|
|
554
|
+
const r = be(W(e), t), a = r?.[S];
|
|
555
|
+
if (a && a.base_ === n) return e.copy_[t] = n, e.assigned_.set(t, !1), !0;
|
|
556
|
+
if (((s = n) === (o = r) ? 0 !== s || 1 / s == 1 / o : s != s && o != o) && (void 0 !== n || $(e.base_, t, e.type_))) return !0;
|
|
557
|
+
ke(e), Ee(e);
|
|
558
|
+
}
|
|
559
|
+
var s, o;
|
|
560
|
+
return e.copy_[t] === n && (void 0 !== n || t in e.copy_) || Number.isNaN(n) && Number.isNaN(e.copy_[t]) || (e.copy_[t] = n,
|
|
561
|
+
e.assigned_.set(t, !0), function(e, t, n) {
|
|
562
|
+
const {scope_: r} = e;
|
|
563
|
+
if (j(n)) {
|
|
564
|
+
const s = n[S];
|
|
565
|
+
pe(s, r) && s.callbacks_.push(function() {
|
|
566
|
+
ke(e);
|
|
567
|
+
const r = Q(s);
|
|
568
|
+
ge(e, n, r, t);
|
|
569
|
+
});
|
|
570
|
+
} else R(n) && e.callbacks_.push(function() {
|
|
571
|
+
const s = W(e);
|
|
572
|
+
3 === e.type_ ? s.has(n) && _e(n, r.handledSet_, r) : V(s, t, e.type_) === n && r.drafts_.length > 1 && !0 === (e.assigned_.get(t) ?? !1) && e.copy_ && _e(V(e.copy_, t, e.type_), r.handledSet_, r);
|
|
573
|
+
});
|
|
574
|
+
}(e, t, n)), !0;
|
|
575
|
+
},
|
|
576
|
+
deleteProperty: (e, t) => (ke(e), void 0 !== be(e.base_, t) || t in e.base_ ? (e.assigned_.set(t, !1),
|
|
577
|
+
Ee(e)) : e.assigned_.delete(t), e.copy_ && delete e.copy_[t], !0),
|
|
578
|
+
getOwnPropertyDescriptor(e, t) {
|
|
579
|
+
const n = W(e), r = Reflect.getOwnPropertyDescriptor(n, t);
|
|
580
|
+
return r ? {
|
|
581
|
+
[M]: !0,
|
|
582
|
+
[C]: 1 !== e.type_ || "length" !== t,
|
|
583
|
+
[D]: r[D],
|
|
584
|
+
[A]: n[t]
|
|
585
|
+
} : r;
|
|
586
|
+
},
|
|
587
|
+
defineProperty() {
|
|
588
|
+
b(11);
|
|
589
|
+
},
|
|
590
|
+
getPrototypeOf: e => E(e.base_),
|
|
591
|
+
setPrototypeOf() {
|
|
592
|
+
b(12);
|
|
593
|
+
}
|
|
594
|
+
}, we = {};
|
|
595
|
+
|
|
596
|
+
for (let e in Se) {
|
|
597
|
+
let t = Se[e];
|
|
598
|
+
we[e] = function() {
|
|
599
|
+
const e = arguments;
|
|
600
|
+
return e[0] = e[0][0], t.apply(this, e);
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function be(e, t) {
|
|
605
|
+
const n = e[S];
|
|
606
|
+
return (n ? W(n) : e)[t];
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function ve(e, t) {
|
|
610
|
+
if (!(t in e)) return;
|
|
611
|
+
let n = E(e);
|
|
612
|
+
for (;n; ) {
|
|
613
|
+
const e = Object.getOwnPropertyDescriptor(n, t);
|
|
614
|
+
if (e) return e;
|
|
615
|
+
n = E(n);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function Ee(e) {
|
|
620
|
+
e.modified_ || (e.modified_ = !0, e.parent_ && Ee(e.parent_));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function ke(e) {
|
|
624
|
+
e.copy_ || (e.assigned_ = new Map, e.copy_ = q(e.base_, e.scope_.immer_.useStrictShallowCopy_));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
we.deleteProperty = function(e, t) {
|
|
628
|
+
return isNaN(parseInt(t)) && b(13), we.set.call(this, e, t, void 0);
|
|
629
|
+
}, we.set = function(e, t, n) {
|
|
630
|
+
return "length" !== t && isNaN(parseInt(t)) && b(14), Se.set.call(this, e[0], t, n, e[0]);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
function Oe(e, t, n, r) {
|
|
634
|
+
const [s, o] = L(t) ? ne(Z).proxyMap_(t, n) : F(t) ? ne(Z).proxySet_(t, n) : function(e, t) {
|
|
635
|
+
const n = U(e), r = {
|
|
636
|
+
type_: n ? 1 : 0,
|
|
637
|
+
scope_: t ? t.scope_ : oe(),
|
|
638
|
+
modified_: !1,
|
|
639
|
+
finalized_: !1,
|
|
640
|
+
assigned_: void 0,
|
|
641
|
+
parent_: t,
|
|
642
|
+
base_: e,
|
|
643
|
+
draft_: null,
|
|
644
|
+
copy_: null,
|
|
645
|
+
revoke_: null,
|
|
646
|
+
isManual_: !1,
|
|
647
|
+
callbacks_: void 0
|
|
648
|
+
};
|
|
649
|
+
let s = r, o = Se;
|
|
650
|
+
n && (s = [ r ], o = we);
|
|
651
|
+
const {revoke: a, proxy: i} = Proxy.revocable(s, o);
|
|
652
|
+
return r.draft_ = i, r.revoke_ = a, [ i, r ];
|
|
653
|
+
}(t, n);
|
|
654
|
+
return (n?.scope_ ?? oe()).drafts_.push(s), o.callbacks_ = n?.callbacks_ ?? [],
|
|
655
|
+
o.key_ = r, n && void 0 !== r ? function(e, t, n) {
|
|
656
|
+
e.callbacks_.push(function(r) {
|
|
657
|
+
const s = t;
|
|
658
|
+
if (!s || !pe(s, r)) return;
|
|
659
|
+
r.mapSetPlugin_?.fixSetContents(s);
|
|
660
|
+
const o = Q(s);
|
|
661
|
+
ge(e, s.draft_ ?? s, o, n), me(s, r);
|
|
662
|
+
});
|
|
663
|
+
}(n, o, r) : o.callbacks_.push(function(e) {
|
|
664
|
+
e.mapSetPlugin_?.fixSetContents(o);
|
|
665
|
+
const {patchPlugin_: t} = e;
|
|
666
|
+
o.modified_ && t && t.generatePatches_(o, [], e);
|
|
667
|
+
}), s;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function Ce(e) {
|
|
671
|
+
if (!R(e) || X(e)) return e;
|
|
672
|
+
const t = e[S];
|
|
673
|
+
let n, r = !0;
|
|
674
|
+
if (t) {
|
|
675
|
+
if (!t.modified_) return t.base_;
|
|
676
|
+
t.finalized_ = !0, n = q(e, t.scope_.immer_.useStrictShallowCopy_), r = t.scope_.immer_.shouldUseStrictIteration();
|
|
677
|
+
} else n = q(e, !0);
|
|
678
|
+
return z(n, (e, t) => {
|
|
679
|
+
N(n, e, Ce(t));
|
|
680
|
+
}, r), t && (t.finalized_ = !1), n;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
var De = (new class {
|
|
684
|
+
constructor(e) {
|
|
685
|
+
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1,
|
|
686
|
+
this.produce = (e, t, n) => {
|
|
687
|
+
if (J(e) && !J(t)) {
|
|
688
|
+
const n = t;
|
|
689
|
+
t = e;
|
|
690
|
+
const r = this;
|
|
691
|
+
return function(e = n, ...s) {
|
|
692
|
+
return r.produce(e, e => t.call(this, e, ...s));
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
let r;
|
|
696
|
+
if (J(t) || b(6), void 0 === n || J(n) || b(7), R(e)) {
|
|
697
|
+
const s = le(this), o = Oe(s, e, void 0);
|
|
698
|
+
let a = !0;
|
|
699
|
+
try {
|
|
700
|
+
r = t(o), a = !1;
|
|
701
|
+
} finally {
|
|
702
|
+
a ? ie(s) : ce(s);
|
|
703
|
+
}
|
|
704
|
+
return ae(s, n), de(r, s);
|
|
705
|
+
}
|
|
706
|
+
if (!e || !K(e)) {
|
|
707
|
+
if (r = t(e), void 0 === r && (r = e), r === m && (r = void 0), this.autoFreeze_ && H(r, !0),
|
|
708
|
+
n) {
|
|
709
|
+
const t = [], s = [];
|
|
710
|
+
ne(Y).generateReplacementPatches_(e, r, {
|
|
711
|
+
patches_: t,
|
|
712
|
+
inversePatches_: s
|
|
713
|
+
}), n(t, s);
|
|
714
|
+
}
|
|
715
|
+
return r;
|
|
716
|
+
}
|
|
717
|
+
b(1, e);
|
|
718
|
+
}, this.produceWithPatches = (e, t) => {
|
|
719
|
+
if (J(e)) return (t, ...n) => this.produceWithPatches(t, t => e(t, ...n));
|
|
720
|
+
let n, r;
|
|
721
|
+
return [ this.produce(e, t, (e, t) => {
|
|
722
|
+
n = e, r = t;
|
|
723
|
+
}), n, r ];
|
|
724
|
+
}, B(e?.autoFreeze) && this.setAutoFreeze(e.autoFreeze), B(e?.useStrictShallowCopy) && this.setUseStrictShallowCopy(e.useStrictShallowCopy),
|
|
725
|
+
B(e?.useStrictIteration) && this.setUseStrictIteration(e.useStrictIteration);
|
|
726
|
+
}
|
|
727
|
+
createDraft(e) {
|
|
728
|
+
R(e) || b(8), j(e) && (e = function(e) {
|
|
729
|
+
j(e) || b(10, e);
|
|
730
|
+
return Ce(e);
|
|
731
|
+
}(e));
|
|
732
|
+
const t = le(this), n = Oe(t, e, void 0);
|
|
733
|
+
return n[S].isManual_ = !0, ce(t), n;
|
|
734
|
+
}
|
|
735
|
+
finishDraft(e, t) {
|
|
736
|
+
const n = e && e[S];
|
|
737
|
+
n && n.isManual_ || b(9);
|
|
738
|
+
const {scope_: r} = n;
|
|
739
|
+
return ae(r, t), de(void 0, r);
|
|
740
|
+
}
|
|
741
|
+
setAutoFreeze(e) {
|
|
742
|
+
this.autoFreeze_ = e;
|
|
743
|
+
}
|
|
744
|
+
setUseStrictShallowCopy(e) {
|
|
745
|
+
this.useStrictShallowCopy_ = e;
|
|
746
|
+
}
|
|
747
|
+
setUseStrictIteration(e) {
|
|
748
|
+
this.useStrictIteration_ = e;
|
|
749
|
+
}
|
|
750
|
+
shouldUseStrictIteration() {
|
|
751
|
+
return this.useStrictIteration_;
|
|
752
|
+
}
|
|
753
|
+
applyPatches(e, t) {
|
|
754
|
+
let n;
|
|
755
|
+
for (n = t.length - 1; n >= 0; n--) {
|
|
756
|
+
const r = t[n];
|
|
757
|
+
if (0 === r.path.length && "replace" === r.op) {
|
|
758
|
+
e = r.value;
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
n > -1 && (t = t.slice(n + 1));
|
|
763
|
+
const r = ne(Y).applyPatches_;
|
|
764
|
+
return j(e) ? r(e, t) : this.produce(e, e => r(e, t));
|
|
765
|
+
}
|
|
766
|
+
}).produce, Me = (e, t) => {
|
|
294
767
|
const n = Date.now();
|
|
295
768
|
if (/\(\.*\+\?\)\+/.test(e) || /\(\.*\?\)\*/.test(e)) return !1;
|
|
296
769
|
if (e.length > 500) return !1;
|
|
@@ -301,28 +774,28 @@ var m = f({
|
|
|
301
774
|
} catch {
|
|
302
775
|
return !1;
|
|
303
776
|
}
|
|
304
|
-
},
|
|
777
|
+
}, Ae = () => {
|
|
305
778
|
if ("undefined" != typeof crypto && "function" == typeof crypto.randomUUID) try {
|
|
306
779
|
return crypto.randomUUID();
|
|
307
780
|
} catch {}
|
|
308
781
|
throw new Error("Cryptographically secure random UUID generation is required but crypto.randomUUID is unavailable. Please use a browser or environment with Web Crypto API support.");
|
|
309
|
-
},
|
|
310
|
-
if (!
|
|
311
|
-
const
|
|
782
|
+
}, je = "undefined" != typeof crypto && void 0 !== crypto.subtle && "function" == typeof crypto.subtle.generateKey, Re = async (e, t, n = 6e5) => {
|
|
783
|
+
if (!je) throw new Error("Web Crypto API not available");
|
|
784
|
+
const r = await crypto.subtle.importKey("raw", (new TextEncoder).encode(e), "PBKDF2", !1, [ "deriveKey" ]);
|
|
312
785
|
return {
|
|
313
786
|
key: await crypto.subtle.deriveKey({
|
|
314
787
|
name: "PBKDF2",
|
|
315
788
|
salt: new Uint8Array(t),
|
|
316
789
|
iterations: n,
|
|
317
790
|
hash: "SHA-256"
|
|
318
|
-
},
|
|
791
|
+
}, r, {
|
|
319
792
|
name: "AES-GCM",
|
|
320
793
|
length: 256
|
|
321
794
|
}, !0, [ "encrypt", "decrypt" ]),
|
|
322
795
|
iv: crypto.getRandomValues(new Uint8Array(12))
|
|
323
796
|
};
|
|
324
|
-
},
|
|
325
|
-
if (!
|
|
797
|
+
}, Pe = (e = 32) => crypto.getRandomValues(new Uint8Array(e)), Te = async () => {
|
|
798
|
+
if (!je) throw new Error("Web Crypto API not available");
|
|
326
799
|
return {
|
|
327
800
|
key: await crypto.subtle.generateKey({
|
|
328
801
|
name: "AES-GCM",
|
|
@@ -330,47 +803,47 @@ var m = f({
|
|
|
330
803
|
}, !0, [ "encrypt", "decrypt" ]),
|
|
331
804
|
iv: crypto.getRandomValues(new Uint8Array(12))
|
|
332
805
|
};
|
|
333
|
-
},
|
|
806
|
+
}, Ie = async e => {
|
|
334
807
|
const t = await crypto.subtle.exportKey("raw", e.key);
|
|
335
808
|
return {
|
|
336
809
|
key: btoa(String.fromCharCode(...new Uint8Array(t))),
|
|
337
810
|
iv: btoa(String.fromCharCode(...e.iv))
|
|
338
811
|
};
|
|
339
|
-
},
|
|
340
|
-
const n = Uint8Array.from(atob(e), e => e.charCodeAt(0)),
|
|
812
|
+
}, ze = async (e, t) => {
|
|
813
|
+
const n = Uint8Array.from(atob(e), e => e.charCodeAt(0)), r = Uint8Array.from(atob(t), e => e.charCodeAt(0));
|
|
341
814
|
return {
|
|
342
815
|
key: await crypto.subtle.importKey("raw", n, {
|
|
343
816
|
name: "AES-GCM",
|
|
344
817
|
length: 256
|
|
345
818
|
}, !0, [ "encrypt", "decrypt" ]),
|
|
346
|
-
iv:
|
|
819
|
+
iv: r
|
|
347
820
|
};
|
|
348
|
-
},
|
|
349
|
-
const n = (new TextEncoder).encode(JSON.stringify(e)),
|
|
821
|
+
}, xe = async (e, t) => {
|
|
822
|
+
const n = (new TextEncoder).encode(JSON.stringify(e)), r = await crypto.subtle.encrypt({
|
|
350
823
|
name: "AES-GCM",
|
|
351
824
|
iv: t.iv
|
|
352
|
-
}, t.key, n),
|
|
353
|
-
return
|
|
354
|
-
},
|
|
355
|
-
const n = Uint8Array.from(atob(e), e => e.charCodeAt(0)),
|
|
825
|
+
}, t.key, n), s = new Uint8Array(t.iv.length + r.byteLength);
|
|
826
|
+
return s.set(t.iv), s.set(new Uint8Array(r), t.iv.length), btoa(String.fromCharCode(...s));
|
|
827
|
+
}, $e = async (e, t) => {
|
|
828
|
+
const n = Uint8Array.from(atob(e), e => e.charCodeAt(0)), r = n.slice(0, 12), s = n.slice(12), o = await crypto.subtle.decrypt({
|
|
356
829
|
name: "AES-GCM",
|
|
357
|
-
iv:
|
|
358
|
-
}, t.key,
|
|
830
|
+
iv: r
|
|
831
|
+
}, t.key, s);
|
|
359
832
|
return JSON.parse((new TextDecoder).decode(o));
|
|
360
|
-
},
|
|
361
|
-
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
},
|
|
833
|
+
}, Ve = null, Ne = e => {
|
|
834
|
+
Ve = e;
|
|
835
|
+
}, Ue = e => {
|
|
836
|
+
Ve && Ve(e);
|
|
837
|
+
}, Le = (e, t, n) => {
|
|
365
838
|
e.set(t instanceof RegExp ? t.source : t, n);
|
|
366
|
-
},
|
|
839
|
+
}, Fe = (e, t, n, r) => {
|
|
367
840
|
if (0 === e.size) return !0;
|
|
368
|
-
for (const [
|
|
841
|
+
for (const [s, o] of e) {
|
|
369
842
|
let e;
|
|
370
|
-
if (e = "function" == typeof
|
|
843
|
+
if (e = "function" == typeof s ? s(t, r) : Me(s, t), e) return o.includes(n) || o.includes("admin");
|
|
371
844
|
}
|
|
372
845
|
return !1;
|
|
373
|
-
},
|
|
846
|
+
}, Ke = e => {
|
|
374
847
|
if ("string" == typeof e) {
|
|
375
848
|
let t = e.replace(/&#[xX]?[0-9a-fA-F]+;?/g, e => {
|
|
376
849
|
const t = e.match(/&#x([0-9a-fA-F]+);?/i);
|
|
@@ -386,35 +859,35 @@ var m = f({
|
|
|
386
859
|
if (e && "object" == typeof e && !Array.isArray(e)) {
|
|
387
860
|
if (Object.getPrototypeOf(e) === Object.prototype) {
|
|
388
861
|
const t = {};
|
|
389
|
-
for (const [n,
|
|
862
|
+
for (const [n, r] of Object.entries(e)) t[n] = Ke(r);
|
|
390
863
|
return t;
|
|
391
864
|
}
|
|
392
865
|
return e;
|
|
393
866
|
}
|
|
394
|
-
return Array.isArray(e) ? e.map(e =>
|
|
395
|
-
},
|
|
396
|
-
const
|
|
397
|
-
id:
|
|
867
|
+
return Array.isArray(e) ? e.map(e => Ke(e)) : e;
|
|
868
|
+
}, Je = e => /^([a-zA-Z0-9_.-][a-zA-Z0-9_.-]*)$/.test(e) && e.length <= 256 && e.length > 0, Be = (e, t, n, r) => {
|
|
869
|
+
const s = {
|
|
870
|
+
id: Ae(),
|
|
398
871
|
purpose: n,
|
|
399
|
-
granted:
|
|
872
|
+
granted: r,
|
|
400
873
|
timestamp: Date.now()
|
|
401
874
|
}, o = e.get(t) || [];
|
|
402
|
-
return o.push(
|
|
875
|
+
return o.push(s), e.set(t, o), Ue({
|
|
403
876
|
timestamp: Date.now(),
|
|
404
877
|
action: "set",
|
|
405
878
|
key: `consent:${n}`,
|
|
406
879
|
userId: t,
|
|
407
880
|
success: !0
|
|
408
|
-
}),
|
|
881
|
+
}), s;
|
|
409
882
|
};
|
|
410
883
|
|
|
411
|
-
|
|
884
|
+
p();
|
|
412
885
|
|
|
413
|
-
var
|
|
886
|
+
var We = e => `${e}_`;
|
|
414
887
|
|
|
415
|
-
|
|
888
|
+
p();
|
|
416
889
|
|
|
417
|
-
var
|
|
890
|
+
var Qe = () => {
|
|
418
891
|
try {
|
|
419
892
|
0;
|
|
420
893
|
const e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : {};
|
|
@@ -422,31 +895,42 @@ var x = () => {
|
|
|
422
895
|
} catch {
|
|
423
896
|
return !1;
|
|
424
897
|
}
|
|
425
|
-
},
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
898
|
+
}, qe = () => "undefined" != typeof window ? window.localStorage : null, He = () => {
|
|
899
|
+
const e = new Map;
|
|
900
|
+
return {
|
|
901
|
+
getItem: t => e.get(t) || null,
|
|
902
|
+
setItem: (t, n) => e.set(t, n),
|
|
903
|
+
removeItem: t => e.delete(t),
|
|
904
|
+
key: t => Array.from(e.keys())[t] || null,
|
|
905
|
+
get length() {
|
|
906
|
+
return e.size;
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
}, Ge = e => {
|
|
910
|
+
const t = new Map, n = new Map, r = new Map, s = new Set, o = new Map, c = new Set, l = new Map, u = new Map, d = new Map, f = new Map, y = new Map, p = new Map, m = new Map, _ = new Map, S = e?.namespace || "gstate", w = e?.silent ?? !1, b = e?.debounceTime ?? 150, v = e?.version ?? 0, E = e?.storage || qe(), k = e?.onError, O = e?.maxObjectSize ?? 0, C = e?.maxTotalSize ?? 0, D = e?.encryptionKey ?? null, M = e?.validateInput ?? !0, A = e?.auditEnabled ?? !0, j = e?.userId, R = e?.immer ?? !0, P = e?.persistByDefault ?? e?.persistence ?? e?.persist ?? !1;
|
|
911
|
+
e?.accessRules && e.accessRules.forEach(e => Le(m, e.pattern, e.permissions));
|
|
912
|
+
let T, I = !1, z = !1, x = !1, $ = 0, V = null, N = null;
|
|
913
|
+
const U = new Promise(e => {
|
|
914
|
+
T = e;
|
|
915
|
+
}), L = () => `${S}_`, F = () => ({
|
|
916
|
+
store: t,
|
|
917
|
+
versions: n,
|
|
918
|
+
sizes: r,
|
|
919
|
+
totalSize: $,
|
|
920
|
+
storage: E,
|
|
921
|
+
config: e || {},
|
|
922
|
+
diskQueue: y,
|
|
923
|
+
encryptionKey: D,
|
|
924
|
+
audit: W,
|
|
925
|
+
onError: k,
|
|
926
|
+
silent: w,
|
|
927
|
+
debounceTime: b,
|
|
928
|
+
currentVersion: v
|
|
929
|
+
}), K = () => ({
|
|
446
930
|
plugins: f,
|
|
447
|
-
onError:
|
|
448
|
-
silent:
|
|
449
|
-
}),
|
|
931
|
+
onError: k,
|
|
932
|
+
silent: w
|
|
933
|
+
}), J = e => {
|
|
450
934
|
if (null == e) return 0;
|
|
451
935
|
const t = typeof e;
|
|
452
936
|
if ("boolean" === t) return 4;
|
|
@@ -454,108 +938,108 @@ var x = () => {
|
|
|
454
938
|
if ("string" === t) return 2 * e.length;
|
|
455
939
|
if ("object" !== t) return 0;
|
|
456
940
|
let n = 0;
|
|
457
|
-
const
|
|
458
|
-
for (;
|
|
459
|
-
const e =
|
|
941
|
+
const r = [ e ], s = new WeakSet;
|
|
942
|
+
for (;r.length > 0; ) {
|
|
943
|
+
const e = r.pop();
|
|
460
944
|
if ("boolean" == typeof e) n += 4; else if ("number" == typeof e) n += 8; else if ("string" == typeof e) n += 2 * e.length; else if ("object" == typeof e && null !== e) {
|
|
461
945
|
const t = e;
|
|
462
|
-
if (
|
|
463
|
-
if (
|
|
464
|
-
|
|
946
|
+
if (s.has(t)) continue;
|
|
947
|
+
if (s.add(t), Array.isArray(t)) for (let e = 0; e < t.length; e++) r.push(t[e]); else for (const e of Object.keys(t)) n += 2 * e.length,
|
|
948
|
+
r.push(t[e]);
|
|
465
949
|
}
|
|
466
950
|
}
|
|
467
951
|
return n;
|
|
468
|
-
},
|
|
952
|
+
}, B = (e, t) => {
|
|
469
953
|
((e, t, n) => {
|
|
470
|
-
if (0 !== e.plugins.size) for (const
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
} catch (
|
|
475
|
-
const o =
|
|
954
|
+
if (0 !== e.plugins.size) for (const r of e.plugins.values()) {
|
|
955
|
+
const s = r.hooks?.[t];
|
|
956
|
+
if (s) try {
|
|
957
|
+
s(n);
|
|
958
|
+
} catch (s) {
|
|
959
|
+
const o = s instanceof Error ? s : new Error(String(s));
|
|
476
960
|
e.onError ? e.onError(o, {
|
|
477
|
-
operation: `plugin:${
|
|
961
|
+
operation: `plugin:${r.name}:${t}`,
|
|
478
962
|
key: n.key
|
|
479
963
|
}) : e.silent;
|
|
480
964
|
}
|
|
481
965
|
}
|
|
482
|
-
})(
|
|
483
|
-
},
|
|
484
|
-
|
|
966
|
+
})(K(), e, t);
|
|
967
|
+
}, W = (e, t, n, r) => {
|
|
968
|
+
A && null !== Ve && Ue && Ue({
|
|
485
969
|
timestamp: Date.now(),
|
|
486
970
|
action: e,
|
|
487
971
|
key: t,
|
|
488
|
-
userId:
|
|
972
|
+
userId: j,
|
|
489
973
|
success: n,
|
|
490
|
-
error:
|
|
974
|
+
error: r
|
|
491
975
|
});
|
|
492
|
-
},
|
|
493
|
-
const
|
|
494
|
-
if (!
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
if (!
|
|
498
|
-
const n =
|
|
499
|
-
n && (n.delete(e), 0 === n.size &&
|
|
976
|
+
}, Q = e => {
|
|
977
|
+
const t = u.get(e);
|
|
978
|
+
if (!t) return;
|
|
979
|
+
const r = new Set, s = t.selector(e => (r.add(e), u.has(e) ? u.get(e).lastValue : Z.get(e)));
|
|
980
|
+
t.deps.forEach(t => {
|
|
981
|
+
if (!r.has(t)) {
|
|
982
|
+
const n = d.get(t);
|
|
983
|
+
n && (n.delete(e), 0 === n.size && d.delete(t));
|
|
500
984
|
}
|
|
501
|
-
}),
|
|
502
|
-
|
|
503
|
-
}),
|
|
504
|
-
|
|
505
|
-
},
|
|
985
|
+
}), r.forEach(n => {
|
|
986
|
+
t.deps.has(n) || (d.has(n) || d.set(n, new Set), d.get(n).add(e));
|
|
987
|
+
}), t.deps = r, i(t.lastValue, s) || (t.lastValue = R && null !== s && "object" == typeof s ? H(a(s), !0) : s,
|
|
988
|
+
n.set(e, (n.get(e) || 0) + 1), q(e));
|
|
989
|
+
}, q = e => {
|
|
506
990
|
if (e) {
|
|
507
|
-
if (
|
|
508
|
-
const t =
|
|
509
|
-
for (const e of t)
|
|
991
|
+
if (d.has(e)) {
|
|
992
|
+
const t = d.get(e);
|
|
993
|
+
for (const e of t) Q(e);
|
|
510
994
|
}
|
|
511
|
-
const t =
|
|
995
|
+
const t = l.get(e);
|
|
512
996
|
if (t) {
|
|
513
|
-
const n =
|
|
514
|
-
for (const
|
|
515
|
-
|
|
997
|
+
const n = Z.get(e);
|
|
998
|
+
for (const r of t) try {
|
|
999
|
+
r(n);
|
|
516
1000
|
} catch (t) {
|
|
517
1001
|
const n = t instanceof Error ? t : new Error(String(t));
|
|
518
|
-
|
|
1002
|
+
k && k(n, {
|
|
519
1003
|
operation: "watcher",
|
|
520
1004
|
key: e
|
|
521
1005
|
});
|
|
522
1006
|
}
|
|
523
1007
|
}
|
|
524
|
-
const n =
|
|
1008
|
+
const n = o.get(e);
|
|
525
1009
|
if (n) for (const t of n) try {
|
|
526
1010
|
t();
|
|
527
1011
|
} catch (t) {
|
|
528
1012
|
const n = t instanceof Error ? t : new Error(String(t));
|
|
529
|
-
|
|
1013
|
+
k && k(n, {
|
|
530
1014
|
operation: "keyListener",
|
|
531
1015
|
key: e
|
|
532
1016
|
});
|
|
533
1017
|
}
|
|
534
1018
|
}
|
|
535
|
-
if (
|
|
1019
|
+
if (I) z = !0; else for (const e of s) try {
|
|
536
1020
|
e();
|
|
537
1021
|
} catch (e) {
|
|
538
1022
|
const t = e instanceof Error ? e : new Error(String(e));
|
|
539
|
-
|
|
1023
|
+
k && k(t, {
|
|
540
1024
|
operation: "listener"
|
|
541
1025
|
});
|
|
542
1026
|
}
|
|
543
|
-
},
|
|
1027
|
+
}, G = async () => {
|
|
544
1028
|
(async e => {
|
|
545
1029
|
if (!e.storage) return;
|
|
546
|
-
const {store: t, config: n, diskQueue:
|
|
1030
|
+
const {store: t, config: n, diskQueue: r, storage: s, encryptionKey: o, audit: a, onError: i, silent: c, currentVersion: l} = e, u = We(n.namespace || "gstate");
|
|
547
1031
|
try {
|
|
548
1032
|
const e = {};
|
|
549
|
-
let
|
|
1033
|
+
let r;
|
|
550
1034
|
t.forEach((t, n) => {
|
|
551
1035
|
e[n] = t;
|
|
552
1036
|
});
|
|
553
1037
|
const o = n?.encoded;
|
|
554
|
-
|
|
1038
|
+
r = o ? btoa(JSON.stringify(e)) : JSON.stringify(e), s.setItem(u.replace("_", ""), JSON.stringify({
|
|
555
1039
|
v: 1,
|
|
556
1040
|
t: Date.now(),
|
|
557
1041
|
e: null,
|
|
558
|
-
d:
|
|
1042
|
+
d: r,
|
|
559
1043
|
_sys_v: l,
|
|
560
1044
|
_b64: !!o || void 0
|
|
561
1045
|
})), a("set", "FULL_STATE", !0);
|
|
@@ -566,21 +1050,21 @@ var x = () => {
|
|
|
566
1050
|
key: "FULL_STATE"
|
|
567
1051
|
});
|
|
568
1052
|
}
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
for (const [t, n] of
|
|
1053
|
+
const d = Array.from(r.entries());
|
|
1054
|
+
r.clear();
|
|
1055
|
+
for (const [t, n] of d) try {
|
|
572
1056
|
if (!t || !/^[a-zA-Z0-9_.-]+$/.test(t) || t.length > 256) continue;
|
|
573
|
-
let
|
|
1057
|
+
let r = n.value;
|
|
574
1058
|
const i = n.options.encoded || n.options.encrypted || n.options.secure;
|
|
575
1059
|
if (n.options.encrypted) {
|
|
576
1060
|
if (!o) throw new Error(`Encryption key missing for "${t}"`);
|
|
577
|
-
|
|
578
|
-
} else i ?
|
|
579
|
-
|
|
1061
|
+
r = await xe(n.value, o);
|
|
1062
|
+
} else i ? r = btoa(JSON.stringify(n.value)) : "object" == typeof n.value && null !== n.value && (r = JSON.stringify(n.value));
|
|
1063
|
+
s.setItem(`${u}${t}`, JSON.stringify({
|
|
580
1064
|
v: e.versions.get(t) || 1,
|
|
581
1065
|
t: Date.now(),
|
|
582
1066
|
e: n.options.ttl ? Date.now() + n.options.ttl : null,
|
|
583
|
-
d:
|
|
1067
|
+
d: r,
|
|
584
1068
|
_sys_v: l,
|
|
585
1069
|
_enc: !!n.options.encrypted || void 0,
|
|
586
1070
|
_b64: !(!n.options.encoded && !n.options.secure) || void 0
|
|
@@ -592,140 +1076,141 @@ var x = () => {
|
|
|
592
1076
|
key: t
|
|
593
1077
|
});
|
|
594
1078
|
}
|
|
595
|
-
})(
|
|
596
|
-
},
|
|
597
|
-
_setSilently: (e,
|
|
598
|
-
const
|
|
599
|
-
|
|
1079
|
+
})(F());
|
|
1080
|
+
}, X = {}, Z = {
|
|
1081
|
+
_setSilently: (e, s) => {
|
|
1082
|
+
const o = r.get(e) || 0, i = R && null !== s && "object" == typeof s ? H(a(s), !0) : s, c = (O > 0 || C > 0) && !Qe() ? J(i) : 0;
|
|
1083
|
+
$ = $ - o + c, r.set(e, c), t.set(e, i), n.set(e, (n.get(e) || 0) + 1), N = null;
|
|
600
1084
|
},
|
|
601
1085
|
_registerMethod: (e, t, n) => {
|
|
602
|
-
const
|
|
603
|
-
|
|
1086
|
+
const r = e => "__proto__" === e || "constructor" === e || "prototype" === e;
|
|
1087
|
+
r(e) || r(t) || (X[e] || (X[e] = {}), X[e][t] = n);
|
|
604
1088
|
},
|
|
605
|
-
set: (
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
608
|
-
if (!
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
key:
|
|
612
|
-
value:
|
|
613
|
-
store:
|
|
614
|
-
version:
|
|
1089
|
+
set: (s, o, c = {}) => {
|
|
1090
|
+
const l = t.get(s), u = R && "function" == typeof o ? De(l, o) : o;
|
|
1091
|
+
if (M && !Je(s)) return !1;
|
|
1092
|
+
if (!Fe(m, s, "write", j)) return W("set", s, !1, "RBAC Denied"), !1;
|
|
1093
|
+
const d = M ? Ke(u) : u, f = r.get(s) || 0;
|
|
1094
|
+
B("onBeforeSet", {
|
|
1095
|
+
key: s,
|
|
1096
|
+
value: d,
|
|
1097
|
+
store: Z,
|
|
1098
|
+
version: n.get(s) || 0
|
|
615
1099
|
});
|
|
616
|
-
const p =
|
|
617
|
-
if (!l
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
620
|
-
const
|
|
621
|
-
|
|
1100
|
+
const p = R && null !== d && "object" == typeof d ? H(a(d), !0) : d;
|
|
1101
|
+
if (!i(l, p)) {
|
|
1102
|
+
const o = (O > 0 || C > 0) && !Qe() ? J(p) : 0;
|
|
1103
|
+
if (O > 0 && o > O) {
|
|
1104
|
+
const e = new Error(`Object size (${o} bytes) exceeds maxObjectSize (${O} bytes)`);
|
|
1105
|
+
return k && k(e, {
|
|
622
1106
|
operation: "set",
|
|
623
|
-
key:
|
|
624
|
-
});
|
|
1107
|
+
key: s
|
|
1108
|
+
}), !1;
|
|
625
1109
|
}
|
|
626
|
-
if (
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
629
|
-
const
|
|
630
|
-
|
|
1110
|
+
if (C > 0) {
|
|
1111
|
+
const e = $ - f + o;
|
|
1112
|
+
if (e > C) {
|
|
1113
|
+
const t = new Error(`Total store size (${e} bytes) exceeds limit (${C} bytes)`);
|
|
1114
|
+
return k && k(t, {
|
|
631
1115
|
operation: "set"
|
|
632
|
-
});
|
|
1116
|
+
}), !1;
|
|
633
1117
|
}
|
|
634
1118
|
}
|
|
635
|
-
|
|
636
|
-
const
|
|
637
|
-
return
|
|
1119
|
+
$ = $ - f + o, r.set(s, o), t.set(s, p), n.set(s, (n.get(s) || 0) + 1), N = null;
|
|
1120
|
+
const a = c.persist ?? P;
|
|
1121
|
+
return a && (y.set(s, {
|
|
638
1122
|
value: p,
|
|
639
1123
|
options: {
|
|
640
|
-
...
|
|
641
|
-
persist:
|
|
642
|
-
encoded:
|
|
1124
|
+
...c,
|
|
1125
|
+
persist: a,
|
|
1126
|
+
encoded: c.encoded || e?.encoded
|
|
643
1127
|
}
|
|
644
|
-
}),
|
|
645
|
-
key:
|
|
1128
|
+
}), V && clearTimeout(V), V = setTimeout(G, b)), B("onSet", {
|
|
1129
|
+
key: s,
|
|
646
1130
|
value: p,
|
|
647
|
-
store:
|
|
648
|
-
version:
|
|
649
|
-
}),
|
|
1131
|
+
store: Z,
|
|
1132
|
+
version: n.get(s)
|
|
1133
|
+
}), W("set", s, !0), q(s), !0;
|
|
650
1134
|
}
|
|
651
1135
|
return !1;
|
|
652
1136
|
},
|
|
653
1137
|
get: e => {
|
|
654
|
-
if (!
|
|
655
|
-
const
|
|
656
|
-
return
|
|
657
|
-
store:
|
|
1138
|
+
if (!Fe(m, e, "read", j)) return W("get", e, !1, "RBAC Denied"), null;
|
|
1139
|
+
const n = t.get(e);
|
|
1140
|
+
return B("onGet", {
|
|
1141
|
+
store: Z,
|
|
658
1142
|
key: e,
|
|
659
|
-
value:
|
|
660
|
-
}),
|
|
1143
|
+
value: n
|
|
1144
|
+
}), W("get", e, !0), n;
|
|
661
1145
|
},
|
|
662
1146
|
compute: (e, t) => {
|
|
663
1147
|
try {
|
|
664
|
-
return
|
|
1148
|
+
return u.has(e) || (u.set(e, {
|
|
665
1149
|
selector: t,
|
|
666
1150
|
lastValue: null,
|
|
667
1151
|
deps: new Set
|
|
668
|
-
}),
|
|
1152
|
+
}), Q(e)), u.get(e).lastValue;
|
|
669
1153
|
} catch (t) {
|
|
670
1154
|
const n = t instanceof Error ? t : new Error(String(t));
|
|
671
|
-
return
|
|
1155
|
+
return k && k(n, {
|
|
672
1156
|
operation: "compute",
|
|
673
1157
|
key: e
|
|
674
1158
|
}), null;
|
|
675
1159
|
}
|
|
676
1160
|
},
|
|
677
1161
|
watch: (e, t) => {
|
|
678
|
-
|
|
679
|
-
const n =
|
|
1162
|
+
l.has(e) || l.set(e, new Set);
|
|
1163
|
+
const n = l.get(e);
|
|
680
1164
|
return n.add(t), () => {
|
|
681
|
-
n.delete(t), 0 === n.size &&
|
|
1165
|
+
n.delete(t), 0 === n.size && l.delete(e);
|
|
682
1166
|
};
|
|
683
1167
|
},
|
|
684
1168
|
remove: e => {
|
|
685
|
-
if (!
|
|
686
|
-
const
|
|
687
|
-
return
|
|
688
|
-
store:
|
|
1169
|
+
if (!Fe(m, e, "delete", j)) return W("delete", e, !1, "RBAC Denied"), !1;
|
|
1170
|
+
const s = t.get(e), o = t.delete(e);
|
|
1171
|
+
return o && ($ -= r.get(e) || 0, r.delete(e), B("onRemove", {
|
|
1172
|
+
store: Z,
|
|
689
1173
|
key: e,
|
|
690
|
-
value:
|
|
691
|
-
}),
|
|
692
|
-
|
|
1174
|
+
value: s
|
|
1175
|
+
}), N = null), n.set(e, (n.get(e) || 0) + 1), E && E.removeItem(`${L()}${e}`), W("delete", e, !0),
|
|
1176
|
+
q(e), o;
|
|
693
1177
|
},
|
|
694
|
-
delete: e =>
|
|
1178
|
+
delete: e => Z.remove(e),
|
|
695
1179
|
deleteAll: () => {
|
|
696
|
-
if (Array.from(
|
|
697
|
-
const e =
|
|
698
|
-
for (let
|
|
699
|
-
const n =
|
|
700
|
-
n
|
|
1180
|
+
if (Array.from(t.keys()).forEach(e => Z.remove(e)), E) {
|
|
1181
|
+
const e = L(), t = [], n = E.length || 0;
|
|
1182
|
+
for (let r = 0; r < n; r++) {
|
|
1183
|
+
const n = E.key(r);
|
|
1184
|
+
n && n.startsWith(e) && t.push(n);
|
|
701
1185
|
}
|
|
1186
|
+
for (const e of t) E.removeItem(e);
|
|
702
1187
|
}
|
|
703
|
-
return
|
|
1188
|
+
return $ = 0, r.clear(), N = null, !0;
|
|
704
1189
|
},
|
|
705
|
-
list: () => Object.fromEntries(
|
|
1190
|
+
list: () => Object.fromEntries(t.entries()),
|
|
706
1191
|
use: e => {
|
|
707
|
-
|
|
1192
|
+
c.add(e);
|
|
708
1193
|
},
|
|
709
1194
|
transaction: e => {
|
|
710
|
-
|
|
711
|
-
store:
|
|
1195
|
+
I = !0, B("onTransaction", {
|
|
1196
|
+
store: Z,
|
|
712
1197
|
key: "START"
|
|
713
1198
|
});
|
|
714
1199
|
try {
|
|
715
1200
|
e();
|
|
716
1201
|
} finally {
|
|
717
|
-
|
|
718
|
-
store:
|
|
1202
|
+
I = !1, B("onTransaction", {
|
|
1203
|
+
store: Z,
|
|
719
1204
|
key: "END"
|
|
720
|
-
}),
|
|
1205
|
+
}), z && (z = !1, q());
|
|
721
1206
|
}
|
|
722
1207
|
},
|
|
723
1208
|
destroy: () => {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
store:
|
|
727
|
-
}),
|
|
728
|
-
|
|
1209
|
+
V && (clearTimeout(V), V = null), y.clear(), "undefined" != typeof window && window.removeEventListener("beforeunload", Y),
|
|
1210
|
+
B("onDestroy", {
|
|
1211
|
+
store: Z
|
|
1212
|
+
}), s.clear(), o.clear(), l.clear(), u.clear(), d.clear(), f.clear(), t.clear(),
|
|
1213
|
+
r.clear(), $ = 0, m.clear(), _.clear(), n.clear(), p.clear(), c.clear();
|
|
729
1214
|
},
|
|
730
1215
|
_addPlugin: e => {
|
|
731
1216
|
((e, t, n) => {
|
|
@@ -734,158 +1219,158 @@ var x = () => {
|
|
|
734
1219
|
store: n
|
|
735
1220
|
});
|
|
736
1221
|
} catch (n) {
|
|
737
|
-
const
|
|
738
|
-
e.onError ? e.onError(
|
|
1222
|
+
const r = n instanceof Error ? n : new Error(String(n));
|
|
1223
|
+
e.onError ? e.onError(r, {
|
|
739
1224
|
operation: "plugin:install",
|
|
740
1225
|
key: t.name
|
|
741
1226
|
}) : e.silent;
|
|
742
1227
|
}
|
|
743
|
-
})(
|
|
1228
|
+
})(K(), e, Z);
|
|
744
1229
|
},
|
|
745
1230
|
_removePlugin: e => {
|
|
746
1231
|
f.delete(e);
|
|
747
1232
|
},
|
|
748
1233
|
_subscribe: (e, t) => {
|
|
749
1234
|
if (t) {
|
|
750
|
-
|
|
751
|
-
const n =
|
|
1235
|
+
o.has(t) || o.set(t, new Set);
|
|
1236
|
+
const n = o.get(t);
|
|
752
1237
|
return n.add(e), () => {
|
|
753
|
-
n.delete(e), 0 === n.size &&
|
|
1238
|
+
n.delete(e), 0 === n.size && o.delete(t);
|
|
754
1239
|
};
|
|
755
1240
|
}
|
|
756
|
-
return
|
|
1241
|
+
return s.add(e), () => s.delete(e);
|
|
757
1242
|
},
|
|
758
|
-
_getVersion: e =>
|
|
759
|
-
addAccessRule: (e, t) =>
|
|
760
|
-
hasPermission: (e, t, n) =>
|
|
761
|
-
recordConsent: (e, t, n) =>
|
|
1243
|
+
_getVersion: e => n.get(e) ?? 0,
|
|
1244
|
+
addAccessRule: (e, t) => Le(m, e, t),
|
|
1245
|
+
hasPermission: (e, t, n) => Fe(m, e, t, n),
|
|
1246
|
+
recordConsent: (e, t, n) => Be(_, e, t, n),
|
|
762
1247
|
hasConsent: (e, t) => ((e, t, n) => {
|
|
763
|
-
const
|
|
764
|
-
if (!
|
|
765
|
-
for (let e =
|
|
766
|
-
const t =
|
|
1248
|
+
const r = e.get(t);
|
|
1249
|
+
if (!r) return !1;
|
|
1250
|
+
for (let e = r.length - 1; e >= 0; e--) {
|
|
1251
|
+
const t = r[e];
|
|
767
1252
|
if (t && t.purpose === n) return t.granted;
|
|
768
1253
|
}
|
|
769
1254
|
return !1;
|
|
770
|
-
})(
|
|
771
|
-
getConsents: e => ((e, t) => e.get(t) || [])(
|
|
772
|
-
revokeConsent: (e, t) => ((e, t, n) =>
|
|
1255
|
+
})(_, e, t),
|
|
1256
|
+
getConsents: e => ((e, t) => e.get(t) || [])(_, e),
|
|
1257
|
+
revokeConsent: (e, t) => ((e, t, n) => Be(e, t, n, !1))(_, e, t),
|
|
773
1258
|
exportUserData: e => ((e, t) => ({
|
|
774
1259
|
userId: t,
|
|
775
1260
|
exportedAt: Date.now(),
|
|
776
1261
|
consents: e.get(t) || []
|
|
777
|
-
}))(
|
|
1262
|
+
}))(_, e),
|
|
778
1263
|
deleteUserData: e => ((e, t) => {
|
|
779
1264
|
const n = e.get(t)?.length || 0;
|
|
780
1265
|
return e.delete(t), {
|
|
781
1266
|
success: !0,
|
|
782
1267
|
deletedConsents: n
|
|
783
1268
|
};
|
|
784
|
-
})(
|
|
785
|
-
getSnapshot: () => (
|
|
1269
|
+
})(_, e),
|
|
1270
|
+
getSnapshot: () => (N || (N = Object.fromEntries(t.entries())), N),
|
|
786
1271
|
get plugins() {
|
|
787
|
-
return
|
|
1272
|
+
return X;
|
|
788
1273
|
},
|
|
789
1274
|
get isReady() {
|
|
790
|
-
return
|
|
1275
|
+
return x;
|
|
791
1276
|
},
|
|
792
1277
|
get namespace() {
|
|
793
|
-
return
|
|
1278
|
+
return S;
|
|
794
1279
|
},
|
|
795
1280
|
get userId() {
|
|
796
|
-
return
|
|
1281
|
+
return j;
|
|
797
1282
|
},
|
|
798
|
-
whenReady: () =>
|
|
1283
|
+
whenReady: () => U
|
|
799
1284
|
};
|
|
800
1285
|
[ "addAccessRule", "recordConsent", "hasConsent", "getConsents", "revokeConsent", "exportUserData", "deleteUserData" ].forEach(e => {
|
|
801
|
-
const t =
|
|
802
|
-
t &&
|
|
1286
|
+
const t = Z[e];
|
|
1287
|
+
t && Z._registerMethod("security", e, t);
|
|
803
1288
|
});
|
|
804
|
-
const
|
|
805
|
-
|
|
1289
|
+
const Y = () => {
|
|
1290
|
+
y.size > 0 && G();
|
|
806
1291
|
};
|
|
807
|
-
if ("undefined" != typeof window && window.addEventListener("beforeunload",
|
|
808
|
-
|
|
809
|
-
const {storage: r, config:
|
|
1292
|
+
if ("undefined" != typeof window && window.addEventListener("beforeunload", Y),
|
|
1293
|
+
E ? (async (e, t, n) => {
|
|
1294
|
+
const {storage: r, config: s, encryptionKey: o, audit: i, onError: c, silent: l, currentVersion: u, store: d, sizes: f, versions: y} = e, p = We(s.namespace || "gstate"), h = s.immer ?? !0;
|
|
810
1295
|
if (r) try {
|
|
811
|
-
const
|
|
812
|
-
let
|
|
1296
|
+
const l = {};
|
|
1297
|
+
let g = 0;
|
|
813
1298
|
for (let e = 0; e < (r.length || 0); e++) {
|
|
814
1299
|
const t = r.key(e);
|
|
815
|
-
if (!t || !t.startsWith(
|
|
1300
|
+
if (!t || !t.startsWith(p)) continue;
|
|
816
1301
|
const n = r.getItem(t);
|
|
817
1302
|
if (n) try {
|
|
818
|
-
const s = JSON.parse(n),
|
|
819
|
-
if (
|
|
1303
|
+
const s = JSON.parse(n), a = t.substring(p.length);
|
|
1304
|
+
if (g = Math.max(g, void 0 !== s._sys_v ? s._sys_v : s.v || 0), s.e && Date.now() > s.e) {
|
|
820
1305
|
r.removeItem(t), e--;
|
|
821
1306
|
continue;
|
|
822
1307
|
}
|
|
823
1308
|
let c = s.d;
|
|
824
|
-
if (s._enc &&
|
|
1309
|
+
if (s._enc && o) c = await $e(c, o); else if ("string" == typeof c) if (s._b64) try {
|
|
825
1310
|
c = JSON.parse(atob(c));
|
|
826
1311
|
} catch (e) {} else if (c.startsWith("{") || c.startsWith("[")) try {
|
|
827
1312
|
c = JSON.parse(c);
|
|
828
1313
|
} catch (e) {}
|
|
829
|
-
|
|
1314
|
+
l[a] = c, i("hydrate", a, !0);
|
|
830
1315
|
} catch (e) {
|
|
831
1316
|
i("hydrate", t, !1, String(e));
|
|
832
1317
|
const n = e instanceof Error ? e : new Error(String(e));
|
|
833
|
-
|
|
1318
|
+
c && c(n, {
|
|
834
1319
|
operation: "hydration",
|
|
835
1320
|
key: t
|
|
836
1321
|
});
|
|
837
1322
|
}
|
|
838
1323
|
}
|
|
839
|
-
const
|
|
840
|
-
Object.entries(
|
|
841
|
-
const
|
|
842
|
-
e.totalSize = e.totalSize - i +
|
|
843
|
-
}),
|
|
1324
|
+
const m = g < u && s.migrate ? s.migrate(l, g) : l;
|
|
1325
|
+
Object.entries(m).forEach(([n, r]) => {
|
|
1326
|
+
const s = h && null !== r && "object" == typeof r ? H(a(r), !0) : r, o = t(s), i = f.get(n) || 0;
|
|
1327
|
+
e.totalSize = e.totalSize - i + o, f.set(n, o), d.set(n, s), y.set(n, 1);
|
|
1328
|
+
}), n();
|
|
844
1329
|
} catch (e) {
|
|
845
1330
|
const t = e instanceof Error ? e : new Error(String(e));
|
|
846
|
-
|
|
1331
|
+
c && c(t, {
|
|
847
1332
|
operation: "hydration"
|
|
848
1333
|
});
|
|
849
1334
|
}
|
|
850
|
-
})(
|
|
851
|
-
|
|
852
|
-
}).then(() => {}) : (
|
|
853
|
-
const
|
|
854
|
-
const {SyncEngine:
|
|
855
|
-
return new
|
|
1335
|
+
})(F(), e => (O > 0 || C > 0) && !Qe() ? J(e) : 0, () => {
|
|
1336
|
+
x = !0, N = null, T(), q();
|
|
1337
|
+
}).then(() => {}) : (x = !0, T()), e?.sync) {
|
|
1338
|
+
const t = e.sync, n = async () => {
|
|
1339
|
+
const {SyncEngine: e} = await Promise.resolve().then(() => (g(), h));
|
|
1340
|
+
return new e(Z, t);
|
|
856
1341
|
};
|
|
857
|
-
let
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
return (await
|
|
861
|
-
}),
|
|
862
|
-
|
|
863
|
-
return (await
|
|
864
|
-
}),
|
|
865
|
-
|
|
866
|
-
return (await
|
|
867
|
-
}),
|
|
868
|
-
|
|
869
|
-
return (await
|
|
1342
|
+
let r = null;
|
|
1343
|
+
Z._registerMethod("sync", "flush", async () => {
|
|
1344
|
+
r || (r = n());
|
|
1345
|
+
return (await r).flush();
|
|
1346
|
+
}), Z._registerMethod("sync", "getState", async () => {
|
|
1347
|
+
r || (r = n());
|
|
1348
|
+
return (await r).getState();
|
|
1349
|
+
}), Z._registerMethod("sync", "onStateChange", async e => {
|
|
1350
|
+
r || (r = n());
|
|
1351
|
+
return (await r).onStateChange(e);
|
|
1352
|
+
}), Z._registerMethod("sync", "forceSync", async () => {
|
|
1353
|
+
r || (r = n());
|
|
1354
|
+
return (await r).sync();
|
|
870
1355
|
});
|
|
871
1356
|
}
|
|
872
|
-
return
|
|
1357
|
+
return Z;
|
|
873
1358
|
};
|
|
874
1359
|
|
|
875
|
-
|
|
1360
|
+
g();
|
|
876
1361
|
|
|
877
|
-
var
|
|
878
|
-
const t =
|
|
879
|
-
return
|
|
880
|
-
},
|
|
881
|
-
|
|
882
|
-
},
|
|
883
|
-
const
|
|
884
|
-
return s
|
|
885
|
-
},
|
|
1362
|
+
var Xe = null, Ze = e => {
|
|
1363
|
+
const t = Ge(e);
|
|
1364
|
+
return Xe = t, t;
|
|
1365
|
+
}, Ye = () => {
|
|
1366
|
+
Xe && (Xe.destroy(), Xe = null);
|
|
1367
|
+
}, et = n => {
|
|
1368
|
+
const r = n || Xe, s = e(() => e => r ? r._subscribe(e) : () => {}, [ r ]);
|
|
1369
|
+
return t(s, () => !!r && r.isReady, () => !0);
|
|
1370
|
+
}, tt = () => Xe;
|
|
886
1371
|
|
|
887
|
-
function
|
|
888
|
-
const a =
|
|
1372
|
+
function nt(s, o) {
|
|
1373
|
+
const a = e(() => o || Xe, [ o ]), i = e(() => {
|
|
889
1374
|
const e = () => {}, t = () => !1, n = () => null;
|
|
890
1375
|
return {
|
|
891
1376
|
set: t,
|
|
@@ -918,96 +1403,96 @@ function Q(e, t) {
|
|
|
918
1403
|
},
|
|
919
1404
|
get userId() {}
|
|
920
1405
|
};
|
|
921
|
-
}, []), c = a || i, l = "function" == typeof
|
|
1406
|
+
}, []), c = a || i, l = "function" == typeof s, u = l ? null : s, d = l ? s : null, f = n(e => l ? c._subscribe(e) : c._subscribe(e, u), [ c, l, u ]), y = n(() => l ? d(c.getSnapshot()) : c.get(u) ?? void 0, [ c, l, u, d ]), p = n(() => {
|
|
922
1407
|
if (l) try {
|
|
923
|
-
return
|
|
1408
|
+
return d({});
|
|
924
1409
|
} catch {
|
|
925
1410
|
return;
|
|
926
1411
|
}
|
|
927
|
-
}, [
|
|
928
|
-
return
|
|
929
|
-
l ? h : [ h,
|
|
1412
|
+
}, [ d, l ]), h = t(f, y, p), g = n((e, t) => l ? (Qe(), !1) : c.set(u, e, t), [ c, l, u ]);
|
|
1413
|
+
return r(h, e => l ? `Selector: ${JSON.stringify(e)}` : `${u}: ${JSON.stringify(e)}`),
|
|
1414
|
+
l ? h : [ h, g ];
|
|
930
1415
|
}
|
|
931
1416
|
|
|
932
|
-
var
|
|
1417
|
+
var rt = new Map, st = (e, t) => {
|
|
933
1418
|
const n = e.namespace;
|
|
934
|
-
if (
|
|
935
|
-
const
|
|
936
|
-
return
|
|
937
|
-
},
|
|
938
|
-
const t =
|
|
939
|
-
t && (t.destroy(),
|
|
1419
|
+
if (rt.has(n)) return rt.get(n);
|
|
1420
|
+
const r = new c(e, t);
|
|
1421
|
+
return rt.set(n, r), r;
|
|
1422
|
+
}, ot = e => {
|
|
1423
|
+
const t = rt.get(e);
|
|
1424
|
+
t && (t.destroy(), rt.delete(e));
|
|
940
1425
|
};
|
|
941
1426
|
|
|
942
|
-
function
|
|
943
|
-
const
|
|
1427
|
+
function at(e, t) {
|
|
1428
|
+
const r = t || Xe, a = r?.namespace || "default", i = rt.get(a), c = nt(e, r), l = c[0], u = c[1], [d, f] = s(() => i?.getState() || {
|
|
944
1429
|
isOnline: !0,
|
|
945
1430
|
isSyncing: !1,
|
|
946
1431
|
lastSyncTimestamp: null,
|
|
947
1432
|
pendingChanges: 0,
|
|
948
1433
|
conflicts: 0
|
|
949
1434
|
});
|
|
950
|
-
|
|
951
|
-
if (!
|
|
952
|
-
return
|
|
953
|
-
}, [
|
|
954
|
-
return [ l,
|
|
955
|
-
const
|
|
956
|
-
if (
|
|
957
|
-
const t =
|
|
958
|
-
|
|
1435
|
+
o(() => {
|
|
1436
|
+
if (!i) return;
|
|
1437
|
+
return i.onStateChange(f);
|
|
1438
|
+
}, [ i ]);
|
|
1439
|
+
return [ l, n((t, n) => {
|
|
1440
|
+
const s = u(t, n);
|
|
1441
|
+
if (s && i) {
|
|
1442
|
+
const t = r?.get(e);
|
|
1443
|
+
i.queueChange(e, t);
|
|
959
1444
|
}
|
|
960
|
-
return
|
|
961
|
-
}, [ u,
|
|
1445
|
+
return s;
|
|
1446
|
+
}, [ u, i, e, r ]), d ];
|
|
962
1447
|
}
|
|
963
1448
|
|
|
964
|
-
var
|
|
965
|
-
const [e, t] =
|
|
1449
|
+
var it, ct, lt, ut, dt, ft, yt = () => {
|
|
1450
|
+
const [e, t] = s({
|
|
966
1451
|
isOnline: !0,
|
|
967
1452
|
isSyncing: !1,
|
|
968
1453
|
lastSyncTimestamp: null,
|
|
969
1454
|
pendingChanges: 0,
|
|
970
1455
|
conflicts: 0
|
|
971
1456
|
});
|
|
972
|
-
return
|
|
1457
|
+
return o(() => {
|
|
973
1458
|
const e = () => {
|
|
974
|
-
let e = !0, n = !1,
|
|
975
|
-
|
|
1459
|
+
let e = !0, n = !1, r = 0, s = 0;
|
|
1460
|
+
rt.forEach(t => {
|
|
976
1461
|
const o = t.getState();
|
|
977
|
-
e = e && o.isOnline, n = n || o.isSyncing,
|
|
1462
|
+
e = e && o.isOnline, n = n || o.isSyncing, r += o.pendingChanges, s += o.conflicts;
|
|
978
1463
|
}), t({
|
|
979
1464
|
isOnline: e,
|
|
980
1465
|
isSyncing: n,
|
|
981
1466
|
lastSyncTimestamp: null,
|
|
982
|
-
pendingChanges:
|
|
983
|
-
conflicts:
|
|
1467
|
+
pendingChanges: r,
|
|
1468
|
+
conflicts: s
|
|
984
1469
|
});
|
|
985
1470
|
};
|
|
986
1471
|
e();
|
|
987
|
-
const n = Array.from(
|
|
1472
|
+
const n = Array.from(rt.values()).map(t => t.onStateChange(e));
|
|
988
1473
|
return () => n.forEach(e => e());
|
|
989
1474
|
}, []), e;
|
|
990
|
-
},
|
|
991
|
-
const t = e ||
|
|
1475
|
+
}, pt = async e => {
|
|
1476
|
+
const t = e || Xe?.namespace;
|
|
992
1477
|
if (!t) return;
|
|
993
|
-
const n =
|
|
1478
|
+
const n = rt.get(t);
|
|
994
1479
|
n && await n.flush();
|
|
995
|
-
},
|
|
996
|
-
const n = t?.key || "async_data",
|
|
1480
|
+
}, ht = (e, t) => {
|
|
1481
|
+
const n = t?.key || "async_data", r = t?.store || Ge({
|
|
997
1482
|
namespace: `async_${n}`,
|
|
998
1483
|
silent: !0
|
|
999
1484
|
});
|
|
1000
|
-
null ==
|
|
1485
|
+
null == r.get(n) && r.set(n, {
|
|
1001
1486
|
data: null,
|
|
1002
1487
|
loading: !1,
|
|
1003
1488
|
error: null,
|
|
1004
1489
|
updatedAt: null
|
|
1005
1490
|
});
|
|
1006
|
-
return Object.assign(
|
|
1491
|
+
return Object.assign(r, {
|
|
1007
1492
|
execute: async () => {
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
...
|
|
1493
|
+
const s = r.get(n);
|
|
1494
|
+
r.set(n, {
|
|
1495
|
+
...s || {
|
|
1011
1496
|
data: null,
|
|
1012
1497
|
loading: !1,
|
|
1013
1498
|
error: null,
|
|
@@ -1015,25 +1500,25 @@ var X = () => {
|
|
|
1015
1500
|
},
|
|
1016
1501
|
loading: !0,
|
|
1017
1502
|
error: null
|
|
1018
|
-
}), "whenReady" in
|
|
1503
|
+
}), "whenReady" in r && !r.isReady && await r.whenReady();
|
|
1019
1504
|
try {
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1505
|
+
const s = await e(), o = r.get(n);
|
|
1506
|
+
r.set(n, {
|
|
1022
1507
|
...o || {
|
|
1023
1508
|
data: null,
|
|
1024
1509
|
loading: !1,
|
|
1025
1510
|
error: null,
|
|
1026
1511
|
updatedAt: null
|
|
1027
1512
|
},
|
|
1028
|
-
data:
|
|
1513
|
+
data: s,
|
|
1029
1514
|
loading: !1,
|
|
1030
1515
|
updatedAt: Date.now()
|
|
1031
1516
|
}, {
|
|
1032
1517
|
persist: t?.persist
|
|
1033
1518
|
});
|
|
1034
1519
|
} catch (e) {
|
|
1035
|
-
const t =
|
|
1036
|
-
|
|
1520
|
+
const t = r.get(n);
|
|
1521
|
+
r.set(n, {
|
|
1037
1522
|
...t || {
|
|
1038
1523
|
data: null,
|
|
1039
1524
|
loading: !1,
|
|
@@ -1046,62 +1531,298 @@ var X = () => {
|
|
|
1046
1531
|
}
|
|
1047
1532
|
}
|
|
1048
1533
|
});
|
|
1049
|
-
}
|
|
1534
|
+
}, gt = () => "undefined" == typeof window || void 0 === window.document, mt = () => !gt(), _t = e => {
|
|
1535
|
+
const t = e?.ssrSafe ?? !0, n = e?.deferHydration ?? !1;
|
|
1536
|
+
let r = e?.storage;
|
|
1537
|
+
!r && t && gt() && (r = He());
|
|
1538
|
+
const s = Ge({
|
|
1539
|
+
...e,
|
|
1540
|
+
storage: r || void 0,
|
|
1541
|
+
persistByDefault: !n && (e?.persistByDefault ?? !1)
|
|
1542
|
+
});
|
|
1543
|
+
let o = !1, a = null;
|
|
1544
|
+
e?.initialState && gt() && (Object.entries(e.initialState).forEach(([e, t]) => {
|
|
1545
|
+
s._setSilently(e, t);
|
|
1546
|
+
}), a = JSON.stringify(e.initialState));
|
|
1547
|
+
return Object.assign(s, {
|
|
1548
|
+
hydrate: async () => {
|
|
1549
|
+
if (!o && !gt()) {
|
|
1550
|
+
if (t && !s.namespace.startsWith("async_")) {
|
|
1551
|
+
const t = s.getSnapshot(), n = Ge({
|
|
1552
|
+
...e,
|
|
1553
|
+
namespace: s.namespace,
|
|
1554
|
+
storage: void 0,
|
|
1555
|
+
persistByDefault: e?.persistByDefault ?? !1
|
|
1556
|
+
});
|
|
1557
|
+
Object.entries(t).forEach(([e, t]) => {
|
|
1558
|
+
n._setSilently(e, t);
|
|
1559
|
+
}), o = !0;
|
|
1560
|
+
} else o = !0;
|
|
1561
|
+
await s.whenReady();
|
|
1562
|
+
}
|
|
1563
|
+
},
|
|
1564
|
+
getSerializedState: () => gt() ? JSON.stringify(s.getSnapshot()) : a,
|
|
1565
|
+
isHydrated: () => o || s.isReady
|
|
1566
|
+
});
|
|
1567
|
+
}, St = async e => {
|
|
1568
|
+
gt() || await e.whenReady();
|
|
1569
|
+
}, wt = e => JSON.stringify(e.getSnapshot()), bt = (e, t) => {
|
|
1570
|
+
if (!gt()) try {
|
|
1571
|
+
const n = JSON.parse(t);
|
|
1572
|
+
Object.entries(n).forEach(([t, n]) => {
|
|
1573
|
+
e._setSilently(t, n);
|
|
1574
|
+
});
|
|
1575
|
+
} catch (e) {}
|
|
1576
|
+
}, vt = () => (it || (it = f("react"), ct = it.useState, lt = it.useEffect, ut = it.useSyncExternalStore,
|
|
1577
|
+
dt = it.useMemo, ft = it.useCallback), {
|
|
1578
|
+
React: it,
|
|
1579
|
+
useState: ct,
|
|
1580
|
+
useEffect: lt,
|
|
1581
|
+
useSyncExternalStore: ut,
|
|
1582
|
+
useMemo: dt,
|
|
1583
|
+
useCallback: ft
|
|
1584
|
+
}), Et = () => {
|
|
1585
|
+
const {useSyncExternalStore: e} = vt();
|
|
1586
|
+
return e(e => () => {}, () => mt(), () => !0);
|
|
1587
|
+
}, kt = () => {
|
|
1588
|
+
const {useState: e, useEffect: t} = vt(), [n, r] = e(() => gt()), [s, o] = e(() => gt());
|
|
1589
|
+
return t(() => {
|
|
1590
|
+
if (gt()) return;
|
|
1591
|
+
r(!0);
|
|
1592
|
+
const e = setTimeout(() => {
|
|
1593
|
+
o(!0), r(!1);
|
|
1594
|
+
}, 0);
|
|
1595
|
+
return () => clearTimeout(e);
|
|
1596
|
+
}, []), {
|
|
1597
|
+
isHydrated: s,
|
|
1598
|
+
isHydrating: n
|
|
1599
|
+
};
|
|
1600
|
+
}, Ot = e => {
|
|
1601
|
+
const {useState: t, useEffect: n, useMemo: r} = vt(), [s, o] = t(() => !!gt() || (e.isHydrated?.() ?? e.isReady));
|
|
1602
|
+
return n(() => {
|
|
1603
|
+
if (gt()) return;
|
|
1604
|
+
const t = () => {
|
|
1605
|
+
const t = e.isHydrated?.() ?? e.isReady;
|
|
1606
|
+
o(t);
|
|
1607
|
+
}, n = setInterval(t, 50), r = e._subscribe(t);
|
|
1608
|
+
return t(), () => {
|
|
1609
|
+
clearInterval(n), r();
|
|
1610
|
+
};
|
|
1611
|
+
}, [ e ]), r(() => {
|
|
1612
|
+
if (s) return e;
|
|
1613
|
+
const t = () => {}, n = () => !1, r = () => null;
|
|
1614
|
+
return {
|
|
1615
|
+
set: n,
|
|
1616
|
+
get: r,
|
|
1617
|
+
remove: n,
|
|
1618
|
+
delete: n,
|
|
1619
|
+
deleteAll: n,
|
|
1620
|
+
list: () => ({}),
|
|
1621
|
+
compute: r,
|
|
1622
|
+
watch: () => () => {},
|
|
1623
|
+
use: t,
|
|
1624
|
+
transaction: t,
|
|
1625
|
+
destroy: t,
|
|
1626
|
+
_subscribe: () => () => {},
|
|
1627
|
+
_setSilently: t,
|
|
1628
|
+
_registerMethod: t,
|
|
1629
|
+
_addPlugin: t,
|
|
1630
|
+
_removePlugin: t,
|
|
1631
|
+
_getVersion: () => 0,
|
|
1632
|
+
get isReady() {
|
|
1633
|
+
return !1;
|
|
1634
|
+
},
|
|
1635
|
+
whenReady: () => Promise.resolve(),
|
|
1636
|
+
get plugins() {
|
|
1637
|
+
return {};
|
|
1638
|
+
},
|
|
1639
|
+
getSnapshot: () => ({}),
|
|
1640
|
+
get namespace() {
|
|
1641
|
+
return e.namespace;
|
|
1642
|
+
},
|
|
1643
|
+
get userId() {
|
|
1644
|
+
return e.userId;
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
}, [ e, s ]);
|
|
1648
|
+
}, Ct = e => {
|
|
1649
|
+
const t = _t(e);
|
|
1650
|
+
return Object.assign(t, {
|
|
1651
|
+
useHydrated: Et,
|
|
1652
|
+
useHydrationStatus: kt,
|
|
1653
|
+
useDeferredStore: e => {
|
|
1654
|
+
const n = Ot(t), {useCallback: r} = vt();
|
|
1655
|
+
return (e => {
|
|
1656
|
+
const {useSyncExternalStore: t} = vt();
|
|
1657
|
+
return t(r(t => n._subscribe(t, e), [ n, e ]), r(() => n.get(e), [ n, e ]), () => {});
|
|
1658
|
+
})(e);
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
}, Dt = e => e.getSnapshot(), Mt = (e, t) => {
|
|
1662
|
+
gt() || Object.entries(t).forEach(([t, n]) => {
|
|
1663
|
+
e._setSilently(t, n);
|
|
1664
|
+
});
|
|
1665
|
+
}, At = (e, t) => {
|
|
1666
|
+
const n = t?.extraArgument, r = async t => {
|
|
1667
|
+
if ("function" == typeof t) return t(r, () => e.getSnapshot(), n);
|
|
1668
|
+
if (t.type) {
|
|
1669
|
+
const {type: n, payload: r} = t, s = n.match(/^SET_(.+)$/i);
|
|
1670
|
+
if (s && s[1]) {
|
|
1671
|
+
const t = s[1].toLowerCase();
|
|
1672
|
+
e.set(t, r);
|
|
1673
|
+
}
|
|
1674
|
+
const o = n.match(/^REMOVE_(.+)$/i);
|
|
1675
|
+
if (o && o[1]) {
|
|
1676
|
+
const t = o[1].toLowerCase();
|
|
1677
|
+
e.remove(t);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
return Object.assign(e, {
|
|
1682
|
+
dispatch: r
|
|
1683
|
+
});
|
|
1684
|
+
}, jt = (e, t) => {
|
|
1685
|
+
const n = At(e);
|
|
1686
|
+
return Object.assign(n.dispatch, t);
|
|
1687
|
+
}, Rt = (e, t) => async (n, r) => {
|
|
1688
|
+
const s = r()[e];
|
|
1689
|
+
n({
|
|
1690
|
+
type: `SET_${e.toUpperCase()}`,
|
|
1691
|
+
payload: {
|
|
1692
|
+
...s,
|
|
1693
|
+
loading: !0,
|
|
1694
|
+
error: null
|
|
1695
|
+
}
|
|
1696
|
+
});
|
|
1697
|
+
try {
|
|
1698
|
+
const r = await t();
|
|
1699
|
+
return n({
|
|
1700
|
+
type: `SET_${e.toUpperCase()}`,
|
|
1701
|
+
payload: {
|
|
1702
|
+
data: r,
|
|
1703
|
+
loading: !1,
|
|
1704
|
+
error: null
|
|
1705
|
+
}
|
|
1706
|
+
}), r;
|
|
1707
|
+
} catch (t) {
|
|
1708
|
+
throw n({
|
|
1709
|
+
type: `SET_${e.toUpperCase()}`,
|
|
1710
|
+
payload: {
|
|
1711
|
+
data: s?.data ?? null,
|
|
1712
|
+
loading: !1,
|
|
1713
|
+
error: t instanceof Error ? t : new Error(String(t))
|
|
1714
|
+
}
|
|
1715
|
+
}), t;
|
|
1716
|
+
}
|
|
1717
|
+
}, Pt = (e, t) => {
|
|
1718
|
+
At(e);
|
|
1719
|
+
const n = {};
|
|
1720
|
+
for (const [e, r] of Object.entries(t)) n[e] = Rt(e, r);
|
|
1721
|
+
return n;
|
|
1722
|
+
}, Tt = (e, ...t) => ({
|
|
1723
|
+
type: "call",
|
|
1724
|
+
fn: e,
|
|
1725
|
+
args: t
|
|
1726
|
+
}), It = e => ({
|
|
1727
|
+
type: "put",
|
|
1728
|
+
action: e
|
|
1729
|
+
}), zt = e => ({
|
|
1730
|
+
type: "select",
|
|
1731
|
+
selector: e
|
|
1732
|
+
}), xt = e => ({
|
|
1733
|
+
type: "take",
|
|
1734
|
+
pattern: e
|
|
1735
|
+
}), $t = e => ({
|
|
1736
|
+
type: "all",
|
|
1737
|
+
effects: e
|
|
1738
|
+
}), Vt = e => ({
|
|
1739
|
+
type: "race",
|
|
1740
|
+
effects: e
|
|
1741
|
+
}), Nt = e => async (t, n) => {
|
|
1742
|
+
const r = async e => {
|
|
1743
|
+
switch (e.type) {
|
|
1744
|
+
case "call":
|
|
1745
|
+
return e.fn();
|
|
1050
1746
|
|
|
1051
|
-
|
|
1747
|
+
case "put":
|
|
1748
|
+
return t(e.action);
|
|
1052
1749
|
|
|
1053
|
-
|
|
1750
|
+
case "select":
|
|
1751
|
+
return e.selector(n());
|
|
1752
|
+
|
|
1753
|
+
case "all":
|
|
1754
|
+
return Promise.all(e.effects.map(r));
|
|
1755
|
+
|
|
1756
|
+
case "race":
|
|
1757
|
+
{
|
|
1758
|
+
const t = Object.fromEntries(Object.entries(e.effects).map(([e, t]) => [ e, r(t) ]));
|
|
1759
|
+
return Promise.race(Object.values(t));
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
default:
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
try {
|
|
1767
|
+
let t = e.next();
|
|
1768
|
+
for (;!t.done; ) await r(t.value), t = e.next();
|
|
1769
|
+
} catch (e) {}
|
|
1770
|
+
}, Ut = (e, t) => (At(e).dispatch(t), () => {});
|
|
1771
|
+
|
|
1772
|
+
g();
|
|
1773
|
+
|
|
1774
|
+
var Lt = () => ({
|
|
1054
1775
|
name: "gstate-immer",
|
|
1055
1776
|
hooks: {
|
|
1056
1777
|
onInstall: ({store: e}) => {
|
|
1057
1778
|
e._registerMethod("immer", "setWithProduce", (t, n) => e.set(t, n));
|
|
1058
1779
|
}
|
|
1059
1780
|
}
|
|
1060
|
-
}),
|
|
1061
|
-
let t = [], n = -1,
|
|
1062
|
-
const
|
|
1781
|
+
}), Ft = e => {
|
|
1782
|
+
let t = [], n = -1, r = !1;
|
|
1783
|
+
const s = e?.limit || 50;
|
|
1063
1784
|
return {
|
|
1064
1785
|
name: "gstate-undo-redo",
|
|
1065
1786
|
hooks: {
|
|
1066
1787
|
onInstall: ({store: e}) => {
|
|
1067
1788
|
t.push(e.list()), n = 0, e._registerMethod("undoRedo", "undo", () => {
|
|
1068
1789
|
if (n > 0) {
|
|
1069
|
-
|
|
1070
|
-
const
|
|
1071
|
-
return !!
|
|
1790
|
+
r = !0, n--;
|
|
1791
|
+
const s = t[n];
|
|
1792
|
+
return !!s && (Object.entries(s).forEach(([t, n]) => {
|
|
1072
1793
|
e._setSilently(t, n);
|
|
1073
|
-
}),
|
|
1794
|
+
}), r = !1, !0);
|
|
1074
1795
|
}
|
|
1075
1796
|
return !1;
|
|
1076
1797
|
}), e._registerMethod("undoRedo", "redo", () => {
|
|
1077
1798
|
if (n < t.length - 1) {
|
|
1078
|
-
|
|
1079
|
-
const
|
|
1080
|
-
return !!
|
|
1799
|
+
r = !0, n++;
|
|
1800
|
+
const s = t[n];
|
|
1801
|
+
return !!s && (Object.entries(s).forEach(([t, n]) => {
|
|
1081
1802
|
e._setSilently(t, n);
|
|
1082
|
-
}),
|
|
1803
|
+
}), r = !1, !0);
|
|
1083
1804
|
}
|
|
1084
1805
|
return !1;
|
|
1085
1806
|
}), e._registerMethod("undoRedo", "canUndo", () => n > 0), e._registerMethod("undoRedo", "canRedo", () => n < t.length - 1);
|
|
1086
1807
|
},
|
|
1087
1808
|
onSet: ({store: e}) => {
|
|
1088
|
-
|
|
1809
|
+
r || (n < t.length - 1 && (t = t.slice(0, n + 1)), t.push(e.list()), t.length > s ? t.shift() : n++);
|
|
1089
1810
|
}
|
|
1090
1811
|
}
|
|
1091
1812
|
};
|
|
1092
|
-
},
|
|
1813
|
+
}, Kt = e => ({
|
|
1093
1814
|
name: "gstate-schema",
|
|
1094
1815
|
hooks: {
|
|
1095
1816
|
onSet: ({key: t, value: n}) => {
|
|
1096
1817
|
if (!t) return;
|
|
1097
|
-
const
|
|
1098
|
-
if (
|
|
1099
|
-
const e =
|
|
1818
|
+
const r = e[t];
|
|
1819
|
+
if (r) {
|
|
1820
|
+
const e = r(n);
|
|
1100
1821
|
if (!0 !== e) throw new Error(`[Schema Error] Validation failed for key "${t}": ${!1 === e ? "Invalid type" : e}`);
|
|
1101
1822
|
}
|
|
1102
1823
|
}
|
|
1103
1824
|
}
|
|
1104
|
-
}),
|
|
1825
|
+
}), Jt = e => {
|
|
1105
1826
|
const t = globalThis.__REDUX_DEVTOOLS_EXTENSION__;
|
|
1106
1827
|
if (!t?.connect) return {
|
|
1107
1828
|
name: "gstate-devtools-noop",
|
|
@@ -1111,10 +1832,10 @@ var Y = () => ({
|
|
|
1111
1832
|
return {
|
|
1112
1833
|
name: "gstate-devtools",
|
|
1113
1834
|
hooks: {
|
|
1114
|
-
onInstall: ({store:
|
|
1835
|
+
onInstall: ({store: r}) => {
|
|
1115
1836
|
n = t.connect({
|
|
1116
1837
|
name: e?.name || "Magnetar Store"
|
|
1117
|
-
}), n.init(
|
|
1838
|
+
}), n.init(r.list());
|
|
1118
1839
|
},
|
|
1119
1840
|
onSet: ({key: e, store: t}) => {
|
|
1120
1841
|
e && n && n.send(`SET_${e.toUpperCase()}`, t.list());
|
|
@@ -1124,7 +1845,7 @@ var Y = () => ({
|
|
|
1124
1845
|
}
|
|
1125
1846
|
}
|
|
1126
1847
|
};
|
|
1127
|
-
},
|
|
1848
|
+
}, Bt = () => {
|
|
1128
1849
|
const e = new Map;
|
|
1129
1850
|
return {
|
|
1130
1851
|
name: "gstate-snapshot",
|
|
@@ -1133,9 +1854,9 @@ var Y = () => ({
|
|
|
1133
1854
|
t._registerMethod("snapshot", "takeSnapshot", n => {
|
|
1134
1855
|
e.set(n, t.list());
|
|
1135
1856
|
}), t._registerMethod("snapshot", "restoreSnapshot", n => {
|
|
1136
|
-
const
|
|
1137
|
-
return !!
|
|
1138
|
-
Object.entries(
|
|
1857
|
+
const r = e.get(n);
|
|
1858
|
+
return !!r && (t.transaction(() => {
|
|
1859
|
+
Object.entries(r).forEach(([e, n]) => {
|
|
1139
1860
|
t.set(e, n);
|
|
1140
1861
|
});
|
|
1141
1862
|
}), !0);
|
|
@@ -1144,16 +1865,16 @@ var Y = () => ({
|
|
|
1144
1865
|
}
|
|
1145
1866
|
}
|
|
1146
1867
|
};
|
|
1147
|
-
},
|
|
1868
|
+
}, Wt = e => ({
|
|
1148
1869
|
name: "gstate-guard",
|
|
1149
1870
|
hooks: {
|
|
1150
|
-
onBeforeSet: ({key: t, value: n, store:
|
|
1871
|
+
onBeforeSet: ({key: t, value: n, store: r}) => {
|
|
1151
1872
|
if (!t) return;
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1873
|
+
const s = e[t];
|
|
1874
|
+
s && s(n);
|
|
1154
1875
|
}
|
|
1155
1876
|
}
|
|
1156
|
-
}),
|
|
1877
|
+
}), Qt = e => ({
|
|
1157
1878
|
name: "gstate-analytics",
|
|
1158
1879
|
hooks: {
|
|
1159
1880
|
onSet: ({key: t, value: n}) => {
|
|
@@ -1171,7 +1892,7 @@ var Y = () => ({
|
|
|
1171
1892
|
}));
|
|
1172
1893
|
}
|
|
1173
1894
|
}
|
|
1174
|
-
}),
|
|
1895
|
+
}), qt = e => {
|
|
1175
1896
|
const t = new BroadcastChannel(e?.channelName || "gstate_sync");
|
|
1176
1897
|
let n = !1;
|
|
1177
1898
|
return {
|
|
@@ -1179,14 +1900,14 @@ var Y = () => ({
|
|
|
1179
1900
|
hooks: {
|
|
1180
1901
|
onInstall: ({store: e}) => {
|
|
1181
1902
|
t.onmessage = t => {
|
|
1182
|
-
const {key:
|
|
1183
|
-
|
|
1903
|
+
const {key: r, value: s, action: o} = t.data;
|
|
1904
|
+
r && (n = !0, "REMOVE" === o ? e.remove(r) : e.set(r, s), n = !1);
|
|
1184
1905
|
};
|
|
1185
1906
|
},
|
|
1186
|
-
onSet: ({key: e, value:
|
|
1907
|
+
onSet: ({key: e, value: r}) => {
|
|
1187
1908
|
e && !n && t.postMessage({
|
|
1188
1909
|
key: e,
|
|
1189
|
-
value:
|
|
1910
|
+
value: r,
|
|
1190
1911
|
action: "SET"
|
|
1191
1912
|
});
|
|
1192
1913
|
},
|
|
@@ -1201,12 +1922,12 @@ var Y = () => ({
|
|
|
1201
1922
|
}
|
|
1202
1923
|
}
|
|
1203
1924
|
};
|
|
1204
|
-
},
|
|
1205
|
-
if (
|
|
1925
|
+
}, Ht = () => {
|
|
1926
|
+
if (Qe()) return {
|
|
1206
1927
|
name: "gstate-debug-noop",
|
|
1207
1928
|
hooks: {}
|
|
1208
1929
|
};
|
|
1209
|
-
|
|
1930
|
+
Qe();
|
|
1210
1931
|
return {
|
|
1211
1932
|
name: "gstate-debug",
|
|
1212
1933
|
hooks: {
|
|
@@ -1218,8 +1939,8 @@ var Y = () => ({
|
|
|
1218
1939
|
return n;
|
|
1219
1940
|
},
|
|
1220
1941
|
set: (t, n) => {
|
|
1221
|
-
const
|
|
1222
|
-
return JSON.stringify(n),
|
|
1942
|
+
const r = e.set(t, n);
|
|
1943
|
+
return JSON.stringify(n), r;
|
|
1223
1944
|
},
|
|
1224
1945
|
watch: (t, n) => e.watch(t, n),
|
|
1225
1946
|
info: () => {
|
|
@@ -1239,23 +1960,23 @@ var Y = () => ({
|
|
|
1239
1960
|
}
|
|
1240
1961
|
}
|
|
1241
1962
|
};
|
|
1242
|
-
},
|
|
1243
|
-
const t = e.dbName || "rgs-db", n = e.storeName || "states",
|
|
1244
|
-
let
|
|
1963
|
+
}, Gt = (e = {}) => {
|
|
1964
|
+
const t = e.dbName || "rgs-db", n = e.storeName || "states", r = e.version || 1;
|
|
1965
|
+
let s = null;
|
|
1245
1966
|
const o = () => new Promise((e, o) => {
|
|
1246
|
-
if (
|
|
1247
|
-
const a = indexedDB.open(t,
|
|
1967
|
+
if (s) return e(s);
|
|
1968
|
+
const a = indexedDB.open(t, r);
|
|
1248
1969
|
a.onerror = () => o(a.error), a.onsuccess = () => {
|
|
1249
|
-
|
|
1970
|
+
s = a.result, e(s);
|
|
1250
1971
|
}, a.onupgradeneeded = e => {
|
|
1251
1972
|
const t = e.target.result;
|
|
1252
1973
|
t.objectStoreNames.contains(n) || t.createObjectStore(n);
|
|
1253
1974
|
};
|
|
1254
1975
|
}), a = async e => {
|
|
1255
1976
|
const t = await o();
|
|
1256
|
-
return new Promise((
|
|
1977
|
+
return new Promise((r, s) => {
|
|
1257
1978
|
const o = t.transaction(n, "readonly").objectStore(n).get(e);
|
|
1258
|
-
o.onsuccess = () =>
|
|
1979
|
+
o.onsuccess = () => r(o.result), o.onerror = () => s(o.error);
|
|
1259
1980
|
});
|
|
1260
1981
|
};
|
|
1261
1982
|
return {
|
|
@@ -1269,46 +1990,46 @@ var Y = () => ({
|
|
|
1269
1990
|
onInit: async ({store: e}) => {
|
|
1270
1991
|
const t = (await o()).transaction(n, "readonly").objectStore(n).getAllKeys();
|
|
1271
1992
|
t.onsuccess = async () => {
|
|
1272
|
-
const n = t.result,
|
|
1273
|
-
for (const t of n) if (t.startsWith(
|
|
1993
|
+
const n = t.result, r = e.namespace + "_";
|
|
1994
|
+
for (const t of n) if (t.startsWith(r)) {
|
|
1274
1995
|
const n = await a(t);
|
|
1275
1996
|
if (n) {
|
|
1276
|
-
const
|
|
1277
|
-
e._setSilently(
|
|
1997
|
+
const s = t.substring(r.length);
|
|
1998
|
+
e._setSilently(s, n.d);
|
|
1278
1999
|
}
|
|
1279
2000
|
}
|
|
1280
2001
|
};
|
|
1281
2002
|
},
|
|
1282
|
-
onSet: async ({key: e, value: t, store:
|
|
2003
|
+
onSet: async ({key: e, value: t, store: r}) => {
|
|
1283
2004
|
if (!e) return;
|
|
1284
|
-
const
|
|
2005
|
+
const s = r.namespace + "_", a = {
|
|
1285
2006
|
d: t,
|
|
1286
2007
|
t: Date.now(),
|
|
1287
|
-
v:
|
|
2008
|
+
v: r._getVersion?.(e) || 1
|
|
1288
2009
|
};
|
|
1289
2010
|
await (async (e, t) => {
|
|
1290
|
-
const
|
|
1291
|
-
return new Promise((
|
|
1292
|
-
const a =
|
|
1293
|
-
a.onsuccess = () =>
|
|
2011
|
+
const r = await o();
|
|
2012
|
+
return new Promise((s, o) => {
|
|
2013
|
+
const a = r.transaction(n, "readwrite").objectStore(n).put(t, e);
|
|
2014
|
+
a.onsuccess = () => s(), a.onerror = () => o(a.error);
|
|
1294
2015
|
});
|
|
1295
|
-
})(`${
|
|
2016
|
+
})(`${s}${e}`, a);
|
|
1296
2017
|
},
|
|
1297
2018
|
onRemove: async ({key: e, store: t}) => {
|
|
1298
2019
|
if (!e) return;
|
|
1299
|
-
const
|
|
2020
|
+
const r = t.namespace + "_";
|
|
1300
2021
|
await (async e => {
|
|
1301
2022
|
const t = await o();
|
|
1302
|
-
return new Promise((
|
|
2023
|
+
return new Promise((r, s) => {
|
|
1303
2024
|
const o = t.transaction(n, "readwrite").objectStore(n).delete(e);
|
|
1304
|
-
o.onsuccess = () =>
|
|
2025
|
+
o.onsuccess = () => r(), o.onerror = () => s(o.error);
|
|
1305
2026
|
});
|
|
1306
|
-
})(`${
|
|
2027
|
+
})(`${r}${e}`);
|
|
1307
2028
|
}
|
|
1308
2029
|
}
|
|
1309
2030
|
};
|
|
1310
|
-
},
|
|
1311
|
-
const {adapter: t, autoSyncInterval: n} = e,
|
|
2031
|
+
}, Xt = e => {
|
|
2032
|
+
const {adapter: t, autoSyncInterval: n} = e, r = new Map, s = {
|
|
1312
2033
|
lastSyncTimestamp: null,
|
|
1313
2034
|
totalKeysSynced: 0,
|
|
1314
2035
|
totalBytesSynced: 0,
|
|
@@ -1328,30 +2049,30 @@ var Y = () => ({
|
|
|
1328
2049
|
const c = a.list(), l = Object.keys(c);
|
|
1329
2050
|
for (const e of l) {
|
|
1330
2051
|
const t = a._getVersion?.(e) || 0;
|
|
1331
|
-
if (t > (
|
|
2052
|
+
if (t > (r.get(e) || 0)) {
|
|
1332
2053
|
const n = c[e];
|
|
1333
|
-
o[e] = n, i += JSON.stringify(n).length,
|
|
2054
|
+
o[e] = n, i += JSON.stringify(n).length, r.set(e, t);
|
|
1334
2055
|
}
|
|
1335
2056
|
}
|
|
1336
2057
|
if (0 === Object.keys(o).length) return {
|
|
1337
2058
|
status: "no-change",
|
|
1338
|
-
stats:
|
|
2059
|
+
stats: s
|
|
1339
2060
|
};
|
|
1340
|
-
if (await t.save(o)) return
|
|
1341
|
-
|
|
1342
|
-
e.onSync && e.onSync(
|
|
2061
|
+
if (await t.save(o)) return s.lastSyncTimestamp = Date.now(), s.totalKeysSynced += Object.keys(o).length,
|
|
2062
|
+
s.totalBytesSynced += i, s.syncCount++, s.lastDuration = performance.now() - n,
|
|
2063
|
+
e.onSync && e.onSync(s), {
|
|
1343
2064
|
status: "success",
|
|
1344
|
-
stats:
|
|
2065
|
+
stats: s
|
|
1345
2066
|
};
|
|
1346
2067
|
throw new Error(`Adapter ${t.name} failed to save.`);
|
|
1347
2068
|
} catch (e) {
|
|
1348
|
-
return
|
|
2069
|
+
return s.errors++, {
|
|
1349
2070
|
status: "error",
|
|
1350
2071
|
error: String(e),
|
|
1351
|
-
stats:
|
|
2072
|
+
stats: s
|
|
1352
2073
|
};
|
|
1353
2074
|
}
|
|
1354
|
-
}), a._registerMethod("cloudSync", "getStats", () =>
|
|
2075
|
+
}), a._registerMethod("cloudSync", "getStats", () => s), n && n > 0 && (o = setInterval(() => {
|
|
1355
2076
|
const e = a.plugins.cloudSync;
|
|
1356
2077
|
e && e.sync();
|
|
1357
2078
|
}, n));
|
|
@@ -1361,7 +2082,7 @@ var Y = () => ({
|
|
|
1361
2082
|
}
|
|
1362
2083
|
}
|
|
1363
2084
|
};
|
|
1364
|
-
},
|
|
2085
|
+
}, Zt = (e, t) => ({
|
|
1365
2086
|
name: "MongoDB-Atlas",
|
|
1366
2087
|
save: async n => (await fetch(`${e}/action/updateOne`, {
|
|
1367
2088
|
method: "POST",
|
|
@@ -1385,32 +2106,32 @@ var Y = () => ({
|
|
|
1385
2106
|
upsert: !0
|
|
1386
2107
|
})
|
|
1387
2108
|
})).ok
|
|
1388
|
-
}),
|
|
2109
|
+
}), Yt = (e, t) => ({
|
|
1389
2110
|
name: "Firebase-Firestore",
|
|
1390
2111
|
save: async e => {
|
|
1391
2112
|
try {
|
|
1392
|
-
|
|
2113
|
+
Qe();
|
|
1393
2114
|
return (() => {})("[Mock] Firestore Syncing:", e), !0;
|
|
1394
2115
|
} catch (e) {
|
|
1395
2116
|
return !1;
|
|
1396
2117
|
}
|
|
1397
2118
|
}
|
|
1398
|
-
}),
|
|
2119
|
+
}), en = (e, t) => ({
|
|
1399
2120
|
name: "SQL-REST-API",
|
|
1400
2121
|
save: async n => {
|
|
1401
|
-
const
|
|
1402
|
-
if (!
|
|
2122
|
+
const r = t();
|
|
2123
|
+
if (!r) return !1;
|
|
1403
2124
|
return (await fetch(e, {
|
|
1404
2125
|
method: "PATCH",
|
|
1405
2126
|
headers: {
|
|
1406
2127
|
"Content-Type": "application/json",
|
|
1407
|
-
Authorization: `Bearer ${
|
|
2128
|
+
Authorization: `Bearer ${r}`
|
|
1408
2129
|
},
|
|
1409
2130
|
body: JSON.stringify(n),
|
|
1410
2131
|
credentials: "same-origin"
|
|
1411
2132
|
})).ok;
|
|
1412
2133
|
}
|
|
1413
|
-
}),
|
|
2134
|
+
}), tn = e => ({
|
|
1414
2135
|
name: "gstate-logger",
|
|
1415
2136
|
hooks: {
|
|
1416
2137
|
onSet: ({key: e, value: t, version: n}) => {
|
|
@@ -1419,27 +2140,27 @@ var Y = () => ({
|
|
|
1419
2140
|
onRemove: ({key: e}) => {},
|
|
1420
2141
|
onTransaction: ({key: e}) => {}
|
|
1421
2142
|
}
|
|
1422
|
-
}),
|
|
1423
|
-
const n =
|
|
2143
|
+
}), nn = (e, t) => {
|
|
2144
|
+
const n = Ge("string" == typeof t ? {
|
|
1424
2145
|
namespace: t
|
|
1425
2146
|
} : t);
|
|
1426
2147
|
e && Object.entries(e).forEach(([e, t]) => {
|
|
1427
2148
|
null === n.get(e) && n._setSilently(e, t);
|
|
1428
2149
|
});
|
|
1429
|
-
return "undefined" == typeof window ||
|
|
1430
|
-
window.rgs = n), Object.assign(e =>
|
|
1431
|
-
},
|
|
1432
|
-
const
|
|
1433
|
-
if (!
|
|
1434
|
-
return
|
|
1435
|
-
},
|
|
1436
|
-
const t =
|
|
2150
|
+
return "undefined" == typeof window || Qe() || (window.gstate = n, window.gState = n,
|
|
2151
|
+
window.rgs = n), Object.assign(e => nt(e, n), n);
|
|
2152
|
+
}, rn = (e, t) => tt()?.addAccessRule(e, t), sn = (e, t, n) => tt()?.hasPermission(e, t, n) ?? !0, on = (e, t, n) => {
|
|
2153
|
+
const r = tt();
|
|
2154
|
+
if (!r) throw new Error("[gstate] recordConsent failed: No store found. call initState() first.");
|
|
2155
|
+
return r.recordConsent(e, t, n);
|
|
2156
|
+
}, an = (e, t) => tt()?.hasConsent(e, t) ?? !1, cn = e => tt()?.getConsents(e) ?? [], ln = (e, t) => tt()?.revokeConsent(e, t), un = e => {
|
|
2157
|
+
const t = tt();
|
|
1437
2158
|
if (!t) throw new Error("[gstate] exportUserData failed: No store found.");
|
|
1438
2159
|
return t.exportUserData(e);
|
|
1439
|
-
},
|
|
1440
|
-
const t =
|
|
2160
|
+
}, dn = e => {
|
|
2161
|
+
const t = tt();
|
|
1441
2162
|
if (!t) throw new Error("[gstate] deleteUserData failed: No store found.");
|
|
1442
2163
|
return t.deleteUserData(e);
|
|
1443
|
-
},
|
|
2164
|
+
}, fn = () => {}, yn = () => {};
|
|
1444
2165
|
|
|
1445
|
-
export {
|
|
2166
|
+
export { c as SyncEngine, rn as addAccessRule, $t as all, Qt as analyticsPlugin, Tt as call, fn as clearAccessRules, yn as clearAllConsents, Xt as cloudSyncPlugin, jt as createActions, Rt as createAsyncAction, Pt as createAsyncActions, ht as createAsyncStore, Yt as createFirestoreAdapter, Zt as createMongoAdapter, Ct as createNextStore, _t as createSSRStore, Nt as createSaga, en as createSqlRestAdapter, Ge as createStore, l as createSyncEngine, At as createThunkStore, Ht as debugPlugin, wt as dehydrateStore, dn as deleteUserData, Re as deriveKeyFromPassword, Ye as destroyState, ot as destroySync, Jt as devToolsPlugin, Ie as exportKey, un as exportUserData, Te as generateEncryptionKey, Pe as generateSalt, cn as getConsents, Dt as getSSRInitialState, tt as getStore, nn as gstate, Wt as guardPlugin, an as hasConsent, sn as hasPermission, St as hydrateOnClient, Lt as immerPlugin, ze as importKey, Gt as indexedDBPlugin, Ze as initState, st as initSync, Mt as initializeFromSSR, mt as isClientSide, je as isCryptoAvailable, gt as isServerSide, Ue as logAudit, tn as loggerPlugin, It as put, Vt as race, on as recordConsent, bt as rehydrateStore, ln as revokeConsent, Ut as runSaga, Ke as sanitizeValue, Kt as schemaPlugin, zt as select, Ne as setAuditLogger, Bt as snapshotPlugin, qt as syncPlugin, xt as take, pt as triggerSync, Ft as undoRedoPlugin, Ot as useDeferredStore, nt as useGState, Et as useHydrated, kt as useHydrationStatus, et as useIsStoreReady, nt as useSimpleState, nt as useStore, yt as useSyncStatus, at as useSyncedState, Je as validateKey };
|