@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.cjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var e, t, n = require("
|
|
4
|
-
|
|
3
|
+
var e, t, n = require("react"), r = Object.defineProperty, s = Object.getOwnPropertyNames, o = (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
|
+
}), a = (e, t) => function() {
|
|
9
|
+
return e && (t = (0, e[s(e)[0]])(e = 0)), t;
|
|
5
10
|
}, i = a({
|
|
6
11
|
"core/utils.ts"() {
|
|
7
12
|
e = e => {
|
|
@@ -51,7 +56,7 @@ var e, t, n = require("immer"), r = require("react"), s = Object.defineProperty,
|
|
|
51
56
|
}), c = {};
|
|
52
57
|
|
|
53
58
|
((e, t) => {
|
|
54
|
-
for (var n in t)
|
|
59
|
+
for (var n in t) r(e, n, {
|
|
55
60
|
get: t[n],
|
|
56
61
|
enumerable: !0
|
|
57
62
|
});
|
|
@@ -288,7 +293,477 @@ var l = a({
|
|
|
288
293
|
}
|
|
289
294
|
}, exports.createSyncEngine = (e, t) => new exports.SyncEngine(e, t);
|
|
290
295
|
}
|
|
291
|
-
}), u = (
|
|
296
|
+
}), u = Symbol.for("immer-nothing"), d = Symbol.for("immer-draftable"), y = Symbol.for("immer-state"), p = [ 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 f(e, ...t) {
|
|
309
|
+
{
|
|
310
|
+
const n = p[e], r = V(n) ? n.apply(null, t) : n;
|
|
311
|
+
throw new Error(`[Immer] ${r}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
var g = Object, h = g.getPrototypeOf, m = "constructor", S = "prototype", _ = "configurable", w = "enumerable", b = "writable", v = "value", E = e => !!e && !!e[y];
|
|
316
|
+
|
|
317
|
+
function k(e) {
|
|
318
|
+
return !!e && (C(e) || j(e) || !!e[d] || !!e[m]?.[d] || T(e) || I(e));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
var x = g[S][m].toString(), O = new WeakMap;
|
|
322
|
+
|
|
323
|
+
function C(e) {
|
|
324
|
+
if (!e || !z(e)) return !1;
|
|
325
|
+
const t = h(e);
|
|
326
|
+
if (null === t || t === g[S]) return !0;
|
|
327
|
+
const n = g.hasOwnProperty.call(t, m) && t[m];
|
|
328
|
+
if (n === Object) return !0;
|
|
329
|
+
if (!V(n)) return !1;
|
|
330
|
+
let r = O.get(n);
|
|
331
|
+
return void 0 === r && (r = Function.toString.call(n), O.set(n, r)), r === x;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function A(e, t, n = !0) {
|
|
335
|
+
if (0 === D(e)) {
|
|
336
|
+
(n ? Reflect.ownKeys(e) : g.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 D(e) {
|
|
343
|
+
const t = e[y];
|
|
344
|
+
return t ? t.type_ : j(e) ? 1 : T(e) ? 2 : I(e) ? 3 : 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var M = (e, t, n = D(e)) => 2 === n ? e.has(t) : g[S].hasOwnProperty.call(e, t), P = (e, t, n = D(e)) => 2 === n ? e.get(t) : e[t], R = (e, t, n, r = D(e)) => {
|
|
348
|
+
2 === r ? e.set(t, n) : 3 === r ? e.add(n) : e[t] = n;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
var j = Array.isArray, T = e => e instanceof Map, I = e => e instanceof Set, z = e => "object" == typeof e, V = e => "function" == typeof e, $ = e => "boolean" == typeof e;
|
|
352
|
+
|
|
353
|
+
var N = e => e.copy_ || e.base_, U = e => e.modified_ ? e.copy_ : e.base_;
|
|
354
|
+
|
|
355
|
+
function L(e, t) {
|
|
356
|
+
if (T(e)) return new Map(e);
|
|
357
|
+
if (I(e)) return new Set(e);
|
|
358
|
+
if (j(e)) return Array[S].slice.call(e);
|
|
359
|
+
const n = C(e);
|
|
360
|
+
if (!0 === t || "class_only" === t && !n) {
|
|
361
|
+
const t = g.getOwnPropertyDescriptors(e);
|
|
362
|
+
delete t[y];
|
|
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[b] && (o[b] = !0, o[_] = !0), (o.get || o.set) && (t[s] = {
|
|
367
|
+
[_]: !0,
|
|
368
|
+
[b]: !0,
|
|
369
|
+
[w]: o[w],
|
|
370
|
+
[v]: e[s]
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return g.create(h(e), t);
|
|
374
|
+
}
|
|
375
|
+
{
|
|
376
|
+
const t = h(e);
|
|
377
|
+
if (null !== t && n) return {
|
|
378
|
+
...e
|
|
379
|
+
};
|
|
380
|
+
const r = g.create(t);
|
|
381
|
+
return g.assign(r, e);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function F(e, t = !1) {
|
|
386
|
+
return B(e) || E(e) || !k(e) || (D(e) > 1 && g.defineProperties(e, {
|
|
387
|
+
set: K,
|
|
388
|
+
add: K,
|
|
389
|
+
clear: K,
|
|
390
|
+
delete: K
|
|
391
|
+
}), g.freeze(e), t && A(e, (e, t) => {
|
|
392
|
+
F(t, !0);
|
|
393
|
+
}, !1)), e;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
var K = {
|
|
397
|
+
[v]: function() {
|
|
398
|
+
f(2);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
function B(e) {
|
|
403
|
+
return null === e || !z(e) || g.isFrozen(e);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
var J = "MapSet", W = "Patches", q = "ArrayMethods", H = {};
|
|
407
|
+
|
|
408
|
+
function Q(e) {
|
|
409
|
+
const t = H[e];
|
|
410
|
+
return t || f(0, e), t;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var G, X = e => !!H[e], Z = () => G;
|
|
414
|
+
|
|
415
|
+
function Y(e, t) {
|
|
416
|
+
t && (e.patchPlugin_ = Q(W), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function ee(e) {
|
|
420
|
+
te(e), e.drafts_.forEach(re), e.drafts_ = null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function te(e) {
|
|
424
|
+
e === G && (G = e.parent_);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
var ne = e => G = {
|
|
428
|
+
drafts_: [],
|
|
429
|
+
parent_: G,
|
|
430
|
+
immer_: e,
|
|
431
|
+
canAutoFreeze_: !0,
|
|
432
|
+
unfinalizedDrafts_: 0,
|
|
433
|
+
handledSet_: new Set,
|
|
434
|
+
processedForPatches_: new Set,
|
|
435
|
+
mapSetPlugin_: X(J) ? Q(J) : void 0,
|
|
436
|
+
arrayMethodsPlugin_: X(q) ? Q(q) : void 0
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
function re(e) {
|
|
440
|
+
const t = e[y];
|
|
441
|
+
0 === t.type_ || 1 === t.type_ ? t.revoke_() : t.revoked_ = !0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function se(e, t) {
|
|
445
|
+
t.unfinalizedDrafts_ = t.drafts_.length;
|
|
446
|
+
const n = t.drafts_[0];
|
|
447
|
+
if (void 0 !== e && e !== n) {
|
|
448
|
+
n[y].modified_ && (ee(t), f(4)), k(e) && (e = oe(t, e));
|
|
449
|
+
const {patchPlugin_: r} = t;
|
|
450
|
+
r && r.generateReplacementPatches_(n[y].base_, e, t);
|
|
451
|
+
} else e = oe(t, n);
|
|
452
|
+
return function(e, t, n = !1) {
|
|
453
|
+
!e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && F(t, n);
|
|
454
|
+
}(t, e, !0), ee(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_),
|
|
455
|
+
e !== u ? e : void 0;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function oe(e, t) {
|
|
459
|
+
if (B(t)) return t;
|
|
460
|
+
const n = t[y];
|
|
461
|
+
if (!n) {
|
|
462
|
+
return de(t, e.handledSet_, e);
|
|
463
|
+
}
|
|
464
|
+
if (!ie(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
|
+
ue(n, e);
|
|
472
|
+
}
|
|
473
|
+
return n.copy_;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function ae(e) {
|
|
477
|
+
e.finalized_ = !0, e.scope_.unfinalizedDrafts_--;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
var ie = (e, t) => e.scope_ === t, ce = [];
|
|
481
|
+
|
|
482
|
+
function le(e, t, n, r) {
|
|
483
|
+
const s = N(e), o = e.type_;
|
|
484
|
+
if (void 0 !== r) {
|
|
485
|
+
if (P(s, r, o) === t) return void R(s, r, n, o);
|
|
486
|
+
}
|
|
487
|
+
if (!e.draftLocations_) {
|
|
488
|
+
const t = e.draftLocations_ = new Map;
|
|
489
|
+
A(s, (e, n) => {
|
|
490
|
+
if (E(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) ?? ce;
|
|
497
|
+
for (const e of a) R(s, e, n, o);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function ue(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
|
+
ae(e);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function de(e, t, n) {
|
|
512
|
+
return !n.immer_.autoFreeze_ && n.unfinalizedDrafts_ < 1 || E(e) || t.has(e) || !k(e) || B(e) || (t.add(e),
|
|
513
|
+
A(e, (r, s) => {
|
|
514
|
+
if (E(s)) {
|
|
515
|
+
const t = s[y];
|
|
516
|
+
if (ie(t, n)) {
|
|
517
|
+
const n = U(t);
|
|
518
|
+
R(e, r, n, e.type_), ae(t);
|
|
519
|
+
}
|
|
520
|
+
} else k(s) && de(s, t, n);
|
|
521
|
+
})), e;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var ye = {
|
|
525
|
+
get(e, t) {
|
|
526
|
+
if (t === y) 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 = N(e);
|
|
531
|
+
if (!M(s, t, e.type_)) return function(e, t, n) {
|
|
532
|
+
const r = ge(t, n);
|
|
533
|
+
return r ? v in r ? r[v] : r.get?.call(e.draft_) : void 0;
|
|
534
|
+
}(e, s, t);
|
|
535
|
+
const o = s[t];
|
|
536
|
+
if (e.finalized_ || !k(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 === fe(e.base_, t)) {
|
|
542
|
+
me(e);
|
|
543
|
+
const n = 1 === e.type_ ? +t : t, r = Se(e.scope_, o, e, n);
|
|
544
|
+
return e.copy_[n] = r;
|
|
545
|
+
}
|
|
546
|
+
return o;
|
|
547
|
+
},
|
|
548
|
+
has: (e, t) => t in N(e),
|
|
549
|
+
ownKeys: e => Reflect.ownKeys(N(e)),
|
|
550
|
+
set(e, t, n) {
|
|
551
|
+
const r = ge(N(e), t);
|
|
552
|
+
if (r?.set) return r.set.call(e.draft_, n), !0;
|
|
553
|
+
if (!e.modified_) {
|
|
554
|
+
const r = fe(N(e), t), a = r?.[y];
|
|
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 || M(e.base_, t, e.type_))) return !0;
|
|
557
|
+
me(e), he(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 (E(n)) {
|
|
564
|
+
const s = n[y];
|
|
565
|
+
ie(s, r) && s.callbacks_.push(function() {
|
|
566
|
+
me(e);
|
|
567
|
+
const r = U(s);
|
|
568
|
+
le(e, n, r, t);
|
|
569
|
+
});
|
|
570
|
+
} else k(n) && e.callbacks_.push(function() {
|
|
571
|
+
const s = N(e);
|
|
572
|
+
3 === e.type_ ? s.has(n) && de(n, r.handledSet_, r) : P(s, t, e.type_) === n && r.drafts_.length > 1 && !0 === (e.assigned_.get(t) ?? !1) && e.copy_ && de(P(e.copy_, t, e.type_), r.handledSet_, r);
|
|
573
|
+
});
|
|
574
|
+
}(e, t, n)), !0;
|
|
575
|
+
},
|
|
576
|
+
deleteProperty: (e, t) => (me(e), void 0 !== fe(e.base_, t) || t in e.base_ ? (e.assigned_.set(t, !1),
|
|
577
|
+
he(e)) : e.assigned_.delete(t), e.copy_ && delete e.copy_[t], !0),
|
|
578
|
+
getOwnPropertyDescriptor(e, t) {
|
|
579
|
+
const n = N(e), r = Reflect.getOwnPropertyDescriptor(n, t);
|
|
580
|
+
return r ? {
|
|
581
|
+
[b]: !0,
|
|
582
|
+
[_]: 1 !== e.type_ || "length" !== t,
|
|
583
|
+
[w]: r[w],
|
|
584
|
+
[v]: n[t]
|
|
585
|
+
} : r;
|
|
586
|
+
},
|
|
587
|
+
defineProperty() {
|
|
588
|
+
f(11);
|
|
589
|
+
},
|
|
590
|
+
getPrototypeOf: e => h(e.base_),
|
|
591
|
+
setPrototypeOf() {
|
|
592
|
+
f(12);
|
|
593
|
+
}
|
|
594
|
+
}, pe = {};
|
|
595
|
+
|
|
596
|
+
for (let e in ye) {
|
|
597
|
+
let t = ye[e];
|
|
598
|
+
pe[e] = function() {
|
|
599
|
+
const e = arguments;
|
|
600
|
+
return e[0] = e[0][0], t.apply(this, e);
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function fe(e, t) {
|
|
605
|
+
const n = e[y];
|
|
606
|
+
return (n ? N(n) : e)[t];
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function ge(e, t) {
|
|
610
|
+
if (!(t in e)) return;
|
|
611
|
+
let n = h(e);
|
|
612
|
+
for (;n; ) {
|
|
613
|
+
const e = Object.getOwnPropertyDescriptor(n, t);
|
|
614
|
+
if (e) return e;
|
|
615
|
+
n = h(n);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function he(e) {
|
|
620
|
+
e.modified_ || (e.modified_ = !0, e.parent_ && he(e.parent_));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function me(e) {
|
|
624
|
+
e.copy_ || (e.assigned_ = new Map, e.copy_ = L(e.base_, e.scope_.immer_.useStrictShallowCopy_));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
pe.deleteProperty = function(e, t) {
|
|
628
|
+
return isNaN(parseInt(t)) && f(13), pe.set.call(this, e, t, void 0);
|
|
629
|
+
}, pe.set = function(e, t, n) {
|
|
630
|
+
return "length" !== t && isNaN(parseInt(t)) && f(14), ye.set.call(this, e[0], t, n, e[0]);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
function Se(e, t, n, r) {
|
|
634
|
+
const [s, o] = T(t) ? Q(J).proxyMap_(t, n) : I(t) ? Q(J).proxySet_(t, n) : function(e, t) {
|
|
635
|
+
const n = j(e), r = {
|
|
636
|
+
type_: n ? 1 : 0,
|
|
637
|
+
scope_: t ? t.scope_ : Z(),
|
|
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 = ye;
|
|
650
|
+
n && (s = [ r ], o = pe);
|
|
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_ ?? Z()).drafts_.push(s), o.callbacks_ = n?.callbacks_ ?? [], o.key_ = r,
|
|
655
|
+
n && void 0 !== r ? function(e, t, n) {
|
|
656
|
+
e.callbacks_.push(function(r) {
|
|
657
|
+
const s = t;
|
|
658
|
+
if (!s || !ie(s, r)) return;
|
|
659
|
+
r.mapSetPlugin_?.fixSetContents(s);
|
|
660
|
+
const o = U(s);
|
|
661
|
+
le(e, s.draft_ ?? s, o, n), ue(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 _e(e) {
|
|
671
|
+
if (!k(e) || B(e)) return e;
|
|
672
|
+
const t = e[y];
|
|
673
|
+
let n, r = !0;
|
|
674
|
+
if (t) {
|
|
675
|
+
if (!t.modified_) return t.base_;
|
|
676
|
+
t.finalized_ = !0, n = L(e, t.scope_.immer_.useStrictShallowCopy_), r = t.scope_.immer_.shouldUseStrictIteration();
|
|
677
|
+
} else n = L(e, !0);
|
|
678
|
+
return A(n, (e, t) => {
|
|
679
|
+
R(n, e, _e(t));
|
|
680
|
+
}, r), t && (t.finalized_ = !1), n;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
var we = (new class {
|
|
684
|
+
constructor(e) {
|
|
685
|
+
this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1,
|
|
686
|
+
this.produce = (e, t, n) => {
|
|
687
|
+
if (V(e) && !V(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 (V(t) || f(6), void 0 === n || V(n) || f(7), k(e)) {
|
|
697
|
+
const s = ne(this), o = Se(s, e, void 0);
|
|
698
|
+
let a = !0;
|
|
699
|
+
try {
|
|
700
|
+
r = t(o), a = !1;
|
|
701
|
+
} finally {
|
|
702
|
+
a ? ee(s) : te(s);
|
|
703
|
+
}
|
|
704
|
+
return Y(s, n), se(r, s);
|
|
705
|
+
}
|
|
706
|
+
if (!e || !z(e)) {
|
|
707
|
+
if (r = t(e), void 0 === r && (r = e), r === u && (r = void 0), this.autoFreeze_ && F(r, !0),
|
|
708
|
+
n) {
|
|
709
|
+
const t = [], s = [];
|
|
710
|
+
Q(W).generateReplacementPatches_(e, r, {
|
|
711
|
+
patches_: t,
|
|
712
|
+
inversePatches_: s
|
|
713
|
+
}), n(t, s);
|
|
714
|
+
}
|
|
715
|
+
return r;
|
|
716
|
+
}
|
|
717
|
+
f(1, e);
|
|
718
|
+
}, this.produceWithPatches = (e, t) => {
|
|
719
|
+
if (V(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
|
+
}, $(e?.autoFreeze) && this.setAutoFreeze(e.autoFreeze), $(e?.useStrictShallowCopy) && this.setUseStrictShallowCopy(e.useStrictShallowCopy),
|
|
725
|
+
$(e?.useStrictIteration) && this.setUseStrictIteration(e.useStrictIteration);
|
|
726
|
+
}
|
|
727
|
+
createDraft(e) {
|
|
728
|
+
k(e) || f(8), E(e) && (e = function(e) {
|
|
729
|
+
E(e) || f(10, e);
|
|
730
|
+
return _e(e);
|
|
731
|
+
}(e));
|
|
732
|
+
const t = ne(this), n = Se(t, e, void 0);
|
|
733
|
+
return n[y].isManual_ = !0, te(t), n;
|
|
734
|
+
}
|
|
735
|
+
finishDraft(e, t) {
|
|
736
|
+
const n = e && e[y];
|
|
737
|
+
n && n.isManual_ || f(9);
|
|
738
|
+
const {scope_: r} = n;
|
|
739
|
+
return Y(r, t), se(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 = Q(W).applyPatches_;
|
|
764
|
+
return E(e) ? r(e, t) : this.produce(e, e => r(e, t));
|
|
765
|
+
}
|
|
766
|
+
}).produce, be = (e, t) => {
|
|
292
767
|
const n = Date.now();
|
|
293
768
|
if (/\(\.*\+\?\)\+/.test(e) || /\(\.*\?\)\*/.test(e)) return !1;
|
|
294
769
|
if (e.length > 500) return !1;
|
|
@@ -299,35 +774,35 @@ var l = a({
|
|
|
299
774
|
} catch {
|
|
300
775
|
return !1;
|
|
301
776
|
}
|
|
302
|
-
},
|
|
777
|
+
}, ve = () => {
|
|
303
778
|
if ("undefined" != typeof crypto && "function" == typeof crypto.randomUUID) try {
|
|
304
779
|
return crypto.randomUUID();
|
|
305
780
|
} catch {}
|
|
306
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.");
|
|
307
|
-
},
|
|
782
|
+
}, Ee = "undefined" != typeof crypto && void 0 !== crypto.subtle && "function" == typeof crypto.subtle.generateKey, ke = async (e, t) => {
|
|
308
783
|
const n = (new TextEncoder).encode(JSON.stringify(e)), r = await crypto.subtle.encrypt({
|
|
309
784
|
name: "AES-GCM",
|
|
310
785
|
iv: t.iv
|
|
311
786
|
}, t.key, n), s = new Uint8Array(t.iv.length + r.byteLength);
|
|
312
787
|
return s.set(t.iv), s.set(new Uint8Array(r), t.iv.length), btoa(String.fromCharCode(...s));
|
|
313
|
-
},
|
|
788
|
+
}, xe = async (e, t) => {
|
|
314
789
|
const n = Uint8Array.from(atob(e), e => e.charCodeAt(0)), r = n.slice(0, 12), s = n.slice(12), o = await crypto.subtle.decrypt({
|
|
315
790
|
name: "AES-GCM",
|
|
316
791
|
iv: r
|
|
317
792
|
}, t.key, s);
|
|
318
793
|
return JSON.parse((new TextDecoder).decode(o));
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
},
|
|
794
|
+
}, Oe = null, Ce = e => {
|
|
795
|
+
Oe && Oe(e);
|
|
796
|
+
}, Ae = (e, t, n) => {
|
|
322
797
|
e.set(t instanceof RegExp ? t.source : t, n);
|
|
323
|
-
},
|
|
798
|
+
}, De = (e, t, n, r) => {
|
|
324
799
|
if (0 === e.size) return !0;
|
|
325
800
|
for (const [s, o] of e) {
|
|
326
801
|
let e;
|
|
327
|
-
if (e = "function" == typeof s ? s(t, r) :
|
|
802
|
+
if (e = "function" == typeof s ? s(t, r) : be(s, t), e) return o.includes(n) || o.includes("admin");
|
|
328
803
|
}
|
|
329
804
|
return !1;
|
|
330
|
-
},
|
|
805
|
+
}, Me = e => {
|
|
331
806
|
if ("string" == typeof e) {
|
|
332
807
|
let t = e.replace(/&#[xX]?[0-9a-fA-F]+;?/g, e => {
|
|
333
808
|
const t = e.match(/&#x([0-9a-fA-F]+);?/i);
|
|
@@ -343,20 +818,20 @@ var l = a({
|
|
|
343
818
|
if (e && "object" == typeof e && !Array.isArray(e)) {
|
|
344
819
|
if (Object.getPrototypeOf(e) === Object.prototype) {
|
|
345
820
|
const t = {};
|
|
346
|
-
for (const [n, r] of Object.entries(e)) t[n] =
|
|
821
|
+
for (const [n, r] of Object.entries(e)) t[n] = Me(r);
|
|
347
822
|
return t;
|
|
348
823
|
}
|
|
349
824
|
return e;
|
|
350
825
|
}
|
|
351
|
-
return Array.isArray(e) ? e.map(e =>
|
|
352
|
-
},
|
|
826
|
+
return Array.isArray(e) ? e.map(e => Me(e)) : e;
|
|
827
|
+
}, Pe = e => /^([a-zA-Z0-9_.-][a-zA-Z0-9_.-]*)$/.test(e) && e.length <= 256 && e.length > 0, Re = (e, t, n, r) => {
|
|
353
828
|
const s = {
|
|
354
|
-
id:
|
|
829
|
+
id: ve(),
|
|
355
830
|
purpose: n,
|
|
356
831
|
granted: r,
|
|
357
832
|
timestamp: Date.now()
|
|
358
833
|
}, o = e.get(t) || [];
|
|
359
|
-
return o.push(s), e.set(t, o),
|
|
834
|
+
return o.push(s), e.set(t, o), Ce({
|
|
360
835
|
timestamp: Date.now(),
|
|
361
836
|
action: "set",
|
|
362
837
|
key: `consent:${n}`,
|
|
@@ -367,11 +842,11 @@ var l = a({
|
|
|
367
842
|
|
|
368
843
|
i();
|
|
369
844
|
|
|
370
|
-
var
|
|
845
|
+
var je = e => `${e}_`;
|
|
371
846
|
|
|
372
847
|
i();
|
|
373
848
|
|
|
374
|
-
var
|
|
849
|
+
var Te = () => {
|
|
375
850
|
try {
|
|
376
851
|
0;
|
|
377
852
|
const e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : {};
|
|
@@ -379,31 +854,42 @@ var k = () => {
|
|
|
379
854
|
} catch {
|
|
380
855
|
return !1;
|
|
381
856
|
}
|
|
382
|
-
},
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
857
|
+
}, Ie = () => "undefined" != typeof window ? window.localStorage : null, ze = () => {
|
|
858
|
+
const e = new Map;
|
|
859
|
+
return {
|
|
860
|
+
getItem: t => e.get(t) || null,
|
|
861
|
+
setItem: (t, n) => e.set(t, n),
|
|
862
|
+
removeItem: t => e.delete(t),
|
|
863
|
+
key: t => Array.from(e.keys())[t] || null,
|
|
864
|
+
get length() {
|
|
865
|
+
return e.size;
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
}, Ve = n => {
|
|
869
|
+
const r = new Map, s = new Map, o = new Map, a = new Set, i = new Map, u = new Set, d = new Map, y = new Map, p = new Map, f = new Map, g = new Map, h = new Map, m = new Map, S = new Map, _ = n?.namespace || "gstate", w = n?.silent ?? !1, b = n?.debounceTime ?? 150, v = n?.version ?? 0, E = n?.storage || Ie(), k = n?.onError, x = n?.maxObjectSize ?? 0, O = n?.maxTotalSize ?? 0, C = n?.encryptionKey ?? null, A = n?.validateInput ?? !0, D = n?.auditEnabled ?? !0, M = n?.userId, P = n?.immer ?? !0, R = n?.persistByDefault ?? n?.persistence ?? n?.persist ?? !1;
|
|
870
|
+
n?.accessRules && n.accessRules.forEach(e => Ae(m, e.pattern, e.permissions));
|
|
871
|
+
let j, T = !1, I = !1, z = !1, V = 0, $ = null, N = null;
|
|
872
|
+
const U = new Promise(e => {
|
|
873
|
+
j = e;
|
|
874
|
+
}), L = () => `${_}_`, K = () => ({
|
|
875
|
+
store: r,
|
|
876
|
+
versions: s,
|
|
877
|
+
sizes: o,
|
|
878
|
+
totalSize: V,
|
|
879
|
+
storage: E,
|
|
880
|
+
config: n || {},
|
|
881
|
+
diskQueue: g,
|
|
882
|
+
encryptionKey: C,
|
|
883
|
+
audit: q,
|
|
884
|
+
onError: k,
|
|
885
|
+
silent: w,
|
|
886
|
+
debounceTime: b,
|
|
887
|
+
currentVersion: v
|
|
888
|
+
}), B = () => ({
|
|
889
|
+
plugins: f,
|
|
890
|
+
onError: k,
|
|
891
|
+
silent: w
|
|
892
|
+
}), J = e => {
|
|
407
893
|
if (null == e) return 0;
|
|
408
894
|
const t = typeof e;
|
|
409
895
|
if ("boolean" === t) return 4;
|
|
@@ -422,7 +908,7 @@ var k = () => {
|
|
|
422
908
|
}
|
|
423
909
|
}
|
|
424
910
|
return n;
|
|
425
|
-
},
|
|
911
|
+
}, W = (e, t) => {
|
|
426
912
|
((e, t, n) => {
|
|
427
913
|
if (0 !== e.plugins.size) for (const r of e.plugins.values()) {
|
|
428
914
|
const s = r.hooks?.[t];
|
|
@@ -436,71 +922,71 @@ var k = () => {
|
|
|
436
922
|
}) : e.silent;
|
|
437
923
|
}
|
|
438
924
|
}
|
|
439
|
-
})(
|
|
440
|
-
},
|
|
441
|
-
|
|
925
|
+
})(B(), e, t);
|
|
926
|
+
}, q = (e, t, n, r) => {
|
|
927
|
+
D && null !== Oe && Ce && Ce({
|
|
442
928
|
timestamp: Date.now(),
|
|
443
929
|
action: e,
|
|
444
930
|
key: t,
|
|
445
|
-
userId:
|
|
931
|
+
userId: M,
|
|
446
932
|
success: n,
|
|
447
933
|
error: r
|
|
448
934
|
});
|
|
449
|
-
},
|
|
450
|
-
const
|
|
451
|
-
if (!
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
if (!
|
|
455
|
-
const t =
|
|
456
|
-
t && (t.delete(
|
|
935
|
+
}, H = n => {
|
|
936
|
+
const r = y.get(n);
|
|
937
|
+
if (!r) return;
|
|
938
|
+
const o = new Set, a = r.selector(e => (o.add(e), y.has(e) ? y.get(e).lastValue : Z.get(e)));
|
|
939
|
+
r.deps.forEach(e => {
|
|
940
|
+
if (!o.has(e)) {
|
|
941
|
+
const t = p.get(e);
|
|
942
|
+
t && (t.delete(n), 0 === t.size && p.delete(e));
|
|
457
943
|
}
|
|
458
|
-
}),
|
|
459
|
-
|
|
460
|
-
}),
|
|
461
|
-
|
|
462
|
-
},
|
|
944
|
+
}), o.forEach(e => {
|
|
945
|
+
r.deps.has(e) || (p.has(e) || p.set(e, new Set), p.get(e).add(n));
|
|
946
|
+
}), r.deps = o, t(r.lastValue, a) || (r.lastValue = P && null !== a && "object" == typeof a ? F(e(a), !0) : a,
|
|
947
|
+
s.set(n, (s.get(n) || 0) + 1), Q(n));
|
|
948
|
+
}, Q = e => {
|
|
463
949
|
if (e) {
|
|
464
|
-
if (
|
|
465
|
-
const t =
|
|
466
|
-
for (const e of t)
|
|
950
|
+
if (p.has(e)) {
|
|
951
|
+
const t = p.get(e);
|
|
952
|
+
for (const e of t) H(e);
|
|
467
953
|
}
|
|
468
954
|
const t = d.get(e);
|
|
469
955
|
if (t) {
|
|
470
|
-
const n =
|
|
956
|
+
const n = Z.get(e);
|
|
471
957
|
for (const r of t) try {
|
|
472
958
|
r(n);
|
|
473
959
|
} catch (t) {
|
|
474
960
|
const n = t instanceof Error ? t : new Error(String(t));
|
|
475
|
-
|
|
961
|
+
k && k(n, {
|
|
476
962
|
operation: "watcher",
|
|
477
963
|
key: e
|
|
478
964
|
});
|
|
479
965
|
}
|
|
480
966
|
}
|
|
481
|
-
const n =
|
|
967
|
+
const n = i.get(e);
|
|
482
968
|
if (n) for (const t of n) try {
|
|
483
969
|
t();
|
|
484
970
|
} catch (t) {
|
|
485
971
|
const n = t instanceof Error ? t : new Error(String(t));
|
|
486
|
-
|
|
972
|
+
k && k(n, {
|
|
487
973
|
operation: "keyListener",
|
|
488
974
|
key: e
|
|
489
975
|
});
|
|
490
976
|
}
|
|
491
977
|
}
|
|
492
|
-
if (
|
|
978
|
+
if (T) I = !0; else for (const e of a) try {
|
|
493
979
|
e();
|
|
494
980
|
} catch (e) {
|
|
495
981
|
const t = e instanceof Error ? e : new Error(String(e));
|
|
496
|
-
|
|
982
|
+
k && k(t, {
|
|
497
983
|
operation: "listener"
|
|
498
984
|
});
|
|
499
985
|
}
|
|
500
|
-
},
|
|
986
|
+
}, G = async () => {
|
|
501
987
|
(async e => {
|
|
502
988
|
if (!e.storage) return;
|
|
503
|
-
const {store: t, config: n, diskQueue: r, storage: s, encryptionKey: o, audit: a, onError: i, silent: c, currentVersion: l} = e, u =
|
|
989
|
+
const {store: t, config: n, diskQueue: r, storage: s, encryptionKey: o, audit: a, onError: i, silent: c, currentVersion: l} = e, u = je(n.namespace || "gstate");
|
|
504
990
|
try {
|
|
505
991
|
const e = {};
|
|
506
992
|
let r;
|
|
@@ -523,15 +1009,15 @@ var k = () => {
|
|
|
523
1009
|
key: "FULL_STATE"
|
|
524
1010
|
});
|
|
525
1011
|
}
|
|
526
|
-
const
|
|
1012
|
+
const d = Array.from(r.entries());
|
|
527
1013
|
r.clear();
|
|
528
|
-
for (const [t, n] of
|
|
1014
|
+
for (const [t, n] of d) try {
|
|
529
1015
|
if (!t || !/^[a-zA-Z0-9_.-]+$/.test(t) || t.length > 256) continue;
|
|
530
1016
|
let r = n.value;
|
|
531
1017
|
const i = n.options.encoded || n.options.encrypted || n.options.secure;
|
|
532
1018
|
if (n.options.encrypted) {
|
|
533
1019
|
if (!o) throw new Error(`Encryption key missing for "${t}"`);
|
|
534
|
-
r = await
|
|
1020
|
+
r = await ke(n.value, o);
|
|
535
1021
|
} else i ? r = btoa(JSON.stringify(n.value)) : "object" == typeof n.value && null !== n.value && (r = JSON.stringify(n.value));
|
|
536
1022
|
s.setItem(`${u}${t}`, JSON.stringify({
|
|
537
1023
|
v: e.versions.get(t) || 1,
|
|
@@ -549,83 +1035,83 @@ var k = () => {
|
|
|
549
1035
|
key: t
|
|
550
1036
|
});
|
|
551
1037
|
}
|
|
552
|
-
})(
|
|
553
|
-
},
|
|
554
|
-
_setSilently: (t,
|
|
555
|
-
const
|
|
556
|
-
|
|
1038
|
+
})(K());
|
|
1039
|
+
}, X = {}, Z = {
|
|
1040
|
+
_setSilently: (t, n) => {
|
|
1041
|
+
const a = o.get(t) || 0, i = P && null !== n && "object" == typeof n ? F(e(n), !0) : n, c = (x > 0 || O > 0) && !Te() ? J(i) : 0;
|
|
1042
|
+
V = V - a + c, o.set(t, c), r.set(t, i), s.set(t, (s.get(t) || 0) + 1), N = null;
|
|
557
1043
|
},
|
|
558
1044
|
_registerMethod: (e, t, n) => {
|
|
559
1045
|
const r = e => "__proto__" === e || "constructor" === e || "prototype" === e;
|
|
560
|
-
r(e) || r(t) || (
|
|
1046
|
+
r(e) || r(t) || (X[e] || (X[e] = {}), X[e][t] = n);
|
|
561
1047
|
},
|
|
562
|
-
set: (i, c
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
565
|
-
if (!
|
|
566
|
-
const d =
|
|
567
|
-
|
|
568
|
-
key:
|
|
1048
|
+
set: (a, i, c = {}) => {
|
|
1049
|
+
const l = r.get(a), u = P && "function" == typeof i ? we(l, i) : i;
|
|
1050
|
+
if (A && !Pe(a)) return !1;
|
|
1051
|
+
if (!De(m, a, "write", M)) return q("set", a, !1, "RBAC Denied"), !1;
|
|
1052
|
+
const d = A ? Me(u) : u, y = o.get(a) || 0;
|
|
1053
|
+
W("onBeforeSet", {
|
|
1054
|
+
key: a,
|
|
569
1055
|
value: d,
|
|
570
|
-
store:
|
|
571
|
-
version:
|
|
1056
|
+
store: Z,
|
|
1057
|
+
version: s.get(a) || 0
|
|
572
1058
|
});
|
|
573
|
-
const p =
|
|
574
|
-
if (!t(
|
|
575
|
-
const e = (
|
|
576
|
-
if (
|
|
577
|
-
const t = new Error(`Object size (${e} bytes) exceeds maxObjectSize (${
|
|
578
|
-
|
|
1059
|
+
const p = P && null !== d && "object" == typeof d ? F(e(d), !0) : d;
|
|
1060
|
+
if (!t(l, p)) {
|
|
1061
|
+
const e = (x > 0 || O > 0) && !Te() ? J(p) : 0;
|
|
1062
|
+
if (x > 0 && e > x) {
|
|
1063
|
+
const t = new Error(`Object size (${e} bytes) exceeds maxObjectSize (${x} bytes)`);
|
|
1064
|
+
return k && k(t, {
|
|
579
1065
|
operation: "set",
|
|
580
|
-
key:
|
|
581
|
-
});
|
|
1066
|
+
key: a
|
|
1067
|
+
}), !1;
|
|
582
1068
|
}
|
|
583
|
-
if (
|
|
584
|
-
const t =
|
|
585
|
-
if (t >
|
|
586
|
-
const e = new Error(`Total store size (${t} bytes) exceeds limit (${
|
|
587
|
-
|
|
1069
|
+
if (O > 0) {
|
|
1070
|
+
const t = V - y + e;
|
|
1071
|
+
if (t > O) {
|
|
1072
|
+
const e = new Error(`Total store size (${t} bytes) exceeds limit (${O} bytes)`);
|
|
1073
|
+
return k && k(e, {
|
|
588
1074
|
operation: "set"
|
|
589
|
-
});
|
|
1075
|
+
}), !1;
|
|
590
1076
|
}
|
|
591
1077
|
}
|
|
592
|
-
|
|
593
|
-
const t =
|
|
594
|
-
return t && (
|
|
1078
|
+
V = V - y + e, o.set(a, e), r.set(a, p), s.set(a, (s.get(a) || 0) + 1), N = null;
|
|
1079
|
+
const t = c.persist ?? R;
|
|
1080
|
+
return t && (g.set(a, {
|
|
595
1081
|
value: p,
|
|
596
1082
|
options: {
|
|
597
|
-
...
|
|
1083
|
+
...c,
|
|
598
1084
|
persist: t,
|
|
599
|
-
encoded:
|
|
1085
|
+
encoded: c.encoded || n?.encoded
|
|
600
1086
|
}
|
|
601
|
-
}),
|
|
602
|
-
key:
|
|
1087
|
+
}), $ && clearTimeout($), $ = setTimeout(G, b)), W("onSet", {
|
|
1088
|
+
key: a,
|
|
603
1089
|
value: p,
|
|
604
|
-
store:
|
|
605
|
-
version:
|
|
606
|
-
}),
|
|
1090
|
+
store: Z,
|
|
1091
|
+
version: s.get(a)
|
|
1092
|
+
}), q("set", a, !0), Q(a), !0;
|
|
607
1093
|
}
|
|
608
1094
|
return !1;
|
|
609
1095
|
},
|
|
610
1096
|
get: e => {
|
|
611
|
-
if (!
|
|
612
|
-
const t =
|
|
613
|
-
return
|
|
614
|
-
store:
|
|
1097
|
+
if (!De(m, e, "read", M)) return q("get", e, !1, "RBAC Denied"), null;
|
|
1098
|
+
const t = r.get(e);
|
|
1099
|
+
return W("onGet", {
|
|
1100
|
+
store: Z,
|
|
615
1101
|
key: e,
|
|
616
1102
|
value: t
|
|
617
|
-
}),
|
|
1103
|
+
}), q("get", e, !0), t;
|
|
618
1104
|
},
|
|
619
1105
|
compute: (e, t) => {
|
|
620
1106
|
try {
|
|
621
|
-
return
|
|
1107
|
+
return y.has(e) || (y.set(e, {
|
|
622
1108
|
selector: t,
|
|
623
1109
|
lastValue: null,
|
|
624
1110
|
deps: new Set
|
|
625
|
-
}),
|
|
1111
|
+
}), H(e)), y.get(e).lastValue;
|
|
626
1112
|
} catch (t) {
|
|
627
1113
|
const n = t instanceof Error ? t : new Error(String(t));
|
|
628
|
-
return
|
|
1114
|
+
return k && k(n, {
|
|
629
1115
|
operation: "compute",
|
|
630
1116
|
key: e
|
|
631
1117
|
}), null;
|
|
@@ -639,50 +1125,51 @@ var k = () => {
|
|
|
639
1125
|
};
|
|
640
1126
|
},
|
|
641
1127
|
remove: e => {
|
|
642
|
-
if (!
|
|
643
|
-
const t =
|
|
644
|
-
return n && (
|
|
645
|
-
store:
|
|
1128
|
+
if (!De(m, e, "delete", M)) return q("delete", e, !1, "RBAC Denied"), !1;
|
|
1129
|
+
const t = r.get(e), n = r.delete(e);
|
|
1130
|
+
return n && (V -= o.get(e) || 0, o.delete(e), W("onRemove", {
|
|
1131
|
+
store: Z,
|
|
646
1132
|
key: e,
|
|
647
1133
|
value: t
|
|
648
|
-
}),
|
|
649
|
-
|
|
1134
|
+
}), N = null), s.set(e, (s.get(e) || 0) + 1), E && E.removeItem(`${L()}${e}`), q("delete", e, !0),
|
|
1135
|
+
Q(e), n;
|
|
650
1136
|
},
|
|
651
|
-
delete: e =>
|
|
1137
|
+
delete: e => Z.remove(e),
|
|
652
1138
|
deleteAll: () => {
|
|
653
|
-
if (Array.from(
|
|
654
|
-
const e =
|
|
655
|
-
for (let
|
|
656
|
-
const n =
|
|
657
|
-
n
|
|
1139
|
+
if (Array.from(r.keys()).forEach(e => Z.remove(e)), E) {
|
|
1140
|
+
const e = L(), t = [], n = E.length || 0;
|
|
1141
|
+
for (let r = 0; r < n; r++) {
|
|
1142
|
+
const n = E.key(r);
|
|
1143
|
+
n && n.startsWith(e) && t.push(n);
|
|
658
1144
|
}
|
|
1145
|
+
for (const e of t) E.removeItem(e);
|
|
659
1146
|
}
|
|
660
|
-
return
|
|
1147
|
+
return V = 0, o.clear(), N = null, !0;
|
|
661
1148
|
},
|
|
662
|
-
list: () => Object.fromEntries(
|
|
1149
|
+
list: () => Object.fromEntries(r.entries()),
|
|
663
1150
|
use: e => {
|
|
664
|
-
|
|
1151
|
+
u.add(e);
|
|
665
1152
|
},
|
|
666
1153
|
transaction: e => {
|
|
667
|
-
|
|
668
|
-
store:
|
|
1154
|
+
T = !0, W("onTransaction", {
|
|
1155
|
+
store: Z,
|
|
669
1156
|
key: "START"
|
|
670
1157
|
});
|
|
671
1158
|
try {
|
|
672
1159
|
e();
|
|
673
1160
|
} finally {
|
|
674
|
-
|
|
675
|
-
store:
|
|
1161
|
+
T = !1, W("onTransaction", {
|
|
1162
|
+
store: Z,
|
|
676
1163
|
key: "END"
|
|
677
|
-
}),
|
|
1164
|
+
}), I && (I = !1, Q());
|
|
678
1165
|
}
|
|
679
1166
|
},
|
|
680
1167
|
destroy: () => {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
store:
|
|
684
|
-
}),
|
|
685
|
-
|
|
1168
|
+
$ && (clearTimeout($), $ = null), g.clear(), "undefined" != typeof window && window.removeEventListener("beforeunload", Y),
|
|
1169
|
+
W("onDestroy", {
|
|
1170
|
+
store: Z
|
|
1171
|
+
}), a.clear(), i.clear(), d.clear(), y.clear(), p.clear(), f.clear(), r.clear(),
|
|
1172
|
+
o.clear(), V = 0, m.clear(), S.clear(), s.clear(), h.clear(), u.clear();
|
|
686
1173
|
},
|
|
687
1174
|
_addPlugin: e => {
|
|
688
1175
|
((e, t, n) => {
|
|
@@ -697,25 +1184,25 @@ var k = () => {
|
|
|
697
1184
|
key: t.name
|
|
698
1185
|
}) : e.silent;
|
|
699
1186
|
}
|
|
700
|
-
})(
|
|
1187
|
+
})(B(), e, Z);
|
|
701
1188
|
},
|
|
702
1189
|
_removePlugin: e => {
|
|
703
|
-
|
|
1190
|
+
f.delete(e);
|
|
704
1191
|
},
|
|
705
1192
|
_subscribe: (e, t) => {
|
|
706
1193
|
if (t) {
|
|
707
|
-
|
|
708
|
-
const n =
|
|
1194
|
+
i.has(t) || i.set(t, new Set);
|
|
1195
|
+
const n = i.get(t);
|
|
709
1196
|
return n.add(e), () => {
|
|
710
|
-
n.delete(e), 0 === n.size &&
|
|
1197
|
+
n.delete(e), 0 === n.size && i.delete(t);
|
|
711
1198
|
};
|
|
712
1199
|
}
|
|
713
|
-
return
|
|
1200
|
+
return a.add(e), () => a.delete(e);
|
|
714
1201
|
},
|
|
715
|
-
_getVersion: e =>
|
|
716
|
-
addAccessRule: (e, t) => m
|
|
717
|
-
hasPermission: (e, t, n) =>
|
|
718
|
-
recordConsent: (e, t, n) =>
|
|
1202
|
+
_getVersion: e => s.get(e) ?? 0,
|
|
1203
|
+
addAccessRule: (e, t) => Ae(m, e, t),
|
|
1204
|
+
hasPermission: (e, t, n) => De(m, e, t, n),
|
|
1205
|
+
recordConsent: (e, t, n) => Re(S, e, t, n),
|
|
719
1206
|
hasConsent: (e, t) => ((e, t, n) => {
|
|
720
1207
|
const r = e.get(t);
|
|
721
1208
|
if (!r) return !1;
|
|
@@ -724,117 +1211,117 @@ var k = () => {
|
|
|
724
1211
|
if (t && t.purpose === n) return t.granted;
|
|
725
1212
|
}
|
|
726
1213
|
return !1;
|
|
727
|
-
})(
|
|
728
|
-
getConsents: e => ((e, t) => e.get(t) || [])(
|
|
729
|
-
revokeConsent: (e, t) => ((e, t, n) =>
|
|
1214
|
+
})(S, e, t),
|
|
1215
|
+
getConsents: e => ((e, t) => e.get(t) || [])(S, e),
|
|
1216
|
+
revokeConsent: (e, t) => ((e, t, n) => Re(e, t, n, !1))(S, e, t),
|
|
730
1217
|
exportUserData: e => ((e, t) => ({
|
|
731
1218
|
userId: t,
|
|
732
1219
|
exportedAt: Date.now(),
|
|
733
1220
|
consents: e.get(t) || []
|
|
734
|
-
}))(
|
|
1221
|
+
}))(S, e),
|
|
735
1222
|
deleteUserData: e => ((e, t) => {
|
|
736
1223
|
const n = e.get(t)?.length || 0;
|
|
737
1224
|
return e.delete(t), {
|
|
738
1225
|
success: !0,
|
|
739
1226
|
deletedConsents: n
|
|
740
1227
|
};
|
|
741
|
-
})(
|
|
742
|
-
getSnapshot: () => (
|
|
1228
|
+
})(S, e),
|
|
1229
|
+
getSnapshot: () => (N || (N = Object.fromEntries(r.entries())), N),
|
|
743
1230
|
get plugins() {
|
|
744
|
-
return
|
|
1231
|
+
return X;
|
|
745
1232
|
},
|
|
746
1233
|
get isReady() {
|
|
747
|
-
return
|
|
1234
|
+
return z;
|
|
748
1235
|
},
|
|
749
1236
|
get namespace() {
|
|
750
|
-
return
|
|
1237
|
+
return _;
|
|
751
1238
|
},
|
|
752
1239
|
get userId() {
|
|
753
|
-
return
|
|
1240
|
+
return M;
|
|
754
1241
|
},
|
|
755
|
-
whenReady: () =>
|
|
1242
|
+
whenReady: () => U
|
|
756
1243
|
};
|
|
757
1244
|
[ "addAccessRule", "recordConsent", "hasConsent", "getConsents", "revokeConsent", "exportUserData", "deleteUserData" ].forEach(e => {
|
|
758
|
-
const t =
|
|
759
|
-
t &&
|
|
1245
|
+
const t = Z[e];
|
|
1246
|
+
t && Z._registerMethod("security", e, t);
|
|
760
1247
|
});
|
|
761
|
-
const
|
|
762
|
-
|
|
1248
|
+
const Y = () => {
|
|
1249
|
+
g.size > 0 && G();
|
|
763
1250
|
};
|
|
764
|
-
if ("undefined" != typeof window && window.addEventListener("beforeunload",
|
|
765
|
-
|
|
766
|
-
const {storage:
|
|
767
|
-
if (
|
|
768
|
-
const
|
|
769
|
-
let
|
|
770
|
-
for (let e = 0; e < (
|
|
771
|
-
const t =
|
|
772
|
-
if (!t || !t.startsWith(
|
|
773
|
-
const n =
|
|
1251
|
+
if ("undefined" != typeof window && window.addEventListener("beforeunload", Y),
|
|
1252
|
+
E ? (async (t, n, r) => {
|
|
1253
|
+
const {storage: s, config: o, encryptionKey: a, audit: i, onError: c, silent: l, currentVersion: u, store: d, sizes: y, versions: p} = t, f = je(o.namespace || "gstate"), g = o.immer ?? !0;
|
|
1254
|
+
if (s) try {
|
|
1255
|
+
const l = {};
|
|
1256
|
+
let h = 0;
|
|
1257
|
+
for (let e = 0; e < (s.length || 0); e++) {
|
|
1258
|
+
const t = s.key(e);
|
|
1259
|
+
if (!t || !t.startsWith(f)) continue;
|
|
1260
|
+
const n = s.getItem(t);
|
|
774
1261
|
if (n) try {
|
|
775
|
-
const r = JSON.parse(n),
|
|
776
|
-
if (
|
|
777
|
-
|
|
1262
|
+
const r = JSON.parse(n), o = t.substring(f.length);
|
|
1263
|
+
if (h = Math.max(h, void 0 !== r._sys_v ? r._sys_v : r.v || 0), r.e && Date.now() > r.e) {
|
|
1264
|
+
s.removeItem(t), e--;
|
|
778
1265
|
continue;
|
|
779
1266
|
}
|
|
780
|
-
let
|
|
781
|
-
if (r._enc &&
|
|
782
|
-
|
|
783
|
-
} catch (e) {} else if (
|
|
784
|
-
|
|
1267
|
+
let c = r.d;
|
|
1268
|
+
if (r._enc && a) c = await xe(c, a); else if ("string" == typeof c) if (r._b64) try {
|
|
1269
|
+
c = JSON.parse(atob(c));
|
|
1270
|
+
} catch (e) {} else if (c.startsWith("{") || c.startsWith("[")) try {
|
|
1271
|
+
c = JSON.parse(c);
|
|
785
1272
|
} catch (e) {}
|
|
786
|
-
|
|
1273
|
+
l[o] = c, i("hydrate", o, !0);
|
|
787
1274
|
} catch (e) {
|
|
788
|
-
|
|
1275
|
+
i("hydrate", t, !1, String(e));
|
|
789
1276
|
const n = e instanceof Error ? e : new Error(String(e));
|
|
790
|
-
|
|
1277
|
+
c && c(n, {
|
|
791
1278
|
operation: "hydration",
|
|
792
1279
|
key: t
|
|
793
1280
|
});
|
|
794
1281
|
}
|
|
795
1282
|
}
|
|
796
|
-
const
|
|
797
|
-
Object.entries(
|
|
798
|
-
const
|
|
799
|
-
t.totalSize = t.totalSize -
|
|
800
|
-
}),
|
|
1283
|
+
const m = h < u && o.migrate ? o.migrate(l, h) : l;
|
|
1284
|
+
Object.entries(m).forEach(([r, s]) => {
|
|
1285
|
+
const o = g && null !== s && "object" == typeof s ? F(e(s), !0) : s, a = n(o), i = y.get(r) || 0;
|
|
1286
|
+
t.totalSize = t.totalSize - i + a, y.set(r, a), d.set(r, o), p.set(r, 1);
|
|
1287
|
+
}), r();
|
|
801
1288
|
} catch (e) {
|
|
802
1289
|
const t = e instanceof Error ? e : new Error(String(e));
|
|
803
|
-
|
|
1290
|
+
c && c(t, {
|
|
804
1291
|
operation: "hydration"
|
|
805
1292
|
});
|
|
806
1293
|
}
|
|
807
|
-
})(
|
|
808
|
-
|
|
809
|
-
}).then(() => {}) : (
|
|
810
|
-
const e =
|
|
1294
|
+
})(K(), e => (x > 0 || O > 0) && !Te() ? J(e) : 0, () => {
|
|
1295
|
+
z = !0, N = null, j(), Q();
|
|
1296
|
+
}).then(() => {}) : (z = !0, j()), n?.sync) {
|
|
1297
|
+
const e = n.sync, t = async () => {
|
|
811
1298
|
const {SyncEngine: t} = await Promise.resolve().then(() => (l(), c));
|
|
812
|
-
return new t(
|
|
1299
|
+
return new t(Z, e);
|
|
813
1300
|
};
|
|
814
|
-
let
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
return (await
|
|
818
|
-
}),
|
|
819
|
-
|
|
820
|
-
return (await
|
|
821
|
-
}),
|
|
822
|
-
|
|
823
|
-
return (await
|
|
824
|
-
}),
|
|
825
|
-
|
|
826
|
-
return (await
|
|
1301
|
+
let r = null;
|
|
1302
|
+
Z._registerMethod("sync", "flush", async () => {
|
|
1303
|
+
r || (r = t());
|
|
1304
|
+
return (await r).flush();
|
|
1305
|
+
}), Z._registerMethod("sync", "getState", async () => {
|
|
1306
|
+
r || (r = t());
|
|
1307
|
+
return (await r).getState();
|
|
1308
|
+
}), Z._registerMethod("sync", "onStateChange", async e => {
|
|
1309
|
+
r || (r = t());
|
|
1310
|
+
return (await r).onStateChange(e);
|
|
1311
|
+
}), Z._registerMethod("sync", "forceSync", async () => {
|
|
1312
|
+
r || (r = t());
|
|
1313
|
+
return (await r).sync();
|
|
827
1314
|
});
|
|
828
1315
|
}
|
|
829
|
-
return
|
|
1316
|
+
return Z;
|
|
830
1317
|
};
|
|
831
1318
|
|
|
832
1319
|
l();
|
|
833
1320
|
|
|
834
|
-
var
|
|
1321
|
+
var $e = null, Ne = () => $e;
|
|
835
1322
|
|
|
836
|
-
function
|
|
837
|
-
const
|
|
1323
|
+
function Ue(e, t) {
|
|
1324
|
+
const r = n.useMemo(() => t || $e, [ t ]), s = n.useMemo(() => {
|
|
838
1325
|
const e = () => {}, t = () => !1, n = () => null;
|
|
839
1326
|
return {
|
|
840
1327
|
set: t,
|
|
@@ -867,23 +1354,182 @@ function A(e, t) {
|
|
|
867
1354
|
},
|
|
868
1355
|
get userId() {}
|
|
869
1356
|
};
|
|
870
|
-
}, []), o =
|
|
1357
|
+
}, []), o = r || s, a = "function" == typeof e, i = a ? null : e, c = a ? e : null, l = n.useCallback(e => a ? o._subscribe(e) : o._subscribe(e, i), [ o, a, i ]), u = n.useCallback(() => a ? c(o.getSnapshot()) : o.get(i) ?? void 0, [ o, a, i, c ]), d = n.useCallback(() => {
|
|
871
1358
|
if (a) try {
|
|
872
1359
|
return c({});
|
|
873
1360
|
} catch {
|
|
874
1361
|
return;
|
|
875
1362
|
}
|
|
876
|
-
}, [ c, a ]),
|
|
1363
|
+
}, [ c, a ]), y = n.useSyncExternalStore(l, u, d), p = n.useCallback((e, t) => a ? (Te(),
|
|
877
1364
|
!1) : o.set(i, e, t), [ o, a, i ]);
|
|
878
|
-
return
|
|
879
|
-
a ?
|
|
1365
|
+
return n.useDebugValue(y, e => a ? `Selector: ${JSON.stringify(e)}` : `${i}: ${JSON.stringify(e)}`),
|
|
1366
|
+
a ? y : [ y, p ];
|
|
880
1367
|
}
|
|
881
1368
|
|
|
882
|
-
var
|
|
1369
|
+
var Le = new Map;
|
|
1370
|
+
|
|
1371
|
+
var Fe, Ke, Be, Je, We, qe, He = () => "undefined" == typeof window || void 0 === window.document, Qe = () => !He(), Ge = e => {
|
|
1372
|
+
const t = e?.ssrSafe ?? !0, n = e?.deferHydration ?? !1;
|
|
1373
|
+
let r = e?.storage;
|
|
1374
|
+
!r && t && He() && (r = ze());
|
|
1375
|
+
const s = Ve({
|
|
1376
|
+
...e,
|
|
1377
|
+
storage: r || void 0,
|
|
1378
|
+
persistByDefault: !n && (e?.persistByDefault ?? !1)
|
|
1379
|
+
});
|
|
1380
|
+
let o = !1, a = null;
|
|
1381
|
+
e?.initialState && He() && (Object.entries(e.initialState).forEach(([e, t]) => {
|
|
1382
|
+
s._setSilently(e, t);
|
|
1383
|
+
}), a = JSON.stringify(e.initialState));
|
|
1384
|
+
return Object.assign(s, {
|
|
1385
|
+
hydrate: async () => {
|
|
1386
|
+
if (!o && !He()) {
|
|
1387
|
+
if (t && !s.namespace.startsWith("async_")) {
|
|
1388
|
+
const t = s.getSnapshot(), n = Ve({
|
|
1389
|
+
...e,
|
|
1390
|
+
namespace: s.namespace,
|
|
1391
|
+
storage: void 0,
|
|
1392
|
+
persistByDefault: e?.persistByDefault ?? !1
|
|
1393
|
+
});
|
|
1394
|
+
Object.entries(t).forEach(([e, t]) => {
|
|
1395
|
+
n._setSilently(e, t);
|
|
1396
|
+
}), o = !0;
|
|
1397
|
+
} else o = !0;
|
|
1398
|
+
await s.whenReady();
|
|
1399
|
+
}
|
|
1400
|
+
},
|
|
1401
|
+
getSerializedState: () => He() ? JSON.stringify(s.getSnapshot()) : a,
|
|
1402
|
+
isHydrated: () => o || s.isReady
|
|
1403
|
+
});
|
|
1404
|
+
}, Xe = () => (Fe || (Fe = o("react"), Ke = Fe.useState, Be = Fe.useEffect, Je = Fe.useSyncExternalStore,
|
|
1405
|
+
We = Fe.useMemo, qe = Fe.useCallback), {
|
|
1406
|
+
React: Fe,
|
|
1407
|
+
useState: Ke,
|
|
1408
|
+
useEffect: Be,
|
|
1409
|
+
useSyncExternalStore: Je,
|
|
1410
|
+
useMemo: We,
|
|
1411
|
+
useCallback: qe
|
|
1412
|
+
}), Ze = () => {
|
|
1413
|
+
const {useSyncExternalStore: e} = Xe();
|
|
1414
|
+
return e(e => () => {}, () => Qe(), () => !0);
|
|
1415
|
+
}, Ye = () => {
|
|
1416
|
+
const {useState: e, useEffect: t} = Xe(), [n, r] = e(() => He()), [s, o] = e(() => He());
|
|
1417
|
+
return t(() => {
|
|
1418
|
+
if (He()) return;
|
|
1419
|
+
r(!0);
|
|
1420
|
+
const e = setTimeout(() => {
|
|
1421
|
+
o(!0), r(!1);
|
|
1422
|
+
}, 0);
|
|
1423
|
+
return () => clearTimeout(e);
|
|
1424
|
+
}, []), {
|
|
1425
|
+
isHydrated: s,
|
|
1426
|
+
isHydrating: n
|
|
1427
|
+
};
|
|
1428
|
+
}, et = e => {
|
|
1429
|
+
const {useState: t, useEffect: n, useMemo: r} = Xe(), [s, o] = t(() => !!He() || (e.isHydrated?.() ?? e.isReady));
|
|
1430
|
+
return n(() => {
|
|
1431
|
+
if (He()) return;
|
|
1432
|
+
const t = () => {
|
|
1433
|
+
const t = e.isHydrated?.() ?? e.isReady;
|
|
1434
|
+
o(t);
|
|
1435
|
+
}, n = setInterval(t, 50), r = e._subscribe(t);
|
|
1436
|
+
return t(), () => {
|
|
1437
|
+
clearInterval(n), r();
|
|
1438
|
+
};
|
|
1439
|
+
}, [ e ]), r(() => {
|
|
1440
|
+
if (s) return e;
|
|
1441
|
+
const t = () => {}, n = () => !1, r = () => null;
|
|
1442
|
+
return {
|
|
1443
|
+
set: n,
|
|
1444
|
+
get: r,
|
|
1445
|
+
remove: n,
|
|
1446
|
+
delete: n,
|
|
1447
|
+
deleteAll: n,
|
|
1448
|
+
list: () => ({}),
|
|
1449
|
+
compute: r,
|
|
1450
|
+
watch: () => () => {},
|
|
1451
|
+
use: t,
|
|
1452
|
+
transaction: t,
|
|
1453
|
+
destroy: t,
|
|
1454
|
+
_subscribe: () => () => {},
|
|
1455
|
+
_setSilently: t,
|
|
1456
|
+
_registerMethod: t,
|
|
1457
|
+
_addPlugin: t,
|
|
1458
|
+
_removePlugin: t,
|
|
1459
|
+
_getVersion: () => 0,
|
|
1460
|
+
get isReady() {
|
|
1461
|
+
return !1;
|
|
1462
|
+
},
|
|
1463
|
+
whenReady: () => Promise.resolve(),
|
|
1464
|
+
get plugins() {
|
|
1465
|
+
return {};
|
|
1466
|
+
},
|
|
1467
|
+
getSnapshot: () => ({}),
|
|
1468
|
+
get namespace() {
|
|
1469
|
+
return e.namespace;
|
|
1470
|
+
},
|
|
1471
|
+
get userId() {
|
|
1472
|
+
return e.userId;
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
}, [ e, s ]);
|
|
1476
|
+
}, tt = (e, t) => {
|
|
1477
|
+
const n = t?.extraArgument, r = async t => {
|
|
1478
|
+
if ("function" == typeof t) return t(r, () => e.getSnapshot(), n);
|
|
1479
|
+
if (t.type) {
|
|
1480
|
+
const {type: n, payload: r} = t, s = n.match(/^SET_(.+)$/i);
|
|
1481
|
+
if (s && s[1]) {
|
|
1482
|
+
const t = s[1].toLowerCase();
|
|
1483
|
+
e.set(t, r);
|
|
1484
|
+
}
|
|
1485
|
+
const o = n.match(/^REMOVE_(.+)$/i);
|
|
1486
|
+
if (o && o[1]) {
|
|
1487
|
+
const t = o[1].toLowerCase();
|
|
1488
|
+
e.remove(t);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
return Object.assign(e, {
|
|
1493
|
+
dispatch: r
|
|
1494
|
+
});
|
|
1495
|
+
}, nt = (e, t) => async (n, r) => {
|
|
1496
|
+
const s = r()[e];
|
|
1497
|
+
n({
|
|
1498
|
+
type: `SET_${e.toUpperCase()}`,
|
|
1499
|
+
payload: {
|
|
1500
|
+
...s,
|
|
1501
|
+
loading: !0,
|
|
1502
|
+
error: null
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
try {
|
|
1506
|
+
const r = await t();
|
|
1507
|
+
return n({
|
|
1508
|
+
type: `SET_${e.toUpperCase()}`,
|
|
1509
|
+
payload: {
|
|
1510
|
+
data: r,
|
|
1511
|
+
loading: !1,
|
|
1512
|
+
error: null
|
|
1513
|
+
}
|
|
1514
|
+
}), r;
|
|
1515
|
+
} catch (t) {
|
|
1516
|
+
throw n({
|
|
1517
|
+
type: `SET_${e.toUpperCase()}`,
|
|
1518
|
+
payload: {
|
|
1519
|
+
data: s?.data ?? null,
|
|
1520
|
+
loading: !1,
|
|
1521
|
+
error: t instanceof Error ? t : new Error(String(t))
|
|
1522
|
+
}
|
|
1523
|
+
}), t;
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
883
1526
|
|
|
884
1527
|
l();
|
|
885
1528
|
|
|
886
|
-
exports.addAccessRule = (e, t) =>
|
|
1529
|
+
exports.addAccessRule = (e, t) => Ne()?.addAccessRule(e, t), exports.all = e => ({
|
|
1530
|
+
type: "all",
|
|
1531
|
+
effects: e
|
|
1532
|
+
}), exports.analyticsPlugin = e => ({
|
|
887
1533
|
name: "gstate-analytics",
|
|
888
1534
|
hooks: {
|
|
889
1535
|
onSet: ({key: t, value: n}) => {
|
|
@@ -901,6 +1547,10 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
901
1547
|
}));
|
|
902
1548
|
}
|
|
903
1549
|
}
|
|
1550
|
+
}), exports.call = (e, ...t) => ({
|
|
1551
|
+
type: "call",
|
|
1552
|
+
fn: e,
|
|
1553
|
+
args: t
|
|
904
1554
|
}), exports.clearAccessRules = () => {}, exports.clearAllConsents = () => {}, exports.cloudSyncPlugin = e => {
|
|
905
1555
|
const {adapter: t, autoSyncInterval: n} = e, r = new Map, s = {
|
|
906
1556
|
lastSyncTimestamp: null,
|
|
@@ -955,8 +1605,16 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
955
1605
|
}
|
|
956
1606
|
}
|
|
957
1607
|
};
|
|
1608
|
+
}, exports.createActions = (e, t) => {
|
|
1609
|
+
const n = tt(e);
|
|
1610
|
+
return Object.assign(n.dispatch, t);
|
|
1611
|
+
}, exports.createAsyncAction = nt, exports.createAsyncActions = (e, t) => {
|
|
1612
|
+
tt(e);
|
|
1613
|
+
const n = {};
|
|
1614
|
+
for (const [e, r] of Object.entries(t)) n[e] = nt(e, r);
|
|
1615
|
+
return n;
|
|
958
1616
|
}, exports.createAsyncStore = (e, t) => {
|
|
959
|
-
const n = t?.key || "async_data", r = t?.store ||
|
|
1617
|
+
const n = t?.key || "async_data", r = t?.store || Ve({
|
|
960
1618
|
namespace: `async_${n}`,
|
|
961
1619
|
silent: !0
|
|
962
1620
|
});
|
|
@@ -1013,7 +1671,7 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1013
1671
|
name: "Firebase-Firestore",
|
|
1014
1672
|
save: async e => {
|
|
1015
1673
|
try {
|
|
1016
|
-
|
|
1674
|
+
Te();
|
|
1017
1675
|
return (() => {})("[Mock] Firestore Syncing:", e), !0;
|
|
1018
1676
|
} catch (e) {
|
|
1019
1677
|
return !1;
|
|
@@ -1043,7 +1701,49 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1043
1701
|
upsert: !0
|
|
1044
1702
|
})
|
|
1045
1703
|
})).ok
|
|
1046
|
-
}), exports.
|
|
1704
|
+
}), exports.createNextStore = e => {
|
|
1705
|
+
const t = Ge(e);
|
|
1706
|
+
return Object.assign(t, {
|
|
1707
|
+
useHydrated: Ze,
|
|
1708
|
+
useHydrationStatus: Ye,
|
|
1709
|
+
useDeferredStore: e => {
|
|
1710
|
+
const n = et(t), {useCallback: r} = Xe();
|
|
1711
|
+
return (e => {
|
|
1712
|
+
const {useSyncExternalStore: t} = Xe();
|
|
1713
|
+
return t(r(t => n._subscribe(t, e), [ n, e ]), r(() => n.get(e), [ n, e ]), () => {});
|
|
1714
|
+
})(e);
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
}, exports.createSSRStore = Ge, exports.createSaga = e => async (t, n) => {
|
|
1718
|
+
const r = async e => {
|
|
1719
|
+
switch (e.type) {
|
|
1720
|
+
case "call":
|
|
1721
|
+
return e.fn();
|
|
1722
|
+
|
|
1723
|
+
case "put":
|
|
1724
|
+
return t(e.action);
|
|
1725
|
+
|
|
1726
|
+
case "select":
|
|
1727
|
+
return e.selector(n());
|
|
1728
|
+
|
|
1729
|
+
case "all":
|
|
1730
|
+
return Promise.all(e.effects.map(r));
|
|
1731
|
+
|
|
1732
|
+
case "race":
|
|
1733
|
+
{
|
|
1734
|
+
const t = Object.fromEntries(Object.entries(e.effects).map(([e, t]) => [ e, r(t) ]));
|
|
1735
|
+
return Promise.race(Object.values(t));
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
default:
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
try {
|
|
1743
|
+
let t = e.next();
|
|
1744
|
+
for (;!t.done; ) await r(t.value), t = e.next();
|
|
1745
|
+
} catch (e) {}
|
|
1746
|
+
}, exports.createSqlRestAdapter = (e, t) => ({
|
|
1047
1747
|
name: "SQL-REST-API",
|
|
1048
1748
|
save: async n => {
|
|
1049
1749
|
const r = t();
|
|
@@ -1058,12 +1758,12 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1058
1758
|
credentials: "same-origin"
|
|
1059
1759
|
})).ok;
|
|
1060
1760
|
}
|
|
1061
|
-
}), exports.createStore =
|
|
1062
|
-
if (
|
|
1761
|
+
}), exports.createStore = Ve, exports.createThunkStore = tt, exports.debugPlugin = () => {
|
|
1762
|
+
if (Te()) return {
|
|
1063
1763
|
name: "gstate-debug-noop",
|
|
1064
1764
|
hooks: {}
|
|
1065
1765
|
};
|
|
1066
|
-
|
|
1766
|
+
Te();
|
|
1067
1767
|
return {
|
|
1068
1768
|
name: "gstate-debug",
|
|
1069
1769
|
hooks: {
|
|
@@ -1096,12 +1796,12 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1096
1796
|
}
|
|
1097
1797
|
}
|
|
1098
1798
|
};
|
|
1099
|
-
}, exports.deleteUserData = e => {
|
|
1100
|
-
const t =
|
|
1799
|
+
}, exports.dehydrateStore = e => JSON.stringify(e.getSnapshot()), exports.deleteUserData = e => {
|
|
1800
|
+
const t = Ne();
|
|
1101
1801
|
if (!t) throw new Error("[gstate] deleteUserData failed: No store found.");
|
|
1102
1802
|
return t.deleteUserData(e);
|
|
1103
1803
|
}, exports.deriveKeyFromPassword = async (e, t, n = 6e5) => {
|
|
1104
|
-
if (!
|
|
1804
|
+
if (!Ee) throw new Error("Web Crypto API not available");
|
|
1105
1805
|
const r = await crypto.subtle.importKey("raw", (new TextEncoder).encode(e), "PBKDF2", !1, [ "deriveKey" ]);
|
|
1106
1806
|
return {
|
|
1107
1807
|
key: await crypto.subtle.deriveKey({
|
|
@@ -1116,10 +1816,10 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1116
1816
|
iv: crypto.getRandomValues(new Uint8Array(12))
|
|
1117
1817
|
};
|
|
1118
1818
|
}, exports.destroyState = () => {
|
|
1119
|
-
|
|
1819
|
+
$e && ($e.destroy(), $e = null);
|
|
1120
1820
|
}, exports.destroySync = e => {
|
|
1121
|
-
const t =
|
|
1122
|
-
t && (t.destroy(),
|
|
1821
|
+
const t = Le.get(e);
|
|
1822
|
+
t && (t.destroy(), Le.delete(e));
|
|
1123
1823
|
}, exports.devToolsPlugin = e => {
|
|
1124
1824
|
const t = globalThis.__REDUX_DEVTOOLS_EXTENSION__;
|
|
1125
1825
|
if (!t?.connect) return {
|
|
@@ -1150,11 +1850,11 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1150
1850
|
iv: btoa(String.fromCharCode(...e.iv))
|
|
1151
1851
|
};
|
|
1152
1852
|
}, exports.exportUserData = e => {
|
|
1153
|
-
const t =
|
|
1853
|
+
const t = Ne();
|
|
1154
1854
|
if (!t) throw new Error("[gstate] exportUserData failed: No store found.");
|
|
1155
1855
|
return t.exportUserData(e);
|
|
1156
1856
|
}, exports.generateEncryptionKey = async () => {
|
|
1157
|
-
if (!
|
|
1857
|
+
if (!Ee) throw new Error("Web Crypto API not available");
|
|
1158
1858
|
return {
|
|
1159
1859
|
key: await crypto.subtle.generateKey({
|
|
1160
1860
|
name: "AES-GCM",
|
|
@@ -1163,15 +1863,16 @@ exports.addAccessRule = (e, t) => x()?.addAccessRule(e, t), exports.analyticsPlu
|
|
|
1163
1863
|
iv: crypto.getRandomValues(new Uint8Array(12))
|
|
1164
1864
|
};
|
|
1165
1865
|
}, exports.generateSalt = (e = 32) => crypto.getRandomValues(new Uint8Array(e)),
|
|
1166
|
-
exports.getConsents = e =>
|
|
1167
|
-
|
|
1866
|
+
exports.getConsents = e => Ne()?.getConsents(e) ?? [], exports.getSSRInitialState = e => e.getSnapshot(),
|
|
1867
|
+
exports.getStore = Ne, exports.gstate = (e, t) => {
|
|
1868
|
+
const n = Ve("string" == typeof t ? {
|
|
1168
1869
|
namespace: t
|
|
1169
1870
|
} : t);
|
|
1170
1871
|
e && Object.entries(e).forEach(([e, t]) => {
|
|
1171
1872
|
null === n.get(e) && n._setSilently(e, t);
|
|
1172
1873
|
});
|
|
1173
|
-
return "undefined" == typeof window ||
|
|
1174
|
-
window.rgs = n), Object.assign(e =>
|
|
1874
|
+
return "undefined" == typeof window || Te() || (window.gstate = n, window.gState = n,
|
|
1875
|
+
window.rgs = n), Object.assign(e => Ue(e, n), n);
|
|
1175
1876
|
}, exports.guardPlugin = e => ({
|
|
1176
1877
|
name: "gstate-guard",
|
|
1177
1878
|
hooks: {
|
|
@@ -1181,8 +1882,10 @@ exports.getConsents = e => x()?.getConsents(e) ?? [], exports.getStore = x, expo
|
|
|
1181
1882
|
s && s(n);
|
|
1182
1883
|
}
|
|
1183
1884
|
}
|
|
1184
|
-
}), exports.hasConsent = (e, t) =>
|
|
1185
|
-
exports.
|
|
1885
|
+
}), exports.hasConsent = (e, t) => Ne()?.hasConsent(e, t) ?? !1, exports.hasPermission = (e, t, n) => Ne()?.hasPermission(e, t, n) ?? !0,
|
|
1886
|
+
exports.hydrateOnClient = async e => {
|
|
1887
|
+
He() || await e.whenReady();
|
|
1888
|
+
}, exports.immerPlugin = () => ({
|
|
1186
1889
|
name: "gstate-immer",
|
|
1187
1890
|
hooks: {
|
|
1188
1891
|
onInstall: ({store: e}) => {
|
|
@@ -1267,14 +1970,19 @@ exports.immerPlugin = () => ({
|
|
|
1267
1970
|
}
|
|
1268
1971
|
};
|
|
1269
1972
|
}, exports.initState = e => {
|
|
1270
|
-
const t =
|
|
1271
|
-
return
|
|
1973
|
+
const t = Ve(e);
|
|
1974
|
+
return $e = t, t;
|
|
1272
1975
|
}, exports.initSync = (e, t) => {
|
|
1273
1976
|
const n = e.namespace;
|
|
1274
|
-
if (
|
|
1977
|
+
if (Le.has(n)) return Le.get(n);
|
|
1275
1978
|
const r = new exports.SyncEngine(e, t);
|
|
1276
|
-
return
|
|
1277
|
-
}, exports.
|
|
1979
|
+
return Le.set(n, r), r;
|
|
1980
|
+
}, exports.initializeFromSSR = (e, t) => {
|
|
1981
|
+
He() || Object.entries(t).forEach(([t, n]) => {
|
|
1982
|
+
e._setSilently(t, n);
|
|
1983
|
+
});
|
|
1984
|
+
}, exports.isClientSide = Qe, exports.isCryptoAvailable = Ee, exports.isServerSide = He,
|
|
1985
|
+
exports.logAudit = Ce, exports.loggerPlugin = e => ({
|
|
1278
1986
|
name: "gstate-logger",
|
|
1279
1987
|
hooks: {
|
|
1280
1988
|
onSet: ({key: e, value: t, version: n}) => {
|
|
@@ -1283,12 +1991,25 @@ exports.immerPlugin = () => ({
|
|
|
1283
1991
|
onRemove: ({key: e}) => {},
|
|
1284
1992
|
onTransaction: ({key: e}) => {}
|
|
1285
1993
|
}
|
|
1994
|
+
}), exports.put = e => ({
|
|
1995
|
+
type: "put",
|
|
1996
|
+
action: e
|
|
1997
|
+
}), exports.race = e => ({
|
|
1998
|
+
type: "race",
|
|
1999
|
+
effects: e
|
|
1286
2000
|
}), exports.recordConsent = (e, t, n) => {
|
|
1287
|
-
const r =
|
|
2001
|
+
const r = Ne();
|
|
1288
2002
|
if (!r) throw new Error("[gstate] recordConsent failed: No store found. call initState() first.");
|
|
1289
2003
|
return r.recordConsent(e, t, n);
|
|
1290
|
-
}, exports.
|
|
1291
|
-
|
|
2004
|
+
}, exports.rehydrateStore = (e, t) => {
|
|
2005
|
+
if (!He()) try {
|
|
2006
|
+
const n = JSON.parse(t);
|
|
2007
|
+
Object.entries(n).forEach(([t, n]) => {
|
|
2008
|
+
e._setSilently(t, n);
|
|
2009
|
+
});
|
|
2010
|
+
} catch (e) {}
|
|
2011
|
+
}, exports.revokeConsent = (e, t) => Ne()?.revokeConsent(e, t), exports.runSaga = (e, t) => (tt(e).dispatch(t),
|
|
2012
|
+
() => {}), exports.sanitizeValue = Me, exports.schemaPlugin = e => ({
|
|
1292
2013
|
name: "gstate-schema",
|
|
1293
2014
|
hooks: {
|
|
1294
2015
|
onSet: ({key: t, value: n}) => {
|
|
@@ -1300,8 +2021,11 @@ exports.schemaPlugin = e => ({
|
|
|
1300
2021
|
}
|
|
1301
2022
|
}
|
|
1302
2023
|
}
|
|
2024
|
+
}), exports.select = e => ({
|
|
2025
|
+
type: "select",
|
|
2026
|
+
selector: e
|
|
1303
2027
|
}), exports.setAuditLogger = e => {
|
|
1304
|
-
|
|
2028
|
+
Oe = e;
|
|
1305
2029
|
}, exports.snapshotPlugin = () => {
|
|
1306
2030
|
const e = new Map;
|
|
1307
2031
|
return {
|
|
@@ -1352,10 +2076,13 @@ exports.schemaPlugin = e => ({
|
|
|
1352
2076
|
}
|
|
1353
2077
|
}
|
|
1354
2078
|
};
|
|
1355
|
-
}, exports.
|
|
1356
|
-
|
|
2079
|
+
}, exports.take = e => ({
|
|
2080
|
+
type: "take",
|
|
2081
|
+
pattern: e
|
|
2082
|
+
}), exports.triggerSync = async e => {
|
|
2083
|
+
const t = e || $e?.namespace;
|
|
1357
2084
|
if (!t) return;
|
|
1358
|
-
const n =
|
|
2085
|
+
const n = Le.get(t);
|
|
1359
2086
|
n && await n.flush();
|
|
1360
2087
|
}, exports.undoRedoPlugin = e => {
|
|
1361
2088
|
let t = [], n = -1, r = !1;
|
|
@@ -1389,21 +2116,22 @@ exports.schemaPlugin = e => ({
|
|
|
1389
2116
|
}
|
|
1390
2117
|
}
|
|
1391
2118
|
};
|
|
1392
|
-
}, exports.useGState =
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
2119
|
+
}, exports.useDeferredStore = et, exports.useGState = Ue, exports.useHydrated = Ze,
|
|
2120
|
+
exports.useHydrationStatus = Ye, exports.useIsStoreReady = e => {
|
|
2121
|
+
const t = e || $e, r = n.useMemo(() => e => t ? t._subscribe(e) : () => {}, [ t ]);
|
|
2122
|
+
return n.useSyncExternalStore(r, () => !!t && t.isReady, () => !0);
|
|
2123
|
+
}, exports.useSimpleState = Ue, exports.useStore = Ue, exports.useSyncStatus = () => {
|
|
2124
|
+
const [e, t] = n.useState({
|
|
1397
2125
|
isOnline: !0,
|
|
1398
2126
|
isSyncing: !1,
|
|
1399
2127
|
lastSyncTimestamp: null,
|
|
1400
2128
|
pendingChanges: 0,
|
|
1401
2129
|
conflicts: 0
|
|
1402
2130
|
});
|
|
1403
|
-
return
|
|
2131
|
+
return n.useEffect(() => {
|
|
1404
2132
|
const e = () => {
|
|
1405
2133
|
let e = !0, n = !1, r = 0, s = 0;
|
|
1406
|
-
|
|
2134
|
+
Le.forEach(t => {
|
|
1407
2135
|
const o = t.getState();
|
|
1408
2136
|
e = e && o.isOnline, n = n || o.isSyncing, r += o.pendingChanges, s += o.conflicts;
|
|
1409
2137
|
}), t({
|
|
@@ -1415,26 +2143,26 @@ exports.schemaPlugin = e => ({
|
|
|
1415
2143
|
});
|
|
1416
2144
|
};
|
|
1417
2145
|
e();
|
|
1418
|
-
const n = Array.from(
|
|
2146
|
+
const n = Array.from(Le.values()).map(t => t.onStateChange(e));
|
|
1419
2147
|
return () => n.forEach(e => e());
|
|
1420
2148
|
}, []), e;
|
|
1421
2149
|
}, exports.useSyncedState = function(e, t) {
|
|
1422
|
-
const
|
|
2150
|
+
const r = t || $e, s = r?.namespace || "default", o = Le.get(s), a = Ue(e, r), i = a[0], c = a[1], [l, u] = n.useState(() => o?.getState() || {
|
|
1423
2151
|
isOnline: !0,
|
|
1424
2152
|
isSyncing: !1,
|
|
1425
2153
|
lastSyncTimestamp: null,
|
|
1426
2154
|
pendingChanges: 0,
|
|
1427
2155
|
conflicts: 0
|
|
1428
2156
|
});
|
|
1429
|
-
return
|
|
2157
|
+
return n.useEffect(() => {
|
|
1430
2158
|
if (!o) return;
|
|
1431
2159
|
return o.onStateChange(u);
|
|
1432
|
-
}, [ o ]), [ i,
|
|
1433
|
-
const s = c(t,
|
|
2160
|
+
}, [ o ]), [ i, n.useCallback((t, n) => {
|
|
2161
|
+
const s = c(t, n);
|
|
1434
2162
|
if (s && o) {
|
|
1435
|
-
const t =
|
|
2163
|
+
const t = r?.get(e);
|
|
1436
2164
|
o.queueChange(e, t);
|
|
1437
2165
|
}
|
|
1438
2166
|
return s;
|
|
1439
|
-
}, [ c, o, e,
|
|
1440
|
-
}, exports.validateKey =
|
|
2167
|
+
}, [ c, o, e, r ]), l ];
|
|
2168
|
+
}, exports.validateKey = Pe;
|