@instantdb/react 0.22.86-experimental.split-store.20243647937.1 → 0.22.86-experimental.split-store.20247643606.1
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/dist/standalone/index.js +843 -841
- package/dist/standalone/index.umd.cjs +1 -1
- package/package.json +4 -4
package/dist/standalone/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import oi, { useRef as ot, useCallback as we, useSyncExternalStore as en, useEffect as ke, useMemo as tn, useState as
|
|
1
|
+
import oi, { useRef as ot, useCallback as we, useSyncExternalStore as en, useEffect as ke, useMemo as tn, useState as ui, createElement as Os } from "react";
|
|
2
2
|
function B(t) {
|
|
3
3
|
if (typeof t == "number")
|
|
4
4
|
return (Math.abs(t * 2654435761) >>> 0).toString(16);
|
|
@@ -41,7 +41,7 @@ const L = {
|
|
|
41
41
|
Remove: "remove",
|
|
42
42
|
Replace: "replace",
|
|
43
43
|
Add: "add"
|
|
44
|
-
},
|
|
44
|
+
}, ai = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Es = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), vt = Symbol.iterator, ne = {
|
|
45
45
|
mutable: "mutable",
|
|
46
46
|
immutable: "immutable"
|
|
47
47
|
}, In = {};
|
|
@@ -73,14 +73,14 @@ function je(t) {
|
|
|
73
73
|
return !!j(t);
|
|
74
74
|
}
|
|
75
75
|
function j(t) {
|
|
76
|
-
return typeof t != "object" ? null : t == null ? void 0 : t[
|
|
76
|
+
return typeof t != "object" ? null : t == null ? void 0 : t[ai];
|
|
77
77
|
}
|
|
78
78
|
function Rn(t) {
|
|
79
79
|
var e;
|
|
80
80
|
const n = j(t);
|
|
81
81
|
return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function ue(t, e) {
|
|
84
84
|
if (!t || typeof t != "object")
|
|
85
85
|
return !1;
|
|
86
86
|
let n;
|
|
@@ -112,7 +112,7 @@ function Ce(t) {
|
|
|
112
112
|
function _e(t, e) {
|
|
113
113
|
return Ce(t) === 2 ? t.get(e) : t[e];
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function at(t, e, n) {
|
|
116
116
|
Ce(t) === 2 ? t.set(e, n) : t[e] = n;
|
|
117
117
|
}
|
|
118
118
|
function Qt(t, e) {
|
|
@@ -197,7 +197,7 @@ function Q(t) {
|
|
|
197
197
|
t.copy || (t.copy = di(t.original, t.options));
|
|
198
198
|
}
|
|
199
199
|
function Ye(t) {
|
|
200
|
-
if (!
|
|
200
|
+
if (!ue(t))
|
|
201
201
|
return Rn(t);
|
|
202
202
|
if (Array.isArray(t))
|
|
203
203
|
return t.map(Ye);
|
|
@@ -240,13 +240,13 @@ function Re(t, e, n, r, i) {
|
|
|
240
240
|
n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], i = i ?? [];
|
|
241
241
|
const o = n.has(t) ? n.get(t) : t;
|
|
242
242
|
if (r.length > 0) {
|
|
243
|
-
const
|
|
244
|
-
if (o && typeof o == "object" &&
|
|
245
|
-
throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0,
|
|
246
|
-
if (typeof
|
|
247
|
-
return `[${
|
|
243
|
+
const u = r.indexOf(o);
|
|
244
|
+
if (o && typeof o == "object" && u !== -1)
|
|
245
|
+
throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, u).map((a, c) => {
|
|
246
|
+
if (typeof a == "symbol")
|
|
247
|
+
return `[${a.toString()}]`;
|
|
248
248
|
const d = r[c];
|
|
249
|
-
return typeof
|
|
249
|
+
return typeof a == "object" && (d instanceof Map || d instanceof Set) ? Array.from(d.keys()).indexOf(a) : a;
|
|
250
250
|
}).join("/")}`);
|
|
251
251
|
r.push(o), i.push(e);
|
|
252
252
|
} else
|
|
@@ -258,25 +258,25 @@ function Re(t, e, n, r, i) {
|
|
|
258
258
|
}
|
|
259
259
|
switch (Ce(t)) {
|
|
260
260
|
case 2:
|
|
261
|
-
for (const [
|
|
262
|
-
Re(
|
|
261
|
+
for (const [u, a] of t)
|
|
262
|
+
Re(u, u, n, r, i), Re(a, u, n, r, i);
|
|
263
263
|
t.set = t.clear = t.delete = br;
|
|
264
264
|
break;
|
|
265
265
|
case 3:
|
|
266
|
-
for (const
|
|
267
|
-
Re(
|
|
266
|
+
for (const u of t)
|
|
267
|
+
Re(u, u, n, r, i);
|
|
268
268
|
t.add = t.clear = t.delete = br;
|
|
269
269
|
break;
|
|
270
270
|
case 1:
|
|
271
271
|
Object.freeze(t);
|
|
272
272
|
let o = 0;
|
|
273
|
-
for (const
|
|
274
|
-
Re(
|
|
273
|
+
for (const u of t)
|
|
274
|
+
Re(u, o, n, r, i), o += 1;
|
|
275
275
|
break;
|
|
276
276
|
default:
|
|
277
|
-
Object.freeze(t), Object.keys(t).forEach((
|
|
278
|
-
const
|
|
279
|
-
Re(
|
|
277
|
+
Object.freeze(t), Object.keys(t).forEach((u) => {
|
|
278
|
+
const a = t[u];
|
|
279
|
+
Re(a, u, n, r, i);
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
r.pop(), i.pop();
|
|
@@ -295,22 +295,22 @@ function xn(t, e) {
|
|
|
295
295
|
t.forEach((r, i) => e(i, r, t));
|
|
296
296
|
}
|
|
297
297
|
function fi(t, e, n) {
|
|
298
|
-
if (je(t) || !
|
|
298
|
+
if (je(t) || !ue(t, n) || e.has(t) || Object.isFrozen(t))
|
|
299
299
|
return;
|
|
300
300
|
const r = t instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
|
|
301
301
|
if (e.add(t), xn(t, (s, o) => {
|
|
302
|
-
var
|
|
302
|
+
var u;
|
|
303
303
|
if (je(o)) {
|
|
304
|
-
const
|
|
305
|
-
Q(
|
|
306
|
-
const c = !((
|
|
307
|
-
|
|
304
|
+
const a = j(o);
|
|
305
|
+
Q(a);
|
|
306
|
+
const c = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
|
|
307
|
+
at(r ? i : t, s, c);
|
|
308
308
|
} else
|
|
309
309
|
fi(o, e, n);
|
|
310
310
|
}), i) {
|
|
311
311
|
const s = t, o = Array.from(s);
|
|
312
|
-
s.clear(), o.forEach((
|
|
313
|
-
s.add(i.has(
|
|
312
|
+
s.clear(), o.forEach((u) => {
|
|
313
|
+
s.add(i.has(u) ? i.get(u) : u);
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
}
|
|
@@ -335,28 +335,28 @@ function sn(t, e, n, r) {
|
|
|
335
335
|
function $n(t, e, n, r) {
|
|
336
336
|
const i = j(n);
|
|
337
337
|
i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
|
|
338
|
-
var
|
|
339
|
-
const
|
|
340
|
-
if (be(_e(
|
|
338
|
+
var u;
|
|
339
|
+
const a = t.type === 3 ? t.setMap : t.copy;
|
|
340
|
+
if (be(_e(a, e), n)) {
|
|
341
341
|
let c = i.original;
|
|
342
|
-
i.copy && (c = i.copy), rn(t), sn(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (
|
|
342
|
+
i.copy && (c = i.copy), rn(t), sn(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(c, i.original)), at(a, e, c);
|
|
343
343
|
}
|
|
344
|
-
}), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)),
|
|
344
|
+
}), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ue(n, t.options) && t.finalities.draft.push(() => {
|
|
345
345
|
const s = t.type === 3 ? t.setMap : t.copy;
|
|
346
346
|
be(_e(s, e), n) && Cs(t, e);
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
function Is(t, e, n, r, i) {
|
|
350
|
-
let { original: s, assignedMap: o, options:
|
|
351
|
-
|
|
350
|
+
let { original: s, assignedMap: o, options: u } = t, a = t.copy;
|
|
351
|
+
a.length < s.length && ([s, a] = [a, s], [n, r] = [r, n]);
|
|
352
352
|
for (let c = 0; c < s.length; c += 1)
|
|
353
|
-
if (o.get(c.toString()) &&
|
|
353
|
+
if (o.get(c.toString()) && a[c] !== s[c]) {
|
|
354
354
|
const d = e.concat([c]), f = Ee(d, i);
|
|
355
355
|
n.push({
|
|
356
356
|
op: L.Replace,
|
|
357
357
|
path: f,
|
|
358
358
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
359
|
-
value: St(
|
|
359
|
+
value: St(a[c])
|
|
360
360
|
}), r.push({
|
|
361
361
|
op: L.Replace,
|
|
362
362
|
path: f,
|
|
@@ -364,17 +364,17 @@ function Is(t, e, n, r, i) {
|
|
|
364
364
|
value: St(s[c])
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
|
-
for (let c = s.length; c <
|
|
367
|
+
for (let c = s.length; c < a.length; c += 1) {
|
|
368
368
|
const d = e.concat([c]), f = Ee(d, i);
|
|
369
369
|
n.push({
|
|
370
370
|
op: L.Add,
|
|
371
371
|
path: f,
|
|
372
372
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
373
|
-
value: St(
|
|
373
|
+
value: St(a[c])
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
|
-
if (s.length <
|
|
377
|
-
const { arrayLengthAssignment: c = !0 } =
|
|
376
|
+
if (s.length < a.length) {
|
|
377
|
+
const { arrayLengthAssignment: c = !0 } = u.enablePatches;
|
|
378
378
|
if (c) {
|
|
379
379
|
const d = e.concat(["length"]), f = Ee(d, i);
|
|
380
380
|
r.push({
|
|
@@ -383,7 +383,7 @@ function Is(t, e, n, r, i) {
|
|
|
383
383
|
value: s.length
|
|
384
384
|
});
|
|
385
385
|
} else
|
|
386
|
-
for (let d =
|
|
386
|
+
for (let d = a.length; s.length < d; d -= 1) {
|
|
387
387
|
const f = e.concat([d - 1]), l = Ee(f, i);
|
|
388
388
|
r.push({
|
|
389
389
|
op: L.Remove,
|
|
@@ -393,47 +393,47 @@ function Is(t, e, n, r, i) {
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
function Ps({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
|
|
396
|
-
n.forEach((
|
|
397
|
-
const c = _e(t,
|
|
396
|
+
n.forEach((u, a) => {
|
|
397
|
+
const c = _e(t, a), d = St(_e(e, a)), f = u ? tt(t, a) ? L.Replace : L.Add : L.Remove;
|
|
398
398
|
if (be(c, d) && f === L.Replace)
|
|
399
399
|
return;
|
|
400
|
-
const l = r.concat(
|
|
400
|
+
const l = r.concat(a), p = Ee(l, o);
|
|
401
401
|
i.push(f === L.Remove ? { op: f, path: p } : { op: f, path: p, value: d }), s.push(f === L.Add ? { op: L.Remove, path: p } : f === L.Remove ? { op: L.Add, path: p, value: c } : { op: L.Replace, path: p, value: c });
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
function Ms({ original: t, copy: e }, n, r, i, s) {
|
|
405
405
|
let o = 0;
|
|
406
|
-
t.forEach((
|
|
407
|
-
if (!e.has(
|
|
408
|
-
const
|
|
406
|
+
t.forEach((u) => {
|
|
407
|
+
if (!e.has(u)) {
|
|
408
|
+
const a = n.concat([o]), c = Ee(a, s);
|
|
409
409
|
r.push({
|
|
410
410
|
op: L.Remove,
|
|
411
411
|
path: c,
|
|
412
|
-
value:
|
|
412
|
+
value: u
|
|
413
413
|
}), i.unshift({
|
|
414
414
|
op: L.Add,
|
|
415
415
|
path: c,
|
|
416
|
-
value:
|
|
416
|
+
value: u
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
o += 1;
|
|
420
|
-
}), o = 0, e.forEach((
|
|
421
|
-
if (!t.has(
|
|
422
|
-
const
|
|
420
|
+
}), o = 0, e.forEach((u) => {
|
|
421
|
+
if (!t.has(u)) {
|
|
422
|
+
const a = n.concat([o]), c = Ee(a, s);
|
|
423
423
|
r.push({
|
|
424
424
|
op: L.Add,
|
|
425
425
|
path: c,
|
|
426
|
-
value:
|
|
426
|
+
value: u
|
|
427
427
|
}), i.unshift({
|
|
428
428
|
op: L.Remove,
|
|
429
429
|
path: c,
|
|
430
|
-
value:
|
|
430
|
+
value: u
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
o += 1;
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function ut(t, e, n, r) {
|
|
437
437
|
const { pathAsArray: i = !0 } = t.options.enablePatches;
|
|
438
438
|
switch (t.type) {
|
|
439
439
|
case 0:
|
|
@@ -446,7 +446,7 @@ function at(t, e, n, r) {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
const jt = (t, e, n = !1) => {
|
|
449
|
-
if (typeof t == "object" && t !== null && (!
|
|
449
|
+
if (typeof t == "object" && t !== null && (!ue(t, e) || n))
|
|
450
450
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
451
451
|
}, on = {
|
|
452
452
|
get size() {
|
|
@@ -457,7 +457,7 @@ const jt = (t, e, n = !1) => {
|
|
|
457
457
|
},
|
|
458
458
|
set(t, e) {
|
|
459
459
|
const n = j(this), r = ee(n);
|
|
460
|
-
return (!r.has(t) || !be(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), $n(n, t, e,
|
|
460
|
+
return (!r.has(t) || !be(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), $n(n, t, e, ut)), this;
|
|
461
461
|
},
|
|
462
462
|
delete(t) {
|
|
463
463
|
if (!this.has(t))
|
|
@@ -483,7 +483,7 @@ const jt = (t, e, n = !1) => {
|
|
|
483
483
|
get(t) {
|
|
484
484
|
var e, n;
|
|
485
485
|
const r = j(this), i = ee(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, ne)) === ne.mutable;
|
|
486
|
-
if (r.options.strict && jt(i, r.options, s), s || r.finalized || !
|
|
486
|
+
if (r.options.strict && jt(i, r.options, s), s || r.finalized || !ue(i, r.options) || i !== r.original.get(t))
|
|
487
487
|
return i;
|
|
488
488
|
const o = In.createDraft({
|
|
489
489
|
original: i,
|
|
@@ -535,9 +535,9 @@ const jt = (t, e, n = !1) => {
|
|
|
535
535
|
if (s.done)
|
|
536
536
|
return s;
|
|
537
537
|
const o = s.value;
|
|
538
|
-
let
|
|
539
|
-
const
|
|
540
|
-
if (t.options.strict && jt(o, t.options, c), !c && !
|
|
538
|
+
let u = t.setMap.get(o);
|
|
539
|
+
const a = j(u), c = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, u, ne)) === ne.mutable;
|
|
540
|
+
if (t.options.strict && jt(o, t.options, c), !c && !a && ue(o, t.options) && !t.finalized && t.original.has(o)) {
|
|
541
541
|
const d = In.createDraft({
|
|
542
542
|
original: o,
|
|
543
543
|
parentDraft: t,
|
|
@@ -545,11 +545,11 @@ const jt = (t, e, n = !1) => {
|
|
|
545
545
|
finalities: t.finalities,
|
|
546
546
|
options: t.options
|
|
547
547
|
});
|
|
548
|
-
t.setMap.set(o, d),
|
|
549
|
-
} else
|
|
548
|
+
t.setMap.set(o, d), u = d;
|
|
549
|
+
} else a && (u = a.proxy);
|
|
550
550
|
return {
|
|
551
551
|
done: !1,
|
|
552
|
-
value: n ?
|
|
552
|
+
value: n ? u : [u, u]
|
|
553
553
|
};
|
|
554
554
|
}, Ct = {
|
|
555
555
|
get size() {
|
|
@@ -565,7 +565,7 @@ const jt = (t, e, n = !1) => {
|
|
|
565
565
|
},
|
|
566
566
|
add(t) {
|
|
567
567
|
const e = j(this);
|
|
568
|
-
return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), $n(e, t, t,
|
|
568
|
+
return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), $n(e, t, t, ut)), this;
|
|
569
569
|
},
|
|
570
570
|
delete(t) {
|
|
571
571
|
if (!this.has(t))
|
|
@@ -646,7 +646,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
|
|
|
646
646
|
const s = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
|
|
647
647
|
if (s && li.has(s))
|
|
648
648
|
return s;
|
|
649
|
-
if (e ===
|
|
649
|
+
if (e === ai)
|
|
650
650
|
return t;
|
|
651
651
|
let o;
|
|
652
652
|
if (t.options.mark) {
|
|
@@ -654,32 +654,32 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
|
|
|
654
654
|
if (o = t.options.mark(c, ne), o === ne.mutable)
|
|
655
655
|
return t.options.strict && jt(c, t.options, !0), c;
|
|
656
656
|
}
|
|
657
|
-
const
|
|
658
|
-
if (
|
|
657
|
+
const u = ee(t);
|
|
658
|
+
if (u instanceof Map && Rs.includes(e)) {
|
|
659
659
|
if (e === "size")
|
|
660
660
|
return Object.getOwnPropertyDescriptor(on, "size").get.call(t.proxy);
|
|
661
661
|
const c = on[e];
|
|
662
662
|
if (c)
|
|
663
663
|
return c.bind(t.proxy);
|
|
664
664
|
}
|
|
665
|
-
if (
|
|
665
|
+
if (u instanceof Set && xs.includes(e)) {
|
|
666
666
|
if (e === "size")
|
|
667
667
|
return Object.getOwnPropertyDescriptor(Ct, "size").get.call(t.proxy);
|
|
668
668
|
const c = Ct[e];
|
|
669
669
|
if (c)
|
|
670
670
|
return c.bind(t.proxy);
|
|
671
671
|
}
|
|
672
|
-
if (!tt(
|
|
673
|
-
const c = yr(
|
|
672
|
+
if (!tt(u, e)) {
|
|
673
|
+
const c = yr(u, e);
|
|
674
674
|
return c ? "value" in c ? c.value : (
|
|
675
675
|
// !case: support for getter
|
|
676
676
|
(i = c.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
|
|
677
677
|
) : void 0;
|
|
678
678
|
}
|
|
679
|
-
const
|
|
680
|
-
if (t.options.strict && jt(
|
|
681
|
-
return
|
|
682
|
-
if (
|
|
679
|
+
const a = u[e];
|
|
680
|
+
if (t.options.strict && jt(a, t.options), t.finalized || !ue(a, t.options))
|
|
681
|
+
return a;
|
|
682
|
+
if (a === Qt(t.original, e)) {
|
|
683
683
|
if (Q(t), t.copy[e] = Dn({
|
|
684
684
|
original: t.original[e],
|
|
685
685
|
parentDraft: t,
|
|
@@ -692,7 +692,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
|
|
|
692
692
|
}
|
|
693
693
|
return t.copy[e];
|
|
694
694
|
}
|
|
695
|
-
return
|
|
695
|
+
return a;
|
|
696
696
|
},
|
|
697
697
|
set(t, e, n) {
|
|
698
698
|
var r;
|
|
@@ -704,8 +704,8 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
|
|
|
704
704
|
const s = yr(ee(t), e);
|
|
705
705
|
if (s != null && s.set)
|
|
706
706
|
return s.set.call(t.proxy, n), !0;
|
|
707
|
-
const o = Qt(ee(t), e),
|
|
708
|
-
return
|
|
707
|
+
const o = Qt(ee(t), e), u = j(o);
|
|
708
|
+
return u && be(u.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (be(n, o) && (n !== void 0 || tt(t.original, e)) || (Q(t), fe(t), tt(t.original, e) && be(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, $n(t, e, n, ut)), !0);
|
|
709
709
|
},
|
|
710
710
|
has(t, e) {
|
|
711
711
|
return e in ee(t);
|
|
@@ -737,7 +737,7 @@ const xs = Reflect.ownKeys(Ct), li = /* @__PURE__ */ new WeakSet(), hi = {
|
|
|
737
737
|
}
|
|
738
738
|
};
|
|
739
739
|
function Dn(t) {
|
|
740
|
-
const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ce(e),
|
|
740
|
+
const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ce(e), u = {
|
|
741
741
|
type: o,
|
|
742
742
|
finalized: !1,
|
|
743
743
|
parent: n,
|
|
@@ -749,43 +749,43 @@ function Dn(t) {
|
|
|
749
749
|
// Mapping of draft Set items to their corresponding draft values.
|
|
750
750
|
setMap: o === 3 ? new Map(e.entries()) : void 0
|
|
751
751
|
};
|
|
752
|
-
(r || "key" in t) && (
|
|
753
|
-
const { proxy:
|
|
754
|
-
if (i.revoke.push(c), li.add(
|
|
752
|
+
(r || "key" in t) && (u.key = r);
|
|
753
|
+
const { proxy: a, revoke: c } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, hi);
|
|
754
|
+
if (i.revoke.push(c), li.add(a), u.proxy = a, n) {
|
|
755
755
|
const d = n;
|
|
756
756
|
d.finalities.draft.push((f, l) => {
|
|
757
757
|
var p, y;
|
|
758
|
-
const b = j(
|
|
758
|
+
const b = j(a);
|
|
759
759
|
let _ = d.type === 3 ? d.setMap : d.copy;
|
|
760
760
|
const T = _e(_, r), g = j(T);
|
|
761
761
|
if (g) {
|
|
762
762
|
let m = g.original;
|
|
763
|
-
g.operated && (m = Rn(T)), rn(g), sn(g,
|
|
763
|
+
g.operated && (m = Rn(T)), rn(g), sn(g, ut, f, l), d.options.enableAutoFreeze && (d.options.updatedValues = (p = d.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), d.options.updatedValues.set(m, g.original)), at(_, r, m);
|
|
764
764
|
}
|
|
765
765
|
(y = b.callbacks) === null || y === void 0 || y.forEach((m) => {
|
|
766
766
|
m(f, l);
|
|
767
767
|
});
|
|
768
768
|
});
|
|
769
769
|
} else {
|
|
770
|
-
const d = j(
|
|
770
|
+
const d = j(a);
|
|
771
771
|
d.finalities.draft.push((f, l) => {
|
|
772
|
-
rn(d), sn(d,
|
|
772
|
+
rn(d), sn(d, ut, f, l);
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
|
-
return
|
|
775
|
+
return a;
|
|
776
776
|
}
|
|
777
777
|
In.createDraft = Dn;
|
|
778
778
|
function $s(t, e, n, r, i) {
|
|
779
779
|
var s;
|
|
780
|
-
const o = j(t),
|
|
780
|
+
const o = j(t), u = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, a = !!e.length;
|
|
781
781
|
if (o != null && o.operated)
|
|
782
782
|
for (; o.finalities.draft.length > 0; )
|
|
783
783
|
o.finalities.draft.pop()(n, r);
|
|
784
|
-
const c =
|
|
784
|
+
const c = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
|
|
785
785
|
return o && nn(o), i && Re(c, c, o == null ? void 0 : o.options.updatedValues), [
|
|
786
786
|
c,
|
|
787
|
-
n &&
|
|
788
|
-
r &&
|
|
787
|
+
n && a ? [{ op: L.Replace, path: [], value: e[0] }] : n,
|
|
788
|
+
r && a ? [{ op: L.Replace, path: [], value: u }] : r
|
|
789
789
|
];
|
|
790
790
|
}
|
|
791
791
|
function Ds(t, e) {
|
|
@@ -797,39 +797,39 @@ function Ds(t, e) {
|
|
|
797
797
|
};
|
|
798
798
|
let i, s;
|
|
799
799
|
e.enablePatches && (i = [], s = []);
|
|
800
|
-
const
|
|
800
|
+
const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ue(t, e) ? t : Dn({
|
|
801
801
|
original: t,
|
|
802
802
|
parentDraft: null,
|
|
803
803
|
finalities: r,
|
|
804
804
|
options: e
|
|
805
805
|
});
|
|
806
806
|
return [
|
|
807
|
-
|
|
808
|
-
(
|
|
809
|
-
const [c, d, f] = $s(
|
|
807
|
+
u,
|
|
808
|
+
(a = []) => {
|
|
809
|
+
const [c, d, f] = $s(u, a, i, s, e.enableAutoFreeze);
|
|
810
810
|
return e.enablePatches ? [c, d, f] : c;
|
|
811
811
|
}
|
|
812
812
|
];
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function un(t) {
|
|
815
815
|
const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: i = !0 } = t;
|
|
816
|
-
xn(n, (s, o,
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
816
|
+
xn(n, (s, o, u) => {
|
|
817
|
+
const a = j(o);
|
|
818
|
+
if (a && e && a.finalities === e.finalities) {
|
|
819
819
|
t.isContainDraft = !0;
|
|
820
|
-
const c =
|
|
821
|
-
if (
|
|
822
|
-
const d = Array.from(
|
|
823
|
-
|
|
820
|
+
const c = a.original;
|
|
821
|
+
if (u instanceof Set) {
|
|
822
|
+
const d = Array.from(u);
|
|
823
|
+
u.clear(), d.forEach((f) => u.add(s === f ? c : f));
|
|
824
824
|
} else
|
|
825
|
-
|
|
826
|
-
} else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1,
|
|
825
|
+
at(u, s, c);
|
|
826
|
+
} else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, un(t));
|
|
827
827
|
}), i && (t.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
|
|
828
828
|
}
|
|
829
829
|
function pi(t) {
|
|
830
830
|
var e;
|
|
831
831
|
const n = j(t);
|
|
832
|
-
if (!
|
|
832
|
+
if (!ue(t, n == null ? void 0 : n.options))
|
|
833
833
|
return t;
|
|
834
834
|
const r = Ce(t);
|
|
835
835
|
if (n && !n.operated)
|
|
@@ -847,11 +847,11 @@ function pi(t) {
|
|
|
847
847
|
}
|
|
848
848
|
} else
|
|
849
849
|
i = t;
|
|
850
|
-
if (xn(i, (o,
|
|
851
|
-
if (n && be(_e(n.original, o),
|
|
850
|
+
if (xn(i, (o, u) => {
|
|
851
|
+
if (n && be(_e(n.original, o), u))
|
|
852
852
|
return;
|
|
853
|
-
const
|
|
854
|
-
|
|
853
|
+
const a = pi(u);
|
|
854
|
+
a !== u && (i === t && s(), at(i, o, a));
|
|
855
855
|
}), r === 3) {
|
|
856
856
|
const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : i;
|
|
857
857
|
return Pn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
|
|
@@ -864,17 +864,17 @@ function gr(t) {
|
|
|
864
864
|
return pi(t);
|
|
865
865
|
}
|
|
866
866
|
const Us = (t) => function e(n, r, i) {
|
|
867
|
-
var s, o,
|
|
867
|
+
var s, o, u;
|
|
868
868
|
if (typeof n == "function" && typeof r != "function")
|
|
869
869
|
return function(S, ...C) {
|
|
870
870
|
return e(S, ($) => n.call(this, $, ...C), r);
|
|
871
871
|
};
|
|
872
|
-
const
|
|
872
|
+
const a = n, c = r;
|
|
873
873
|
let d = i;
|
|
874
874
|
if (typeof r != "function" && (d = r), d !== void 0 && Object.prototype.toString.call(d) !== "[object Object]")
|
|
875
875
|
throw new Error(`Invalid options: ${d}, 'options' should be an object.`);
|
|
876
876
|
d = Object.assign(Object.assign({}, t), d);
|
|
877
|
-
const f = je(
|
|
877
|
+
const f = je(a) ? gr(a) : a, l = Array.isArray(d.mark) ? (S, C) => {
|
|
878
878
|
for (const $ of d.mark) {
|
|
879
879
|
if (typeof $ != "function")
|
|
880
880
|
throw new Error(`Invalid mark: ${$}, 'mark' should be a function.`);
|
|
@@ -883,16 +883,16 @@ const Us = (t) => function e(n, r, i) {
|
|
|
883
883
|
return D;
|
|
884
884
|
}
|
|
885
885
|
} : d.mark, p = (s = d.enablePatches) !== null && s !== void 0 ? s : !1, y = (o = d.strict) !== null && o !== void 0 ? o : !1, _ = {
|
|
886
|
-
enableAutoFreeze: (
|
|
886
|
+
enableAutoFreeze: (u = d.enableAutoFreeze) !== null && u !== void 0 ? u : !1,
|
|
887
887
|
mark: l,
|
|
888
888
|
strict: y,
|
|
889
889
|
enablePatches: p
|
|
890
890
|
};
|
|
891
|
-
if (!
|
|
891
|
+
if (!ue(f, _) && typeof f == "object" && f !== null)
|
|
892
892
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
893
893
|
const [T, g] = Ds(f, _);
|
|
894
894
|
if (typeof r != "function") {
|
|
895
|
-
if (!
|
|
895
|
+
if (!ue(f, _))
|
|
896
896
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
897
897
|
return [T, g];
|
|
898
898
|
}
|
|
@@ -910,14 +910,14 @@ const Us = (t) => function e(n, r, i) {
|
|
|
910
910
|
const D = S == null ? void 0 : S[Es];
|
|
911
911
|
if (D) {
|
|
912
912
|
const Ve = D[0];
|
|
913
|
-
return _.strict && typeof S == "object" && S !== null &&
|
|
913
|
+
return _.strict && typeof S == "object" && S !== null && un({
|
|
914
914
|
rootDraft: C,
|
|
915
915
|
value: S,
|
|
916
916
|
useRawReturn: !0
|
|
917
917
|
}), g([Ve]);
|
|
918
918
|
}
|
|
919
919
|
if (S !== void 0)
|
|
920
|
-
return typeof S == "object" && S !== null &&
|
|
920
|
+
return typeof S == "object" && S !== null && un({ rootDraft: C, value: S }), g([S]);
|
|
921
921
|
}
|
|
922
922
|
if (S === T || S === void 0)
|
|
923
923
|
return g([]);
|
|
@@ -1246,7 +1246,7 @@ function Hs(t) {
|
|
|
1246
1246
|
function Ys(t) {
|
|
1247
1247
|
const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
|
|
1248
1248
|
if (n) {
|
|
1249
|
-
const [, r, i, s, o,
|
|
1249
|
+
const [, r, i, s, o, u] = n, a = i.padStart(2, "0"), c = s.padStart(2, "0"), d = `${r}-${a}-${c}T${u}`;
|
|
1250
1250
|
return new Date(d);
|
|
1251
1251
|
}
|
|
1252
1252
|
return null;
|
|
@@ -1255,8 +1255,8 @@ function Js(t) {
|
|
|
1255
1255
|
const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
|
|
1256
1256
|
if (!o)
|
|
1257
1257
|
throw new Error(`Unable to parse time from: ${t}`);
|
|
1258
|
-
let [,
|
|
1259
|
-
return
|
|
1258
|
+
let [, u, a, c, d] = o;
|
|
1259
|
+
return u = Number(u), a = Number(a), c = Number(c), d === "PM" && u !== 12 ? u += 12 : d === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, c));
|
|
1260
1260
|
}
|
|
1261
1261
|
function Zs(t) {
|
|
1262
1262
|
switch (t) {
|
|
@@ -1299,7 +1299,7 @@ function to(t, e) {
|
|
|
1299
1299
|
return null;
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
|
-
function
|
|
1302
|
+
function an(t) {
|
|
1303
1303
|
for (const e of eo) {
|
|
1304
1304
|
const n = to(e, t);
|
|
1305
1305
|
if (n)
|
|
@@ -1310,7 +1310,7 @@ function un(t) {
|
|
|
1310
1310
|
function no(t) {
|
|
1311
1311
|
try {
|
|
1312
1312
|
const e = JSON.parse(t);
|
|
1313
|
-
return typeof e == "string" ?
|
|
1313
|
+
return typeof e == "string" ? an(e) : null;
|
|
1314
1314
|
} catch {
|
|
1315
1315
|
return null;
|
|
1316
1316
|
}
|
|
@@ -1322,7 +1322,7 @@ function xt(t) {
|
|
|
1322
1322
|
if (t instanceof Date)
|
|
1323
1323
|
return t;
|
|
1324
1324
|
if (typeof t == "string") {
|
|
1325
|
-
const e =
|
|
1325
|
+
const e = an(t) || no(t) || an(t.trim());
|
|
1326
1326
|
if (!e)
|
|
1327
1327
|
throw new Error(`Unable to parse \`${t}\` as a date.`);
|
|
1328
1328
|
return e;
|
|
@@ -1351,12 +1351,10 @@ class Ae {
|
|
|
1351
1351
|
getAttr(e) {
|
|
1352
1352
|
return this.attrs[e];
|
|
1353
1353
|
}
|
|
1354
|
-
// XXX: Might be better to create all of the indexes at once as soon as someone
|
|
1355
|
-
// requests one index
|
|
1356
1354
|
get blobAttrs() {
|
|
1357
1355
|
if (this._blobAttrs)
|
|
1358
1356
|
return this._blobAttrs;
|
|
1359
|
-
|
|
1357
|
+
this._blobAttrs = /* @__PURE__ */ new Map();
|
|
1360
1358
|
for (const e of Object.values(this.attrs))
|
|
1361
1359
|
if (Fn(e)) {
|
|
1362
1360
|
const [n, r, i] = e["forward-identity"];
|
|
@@ -1367,7 +1365,7 @@ class Ae {
|
|
|
1367
1365
|
get primaryKeys() {
|
|
1368
1366
|
if (this._primaryKeys)
|
|
1369
1367
|
return this._primaryKeys;
|
|
1370
|
-
|
|
1368
|
+
this._primaryKeys = /* @__PURE__ */ new Map();
|
|
1371
1369
|
for (const e of Object.values(this.attrs))
|
|
1372
1370
|
if (e["primary?"]) {
|
|
1373
1371
|
const [n, r] = e["forward-identity"];
|
|
@@ -1378,7 +1376,7 @@ class Ae {
|
|
|
1378
1376
|
get forwardIdents() {
|
|
1379
1377
|
if (this._forwardIdents)
|
|
1380
1378
|
return this._forwardIdents;
|
|
1381
|
-
|
|
1379
|
+
this._forwardIdents = /* @__PURE__ */ new Map();
|
|
1382
1380
|
for (const e of Object.values(this.attrs)) {
|
|
1383
1381
|
const n = e["forward-identity"], [r, i, s] = n;
|
|
1384
1382
|
te(this._forwardIdents, [i, s], e);
|
|
@@ -1388,7 +1386,7 @@ class Ae {
|
|
|
1388
1386
|
get revIdents() {
|
|
1389
1387
|
if (this._revIdents)
|
|
1390
1388
|
return this._revIdents;
|
|
1391
|
-
|
|
1389
|
+
this._revIdents = /* @__PURE__ */ new Map();
|
|
1392
1390
|
for (const e of Object.values(this.attrs)) {
|
|
1393
1391
|
const n = e["reverse-identity"];
|
|
1394
1392
|
if (n) {
|
|
@@ -1429,21 +1427,21 @@ function te(t, e, n) {
|
|
|
1429
1427
|
const i = e.length - 1;
|
|
1430
1428
|
for (let s = 0; s < i; s++) {
|
|
1431
1429
|
const o = e[s];
|
|
1432
|
-
let
|
|
1433
|
-
|
|
1430
|
+
let u = r.get(o);
|
|
1431
|
+
u === void 0 && (u = /* @__PURE__ */ new Map(), r.set(o, u)), r = u;
|
|
1434
1432
|
}
|
|
1435
1433
|
i > -1 && r.set(e[i], n);
|
|
1436
1434
|
}
|
|
1437
1435
|
function gi(t, e, n) {
|
|
1438
1436
|
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1439
1437
|
for (const o of e) {
|
|
1440
|
-
let [
|
|
1441
|
-
const d = t.getAttr(
|
|
1438
|
+
let [u, a, c] = o;
|
|
1439
|
+
const d = t.getAttr(a);
|
|
1442
1440
|
if (!d) {
|
|
1443
|
-
console.warn("no such attr",
|
|
1441
|
+
console.warn("no such attr", a, u);
|
|
1444
1442
|
continue;
|
|
1445
1443
|
}
|
|
1446
|
-
d["checked-data-type"] === "date" && n && (c = xt(c), o[2] = c), Ln(d) && te(s, [c,
|
|
1444
|
+
d["checked-data-type"] === "date" && n && (c = xt(c), o[2] = c), Ln(d) && te(s, [c, a, u], o), te(r, [u, a, c], o), te(i, [a, u, c], o);
|
|
1447
1445
|
}
|
|
1448
1446
|
return { eav: r, aev: i, vae: s };
|
|
1449
1447
|
}
|
|
@@ -1475,65 +1473,65 @@ function ct(t, e) {
|
|
|
1475
1473
|
var n, r;
|
|
1476
1474
|
let i;
|
|
1477
1475
|
if (Array.isArray(e[0])) {
|
|
1478
|
-
const [o,
|
|
1479
|
-
if (!
|
|
1476
|
+
const [o, u] = e[0], a = t.aev.get(o);
|
|
1477
|
+
if (!a)
|
|
1480
1478
|
return null;
|
|
1481
|
-
i = (n = Z(
|
|
1479
|
+
i = (n = Z(a, 2).find((d) => d[2] === u)) === null || n === void 0 ? void 0 : n[0];
|
|
1482
1480
|
} else
|
|
1483
1481
|
i = e[0];
|
|
1484
1482
|
if (!i)
|
|
1485
1483
|
return null;
|
|
1486
1484
|
const s = e[2];
|
|
1487
1485
|
if (Array.isArray(s) && s.length === 2 && t.aev.get(s[0])) {
|
|
1488
|
-
const [o,
|
|
1489
|
-
if (!
|
|
1486
|
+
const [o, u] = s, a = t.aev.get(o);
|
|
1487
|
+
if (!a)
|
|
1490
1488
|
return null;
|
|
1491
|
-
const d = (r = Z(
|
|
1489
|
+
const d = (r = Z(a, 2).find((b) => b[2] === u)) === null || r === void 0 ? void 0 : r[0];
|
|
1492
1490
|
if (!d)
|
|
1493
1491
|
return null;
|
|
1494
1492
|
const [f, l, p, ...y] = e;
|
|
1495
1493
|
return [i, l, d, ...y];
|
|
1496
1494
|
} else {
|
|
1497
|
-
const [o, ...
|
|
1498
|
-
return [i, ...
|
|
1495
|
+
const [o, ...u] = e;
|
|
1496
|
+
return [i, ...u];
|
|
1499
1497
|
}
|
|
1500
1498
|
}
|
|
1501
1499
|
function vi(t, e, n) {
|
|
1502
1500
|
const r = ct(t, n);
|
|
1503
1501
|
if (!r)
|
|
1504
1502
|
return;
|
|
1505
|
-
const [i, s, o] = r,
|
|
1506
|
-
|
|
1503
|
+
const [i, s, o] = r, u = e.getAttr(s);
|
|
1504
|
+
u && (oe(t.eav, [i, s, o]), oe(t.aev, [s, i, o]), Ln(u) && oe(t.vae, [o, s, i]));
|
|
1507
1505
|
}
|
|
1508
1506
|
let so = 0;
|
|
1509
1507
|
function Si(t, e, n) {
|
|
1510
1508
|
const [r, i, s] = n;
|
|
1511
1509
|
let o;
|
|
1512
|
-
const
|
|
1513
|
-
return
|
|
1510
|
+
const u = We(t.eav, [r, i, s]);
|
|
1511
|
+
return u && (o = u[3]), o || Date.now() * 10 + so++;
|
|
1514
1512
|
}
|
|
1515
1513
|
function Oi(t, e, n) {
|
|
1516
1514
|
var r;
|
|
1517
1515
|
const i = ct(t, n);
|
|
1518
1516
|
if (!i)
|
|
1519
1517
|
return;
|
|
1520
|
-
let [s, o,
|
|
1521
|
-
const
|
|
1522
|
-
if (!
|
|
1518
|
+
let [s, o, u] = i;
|
|
1519
|
+
const a = e.getAttr(o);
|
|
1520
|
+
if (!a)
|
|
1523
1521
|
return;
|
|
1524
|
-
|
|
1525
|
-
const c = We(t.eav, [s, o,
|
|
1526
|
-
ro(
|
|
1522
|
+
a["checked-data-type"] === "date" && t.useDateObjects && (u = xt(u));
|
|
1523
|
+
const c = We(t.eav, [s, o, u]), d = (r = c == null ? void 0 : c[3]) !== null && r !== void 0 ? r : Si(t, a, i), f = [s, o, u, d];
|
|
1524
|
+
ro(a) ? (te(t.eav, [s, o], /* @__PURE__ */ new Map([[u, f]])), te(t.aev, [o, s], /* @__PURE__ */ new Map([[u, f]]))) : (te(t.eav, [s, o, u], f), te(t.aev, [o, s, u], f)), Ln(a) && te(t.vae, [u, o, s], f);
|
|
1527
1525
|
}
|
|
1528
1526
|
function oo(t, e, n) {
|
|
1529
1527
|
var r;
|
|
1530
1528
|
const i = ct(t, n);
|
|
1531
1529
|
if (!i)
|
|
1532
1530
|
return;
|
|
1533
|
-
const [s, o,
|
|
1534
|
-
if (!
|
|
1531
|
+
const [s, o, u] = i, a = e.getAttr(o);
|
|
1532
|
+
if (!a)
|
|
1535
1533
|
return;
|
|
1536
|
-
if (!Fn(
|
|
1534
|
+
if (!Fn(a))
|
|
1537
1535
|
throw new Error("merge operation is not supported for links");
|
|
1538
1536
|
const c = We(t.eav, [s, o]);
|
|
1539
1537
|
if (!c)
|
|
@@ -1541,20 +1539,20 @@ function oo(t, e, n) {
|
|
|
1541
1539
|
const d = (r = c.values().next()) === null || r === void 0 ? void 0 : r.value;
|
|
1542
1540
|
if (!d)
|
|
1543
1541
|
return;
|
|
1544
|
-
const f = d[2], l = bi(f,
|
|
1542
|
+
const f = d[2], l = bi(f, u), p = [
|
|
1545
1543
|
s,
|
|
1546
1544
|
o,
|
|
1547
1545
|
l,
|
|
1548
|
-
Si(t,
|
|
1546
|
+
Si(t, a, d)
|
|
1549
1547
|
];
|
|
1550
1548
|
te(t.eav, [s, o], /* @__PURE__ */ new Map([[l, p]]));
|
|
1551
1549
|
}
|
|
1552
1550
|
function cn(t, e, n) {
|
|
1553
1551
|
var r, i;
|
|
1554
|
-
const [s, o] = n,
|
|
1555
|
-
if (!
|
|
1552
|
+
const [s, o] = n, u = ct(t, [s]);
|
|
1553
|
+
if (!u)
|
|
1556
1554
|
return;
|
|
1557
|
-
const [
|
|
1555
|
+
const [a] = u, c = t.eav.get(a);
|
|
1558
1556
|
if (c) {
|
|
1559
1557
|
for (const f of c.keys()) {
|
|
1560
1558
|
const l = e.getAttr(f);
|
|
@@ -1565,16 +1563,16 @@ function cn(t, e, n) {
|
|
|
1565
1563
|
// the store that didn't set `etype` in deleteEntity
|
|
1566
1564
|
(!o || // If we don't know about the attr, let's just get rid of it
|
|
1567
1565
|
!l || // Make sure it matches the etype
|
|
1568
|
-
((r = l["forward-identity"]) === null || r === void 0 ? void 0 : r[1]) === o) && (oe(t.aev, [f,
|
|
1566
|
+
((r = l["forward-identity"]) === null || r === void 0 ? void 0 : r[1]) === o) && (oe(t.aev, [f, a]), oe(t.eav, [a, f]));
|
|
1569
1567
|
}
|
|
1570
|
-
c.size === 0 && oe(t.eav, [
|
|
1568
|
+
c.size === 0 && oe(t.eav, [a]);
|
|
1571
1569
|
}
|
|
1572
|
-
const d = t.vae.get(
|
|
1570
|
+
const d = t.vae.get(a) && Z(t.vae.get(a), 2);
|
|
1573
1571
|
d && d.forEach((f) => {
|
|
1574
1572
|
var l, p, y;
|
|
1575
1573
|
const [b, _, T] = f, g = e.getAttr(_);
|
|
1576
1574
|
(!o || !g || ((l = g["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === o) && (oe(t.eav, [b, _, T]), oe(t.aev, [_, b, T]), oe(t.vae, [T, _, b])), g && g["on-delete"] === "cascade" && ((p = g["reverse-identity"]) === null || p === void 0 ? void 0 : p[1]) === o && cn(t, e, [b, (y = g["forward-identity"]) === null || y === void 0 ? void 0 : y[1]]);
|
|
1577
|
-
}), ((i = t.vae.get(
|
|
1575
|
+
}), ((i = t.vae.get(a)) === null || i === void 0 ? void 0 : i.size) === 0 && oe(t.vae, [a]);
|
|
1578
1576
|
}
|
|
1579
1577
|
function Ei(t, e, n) {
|
|
1580
1578
|
const r = gi(e, n, t.useDateObjects);
|
|
@@ -1582,13 +1580,13 @@ function Ei(t, e, n) {
|
|
|
1582
1580
|
t[i] = r[i];
|
|
1583
1581
|
});
|
|
1584
1582
|
}
|
|
1585
|
-
function
|
|
1583
|
+
function uo(t, [e]) {
|
|
1586
1584
|
t.addAttr(e);
|
|
1587
1585
|
}
|
|
1588
1586
|
function Ai(t) {
|
|
1589
1587
|
return Z(t.eav, 3);
|
|
1590
1588
|
}
|
|
1591
|
-
function
|
|
1589
|
+
function ao(t, e, [n]) {
|
|
1592
1590
|
if (!e.getAttr(n))
|
|
1593
1591
|
return;
|
|
1594
1592
|
const r = Ai(t).filter(([i, s]) => s !== n);
|
|
@@ -1613,10 +1611,10 @@ function fo(t, e, n) {
|
|
|
1613
1611
|
cn(t, e, i);
|
|
1614
1612
|
break;
|
|
1615
1613
|
case "add-attr":
|
|
1616
|
-
|
|
1614
|
+
uo(e, i);
|
|
1617
1615
|
break;
|
|
1618
1616
|
case "delete-attr":
|
|
1619
|
-
|
|
1617
|
+
ao(t, e, i);
|
|
1620
1618
|
break;
|
|
1621
1619
|
case "update-attr":
|
|
1622
1620
|
co(t, e, i);
|
|
@@ -1650,17 +1648,17 @@ function gt(t, e, n) {
|
|
|
1650
1648
|
return i;
|
|
1651
1649
|
}
|
|
1652
1650
|
if (n != null && n.hasOwnProperty("$isNull")) {
|
|
1653
|
-
const { attrId: o, isNull:
|
|
1654
|
-
if (
|
|
1651
|
+
const { attrId: o, isNull: u, reverse: a } = n.$isNull;
|
|
1652
|
+
if (a)
|
|
1655
1653
|
for (const c of e.keys()) {
|
|
1656
1654
|
const d = t.vae.get(c), f = !d || !d.get(o);
|
|
1657
|
-
(
|
|
1655
|
+
(u ? f : !f) && i.push(e.get(c));
|
|
1658
1656
|
}
|
|
1659
1657
|
else {
|
|
1660
1658
|
const c = t.aev.get(o);
|
|
1661
1659
|
for (const d of e.keys()) {
|
|
1662
1660
|
const f = !c || ((r = c.get(d)) === null || r === void 0 ? void 0 : r.get(null)) || !c.get(d);
|
|
1663
|
-
(
|
|
1661
|
+
(u ? f : !f) && i.push(e.get(d));
|
|
1664
1662
|
}
|
|
1665
1663
|
}
|
|
1666
1664
|
return i;
|
|
@@ -1669,8 +1667,8 @@ function gt(t, e, n) {
|
|
|
1669
1667
|
return Z(e, 1).filter(n.$op);
|
|
1670
1668
|
const s = n.in || n.$in || [n];
|
|
1671
1669
|
for (const o of s) {
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1670
|
+
const u = e.get(o);
|
|
1671
|
+
u && i.push(u);
|
|
1674
1672
|
}
|
|
1675
1673
|
return i;
|
|
1676
1674
|
}
|
|
@@ -1682,46 +1680,46 @@ function ho(t, [e, n, r]) {
|
|
|
1682
1680
|
var i, s;
|
|
1683
1681
|
switch (lo(e, n, r)) {
|
|
1684
1682
|
case "e": {
|
|
1685
|
-
const
|
|
1686
|
-
return Z(
|
|
1683
|
+
const u = t.eav.get(e);
|
|
1684
|
+
return Z(u, 2);
|
|
1687
1685
|
}
|
|
1688
1686
|
case "ea": {
|
|
1689
|
-
const
|
|
1690
|
-
return Z(
|
|
1687
|
+
const u = (i = t.eav.get(e)) === null || i === void 0 ? void 0 : i.get(n);
|
|
1688
|
+
return Z(u, 1);
|
|
1691
1689
|
}
|
|
1692
1690
|
case "eav": {
|
|
1693
|
-
const
|
|
1694
|
-
return
|
|
1691
|
+
const u = (s = t.eav.get(e)) === null || s === void 0 ? void 0 : s.get(n);
|
|
1692
|
+
return u ? gt(t, u, r) : [];
|
|
1695
1693
|
}
|
|
1696
1694
|
case "ev": {
|
|
1697
|
-
const
|
|
1698
|
-
if (!
|
|
1695
|
+
const u = t.eav.get(e);
|
|
1696
|
+
if (!u)
|
|
1699
1697
|
return [];
|
|
1700
|
-
const
|
|
1701
|
-
for (const c of
|
|
1702
|
-
|
|
1703
|
-
return
|
|
1698
|
+
const a = [];
|
|
1699
|
+
for (const c of u.values())
|
|
1700
|
+
a.push(...gt(t, c, r));
|
|
1701
|
+
return a;
|
|
1704
1702
|
}
|
|
1705
1703
|
case "a": {
|
|
1706
|
-
const
|
|
1707
|
-
return Z(
|
|
1704
|
+
const u = t.aev.get(n);
|
|
1705
|
+
return Z(u, 2);
|
|
1708
1706
|
}
|
|
1709
1707
|
case "av": {
|
|
1710
|
-
const
|
|
1711
|
-
if (!
|
|
1708
|
+
const u = t.aev.get(n);
|
|
1709
|
+
if (!u)
|
|
1712
1710
|
return [];
|
|
1713
|
-
const u = [];
|
|
1714
|
-
for (const c of a.values())
|
|
1715
|
-
u.push(...gt(t, c, r));
|
|
1716
|
-
return u;
|
|
1717
|
-
}
|
|
1718
|
-
case "v": {
|
|
1719
1711
|
const a = [];
|
|
1720
|
-
for (const
|
|
1721
|
-
|
|
1722
|
-
a.push(...gt(t, c, r));
|
|
1712
|
+
for (const c of u.values())
|
|
1713
|
+
a.push(...gt(t, c, r));
|
|
1723
1714
|
return a;
|
|
1724
1715
|
}
|
|
1716
|
+
case "v": {
|
|
1717
|
+
const u = [];
|
|
1718
|
+
for (const a of t.eav.values())
|
|
1719
|
+
for (const c of a.values())
|
|
1720
|
+
u.push(...gt(t, c, r));
|
|
1721
|
+
return u;
|
|
1722
|
+
}
|
|
1725
1723
|
default:
|
|
1726
1724
|
return Z(t.eav, 3);
|
|
1727
1725
|
}
|
|
@@ -1732,8 +1730,8 @@ function po(t, e, n) {
|
|
|
1732
1730
|
if (!e)
|
|
1733
1731
|
return i;
|
|
1734
1732
|
for (const [s, o] of e.entries()) {
|
|
1735
|
-
const
|
|
1736
|
-
for (const c of
|
|
1733
|
+
const u = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), a = Z(u, 1);
|
|
1734
|
+
for (const c of a)
|
|
1737
1735
|
i[s] = c[2];
|
|
1738
1736
|
}
|
|
1739
1737
|
return i;
|
|
@@ -1763,10 +1761,10 @@ function bo(t, e, n) {
|
|
|
1763
1761
|
return We(t.eav, [i, s]);
|
|
1764
1762
|
}
|
|
1765
1763
|
function _o(t, e, n) {
|
|
1766
|
-
const r = n.filter(([i, s, o,
|
|
1764
|
+
const r = n.filter(([i, s, o, u, a]) => {
|
|
1767
1765
|
if (i !== "add-triple" && i !== "deep-merge-triple")
|
|
1768
1766
|
return !0;
|
|
1769
|
-
const c =
|
|
1767
|
+
const c = a == null ? void 0 : a.mode;
|
|
1770
1768
|
if (c !== "create" && c !== "update")
|
|
1771
1769
|
return !0;
|
|
1772
1770
|
let d = !1;
|
|
@@ -1952,23 +1950,23 @@ function qo(t, e, n) {
|
|
|
1952
1950
|
return t.map((r) => r === e ? n : r);
|
|
1953
1951
|
}
|
|
1954
1952
|
function Ci(t, e, n, r, i) {
|
|
1955
|
-
const s = K(e, n, i), o = Ie(e, n, i),
|
|
1956
|
-
if (!
|
|
1953
|
+
const s = K(e, n, i), o = Ie(e, n, i), u = s || o;
|
|
1954
|
+
if (!u)
|
|
1957
1955
|
throw new Ke(`Could not find attr for ${[n, i]}`);
|
|
1958
|
-
if (
|
|
1959
|
-
throw new Error(`Attr ${
|
|
1960
|
-
const [
|
|
1956
|
+
if (u["value-type"] !== "ref")
|
|
1957
|
+
throw new Error(`Attr ${u.id} is not a ref`);
|
|
1958
|
+
const [a, c] = u["forward-identity"], [d, f] = u["reverse-identity"], l = r + 1, p = s ? [
|
|
1961
1959
|
t(c, r),
|
|
1962
|
-
|
|
1960
|
+
u.id,
|
|
1963
1961
|
t(f, l),
|
|
1964
1962
|
nt("time")
|
|
1965
1963
|
] : [
|
|
1966
1964
|
t(c, l),
|
|
1967
|
-
|
|
1965
|
+
u.id,
|
|
1968
1966
|
t(f, r),
|
|
1969
1967
|
nt("time")
|
|
1970
1968
|
];
|
|
1971
|
-
return [s ? f : c, l, p,
|
|
1969
|
+
return [s ? f : c, l, p, u, !!s];
|
|
1972
1970
|
}
|
|
1973
1971
|
function Ar(t, e) {
|
|
1974
1972
|
if (typeof e != "string")
|
|
@@ -2041,8 +2039,8 @@ function Wo(t, e) {
|
|
|
2041
2039
|
return e;
|
|
2042
2040
|
}
|
|
2043
2041
|
function zo(t, e, n, r, i, s) {
|
|
2044
|
-
const o = K(e, n, i),
|
|
2045
|
-
if (!
|
|
2042
|
+
const o = K(e, n, i), u = Ie(e, n, i), a = o || u;
|
|
2043
|
+
if (!a)
|
|
2046
2044
|
throw new Ke(`No attr for etype = ${n} label = ${i}`);
|
|
2047
2045
|
if (s != null && s.hasOwnProperty("$isNull")) {
|
|
2048
2046
|
const c = K(e, n, "id");
|
|
@@ -2051,26 +2049,26 @@ function zo(t, e, n, r, i, s) {
|
|
|
2051
2049
|
return [
|
|
2052
2050
|
t(n, r),
|
|
2053
2051
|
c.id,
|
|
2054
|
-
{ $isNull: { attrId:
|
|
2052
|
+
{ $isNull: { attrId: a.id, isNull: s.$isNull, reverse: !o } },
|
|
2055
2053
|
nt("time")
|
|
2056
2054
|
];
|
|
2057
2055
|
}
|
|
2058
2056
|
return o ? [
|
|
2059
2057
|
t(n, r),
|
|
2060
|
-
|
|
2061
|
-
Wo(
|
|
2058
|
+
a.id,
|
|
2059
|
+
Wo(a, s),
|
|
2062
2060
|
nt("time")
|
|
2063
|
-
] : [s,
|
|
2061
|
+
] : [s, a.id, t(n, r), nt("time")];
|
|
2064
2062
|
}
|
|
2065
2063
|
function Vo(t, e, n, r, i) {
|
|
2066
|
-
const [s, o,
|
|
2067
|
-
const [d, f, l] =
|
|
2064
|
+
const [s, o, u] = i.reduce((a, c) => {
|
|
2065
|
+
const [d, f, l] = a, [p, y, b] = Ci(t, e, d, f, c);
|
|
2068
2066
|
return [p, y, [...l, b]];
|
|
2069
2067
|
}, [n, r, []]);
|
|
2070
|
-
return [s, o,
|
|
2068
|
+
return [s, o, u];
|
|
2071
2069
|
}
|
|
2072
2070
|
function fn(t, e, n, r, i, s) {
|
|
2073
|
-
const o = i.slice(0, i.length - 1),
|
|
2071
|
+
const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = Vo(t, e, n, r, o), f = zo(t, e, a, c, u, s);
|
|
2074
2072
|
return d.concat([f]);
|
|
2075
2073
|
}
|
|
2076
2074
|
function Bo(t, e) {
|
|
@@ -2089,11 +2087,11 @@ function Ho(t, e, n) {
|
|
|
2089
2087
|
};
|
|
2090
2088
|
}
|
|
2091
2089
|
function kr(t, e, n, r, i, s) {
|
|
2092
|
-
const o = t(r, i),
|
|
2090
|
+
const o = t(r, i), u = s.map((a, c) => {
|
|
2093
2091
|
const d = Ho(t, o, c);
|
|
2094
|
-
return Ii(d, n, r, i,
|
|
2092
|
+
return Ii(d, n, r, i, a);
|
|
2095
2093
|
});
|
|
2096
|
-
return { [e]: { patterns:
|
|
2094
|
+
return { [e]: { patterns: u, joinSym: o } };
|
|
2097
2095
|
}
|
|
2098
2096
|
function Yo(t) {
|
|
2099
2097
|
const e = [];
|
|
@@ -2114,26 +2112,26 @@ function Ii(t, e, n, r, i) {
|
|
|
2114
2112
|
return kr(t, "and", e, n, r, o);
|
|
2115
2113
|
if (s === "$entityIdStartsWith")
|
|
2116
2114
|
return [];
|
|
2117
|
-
const
|
|
2115
|
+
const u = s.split(".");
|
|
2118
2116
|
if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
|
|
2119
|
-
const
|
|
2117
|
+
const a = fn(t, e, n, r, u, o), c = jr(t, e, n, r, u);
|
|
2120
2118
|
return [
|
|
2121
2119
|
{
|
|
2122
2120
|
or: {
|
|
2123
|
-
patterns: [
|
|
2121
|
+
patterns: [a, ...c],
|
|
2124
2122
|
joinSym: t(n, r)
|
|
2125
2123
|
}
|
|
2126
2124
|
}
|
|
2127
2125
|
];
|
|
2128
2126
|
}
|
|
2129
|
-
return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 &&
|
|
2127
|
+
return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && u.length > 1 ? [
|
|
2130
2128
|
{
|
|
2131
2129
|
or: {
|
|
2132
|
-
patterns: jr(t, e, n, r,
|
|
2130
|
+
patterns: jr(t, e, n, r, u),
|
|
2133
2131
|
joinSym: t(n, r)
|
|
2134
2132
|
}
|
|
2135
2133
|
}
|
|
2136
|
-
] : fn(t, e, n, r,
|
|
2134
|
+
] : fn(t, e, n, r, u, o);
|
|
2137
2135
|
});
|
|
2138
2136
|
}
|
|
2139
2137
|
function Jo(t, e, n, r) {
|
|
@@ -2144,13 +2142,13 @@ function Zo(t, e, n) {
|
|
|
2144
2142
|
return [t(e, n), t("time", n)];
|
|
2145
2143
|
}
|
|
2146
2144
|
function Xo(t, e, n, r, i, s) {
|
|
2147
|
-
const [o,
|
|
2148
|
-
return [o,
|
|
2145
|
+
const [o, u, a, c, d] = Ci(t, e, n, r, i), f = qo(a, t(n, r), s);
|
|
2146
|
+
return [o, u, f, c, d];
|
|
2149
2147
|
}
|
|
2150
|
-
function
|
|
2151
|
-
const
|
|
2152
|
-
return
|
|
2153
|
-
return
|
|
2148
|
+
function eu(t, e, n, { etype: r, level: i, form: s }, o) {
|
|
2149
|
+
const u = Object.keys(s).filter((a) => a !== "$");
|
|
2150
|
+
return u.length ? Object.entries(o).map(function([c, d]) {
|
|
2151
|
+
return u.map(function(p) {
|
|
2154
2152
|
var y, b, _;
|
|
2155
2153
|
const T = !!(e.cardinalityInference && (!((_ = (b = (y = n.linkIndex) === null || y === void 0 ? void 0 : y[r]) === null || b === void 0 ? void 0 : b[p]) === null || _ === void 0) && _.isSingular));
|
|
2156
2154
|
try {
|
|
@@ -2171,11 +2169,11 @@ function ea(t, e, n, { etype: r, level: i, form: s }, o) {
|
|
|
2171
2169
|
}, d);
|
|
2172
2170
|
}) : Object.values(o);
|
|
2173
2171
|
}
|
|
2174
|
-
function
|
|
2172
|
+
function tu(t, e, n) {
|
|
2175
2173
|
return n === "string" ? Lo(t, e) : t > e ? 1 : -1;
|
|
2176
2174
|
}
|
|
2177
2175
|
function Ze(t, e, n, r, i) {
|
|
2178
|
-
return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 :
|
|
2176
|
+
return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 : tu(e, r, i);
|
|
2179
2177
|
}
|
|
2180
2178
|
function Pt([t, e], [n, r], i) {
|
|
2181
2179
|
return Ze(t, e, n, r, i);
|
|
@@ -2183,49 +2181,49 @@ function Pt([t, e], [n, r], i) {
|
|
|
2183
2181
|
function ln(t) {
|
|
2184
2182
|
return t == null ? t : new Date(t).getTime();
|
|
2185
2183
|
}
|
|
2186
|
-
function
|
|
2184
|
+
function nu(t, e, n, r) {
|
|
2187
2185
|
var i;
|
|
2188
|
-
const [s, o,
|
|
2186
|
+
const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
|
|
2189
2187
|
if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
|
|
2190
|
-
return Pt(r, [s,
|
|
2191
|
-
const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(
|
|
2188
|
+
return Pt(r, [s, a], null) === c;
|
|
2189
|
+
const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(u) : u;
|
|
2192
2190
|
return Pt([d, p], [s, y], l) === c;
|
|
2193
2191
|
}
|
|
2194
|
-
function
|
|
2192
|
+
function ru(t, e) {
|
|
2195
2193
|
const n = e[1];
|
|
2196
2194
|
return t.getAttr(n);
|
|
2197
2195
|
}
|
|
2198
|
-
function
|
|
2196
|
+
function iu(t, e, n) {
|
|
2199
2197
|
const r = Object.keys(n)[0];
|
|
2200
2198
|
return K(t, e, r);
|
|
2201
2199
|
}
|
|
2202
|
-
function
|
|
2200
|
+
function su(t, e, n, r) {
|
|
2203
2201
|
if (n)
|
|
2204
|
-
return
|
|
2202
|
+
return ru(t, n);
|
|
2205
2203
|
if (r)
|
|
2206
|
-
return
|
|
2204
|
+
return iu(t, e, r);
|
|
2207
2205
|
}
|
|
2208
|
-
function
|
|
2206
|
+
function ou(t, e, n) {
|
|
2209
2207
|
var r, i;
|
|
2210
2208
|
if (!Array.isArray(n.fields))
|
|
2211
2209
|
return yo(t, e);
|
|
2212
2210
|
const s = /* @__PURE__ */ new Map();
|
|
2213
2211
|
for (const o of n.fields) {
|
|
2214
|
-
const
|
|
2215
|
-
|
|
2212
|
+
const u = K(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
|
|
2213
|
+
a && Fn(u) && s.set(a, u);
|
|
2216
2214
|
}
|
|
2217
2215
|
if (!s.has("id")) {
|
|
2218
|
-
const o = K(t, e, "id"),
|
|
2219
|
-
|
|
2216
|
+
const o = K(t, e, "id"), u = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
|
|
2217
|
+
u && s.set(u, o);
|
|
2220
2218
|
}
|
|
2221
2219
|
return s;
|
|
2222
2220
|
}
|
|
2223
|
-
function
|
|
2224
|
-
var o,
|
|
2225
|
-
const
|
|
2221
|
+
function uu(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
|
|
2222
|
+
var o, u;
|
|
2223
|
+
const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = au(s);
|
|
2226
2224
|
let f = Ao(t, i);
|
|
2227
|
-
const l = r == null ? void 0 : r["start-cursor"], p =
|
|
2228
|
-
if (p && ((
|
|
2225
|
+
const l = r == null ? void 0 : r["start-cursor"], p = su(e, n, l, a);
|
|
2226
|
+
if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
|
|
2229
2227
|
const _ = p["checked-data-type"] === "date", T = p.id;
|
|
2230
2228
|
f = f.map(([g]) => {
|
|
2231
2229
|
var m, O, S, C, $;
|
|
@@ -2239,17 +2237,17 @@ function aa(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
|
|
|
2239
2237
|
return Pt(g, T, p == null ? void 0 : p["checked-data-type"]);
|
|
2240
2238
|
});
|
|
2241
2239
|
let y = {};
|
|
2242
|
-
const b =
|
|
2240
|
+
const b = ou(e, n, i);
|
|
2243
2241
|
for (const _ of f) {
|
|
2244
2242
|
const [T] = _;
|
|
2245
|
-
if (y[T] || !c && l && p &&
|
|
2243
|
+
if (y[T] || !c && l && p && nu(l, p, d, _))
|
|
2246
2244
|
continue;
|
|
2247
2245
|
const g = po(t, b, T);
|
|
2248
2246
|
g && (y[T] = g);
|
|
2249
2247
|
}
|
|
2250
2248
|
return y;
|
|
2251
2249
|
}
|
|
2252
|
-
function
|
|
2250
|
+
function au(t) {
|
|
2253
2251
|
var e;
|
|
2254
2252
|
const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
|
|
2255
2253
|
return n && n[Object.keys(n)[0]] || "asc";
|
|
@@ -2259,11 +2257,11 @@ function Pi(t) {
|
|
|
2259
2257
|
const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
|
|
2260
2258
|
return !i && !s && !o;
|
|
2261
2259
|
}
|
|
2262
|
-
function
|
|
2263
|
-
var
|
|
2260
|
+
function cu(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
|
|
2261
|
+
var u, a, c, d, f;
|
|
2264
2262
|
if (!Pi(i) && (!o || !o["start-cursor"]))
|
|
2265
2263
|
return [];
|
|
2266
|
-
const l = Bo(Jo(e, n, r, (
|
|
2264
|
+
const l = Bo(Jo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = Zo($t, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = uu(t, e, {
|
|
2267
2265
|
etype: n,
|
|
2268
2266
|
pageInfo: o,
|
|
2269
2267
|
form: i,
|
|
@@ -2276,9 +2274,9 @@ function ca(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
|
|
|
2276
2274
|
}
|
|
2277
2275
|
return b;
|
|
2278
2276
|
}
|
|
2279
|
-
function
|
|
2277
|
+
function du(t, e, n) {
|
|
2280
2278
|
try {
|
|
2281
|
-
return
|
|
2279
|
+
return cu(t, e, n);
|
|
2282
2280
|
} catch (r) {
|
|
2283
2281
|
if (r instanceof Ke)
|
|
2284
2282
|
return {};
|
|
@@ -2286,10 +2284,10 @@ function da(t, e, n) {
|
|
|
2286
2284
|
}
|
|
2287
2285
|
}
|
|
2288
2286
|
function Mi(t, e, n) {
|
|
2289
|
-
const r =
|
|
2290
|
-
return
|
|
2287
|
+
const r = du(t, e, n);
|
|
2288
|
+
return eu($t, t, e, n, r);
|
|
2291
2289
|
}
|
|
2292
|
-
function
|
|
2290
|
+
function fu(t) {
|
|
2293
2291
|
const e = {};
|
|
2294
2292
|
for (const [n, r] of Object.entries(t))
|
|
2295
2293
|
e[n] = {
|
|
@@ -2301,17 +2299,17 @@ function fa(t) {
|
|
|
2301
2299
|
return e;
|
|
2302
2300
|
}
|
|
2303
2301
|
function Ri({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
|
|
2304
|
-
const o = { data: Object.keys(i).reduce(function(
|
|
2305
|
-
return r != null && r[c] || c === "$$ruleParams" || (
|
|
2302
|
+
const o = { data: Object.keys(i).reduce(function(a, c) {
|
|
2303
|
+
return r != null && r[c] || c === "$$ruleParams" || (a[c] = Mi(t, e, {
|
|
2306
2304
|
etype: c,
|
|
2307
2305
|
form: i[c],
|
|
2308
2306
|
level: 0,
|
|
2309
2307
|
pageInfo: n == null ? void 0 : n[c]
|
|
2310
|
-
})),
|
|
2308
|
+
})), a;
|
|
2311
2309
|
}, {}) };
|
|
2312
|
-
return n && (o.pageInfo =
|
|
2310
|
+
return n && (o.pageInfo = fu(n)), r && (o.aggregate = r), o;
|
|
2313
2311
|
}
|
|
2314
|
-
function
|
|
2312
|
+
function lu() {
|
|
2315
2313
|
const e = {
|
|
2316
2314
|
__etype: 1,
|
|
2317
2315
|
__ops: 1,
|
|
@@ -2325,7 +2323,7 @@ function la() {
|
|
|
2325
2323
|
};
|
|
2326
2324
|
return new Set(Object.keys(e));
|
|
2327
2325
|
}
|
|
2328
|
-
const
|
|
2326
|
+
const hu = lu();
|
|
2329
2327
|
function hn(t, e, n) {
|
|
2330
2328
|
const r = {
|
|
2331
2329
|
__etype: t,
|
|
@@ -2337,10 +2335,10 @@ function hn(t, e, n) {
|
|
|
2337
2335
|
return n;
|
|
2338
2336
|
if (s === "__etype")
|
|
2339
2337
|
return t;
|
|
2340
|
-
if (
|
|
2341
|
-
return (o,
|
|
2338
|
+
if (hu.has(s))
|
|
2339
|
+
return (o, u) => hn(t, e, [
|
|
2342
2340
|
...n,
|
|
2343
|
-
|
|
2341
|
+
u ? [s, t, e, o, u] : [s, t, e, o]
|
|
2344
2342
|
]);
|
|
2345
2343
|
}
|
|
2346
2344
|
});
|
|
@@ -2355,7 +2353,7 @@ function xi(t) {
|
|
|
2355
2353
|
const [e, n, ...r] = t.split("__");
|
|
2356
2354
|
return [n, JSON.parse(r.join("__"))];
|
|
2357
2355
|
}
|
|
2358
|
-
function
|
|
2356
|
+
function pu(t) {
|
|
2359
2357
|
return new Proxy({
|
|
2360
2358
|
__etype: t
|
|
2361
2359
|
}, {
|
|
@@ -2370,23 +2368,23 @@ function pa(t) {
|
|
|
2370
2368
|
function Kn() {
|
|
2371
2369
|
return new Proxy({}, {
|
|
2372
2370
|
get(t, e) {
|
|
2373
|
-
return
|
|
2371
|
+
return pu(e);
|
|
2374
2372
|
}
|
|
2375
2373
|
});
|
|
2376
2374
|
}
|
|
2377
2375
|
const Lc = Kn();
|
|
2378
|
-
function
|
|
2376
|
+
function yu(t) {
|
|
2379
2377
|
return t.__ops;
|
|
2380
2378
|
}
|
|
2381
|
-
function
|
|
2379
|
+
function bu(t, e) {
|
|
2382
2380
|
const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
|
|
2383
2381
|
for (const o of e) {
|
|
2384
|
-
const
|
|
2385
|
-
if (
|
|
2386
|
-
i.push(
|
|
2382
|
+
const u = n[o];
|
|
2383
|
+
if (u)
|
|
2384
|
+
i.push(u);
|
|
2387
2385
|
else if (Array.isArray(o) && o.length == 2 && n[o[0]]) {
|
|
2388
|
-
const [
|
|
2389
|
-
i.push([n[
|
|
2386
|
+
const [a, c] = o;
|
|
2387
|
+
i.push([n[a], c]);
|
|
2390
2388
|
} else
|
|
2391
2389
|
i.push(o);
|
|
2392
2390
|
}
|
|
@@ -2397,7 +2395,7 @@ function ba(t, e) {
|
|
|
2397
2395
|
}
|
|
2398
2396
|
return i;
|
|
2399
2397
|
}
|
|
2400
|
-
function
|
|
2398
|
+
function _u(t) {
|
|
2401
2399
|
if (Array.isArray(t))
|
|
2402
2400
|
return t;
|
|
2403
2401
|
const e = Object.entries(t);
|
|
@@ -2405,7 +2403,7 @@ function _a(t) {
|
|
|
2405
2403
|
throw new Error("lookup must be an object with a single unique attr and value.");
|
|
2406
2404
|
return e[0];
|
|
2407
2405
|
}
|
|
2408
|
-
function
|
|
2406
|
+
function gu(t, e, n) {
|
|
2409
2407
|
return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2410
2408
|
// before assuming it's a ref lookup.
|
|
2411
2409
|
!K(t, e, n);
|
|
@@ -2416,8 +2414,8 @@ function pn(t) {
|
|
|
2416
2414
|
throw new Error(`${t} is not a valid lookup attribute.`);
|
|
2417
2415
|
return e;
|
|
2418
2416
|
}
|
|
2419
|
-
function
|
|
2420
|
-
if (!
|
|
2417
|
+
function wu(t, e, n) {
|
|
2418
|
+
if (!gu(t, e, n))
|
|
2421
2419
|
return K(t, e, n);
|
|
2422
2420
|
const r = pn(n), i = K(t, e, r) || Ie(t, e, r);
|
|
2423
2421
|
if (i && i["value-type"] !== "ref")
|
|
@@ -2425,13 +2423,13 @@ function wa(t, e, n) {
|
|
|
2425
2423
|
return i;
|
|
2426
2424
|
}
|
|
2427
2425
|
function yn(t) {
|
|
2428
|
-
return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) :
|
|
2426
|
+
return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : _u(t);
|
|
2429
2427
|
}
|
|
2430
2428
|
function X(t, e, n) {
|
|
2431
2429
|
const r = yn(n);
|
|
2432
2430
|
if (r === null)
|
|
2433
2431
|
return n;
|
|
2434
|
-
const [i, s] = r, o =
|
|
2432
|
+
const [i, s] = r, o = wu(t, e, i);
|
|
2435
2433
|
if (!o || !o["unique?"])
|
|
2436
2434
|
throw new Error(`${i} is not a unique attribute.`);
|
|
2437
2435
|
return [o.id, s];
|
|
@@ -2446,18 +2444,20 @@ function $i(t, e, n, r) {
|
|
|
2446
2444
|
s
|
|
2447
2445
|
]].concat(r) : r;
|
|
2448
2446
|
}
|
|
2449
|
-
function
|
|
2447
|
+
function Tu({ attrsStore: t }, [e, n, r]) {
|
|
2450
2448
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
2451
|
-
const
|
|
2452
|
-
return
|
|
2449
|
+
const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
|
|
2450
|
+
return u.map((d) => a ? [
|
|
2453
2451
|
"add-triple",
|
|
2454
2452
|
X(t, e, n),
|
|
2455
|
-
|
|
2456
|
-
//
|
|
2457
|
-
|
|
2453
|
+
a.id,
|
|
2454
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2455
|
+
// already exist
|
|
2456
|
+
X(t, a["reverse-identity"][1], d)
|
|
2458
2457
|
] : [
|
|
2459
2458
|
"add-triple",
|
|
2460
|
-
//
|
|
2459
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2460
|
+
// already exist
|
|
2461
2461
|
X(t, c["forward-identity"][1], d),
|
|
2462
2462
|
c == null ? void 0 : c.id,
|
|
2463
2463
|
X(t, e, n)
|
|
@@ -2465,18 +2465,20 @@ function Ta({ attrsStore: t }, [e, n, r]) {
|
|
|
2465
2465
|
});
|
|
2466
2466
|
return $i(t, e, n, i);
|
|
2467
2467
|
}
|
|
2468
|
-
function
|
|
2468
|
+
function mu({ attrsStore: t }, [e, n, r]) {
|
|
2469
2469
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
2470
|
-
const
|
|
2471
|
-
return
|
|
2470
|
+
const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
|
|
2471
|
+
return u.map((d) => a ? [
|
|
2472
2472
|
"retract-triple",
|
|
2473
2473
|
X(t, e, n),
|
|
2474
|
-
|
|
2475
|
-
//
|
|
2476
|
-
|
|
2474
|
+
a.id,
|
|
2475
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2476
|
+
// already exist
|
|
2477
|
+
X(t, a["reverse-identity"][1], d)
|
|
2477
2478
|
] : [
|
|
2478
2479
|
"retract-triple",
|
|
2479
|
-
//
|
|
2480
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2481
|
+
// already exist
|
|
2480
2482
|
X(t, c["forward-identity"][1], d),
|
|
2481
2483
|
c.id,
|
|
2482
2484
|
X(t, e, n)
|
|
@@ -2484,14 +2486,14 @@ function ma({ attrsStore: t }, [e, n, r]) {
|
|
|
2484
2486
|
});
|
|
2485
2487
|
return $i(t, e, n, i);
|
|
2486
2488
|
}
|
|
2487
|
-
function
|
|
2489
|
+
function vu(t, e, n, r) {
|
|
2488
2490
|
var i;
|
|
2489
2491
|
if (Array.isArray(r)) {
|
|
2490
2492
|
const [s, o] = r;
|
|
2491
|
-
for (const
|
|
2492
|
-
const
|
|
2493
|
-
if (
|
|
2494
|
-
for (const [c, d, f] of Z(
|
|
2493
|
+
for (const u of t || []) {
|
|
2494
|
+
const a = u == null ? void 0 : u.aev.get(s);
|
|
2495
|
+
if (a) {
|
|
2496
|
+
for (const [c, d, f] of Z(a, 2))
|
|
2495
2497
|
if (f === o)
|
|
2496
2498
|
return !0;
|
|
2497
2499
|
}
|
|
@@ -2500,45 +2502,45 @@ function va(t, e, n, r) {
|
|
|
2500
2502
|
for (const s of t || []) {
|
|
2501
2503
|
const o = s == null ? void 0 : s.eav.get(r);
|
|
2502
2504
|
if (o) {
|
|
2503
|
-
for (const
|
|
2504
|
-
if (((i = e.getAttr(
|
|
2505
|
+
for (const u of o.keys())
|
|
2506
|
+
if (((i = e.getAttr(u)) === null || i === void 0 ? void 0 : i["forward-identity"][1]) == n)
|
|
2505
2507
|
return !0;
|
|
2506
2508
|
}
|
|
2507
2509
|
}
|
|
2508
2510
|
return !1;
|
|
2509
2511
|
}
|
|
2510
2512
|
function Di({ stores: t, attrsStore: e }, [n, r, i, s]) {
|
|
2511
|
-
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null :
|
|
2513
|
+
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : vu(t, e, n, r) ? { mode: "update" } : null;
|
|
2512
2514
|
}
|
|
2513
|
-
function
|
|
2514
|
-
const { attrsStore: n } = t, [r, i, s, o] = e,
|
|
2515
|
-
return [["id",
|
|
2515
|
+
function Su(t, e) {
|
|
2516
|
+
const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = X(n, r, i);
|
|
2517
|
+
return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
|
|
2516
2518
|
const l = K(n, r, d);
|
|
2517
|
-
return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple",
|
|
2519
|
+
return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
|
|
2518
2520
|
});
|
|
2519
2521
|
}
|
|
2520
|
-
function
|
|
2521
|
-
const { attrsStore: n } = t, [r, i, s, o] = e,
|
|
2522
|
-
return [["id",
|
|
2522
|
+
function Ou(t, e) {
|
|
2523
|
+
const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = X(n, r, i), c = Di(t, [r, a, s, o]);
|
|
2524
|
+
return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
|
|
2523
2525
|
const p = K(n, r, f);
|
|
2524
2526
|
return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), [
|
|
2525
2527
|
"add-triple",
|
|
2526
|
-
|
|
2528
|
+
a,
|
|
2527
2529
|
p.id,
|
|
2528
2530
|
l,
|
|
2529
2531
|
...c ? [c] : []
|
|
2530
2532
|
];
|
|
2531
2533
|
});
|
|
2532
2534
|
}
|
|
2533
|
-
function
|
|
2535
|
+
function Eu({ attrsStore: t }, [e, n]) {
|
|
2534
2536
|
return [["delete-entity", X(t, e, n), e]];
|
|
2535
2537
|
}
|
|
2536
|
-
function
|
|
2537
|
-
const { attrsStore: n } = t, [r, i, s, o] = e,
|
|
2538
|
+
function Au(t, e) {
|
|
2539
|
+
const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = X(n, r, i), c = Di(t, [r, a, s, o]), d = Object.entries(u).map(([l, p]) => {
|
|
2538
2540
|
const y = K(n, r, l);
|
|
2539
2541
|
return [
|
|
2540
2542
|
"deep-merge-triple",
|
|
2541
|
-
|
|
2543
|
+
a,
|
|
2542
2544
|
y.id,
|
|
2543
2545
|
p,
|
|
2544
2546
|
...c ? [c] : []
|
|
@@ -2546,44 +2548,44 @@ function Aa(t, e) {
|
|
|
2546
2548
|
});
|
|
2547
2549
|
return [[
|
|
2548
2550
|
"add-triple",
|
|
2549
|
-
|
|
2551
|
+
a,
|
|
2550
2552
|
K(n, r, "id").id,
|
|
2551
|
-
|
|
2553
|
+
a,
|
|
2552
2554
|
...c ? [c] : []
|
|
2553
2555
|
]].concat(d);
|
|
2554
2556
|
}
|
|
2555
|
-
function
|
|
2557
|
+
function ku({ attrsStore: t }, [e, n, r]) {
|
|
2556
2558
|
return [["rule-params", X(t, e, n), e, r]];
|
|
2557
2559
|
}
|
|
2558
|
-
function
|
|
2560
|
+
function ju(t) {
|
|
2559
2561
|
const [e, n, r, i, s] = t;
|
|
2560
2562
|
if (!i)
|
|
2561
2563
|
return t;
|
|
2562
2564
|
const o = Object.assign({}, i);
|
|
2563
2565
|
return delete o.id, [e, n, r, o, ...s ? [s] : []];
|
|
2564
2566
|
}
|
|
2565
|
-
function
|
|
2566
|
-
const [n, ...r] =
|
|
2567
|
+
function Cu(t, e) {
|
|
2568
|
+
const [n, ...r] = ju(e);
|
|
2567
2569
|
switch (n) {
|
|
2568
2570
|
case "merge":
|
|
2569
|
-
return
|
|
2571
|
+
return Au(t, r);
|
|
2570
2572
|
case "create":
|
|
2571
|
-
return
|
|
2573
|
+
return Su(t, r);
|
|
2572
2574
|
case "update":
|
|
2573
|
-
return
|
|
2575
|
+
return Ou(t, r);
|
|
2574
2576
|
case "link":
|
|
2575
|
-
return
|
|
2577
|
+
return Tu(t, r);
|
|
2576
2578
|
case "unlink":
|
|
2577
|
-
return
|
|
2579
|
+
return mu(t, r);
|
|
2578
2580
|
case "delete":
|
|
2579
|
-
return
|
|
2581
|
+
return Eu(t, r);
|
|
2580
2582
|
case "ruleParams":
|
|
2581
|
-
return
|
|
2583
|
+
return ku(t, r);
|
|
2582
2584
|
default:
|
|
2583
2585
|
throw new Error(`unsupported action ${n}`);
|
|
2584
2586
|
}
|
|
2585
2587
|
}
|
|
2586
|
-
function
|
|
2588
|
+
function Iu(t) {
|
|
2587
2589
|
switch (t) {
|
|
2588
2590
|
case "string":
|
|
2589
2591
|
case "date":
|
|
@@ -2594,29 +2596,29 @@ function Ia(t) {
|
|
|
2594
2596
|
return;
|
|
2595
2597
|
}
|
|
2596
2598
|
}
|
|
2597
|
-
function
|
|
2599
|
+
function Pu(t, e, n) {
|
|
2598
2600
|
var r, i;
|
|
2599
2601
|
const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
|
|
2600
2602
|
if (n === "id")
|
|
2601
2603
|
return null;
|
|
2602
2604
|
if (!s)
|
|
2603
2605
|
throw new Error(`${e}.${n} does not exist in your schema`);
|
|
2604
|
-
const { unique: o, indexed:
|
|
2606
|
+
const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Iu(s == null ? void 0 : s.valueType);
|
|
2605
2607
|
return {
|
|
2606
|
-
"index?":
|
|
2608
|
+
"index?": u,
|
|
2607
2609
|
"unique?": o,
|
|
2608
|
-
"checked-data-type":
|
|
2610
|
+
"checked-data-type": a
|
|
2609
2611
|
};
|
|
2610
2612
|
}
|
|
2611
2613
|
function wt(t, e, n, r) {
|
|
2612
|
-
const i = t ?
|
|
2613
|
-
return Object.assign(Object.assign({ id: s, "forward-identity":
|
|
2614
|
+
const i = t ? Pu(t, e, n) : null, s = W(), u = [W(), e, n];
|
|
2615
|
+
return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
|
|
2614
2616
|
}
|
|
2615
|
-
function
|
|
2617
|
+
function Mu(t, e, n) {
|
|
2616
2618
|
return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
|
|
2617
2619
|
}
|
|
2618
|
-
function
|
|
2619
|
-
const r =
|
|
2620
|
+
function Ru(t, e, n) {
|
|
2621
|
+
const r = Mu(t, e, n);
|
|
2620
2622
|
if (!r)
|
|
2621
2623
|
throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
|
|
2622
2624
|
const { forward: i, reverse: s } = r;
|
|
@@ -2630,13 +2632,13 @@ function Ra(t, e, n) {
|
|
|
2630
2632
|
};
|
|
2631
2633
|
}
|
|
2632
2634
|
function Cr(t, e, n, r) {
|
|
2633
|
-
const i = t ?
|
|
2635
|
+
const i = t ? Ru(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
|
|
2634
2636
|
return Object.assign(Object.assign({
|
|
2635
2637
|
id: s,
|
|
2636
2638
|
// @ts-ignore: ts thinks it's any[]
|
|
2637
2639
|
"forward-identity": o,
|
|
2638
2640
|
// @ts-ignore: ts thinks it's any[]
|
|
2639
|
-
"reverse-identity":
|
|
2641
|
+
"reverse-identity": u,
|
|
2640
2642
|
"value-type": "ref",
|
|
2641
2643
|
// @ts-ignore: ts thinks it's type string
|
|
2642
2644
|
cardinality: "many",
|
|
@@ -2645,7 +2647,7 @@ function Cr(t, e, n, r) {
|
|
|
2645
2647
|
isUnsynced: !0
|
|
2646
2648
|
}, i || {}), r || {});
|
|
2647
2649
|
}
|
|
2648
|
-
const
|
|
2650
|
+
const xu = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), $u = /* @__PURE__ */ new Set(["link", "unlink"]), Du = /* @__PURE__ */ new Set(["create", "update", "merge"]), Uu = /* @__PURE__ */ new Set([
|
|
2649
2651
|
"link",
|
|
2650
2652
|
"unlink",
|
|
2651
2653
|
"create",
|
|
@@ -2653,30 +2655,30 @@ const xa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
|
|
|
2653
2655
|
"merge",
|
|
2654
2656
|
"delete",
|
|
2655
2657
|
"ruleParams"
|
|
2656
|
-
]), bn = { "unique?": !0, "index?": !0 },
|
|
2657
|
-
function
|
|
2658
|
+
]), bn = { "unique?": !0, "index?": !0 }, Lu = Object.assign(Object.assign({}, bn), { cardinality: "one" });
|
|
2659
|
+
function Fu(t) {
|
|
2658
2660
|
const e = [], [n, r, i, s] = t;
|
|
2659
|
-
if (!
|
|
2661
|
+
if (!Uu.has(n))
|
|
2660
2662
|
return e;
|
|
2661
2663
|
const o = yn(i);
|
|
2662
2664
|
if (o && e.push({ etype: r, lookupPair: o }), n === "link")
|
|
2663
|
-
for (const [
|
|
2664
|
-
const c = Array.isArray(
|
|
2665
|
+
for (const [u, a] of Object.entries(s)) {
|
|
2666
|
+
const c = Array.isArray(a) ? a : [a];
|
|
2665
2667
|
for (const d of c) {
|
|
2666
2668
|
const f = yn(d);
|
|
2667
2669
|
f && e.push({
|
|
2668
2670
|
etype: r,
|
|
2669
2671
|
lookupPair: f,
|
|
2670
|
-
linkLabel:
|
|
2672
|
+
linkLabel: u
|
|
2671
2673
|
});
|
|
2672
2674
|
}
|
|
2673
2675
|
}
|
|
2674
2676
|
return e;
|
|
2675
2677
|
}
|
|
2676
|
-
function
|
|
2678
|
+
function Nu({ attrsStore: t, schema: e }, n) {
|
|
2677
2679
|
var r, i;
|
|
2678
|
-
const s = /* @__PURE__ */ new Set(), o = [],
|
|
2679
|
-
function
|
|
2680
|
+
const s = /* @__PURE__ */ new Set(), o = [], u = [];
|
|
2681
|
+
function a(y, b) {
|
|
2680
2682
|
return K(t, y, b) || o.find((_) => _["forward-identity"][1] === y && _["forward-identity"][2] === b);
|
|
2681
2683
|
}
|
|
2682
2684
|
function c(y, b) {
|
|
@@ -2686,49 +2688,49 @@ function Na({ attrsStore: t, schema: e }, n) {
|
|
|
2686
2688
|
});
|
|
2687
2689
|
}
|
|
2688
2690
|
function d(y) {
|
|
2689
|
-
o.push(y),
|
|
2691
|
+
o.push(y), u.push(["add-attr", y]), s.add(y.id);
|
|
2690
2692
|
}
|
|
2691
2693
|
function f(y) {
|
|
2692
|
-
y && "isUnsynced" in y && y.isUnsynced && !s.has(y.id) && (o.push(y),
|
|
2694
|
+
y && "isUnsynced" in y && y.isUnsynced && !s.has(y.id) && (o.push(y), u.push(["add-attr", y]), s.add(y.id));
|
|
2693
2695
|
}
|
|
2694
2696
|
function l(y, b) {
|
|
2695
2697
|
return b.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2696
2698
|
// before assuming it's a ref lookup.
|
|
2697
|
-
!
|
|
2699
|
+
!a(y, b);
|
|
2698
2700
|
}
|
|
2699
2701
|
function p(y, b) {
|
|
2700
|
-
const _ =
|
|
2701
|
-
f(_), f(T), !_ && !T && d(Cr(e, y, b,
|
|
2702
|
+
const _ = a(y, b), T = c(y, b);
|
|
2703
|
+
f(_), f(T), !_ && !T && d(Cr(e, y, b, Lu));
|
|
2702
2704
|
}
|
|
2703
2705
|
for (const y of n)
|
|
2704
|
-
for (const { etype: b, lookupPair: _, linkLabel: T } of
|
|
2706
|
+
for (const { etype: b, lookupPair: _, linkLabel: T } of Fu(y)) {
|
|
2705
2707
|
const g = _[0];
|
|
2706
2708
|
if (T) {
|
|
2707
2709
|
p(b, T);
|
|
2708
|
-
const m =
|
|
2710
|
+
const m = a(b, T), O = c(b, T);
|
|
2709
2711
|
f(m), f(O);
|
|
2710
2712
|
const S = ((r = m == null ? void 0 : m["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = O == null ? void 0 : O["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || T;
|
|
2711
2713
|
if (l(S, g))
|
|
2712
2714
|
p(S, pn(g));
|
|
2713
2715
|
else {
|
|
2714
|
-
const C =
|
|
2716
|
+
const C = a(S, g);
|
|
2715
2717
|
C || d(wt(e, S, g, bn)), f(C);
|
|
2716
2718
|
}
|
|
2717
2719
|
} else if (l(b, g))
|
|
2718
2720
|
p(b, pn(g));
|
|
2719
2721
|
else {
|
|
2720
|
-
const m =
|
|
2722
|
+
const m = a(b, g);
|
|
2721
2723
|
m || d(wt(e, b, g, bn)), f(m);
|
|
2722
2724
|
}
|
|
2723
2725
|
}
|
|
2724
2726
|
for (const y of n) {
|
|
2725
2727
|
const [b, _, T, g] = y;
|
|
2726
|
-
if (
|
|
2727
|
-
const m =
|
|
2728
|
+
if (xu.has(b)) {
|
|
2729
|
+
const m = a(_, "id");
|
|
2728
2730
|
f(m), m || d(wt(e, _, "id", { "unique?": !0 }));
|
|
2729
2731
|
for (const O of Object.keys(g)) {
|
|
2730
|
-
const S =
|
|
2731
|
-
if (f(S),
|
|
2732
|
+
const S = a(_, O);
|
|
2733
|
+
if (f(S), Du.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), $u.has(b)) {
|
|
2732
2734
|
const C = c(_, O);
|
|
2733
2735
|
!S && !C && d(Cr(e, _, O)), f(C);
|
|
2734
2736
|
}
|
|
@@ -2739,13 +2741,13 @@ function Na({ attrsStore: t, schema: e }, n) {
|
|
|
2739
2741
|
const y = Object.assign({}, t.attrs);
|
|
2740
2742
|
for (const b of o)
|
|
2741
2743
|
y[b.id] = b;
|
|
2742
|
-
return [new Ae(y, t.linkIndex),
|
|
2744
|
+
return [new Ae(y, t.linkIndex), u];
|
|
2743
2745
|
}
|
|
2744
|
-
return [t,
|
|
2746
|
+
return [t, u];
|
|
2745
2747
|
}
|
|
2746
|
-
function
|
|
2747
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((
|
|
2748
|
-
return [...s, ...
|
|
2748
|
+
function Ku(t, e) {
|
|
2749
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((a) => yu(a)), [i, s] = Nu(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Cu(o, a));
|
|
2750
|
+
return [...s, ...u];
|
|
2749
2751
|
}
|
|
2750
2752
|
var de = function(t, e, n, r) {
|
|
2751
2753
|
function i(s) {
|
|
@@ -2754,14 +2756,14 @@ var de = function(t, e, n, r) {
|
|
|
2754
2756
|
});
|
|
2755
2757
|
}
|
|
2756
2758
|
return new (n || (n = Promise))(function(s, o) {
|
|
2757
|
-
function
|
|
2759
|
+
function u(d) {
|
|
2758
2760
|
try {
|
|
2759
2761
|
c(r.next(d));
|
|
2760
2762
|
} catch (f) {
|
|
2761
2763
|
o(f);
|
|
2762
2764
|
}
|
|
2763
2765
|
}
|
|
2764
|
-
function
|
|
2766
|
+
function a(d) {
|
|
2765
2767
|
try {
|
|
2766
2768
|
c(r.throw(d));
|
|
2767
2769
|
} catch (f) {
|
|
@@ -2769,7 +2771,7 @@ var de = function(t, e, n, r) {
|
|
|
2769
2771
|
}
|
|
2770
2772
|
}
|
|
2771
2773
|
function c(d) {
|
|
2772
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
2774
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
2773
2775
|
}
|
|
2774
2776
|
c((r = r.apply(t, e || [])).next());
|
|
2775
2777
|
});
|
|
@@ -2778,7 +2780,7 @@ function Ir(t, e) {
|
|
|
2778
2780
|
typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
|
|
2779
2781
|
}
|
|
2780
2782
|
const rt = "__meta";
|
|
2781
|
-
class
|
|
2783
|
+
class qu {
|
|
2782
2784
|
constructor(e, n) {
|
|
2783
2785
|
}
|
|
2784
2786
|
}
|
|
@@ -2802,8 +2804,8 @@ class _n {
|
|
|
2802
2804
|
this._meta.loadingPromise = i;
|
|
2803
2805
|
const s = yield i;
|
|
2804
2806
|
this._meta.isLoading = !1, this._meta.error = null, this._meta.loadingPromise = null, this._meta.attempts = 0;
|
|
2805
|
-
const o = (n = (e = this._meta.value) === null || e === void 0 ? void 0 : e.objects) !== null && n !== void 0 ? n : {},
|
|
2806
|
-
this._meta.value = Object.assign(Object.assign({},
|
|
2807
|
+
const o = (n = (e = this._meta.value) === null || e === void 0 ? void 0 : e.objects) !== null && n !== void 0 ? n : {}, u = s ?? {}, a = (r = u.objects) !== null && r !== void 0 ? r : {};
|
|
2808
|
+
this._meta.value = Object.assign(Object.assign({}, u), { objects: Object.assign(Object.assign({}, o), a) });
|
|
2807
2809
|
} catch (i) {
|
|
2808
2810
|
this._meta.error = i, this._meta.attempts++, this._meta.loadingPromise = null;
|
|
2809
2811
|
}
|
|
@@ -2825,7 +2827,7 @@ class _n {
|
|
|
2825
2827
|
if (!n)
|
|
2826
2828
|
return;
|
|
2827
2829
|
const r = Object.entries(n.objects);
|
|
2828
|
-
r.sort(([i, s], [o,
|
|
2830
|
+
r.sort(([i, s], [o, u]) => u.updatedAt - s.updatedAt);
|
|
2829
2831
|
for (const [i] of r.slice(0, e))
|
|
2830
2832
|
this._loadKey(i);
|
|
2831
2833
|
});
|
|
@@ -2887,16 +2889,16 @@ class _n {
|
|
|
2887
2889
|
const o = this._meta.value;
|
|
2888
2890
|
if (!o)
|
|
2889
2891
|
return Promise.resolve(0);
|
|
2890
|
-
const
|
|
2892
|
+
const u = [], a = [];
|
|
2891
2893
|
for (const p of this._pendingSaveKeys)
|
|
2892
|
-
p in this.currentValue ?
|
|
2893
|
-
for (const p of
|
|
2894
|
+
p in this.currentValue ? a.push(p) : (u.push(p), delete o.objects[p]);
|
|
2895
|
+
for (const p of u) {
|
|
2894
2896
|
const y = this._persister.removeItem(p);
|
|
2895
2897
|
i.push(y.then(() => 1)), this._loadedKeys.delete(p), this._pendingSaveKeys.delete(p);
|
|
2896
2898
|
}
|
|
2897
2899
|
const c = [], d = [[rt, o]], f = (n = o.objects) !== null && n !== void 0 ? n : {};
|
|
2898
2900
|
o.objects = f;
|
|
2899
|
-
for (const p of
|
|
2901
|
+
for (const p of a)
|
|
2900
2902
|
if (this._loadedKeys.has(p)) {
|
|
2901
2903
|
const y = this.serialize(p, this.currentValue[p]);
|
|
2902
2904
|
d.push([p, y]);
|
|
@@ -2953,11 +2955,11 @@ class _n {
|
|
|
2953
2955
|
const o = Date.now();
|
|
2954
2956
|
for (const [l, p] of Object.entries(r.objects))
|
|
2955
2957
|
!n.has(l) && p.updatedAt < o - this._gcOpts.maxAgeMs && (i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedOldCount++);
|
|
2956
|
-
const
|
|
2957
|
-
|
|
2958
|
-
const
|
|
2959
|
-
if (
|
|
2960
|
-
for (const [l] of
|
|
2958
|
+
const u = Object.entries(r.objects);
|
|
2959
|
+
u.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
|
|
2960
|
+
const a = u.filter(([l]) => !n.has(l));
|
|
2961
|
+
if (u.length > this._gcOpts.maxEntries)
|
|
2962
|
+
for (const [l] of a.slice(0, u.length - this._gcOpts.maxEntries))
|
|
2961
2963
|
i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedThresholdCount++;
|
|
2962
2964
|
const c = Object.entries(r.objects);
|
|
2963
2965
|
c.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
|
|
@@ -3030,14 +3032,14 @@ var ye = function(t, e, n, r) {
|
|
|
3030
3032
|
});
|
|
3031
3033
|
}
|
|
3032
3034
|
return new (n || (n = Promise))(function(s, o) {
|
|
3033
|
-
function
|
|
3035
|
+
function u(d) {
|
|
3034
3036
|
try {
|
|
3035
3037
|
c(r.next(d));
|
|
3036
3038
|
} catch (f) {
|
|
3037
3039
|
o(f);
|
|
3038
3040
|
}
|
|
3039
3041
|
}
|
|
3040
|
-
function
|
|
3042
|
+
function a(d) {
|
|
3041
3043
|
try {
|
|
3042
3044
|
c(r.throw(d));
|
|
3043
3045
|
} catch (f) {
|
|
@@ -3045,18 +3047,18 @@ var ye = function(t, e, n, r) {
|
|
|
3045
3047
|
}
|
|
3046
3048
|
}
|
|
3047
3049
|
function c(d) {
|
|
3048
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
3050
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
3049
3051
|
}
|
|
3050
3052
|
c((r = r.apply(t, e || [])).next());
|
|
3051
3053
|
});
|
|
3052
3054
|
};
|
|
3053
|
-
const
|
|
3054
|
-
function
|
|
3055
|
+
const Wu = 6, zu = ["kv", "querySubs", "syncSubs"];
|
|
3056
|
+
function Vu(t) {
|
|
3055
3057
|
return function(n) {
|
|
3056
3058
|
console.error("Error in IndexedDB event", { source: t, event: n });
|
|
3057
3059
|
};
|
|
3058
3060
|
}
|
|
3059
|
-
function
|
|
3061
|
+
function Bu(t) {
|
|
3060
3062
|
return ye(this, void 0, void 0, function* () {
|
|
3061
3063
|
return new Promise((e) => {
|
|
3062
3064
|
const n = indexedDB.open(t);
|
|
@@ -3072,7 +3074,7 @@ function Ba(t) {
|
|
|
3072
3074
|
});
|
|
3073
3075
|
});
|
|
3074
3076
|
}
|
|
3075
|
-
function
|
|
3077
|
+
function Gu(t, e, n) {
|
|
3076
3078
|
return ye(this, void 0, void 0, function* () {
|
|
3077
3079
|
const r = (
|
|
3078
3080
|
// Backwards compatibility for older versions where we JSON.stringified before storing
|
|
@@ -3082,7 +3084,7 @@ function Ga(t, e, n) {
|
|
|
3082
3084
|
return;
|
|
3083
3085
|
const i = /* @__PURE__ */ new Set();
|
|
3084
3086
|
return new Promise((s, o) => {
|
|
3085
|
-
var
|
|
3087
|
+
var u, a, c, d;
|
|
3086
3088
|
const f = {};
|
|
3087
3089
|
for (const [y, b] of Object.entries(r)) {
|
|
3088
3090
|
const _ = typeof b == "string" ? JSON.parse(b) : b;
|
|
@@ -3090,7 +3092,7 @@ function Ga(t, e, n) {
|
|
|
3090
3092
|
const g = {
|
|
3091
3093
|
createdAt: _.lastAccessed,
|
|
3092
3094
|
updatedAt: _.lastAccessed,
|
|
3093
|
-
size: (d = (c = (
|
|
3095
|
+
size: (d = (c = (a = (u = _.result) === null || u === void 0 ? void 0 : u.store) === null || a === void 0 ? void 0 : a.triples) === null || c === void 0 ? void 0 : c.length) !== null && d !== void 0 ? d : 0
|
|
3094
3096
|
};
|
|
3095
3097
|
f[y] = g;
|
|
3096
3098
|
}
|
|
@@ -3116,9 +3118,9 @@ function Pr(t, e, n) {
|
|
|
3116
3118
|
});
|
|
3117
3119
|
});
|
|
3118
3120
|
}
|
|
3119
|
-
function
|
|
3121
|
+
function Qu(t, e) {
|
|
3120
3122
|
return ye(this, void 0, void 0, function* () {
|
|
3121
|
-
const n = yield
|
|
3123
|
+
const n = yield Bu(`instant_${t}_5`);
|
|
3122
3124
|
if (!n)
|
|
3123
3125
|
return;
|
|
3124
3126
|
const r = yield new Promise((d, f) => {
|
|
@@ -3137,36 +3139,36 @@ function Qa(t, e) {
|
|
|
3137
3139
|
}, y.onerror = (_) => {
|
|
3138
3140
|
f(_);
|
|
3139
3141
|
};
|
|
3140
|
-
}), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"),
|
|
3142
|
+
}), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), u = [], a = { objects: {} };
|
|
3141
3143
|
for (const [d, f] of r)
|
|
3142
3144
|
switch (d) {
|
|
3143
3145
|
case "querySubs": {
|
|
3144
|
-
const l =
|
|
3145
|
-
|
|
3146
|
+
const l = Gu(d, f, o);
|
|
3147
|
+
u.push(l);
|
|
3146
3148
|
break;
|
|
3147
3149
|
}
|
|
3148
3150
|
default: {
|
|
3149
3151
|
const l = Pr(d, f, s);
|
|
3150
|
-
|
|
3152
|
+
u.push(l);
|
|
3151
3153
|
const p = {
|
|
3152
3154
|
createdAt: Date.now(),
|
|
3153
3155
|
updatedAt: Date.now(),
|
|
3154
3156
|
size: 0
|
|
3155
3157
|
};
|
|
3156
|
-
|
|
3158
|
+
a.objects[d] = p;
|
|
3157
3159
|
break;
|
|
3158
3160
|
}
|
|
3159
3161
|
}
|
|
3160
|
-
const c = Pr(rt,
|
|
3161
|
-
|
|
3162
|
+
const c = Pr(rt, a, s);
|
|
3163
|
+
u.push(c), yield Promise.all(u), yield new Promise((d, f) => {
|
|
3162
3164
|
i.oncomplete = (l) => d(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
|
|
3163
3165
|
});
|
|
3164
3166
|
});
|
|
3165
3167
|
}
|
|
3166
3168
|
const Mr = /* @__PURE__ */ new Map();
|
|
3167
|
-
class Ui extends
|
|
3169
|
+
class Ui extends qu {
|
|
3168
3170
|
constructor(e, n) {
|
|
3169
|
-
super(e, n), this.dbName = `instant_${e}_${
|
|
3171
|
+
super(e, n), this.dbName = `instant_${e}_${Wu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
|
|
3170
3172
|
}
|
|
3171
3173
|
_init() {
|
|
3172
3174
|
return new Promise((e, n) => {
|
|
@@ -3175,15 +3177,15 @@ class Ui extends qa {
|
|
|
3175
3177
|
i.onerror = (s) => {
|
|
3176
3178
|
n(s);
|
|
3177
3179
|
}, i.onsuccess = (s) => {
|
|
3178
|
-
const
|
|
3180
|
+
const u = s.target.result;
|
|
3179
3181
|
if (r) {
|
|
3180
|
-
const
|
|
3181
|
-
|
|
3182
|
+
const a = Qu(this._appId, u).catch((c) => {
|
|
3183
|
+
Vu("Error upgrading store from version 5 to 6.")(c);
|
|
3182
3184
|
});
|
|
3183
|
-
Mr.set(this.dbName,
|
|
3185
|
+
Mr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
|
|
3184
3186
|
} else {
|
|
3185
|
-
const
|
|
3186
|
-
|
|
3187
|
+
const a = Mr.get(this.dbName);
|
|
3188
|
+
a ? a.then(() => e(u)).catch(() => e(u)) : e(u);
|
|
3187
3189
|
}
|
|
3188
3190
|
}, i.onupgradeneeded = (s) => {
|
|
3189
3191
|
r = !0, this._upgradeStore(s);
|
|
@@ -3192,18 +3194,18 @@ class Ui extends qa {
|
|
|
3192
3194
|
}
|
|
3193
3195
|
_upgradeStore(e) {
|
|
3194
3196
|
const r = e.target.result;
|
|
3195
|
-
for (const i of
|
|
3197
|
+
for (const i of zu)
|
|
3196
3198
|
r.objectStoreNames.contains(i) || r.createObjectStore(i);
|
|
3197
3199
|
}
|
|
3198
3200
|
getItem(e) {
|
|
3199
3201
|
return ye(this, void 0, void 0, function* () {
|
|
3200
3202
|
const n = yield this._dbPromise;
|
|
3201
3203
|
return new Promise((r, i) => {
|
|
3202
|
-
const
|
|
3203
|
-
|
|
3204
|
-
i(
|
|
3205
|
-
},
|
|
3206
|
-
|
|
3204
|
+
const u = n.transaction([this._storeName], "readonly").objectStore(this._storeName).get(e);
|
|
3205
|
+
u.onerror = (a) => {
|
|
3206
|
+
i(a);
|
|
3207
|
+
}, u.onsuccess = (a) => {
|
|
3208
|
+
u.result ? r(u.result) : r(null);
|
|
3207
3209
|
};
|
|
3208
3210
|
});
|
|
3209
3211
|
});
|
|
@@ -3212,10 +3214,10 @@ class Ui extends qa {
|
|
|
3212
3214
|
return ye(this, void 0, void 0, function* () {
|
|
3213
3215
|
const r = yield this._dbPromise;
|
|
3214
3216
|
return new Promise((i, s) => {
|
|
3215
|
-
const
|
|
3216
|
-
|
|
3217
|
+
const a = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
|
|
3218
|
+
a.onerror = (c) => {
|
|
3217
3219
|
s(c);
|
|
3218
|
-
},
|
|
3220
|
+
}, a.onsuccess = (c) => {
|
|
3219
3221
|
i();
|
|
3220
3222
|
};
|
|
3221
3223
|
});
|
|
@@ -3226,16 +3228,16 @@ class Ui extends qa {
|
|
|
3226
3228
|
return ye(this, void 0, void 0, function* () {
|
|
3227
3229
|
const n = yield this._dbPromise;
|
|
3228
3230
|
return new Promise((r, i) => {
|
|
3229
|
-
const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName),
|
|
3230
|
-
for (const [
|
|
3231
|
-
const d = o.put(c,
|
|
3232
|
-
|
|
3231
|
+
const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), u = /* @__PURE__ */ new Set();
|
|
3232
|
+
for (const [a, c] of e) {
|
|
3233
|
+
const d = o.put(c, a);
|
|
3234
|
+
u.add(d);
|
|
3233
3235
|
}
|
|
3234
|
-
for (const
|
|
3235
|
-
|
|
3236
|
+
for (const a of u)
|
|
3237
|
+
a.onerror = (c) => {
|
|
3236
3238
|
s.abort(), i(c);
|
|
3237
|
-
},
|
|
3238
|
-
|
|
3239
|
+
}, a.onsuccess = (c) => {
|
|
3240
|
+
u.delete(a), u.size === 0 && r();
|
|
3239
3241
|
};
|
|
3240
3242
|
});
|
|
3241
3243
|
});
|
|
@@ -3244,10 +3246,10 @@ class Ui extends qa {
|
|
|
3244
3246
|
return ye(this, void 0, void 0, function* () {
|
|
3245
3247
|
const n = yield this._dbPromise;
|
|
3246
3248
|
return new Promise((r, i) => {
|
|
3247
|
-
const
|
|
3248
|
-
|
|
3249
|
-
i(
|
|
3250
|
-
},
|
|
3249
|
+
const u = n.transaction([this._storeName], "readwrite").objectStore(this._storeName).delete(e);
|
|
3250
|
+
u.onerror = (a) => {
|
|
3251
|
+
i(a);
|
|
3252
|
+
}, u.onsuccess = (a) => {
|
|
3251
3253
|
r();
|
|
3252
3254
|
};
|
|
3253
3255
|
});
|
|
@@ -3258,30 +3260,30 @@ class Ui extends qa {
|
|
|
3258
3260
|
const e = yield this._dbPromise;
|
|
3259
3261
|
return new Promise((n, r) => {
|
|
3260
3262
|
const o = e.transaction([this._storeName], "readonly").objectStore(this._storeName).getAllKeys();
|
|
3261
|
-
o.onerror = (
|
|
3262
|
-
r(
|
|
3263
|
-
}, o.onsuccess = (
|
|
3264
|
-
n(o.result.filter((
|
|
3263
|
+
o.onerror = (u) => {
|
|
3264
|
+
r(u);
|
|
3265
|
+
}, o.onsuccess = (u) => {
|
|
3266
|
+
n(o.result.filter((a) => typeof a == "string"));
|
|
3265
3267
|
};
|
|
3266
3268
|
});
|
|
3267
3269
|
});
|
|
3268
3270
|
}
|
|
3269
3271
|
}
|
|
3270
|
-
var
|
|
3272
|
+
var Hu = function(t, e, n, r) {
|
|
3271
3273
|
function i(s) {
|
|
3272
3274
|
return s instanceof n ? s : new n(function(o) {
|
|
3273
3275
|
o(s);
|
|
3274
3276
|
});
|
|
3275
3277
|
}
|
|
3276
3278
|
return new (n || (n = Promise))(function(s, o) {
|
|
3277
|
-
function
|
|
3279
|
+
function u(d) {
|
|
3278
3280
|
try {
|
|
3279
3281
|
c(r.next(d));
|
|
3280
3282
|
} catch (f) {
|
|
3281
3283
|
o(f);
|
|
3282
3284
|
}
|
|
3283
3285
|
}
|
|
3284
|
-
function
|
|
3286
|
+
function a(d) {
|
|
3285
3287
|
try {
|
|
3286
3288
|
c(r.throw(d));
|
|
3287
3289
|
} catch (f) {
|
|
@@ -3289,14 +3291,14 @@ var Ha = function(t, e, n, r) {
|
|
|
3289
3291
|
}
|
|
3290
3292
|
}
|
|
3291
3293
|
function c(d) {
|
|
3292
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
3294
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
3293
3295
|
}
|
|
3294
3296
|
c((r = r.apply(t, e || [])).next());
|
|
3295
3297
|
});
|
|
3296
3298
|
};
|
|
3297
3299
|
class Li {
|
|
3298
3300
|
static getIsOnline() {
|
|
3299
|
-
return
|
|
3301
|
+
return Hu(this, void 0, void 0, function* () {
|
|
3300
3302
|
return navigator.onLine;
|
|
3301
3303
|
});
|
|
3302
3304
|
}
|
|
@@ -3321,21 +3323,21 @@ class qe extends Error {
|
|
|
3321
3323
|
return "InstantError";
|
|
3322
3324
|
}
|
|
3323
3325
|
}
|
|
3324
|
-
var
|
|
3326
|
+
var Yu = function(t, e, n, r) {
|
|
3325
3327
|
function i(s) {
|
|
3326
3328
|
return s instanceof n ? s : new n(function(o) {
|
|
3327
3329
|
o(s);
|
|
3328
3330
|
});
|
|
3329
3331
|
}
|
|
3330
3332
|
return new (n || (n = Promise))(function(s, o) {
|
|
3331
|
-
function
|
|
3333
|
+
function u(d) {
|
|
3332
3334
|
try {
|
|
3333
3335
|
c(r.next(d));
|
|
3334
3336
|
} catch (f) {
|
|
3335
3337
|
o(f);
|
|
3336
3338
|
}
|
|
3337
3339
|
}
|
|
3338
|
-
function
|
|
3340
|
+
function a(d) {
|
|
3339
3341
|
try {
|
|
3340
3342
|
c(r.throw(d));
|
|
3341
3343
|
} catch (f) {
|
|
@@ -3343,7 +3345,7 @@ var Ya = function(t, e, n, r) {
|
|
|
3343
3345
|
}
|
|
3344
3346
|
}
|
|
3345
3347
|
function c(d) {
|
|
3346
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
3348
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
3347
3349
|
}
|
|
3348
3350
|
c((r = r.apply(t, e || [])).next());
|
|
3349
3351
|
});
|
|
@@ -3360,8 +3362,8 @@ class Dt extends qe {
|
|
|
3360
3362
|
return "InstantAPIError";
|
|
3361
3363
|
}
|
|
3362
3364
|
}
|
|
3363
|
-
function
|
|
3364
|
-
return
|
|
3365
|
+
function ae(t, e) {
|
|
3366
|
+
return Yu(this, void 0, void 0, function* () {
|
|
3365
3367
|
const n = yield fetch(t, e), r = yield n.json();
|
|
3366
3368
|
return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Dt({ status: n.status, body: r }));
|
|
3367
3369
|
});
|
|
@@ -3373,14 +3375,14 @@ var ze = function(t, e, n, r) {
|
|
|
3373
3375
|
});
|
|
3374
3376
|
}
|
|
3375
3377
|
return new (n || (n = Promise))(function(s, o) {
|
|
3376
|
-
function
|
|
3378
|
+
function u(d) {
|
|
3377
3379
|
try {
|
|
3378
3380
|
c(r.next(d));
|
|
3379
3381
|
} catch (f) {
|
|
3380
3382
|
o(f);
|
|
3381
3383
|
}
|
|
3382
3384
|
}
|
|
3383
|
-
function
|
|
3385
|
+
function a(d) {
|
|
3384
3386
|
try {
|
|
3385
3387
|
c(r.throw(d));
|
|
3386
3388
|
} catch (f) {
|
|
@@ -3388,21 +3390,21 @@ var ze = function(t, e, n, r) {
|
|
|
3388
3390
|
}
|
|
3389
3391
|
}
|
|
3390
3392
|
function c(d) {
|
|
3391
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
3393
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
3392
3394
|
}
|
|
3393
3395
|
c((r = r.apply(t, e || [])).next());
|
|
3394
3396
|
});
|
|
3395
3397
|
};
|
|
3396
|
-
function
|
|
3397
|
-
return
|
|
3398
|
+
function Ju({ apiURI: t, appId: e, email: n }) {
|
|
3399
|
+
return ae(`${t}/runtime/auth/send_magic_code`, {
|
|
3398
3400
|
method: "POST",
|
|
3399
3401
|
headers: { "content-type": "application/json" },
|
|
3400
3402
|
body: JSON.stringify({ "app-id": e, email: n })
|
|
3401
3403
|
});
|
|
3402
3404
|
}
|
|
3403
|
-
function
|
|
3405
|
+
function Zu(t) {
|
|
3404
3406
|
return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
|
|
3405
|
-
return yield
|
|
3407
|
+
return yield ae(`${e}/runtime/auth/verify_magic_code`, {
|
|
3406
3408
|
method: "POST",
|
|
3407
3409
|
headers: { "content-type": "application/json" },
|
|
3408
3410
|
body: JSON.stringify(Object.assign({
|
|
@@ -3413,9 +3415,9 @@ function Za(t) {
|
|
|
3413
3415
|
});
|
|
3414
3416
|
});
|
|
3415
3417
|
}
|
|
3416
|
-
function
|
|
3418
|
+
function Xu(t) {
|
|
3417
3419
|
return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
|
|
3418
|
-
return yield
|
|
3420
|
+
return yield ae(`${e}/runtime/auth/verify_refresh_token`, {
|
|
3419
3421
|
method: "POST",
|
|
3420
3422
|
headers: { "content-type": "application/json" },
|
|
3421
3423
|
body: JSON.stringify({
|
|
@@ -3425,9 +3427,9 @@ function Xa(t) {
|
|
|
3425
3427
|
});
|
|
3426
3428
|
});
|
|
3427
3429
|
}
|
|
3428
|
-
function
|
|
3430
|
+
function ea(t) {
|
|
3429
3431
|
return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
|
|
3430
|
-
return yield
|
|
3432
|
+
return yield ae(`${e}/runtime/auth/sign_in_guest`, {
|
|
3431
3433
|
method: "POST",
|
|
3432
3434
|
headers: { "content-type": "application/json" },
|
|
3433
3435
|
body: JSON.stringify({
|
|
@@ -3438,7 +3440,7 @@ function eu(t) {
|
|
|
3438
3440
|
}
|
|
3439
3441
|
function Rr(t) {
|
|
3440
3442
|
return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
|
|
3441
|
-
return yield
|
|
3443
|
+
return yield ae(`${e}/runtime/oauth/token`, {
|
|
3442
3444
|
method: "POST",
|
|
3443
3445
|
headers: { "content-type": "application/json" },
|
|
3444
3446
|
body: JSON.stringify({
|
|
@@ -3450,9 +3452,9 @@ function Rr(t) {
|
|
|
3450
3452
|
});
|
|
3451
3453
|
});
|
|
3452
3454
|
}
|
|
3453
|
-
function
|
|
3455
|
+
function ta(t) {
|
|
3454
3456
|
return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
|
|
3455
|
-
return yield
|
|
3457
|
+
return yield ae(`${e}/runtime/oauth/id_token`, {
|
|
3456
3458
|
method: "POST",
|
|
3457
3459
|
headers: { "content-type": "application/json" },
|
|
3458
3460
|
body: JSON.stringify({
|
|
@@ -3465,9 +3467,9 @@ function tu(t) {
|
|
|
3465
3467
|
});
|
|
3466
3468
|
});
|
|
3467
3469
|
}
|
|
3468
|
-
function
|
|
3470
|
+
function na(t) {
|
|
3469
3471
|
return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
|
|
3470
|
-
return yield
|
|
3472
|
+
return yield ae(`${e}/runtime/signout`, {
|
|
3471
3473
|
method: "POST",
|
|
3472
3474
|
headers: {
|
|
3473
3475
|
"content-type": "application/json"
|
|
@@ -3486,14 +3488,14 @@ var dt = function(t, e, n, r) {
|
|
|
3486
3488
|
});
|
|
3487
3489
|
}
|
|
3488
3490
|
return new (n || (n = Promise))(function(s, o) {
|
|
3489
|
-
function
|
|
3491
|
+
function u(d) {
|
|
3490
3492
|
try {
|
|
3491
3493
|
c(r.next(d));
|
|
3492
3494
|
} catch (f) {
|
|
3493
3495
|
o(f);
|
|
3494
3496
|
}
|
|
3495
3497
|
}
|
|
3496
|
-
function
|
|
3498
|
+
function a(d) {
|
|
3497
3499
|
try {
|
|
3498
3500
|
c(r.throw(d));
|
|
3499
3501
|
} catch (f) {
|
|
@@ -3501,29 +3503,29 @@ var dt = function(t, e, n, r) {
|
|
|
3501
3503
|
}
|
|
3502
3504
|
}
|
|
3503
3505
|
function c(d) {
|
|
3504
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
3506
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
3505
3507
|
}
|
|
3506
3508
|
c((r = r.apply(t, e || [])).next());
|
|
3507
3509
|
});
|
|
3508
3510
|
};
|
|
3509
|
-
function
|
|
3510
|
-
return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition:
|
|
3511
|
-
const
|
|
3511
|
+
function ra(t) {
|
|
3512
|
+
return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
|
|
3513
|
+
const a = {
|
|
3512
3514
|
app_id: n,
|
|
3513
3515
|
path: r,
|
|
3514
3516
|
authorization: `Bearer ${s}`,
|
|
3515
3517
|
"content-type": o || i.type
|
|
3516
3518
|
};
|
|
3517
|
-
return
|
|
3519
|
+
return u && (a["content-disposition"] = u), yield ae(`${e}/storage/upload`, {
|
|
3518
3520
|
method: "PUT",
|
|
3519
|
-
headers:
|
|
3521
|
+
headers: a,
|
|
3520
3522
|
body: i
|
|
3521
3523
|
});
|
|
3522
3524
|
});
|
|
3523
3525
|
}
|
|
3524
|
-
function
|
|
3526
|
+
function ia(t) {
|
|
3525
3527
|
return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
|
|
3526
|
-
const { data: s } = yield
|
|
3528
|
+
const { data: s } = yield ae(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
|
|
3527
3529
|
method: "DELETE",
|
|
3528
3530
|
headers: {
|
|
3529
3531
|
"content-type": "application/json",
|
|
@@ -3533,9 +3535,9 @@ function iu(t) {
|
|
|
3533
3535
|
return s;
|
|
3534
3536
|
});
|
|
3535
3537
|
}
|
|
3536
|
-
function
|
|
3538
|
+
function sa(t) {
|
|
3537
3539
|
return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
|
|
3538
|
-
const { data: o } = yield
|
|
3540
|
+
const { data: o } = yield ae(`${e}/storage/signed-upload-url`, {
|
|
3539
3541
|
method: "POST",
|
|
3540
3542
|
headers: {
|
|
3541
3543
|
"content-type": "application/json",
|
|
@@ -3549,7 +3551,7 @@ function su(t) {
|
|
|
3549
3551
|
return o;
|
|
3550
3552
|
});
|
|
3551
3553
|
}
|
|
3552
|
-
function
|
|
3554
|
+
function oa(t, e) {
|
|
3553
3555
|
return dt(this, void 0, void 0, function* () {
|
|
3554
3556
|
return (yield fetch(t, {
|
|
3555
3557
|
method: "PUT",
|
|
@@ -3560,9 +3562,9 @@ function ou(t, e) {
|
|
|
3560
3562
|
})).ok;
|
|
3561
3563
|
});
|
|
3562
3564
|
}
|
|
3563
|
-
function
|
|
3565
|
+
function ua(t) {
|
|
3564
3566
|
return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
|
|
3565
|
-
const { data: s } = yield
|
|
3567
|
+
const { data: s } = yield ae(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
|
|
3566
3568
|
method: "GET",
|
|
3567
3569
|
headers: {
|
|
3568
3570
|
"content-type": "application/json",
|
|
@@ -3582,25 +3584,25 @@ function xr(t, e) {
|
|
|
3582
3584
|
n[r] = t[r];
|
|
3583
3585
|
}), n;
|
|
3584
3586
|
}
|
|
3585
|
-
function
|
|
3587
|
+
function aa(t, e, n) {
|
|
3586
3588
|
var r, i;
|
|
3587
3589
|
const s = {
|
|
3588
3590
|
peers: {}
|
|
3589
3591
|
};
|
|
3590
3592
|
if (e && "user" in e ? e.user : !0) {
|
|
3591
|
-
const
|
|
3592
|
-
s.user = Object.assign(Object.assign({},
|
|
3593
|
+
const u = xr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
|
|
3594
|
+
s.user = Object.assign(Object.assign({}, u), { peerId: n });
|
|
3593
3595
|
}
|
|
3594
|
-
for (const
|
|
3595
|
-
const
|
|
3596
|
-
if (
|
|
3597
|
-
const d = xr(t.peers[
|
|
3598
|
-
s.peers[
|
|
3596
|
+
for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
|
|
3597
|
+
const a = (e == null ? void 0 : e.peers) === void 0, c = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
|
|
3598
|
+
if (a || c) {
|
|
3599
|
+
const d = xr(t.peers[u], e == null ? void 0 : e.keys);
|
|
3600
|
+
s.peers[u] = Object.assign(Object.assign({}, d), { peerId: u });
|
|
3599
3601
|
}
|
|
3600
3602
|
}
|
|
3601
3603
|
return s;
|
|
3602
3604
|
}
|
|
3603
|
-
function
|
|
3605
|
+
function ca(t, e) {
|
|
3604
3606
|
if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !wr(t.user, e.user)) || !yi(t.peers, e.peers))
|
|
3605
3607
|
return !0;
|
|
3606
3608
|
for (const r of Object.keys(t.peers))
|
|
@@ -3625,8 +3627,8 @@ function Ki(t, e = []) {
|
|
|
3625
3627
|
t.forEach((n) => {
|
|
3626
3628
|
const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
|
|
3627
3629
|
for (const o of s)
|
|
3628
|
-
for (const
|
|
3629
|
-
e.push(
|
|
3630
|
+
for (const u of o)
|
|
3631
|
+
e.push(u);
|
|
3630
3632
|
Ki(n["child-nodes"], e);
|
|
3631
3633
|
});
|
|
3632
3634
|
}
|
|
@@ -3648,8 +3650,8 @@ function Ur(t) {
|
|
|
3648
3650
|
}, e;
|
|
3649
3651
|
}, {});
|
|
3650
3652
|
}
|
|
3651
|
-
const Wn = "v0.22.86-experimental.split-store.
|
|
3652
|
-
function
|
|
3653
|
+
const Wn = "v0.22.86-experimental.split-store.20247643606.1";
|
|
3654
|
+
function da(t, e) {
|
|
3653
3655
|
return {
|
|
3654
3656
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
3655
3657
|
},
|
|
@@ -3733,7 +3735,7 @@ const Lr = [
|
|
|
3733
3735
|
"before",
|
|
3734
3736
|
"fields",
|
|
3735
3737
|
"aggregate"
|
|
3736
|
-
],
|
|
3738
|
+
], fa = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
|
|
3737
3739
|
if (n || t == null)
|
|
3738
3740
|
return !0;
|
|
3739
3741
|
switch (e) {
|
|
@@ -3748,9 +3750,9 @@ const Lr = [
|
|
|
3748
3750
|
default:
|
|
3749
3751
|
return !0;
|
|
3750
3752
|
}
|
|
3751
|
-
},
|
|
3752
|
-
const
|
|
3753
|
-
if (!qi(f, d,
|
|
3753
|
+
}, la = (t, e, n, r, i, s, o) => {
|
|
3754
|
+
const u = s.valueType === "json", a = (c, d, f) => {
|
|
3755
|
+
if (!qi(f, d, u))
|
|
3754
3756
|
throw new R(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
|
|
3755
3757
|
};
|
|
3756
3758
|
switch (t) {
|
|
@@ -3759,7 +3761,7 @@ const Lr = [
|
|
|
3759
3761
|
if (!Array.isArray(e))
|
|
3760
3762
|
throw new R(`Operator '${t}' for attribute '${r}' in entity '${i}' must be an array, but received: ${typeof e}`, o);
|
|
3761
3763
|
for (const c of e)
|
|
3762
|
-
|
|
3764
|
+
a(t, n, c);
|
|
3763
3765
|
break;
|
|
3764
3766
|
case "$not":
|
|
3765
3767
|
case "$ne":
|
|
@@ -3767,30 +3769,30 @@ const Lr = [
|
|
|
3767
3769
|
case "$lt":
|
|
3768
3770
|
case "$gte":
|
|
3769
3771
|
case "$lte":
|
|
3770
|
-
|
|
3772
|
+
a(t, n, e);
|
|
3771
3773
|
break;
|
|
3772
3774
|
case "$like":
|
|
3773
3775
|
case "$ilike":
|
|
3774
|
-
if (
|
|
3776
|
+
if (a(t, "string", e), t === "$ilike" && !s.isIndexed)
|
|
3775
3777
|
throw new R(`Operator '${t}' can only be used with indexed attributes, but '${r}' in entity '${i}' is not indexed`, o);
|
|
3776
3778
|
break;
|
|
3777
3779
|
case "$isNull":
|
|
3778
|
-
|
|
3780
|
+
a(t, "boolean", e);
|
|
3779
3781
|
break;
|
|
3780
3782
|
default:
|
|
3781
3783
|
throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
|
|
3782
3784
|
}
|
|
3783
3785
|
}, Le = (t, e, n, r, i) => {
|
|
3784
|
-
const s =
|
|
3786
|
+
const s = fa(n), o = n.valueType === "json";
|
|
3785
3787
|
if (typeof t == "object" && t !== null && !Array.isArray(t)) {
|
|
3786
3788
|
if (o)
|
|
3787
3789
|
return;
|
|
3788
|
-
const
|
|
3789
|
-
for (const [c, d] of Object.entries(
|
|
3790
|
-
|
|
3790
|
+
const a = t;
|
|
3791
|
+
for (const [c, d] of Object.entries(a))
|
|
3792
|
+
la(c, d, s, e, r, n, `${i}.${c}`);
|
|
3791
3793
|
} else if (!qi(t, s, o))
|
|
3792
3794
|
throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
|
|
3793
|
-
},
|
|
3795
|
+
}, ha = (t, e, n, r, i) => {
|
|
3794
3796
|
const s = t.split(".");
|
|
3795
3797
|
if (s.length < 2)
|
|
3796
3798
|
throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
|
|
@@ -3806,25 +3808,25 @@ const Lr = [
|
|
|
3806
3808
|
}
|
|
3807
3809
|
o = p.entityName;
|
|
3808
3810
|
}
|
|
3809
|
-
const
|
|
3810
|
-
if (!
|
|
3811
|
+
const u = s[s.length - 1], a = r.entities[o];
|
|
3812
|
+
if (!a)
|
|
3811
3813
|
throw new R(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, i);
|
|
3812
|
-
if (
|
|
3814
|
+
if (u === "id") {
|
|
3813
3815
|
if (typeof e == "string" && !Ne(e))
|
|
3814
3816
|
throw new R(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, i);
|
|
3815
3817
|
Le(e, t, new H("string", !1, !0), n, i);
|
|
3816
3818
|
return;
|
|
3817
3819
|
}
|
|
3818
|
-
const c =
|
|
3819
|
-
if (Object.keys(
|
|
3820
|
+
const c = a.attrs[u];
|
|
3821
|
+
if (Object.keys(a.links).includes(u)) {
|
|
3820
3822
|
if (typeof e == "string" && !Ne(e))
|
|
3821
|
-
throw new R(`Invalid value for link '${
|
|
3823
|
+
throw new R(`Invalid value for link '${u}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
|
|
3822
3824
|
Le(e, t, new H("string", !1, !0), n, i);
|
|
3823
3825
|
return;
|
|
3824
3826
|
}
|
|
3825
3827
|
if (!c) {
|
|
3826
|
-
const d = Object.keys(
|
|
3827
|
-
throw new R(`Attribute '${
|
|
3828
|
+
const d = Object.keys(a.attrs);
|
|
3829
|
+
throw new R(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${d.length > 0 ? d.join(", ") + ", id" : "id"}`, i);
|
|
3828
3830
|
}
|
|
3829
3831
|
Le(e, t, c, n, i);
|
|
3830
3832
|
}, Wi = (t, e, n, r) => {
|
|
@@ -3840,27 +3842,27 @@ const Lr = [
|
|
|
3840
3842
|
continue;
|
|
3841
3843
|
}
|
|
3842
3844
|
if (i.includes(".")) {
|
|
3843
|
-
|
|
3845
|
+
ha(i, s, e, n, `${r}.${i}`);
|
|
3844
3846
|
continue;
|
|
3845
3847
|
}
|
|
3846
3848
|
const o = n.entities[e];
|
|
3847
3849
|
if (!o)
|
|
3848
3850
|
continue;
|
|
3849
|
-
const
|
|
3850
|
-
if (!
|
|
3851
|
+
const u = o.attrs[i], a = o.links[i];
|
|
3852
|
+
if (!u && !a) {
|
|
3851
3853
|
const c = Object.keys(o.attrs), d = Object.keys(o.links);
|
|
3852
3854
|
throw new R(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${c.length > 0 ? c.join(", ") : "none"}. Available links: ${d.length > 0 ? d.join(", ") : "none"}`, `${r}.${i}`);
|
|
3853
3855
|
}
|
|
3854
|
-
if (
|
|
3855
|
-
Le(s, i,
|
|
3856
|
-
else if (
|
|
3856
|
+
if (u)
|
|
3857
|
+
Le(s, i, u, e, `${r}.${i}`);
|
|
3858
|
+
else if (a) {
|
|
3857
3859
|
if (typeof s == "string" && !Ne(s))
|
|
3858
3860
|
throw new R(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${s}`, `${r}.${i}`);
|
|
3859
3861
|
const c = new H("string", !1, !0);
|
|
3860
3862
|
Le(s, i, c, e, `${r}.${i}`);
|
|
3861
3863
|
}
|
|
3862
3864
|
}
|
|
3863
|
-
},
|
|
3865
|
+
}, pa = (t, e, n, r, i = 0) => {
|
|
3864
3866
|
for (const o of Object.keys(t))
|
|
3865
3867
|
if (!Lr.includes(o))
|
|
3866
3868
|
throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Lr.join(", ")}. Found: ${o}`, r);
|
|
@@ -3887,19 +3889,19 @@ const Lr = [
|
|
|
3887
3889
|
for (const o of Object.keys(t))
|
|
3888
3890
|
if (o !== "$") {
|
|
3889
3891
|
if (n && !(o in n.entities[e].links)) {
|
|
3890
|
-
const
|
|
3891
|
-
throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${
|
|
3892
|
+
const a = Object.keys(n.entities[e].links);
|
|
3893
|
+
throw new R(`Link '${o}' does not exist on entity '${e}'. Available links: ${a.length > 0 ? a.join(", ") : "none"}`, `${r}.${o}`);
|
|
3892
3894
|
}
|
|
3893
|
-
const
|
|
3894
|
-
if (typeof
|
|
3895
|
-
const
|
|
3896
|
-
|
|
3895
|
+
const u = t[o];
|
|
3896
|
+
if (typeof u == "object" && u !== null) {
|
|
3897
|
+
const a = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
|
|
3898
|
+
a && zi(u, a, n, `${r}.${o}`, i + 1);
|
|
3897
3899
|
}
|
|
3898
3900
|
} else {
|
|
3899
|
-
const
|
|
3900
|
-
if (typeof
|
|
3901
|
-
throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof
|
|
3902
|
-
|
|
3901
|
+
const u = t[o];
|
|
3902
|
+
if (typeof u != "object" || u === null)
|
|
3903
|
+
throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
|
|
3904
|
+
pa(u, e, n, `${r}.$`, i);
|
|
3903
3905
|
}
|
|
3904
3906
|
}, Fr = (t, e) => {
|
|
3905
3907
|
if (typeof t != "object" || t === null)
|
|
@@ -3926,19 +3928,19 @@ class ie extends Error {
|
|
|
3926
3928
|
super(e), this.name = "TransactionValidationError";
|
|
3927
3929
|
}
|
|
3928
3930
|
}
|
|
3929
|
-
const Vi = (t) => t.length > 0 ? t.join(", ") : "none",
|
|
3931
|
+
const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ya = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Vi(e)}`), Kr = {
|
|
3930
3932
|
string: (t) => typeof t == "string",
|
|
3931
3933
|
number: (t) => typeof t == "number" && !isNaN(t),
|
|
3932
3934
|
boolean: (t) => typeof t == "boolean",
|
|
3933
3935
|
date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
|
|
3934
3936
|
json: () => !0
|
|
3935
|
-
},
|
|
3937
|
+
}, ba = (t, e) => {
|
|
3936
3938
|
var n, r;
|
|
3937
3939
|
return t == null ? !0 : (r = (n = Kr[e.valueType]) === null || n === void 0 ? void 0 : n.call(Kr, t)) !== null && r !== void 0 ? r : !1;
|
|
3938
3940
|
}, Bi = (t, e) => {
|
|
3939
3941
|
const n = e.entities[t];
|
|
3940
3942
|
if (!n)
|
|
3941
|
-
throw
|
|
3943
|
+
throw ya(t, Object.keys(e.entities));
|
|
3942
3944
|
return n;
|
|
3943
3945
|
}, Yt = (t, e, n) => {
|
|
3944
3946
|
const r = Bi(t, n);
|
|
@@ -3948,7 +3950,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
|
|
|
3948
3950
|
if (i === "id")
|
|
3949
3951
|
continue;
|
|
3950
3952
|
const o = r.attrs[i];
|
|
3951
|
-
if (o && !
|
|
3953
|
+
if (o && !ba(s, o))
|
|
3952
3954
|
throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
|
|
3953
3955
|
}
|
|
3954
3956
|
}, qr = (t, e, n) => {
|
|
@@ -3957,19 +3959,19 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
|
|
|
3957
3959
|
throw new ie(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
|
|
3958
3960
|
for (const [i, s] of Object.entries(e)) {
|
|
3959
3961
|
if (!r.links[i]) {
|
|
3960
|
-
const
|
|
3961
|
-
throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Vi(
|
|
3962
|
+
const u = Object.keys(r.links);
|
|
3963
|
+
throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Vi(u)}`);
|
|
3962
3964
|
}
|
|
3963
3965
|
if (s != null) {
|
|
3964
3966
|
if (Array.isArray(s)) {
|
|
3965
|
-
for (const
|
|
3966
|
-
if (!Nr(
|
|
3967
|
-
throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${
|
|
3967
|
+
for (const u of s)
|
|
3968
|
+
if (!Nr(u))
|
|
3969
|
+
throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${u}`);
|
|
3968
3970
|
} else if (!Nr(s))
|
|
3969
3971
|
throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
|
|
3970
3972
|
}
|
|
3971
3973
|
}
|
|
3972
|
-
},
|
|
3974
|
+
}, _a = {
|
|
3973
3975
|
create: Yt,
|
|
3974
3976
|
update: Yt,
|
|
3975
3977
|
merge: Yt,
|
|
@@ -3977,7 +3979,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
|
|
|
3977
3979
|
unlink: qr,
|
|
3978
3980
|
delete: () => {
|
|
3979
3981
|
}
|
|
3980
|
-
},
|
|
3982
|
+
}, ga = (t, e) => {
|
|
3981
3983
|
if (!e)
|
|
3982
3984
|
return;
|
|
3983
3985
|
const [n, r, i, s] = t;
|
|
@@ -3985,9 +3987,9 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
|
|
|
3985
3987
|
throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
|
|
3986
3988
|
if (typeof r != "string")
|
|
3987
3989
|
throw new ie(`Entity name must be a string, but received: ${typeof r}`);
|
|
3988
|
-
const o =
|
|
3990
|
+
const o = _a[n];
|
|
3989
3991
|
o && s !== void 0 && o(r, s, e);
|
|
3990
|
-
},
|
|
3992
|
+
}, wa = (t, e) => {
|
|
3991
3993
|
const n = Array.isArray(t) ? t : [t];
|
|
3992
3994
|
for (const r of n) {
|
|
3993
3995
|
if (!r || typeof r != "object")
|
|
@@ -3997,7 +3999,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", yu = (t, e) => new ie(`E
|
|
|
3997
3999
|
for (const i of r.__ops) {
|
|
3998
4000
|
if (!Array.isArray(i))
|
|
3999
4001
|
throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
|
|
4000
|
-
|
|
4002
|
+
ga(i, e);
|
|
4001
4003
|
}
|
|
4002
4004
|
}
|
|
4003
4005
|
};
|
|
@@ -4008,14 +4010,14 @@ var Wr = function(t, e, n, r) {
|
|
|
4008
4010
|
});
|
|
4009
4011
|
}
|
|
4010
4012
|
return new (n || (n = Promise))(function(s, o) {
|
|
4011
|
-
function
|
|
4013
|
+
function u(d) {
|
|
4012
4014
|
try {
|
|
4013
4015
|
c(r.next(d));
|
|
4014
4016
|
} catch (f) {
|
|
4015
4017
|
o(f);
|
|
4016
4018
|
}
|
|
4017
4019
|
}
|
|
4018
|
-
function
|
|
4020
|
+
function a(d) {
|
|
4019
4021
|
try {
|
|
4020
4022
|
c(r.throw(d));
|
|
4021
4023
|
} catch (f) {
|
|
@@ -4023,7 +4025,7 @@ var Wr = function(t, e, n, r) {
|
|
|
4023
4025
|
}
|
|
4024
4026
|
}
|
|
4025
4027
|
function c(d) {
|
|
4026
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
4028
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
4027
4029
|
}
|
|
4028
4030
|
c((r = r.apply(t, e || [])).next());
|
|
4029
4031
|
});
|
|
@@ -4059,7 +4061,7 @@ class zr {
|
|
|
4059
4061
|
return this.conn.send(JSON.stringify(e));
|
|
4060
4062
|
}
|
|
4061
4063
|
}
|
|
4062
|
-
class
|
|
4064
|
+
class Ta {
|
|
4063
4065
|
constructor(e, n) {
|
|
4064
4066
|
this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Gi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
|
|
4065
4067
|
this.initParams || this.handleError();
|
|
@@ -4152,14 +4154,14 @@ var Vr = function(t, e, n, r) {
|
|
|
4152
4154
|
});
|
|
4153
4155
|
}
|
|
4154
4156
|
return new (n || (n = Promise))(function(s, o) {
|
|
4155
|
-
function
|
|
4157
|
+
function u(d) {
|
|
4156
4158
|
try {
|
|
4157
4159
|
c(r.next(d));
|
|
4158
4160
|
} catch (f) {
|
|
4159
4161
|
o(f);
|
|
4160
4162
|
}
|
|
4161
4163
|
}
|
|
4162
|
-
function
|
|
4164
|
+
function a(d) {
|
|
4163
4165
|
try {
|
|
4164
4166
|
c(r.throw(d));
|
|
4165
4167
|
} catch (f) {
|
|
@@ -4167,12 +4169,12 @@ var Vr = function(t, e, n, r) {
|
|
|
4167
4169
|
}
|
|
4168
4170
|
}
|
|
4169
4171
|
function c(d) {
|
|
4170
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
4172
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
4171
4173
|
}
|
|
4172
4174
|
c((r = r.apply(t, e || [])).next());
|
|
4173
4175
|
});
|
|
4174
4176
|
};
|
|
4175
|
-
function
|
|
4177
|
+
function ma(t, e) {
|
|
4176
4178
|
const n = t.values;
|
|
4177
4179
|
if (n) {
|
|
4178
4180
|
const r = mi(n.attrsStore, null);
|
|
@@ -4184,7 +4186,7 @@ function mu(t, e) {
|
|
|
4184
4186
|
}
|
|
4185
4187
|
return t;
|
|
4186
4188
|
}
|
|
4187
|
-
function
|
|
4189
|
+
function va(t, e) {
|
|
4188
4190
|
var n;
|
|
4189
4191
|
if (e.values) {
|
|
4190
4192
|
const r = [];
|
|
@@ -4196,7 +4198,7 @@ function vu(t, e) {
|
|
|
4196
4198
|
} else
|
|
4197
4199
|
return e;
|
|
4198
4200
|
}
|
|
4199
|
-
function
|
|
4201
|
+
function Sa(t, e, n) {
|
|
4200
4202
|
var r, i;
|
|
4201
4203
|
const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
|
|
4202
4204
|
return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
|
|
@@ -4223,17 +4225,17 @@ function Gr(t, e, n) {
|
|
|
4223
4225
|
break;
|
|
4224
4226
|
}
|
|
4225
4227
|
}
|
|
4226
|
-
function
|
|
4228
|
+
function Oa(t, e, n) {
|
|
4227
4229
|
var r, i, s, o;
|
|
4228
|
-
const
|
|
4229
|
-
for (const { action:
|
|
4230
|
+
const u = {};
|
|
4231
|
+
for (const { action: a, triple: c } of n) {
|
|
4230
4232
|
const [d, f, l] = c, p = (i = (r = e.getAttr(f)) === null || r === void 0 ? void 0 : r["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
|
|
4231
4233
|
if (!p)
|
|
4232
4234
|
continue;
|
|
4233
|
-
const y = (s =
|
|
4234
|
-
|
|
4235
|
+
const y = (s = u[d]) !== null && s !== void 0 ? s : {};
|
|
4236
|
+
u[d] = y;
|
|
4235
4237
|
const b = (o = y[p]) !== null && o !== void 0 ? o : {};
|
|
4236
|
-
switch (y[p] = b,
|
|
4238
|
+
switch (y[p] = b, a) {
|
|
4237
4239
|
case "added":
|
|
4238
4240
|
b.newValue = l;
|
|
4239
4241
|
break;
|
|
@@ -4242,53 +4244,53 @@ function Ou(t, e, n) {
|
|
|
4242
4244
|
break;
|
|
4243
4245
|
}
|
|
4244
4246
|
}
|
|
4245
|
-
for (const
|
|
4246
|
-
const { oldValue: c, newValue: d } = a
|
|
4247
|
-
c === d && delete a
|
|
4247
|
+
for (const a of Object.keys(u)) {
|
|
4248
|
+
const { oldValue: c, newValue: d } = u[a];
|
|
4249
|
+
c === d && delete u[a];
|
|
4248
4250
|
}
|
|
4249
|
-
return
|
|
4251
|
+
return u;
|
|
4250
4252
|
}
|
|
4251
4253
|
function Tt(t, e) {
|
|
4252
4254
|
return { [t.table]: e.map((n) => n.entity) };
|
|
4253
4255
|
}
|
|
4254
|
-
function
|
|
4256
|
+
function Ea(t, e) {
|
|
4255
4257
|
var n;
|
|
4256
4258
|
if (t.orderFieldType)
|
|
4257
4259
|
return t.orderFieldType;
|
|
4258
4260
|
const r = t.orderField === "serverCreatedAt" ? "number" : (n = K(e(), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
|
|
4259
4261
|
return t.orderFieldType = r, r;
|
|
4260
4262
|
}
|
|
4261
|
-
function
|
|
4263
|
+
function Aa(t, e, n) {
|
|
4262
4264
|
const r = e;
|
|
4263
4265
|
if (t.orderField === "serverCreatedAt") {
|
|
4264
|
-
n.sort(t.orderDirection === "asc" ? function(o,
|
|
4265
|
-
return Ze(o.entity.id, o.serverCreatedAt,
|
|
4266
|
-
} : function(o,
|
|
4267
|
-
return Ze(
|
|
4266
|
+
n.sort(t.orderDirection === "asc" ? function(o, u) {
|
|
4267
|
+
return Ze(o.entity.id, o.serverCreatedAt, u.entity.id, u.serverCreatedAt, r);
|
|
4268
|
+
} : function(o, u) {
|
|
4269
|
+
return Ze(u.entity.id, u.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
|
|
4268
4270
|
});
|
|
4269
4271
|
return;
|
|
4270
4272
|
}
|
|
4271
4273
|
const i = t.orderField;
|
|
4272
|
-
n.sort(t.orderDirection === "asc" ? function(o,
|
|
4273
|
-
return Ze(o.entity.id, o.entity[i],
|
|
4274
|
-
} : function(o,
|
|
4275
|
-
return Ze(
|
|
4274
|
+
n.sort(t.orderDirection === "asc" ? function(o, u) {
|
|
4275
|
+
return Ze(o.entity.id, o.entity[i], u.entity.id, u.entity[i], r);
|
|
4276
|
+
} : function(o, u) {
|
|
4277
|
+
return Ze(u.entity.id, u.entity[i], o.entity.id, o.entity[i], r);
|
|
4276
4278
|
});
|
|
4277
4279
|
}
|
|
4278
4280
|
var ve;
|
|
4279
4281
|
(function(t) {
|
|
4280
4282
|
t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
|
|
4281
4283
|
})(ve || (ve = {}));
|
|
4282
|
-
class
|
|
4284
|
+
class ka {
|
|
4283
4285
|
constructor(e, n, r, i, s, o) {
|
|
4284
4286
|
this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.getAttrs = o, this.subs = new _n({
|
|
4285
4287
|
persister: n,
|
|
4286
|
-
merge:
|
|
4287
|
-
serialize:
|
|
4288
|
-
parse: (
|
|
4289
|
-
objectSize: (
|
|
4290
|
-
var
|
|
4291
|
-
return ((
|
|
4288
|
+
merge: Sa,
|
|
4289
|
+
serialize: va,
|
|
4290
|
+
parse: (u, a) => ma(a, this.config.useDateObjects),
|
|
4291
|
+
objectSize: (u) => {
|
|
4292
|
+
var a;
|
|
4293
|
+
return ((a = u.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
|
|
4292
4294
|
},
|
|
4293
4295
|
logger: i,
|
|
4294
4296
|
gc: {
|
|
@@ -4343,17 +4345,17 @@ class ku {
|
|
|
4343
4345
|
}
|
|
4344
4346
|
initSubscription(e, n, r) {
|
|
4345
4347
|
return Vr(this, void 0, void 0, function* () {
|
|
4346
|
-
var i, s, o,
|
|
4348
|
+
var i, s, o, u;
|
|
4347
4349
|
yield this.subs.waitForKeyToLoad(n);
|
|
4348
|
-
const
|
|
4349
|
-
if (
|
|
4350
|
-
this.sendResync(
|
|
4350
|
+
const a = this.subs.currentValue[n];
|
|
4351
|
+
if (a && a.state && a.state.txId) {
|
|
4352
|
+
this.sendResync(a, a.state, a.state.txId), !((i = a.values) === null || i === void 0) && i.entities && r && r({
|
|
4351
4353
|
type: ve.LoadFromStorage,
|
|
4352
|
-
data: Tt(
|
|
4354
|
+
data: Tt(a, (s = a.values) === null || s === void 0 ? void 0 : s.entities)
|
|
4353
4355
|
});
|
|
4354
4356
|
return;
|
|
4355
4357
|
}
|
|
4356
|
-
const c = Object.keys(e)[0], d = ((
|
|
4358
|
+
const c = Object.keys(e)[0], d = ((u = (o = e[c]) === null || o === void 0 ? void 0 : o.$) === null || u === void 0 ? void 0 : u.order) || { serverCreatedAt: "asc" }, [f, l] = Object.entries(d)[0];
|
|
4357
4359
|
this.subs.updateInPlace((p) => {
|
|
4358
4360
|
p[n] = {
|
|
4359
4361
|
query: e,
|
|
@@ -4399,30 +4401,30 @@ class ku {
|
|
|
4399
4401
|
this.log.error("Missing hash for subscription", e);
|
|
4400
4402
|
return;
|
|
4401
4403
|
}
|
|
4402
|
-
const o = [],
|
|
4403
|
-
if (!
|
|
4404
|
+
const o = [], u = this.subs.currentValue[s];
|
|
4405
|
+
if (!u) {
|
|
4404
4406
|
this.log.error("Missing sub for hash", s, e);
|
|
4405
4407
|
return;
|
|
4406
4408
|
}
|
|
4407
|
-
const
|
|
4409
|
+
const a = (n = u.values) !== null && n !== void 0 ? n : {
|
|
4408
4410
|
entities: [],
|
|
4409
4411
|
attrsStore: this.getAttrs()
|
|
4410
4412
|
};
|
|
4411
|
-
|
|
4412
|
-
const c =
|
|
4413
|
+
u.values = a;
|
|
4414
|
+
const c = a.entities;
|
|
4413
4415
|
for (const d of i) {
|
|
4414
|
-
const f = this.createStore(d), l = Jt(
|
|
4416
|
+
const f = this.createStore(d), l = Jt(u, f, a.attrsStore);
|
|
4415
4417
|
c.push({
|
|
4416
4418
|
store: f,
|
|
4417
4419
|
entity: l,
|
|
4418
|
-
serverCreatedAt: Br(
|
|
4420
|
+
serverCreatedAt: Br(u, f, a.attrsStore, l.id)
|
|
4419
4421
|
}), o.push(l);
|
|
4420
4422
|
}
|
|
4421
4423
|
this.subs.updateInPlace((d) => {
|
|
4422
|
-
d[s] =
|
|
4423
|
-
}),
|
|
4424
|
+
d[s] = u, d[s].updatedAt = Date.now();
|
|
4425
|
+
}), u.values && this.notifyCbs(s, {
|
|
4424
4426
|
type: ve.InitialSyncBatch,
|
|
4425
|
-
data: Tt(
|
|
4427
|
+
data: Tt(u, u.values.entities),
|
|
4426
4428
|
batch: o
|
|
4427
4429
|
});
|
|
4428
4430
|
}
|
|
@@ -4434,15 +4436,15 @@ class ku {
|
|
|
4434
4436
|
return;
|
|
4435
4437
|
}
|
|
4436
4438
|
this.subs.updateInPlace((o) => {
|
|
4437
|
-
const
|
|
4438
|
-
if (!
|
|
4439
|
+
const u = o[i];
|
|
4440
|
+
if (!u) {
|
|
4439
4441
|
this.log.error("Missing sub for hash", i, e);
|
|
4440
4442
|
return;
|
|
4441
4443
|
}
|
|
4442
|
-
const
|
|
4443
|
-
if (!
|
|
4444
|
-
return this.log.error("Sub never set init, missing result",
|
|
4445
|
-
|
|
4444
|
+
const a = u.state;
|
|
4445
|
+
if (!a)
|
|
4446
|
+
return this.log.error("Sub never set init, missing result", u, e), o;
|
|
4447
|
+
a.txId = e["tx-id"], u.updatedAt = Date.now();
|
|
4446
4448
|
});
|
|
4447
4449
|
const s = this.subs.currentValue[i];
|
|
4448
4450
|
s && this.notifyCbs(i, {
|
|
@@ -4457,37 +4459,37 @@ class ku {
|
|
|
4457
4459
|
this.log.error("Missing hash for subscription", e);
|
|
4458
4460
|
return;
|
|
4459
4461
|
}
|
|
4460
|
-
const
|
|
4461
|
-
if (!
|
|
4462
|
+
const u = this.subs.currentValue[o];
|
|
4463
|
+
if (!u) {
|
|
4462
4464
|
this.log.error("Missing sub for hash", o, e);
|
|
4463
4465
|
return;
|
|
4464
4466
|
}
|
|
4465
|
-
const
|
|
4466
|
-
if (!
|
|
4467
|
-
this.log.error("Missing state for sub",
|
|
4467
|
+
const a = u.state;
|
|
4468
|
+
if (!a) {
|
|
4469
|
+
this.log.error("Missing state for sub", u, e);
|
|
4468
4470
|
return;
|
|
4469
4471
|
}
|
|
4470
4472
|
for (const c of e.txes) {
|
|
4471
|
-
if (
|
|
4473
|
+
if (a.txId && a.txId >= c["tx-id"])
|
|
4472
4474
|
continue;
|
|
4473
|
-
|
|
4475
|
+
a.txId = c["tx-id"];
|
|
4474
4476
|
const d = [], f = {};
|
|
4475
4477
|
for (const g of c.changes) {
|
|
4476
4478
|
const m = (n = f[g.triple[0]]) !== null && n !== void 0 ? n : [];
|
|
4477
4479
|
f[g.triple[0]] = m, m.push(g);
|
|
4478
4480
|
}
|
|
4479
|
-
const l = (r =
|
|
4481
|
+
const l = (r = u.values) !== null && r !== void 0 ? r : {
|
|
4480
4482
|
entities: [],
|
|
4481
4483
|
attrsStore: this.getAttrs()
|
|
4482
4484
|
}, p = l.entities;
|
|
4483
|
-
|
|
4485
|
+
u.values = l;
|
|
4484
4486
|
const y = [];
|
|
4485
4487
|
e: for (const [g, m] of Object.entries(f))
|
|
4486
4488
|
for (let O = 0; O < p.length; O++) {
|
|
4487
4489
|
const S = p[O];
|
|
4488
4490
|
if (io(S.store, g)) {
|
|
4489
4491
|
Gr(S.store, l.attrsStore, m);
|
|
4490
|
-
const C = Jt(
|
|
4492
|
+
const C = Jt(u, S.store, l.attrsStore), $ = Oa(S.store, l.attrsStore, m)[g];
|
|
4491
4493
|
C ? (y.push({
|
|
4492
4494
|
oldEntity: S.entity,
|
|
4493
4495
|
newEntity: C,
|
|
@@ -4500,10 +4502,10 @@ class ku {
|
|
|
4500
4502
|
for (const [g, m] of Object.entries(f)) {
|
|
4501
4503
|
const O = this.createStore([]);
|
|
4502
4504
|
Gr(O, l.attrsStore, m);
|
|
4503
|
-
const S = Jt(
|
|
4505
|
+
const S = Jt(u, O, l.attrsStore);
|
|
4504
4506
|
if (!S) {
|
|
4505
4507
|
this.log.error("No entity found after applying change", {
|
|
4506
|
-
sub:
|
|
4508
|
+
sub: u,
|
|
4507
4509
|
changes: m,
|
|
4508
4510
|
store: O
|
|
4509
4511
|
});
|
|
@@ -4512,23 +4514,23 @@ class ku {
|
|
|
4512
4514
|
p.push({
|
|
4513
4515
|
store: O,
|
|
4514
4516
|
entity: S,
|
|
4515
|
-
serverCreatedAt: Br(
|
|
4517
|
+
serverCreatedAt: Br(u, O, l.attrsStore, S.id)
|
|
4516
4518
|
}), b.push(S);
|
|
4517
4519
|
}
|
|
4518
4520
|
const _ = [];
|
|
4519
4521
|
for (const g of d.sort().reverse())
|
|
4520
4522
|
_.push(p[g].entity), p.splice(g, 1);
|
|
4521
|
-
const T =
|
|
4522
|
-
|
|
4523
|
+
const T = Ea(u, this.getAttrs);
|
|
4524
|
+
Aa(u, T, p), this.notifyCbs(o, {
|
|
4523
4525
|
type: ve.SyncTransaction,
|
|
4524
|
-
data: Tt(
|
|
4526
|
+
data: Tt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
|
|
4525
4527
|
added: b,
|
|
4526
4528
|
removed: _,
|
|
4527
4529
|
updated: y
|
|
4528
4530
|
});
|
|
4529
4531
|
}
|
|
4530
4532
|
this.subs.updateInPlace((c) => {
|
|
4531
|
-
c[o] =
|
|
4533
|
+
c[o] = u, c[o].updatedAt = Date.now();
|
|
4532
4534
|
});
|
|
4533
4535
|
}
|
|
4534
4536
|
clearSubscriptionData(e, n) {
|
|
@@ -4567,14 +4569,14 @@ var N = function(t, e, n, r) {
|
|
|
4567
4569
|
});
|
|
4568
4570
|
}
|
|
4569
4571
|
return new (n || (n = Promise))(function(s, o) {
|
|
4570
|
-
function
|
|
4572
|
+
function u(d) {
|
|
4571
4573
|
try {
|
|
4572
4574
|
c(r.next(d));
|
|
4573
4575
|
} catch (f) {
|
|
4574
4576
|
o(f);
|
|
4575
4577
|
}
|
|
4576
4578
|
}
|
|
4577
|
-
function
|
|
4579
|
+
function a(d) {
|
|
4578
4580
|
try {
|
|
4579
4581
|
c(r.throw(d));
|
|
4580
4582
|
} catch (f) {
|
|
@@ -4582,7 +4584,7 @@ var N = function(t, e, n, r) {
|
|
|
4582
4584
|
}
|
|
4583
4585
|
}
|
|
4584
4586
|
function c(d) {
|
|
4585
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
4587
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
4586
4588
|
}
|
|
4587
4589
|
c((r = r.apply(t, e || [])).next());
|
|
4588
4590
|
});
|
|
@@ -4600,23 +4602,23 @@ const he = {
|
|
|
4600
4602
|
AUTHENTICATED: "authenticated",
|
|
4601
4603
|
CLOSED: "closed",
|
|
4602
4604
|
ERRORED: "errored"
|
|
4603
|
-
},
|
|
4605
|
+
}, ja = 3e4, Ca = 3e4, Ia = 200, Pa = {
|
|
4604
4606
|
apiURI: "https://api.instantdb.com",
|
|
4605
4607
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
4606
4608
|
}, Zt = "_instant_oauth_redirect", Ge = "currentUser";
|
|
4607
|
-
function
|
|
4609
|
+
function Ma({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
|
|
4608
4610
|
if (!i)
|
|
4609
4611
|
return new zr(`${r}?app_id=${e}`);
|
|
4610
4612
|
switch (t) {
|
|
4611
4613
|
case "ws":
|
|
4612
4614
|
return new zr(`${r}?app_id=${e}`);
|
|
4613
4615
|
case "sse":
|
|
4614
|
-
return new
|
|
4616
|
+
return new Ta(i, `${n}/runtime/sse?app_id=${e}`);
|
|
4615
4617
|
default:
|
|
4616
4618
|
throw new Error("Unknown transport type " + t);
|
|
4617
4619
|
}
|
|
4618
4620
|
}
|
|
4619
|
-
function
|
|
4621
|
+
function Ra() {
|
|
4620
4622
|
return typeof window < "u" || typeof chrome < "u";
|
|
4621
4623
|
}
|
|
4622
4624
|
const Qr = {
|
|
@@ -4625,7 +4627,7 @@ const Qr = {
|
|
|
4625
4627
|
"refresh-presence": !0,
|
|
4626
4628
|
"patch-presence": !0
|
|
4627
4629
|
};
|
|
4628
|
-
function
|
|
4630
|
+
function xa(t, e) {
|
|
4629
4631
|
var n;
|
|
4630
4632
|
const r = typeof t == "string" ? JSON.parse(t) : t;
|
|
4631
4633
|
if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
|
|
@@ -4637,7 +4639,7 @@ function xu(t, e) {
|
|
|
4637
4639
|
}
|
|
4638
4640
|
return r;
|
|
4639
4641
|
}
|
|
4640
|
-
function $
|
|
4642
|
+
function $a(t, e) {
|
|
4641
4643
|
const { result: n } = e, i = Qi(e, ["result"]);
|
|
4642
4644
|
if (n) {
|
|
4643
4645
|
const s = Object.assign(Object.assign({}, n), { store: wi(n.store), attrsStore: n.attrsStore.toJSON() });
|
|
@@ -4645,7 +4647,7 @@ function $u(t, e) {
|
|
|
4645
4647
|
}
|
|
4646
4648
|
return i;
|
|
4647
4649
|
}
|
|
4648
|
-
function
|
|
4650
|
+
function Da(t, e) {
|
|
4649
4651
|
switch (t) {
|
|
4650
4652
|
case "pendingMutations":
|
|
4651
4653
|
return new Map(typeof e == "string" ? JSON.parse(e) : e);
|
|
@@ -4653,7 +4655,7 @@ function Du(t, e) {
|
|
|
4653
4655
|
return e;
|
|
4654
4656
|
}
|
|
4655
4657
|
}
|
|
4656
|
-
function
|
|
4658
|
+
function Ua(t, e) {
|
|
4657
4659
|
switch (t) {
|
|
4658
4660
|
case "pendingMutations":
|
|
4659
4661
|
return [...e.entries()];
|
|
@@ -4661,19 +4663,19 @@ function Uu(t, e) {
|
|
|
4661
4663
|
return e;
|
|
4662
4664
|
}
|
|
4663
4665
|
}
|
|
4664
|
-
function
|
|
4666
|
+
function La(t, e, n) {
|
|
4665
4667
|
const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
|
|
4666
4668
|
return r && !i && n && (n.result = r), n || e;
|
|
4667
4669
|
}
|
|
4668
4670
|
function Hr(t) {
|
|
4669
4671
|
return [...t].sort((e, n) => {
|
|
4670
|
-
const [r, i] = e, [s, o] = n,
|
|
4671
|
-
return
|
|
4672
|
+
const [r, i] = e, [s, o] = n, u = i.order || 0, a = o.order || 0;
|
|
4673
|
+
return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
|
|
4672
4674
|
});
|
|
4673
4675
|
}
|
|
4674
|
-
class
|
|
4676
|
+
class Fa {
|
|
4675
4677
|
constructor(e, n = Ui, r = Li, i, s) {
|
|
4676
|
-
var o,
|
|
4678
|
+
var o, u, a;
|
|
4677
4679
|
if (this._isOnline = !0, this._isShutdown = !1, this.status = he.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (c, d, f) => {
|
|
4678
4680
|
var l, p;
|
|
4679
4681
|
switch (c) {
|
|
@@ -4704,9 +4706,9 @@ class Fu {
|
|
|
4704
4706
|
}, this.notifyQueryError = (c, d) => {
|
|
4705
4707
|
(this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
|
|
4706
4708
|
}, this.pushTx = (c) => {
|
|
4707
|
-
this.config.disableValidation ||
|
|
4709
|
+
this.config.disableValidation || wa(c, this.config.schema);
|
|
4708
4710
|
try {
|
|
4709
|
-
const d =
|
|
4711
|
+
const d = Ku({
|
|
4710
4712
|
attrsStore: this.optimisticAttrs(),
|
|
4711
4713
|
schema: this.config.schema,
|
|
4712
4714
|
stores: Object.values(this.querySubs.currentValue).map((f) => {
|
|
@@ -4795,7 +4797,7 @@ class Fu {
|
|
|
4795
4797
|
return;
|
|
4796
4798
|
}
|
|
4797
4799
|
this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
|
|
4798
|
-
}, this._EventSource = s, this.config = Object.assign(Object.assign({},
|
|
4800
|
+
}, this._EventSource = s, this.config = Object.assign(Object.assign({}, Pa), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Ca, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Ia, this._log = da(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Ra()) {
|
|
4799
4801
|
if (!e.appId)
|
|
4800
4802
|
throw new Error("Instant must be initialized with an appId.");
|
|
4801
4803
|
if (!Ne(e.appId))
|
|
@@ -4810,7 +4812,7 @@ class Fu {
|
|
|
4810
4812
|
} catch (f) {
|
|
4811
4813
|
this._log.error("[error] handle broadcast channel", f);
|
|
4812
4814
|
}
|
|
4813
|
-
}))), this._initStorage(n), this._syncTable = new
|
|
4815
|
+
}))), this._initStorage(n), this._syncTable = new ka(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
|
|
4814
4816
|
useDateObjects: this.config.useDateObjects
|
|
4815
4817
|
}, this._log, (c) => Et(this.ensureAttrs(), c, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((c) => {
|
|
4816
4818
|
this._isOnline = c, this._startSocket(), r.listen((d) => {
|
|
@@ -4840,9 +4842,9 @@ class Fu {
|
|
|
4840
4842
|
_initStorage(e) {
|
|
4841
4843
|
this.querySubs = new _n({
|
|
4842
4844
|
persister: new e(this.config.appId, "querySubs"),
|
|
4843
|
-
merge:
|
|
4844
|
-
serialize: $
|
|
4845
|
-
parse: (n, r) =>
|
|
4845
|
+
merge: La,
|
|
4846
|
+
serialize: $a,
|
|
4847
|
+
parse: (n, r) => xa(r, this.config.useDateObjects),
|
|
4846
4848
|
// objectSize
|
|
4847
4849
|
objectSize: (n) => {
|
|
4848
4850
|
var r, i, s, o;
|
|
@@ -4861,8 +4863,8 @@ class Fu {
|
|
|
4861
4863
|
}), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new _n({
|
|
4862
4864
|
persister: new e(this.config.appId, "kv"),
|
|
4863
4865
|
merge: this._onMergeKv,
|
|
4864
|
-
serialize:
|
|
4865
|
-
parse:
|
|
4866
|
+
serialize: Ua,
|
|
4867
|
+
parse: Da,
|
|
4866
4868
|
objectSize: () => 0,
|
|
4867
4869
|
logger: this._log,
|
|
4868
4870
|
saveThrottleMs: 100,
|
|
@@ -4893,10 +4895,10 @@ class Fu {
|
|
|
4893
4895
|
if (s)
|
|
4894
4896
|
i.resolve({ status: e, eventId: n });
|
|
4895
4897
|
else if (r != null && r.type) {
|
|
4896
|
-
const { status: o } = r,
|
|
4898
|
+
const { status: o } = r, u = Qi(r, ["status"]);
|
|
4897
4899
|
i.reject(new Dt({
|
|
4898
4900
|
// @ts-expect-error body.type is not constant typed
|
|
4899
|
-
body:
|
|
4901
|
+
body: u,
|
|
4900
4902
|
status: o ?? 0
|
|
4901
4903
|
}));
|
|
4902
4904
|
} else
|
|
@@ -4910,12 +4912,12 @@ class Fu {
|
|
|
4910
4912
|
const i = (r = (n = this._presence[e]) === null || n === void 0 ? void 0 : n.result) === null || r === void 0 ? void 0 : r.user, s = this._broadcastQueue[e];
|
|
4911
4913
|
if (this._broadcastQueue[e] = [], i && this._trySetPresence(e, i), s)
|
|
4912
4914
|
for (const o of s) {
|
|
4913
|
-
const { topic:
|
|
4914
|
-
this._tryBroadcast(e,
|
|
4915
|
+
const { topic: u, roomType: a, data: c } = o;
|
|
4916
|
+
this._tryBroadcast(e, a, u, c);
|
|
4915
4917
|
}
|
|
4916
4918
|
}
|
|
4917
4919
|
_handleReceive(e, n) {
|
|
4918
|
-
var r, i, s, o,
|
|
4920
|
+
var r, i, s, o, u, a;
|
|
4919
4921
|
const c = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
|
|
4920
4922
|
switch (Qr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
|
|
4921
4923
|
case "init-ok": {
|
|
@@ -4934,15 +4936,15 @@ class Fu {
|
|
|
4934
4936
|
const { q: l, result: p } = n, y = B(l);
|
|
4935
4937
|
if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
|
|
4936
4938
|
break;
|
|
4937
|
-
const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (
|
|
4938
|
-
this.querySubs.updateInPlace((
|
|
4939
|
-
if (!
|
|
4939
|
+
const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, T = Dr(p), g = this.ensureAttrs(), m = Et(g, T, c, this.config.useDateObjects);
|
|
4940
|
+
this.querySubs.updateInPlace((O) => {
|
|
4941
|
+
if (!O[y]) {
|
|
4940
4942
|
this._log.info("Missing value in querySubs", { hash: y, q: l });
|
|
4941
4943
|
return;
|
|
4942
4944
|
}
|
|
4943
|
-
|
|
4944
|
-
store:
|
|
4945
|
-
attrsStore:
|
|
4945
|
+
O[y].result = {
|
|
4946
|
+
store: m,
|
|
4947
|
+
attrsStore: g,
|
|
4946
4948
|
pageInfo: b,
|
|
4947
4949
|
aggregate: _,
|
|
4948
4950
|
processedTxId: n["processed-tx-id"]
|
|
@@ -5095,7 +5097,7 @@ class Fu {
|
|
|
5095
5097
|
}
|
|
5096
5098
|
}
|
|
5097
5099
|
_handleReceiveError(e) {
|
|
5098
|
-
var n, r, i, s, o,
|
|
5100
|
+
var n, r, i, s, o, u, a;
|
|
5099
5101
|
console.log("error", e);
|
|
5100
5102
|
const c = e["client-event-id"];
|
|
5101
5103
|
this._inFlightMutationEventIds.delete(c);
|
|
@@ -5119,11 +5121,11 @@ class Fu {
|
|
|
5119
5121
|
this._setStatus(he.ERRORED, f), this.notifyAll();
|
|
5120
5122
|
return;
|
|
5121
5123
|
}
|
|
5122
|
-
if (((
|
|
5124
|
+
if (((u = e["original-event"]) === null || u === void 0 ? void 0 : u.op) === "resync-table") {
|
|
5123
5125
|
this._syncTable.onResyncError(e);
|
|
5124
5126
|
return;
|
|
5125
5127
|
}
|
|
5126
|
-
if (((
|
|
5128
|
+
if (((a = e["original-event"]) === null || a === void 0 ? void 0 : a.op) === "start-sync") {
|
|
5127
5129
|
this._syncTable.onStartSyncError(e);
|
|
5128
5130
|
return;
|
|
5129
5131
|
}
|
|
@@ -5133,7 +5135,7 @@ class Fu {
|
|
|
5133
5135
|
}
|
|
5134
5136
|
notifyQueryOnceError(e, n, r, i) {
|
|
5135
5137
|
var s;
|
|
5136
|
-
const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((
|
|
5138
|
+
const o = (s = this.queryOnceDfds[n]) === null || s === void 0 ? void 0 : s.find((u) => u.eventId === r);
|
|
5137
5139
|
o && (o.dfd.reject(i), this._completeQueryOnce(e, n, o.dfd));
|
|
5138
5140
|
}
|
|
5139
5141
|
_setAttrs(e) {
|
|
@@ -5175,7 +5177,7 @@ class Fu {
|
|
|
5175
5177
|
if (!this.querySubs)
|
|
5176
5178
|
return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
|
|
5177
5179
|
const s = B(e), o = this._startQuerySub(e, s);
|
|
5178
|
-
return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")),
|
|
5180
|
+
return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), ja), i.promise;
|
|
5179
5181
|
}
|
|
5180
5182
|
_completeQueryOnce(e, n, r) {
|
|
5181
5183
|
this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
|
|
@@ -5219,37 +5221,37 @@ class Fu {
|
|
|
5219
5221
|
const [f, l, p] = d["forward-identity"];
|
|
5220
5222
|
return Ie(e, l, p);
|
|
5221
5223
|
}, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
|
|
5222
|
-
let
|
|
5223
|
-
const
|
|
5224
|
+
let u = !1;
|
|
5225
|
+
const a = (d, f) => {
|
|
5224
5226
|
const l = [];
|
|
5225
5227
|
for (const p of d) {
|
|
5226
5228
|
const [y] = p;
|
|
5227
5229
|
if (y === "add-attr") {
|
|
5228
5230
|
const [_, T] = p, g = i(T);
|
|
5229
5231
|
if (g && T.id !== g.id) {
|
|
5230
|
-
o.attrIdMap[T.id] = g.id,
|
|
5232
|
+
o.attrIdMap[T.id] = g.id, u = !0;
|
|
5231
5233
|
continue;
|
|
5232
5234
|
}
|
|
5233
5235
|
if (T["value-type"] === "ref") {
|
|
5234
5236
|
const m = s(T);
|
|
5235
5237
|
if (m) {
|
|
5236
|
-
o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id),
|
|
5238
|
+
o.attrIdMap[T.id] = m.id, o.refSwapAttrIds.add(T.id), u = !0;
|
|
5237
5239
|
continue;
|
|
5238
5240
|
}
|
|
5239
5241
|
}
|
|
5240
5242
|
}
|
|
5241
5243
|
if (r && f && r >= f && y === "add-attr" || y === "update-attr" || y === "delete-attr") {
|
|
5242
|
-
|
|
5244
|
+
u = !0;
|
|
5243
5245
|
continue;
|
|
5244
5246
|
}
|
|
5245
|
-
const b =
|
|
5247
|
+
const b = u ? bu(o, p) : p;
|
|
5246
5248
|
l.push(b);
|
|
5247
5249
|
}
|
|
5248
|
-
return
|
|
5250
|
+
return u ? l : d;
|
|
5249
5251
|
}, c = /* @__PURE__ */ new Map();
|
|
5250
5252
|
for (const [d, f] of n.entries())
|
|
5251
|
-
c.set(d, Object.assign(Object.assign({}, f), { "tx-steps":
|
|
5252
|
-
return
|
|
5253
|
+
c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": a(f["tx-steps"], f["tx-id"]) }));
|
|
5254
|
+
return u ? c : n;
|
|
5253
5255
|
}
|
|
5254
5256
|
_rewriteMutationsSorted(e, n) {
|
|
5255
5257
|
return Hr(this._rewriteMutations(e, n).entries());
|
|
@@ -5261,21 +5263,21 @@ class Fu {
|
|
|
5261
5263
|
*/
|
|
5262
5264
|
optimisticAttrs() {
|
|
5263
5265
|
var e, n;
|
|
5264
|
-
const r = [...this._pendingMutations().values()].flatMap((
|
|
5265
|
-
for (const [
|
|
5266
|
-
if (
|
|
5267
|
-
s.push(
|
|
5268
|
-
else if (
|
|
5269
|
-
const c = Object.assign(Object.assign({}, this.attrs.getAttr(
|
|
5266
|
+
const r = [...this._pendingMutations().values()].flatMap((u) => u["tx-steps"]), i = new Set(r.filter(([u, a]) => u === "delete-attr").map(([u, a]) => a)), s = [];
|
|
5267
|
+
for (const [u, a] of r)
|
|
5268
|
+
if (u === "add-attr")
|
|
5269
|
+
s.push(a);
|
|
5270
|
+
else if (u === "update-attr" && a.id && (!((e = this.attrs) === null || e === void 0) && e.getAttr(a.id))) {
|
|
5271
|
+
const c = Object.assign(Object.assign({}, this.attrs.getAttr(a.id)), a);
|
|
5270
5272
|
s.push(c);
|
|
5271
5273
|
}
|
|
5272
5274
|
if (!i.size && !s.length)
|
|
5273
5275
|
return this.attrs || new Ae({}, this._linkIndex);
|
|
5274
5276
|
const o = Object.assign({}, ((n = this.attrs) === null || n === void 0 ? void 0 : n.attrs) || {});
|
|
5275
|
-
for (const
|
|
5276
|
-
o[
|
|
5277
|
-
for (const
|
|
5278
|
-
delete o[
|
|
5277
|
+
for (const u of s)
|
|
5278
|
+
o[u.id] = u;
|
|
5279
|
+
for (const u of i)
|
|
5280
|
+
delete o[u];
|
|
5279
5281
|
return new Ae(o, this._linkIndex);
|
|
5280
5282
|
}
|
|
5281
5283
|
/** Runs instaql on a query and a store */
|
|
@@ -5285,20 +5287,20 @@ class Fu {
|
|
|
5285
5287
|
return { error: n };
|
|
5286
5288
|
if (!this.querySubs || !this.kv.currentValue.pendingMutations)
|
|
5287
5289
|
return;
|
|
5288
|
-
const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q:
|
|
5289
|
-
if (!
|
|
5290
|
+
const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: u, result: a } = i[e] || {};
|
|
5291
|
+
if (!a)
|
|
5290
5292
|
return;
|
|
5291
5293
|
const c = this._dataForQueryCache[e];
|
|
5292
5294
|
if (c && r === c.querySubVersion && s === c.pendingMutationsVersion)
|
|
5293
5295
|
return c;
|
|
5294
|
-
const { store: d, attrsStore: f, pageInfo: l, aggregate: p, processedTxId: y } =
|
|
5295
|
-
return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p },
|
|
5296
|
+
const { store: d, attrsStore: f, pageInfo: l, aggregate: p, processedTxId: y } = a, b = this._rewriteMutationsSorted(f, o), { store: _, attrsStore: T } = this._applyOptimisticUpdates(d, f, b, y);
|
|
5297
|
+
return { data: Ri({ store: _, attrsStore: T, pageInfo: l, aggregate: p }, u), querySubVersion: r, pendingMutationsVersion: s };
|
|
5296
5298
|
}
|
|
5297
5299
|
_applyOptimisticUpdates(e, n, r, i) {
|
|
5298
5300
|
for (const [s, o] of r)
|
|
5299
5301
|
if (!o["tx-id"] || i && o["tx-id"] > i) {
|
|
5300
|
-
const
|
|
5301
|
-
e =
|
|
5302
|
+
const u = _o(e, n, o["tx-steps"]);
|
|
5303
|
+
e = u.store, n = u.attrsStore;
|
|
5302
5304
|
}
|
|
5303
5305
|
return { store: e, attrsStore: n };
|
|
5304
5306
|
}
|
|
@@ -5408,7 +5410,7 @@ class Fu {
|
|
|
5408
5410
|
return;
|
|
5409
5411
|
}
|
|
5410
5412
|
const e = this._transport;
|
|
5411
|
-
this._transport =
|
|
5413
|
+
this._transport = Ma({
|
|
5412
5414
|
transportType: this._transportType,
|
|
5413
5415
|
appId: this.config.appId,
|
|
5414
5416
|
apiURI: this.config.apiURI,
|
|
@@ -5454,8 +5456,8 @@ class Fu {
|
|
|
5454
5456
|
typeof navigation.removeEventListener == "function") {
|
|
5455
5457
|
let i = !1;
|
|
5456
5458
|
const s = (o) => {
|
|
5457
|
-
var
|
|
5458
|
-
i || (i = !0, navigation.removeEventListener("navigate", s), !o.userInitiated && o.navigationType === "replace" && ((
|
|
5459
|
+
var u;
|
|
5460
|
+
i || (i = !0, navigation.removeEventListener("navigate", s), !o.userInitiated && o.navigationType === "replace" && ((u = o.destination) === null || u === void 0 ? void 0 : u.url) === n && history.replaceState(history.state, "", r));
|
|
5459
5461
|
};
|
|
5460
5462
|
navigation.addEventListener("navigate", s);
|
|
5461
5463
|
}
|
|
@@ -5476,20 +5478,20 @@ class Fu {
|
|
|
5476
5478
|
const o = s.get("error");
|
|
5477
5479
|
if (o)
|
|
5478
5480
|
return this._replaceUrlAfterOAuth(), { error: { message: o } };
|
|
5479
|
-
const
|
|
5480
|
-
if (!
|
|
5481
|
+
const u = s.get("code");
|
|
5482
|
+
if (!u)
|
|
5481
5483
|
return null;
|
|
5482
5484
|
this._replaceUrlAfterOAuth();
|
|
5483
5485
|
try {
|
|
5484
|
-
const
|
|
5486
|
+
const a = yield this._getCurrentUser(), c = (a == null ? void 0 : a.type) === "guest", { user: d } = yield Rr({
|
|
5485
5487
|
apiURI: this.config.apiURI,
|
|
5486
5488
|
appId: this.config.appId,
|
|
5487
|
-
code:
|
|
5488
|
-
refreshToken: c ?
|
|
5489
|
+
code: u,
|
|
5490
|
+
refreshToken: c ? a.refresh_token : void 0
|
|
5489
5491
|
});
|
|
5490
5492
|
return this.setCurrentUser(d), null;
|
|
5491
|
-
} catch (
|
|
5492
|
-
return ((e =
|
|
5493
|
+
} catch (a) {
|
|
5494
|
+
return ((e = a == null ? void 0 : a.body) === null || e === void 0 ? void 0 : e.type) === "record-not-found" && ((r = (n = a == null ? void 0 : a.body) === null || n === void 0 ? void 0 : n.hint) === null || r === void 0 ? void 0 : r["record-type"]) === "app-oauth-code" && (yield this._hasCurrentUser()) ? null : { error: { message: ((i = a == null ? void 0 : a.body) === null || i === void 0 ? void 0 : i.message) || "Error logging in." } };
|
|
5493
5495
|
}
|
|
5494
5496
|
});
|
|
5495
5497
|
}
|
|
@@ -5611,7 +5613,7 @@ class Fu {
|
|
|
5611
5613
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
|
|
5612
5614
|
}
|
|
5613
5615
|
sendMagicCode({ email: e }) {
|
|
5614
|
-
return
|
|
5616
|
+
return Ju({
|
|
5615
5617
|
apiURI: this.config.apiURI,
|
|
5616
5618
|
appId: this.config.appId,
|
|
5617
5619
|
email: e
|
|
@@ -5620,19 +5622,19 @@ class Fu {
|
|
|
5620
5622
|
signInWithMagicCode(e) {
|
|
5621
5623
|
return N(this, arguments, void 0, function* ({ email: n, code: r }) {
|
|
5622
5624
|
var i;
|
|
5623
|
-
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest",
|
|
5625
|
+
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Zu({
|
|
5624
5626
|
apiURI: this.config.apiURI,
|
|
5625
5627
|
appId: this.config.appId,
|
|
5626
5628
|
email: n,
|
|
5627
5629
|
code: r,
|
|
5628
5630
|
refreshToken: o ? s.user.refresh_token : void 0
|
|
5629
5631
|
});
|
|
5630
|
-
return yield this.changeCurrentUser(
|
|
5632
|
+
return yield this.changeCurrentUser(u.user), u;
|
|
5631
5633
|
});
|
|
5632
5634
|
}
|
|
5633
5635
|
signInWithCustomToken(e) {
|
|
5634
5636
|
return N(this, void 0, void 0, function* () {
|
|
5635
|
-
const n = yield
|
|
5637
|
+
const n = yield Xu({
|
|
5636
5638
|
apiURI: this.config.apiURI,
|
|
5637
5639
|
appId: this.config.appId,
|
|
5638
5640
|
refreshToken: e
|
|
@@ -5642,7 +5644,7 @@ class Fu {
|
|
|
5642
5644
|
}
|
|
5643
5645
|
signInAsGuest() {
|
|
5644
5646
|
return N(this, void 0, void 0, function* () {
|
|
5645
|
-
const e = yield
|
|
5647
|
+
const e = yield ea({
|
|
5646
5648
|
apiURI: this.config.apiURI,
|
|
5647
5649
|
appId: this.config.appId
|
|
5648
5650
|
});
|
|
@@ -5658,7 +5660,7 @@ class Fu {
|
|
|
5658
5660
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
5659
5661
|
return;
|
|
5660
5662
|
}
|
|
5661
|
-
|
|
5663
|
+
na({
|
|
5662
5664
|
apiURI: this.config.apiURI,
|
|
5663
5665
|
appId: this.config.appId,
|
|
5664
5666
|
refreshToken: i
|
|
@@ -5693,14 +5695,14 @@ class Fu {
|
|
|
5693
5695
|
exchangeCodeForToken(e) {
|
|
5694
5696
|
return N(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
|
|
5695
5697
|
var i;
|
|
5696
|
-
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest",
|
|
5698
|
+
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Rr({
|
|
5697
5699
|
apiURI: this.config.apiURI,
|
|
5698
5700
|
appId: this.config.appId,
|
|
5699
5701
|
code: n,
|
|
5700
5702
|
codeVerifier: r,
|
|
5701
5703
|
refreshToken: o ? s.user.refresh_token : void 0
|
|
5702
5704
|
});
|
|
5703
|
-
return yield this.changeCurrentUser(
|
|
5705
|
+
return yield this.changeCurrentUser(u.user), u;
|
|
5704
5706
|
});
|
|
5705
5707
|
}
|
|
5706
5708
|
issuerURI() {
|
|
@@ -5716,15 +5718,15 @@ class Fu {
|
|
|
5716
5718
|
signInWithIdToken(e) {
|
|
5717
5719
|
return N(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
|
|
5718
5720
|
var s;
|
|
5719
|
-
const o = yield this.getCurrentUser(),
|
|
5721
|
+
const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield ta({
|
|
5720
5722
|
apiURI: this.config.apiURI,
|
|
5721
5723
|
appId: this.config.appId,
|
|
5722
5724
|
idToken: n,
|
|
5723
5725
|
clientName: r,
|
|
5724
5726
|
nonce: i,
|
|
5725
|
-
refreshToken:
|
|
5727
|
+
refreshToken: u
|
|
5726
5728
|
});
|
|
5727
|
-
return yield this.changeCurrentUser(
|
|
5729
|
+
return yield this.changeCurrentUser(a.user), a;
|
|
5728
5730
|
});
|
|
5729
5731
|
}
|
|
5730
5732
|
// --------
|
|
@@ -5757,7 +5759,7 @@ class Fu {
|
|
|
5757
5759
|
// TODO: look into typing again
|
|
5758
5760
|
getPresence(e, n, r = {}) {
|
|
5759
5761
|
const i = this._rooms[n], s = this._presence[n];
|
|
5760
|
-
return !i || !s || !s.result ? null : Object.assign(Object.assign({},
|
|
5762
|
+
return !i || !s || !s.result ? null : Object.assign(Object.assign({}, aa(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
|
|
5761
5763
|
}
|
|
5762
5764
|
// TODO: look into typing again
|
|
5763
5765
|
publishPresence(e, n, r) {
|
|
@@ -5795,8 +5797,8 @@ class Fu {
|
|
|
5795
5797
|
r.initialPresence || r.initialData
|
|
5796
5798
|
), o = Object.assign(Object.assign({}, r), { roomId: n, cb: i, prev: null });
|
|
5797
5799
|
return this._presence[n] = this._presence[n] || {}, this._presence[n].handlers = this._presence[n].handlers || [], this._presence[n].handlers.push(o), this._notifyPresenceSub(n, o), () => {
|
|
5798
|
-
var
|
|
5799
|
-
this._presence[n].handlers = (c = (
|
|
5800
|
+
var u, a, c;
|
|
5801
|
+
this._presence[n].handlers = (c = (a = (u = this._presence[n]) === null || u === void 0 ? void 0 : u.handlers) === null || a === void 0 ? void 0 : a.filter((d) => d !== o)) !== null && c !== void 0 ? c : [], s();
|
|
5800
5802
|
};
|
|
5801
5803
|
}
|
|
5802
5804
|
_notifyPresenceSubs(e) {
|
|
@@ -5807,14 +5809,14 @@ class Fu {
|
|
|
5807
5809
|
}
|
|
5808
5810
|
_notifyPresenceSub(e, n) {
|
|
5809
5811
|
const r = this.getPresence("", e, n);
|
|
5810
|
-
r && (n.prev && !
|
|
5812
|
+
r && (n.prev && !ca(r, n.prev) || (n.prev = r, n.cb(r)));
|
|
5811
5813
|
}
|
|
5812
5814
|
_patchPresencePeers(e, n) {
|
|
5813
5815
|
var r, i, s;
|
|
5814
5816
|
const o = ((i = (r = this._presence[e]) === null || r === void 0 ? void 0 : r.result) === null || i === void 0 ? void 0 : i.peers) || {};
|
|
5815
|
-
let
|
|
5817
|
+
let u = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
|
|
5816
5818
|
(s = this._presence[e]) === null || s === void 0 || s.result;
|
|
5817
|
-
const
|
|
5819
|
+
const a = It(u, (c) => {
|
|
5818
5820
|
for (let [d, f, l] of n)
|
|
5819
5821
|
switch (f) {
|
|
5820
5822
|
case "+":
|
|
@@ -5829,7 +5831,7 @@ class Fu {
|
|
|
5829
5831
|
}
|
|
5830
5832
|
delete c[this._sessionId];
|
|
5831
5833
|
});
|
|
5832
|
-
this._setPresencePeers(e,
|
|
5834
|
+
this._setPresencePeers(e, a);
|
|
5833
5835
|
}
|
|
5834
5836
|
_setPresencePeers(e, n) {
|
|
5835
5837
|
const r = Object.assign({}, n);
|
|
@@ -5869,10 +5871,10 @@ class Fu {
|
|
|
5869
5871
|
}
|
|
5870
5872
|
_notifyBroadcastSubs(e, n, r) {
|
|
5871
5873
|
var i, s, o;
|
|
5872
|
-
(o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((
|
|
5873
|
-
var
|
|
5874
|
-
const y = (
|
|
5875
|
-
return
|
|
5874
|
+
(o = (s = (i = this._broadcastSubs) === null || i === void 0 ? void 0 : i[e]) === null || s === void 0 ? void 0 : s[n]) === null || o === void 0 || o.forEach((u) => {
|
|
5875
|
+
var a, c, d, f, l, p;
|
|
5876
|
+
const y = (a = r.data) === null || a === void 0 ? void 0 : a.data, b = r.data["peer-id"] === this._sessionId ? (d = (c = this._presence[e]) === null || c === void 0 ? void 0 : c.result) === null || d === void 0 ? void 0 : d.user : (p = (l = (f = this._presence[e]) === null || f === void 0 ? void 0 : f.result) === null || l === void 0 ? void 0 : l.peers) === null || p === void 0 ? void 0 : p[r.data["peer-id"]];
|
|
5877
|
+
return u(y, b);
|
|
5876
5878
|
});
|
|
5877
5879
|
}
|
|
5878
5880
|
// --------
|
|
@@ -5881,14 +5883,14 @@ class Fu {
|
|
|
5881
5883
|
return N(this, void 0, void 0, function* () {
|
|
5882
5884
|
var i;
|
|
5883
5885
|
const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
|
|
5884
|
-
return
|
|
5886
|
+
return ra(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
|
|
5885
5887
|
});
|
|
5886
5888
|
}
|
|
5887
5889
|
deleteFile(e) {
|
|
5888
5890
|
return N(this, void 0, void 0, function* () {
|
|
5889
5891
|
var n;
|
|
5890
5892
|
const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
|
|
5891
|
-
return yield
|
|
5893
|
+
return yield ia({
|
|
5892
5894
|
apiURI: this.config.apiURI,
|
|
5893
5895
|
appId: this.config.appId,
|
|
5894
5896
|
path: e,
|
|
@@ -5901,20 +5903,20 @@ class Fu {
|
|
|
5901
5903
|
upload(e, n) {
|
|
5902
5904
|
return N(this, void 0, void 0, function* () {
|
|
5903
5905
|
var r;
|
|
5904
|
-
const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name,
|
|
5906
|
+
const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield sa({
|
|
5905
5907
|
apiURI: this.config.apiURI,
|
|
5906
5908
|
appId: this.config.appId,
|
|
5907
5909
|
fileName: o,
|
|
5908
5910
|
refreshToken: s
|
|
5909
5911
|
});
|
|
5910
|
-
return yield
|
|
5912
|
+
return yield oa(u, n);
|
|
5911
5913
|
});
|
|
5912
5914
|
}
|
|
5913
5915
|
getDownloadUrl(e) {
|
|
5914
5916
|
return N(this, void 0, void 0, function* () {
|
|
5915
5917
|
var n;
|
|
5916
5918
|
const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
|
|
5917
|
-
return yield
|
|
5919
|
+
return yield ua({
|
|
5918
5920
|
apiURI: this.config.apiURI,
|
|
5919
5921
|
appId: this.config.appId,
|
|
5920
5922
|
path: e,
|
|
@@ -5923,7 +5925,7 @@ class Fu {
|
|
|
5923
5925
|
});
|
|
5924
5926
|
}
|
|
5925
5927
|
}
|
|
5926
|
-
function
|
|
5928
|
+
function Na(t, e) {
|
|
5927
5929
|
return new Lt(
|
|
5928
5930
|
Hi(t, e),
|
|
5929
5931
|
// (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
|
|
@@ -5935,44 +5937,44 @@ function Nu(t, e) {
|
|
|
5935
5937
|
void 0
|
|
5936
5938
|
);
|
|
5937
5939
|
}
|
|
5938
|
-
function
|
|
5940
|
+
function Ka(t) {
|
|
5939
5941
|
return new Ut(t, {});
|
|
5940
5942
|
}
|
|
5941
|
-
function
|
|
5943
|
+
function qa() {
|
|
5942
5944
|
return new H("string", !0, !1);
|
|
5943
5945
|
}
|
|
5944
|
-
function
|
|
5946
|
+
function Wa() {
|
|
5945
5947
|
return new H("number", !0, !1);
|
|
5946
5948
|
}
|
|
5947
|
-
function
|
|
5949
|
+
function za() {
|
|
5948
5950
|
return new H("boolean", !0, !1);
|
|
5949
5951
|
}
|
|
5950
|
-
function
|
|
5952
|
+
function Va() {
|
|
5951
5953
|
return new H("date", !0, !1);
|
|
5952
5954
|
}
|
|
5953
|
-
function
|
|
5955
|
+
function Ba() {
|
|
5954
5956
|
return new H("json", !0, !1);
|
|
5955
5957
|
}
|
|
5956
|
-
function
|
|
5958
|
+
function Ga() {
|
|
5957
5959
|
return new H("json", !0, !1);
|
|
5958
5960
|
}
|
|
5959
5961
|
function Hi(t, e) {
|
|
5960
5962
|
var n, r, i, s;
|
|
5961
5963
|
const o = { fwd: {}, rev: {} };
|
|
5962
|
-
for (const
|
|
5963
|
-
(n = o.fwd)[r =
|
|
5964
|
-
entityName:
|
|
5965
|
-
cardinality:
|
|
5966
|
-
}, o.rev[
|
|
5967
|
-
entityName:
|
|
5968
|
-
cardinality:
|
|
5964
|
+
for (const a of Object.values(e))
|
|
5965
|
+
(n = o.fwd)[r = a.forward.on] || (n[r] = {}), (i = o.rev)[s = a.reverse.on] || (i[s] = {}), o.fwd[a.forward.on][a.forward.label] = {
|
|
5966
|
+
entityName: a.reverse.on,
|
|
5967
|
+
cardinality: a.forward.has
|
|
5968
|
+
}, o.rev[a.reverse.on][a.reverse.label] = {
|
|
5969
|
+
entityName: a.forward.on,
|
|
5970
|
+
cardinality: a.reverse.has
|
|
5969
5971
|
};
|
|
5970
|
-
return Object.fromEntries(Object.entries(t).map(([
|
|
5971
|
-
|
|
5972
|
-
new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[
|
|
5972
|
+
return Object.fromEntries(Object.entries(t).map(([a, c]) => [
|
|
5973
|
+
a,
|
|
5974
|
+
new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
|
|
5973
5975
|
]));
|
|
5974
5976
|
}
|
|
5975
|
-
function
|
|
5977
|
+
function Qa({ entities: t, links: e, rooms: n }) {
|
|
5976
5978
|
const r = e ?? {}, i = n ?? {};
|
|
5977
5979
|
return new Lt(
|
|
5978
5980
|
Hi(t, r),
|
|
@@ -5987,46 +5989,46 @@ function Qu({ entities: t, links: e, rooms: n }) {
|
|
|
5987
5989
|
}
|
|
5988
5990
|
const Fc = {
|
|
5989
5991
|
// constructs
|
|
5990
|
-
graph:
|
|
5991
|
-
schema:
|
|
5992
|
-
entity:
|
|
5992
|
+
graph: Na,
|
|
5993
|
+
schema: Qa,
|
|
5994
|
+
entity: Ka,
|
|
5993
5995
|
// value types
|
|
5994
|
-
string:
|
|
5995
|
-
number:
|
|
5996
|
-
boolean:
|
|
5997
|
-
date:
|
|
5998
|
-
json:
|
|
5999
|
-
any:
|
|
5996
|
+
string: qa,
|
|
5997
|
+
number: Wa,
|
|
5998
|
+
boolean: za,
|
|
5999
|
+
date: Va,
|
|
6000
|
+
json: Ba,
|
|
6001
|
+
any: Ga
|
|
6000
6002
|
};
|
|
6001
6003
|
let mt;
|
|
6002
|
-
function
|
|
6004
|
+
function Ha(t, e) {
|
|
6003
6005
|
mt == null || mt.dispose();
|
|
6004
|
-
const n = tc(e), r =
|
|
6006
|
+
const n = tc(e), r = Za(e, u), i = Ja(Ya(t));
|
|
6005
6007
|
function s(d) {
|
|
6006
6008
|
var f;
|
|
6007
|
-
d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() &&
|
|
6009
|
+
d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
|
|
6008
6010
|
}
|
|
6009
6011
|
function o(d) {
|
|
6010
6012
|
const f = d.shiftKey && d.ctrlKey && d.key === "0", l = d.key === "Escape" || d.key === "Esc";
|
|
6011
|
-
(f || l && n.isVisible()) &&
|
|
6013
|
+
(f || l && n.isVisible()) && u();
|
|
6012
6014
|
}
|
|
6013
|
-
function
|
|
6015
|
+
function u() {
|
|
6014
6016
|
n.isVisible() ? n.element.style.display = "none" : (n.element.style.display = "block", n.element.contains(i.element) || n.element.appendChild(i.element));
|
|
6015
6017
|
}
|
|
6016
|
-
function
|
|
6018
|
+
function a() {
|
|
6017
6019
|
n.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", s);
|
|
6018
6020
|
}
|
|
6019
6021
|
function c() {
|
|
6020
6022
|
document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), mt = {
|
|
6021
|
-
dispose:
|
|
6023
|
+
dispose: a
|
|
6022
6024
|
};
|
|
6023
6025
|
}
|
|
6024
6026
|
return c();
|
|
6025
6027
|
}
|
|
6026
|
-
function
|
|
6028
|
+
function Ya(t) {
|
|
6027
6029
|
return `${qn || Ni ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
6028
6030
|
}
|
|
6029
|
-
function
|
|
6031
|
+
function Ja(t) {
|
|
6030
6032
|
const e = document.createElement("iframe");
|
|
6031
6033
|
return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
6032
6034
|
width: "100%",
|
|
@@ -6035,7 +6037,7 @@ function Ju(t) {
|
|
|
6035
6037
|
border: "none"
|
|
6036
6038
|
}), { element: e };
|
|
6037
6039
|
}
|
|
6038
|
-
function
|
|
6040
|
+
function Za(t, e) {
|
|
6039
6041
|
const n = `
|
|
6040
6042
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6041
6043
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -6045,7 +6047,7 @@ function Zu(t, e) {
|
|
|
6045
6047
|
return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
|
|
6046
6048
|
// pos
|
|
6047
6049
|
position: "fixed"
|
|
6048
|
-
},
|
|
6050
|
+
}, Xa(t.position)), {
|
|
6049
6051
|
height: "32px",
|
|
6050
6052
|
width: "32px",
|
|
6051
6053
|
// layout
|
|
@@ -6060,7 +6062,7 @@ function Zu(t, e) {
|
|
|
6060
6062
|
cursor: "pointer"
|
|
6061
6063
|
})), r.addEventListener("click", e), { element: r };
|
|
6062
6064
|
}
|
|
6063
|
-
function
|
|
6065
|
+
function Xa(t) {
|
|
6064
6066
|
switch (t) {
|
|
6065
6067
|
case "bottom-left":
|
|
6066
6068
|
return { bottom: "24px", left: "24px" };
|
|
@@ -6119,10 +6121,10 @@ class oc {
|
|
|
6119
6121
|
this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
|
|
6120
6122
|
}
|
|
6121
6123
|
}
|
|
6122
|
-
function
|
|
6124
|
+
function uc(t) {
|
|
6123
6125
|
return JSON.parse(JSON.stringify(t));
|
|
6124
6126
|
}
|
|
6125
|
-
class
|
|
6127
|
+
class ac {
|
|
6126
6128
|
constructor(e) {
|
|
6127
6129
|
this.tx = Kn(), this._reactor = e, this.auth = new sc(this._reactor), this.storage = new oc(this._reactor);
|
|
6128
6130
|
}
|
|
@@ -6312,17 +6314,17 @@ function cc(t, e) {
|
|
|
6312
6314
|
}
|
|
6313
6315
|
function dc(t, e, n, r, i) {
|
|
6314
6316
|
var s;
|
|
6315
|
-
const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }),
|
|
6316
|
-
if (
|
|
6317
|
-
return cc(
|
|
6318
|
-
const
|
|
6317
|
+
const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = wn[gn(o)];
|
|
6318
|
+
if (u)
|
|
6319
|
+
return cc(u, o.schema) && u._reactor.updateSchema(o.schema), u;
|
|
6320
|
+
const a = new Fa(Object.assign(Object.assign(Object.assign({}, nc), o), { cardinalityInference: !!o.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new ac(a);
|
|
6319
6321
|
return wn[gn(o)] = c, fc(o.appId, o.devtool), c;
|
|
6320
6322
|
}
|
|
6321
6323
|
function fc(t, e) {
|
|
6322
6324
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
6323
6325
|
return;
|
|
6324
6326
|
const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
|
|
6325
|
-
n.allowedHosts.includes(window.location.hostname) &&
|
|
6327
|
+
n.allowedHosts.includes(window.location.hostname) && Ha(t, n);
|
|
6326
6328
|
}
|
|
6327
6329
|
var Tn = { exports: {} }, Qe = {};
|
|
6328
6330
|
/**
|
|
@@ -6339,12 +6341,12 @@ function lc() {
|
|
|
6339
6341
|
if (Zr) return Qe;
|
|
6340
6342
|
Zr = 1;
|
|
6341
6343
|
var t = oi, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
6342
|
-
function o(
|
|
6344
|
+
function o(u, a, c) {
|
|
6343
6345
|
var d, f = {}, l = null, p = null;
|
|
6344
|
-
c !== void 0 && (l = "" + c),
|
|
6345
|
-
for (d in
|
|
6346
|
-
if (
|
|
6347
|
-
return { $$typeof: e, type:
|
|
6346
|
+
c !== void 0 && (l = "" + c), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
|
|
6347
|
+
for (d in a) r.call(a, d) && !s.hasOwnProperty(d) && (f[d] = a[d]);
|
|
6348
|
+
if (u && u.defaultProps) for (d in a = u.defaultProps, a) f[d] === void 0 && (f[d] = a[d]);
|
|
6349
|
+
return { $$typeof: e, type: u, key: l, ref: p, props: f, _owner: i.current };
|
|
6348
6350
|
}
|
|
6349
6351
|
return Qe.Fragment = n, Qe.jsx = o, Qe.jsxs = o, Qe;
|
|
6350
6352
|
}
|
|
@@ -6363,7 +6365,7 @@ function hc() {
|
|
|
6363
6365
|
* LICENSE file in the root directory of this source tree.
|
|
6364
6366
|
*/
|
|
6365
6367
|
return t.NODE_ENV !== "production" && function() {
|
|
6366
|
-
var e = oi, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"),
|
|
6368
|
+
var e = oi, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
|
|
6367
6369
|
function T(h) {
|
|
6368
6370
|
if (h === null || typeof h != "object")
|
|
6369
6371
|
return null;
|
|
@@ -6391,7 +6393,7 @@ function hc() {
|
|
|
6391
6393
|
var S = !1, C = !1, $ = !1, D = !1, Ve = !1, ft;
|
|
6392
6394
|
ft = Symbol.for("react.module.reference");
|
|
6393
6395
|
function lt(h) {
|
|
6394
|
-
return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h === d || h === f || D || h === y || S || C || $ || typeof h == "object" && h !== null && (h.$$typeof === p || h.$$typeof === l || h.$$typeof ===
|
|
6396
|
+
return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h === d || h === f || D || h === y || S || C || $ || typeof h == "object" && h !== null && (h.$$typeof === p || h.$$typeof === l || h.$$typeof === u || h.$$typeof === a || h.$$typeof === c || // This needs to include all possible module reference object
|
|
6395
6397
|
// types supported by any Flight configuration anywhere since
|
|
6396
6398
|
// we don't know which Flight build this will end up being used
|
|
6397
6399
|
// with.
|
|
@@ -6430,10 +6432,10 @@ function hc() {
|
|
|
6430
6432
|
}
|
|
6431
6433
|
if (typeof h == "object")
|
|
6432
6434
|
switch (h.$$typeof) {
|
|
6433
|
-
case
|
|
6435
|
+
case a:
|
|
6434
6436
|
var w = h;
|
|
6435
6437
|
return ht(w) + ".Consumer";
|
|
6436
|
-
case
|
|
6438
|
+
case u:
|
|
6437
6439
|
var v = h;
|
|
6438
6440
|
return ht(v._context) + ".Provider";
|
|
6439
6441
|
case c:
|
|
@@ -6696,8 +6698,8 @@ function hc() {
|
|
|
6696
6698
|
ref: !0,
|
|
6697
6699
|
__self: !0,
|
|
6698
6700
|
__source: !0
|
|
6699
|
-
}, or,
|
|
6700
|
-
function
|
|
6701
|
+
}, or, ur;
|
|
6702
|
+
function us(h) {
|
|
6701
6703
|
if (Be.call(h, "ref")) {
|
|
6702
6704
|
var w = Object.getOwnPropertyDescriptor(h, "ref").get;
|
|
6703
6705
|
if (w && w.isReactWarning)
|
|
@@ -6705,7 +6707,7 @@ function hc() {
|
|
|
6705
6707
|
}
|
|
6706
6708
|
return h.ref !== void 0;
|
|
6707
6709
|
}
|
|
6708
|
-
function
|
|
6710
|
+
function as(h) {
|
|
6709
6711
|
if (Be.call(h, "key")) {
|
|
6710
6712
|
var w = Object.getOwnPropertyDescriptor(h, "key").get;
|
|
6711
6713
|
if (w && w.isReactWarning)
|
|
@@ -6730,7 +6732,7 @@ function hc() {
|
|
|
6730
6732
|
function fs(h, w) {
|
|
6731
6733
|
{
|
|
6732
6734
|
var v = function() {
|
|
6733
|
-
|
|
6735
|
+
ur || (ur = !0, m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", w));
|
|
6734
6736
|
};
|
|
6735
6737
|
v.isReactWarning = !0, Object.defineProperty(h, "ref", {
|
|
6736
6738
|
get: v,
|
|
@@ -6770,7 +6772,7 @@ function hc() {
|
|
|
6770
6772
|
function hs(h, w, v, E, P) {
|
|
6771
6773
|
{
|
|
6772
6774
|
var M, I = {}, k = null, G = null;
|
|
6773
|
-
v !== void 0 && (ir(v), k = "" + v),
|
|
6775
|
+
v !== void 0 && (ir(v), k = "" + v), as(w) && (ir(w.key), k = "" + w.key), us(w) && (G = w.ref, cs(w, P));
|
|
6774
6776
|
for (M in w)
|
|
6775
6777
|
Be.call(w, M) && !os.hasOwnProperty(M) && (I[M] = w[M]);
|
|
6776
6778
|
if (h && h.defaultProps) {
|
|
@@ -6785,13 +6787,13 @@ function hc() {
|
|
|
6785
6787
|
return ls(h, k, G, P, E, sr.current, I);
|
|
6786
6788
|
}
|
|
6787
6789
|
}
|
|
6788
|
-
var zt = g.ReactCurrentOwner,
|
|
6790
|
+
var zt = g.ReactCurrentOwner, ar = g.ReactDebugCurrentFrame;
|
|
6789
6791
|
function Pe(h) {
|
|
6790
6792
|
if (h) {
|
|
6791
6793
|
var w = h._owner, v = bt(h.type, h._source, w ? w.type : null);
|
|
6792
|
-
|
|
6794
|
+
ar.setExtraStackFrame(v);
|
|
6793
6795
|
} else
|
|
6794
|
-
|
|
6796
|
+
ar.setExtraStackFrame(null);
|
|
6795
6797
|
}
|
|
6796
6798
|
var Vt;
|
|
6797
6799
|
Vt = !1;
|
|
@@ -6964,8 +6966,8 @@ function ei(t) {
|
|
|
6964
6966
|
}
|
|
6965
6967
|
function bc(t, e, n) {
|
|
6966
6968
|
e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
|
|
6967
|
-
const r = e ?
|
|
6968
|
-
(
|
|
6969
|
+
const r = e ? uc(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
|
|
6970
|
+
(a) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
|
|
6969
6971
|
s.current = Object.assign({
|
|
6970
6972
|
isLoading: !d,
|
|
6971
6973
|
// @ts-expect-error: ts thinks this will always be overwritten
|
|
@@ -6974,7 +6976,7 @@ function bc(t, e, n) {
|
|
|
6974
6976
|
pageInfo: void 0,
|
|
6975
6977
|
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6976
6978
|
error: void 0
|
|
6977
|
-
}, d),
|
|
6979
|
+
}, d), a();
|
|
6978
6980
|
}) : () => {
|
|
6979
6981
|
}),
|
|
6980
6982
|
// Build a new subscribe function if the query changes
|
|
@@ -7014,9 +7016,9 @@ function Tc(t, e) {
|
|
|
7014
7016
|
}
|
|
7015
7017
|
function mc(t, e = {}) {
|
|
7016
7018
|
var n, r;
|
|
7017
|
-
const [i, s] =
|
|
7018
|
-
var
|
|
7019
|
-
return (
|
|
7019
|
+
const [i, s] = ui(() => {
|
|
7020
|
+
var a;
|
|
7021
|
+
return (a = t.core._reactor.getPresence(t.type, t.id, e)) !== null && a !== void 0 ? a : {
|
|
7020
7022
|
peers: {},
|
|
7021
7023
|
isLoading: !0
|
|
7022
7024
|
};
|
|
@@ -7024,8 +7026,8 @@ function mc(t, e = {}) {
|
|
|
7024
7026
|
ke(() => t.core._reactor.subscribePresence(t.type, t.id, e, (c) => {
|
|
7025
7027
|
s(c);
|
|
7026
7028
|
}), [t.id, e.user, (n = e.peers) === null || n === void 0 ? void 0 : n.join(), (r = e.keys) === null || r === void 0 ? void 0 : r.join()]);
|
|
7027
|
-
const o = we((
|
|
7028
|
-
t.core._reactor.publishPresence(t.type, t.id,
|
|
7029
|
+
const o = we((a) => {
|
|
7030
|
+
t.core._reactor.publishPresence(t.type, t.id, a);
|
|
7029
7031
|
}, [t.type, t.id]);
|
|
7030
7032
|
return tn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
|
|
7031
7033
|
}
|
|
@@ -7048,12 +7050,12 @@ function Sc(t, e, n = {}) {
|
|
|
7048
7050
|
[e]: null
|
|
7049
7051
|
});
|
|
7050
7052
|
}));
|
|
7051
|
-
}, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]),
|
|
7053
|
+
}, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), u = we((d) => {
|
|
7052
7054
|
const l = !((n == null ? void 0 : n.stopOnEnter) && d.key === "Enter");
|
|
7053
7055
|
o(l);
|
|
7054
|
-
}, [n.stopOnEnter, o]),
|
|
7056
|
+
}, [n.stopOnEnter, o]), a = we(() => {
|
|
7055
7057
|
o(!1);
|
|
7056
|
-
}, [o]), c = tn(() => ({ onKeyDown:
|
|
7058
|
+
}, [o]), c = tn(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
|
|
7057
7059
|
return {
|
|
7058
7060
|
active: s,
|
|
7059
7061
|
setActive: o,
|
|
@@ -7081,14 +7083,14 @@ var Ec = function(t, e, n, r) {
|
|
|
7081
7083
|
});
|
|
7082
7084
|
}
|
|
7083
7085
|
return new (n || (n = Promise))(function(s, o) {
|
|
7084
|
-
function
|
|
7086
|
+
function u(d) {
|
|
7085
7087
|
try {
|
|
7086
7088
|
c(r.next(d));
|
|
7087
7089
|
} catch (f) {
|
|
7088
7090
|
o(f);
|
|
7089
7091
|
}
|
|
7090
7092
|
}
|
|
7091
|
-
function
|
|
7093
|
+
function a(d) {
|
|
7092
7094
|
try {
|
|
7093
7095
|
c(r.throw(d));
|
|
7094
7096
|
} catch (f) {
|
|
@@ -7096,7 +7098,7 @@ var Ec = function(t, e, n, r) {
|
|
|
7096
7098
|
}
|
|
7097
7099
|
}
|
|
7098
7100
|
function c(d) {
|
|
7099
|
-
d.done ? s(d.value) : i(d.value).then(
|
|
7101
|
+
d.done ? s(d.value) : i(d.value).then(u, a);
|
|
7100
7102
|
}
|
|
7101
7103
|
c((r = r.apply(t, e || [])).next());
|
|
7102
7104
|
});
|
|
@@ -7109,16 +7111,16 @@ const Ac = {
|
|
|
7109
7111
|
class kc {
|
|
7110
7112
|
constructor(e, n) {
|
|
7111
7113
|
this.tx = Kn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
|
|
7112
|
-
const [i, s] =
|
|
7114
|
+
const [i, s] = ui(null);
|
|
7113
7115
|
return ke(() => {
|
|
7114
7116
|
Ec(this, void 0, void 0, function* () {
|
|
7115
|
-
const
|
|
7116
|
-
s(
|
|
7117
|
+
const u = yield this.getLocalId(r);
|
|
7118
|
+
s(u);
|
|
7117
7119
|
});
|
|
7118
7120
|
}, [r]), i;
|
|
7119
7121
|
}, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => bc(this.core, r, i).state, this.useAuth = () => {
|
|
7120
|
-
const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((
|
|
7121
|
-
r.current = Object.assign({ isLoading: !1 },
|
|
7122
|
+
const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((a) => {
|
|
7123
|
+
r.current = Object.assign({ isLoading: !1 }, a), o();
|
|
7122
7124
|
}), []);
|
|
7123
7125
|
return en(i, () => r.current, () => Ac);
|
|
7124
7126
|
}, this.useUser = () => {
|
|
@@ -7127,8 +7129,8 @@ class kc {
|
|
|
7127
7129
|
throw new qe("useUser must be used within an auth-protected route");
|
|
7128
7130
|
return r;
|
|
7129
7131
|
}, this.useConnectionStatus = () => {
|
|
7130
|
-
const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((
|
|
7131
|
-
|
|
7132
|
+
const r = ot(this.core._reactor.status), i = we((o) => this.core.subscribeConnectionStatus((a) => {
|
|
7133
|
+
a !== r.current && (r.current = a, o());
|
|
7132
7134
|
}), []);
|
|
7133
7135
|
return en(
|
|
7134
7136
|
i,
|
|
@@ -7195,7 +7197,7 @@ function jc(t) {
|
|
|
7195
7197
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
7196
7198
|
);
|
|
7197
7199
|
const { onEvent: e = Xt, onError: n = Xt, onRetry: r = Xt, onComment: i } = t;
|
|
7198
|
-
let s = "", o = !0,
|
|
7200
|
+
let s = "", o = !0, u, a = "", c = "";
|
|
7199
7201
|
function d(b) {
|
|
7200
7202
|
const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Cc(`${s}${_}`);
|
|
7201
7203
|
for (const m of T)
|
|
@@ -7225,11 +7227,11 @@ function jc(t) {
|
|
|
7225
7227
|
c = _;
|
|
7226
7228
|
break;
|
|
7227
7229
|
case "data":
|
|
7228
|
-
|
|
7230
|
+
a = `${a}${_}
|
|
7229
7231
|
`;
|
|
7230
7232
|
break;
|
|
7231
7233
|
case "id":
|
|
7232
|
-
|
|
7234
|
+
u = _.includes("\0") ? void 0 : _;
|
|
7233
7235
|
break;
|
|
7234
7236
|
case "retry":
|
|
7235
7237
|
/^\d+$/.test(_) ? r(parseInt(_, 10)) : n(
|
|
@@ -7251,17 +7253,17 @@ function jc(t) {
|
|
|
7251
7253
|
}
|
|
7252
7254
|
}
|
|
7253
7255
|
function p() {
|
|
7254
|
-
|
|
7255
|
-
id:
|
|
7256
|
+
a.length > 0 && e({
|
|
7257
|
+
id: u,
|
|
7256
7258
|
event: c || void 0,
|
|
7257
7259
|
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
7258
7260
|
// then remove the last character from the data buffer.
|
|
7259
|
-
data:
|
|
7260
|
-
`) ?
|
|
7261
|
-
}),
|
|
7261
|
+
data: a.endsWith(`
|
|
7262
|
+
`) ? a.slice(0, -1) : a
|
|
7263
|
+
}), u = void 0, a = "", c = "";
|
|
7262
7264
|
}
|
|
7263
7265
|
function y(b = {}) {
|
|
7264
|
-
s && b.consume && f(s), o = !0,
|
|
7266
|
+
s && b.consume && f(s), o = !0, u = void 0, a = "", c = "", s = "";
|
|
7265
7267
|
}
|
|
7266
7268
|
return { feed: d, reset: y };
|
|
7267
7269
|
}
|
|
@@ -7276,8 +7278,8 @@ function Cc(t) {
|
|
|
7276
7278
|
n = t.slice(r);
|
|
7277
7279
|
break;
|
|
7278
7280
|
} else {
|
|
7279
|
-
const
|
|
7280
|
-
e.push(
|
|
7281
|
+
const u = t.slice(r, o);
|
|
7282
|
+
e.push(u), r = o + 1, t[r - 1] === "\r" && t[r] === `
|
|
7281
7283
|
` && r++;
|
|
7282
7284
|
}
|
|
7283
7285
|
}
|
|
@@ -7351,12 +7353,12 @@ class kt extends EventTarget {
|
|
|
7351
7353
|
super(), q(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, q(this, J), q(this, Oe), q(this, xe), q(this, At), q(this, Rt), q(this, it), q(this, Ue), q(this, st, null), q(this, ge), q(this, $e), q(this, Fe, null), q(this, De, null), q(this, Xe, null), q(this, Sn, async (s) => {
|
|
7352
7354
|
var o;
|
|
7353
7355
|
A(this, $e).reset();
|
|
7354
|
-
const { body:
|
|
7356
|
+
const { body: u, redirected: a, status: c, headers: d } = s;
|
|
7355
7357
|
if (c === 204) {
|
|
7356
7358
|
pe(this, se, et).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
7357
7359
|
return;
|
|
7358
7360
|
}
|
|
7359
|
-
if (
|
|
7361
|
+
if (a ? x(this, xe, new URL(s.url)) : x(this, xe, void 0), c !== 200) {
|
|
7360
7362
|
pe(this, se, et).call(this, `Non-200 status code (${c})`, c);
|
|
7361
7363
|
return;
|
|
7362
7364
|
}
|
|
@@ -7368,11 +7370,11 @@ class kt extends EventTarget {
|
|
|
7368
7370
|
return;
|
|
7369
7371
|
x(this, J, this.OPEN);
|
|
7370
7372
|
const f = new Event("open");
|
|
7371
|
-
if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof
|
|
7373
|
+
if ((o = A(this, Xe)) == null || o.call(this, f), this.dispatchEvent(f), typeof u != "object" || !u || !("getReader" in u)) {
|
|
7372
7374
|
pe(this, se, et).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
|
|
7373
7375
|
return;
|
|
7374
7376
|
}
|
|
7375
|
-
const l = new TextDecoder(), p =
|
|
7377
|
+
const l = new TextDecoder(), p = u.getReader();
|
|
7376
7378
|
let y = !0;
|
|
7377
7379
|
do {
|
|
7378
7380
|
const { done: b, value: _ } = await p.read();
|
|
@@ -7572,8 +7574,8 @@ function Kc({
|
|
|
7572
7574
|
style: i,
|
|
7573
7575
|
userCursorColor: s,
|
|
7574
7576
|
children: o,
|
|
7575
|
-
renderCursor:
|
|
7576
|
-
propagate:
|
|
7577
|
+
renderCursor: u,
|
|
7578
|
+
propagate: a,
|
|
7577
7579
|
zIndex: c
|
|
7578
7580
|
}) {
|
|
7579
7581
|
const d = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
|
|
@@ -7592,7 +7594,7 @@ function Kc({
|
|
|
7592
7594
|
});
|
|
7593
7595
|
}
|
|
7594
7596
|
function y(g) {
|
|
7595
|
-
|
|
7597
|
+
a || g.stopPropagation();
|
|
7596
7598
|
const m = g.currentTarget.getBoundingClientRect();
|
|
7597
7599
|
p(m, g);
|
|
7598
7600
|
}
|
|
@@ -7606,7 +7608,7 @@ function Kc({
|
|
|
7606
7608
|
return;
|
|
7607
7609
|
const m = g.touches[0];
|
|
7608
7610
|
if (m.target instanceof Element) {
|
|
7609
|
-
|
|
7611
|
+
a || g.stopPropagation();
|
|
7610
7612
|
const O = m.target.getBoundingClientRect();
|
|
7611
7613
|
p(O, m);
|
|
7612
7614
|
}
|
|
@@ -7650,7 +7652,7 @@ function Kc({
|
|
|
7650
7652
|
transformOrigin: "0 0",
|
|
7651
7653
|
transition: "transform 100ms"
|
|
7652
7654
|
},
|
|
7653
|
-
children:
|
|
7655
|
+
children: u ? u({
|
|
7654
7656
|
color: O.color,
|
|
7655
7657
|
presence: l == null ? void 0 : l.peers[g]
|
|
7656
7658
|
}) : /* @__PURE__ */ V.jsx(Rc, { ...O })
|