@instantdb/react 0.22.83 → 0.22.84
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 +526 -522
- package/dist/standalone/index.umd.cjs +11 -11
- package/package.json +4 -4
package/dist/standalone/index.js
CHANGED
|
@@ -242,11 +242,11 @@ function Me(t, e, n, r, i) {
|
|
|
242
242
|
if (r.length > 0) {
|
|
243
243
|
const a = r.indexOf(o);
|
|
244
244
|
if (o && typeof o == "object" && a !== -1)
|
|
245
|
-
throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, a).map((u,
|
|
245
|
+
throw r[0] === o ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${i.slice(0, a).map((u, c) => {
|
|
246
246
|
if (typeof u == "symbol")
|
|
247
247
|
return `[${u.toString()}]`;
|
|
248
|
-
const
|
|
249
|
-
return typeof u == "object" && (
|
|
248
|
+
const d = r[c];
|
|
249
|
+
return typeof u == "object" && (d instanceof Map || d instanceof Set) ? Array.from(d.keys()).indexOf(u) : u;
|
|
250
250
|
}).join("/")}`);
|
|
251
251
|
r.push(o), i.push(e);
|
|
252
252
|
} else
|
|
@@ -303,8 +303,8 @@ function pi(t, e, n) {
|
|
|
303
303
|
if (ke(o)) {
|
|
304
304
|
const u = k(o);
|
|
305
305
|
Q(u);
|
|
306
|
-
const
|
|
307
|
-
ct(r ? i : t, s,
|
|
306
|
+
const c = !((a = u.assignedMap) === null || a === void 0) && a.size || u.operated ? u.copy : u.original;
|
|
307
|
+
ct(r ? i : t, s, c);
|
|
308
308
|
} else
|
|
309
309
|
pi(o, e, n);
|
|
310
310
|
}), i) {
|
|
@@ -338,8 +338,8 @@ function Un(t, e, n, r) {
|
|
|
338
338
|
var a;
|
|
339
339
|
const u = t.type === 3 ? t.setMap : t.copy;
|
|
340
340
|
if (ye(be(u, e), n)) {
|
|
341
|
-
let
|
|
342
|
-
i.copy && (
|
|
341
|
+
let c = i.original;
|
|
342
|
+
i.copy && (c = i.copy), sn(t), on(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(c, i.original)), ct(u, e, c);
|
|
343
343
|
}
|
|
344
344
|
}), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ae(n, t.options) && t.finalities.draft.push(() => {
|
|
345
345
|
const s = t.type === 3 ? t.setMap : t.copy;
|
|
@@ -349,42 +349,42 @@ function Un(t, e, n, r) {
|
|
|
349
349
|
function Rs(t, e, n, r, i) {
|
|
350
350
|
let { original: s, assignedMap: o, options: a } = t, u = t.copy;
|
|
351
351
|
u.length < s.length && ([s, u] = [u, s], [n, r] = [r, n]);
|
|
352
|
-
for (let
|
|
353
|
-
if (o.get(
|
|
354
|
-
const
|
|
352
|
+
for (let c = 0; c < s.length; c += 1)
|
|
353
|
+
if (o.get(c.toString()) && u[c] !== s[c]) {
|
|
354
|
+
const d = e.concat([c]), f = Ee(d, i);
|
|
355
355
|
n.push({
|
|
356
356
|
op: U.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(u[
|
|
359
|
+
value: St(u[c])
|
|
360
360
|
}), r.push({
|
|
361
361
|
op: U.Replace,
|
|
362
362
|
path: f,
|
|
363
363
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
364
|
-
value: St(s[
|
|
364
|
+
value: St(s[c])
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
|
-
for (let
|
|
368
|
-
const
|
|
367
|
+
for (let c = s.length; c < u.length; c += 1) {
|
|
368
|
+
const d = e.concat([c]), f = Ee(d, i);
|
|
369
369
|
n.push({
|
|
370
370
|
op: U.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(u[
|
|
373
|
+
value: St(u[c])
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
if (s.length < u.length) {
|
|
377
|
-
const { arrayLengthAssignment:
|
|
378
|
-
if (
|
|
379
|
-
const
|
|
377
|
+
const { arrayLengthAssignment: c = !0 } = a.enablePatches;
|
|
378
|
+
if (c) {
|
|
379
|
+
const d = e.concat(["length"]), f = Ee(d, i);
|
|
380
380
|
r.push({
|
|
381
381
|
op: U.Replace,
|
|
382
382
|
path: f,
|
|
383
383
|
value: s.length
|
|
384
384
|
});
|
|
385
385
|
} else
|
|
386
|
-
for (let
|
|
387
|
-
const f = e.concat([
|
|
386
|
+
for (let d = u.length; s.length < d; d -= 1) {
|
|
387
|
+
const f = e.concat([d - 1]), l = Ee(f, i);
|
|
388
388
|
r.push({
|
|
389
389
|
op: U.Remove,
|
|
390
390
|
path: l
|
|
@@ -394,39 +394,39 @@ function Rs(t, e, n, r, i) {
|
|
|
394
394
|
}
|
|
395
395
|
function xs({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
|
|
396
396
|
n.forEach((a, u) => {
|
|
397
|
-
const
|
|
398
|
-
if (ye(
|
|
397
|
+
const c = be(t, u), d = St(be(e, u)), f = a ? nt(t, u) ? U.Replace : U.Add : U.Remove;
|
|
398
|
+
if (ye(c, d) && f === U.Replace)
|
|
399
399
|
return;
|
|
400
400
|
const l = r.concat(u), p = Ee(l, o);
|
|
401
|
-
i.push(f === U.Remove ? { op: f, path: p } : { op: f, path: p, value:
|
|
401
|
+
i.push(f === U.Remove ? { op: f, path: p } : { op: f, path: p, value: d }), s.push(f === U.Add ? { op: U.Remove, path: p } : f === U.Remove ? { op: U.Add, path: p, value: c } : { op: U.Replace, path: p, value: c });
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
function $s({ original: t, copy: e }, n, r, i, s) {
|
|
405
405
|
let o = 0;
|
|
406
406
|
t.forEach((a) => {
|
|
407
407
|
if (!e.has(a)) {
|
|
408
|
-
const u = n.concat([o]),
|
|
408
|
+
const u = n.concat([o]), c = Ee(u, s);
|
|
409
409
|
r.push({
|
|
410
410
|
op: U.Remove,
|
|
411
|
-
path:
|
|
411
|
+
path: c,
|
|
412
412
|
value: a
|
|
413
413
|
}), i.unshift({
|
|
414
414
|
op: U.Add,
|
|
415
|
-
path:
|
|
415
|
+
path: c,
|
|
416
416
|
value: a
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
o += 1;
|
|
420
420
|
}), o = 0, e.forEach((a) => {
|
|
421
421
|
if (!t.has(a)) {
|
|
422
|
-
const u = n.concat([o]),
|
|
422
|
+
const u = n.concat([o]), c = Ee(u, s);
|
|
423
423
|
r.push({
|
|
424
424
|
op: U.Add,
|
|
425
|
-
path:
|
|
425
|
+
path: c,
|
|
426
426
|
value: a
|
|
427
427
|
}), i.unshift({
|
|
428
428
|
op: U.Remove,
|
|
429
|
-
path:
|
|
429
|
+
path: c,
|
|
430
430
|
value: a
|
|
431
431
|
});
|
|
432
432
|
}
|
|
@@ -536,16 +536,16 @@ const kt = (t, e, n = !1) => {
|
|
|
536
536
|
return s;
|
|
537
537
|
const o = s.value;
|
|
538
538
|
let a = t.setMap.get(o);
|
|
539
|
-
const u = k(a),
|
|
540
|
-
if (t.options.strict && kt(o, t.options,
|
|
541
|
-
const
|
|
539
|
+
const u = k(a), c = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, a, ne)) === ne.mutable;
|
|
540
|
+
if (t.options.strict && kt(o, t.options, c), !c && !u && ae(o, t.options) && !t.finalized && t.original.has(o)) {
|
|
541
|
+
const d = Mn.createDraft({
|
|
542
542
|
original: o,
|
|
543
543
|
parentDraft: t,
|
|
544
544
|
key: o,
|
|
545
545
|
finalities: t.finalities,
|
|
546
546
|
options: t.options
|
|
547
547
|
});
|
|
548
|
-
t.setMap.set(o,
|
|
548
|
+
t.setMap.set(o, d), a = d;
|
|
549
549
|
} else u && (a = u.proxy);
|
|
550
550
|
return {
|
|
551
551
|
done: !1,
|
|
@@ -650,30 +650,30 @@ const Us = Reflect.ownKeys(Ct), yi = /* @__PURE__ */ new WeakSet(), bi = {
|
|
|
650
650
|
return t;
|
|
651
651
|
let o;
|
|
652
652
|
if (t.options.mark) {
|
|
653
|
-
const
|
|
654
|
-
if (o = t.options.mark(
|
|
655
|
-
return t.options.strict && kt(
|
|
653
|
+
const c = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
|
|
654
|
+
if (o = t.options.mark(c, ne), o === ne.mutable)
|
|
655
|
+
return t.options.strict && kt(c, t.options, !0), c;
|
|
656
656
|
}
|
|
657
657
|
const a = te(t);
|
|
658
658
|
if (a instanceof Map && Ds.includes(e)) {
|
|
659
659
|
if (e === "size")
|
|
660
660
|
return Object.getOwnPropertyDescriptor(an, "size").get.call(t.proxy);
|
|
661
|
-
const
|
|
662
|
-
if (
|
|
663
|
-
return
|
|
661
|
+
const c = an[e];
|
|
662
|
+
if (c)
|
|
663
|
+
return c.bind(t.proxy);
|
|
664
664
|
}
|
|
665
665
|
if (a instanceof Set && Us.includes(e)) {
|
|
666
666
|
if (e === "size")
|
|
667
667
|
return Object.getOwnPropertyDescriptor(Ct, "size").get.call(t.proxy);
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
return
|
|
668
|
+
const c = Ct[e];
|
|
669
|
+
if (c)
|
|
670
|
+
return c.bind(t.proxy);
|
|
671
671
|
}
|
|
672
672
|
if (!nt(a, e)) {
|
|
673
|
-
const
|
|
674
|
-
return
|
|
673
|
+
const c = gr(a, e);
|
|
674
|
+
return c ? "value" in c ? c.value : (
|
|
675
675
|
// !case: support for getter
|
|
676
|
-
(i =
|
|
676
|
+
(i = c.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
|
|
677
677
|
) : void 0;
|
|
678
678
|
}
|
|
679
679
|
const u = a[e];
|
|
@@ -687,8 +687,8 @@ const Us = Reflect.ownKeys(Ct), yi = /* @__PURE__ */ new WeakSet(), bi = {
|
|
|
687
687
|
finalities: t.finalities,
|
|
688
688
|
options: t.options
|
|
689
689
|
}), typeof o == "function") {
|
|
690
|
-
const
|
|
691
|
-
return Q(
|
|
690
|
+
const c = k(t.copy[e]);
|
|
691
|
+
return Q(c), fe(c), c.copy;
|
|
692
692
|
}
|
|
693
693
|
return t.copy[e];
|
|
694
694
|
}
|
|
@@ -750,26 +750,26 @@ function Ln(t) {
|
|
|
750
750
|
setMap: o === 3 ? new Map(e.entries()) : void 0
|
|
751
751
|
};
|
|
752
752
|
(r || "key" in t) && (a.key = r);
|
|
753
|
-
const { proxy: u, revoke:
|
|
754
|
-
if (i.revoke.push(
|
|
755
|
-
const
|
|
756
|
-
|
|
753
|
+
const { proxy: u, revoke: c } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, bi);
|
|
754
|
+
if (i.revoke.push(c), yi.add(u), a.proxy = u, n) {
|
|
755
|
+
const d = n;
|
|
756
|
+
d.finalities.draft.push((f, l) => {
|
|
757
757
|
var p, y;
|
|
758
758
|
const b = k(u);
|
|
759
|
-
let _ =
|
|
759
|
+
let _ = d.type === 3 ? d.setMap : d.copy;
|
|
760
760
|
const w = be(_, r), g = k(w);
|
|
761
761
|
if (g) {
|
|
762
762
|
let m = g.original;
|
|
763
|
-
g.operated && (m = $n(w)), sn(g), on(g, ut, f, l),
|
|
763
|
+
g.operated && (m = $n(w)), sn(g), on(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)), ct(_, 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
|
|
771
|
-
|
|
772
|
-
sn(
|
|
770
|
+
const d = k(u);
|
|
771
|
+
d.finalities.draft.push((f, l) => {
|
|
772
|
+
sn(d), on(d, ut, f, l);
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
return u;
|
|
@@ -781,9 +781,9 @@ function Ls(t, e, n, r, i) {
|
|
|
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
|
|
785
|
-
return o && rn(o), i && Me(
|
|
786
|
-
|
|
784
|
+
const c = u ? e[0] : o ? o.operated ? o.copy : o.original : t;
|
|
785
|
+
return o && rn(o), i && Me(c, c, o == null ? void 0 : o.options.updatedValues), [
|
|
786
|
+
c,
|
|
787
787
|
n && u ? [{ op: U.Replace, path: [], value: e[0] }] : n,
|
|
788
788
|
r && u ? [{ op: U.Replace, path: [], value: a }] : r
|
|
789
789
|
];
|
|
@@ -806,8 +806,8 @@ function Fs(t, e) {
|
|
|
806
806
|
return [
|
|
807
807
|
a,
|
|
808
808
|
(u = []) => {
|
|
809
|
-
const [
|
|
810
|
-
return e.enablePatches ? [
|
|
809
|
+
const [c, d, f] = Ls(a, u, i, s, e.enableAutoFreeze);
|
|
810
|
+
return e.enablePatches ? [c, d, f] : c;
|
|
811
811
|
}
|
|
812
812
|
];
|
|
813
813
|
}
|
|
@@ -817,12 +817,12 @@ function un(t) {
|
|
|
817
817
|
const u = k(o);
|
|
818
818
|
if (u && e && u.finalities === e.finalities) {
|
|
819
819
|
t.isContainDraft = !0;
|
|
820
|
-
const
|
|
820
|
+
const c = u.original;
|
|
821
821
|
if (a instanceof Set) {
|
|
822
|
-
const
|
|
823
|
-
a.clear(),
|
|
822
|
+
const d = Array.from(a);
|
|
823
|
+
a.clear(), d.forEach((f) => a.add(s === f ? c : f));
|
|
824
824
|
} else
|
|
825
|
-
ct(a, s,
|
|
825
|
+
ct(a, s, c);
|
|
826
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
|
}
|
|
@@ -869,21 +869,21 @@ const Ns = (t) => function e(n, r, i) {
|
|
|
869
869
|
return function(S, ...I) {
|
|
870
870
|
return e(S, (x) => n.call(this, x, ...I), r);
|
|
871
871
|
};
|
|
872
|
-
const u = n,
|
|
873
|
-
let
|
|
874
|
-
if (typeof r != "function" && (
|
|
875
|
-
throw new Error(`Invalid options: ${
|
|
876
|
-
|
|
877
|
-
const f = ke(u) ? mr(u) : u, l = Array.isArray(
|
|
878
|
-
for (const x of
|
|
872
|
+
const u = n, c = r;
|
|
873
|
+
let d = i;
|
|
874
|
+
if (typeof r != "function" && (d = r), d !== void 0 && Object.prototype.toString.call(d) !== "[object Object]")
|
|
875
|
+
throw new Error(`Invalid options: ${d}, 'options' should be an object.`);
|
|
876
|
+
d = Object.assign(Object.assign({}, t), d);
|
|
877
|
+
const f = ke(u) ? mr(u) : u, l = Array.isArray(d.mark) ? (S, I) => {
|
|
878
|
+
for (const x of d.mark) {
|
|
879
879
|
if (typeof x != "function")
|
|
880
880
|
throw new Error(`Invalid mark: ${x}, 'mark' should be a function.`);
|
|
881
881
|
const B = x(S, I);
|
|
882
882
|
if (B)
|
|
883
883
|
return B;
|
|
884
884
|
}
|
|
885
|
-
} :
|
|
886
|
-
enableAutoFreeze: (a =
|
|
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: (a = d.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
|
|
887
887
|
mark: l,
|
|
888
888
|
strict: y,
|
|
889
889
|
enablePatches: p
|
|
@@ -898,7 +898,7 @@ const Ns = (t) => function e(n, r, i) {
|
|
|
898
898
|
}
|
|
899
899
|
let m;
|
|
900
900
|
try {
|
|
901
|
-
m =
|
|
901
|
+
m = c(w);
|
|
902
902
|
} catch (S) {
|
|
903
903
|
throw rn(k(w)), S;
|
|
904
904
|
}
|
|
@@ -1246,8 +1246,8 @@ function Zs(t) {
|
|
|
1246
1246
|
function Xs(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, a] = n, u = i.padStart(2, "0"),
|
|
1250
|
-
return new Date(
|
|
1249
|
+
const [, r, i, s, o, a] = n, u = i.padStart(2, "0"), c = s.padStart(2, "0"), d = `${r}-${u}-${c}T${a}`;
|
|
1250
|
+
return new Date(d);
|
|
1251
1251
|
}
|
|
1252
1252
|
return null;
|
|
1253
1253
|
}
|
|
@@ -1255,8 +1255,8 @@ function eo(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 [, a, u,
|
|
1259
|
-
return a = Number(a), u = Number(u),
|
|
1258
|
+
let [, a, u, c, d] = o;
|
|
1259
|
+
return a = Number(a), u = Number(u), c = Number(c), d === "PM" && a !== 12 ? a += 12 : d === "AM" && a === 12 && (a = 0), new Date(Date.UTC(s, r - 1, i, a, u, c));
|
|
1260
1260
|
}
|
|
1261
1261
|
function to(t) {
|
|
1262
1262
|
switch (t) {
|
|
@@ -1370,22 +1370,22 @@ function Z(t, e, n) {
|
|
|
1370
1370
|
function mi(t, e, n) {
|
|
1371
1371
|
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1372
1372
|
for (const o of e) {
|
|
1373
|
-
let [a, u,
|
|
1373
|
+
let [a, u, c, d] = o;
|
|
1374
1374
|
const f = qe(t, u);
|
|
1375
1375
|
if (!f) {
|
|
1376
1376
|
console.warn("no such attr", a, t);
|
|
1377
1377
|
continue;
|
|
1378
1378
|
}
|
|
1379
|
-
f["checked-data-type"] === "date" && n && (
|
|
1379
|
+
f["checked-data-type"] === "date" && n && (c = xt(c), o[2] = c), Nn(f) && Z(s, [c, u, a], o), Z(r, [a, u, c], o), Z(i, [u, a, c], o);
|
|
1380
1380
|
}
|
|
1381
1381
|
return { eav: r, aev: i, vae: s };
|
|
1382
1382
|
}
|
|
1383
1383
|
function vi(t) {
|
|
1384
1384
|
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
1385
1385
|
for (const s of Object.values(t)) {
|
|
1386
|
-
const o = s["forward-identity"], [a, u,
|
|
1387
|
-
if (Z(r, [u,
|
|
1388
|
-
const [f, l, p] =
|
|
1386
|
+
const o = s["forward-identity"], [a, u, c] = o, d = s["reverse-identity"];
|
|
1387
|
+
if (Z(r, [u, c], s), Kn(s) && Z(e, [u, c], s), s["primary?"] && Z(n, [u], s), d) {
|
|
1388
|
+
const [f, l, p] = d;
|
|
1389
1389
|
Z(i, [l, p], s);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
@@ -1421,7 +1421,7 @@ function dt(t, e) {
|
|
|
1421
1421
|
const [o, a] = e[0], u = t.aev.get(o);
|
|
1422
1422
|
if (!u)
|
|
1423
1423
|
return null;
|
|
1424
|
-
i = (n = X(u, 2).find((
|
|
1424
|
+
i = (n = X(u, 2).find((d) => d[2] === a)) === null || n === void 0 ? void 0 : n[0];
|
|
1425
1425
|
} else
|
|
1426
1426
|
i = e[0];
|
|
1427
1427
|
if (!i)
|
|
@@ -1431,11 +1431,11 @@ function dt(t, e) {
|
|
|
1431
1431
|
const [o, a] = s, u = t.aev.get(o);
|
|
1432
1432
|
if (!u)
|
|
1433
1433
|
return null;
|
|
1434
|
-
const
|
|
1435
|
-
if (!
|
|
1434
|
+
const d = (r = X(u, 2).find((b) => b[2] === a)) === null || r === void 0 ? void 0 : r[0];
|
|
1435
|
+
if (!d)
|
|
1436
1436
|
return null;
|
|
1437
1437
|
const [f, l, p, ...y] = e;
|
|
1438
|
-
return [i, l,
|
|
1438
|
+
return [i, l, d, ...y];
|
|
1439
1439
|
} else {
|
|
1440
1440
|
const [o, ...a] = e;
|
|
1441
1441
|
return [i, ...a];
|
|
@@ -1452,7 +1452,7 @@ let uo = 0;
|
|
|
1452
1452
|
function Ai(t, e, n) {
|
|
1453
1453
|
const [r, i, s] = n;
|
|
1454
1454
|
let o;
|
|
1455
|
-
const a = We(t.
|
|
1455
|
+
const a = We(t.eav, [r, i, s]);
|
|
1456
1456
|
return a && (o = a[3]), o || Date.now() * 10 + uo++;
|
|
1457
1457
|
}
|
|
1458
1458
|
function ji(t, e) {
|
|
@@ -1465,8 +1465,8 @@ function ji(t, e) {
|
|
|
1465
1465
|
if (!a)
|
|
1466
1466
|
return;
|
|
1467
1467
|
a["checked-data-type"] === "date" && t.useDateObjects && (o = xt(o));
|
|
1468
|
-
const u = We(t.eav, [i, s, o]),
|
|
1469
|
-
oo(a) ? (Z(t.eav, [i, s], /* @__PURE__ */ new Map([[o,
|
|
1468
|
+
const u = We(t.eav, [i, s, o]), c = (n = u == null ? void 0 : u[3]) !== null && n !== void 0 ? n : Ai(t, a, r), d = [i, s, o, c];
|
|
1469
|
+
oo(a) ? (Z(t.eav, [i, s], /* @__PURE__ */ new Map([[o, d]])), Z(t.aev, [s, i], /* @__PURE__ */ new Map([[o, d]]))) : (Z(t.eav, [i, s, o], d), Z(t.aev, [s, i, o], d)), Nn(a) && Z(t.vae, [o, s, i], d);
|
|
1470
1470
|
}
|
|
1471
1471
|
function co(t, e) {
|
|
1472
1472
|
var n;
|
|
@@ -1481,14 +1481,14 @@ function co(t, e) {
|
|
|
1481
1481
|
const u = We(t.eav, [i, s]);
|
|
1482
1482
|
if (!u)
|
|
1483
1483
|
return;
|
|
1484
|
-
const
|
|
1485
|
-
if (!
|
|
1484
|
+
const c = (n = u.values().next()) === null || n === void 0 ? void 0 : n.value;
|
|
1485
|
+
if (!c)
|
|
1486
1486
|
return;
|
|
1487
|
-
const
|
|
1487
|
+
const d = c[2], f = Ti(d, o), l = [
|
|
1488
1488
|
i,
|
|
1489
1489
|
s,
|
|
1490
1490
|
f,
|
|
1491
|
-
Ai(t, a,
|
|
1491
|
+
Ai(t, a, c)
|
|
1492
1492
|
];
|
|
1493
1493
|
Z(t.eav, [i, s], /* @__PURE__ */ new Map([[f, l]]));
|
|
1494
1494
|
}
|
|
@@ -1499,23 +1499,23 @@ function dn(t, e) {
|
|
|
1499
1499
|
return;
|
|
1500
1500
|
const [a] = o, u = t.eav.get(a);
|
|
1501
1501
|
if (u) {
|
|
1502
|
-
for (const
|
|
1503
|
-
const f = t.attrs[
|
|
1504
|
-
f && f["on-delete-reverse"] === "cascade" && X(u.get(
|
|
1502
|
+
for (const d of u.keys()) {
|
|
1503
|
+
const f = t.attrs[d];
|
|
1504
|
+
f && f["on-delete-reverse"] === "cascade" && X(u.get(d), 1).forEach(([l, p, y]) => {
|
|
1505
1505
|
var b;
|
|
1506
1506
|
return dn(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
|
|
1507
1507
|
}), // Fall back to deleting everything if we've rehydrated tx-steps from
|
|
1508
1508
|
// the store that didn't set `etype` in deleteEntity
|
|
1509
1509
|
(!s || // If we don't know about the attr, let's just get rid of it
|
|
1510
1510
|
!f || // Make sure it matches the etype
|
|
1511
|
-
((n = f["forward-identity"]) === null || n === void 0 ? void 0 : n[1]) === s) && (oe(t.aev, [
|
|
1511
|
+
((n = f["forward-identity"]) === null || n === void 0 ? void 0 : n[1]) === s) && (oe(t.aev, [d, a]), oe(t.eav, [a, d]));
|
|
1512
1512
|
}
|
|
1513
1513
|
u.size === 0 && oe(t.eav, [a]);
|
|
1514
1514
|
}
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1515
|
+
const c = t.vae.get(a) && X(t.vae.get(a), 2);
|
|
1516
|
+
c && c.forEach((d) => {
|
|
1517
1517
|
var f, l, p;
|
|
1518
|
-
const [y, b, _] =
|
|
1518
|
+
const [y, b, _] = d, w = t.attrs[b];
|
|
1519
1519
|
(!s || !w || ((f = w["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (oe(t.eav, [y, b, _]), oe(t.aev, [b, y, _]), oe(t.vae, [_, b, y])), w && w["on-delete"] === "cascade" && ((l = w["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && dn(t, [y, (p = w["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
|
|
1520
1520
|
}), ((r = t.vae.get(a)) === null || r === void 0 ? void 0 : r.size) === 0 && oe(t.vae, [a]);
|
|
1521
1521
|
}
|
|
@@ -1586,37 +1586,37 @@ function X(t, e, n = []) {
|
|
|
1586
1586
|
return n;
|
|
1587
1587
|
}
|
|
1588
1588
|
function gt(t, e, n) {
|
|
1589
|
-
var r
|
|
1590
|
-
const
|
|
1589
|
+
var r;
|
|
1590
|
+
const i = [];
|
|
1591
1591
|
if (n != null && n.hasOwnProperty("$not")) {
|
|
1592
|
-
for (const
|
|
1593
|
-
n.$not !==
|
|
1594
|
-
return
|
|
1592
|
+
for (const o of e.keys())
|
|
1593
|
+
n.$not !== o && i.push(e.get(o));
|
|
1594
|
+
return i;
|
|
1595
1595
|
}
|
|
1596
1596
|
if (n != null && n.hasOwnProperty("$isNull")) {
|
|
1597
|
-
const { attrId:
|
|
1598
|
-
if (
|
|
1597
|
+
const { attrId: o, isNull: a, reverse: u } = n.$isNull;
|
|
1598
|
+
if (u)
|
|
1599
1599
|
for (const c of e.keys()) {
|
|
1600
|
-
const
|
|
1601
|
-
(
|
|
1600
|
+
const d = t.vae.get(c), f = !d || !d.get(o);
|
|
1601
|
+
(a ? f : !f) && i.push(e.get(c));
|
|
1602
1602
|
}
|
|
1603
1603
|
else {
|
|
1604
|
-
const c = t.aev.get(
|
|
1605
|
-
for (const
|
|
1606
|
-
const
|
|
1607
|
-
(
|
|
1604
|
+
const c = t.aev.get(o);
|
|
1605
|
+
for (const d of e.keys()) {
|
|
1606
|
+
const f = !c || ((r = c.get(d)) === null || r === void 0 ? void 0 : r.get(null)) || !c.get(d);
|
|
1607
|
+
(a ? f : !f) && i.push(e.get(d));
|
|
1608
1608
|
}
|
|
1609
1609
|
}
|
|
1610
|
-
return
|
|
1610
|
+
return i;
|
|
1611
1611
|
}
|
|
1612
1612
|
if (n != null && n.$comparator)
|
|
1613
1613
|
return X(e, 1).filter(n.$op);
|
|
1614
|
-
const
|
|
1615
|
-
for (const
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1614
|
+
const s = n.in || n.$in || [n];
|
|
1615
|
+
for (const o of s) {
|
|
1616
|
+
const a = e.get(o);
|
|
1617
|
+
a && i.push(a);
|
|
1618
1618
|
}
|
|
1619
|
-
return
|
|
1619
|
+
return i;
|
|
1620
1620
|
}
|
|
1621
1621
|
function yo(t, e, n) {
|
|
1622
1622
|
let r = "";
|
|
@@ -1642,8 +1642,8 @@ function bo(t, [e, n, r]) {
|
|
|
1642
1642
|
if (!a)
|
|
1643
1643
|
return [];
|
|
1644
1644
|
const u = [];
|
|
1645
|
-
for (const
|
|
1646
|
-
u.push(...gt(t,
|
|
1645
|
+
for (const c of a.values())
|
|
1646
|
+
u.push(...gt(t, c, r));
|
|
1647
1647
|
return u;
|
|
1648
1648
|
}
|
|
1649
1649
|
case "a": {
|
|
@@ -1655,15 +1655,15 @@ function bo(t, [e, n, r]) {
|
|
|
1655
1655
|
if (!a)
|
|
1656
1656
|
return [];
|
|
1657
1657
|
const u = [];
|
|
1658
|
-
for (const
|
|
1659
|
-
u.push(...gt(t,
|
|
1658
|
+
for (const c of a.values())
|
|
1659
|
+
u.push(...gt(t, c, r));
|
|
1660
1660
|
return u;
|
|
1661
1661
|
}
|
|
1662
1662
|
case "v": {
|
|
1663
1663
|
const a = [];
|
|
1664
1664
|
for (const u of t.eav.values())
|
|
1665
|
-
for (const
|
|
1666
|
-
a.push(...gt(t,
|
|
1665
|
+
for (const c of u.values())
|
|
1666
|
+
a.push(...gt(t, c, r));
|
|
1667
1667
|
return a;
|
|
1668
1668
|
}
|
|
1669
1669
|
default:
|
|
@@ -1675,8 +1675,8 @@ function _o(t, e, n) {
|
|
|
1675
1675
|
const i = {};
|
|
1676
1676
|
for (const [s, o] of e.entries()) {
|
|
1677
1677
|
const a = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), u = X(a, 1);
|
|
1678
|
-
for (const
|
|
1679
|
-
i[s] =
|
|
1678
|
+
for (const c of u)
|
|
1679
|
+
i[s] = c[2];
|
|
1680
1680
|
}
|
|
1681
1681
|
return i;
|
|
1682
1682
|
}
|
|
@@ -1711,13 +1711,17 @@ function wo(t, e) {
|
|
|
1711
1711
|
const u = a == null ? void 0 : a.mode;
|
|
1712
1712
|
if (u !== "create" && u !== "update")
|
|
1713
1713
|
return !0;
|
|
1714
|
-
let
|
|
1715
|
-
const
|
|
1716
|
-
if (
|
|
1717
|
-
const f = Ii(t,
|
|
1718
|
-
|
|
1714
|
+
let c = !1;
|
|
1715
|
+
const d = qe(t.attrs, s);
|
|
1716
|
+
if (d) {
|
|
1717
|
+
const f = Ii(t, d["forward-identity"][1]);
|
|
1718
|
+
c = !!To(t, [
|
|
1719
|
+
i,
|
|
1720
|
+
f == null ? void 0 : f.id,
|
|
1721
|
+
i
|
|
1722
|
+
]);
|
|
1719
1723
|
}
|
|
1720
|
-
return !(u === "create" &&
|
|
1724
|
+
return !(u === "create" && c || u === "update" && !c);
|
|
1721
1725
|
});
|
|
1722
1726
|
return Pt(t, (r) => {
|
|
1723
1727
|
n.forEach((i) => {
|
|
@@ -1890,18 +1894,18 @@ function Ri(t, e, n, r, i) {
|
|
|
1890
1894
|
throw new Ne(`Could not find attr for ${[n, i]}`);
|
|
1891
1895
|
if (a["value-type"] !== "ref")
|
|
1892
1896
|
throw new Error(`Attr ${a.id} is not a ref`);
|
|
1893
|
-
const [u,
|
|
1894
|
-
t(
|
|
1897
|
+
const [u, c] = a["forward-identity"], [d, f] = a["reverse-identity"], l = r + 1, p = s ? [
|
|
1898
|
+
t(c, r),
|
|
1895
1899
|
a.id,
|
|
1896
1900
|
t(f, l),
|
|
1897
1901
|
rt("time")
|
|
1898
1902
|
] : [
|
|
1899
|
-
t(
|
|
1903
|
+
t(c, l),
|
|
1900
1904
|
a.id,
|
|
1901
1905
|
t(f, r),
|
|
1902
1906
|
rt("time")
|
|
1903
1907
|
];
|
|
1904
|
-
return [s ? f :
|
|
1908
|
+
return [s ? f : c, l, p, a, !!s];
|
|
1905
1909
|
}
|
|
1906
1910
|
function Cr(t, e) {
|
|
1907
1911
|
if (typeof e != "string")
|
|
@@ -1978,12 +1982,12 @@ function Go(t, e, n, r, i, s) {
|
|
|
1978
1982
|
if (!u)
|
|
1979
1983
|
throw new Ne(`No attr for etype = ${n} label = ${i}`);
|
|
1980
1984
|
if (s != null && s.hasOwnProperty("$isNull")) {
|
|
1981
|
-
const
|
|
1982
|
-
if (!
|
|
1985
|
+
const c = Te(e, n, "id");
|
|
1986
|
+
if (!c)
|
|
1983
1987
|
throw new Ne(`No attr for etype = ${n} label = id`);
|
|
1984
1988
|
return [
|
|
1985
1989
|
t(n, r),
|
|
1986
|
-
|
|
1990
|
+
c.id,
|
|
1987
1991
|
{ $isNull: { attrId: u.id, isNull: s.$isNull, reverse: !o } },
|
|
1988
1992
|
rt("time")
|
|
1989
1993
|
];
|
|
@@ -1996,15 +2000,15 @@ function Go(t, e, n, r, i, s) {
|
|
|
1996
2000
|
] : [s, u.id, t(n, r), rt("time")];
|
|
1997
2001
|
}
|
|
1998
2002
|
function Qo(t, e, n, r, i) {
|
|
1999
|
-
const [s, o, a] = i.reduce((u,
|
|
2000
|
-
const [
|
|
2003
|
+
const [s, o, a] = i.reduce((u, c) => {
|
|
2004
|
+
const [d, f, l] = u, [p, y, b] = Ri(t, e, d, f, c);
|
|
2001
2005
|
return [p, y, [...l, b]];
|
|
2002
2006
|
}, [n, r, []]);
|
|
2003
2007
|
return [s, o, a];
|
|
2004
2008
|
}
|
|
2005
2009
|
function ln(t, e, n, r, i, s) {
|
|
2006
|
-
const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u,
|
|
2007
|
-
return
|
|
2010
|
+
const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, c, d] = Qo(t, e, n, r, o), f = Go(t, e, u, c, a, s);
|
|
2011
|
+
return d.concat([f]);
|
|
2008
2012
|
}
|
|
2009
2013
|
function Ho(t, e) {
|
|
2010
2014
|
return e ? [e].concat(t) : t;
|
|
@@ -2022,9 +2026,9 @@ function Zo(t, e, n) {
|
|
|
2022
2026
|
};
|
|
2023
2027
|
}
|
|
2024
2028
|
function Pr(t, e, n, r, i, s) {
|
|
2025
|
-
const o = t(r, i), a = s.map((u,
|
|
2026
|
-
const
|
|
2027
|
-
return xi(
|
|
2029
|
+
const o = t(r, i), a = s.map((u, c) => {
|
|
2030
|
+
const d = Zo(t, o, c);
|
|
2031
|
+
return xi(d, n, r, i, u);
|
|
2028
2032
|
});
|
|
2029
2033
|
return { [e]: { patterns: a, joinSym: o } };
|
|
2030
2034
|
}
|
|
@@ -2047,11 +2051,11 @@ function xi(t, e, n, r, i) {
|
|
|
2047
2051
|
return [];
|
|
2048
2052
|
const a = s.split(".");
|
|
2049
2053
|
if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
|
|
2050
|
-
const u = ln(t, e, n, r, a, o),
|
|
2054
|
+
const u = ln(t, e, n, r, a, o), c = Ir(t, e, n, r, a);
|
|
2051
2055
|
return [
|
|
2052
2056
|
{
|
|
2053
2057
|
or: {
|
|
2054
|
-
patterns: [u, ...
|
|
2058
|
+
patterns: [u, ...c],
|
|
2055
2059
|
joinSym: t(n, r)
|
|
2056
2060
|
}
|
|
2057
2061
|
}
|
|
@@ -2075,12 +2079,12 @@ function ta(t, e, n) {
|
|
|
2075
2079
|
return [t(e, n), t("time", n)];
|
|
2076
2080
|
}
|
|
2077
2081
|
function na(t, e, n, r, i, s) {
|
|
2078
|
-
const [o, a, u,
|
|
2079
|
-
return [o, a, f,
|
|
2082
|
+
const [o, a, u, c, d] = Ri(t, e, n, r, i), f = Vo(u, t(n, r), s);
|
|
2083
|
+
return [o, a, f, c, d];
|
|
2080
2084
|
}
|
|
2081
2085
|
function ra(t, e, { etype: n, level: r, form: i }, s) {
|
|
2082
2086
|
const o = Object.keys(i).filter((a) => a !== "$");
|
|
2083
|
-
return o.length ? Object.entries(s).map(function([u,
|
|
2087
|
+
return o.length ? Object.entries(s).map(function([u, c]) {
|
|
2084
2088
|
return o.map(function(l) {
|
|
2085
2089
|
var p, y, b;
|
|
2086
2090
|
const _ = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[l]) === null || b === void 0) && b.isSingular));
|
|
@@ -2099,7 +2103,7 @@ function ra(t, e, { etype: n, level: r, form: i }, s) {
|
|
|
2099
2103
|
}
|
|
2100
2104
|
}).reduce(function(l, p) {
|
|
2101
2105
|
return Object.assign(Object.assign({}, l), p);
|
|
2102
|
-
},
|
|
2106
|
+
}, c);
|
|
2103
2107
|
}) : Object.values(s);
|
|
2104
2108
|
}
|
|
2105
2109
|
function ia(t, e, n) {
|
|
@@ -2116,11 +2120,11 @@ function hn(t) {
|
|
|
2116
2120
|
}
|
|
2117
2121
|
function sa(t, e, n, r) {
|
|
2118
2122
|
var i;
|
|
2119
|
-
const [s, o, a, u] = t,
|
|
2123
|
+
const [s, o, a, u] = t, c = n === "desc" ? 1 : -1;
|
|
2120
2124
|
if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
|
|
2121
|
-
return It(r, [s, u], null) ===
|
|
2122
|
-
const [
|
|
2123
|
-
return It([
|
|
2125
|
+
return It(r, [s, u], null) === c;
|
|
2126
|
+
const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? hn(f) : f, y = l === "date" ? hn(a) : a;
|
|
2127
|
+
return It([d, p], [s, y], l) === c;
|
|
2124
2128
|
}
|
|
2125
2129
|
function oa(t, e) {
|
|
2126
2130
|
const n = e[1];
|
|
@@ -2153,27 +2157,27 @@ function ca(t, e, n) {
|
|
|
2153
2157
|
}
|
|
2154
2158
|
function da(t, { etype: e, pageInfo: n, dq: r, form: i }) {
|
|
2155
2159
|
var s, o;
|
|
2156
|
-
const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = $i(i),
|
|
2157
|
-
let
|
|
2160
|
+
const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = $i(i), c = fa(i);
|
|
2161
|
+
let d = Co(t, r);
|
|
2158
2162
|
const f = n == null ? void 0 : n["start-cursor"], l = ua(t, e, f, a);
|
|
2159
2163
|
if (l && ((o = l == null ? void 0 : l["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
|
|
2160
2164
|
const b = l["checked-data-type"] === "date", _ = l.id;
|
|
2161
|
-
|
|
2165
|
+
d = d.map(([w]) => {
|
|
2162
2166
|
var g, m, E, S, I;
|
|
2163
2167
|
let x = (I = (S = (E = (m = (g = t.eav.get(w)) === null || g === void 0 ? void 0 : g.get(_)) === null || m === void 0 ? void 0 : m.values()) === null || E === void 0 ? void 0 : E.next()) === null || S === void 0 ? void 0 : S.value) === null || I === void 0 ? void 0 : I[2];
|
|
2164
2168
|
return b && (x = hn(x)), [w, x];
|
|
2165
2169
|
});
|
|
2166
2170
|
}
|
|
2167
|
-
|
|
2171
|
+
d.sort(c === "asc" ? function(_, w) {
|
|
2168
2172
|
return It(_, w, l == null ? void 0 : l["checked-data-type"]);
|
|
2169
2173
|
} : function(_, w) {
|
|
2170
2174
|
return It(w, _, l == null ? void 0 : l["checked-data-type"]);
|
|
2171
2175
|
});
|
|
2172
2176
|
let p = {};
|
|
2173
2177
|
const y = ca(t, e, r);
|
|
2174
|
-
for (const b of
|
|
2178
|
+
for (const b of d) {
|
|
2175
2179
|
const [_] = b;
|
|
2176
|
-
if (p[_] || !u && f && l && sa(f, l,
|
|
2180
|
+
if (p[_] || !u && f && l && sa(f, l, c, b))
|
|
2177
2181
|
continue;
|
|
2178
2182
|
const w = _o(t, y, _);
|
|
2179
2183
|
w && (p[_] = w);
|
|
@@ -2191,7 +2195,7 @@ function $i(t) {
|
|
|
2191
2195
|
return !i && !s && !o;
|
|
2192
2196
|
}
|
|
2193
2197
|
function la(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
|
|
2194
|
-
var o, a, u,
|
|
2198
|
+
var o, a, u, c, d;
|
|
2195
2199
|
if (!$i(r) && (!s || !s["start-cursor"]))
|
|
2196
2200
|
return [];
|
|
2197
2201
|
const f = Ho(ea(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = ta($t, e, n), p = (a = r.$) === null || a === void 0 ? void 0 : a.fields, y = da(t, {
|
|
@@ -2199,7 +2203,7 @@ function la(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
|
|
|
2199
2203
|
pageInfo: s,
|
|
2200
2204
|
form: r,
|
|
2201
2205
|
dq: { where: f, find: l, fields: p }
|
|
2202
|
-
}), b = ((u = r.$) === null || u === void 0 ? void 0 : u.limit) || ((
|
|
2206
|
+
}), b = ((u = r.$) === null || u === void 0 ? void 0 : u.limit) || ((c = r.$) === null || c === void 0 ? void 0 : c.first) || ((d = r.$) === null || d === void 0 ? void 0 : d.last);
|
|
2203
2207
|
if (b != null) {
|
|
2204
2208
|
n > 0 && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
|
|
2205
2209
|
const _ = Object.entries(y);
|
|
@@ -2316,8 +2320,8 @@ function Ta(t, e) {
|
|
|
2316
2320
|
if (a)
|
|
2317
2321
|
i.push(a);
|
|
2318
2322
|
else if (Array.isArray(o) && o.length == 2 && n[o[0]]) {
|
|
2319
|
-
const [u,
|
|
2320
|
-
i.push([n[u],
|
|
2323
|
+
const [u, c] = o;
|
|
2324
|
+
i.push([n[u], c]);
|
|
2321
2325
|
} else
|
|
2322
2326
|
i.push(o);
|
|
2323
2327
|
}
|
|
@@ -2393,16 +2397,16 @@ function Fi(t, e, n, r) {
|
|
|
2393
2397
|
}
|
|
2394
2398
|
function va({ attrs: t }, [e, n, r]) {
|
|
2395
2399
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
2396
|
-
const a = Array.isArray(o) ? o : [o], u = V(t, e, s),
|
|
2397
|
-
return a.map((
|
|
2400
|
+
const a = Array.isArray(o) ? o : [o], u = V(t, e, s), c = Ae(t, e, s);
|
|
2401
|
+
return a.map((d) => u ? [
|
|
2398
2402
|
"add-triple",
|
|
2399
2403
|
ee(t, e, n),
|
|
2400
2404
|
u.id,
|
|
2401
|
-
ee(t, u["reverse-identity"][1],
|
|
2405
|
+
ee(t, u["reverse-identity"][1], d)
|
|
2402
2406
|
] : [
|
|
2403
2407
|
"add-triple",
|
|
2404
|
-
ee(t,
|
|
2405
|
-
|
|
2408
|
+
ee(t, c["forward-identity"][1], d),
|
|
2409
|
+
c.id,
|
|
2406
2410
|
ee(t, e, n)
|
|
2407
2411
|
]);
|
|
2408
2412
|
});
|
|
@@ -2410,16 +2414,16 @@ function va({ attrs: t }, [e, n, r]) {
|
|
|
2410
2414
|
}
|
|
2411
2415
|
function Sa({ attrs: t }, [e, n, r]) {
|
|
2412
2416
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
2413
|
-
const a = Array.isArray(o) ? o : [o], u = V(t, e, s),
|
|
2414
|
-
return a.map((
|
|
2417
|
+
const a = Array.isArray(o) ? o : [o], u = V(t, e, s), c = Ae(t, e, s);
|
|
2418
|
+
return a.map((d) => u ? [
|
|
2415
2419
|
"retract-triple",
|
|
2416
2420
|
ee(t, e, n),
|
|
2417
2421
|
u.id,
|
|
2418
|
-
ee(t, u["reverse-identity"][1],
|
|
2422
|
+
ee(t, u["reverse-identity"][1], d)
|
|
2419
2423
|
] : [
|
|
2420
2424
|
"retract-triple",
|
|
2421
|
-
ee(t,
|
|
2422
|
-
|
|
2425
|
+
ee(t, c["forward-identity"][1], d),
|
|
2426
|
+
c.id,
|
|
2423
2427
|
ee(t, e, n)
|
|
2424
2428
|
]);
|
|
2425
2429
|
});
|
|
@@ -2431,8 +2435,8 @@ function Oa(t, e, n) {
|
|
|
2431
2435
|
for (const s of t || []) {
|
|
2432
2436
|
const o = s == null ? void 0 : s.aev.get(r);
|
|
2433
2437
|
if (o) {
|
|
2434
|
-
for (const [a, u,
|
|
2435
|
-
if (
|
|
2438
|
+
for (const [a, u, c] of X(o, 2))
|
|
2439
|
+
if (c === i)
|
|
2436
2440
|
return !0;
|
|
2437
2441
|
}
|
|
2438
2442
|
}
|
|
@@ -2451,22 +2455,22 @@ function Ni({ stores: t, attrs: e }, [n, r, i, s]) {
|
|
|
2451
2455
|
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Oa(t, n, r) ? { mode: "update" } : null;
|
|
2452
2456
|
}
|
|
2453
2457
|
function Ea(t, e) {
|
|
2454
|
-
const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o),
|
|
2455
|
-
return [["id",
|
|
2458
|
+
const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o), c = ee(r, i, s);
|
|
2459
|
+
return [["id", c]].concat(Object.entries(u)).map(([f, l]) => {
|
|
2456
2460
|
const p = V(r, i, f);
|
|
2457
|
-
return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), ["add-triple",
|
|
2461
|
+
return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), ["add-triple", c, p.id, l, { mode: "create" }];
|
|
2458
2462
|
});
|
|
2459
2463
|
}
|
|
2460
2464
|
function Aa(t, e) {
|
|
2461
|
-
const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o),
|
|
2462
|
-
return [["id",
|
|
2465
|
+
const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o), c = ee(r, i, s), d = Ni(t, [i, c, o, a]);
|
|
2466
|
+
return [["id", c]].concat(Object.entries(u)).map(([l, p]) => {
|
|
2463
2467
|
const y = V(r, i, l);
|
|
2464
2468
|
return y["checked-data-type"] === "date" && t.useDateObjects && (p = xt(p)), [
|
|
2465
2469
|
"add-triple",
|
|
2466
|
-
|
|
2470
|
+
c,
|
|
2467
2471
|
y.id,
|
|
2468
2472
|
p,
|
|
2469
|
-
...
|
|
2473
|
+
...d ? [d] : []
|
|
2470
2474
|
];
|
|
2471
2475
|
});
|
|
2472
2476
|
}
|
|
@@ -2474,22 +2478,22 @@ function ja({ attrs: t }, [e, n]) {
|
|
|
2474
2478
|
return [["delete-entity", ee(t, e, n), e]];
|
|
2475
2479
|
}
|
|
2476
2480
|
function ka(t, e) {
|
|
2477
|
-
const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o),
|
|
2481
|
+
const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Fn(o), c = ee(r, i, s), d = Ni(t, [i, c, o, a]), f = Object.entries(u).map(([p, y]) => {
|
|
2478
2482
|
const b = V(r, i, p);
|
|
2479
2483
|
return [
|
|
2480
2484
|
"deep-merge-triple",
|
|
2481
|
-
|
|
2485
|
+
c,
|
|
2482
2486
|
b.id,
|
|
2483
2487
|
y,
|
|
2484
|
-
...
|
|
2488
|
+
...d ? [d] : []
|
|
2485
2489
|
];
|
|
2486
2490
|
});
|
|
2487
2491
|
return [[
|
|
2488
2492
|
"add-triple",
|
|
2489
|
-
|
|
2493
|
+
c,
|
|
2490
2494
|
V(r, i, "id").id,
|
|
2491
|
-
|
|
2492
|
-
...
|
|
2495
|
+
c,
|
|
2496
|
+
...d ? [d] : []
|
|
2493
2497
|
]].concat(f);
|
|
2494
2498
|
}
|
|
2495
2499
|
function Ca({ attrs: t }, [e, n, r]) {
|
|
@@ -2589,9 +2593,9 @@ function Ka(t) {
|
|
|
2589
2593
|
const o = _n(i);
|
|
2590
2594
|
if (o && e.push({ etype: r, lookupPair: o }), n === "link")
|
|
2591
2595
|
for (const [a, u] of Object.entries(s)) {
|
|
2592
|
-
const
|
|
2593
|
-
for (const
|
|
2594
|
-
const f = _n(
|
|
2596
|
+
const c = Array.isArray(u) ? u : [u];
|
|
2597
|
+
for (const d of c) {
|
|
2598
|
+
const f = _n(d);
|
|
2595
2599
|
f && e.push({
|
|
2596
2600
|
etype: r,
|
|
2597
2601
|
lookupPair: f,
|
|
@@ -2607,44 +2611,44 @@ function qa({ attrs: t, schema: e }, n) {
|
|
|
2607
2611
|
function u(f) {
|
|
2608
2612
|
o[f.id] = f, a.push(["add-attr", f]), s.add(f.id);
|
|
2609
2613
|
}
|
|
2610
|
-
function
|
|
2614
|
+
function c(f) {
|
|
2611
2615
|
f != null && f.isUnsynced && !s.has(f.id) && (a.push(["add-attr", f]), s.add(f.id));
|
|
2612
2616
|
}
|
|
2613
|
-
function
|
|
2617
|
+
function d(f, l) {
|
|
2614
2618
|
const p = V(o, f, l), y = Ae(o, f, l);
|
|
2615
|
-
|
|
2619
|
+
c(p), c(y), !p && !y && u(Mr(e, f, l, Na));
|
|
2616
2620
|
}
|
|
2617
2621
|
for (const f of n)
|
|
2618
2622
|
for (const { etype: l, lookupPair: p, linkLabel: y } of Ka(f)) {
|
|
2619
2623
|
const b = p[0];
|
|
2620
2624
|
if (y) {
|
|
2621
|
-
|
|
2625
|
+
d(l, y);
|
|
2622
2626
|
const _ = V(o, l, y), w = Ae(o, l, y);
|
|
2623
|
-
|
|
2627
|
+
c(_), c(w);
|
|
2624
2628
|
const g = ((r = _ == null ? void 0 : _["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = w == null ? void 0 : w["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || y;
|
|
2625
2629
|
if (yn(o, g, b))
|
|
2626
|
-
|
|
2630
|
+
d(g, bn(b));
|
|
2627
2631
|
else {
|
|
2628
2632
|
const m = V(o, g, b);
|
|
2629
|
-
m || u(Tt(e, g, b, gn)),
|
|
2633
|
+
m || u(Tt(e, g, b, gn)), c(m);
|
|
2630
2634
|
}
|
|
2631
2635
|
} else if (yn(o, l, b))
|
|
2632
|
-
|
|
2636
|
+
d(l, bn(b));
|
|
2633
2637
|
else {
|
|
2634
2638
|
const _ = V(o, l, b);
|
|
2635
|
-
_ || u(Tt(e, l, b, gn)),
|
|
2639
|
+
_ || u(Tt(e, l, b, gn)), c(_);
|
|
2636
2640
|
}
|
|
2637
2641
|
}
|
|
2638
2642
|
for (const f of n) {
|
|
2639
2643
|
const [l, p, y, b] = f;
|
|
2640
2644
|
if (Da.has(l)) {
|
|
2641
2645
|
const _ = V(o, p, "id");
|
|
2642
|
-
|
|
2646
|
+
c(_), _ || u(Tt(e, p, "id", { "unique?": !0 }));
|
|
2643
2647
|
for (const w of Object.keys(b)) {
|
|
2644
2648
|
const g = V(o, p, w);
|
|
2645
|
-
if (
|
|
2649
|
+
if (c(g), La.has(l) && (g || u(Tt(e, p, w, w === "id" ? { "unique?": !0 } : null))), Ua.has(l)) {
|
|
2646
2650
|
const m = Ae(o, p, w);
|
|
2647
|
-
!g && !m && u(Mr(e, p, w)),
|
|
2651
|
+
!g && !m && u(Mr(e, p, w)), c(m);
|
|
2648
2652
|
}
|
|
2649
2653
|
}
|
|
2650
2654
|
}
|
|
@@ -2662,24 +2666,24 @@ var de = function(t, e, n, r) {
|
|
|
2662
2666
|
});
|
|
2663
2667
|
}
|
|
2664
2668
|
return new (n || (n = Promise))(function(s, o) {
|
|
2665
|
-
function a(
|
|
2669
|
+
function a(d) {
|
|
2666
2670
|
try {
|
|
2667
|
-
|
|
2671
|
+
c(r.next(d));
|
|
2668
2672
|
} catch (f) {
|
|
2669
2673
|
o(f);
|
|
2670
2674
|
}
|
|
2671
2675
|
}
|
|
2672
|
-
function u(
|
|
2676
|
+
function u(d) {
|
|
2673
2677
|
try {
|
|
2674
|
-
|
|
2678
|
+
c(r.throw(d));
|
|
2675
2679
|
} catch (f) {
|
|
2676
2680
|
o(f);
|
|
2677
2681
|
}
|
|
2678
2682
|
}
|
|
2679
|
-
function d
|
|
2680
|
-
|
|
2683
|
+
function c(d) {
|
|
2684
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
2681
2685
|
}
|
|
2682
|
-
|
|
2686
|
+
c((r = r.apply(t, e || [])).next());
|
|
2683
2687
|
});
|
|
2684
2688
|
};
|
|
2685
2689
|
function Rr(t, e) {
|
|
@@ -2802,12 +2806,12 @@ class Tn {
|
|
|
2802
2806
|
const y = this._persister.removeItem(p);
|
|
2803
2807
|
i.push(y.then(() => 1)), this._loadedKeys.delete(p), this._pendingSaveKeys.delete(p);
|
|
2804
2808
|
}
|
|
2805
|
-
const
|
|
2809
|
+
const c = [], d = [[it, o]], f = (n = o.objects) !== null && n !== void 0 ? n : {};
|
|
2806
2810
|
o.objects = f;
|
|
2807
2811
|
for (const p of u)
|
|
2808
2812
|
if (this._loadedKeys.has(p)) {
|
|
2809
2813
|
const y = this.serialize(p, this.currentValue[p]);
|
|
2810
|
-
|
|
2814
|
+
d.push([p, y]);
|
|
2811
2815
|
const b = this._objectSize(y), _ = (r = f[p]) !== null && r !== void 0 ? r : {
|
|
2812
2816
|
createdAt: Date.now(),
|
|
2813
2817
|
updatedAt: Date.now(),
|
|
@@ -2815,10 +2819,10 @@ class Tn {
|
|
|
2815
2819
|
};
|
|
2816
2820
|
_.updatedAt = Date.now(), _.size = b, f[p] = _, this._pendingSaveKeys.delete(p);
|
|
2817
2821
|
} else
|
|
2818
|
-
|
|
2819
|
-
const l = this._persister.multiSet(
|
|
2822
|
+
c.push(p);
|
|
2823
|
+
const l = this._persister.multiSet(d);
|
|
2820
2824
|
i.push(l.then(() => 1));
|
|
2821
|
-
for (const p of
|
|
2825
|
+
for (const p of c) {
|
|
2822
2826
|
const y = this._loadKey(p).then(() => this._enqueuePersist(e));
|
|
2823
2827
|
i.push(y);
|
|
2824
2828
|
}
|
|
@@ -2867,12 +2871,12 @@ class Tn {
|
|
|
2867
2871
|
if (a.length > this._gcOpts.maxEntries)
|
|
2868
2872
|
for (const [l] of u.slice(0, a.length - this._gcOpts.maxEntries))
|
|
2869
2873
|
i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedThresholdCount++;
|
|
2870
|
-
const
|
|
2871
|
-
|
|
2872
|
-
const
|
|
2873
|
-
let f =
|
|
2874
|
-
for (; f > 0 && f > this._gcOpts.maxSize &&
|
|
2875
|
-
const [[l, p]] =
|
|
2874
|
+
const c = Object.entries(r.objects);
|
|
2875
|
+
c.sort(([l, p], [y, b]) => p.updatedAt - b.updatedAt);
|
|
2876
|
+
const d = c.filter(([l]) => !n.has(l));
|
|
2877
|
+
let f = c.reduce((l, [p, y]) => l + y.size, 0);
|
|
2878
|
+
for (; f > 0 && f > this._gcOpts.maxSize && d.length; ) {
|
|
2879
|
+
const [[l, p]] = d.splice(0, 1);
|
|
2876
2880
|
f -= p.size, i.push(this._persister.removeItem(l)), delete r.objects[l], s.removed.push(l), s.removedSizeCount++;
|
|
2877
2881
|
}
|
|
2878
2882
|
for (const l of Object.keys(r.objects))
|
|
@@ -2938,24 +2942,24 @@ var pe = function(t, e, n, r) {
|
|
|
2938
2942
|
});
|
|
2939
2943
|
}
|
|
2940
2944
|
return new (n || (n = Promise))(function(s, o) {
|
|
2941
|
-
function a(
|
|
2945
|
+
function a(d) {
|
|
2942
2946
|
try {
|
|
2943
|
-
|
|
2947
|
+
c(r.next(d));
|
|
2944
2948
|
} catch (f) {
|
|
2945
2949
|
o(f);
|
|
2946
2950
|
}
|
|
2947
2951
|
}
|
|
2948
|
-
function u(
|
|
2952
|
+
function u(d) {
|
|
2949
2953
|
try {
|
|
2950
|
-
|
|
2954
|
+
c(r.throw(d));
|
|
2951
2955
|
} catch (f) {
|
|
2952
2956
|
o(f);
|
|
2953
2957
|
}
|
|
2954
2958
|
}
|
|
2955
|
-
function d
|
|
2956
|
-
|
|
2959
|
+
function c(d) {
|
|
2960
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
2957
2961
|
}
|
|
2958
|
-
|
|
2962
|
+
c((r = r.apply(t, e || [])).next());
|
|
2959
2963
|
});
|
|
2960
2964
|
};
|
|
2961
2965
|
const Va = 6, Ba = ["kv", "querySubs", "syncSubs"];
|
|
@@ -2990,7 +2994,7 @@ function Ha(t, e, n) {
|
|
|
2990
2994
|
return;
|
|
2991
2995
|
const i = /* @__PURE__ */ new Set();
|
|
2992
2996
|
return new Promise((s, o) => {
|
|
2993
|
-
var a, u,
|
|
2997
|
+
var a, u, c, d;
|
|
2994
2998
|
const f = {};
|
|
2995
2999
|
for (const [y, b] of Object.entries(r)) {
|
|
2996
3000
|
const _ = typeof b == "string" ? JSON.parse(b) : b;
|
|
@@ -2998,7 +3002,7 @@ function Ha(t, e, n) {
|
|
|
2998
3002
|
const g = {
|
|
2999
3003
|
createdAt: _.lastAccessed,
|
|
3000
3004
|
updatedAt: _.lastAccessed,
|
|
3001
|
-
size: (
|
|
3005
|
+
size: (d = (c = (u = (a = _.result) === null || a === void 0 ? void 0 : a.store) === null || u === void 0 ? void 0 : u.triples) === null || c === void 0 ? void 0 : c.length) !== null && d !== void 0 ? d : 0
|
|
3002
3006
|
};
|
|
3003
3007
|
f[y] = g;
|
|
3004
3008
|
}
|
|
@@ -3029,7 +3033,7 @@ function Ya(t, e) {
|
|
|
3029
3033
|
const n = yield Qa(`instant_${t}_5`);
|
|
3030
3034
|
if (!n)
|
|
3031
3035
|
return;
|
|
3032
|
-
const r = yield new Promise((
|
|
3036
|
+
const r = yield new Promise((d, f) => {
|
|
3033
3037
|
const y = n.transaction(["kv"], "readonly").objectStore("kv").openCursor();
|
|
3034
3038
|
y.onerror = (_) => {
|
|
3035
3039
|
f(_);
|
|
@@ -3041,33 +3045,33 @@ function Ya(t, e) {
|
|
|
3041
3045
|
const w = _.key, g = _.value;
|
|
3042
3046
|
b.push([w, g]), _.continue();
|
|
3043
3047
|
} else
|
|
3044
|
-
|
|
3048
|
+
d(b);
|
|
3045
3049
|
}, y.onerror = (_) => {
|
|
3046
3050
|
f(_);
|
|
3047
3051
|
};
|
|
3048
3052
|
}), i = e.transaction(["kv", "querySubs"], "readwrite"), s = i.objectStore("kv"), o = i.objectStore("querySubs"), a = [], u = { objects: {} };
|
|
3049
|
-
for (const [
|
|
3050
|
-
switch (
|
|
3053
|
+
for (const [d, f] of r)
|
|
3054
|
+
switch (d) {
|
|
3051
3055
|
case "querySubs": {
|
|
3052
|
-
const l = Ha(
|
|
3056
|
+
const l = Ha(d, f, o);
|
|
3053
3057
|
a.push(l);
|
|
3054
3058
|
break;
|
|
3055
3059
|
}
|
|
3056
3060
|
default: {
|
|
3057
|
-
const l = xr(
|
|
3061
|
+
const l = xr(d, f, s);
|
|
3058
3062
|
a.push(l);
|
|
3059
3063
|
const p = {
|
|
3060
3064
|
createdAt: Date.now(),
|
|
3061
3065
|
updatedAt: Date.now(),
|
|
3062
3066
|
size: 0
|
|
3063
3067
|
};
|
|
3064
|
-
u.objects[
|
|
3068
|
+
u.objects[d] = p;
|
|
3065
3069
|
break;
|
|
3066
3070
|
}
|
|
3067
3071
|
}
|
|
3068
|
-
const
|
|
3069
|
-
a.push(
|
|
3070
|
-
i.oncomplete = (l) =>
|
|
3072
|
+
const c = xr(it, u, s);
|
|
3073
|
+
a.push(c), yield Promise.all(a), yield new Promise((d, f) => {
|
|
3074
|
+
i.oncomplete = (l) => d(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
|
|
3071
3075
|
});
|
|
3072
3076
|
});
|
|
3073
3077
|
}
|
|
@@ -3085,8 +3089,8 @@ class Ki extends za {
|
|
|
3085
3089
|
}, i.onsuccess = (s) => {
|
|
3086
3090
|
const a = s.target.result;
|
|
3087
3091
|
if (r) {
|
|
3088
|
-
const u = Ya(this._appId, a).catch((
|
|
3089
|
-
Ga("Error upgrading store from version 5 to 6.")(
|
|
3092
|
+
const u = Ya(this._appId, a).catch((c) => {
|
|
3093
|
+
Ga("Error upgrading store from version 5 to 6.")(c);
|
|
3090
3094
|
});
|
|
3091
3095
|
$r.set(this.dbName, u), u.then(() => e(a)).catch(() => e(a));
|
|
3092
3096
|
} else {
|
|
@@ -3121,9 +3125,9 @@ class Ki extends za {
|
|
|
3121
3125
|
const r = yield this._dbPromise;
|
|
3122
3126
|
return new Promise((i, s) => {
|
|
3123
3127
|
const u = r.transaction([this._storeName], "readwrite").objectStore(this._storeName).put(n, e);
|
|
3124
|
-
u.onerror = (
|
|
3125
|
-
s(
|
|
3126
|
-
}, u.onsuccess = (
|
|
3128
|
+
u.onerror = (c) => {
|
|
3129
|
+
s(c);
|
|
3130
|
+
}, u.onsuccess = (c) => {
|
|
3127
3131
|
i();
|
|
3128
3132
|
};
|
|
3129
3133
|
});
|
|
@@ -3135,14 +3139,14 @@ class Ki extends za {
|
|
|
3135
3139
|
const n = yield this._dbPromise;
|
|
3136
3140
|
return new Promise((r, i) => {
|
|
3137
3141
|
const s = n.transaction([this._storeName], "readwrite"), o = s.objectStore(this._storeName), a = /* @__PURE__ */ new Set();
|
|
3138
|
-
for (const [u,
|
|
3139
|
-
const
|
|
3140
|
-
a.add(
|
|
3142
|
+
for (const [u, c] of e) {
|
|
3143
|
+
const d = o.put(c, u);
|
|
3144
|
+
a.add(d);
|
|
3141
3145
|
}
|
|
3142
3146
|
for (const u of a)
|
|
3143
|
-
u.onerror = (
|
|
3144
|
-
s.abort(), i(
|
|
3145
|
-
}, u.onsuccess = (
|
|
3147
|
+
u.onerror = (c) => {
|
|
3148
|
+
s.abort(), i(c);
|
|
3149
|
+
}, u.onsuccess = (c) => {
|
|
3146
3150
|
a.delete(u), a.size === 0 && r();
|
|
3147
3151
|
};
|
|
3148
3152
|
});
|
|
@@ -3182,24 +3186,24 @@ var Ja = function(t, e, n, r) {
|
|
|
3182
3186
|
});
|
|
3183
3187
|
}
|
|
3184
3188
|
return new (n || (n = Promise))(function(s, o) {
|
|
3185
|
-
function a(
|
|
3189
|
+
function a(d) {
|
|
3186
3190
|
try {
|
|
3187
|
-
|
|
3191
|
+
c(r.next(d));
|
|
3188
3192
|
} catch (f) {
|
|
3189
3193
|
o(f);
|
|
3190
3194
|
}
|
|
3191
3195
|
}
|
|
3192
|
-
function u(
|
|
3196
|
+
function u(d) {
|
|
3193
3197
|
try {
|
|
3194
|
-
|
|
3198
|
+
c(r.throw(d));
|
|
3195
3199
|
} catch (f) {
|
|
3196
3200
|
o(f);
|
|
3197
3201
|
}
|
|
3198
3202
|
}
|
|
3199
|
-
function d
|
|
3200
|
-
|
|
3203
|
+
function c(d) {
|
|
3204
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
3201
3205
|
}
|
|
3202
|
-
|
|
3206
|
+
c((r = r.apply(t, e || [])).next());
|
|
3203
3207
|
});
|
|
3204
3208
|
};
|
|
3205
3209
|
class qi {
|
|
@@ -3236,24 +3240,24 @@ var Za = function(t, e, n, r) {
|
|
|
3236
3240
|
});
|
|
3237
3241
|
}
|
|
3238
3242
|
return new (n || (n = Promise))(function(s, o) {
|
|
3239
|
-
function a(
|
|
3243
|
+
function a(d) {
|
|
3240
3244
|
try {
|
|
3241
|
-
|
|
3245
|
+
c(r.next(d));
|
|
3242
3246
|
} catch (f) {
|
|
3243
3247
|
o(f);
|
|
3244
3248
|
}
|
|
3245
3249
|
}
|
|
3246
|
-
function u(
|
|
3250
|
+
function u(d) {
|
|
3247
3251
|
try {
|
|
3248
|
-
|
|
3252
|
+
c(r.throw(d));
|
|
3249
3253
|
} catch (f) {
|
|
3250
3254
|
o(f);
|
|
3251
3255
|
}
|
|
3252
3256
|
}
|
|
3253
|
-
function d
|
|
3254
|
-
|
|
3257
|
+
function c(d) {
|
|
3258
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
3255
3259
|
}
|
|
3256
|
-
|
|
3260
|
+
c((r = r.apply(t, e || [])).next());
|
|
3257
3261
|
});
|
|
3258
3262
|
};
|
|
3259
3263
|
class Dt extends Ke {
|
|
@@ -3281,24 +3285,24 @@ var ze = function(t, e, n, r) {
|
|
|
3281
3285
|
});
|
|
3282
3286
|
}
|
|
3283
3287
|
return new (n || (n = Promise))(function(s, o) {
|
|
3284
|
-
function a(
|
|
3288
|
+
function a(d) {
|
|
3285
3289
|
try {
|
|
3286
|
-
|
|
3290
|
+
c(r.next(d));
|
|
3287
3291
|
} catch (f) {
|
|
3288
3292
|
o(f);
|
|
3289
3293
|
}
|
|
3290
3294
|
}
|
|
3291
|
-
function u(
|
|
3295
|
+
function u(d) {
|
|
3292
3296
|
try {
|
|
3293
|
-
|
|
3297
|
+
c(r.throw(d));
|
|
3294
3298
|
} catch (f) {
|
|
3295
3299
|
o(f);
|
|
3296
3300
|
}
|
|
3297
3301
|
}
|
|
3298
|
-
function d
|
|
3299
|
-
|
|
3302
|
+
function c(d) {
|
|
3303
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
3300
3304
|
}
|
|
3301
|
-
|
|
3305
|
+
c((r = r.apply(t, e || [])).next());
|
|
3302
3306
|
});
|
|
3303
3307
|
};
|
|
3304
3308
|
function Xa({ apiURI: t, appId: e, email: n }) {
|
|
@@ -3394,24 +3398,24 @@ var ft = function(t, e, n, r) {
|
|
|
3394
3398
|
});
|
|
3395
3399
|
}
|
|
3396
3400
|
return new (n || (n = Promise))(function(s, o) {
|
|
3397
|
-
function a(
|
|
3401
|
+
function a(d) {
|
|
3398
3402
|
try {
|
|
3399
|
-
|
|
3403
|
+
c(r.next(d));
|
|
3400
3404
|
} catch (f) {
|
|
3401
3405
|
o(f);
|
|
3402
3406
|
}
|
|
3403
3407
|
}
|
|
3404
|
-
function u(
|
|
3408
|
+
function u(d) {
|
|
3405
3409
|
try {
|
|
3406
|
-
|
|
3410
|
+
c(r.throw(d));
|
|
3407
3411
|
} catch (f) {
|
|
3408
3412
|
o(f);
|
|
3409
3413
|
}
|
|
3410
3414
|
}
|
|
3411
|
-
function d
|
|
3412
|
-
|
|
3415
|
+
function c(d) {
|
|
3416
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
3413
3417
|
}
|
|
3414
|
-
|
|
3418
|
+
c((r = r.apply(t, e || [])).next());
|
|
3415
3419
|
});
|
|
3416
3420
|
};
|
|
3417
3421
|
function su(t) {
|
|
@@ -3500,10 +3504,10 @@ function du(t, e, n) {
|
|
|
3500
3504
|
s.user = Object.assign(Object.assign({}, a), { peerId: n });
|
|
3501
3505
|
}
|
|
3502
3506
|
for (const a of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
|
|
3503
|
-
const u = (e == null ? void 0 : e.peers) === void 0,
|
|
3504
|
-
if (u ||
|
|
3505
|
-
const
|
|
3506
|
-
s.peers[a] = Object.assign(Object.assign({},
|
|
3507
|
+
const u = (e == null ? void 0 : e.peers) === void 0, c = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(a));
|
|
3508
|
+
if (u || c) {
|
|
3509
|
+
const d = Ur(t.peers[a], e == null ? void 0 : e.keys);
|
|
3510
|
+
s.peers[a] = Object.assign(Object.assign({}, d), { peerId: a });
|
|
3507
3511
|
}
|
|
3508
3512
|
}
|
|
3509
3513
|
return s;
|
|
@@ -3556,7 +3560,7 @@ function Nr(t) {
|
|
|
3556
3560
|
}, e;
|
|
3557
3561
|
}, {});
|
|
3558
3562
|
}
|
|
3559
|
-
const Bn = "v0.22.
|
|
3563
|
+
const Bn = "v0.22.84";
|
|
3560
3564
|
function lu(t, e) {
|
|
3561
3565
|
return {
|
|
3562
3566
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
@@ -3657,17 +3661,17 @@ const Kr = [
|
|
|
3657
3661
|
return !0;
|
|
3658
3662
|
}
|
|
3659
3663
|
}, pu = (t, e, n, r, i, s, o) => {
|
|
3660
|
-
const a = s.valueType === "json", u = (
|
|
3661
|
-
if (!Bi(f,
|
|
3662
|
-
throw new R(`Invalid value for operator '${
|
|
3664
|
+
const a = s.valueType === "json", u = (c, d, f) => {
|
|
3665
|
+
if (!Bi(f, d, a))
|
|
3666
|
+
throw new R(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
|
|
3663
3667
|
};
|
|
3664
3668
|
switch (t) {
|
|
3665
3669
|
case "in":
|
|
3666
3670
|
case "$in":
|
|
3667
3671
|
if (!Array.isArray(e))
|
|
3668
3672
|
throw new R(`Operator '${t}' for attribute '${r}' in entity '${i}' must be an array, but received: ${typeof e}`, o);
|
|
3669
|
-
for (const
|
|
3670
|
-
u(t, n,
|
|
3673
|
+
for (const c of e)
|
|
3674
|
+
u(t, n, c);
|
|
3671
3675
|
break;
|
|
3672
3676
|
case "$not":
|
|
3673
3677
|
case "$ne":
|
|
@@ -3694,8 +3698,8 @@ const Kr = [
|
|
|
3694
3698
|
if (o)
|
|
3695
3699
|
return;
|
|
3696
3700
|
const u = t;
|
|
3697
|
-
for (const [
|
|
3698
|
-
pu(
|
|
3701
|
+
for (const [c, d] of Object.entries(u))
|
|
3702
|
+
pu(c, d, s, e, r, n, `${i}.${c}`);
|
|
3699
3703
|
} else if (!Bi(t, s, o))
|
|
3700
3704
|
throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
|
|
3701
3705
|
}, yu = (t, e, n, r, i) => {
|
|
@@ -3703,8 +3707,8 @@ const Kr = [
|
|
|
3703
3707
|
if (s.length < 2)
|
|
3704
3708
|
throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
|
|
3705
3709
|
let o = n;
|
|
3706
|
-
for (let
|
|
3707
|
-
const f = s[
|
|
3710
|
+
for (let d = 0; d < s.length - 1; d++) {
|
|
3711
|
+
const f = s[d], l = r.entities[o];
|
|
3708
3712
|
if (!l)
|
|
3709
3713
|
throw new R(`Entity '${o}' does not exist in schema while traversing dot notation path '${t}'.`, i);
|
|
3710
3714
|
const p = l.links[f];
|
|
@@ -3723,24 +3727,24 @@ const Kr = [
|
|
|
3723
3727
|
Ue(e, t, new H("string", !1, !0), n, i);
|
|
3724
3728
|
return;
|
|
3725
3729
|
}
|
|
3726
|
-
const
|
|
3730
|
+
const c = u.attrs[a];
|
|
3727
3731
|
if (Object.keys(u.links).includes(a)) {
|
|
3728
3732
|
if (typeof e == "string" && !Fe(e))
|
|
3729
3733
|
throw new R(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, i);
|
|
3730
3734
|
Ue(e, t, new H("string", !1, !0), n, i);
|
|
3731
3735
|
return;
|
|
3732
3736
|
}
|
|
3733
|
-
if (!
|
|
3734
|
-
const
|
|
3735
|
-
throw new R(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${
|
|
3737
|
+
if (!c) {
|
|
3738
|
+
const d = Object.keys(u.attrs);
|
|
3739
|
+
throw new R(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${d.length > 0 ? d.join(", ") + ", id" : "id"}`, i);
|
|
3736
3740
|
}
|
|
3737
|
-
Ue(e, t,
|
|
3741
|
+
Ue(e, t, c, n, i);
|
|
3738
3742
|
}, Gi = (t, e, n, r) => {
|
|
3739
3743
|
for (const [i, s] of Object.entries(t)) {
|
|
3740
3744
|
if (i === "or" || i === "and") {
|
|
3741
3745
|
if (Array.isArray(s))
|
|
3742
|
-
for (const
|
|
3743
|
-
typeof
|
|
3746
|
+
for (const c of s)
|
|
3747
|
+
typeof c == "object" && c !== null && Gi(c, e, n, `${r}.${i}[${c}]`);
|
|
3744
3748
|
continue;
|
|
3745
3749
|
}
|
|
3746
3750
|
if (i === "id") {
|
|
@@ -3756,16 +3760,16 @@ const Kr = [
|
|
|
3756
3760
|
continue;
|
|
3757
3761
|
const a = o.attrs[i], u = o.links[i];
|
|
3758
3762
|
if (!a && !u) {
|
|
3759
|
-
const
|
|
3760
|
-
throw new R(`Attribute or link '${i}' does not exist on entity '${e}'. Available attributes: ${
|
|
3763
|
+
const c = Object.keys(o.attrs), d = Object.keys(o.links);
|
|
3764
|
+
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}`);
|
|
3761
3765
|
}
|
|
3762
3766
|
if (a)
|
|
3763
3767
|
Ue(s, i, a, e, `${r}.${i}`);
|
|
3764
3768
|
else if (u) {
|
|
3765
3769
|
if (typeof s == "string" && !Fe(s))
|
|
3766
3770
|
throw new R(`Invalid value for link '${i}' in entity '${e}'. Expected a UUID, but received: ${s}`, `${r}.${i}`);
|
|
3767
|
-
const
|
|
3768
|
-
Ue(s, i,
|
|
3771
|
+
const c = new H("string", !1, !0);
|
|
3772
|
+
Ue(s, i, c, e, `${r}.${i}`);
|
|
3769
3773
|
}
|
|
3770
3774
|
}
|
|
3771
3775
|
}, bu = (t, e, n, r, i = 0) => {
|
|
@@ -3916,24 +3920,24 @@ var Br = function(t, e, n, r) {
|
|
|
3916
3920
|
});
|
|
3917
3921
|
}
|
|
3918
3922
|
return new (n || (n = Promise))(function(s, o) {
|
|
3919
|
-
function a(
|
|
3923
|
+
function a(d) {
|
|
3920
3924
|
try {
|
|
3921
|
-
|
|
3925
|
+
c(r.next(d));
|
|
3922
3926
|
} catch (f) {
|
|
3923
3927
|
o(f);
|
|
3924
3928
|
}
|
|
3925
3929
|
}
|
|
3926
|
-
function u(
|
|
3930
|
+
function u(d) {
|
|
3927
3931
|
try {
|
|
3928
|
-
|
|
3932
|
+
c(r.throw(d));
|
|
3929
3933
|
} catch (f) {
|
|
3930
3934
|
o(f);
|
|
3931
3935
|
}
|
|
3932
3936
|
}
|
|
3933
|
-
function d
|
|
3934
|
-
|
|
3937
|
+
function c(d) {
|
|
3938
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
3935
3939
|
}
|
|
3936
|
-
|
|
3940
|
+
c((r = r.apply(t, e || [])).next());
|
|
3937
3941
|
});
|
|
3938
3942
|
};
|
|
3939
3943
|
let Ji = 0;
|
|
@@ -4060,24 +4064,24 @@ var Qr = function(t, e, n, r) {
|
|
|
4060
4064
|
});
|
|
4061
4065
|
}
|
|
4062
4066
|
return new (n || (n = Promise))(function(s, o) {
|
|
4063
|
-
function a(
|
|
4067
|
+
function a(d) {
|
|
4064
4068
|
try {
|
|
4065
|
-
|
|
4069
|
+
c(r.next(d));
|
|
4066
4070
|
} catch (f) {
|
|
4067
4071
|
o(f);
|
|
4068
4072
|
}
|
|
4069
4073
|
}
|
|
4070
|
-
function u(
|
|
4074
|
+
function u(d) {
|
|
4071
4075
|
try {
|
|
4072
|
-
|
|
4076
|
+
c(r.throw(d));
|
|
4073
4077
|
} catch (f) {
|
|
4074
4078
|
o(f);
|
|
4075
4079
|
}
|
|
4076
4080
|
}
|
|
4077
|
-
function d
|
|
4078
|
-
|
|
4081
|
+
function c(d) {
|
|
4082
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
4079
4083
|
}
|
|
4080
|
-
|
|
4084
|
+
c((r = r.apply(t, e || [])).next());
|
|
4081
4085
|
});
|
|
4082
4086
|
};
|
|
4083
4087
|
function Su(t, e) {
|
|
@@ -4130,11 +4134,11 @@ function Au(t, e) {
|
|
|
4130
4134
|
var n, r, i, s;
|
|
4131
4135
|
const o = {};
|
|
4132
4136
|
for (const { action: a, triple: u } of e) {
|
|
4133
|
-
const [
|
|
4137
|
+
const [c, d, f] = u, l = (r = (n = t.attrs[d]) === null || n === void 0 ? void 0 : n["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
|
|
4134
4138
|
if (!l)
|
|
4135
4139
|
continue;
|
|
4136
|
-
const p = (i = o[
|
|
4137
|
-
o[
|
|
4140
|
+
const p = (i = o[c]) !== null && i !== void 0 ? i : {};
|
|
4141
|
+
o[c] = p;
|
|
4138
4142
|
const y = (s = p[l]) !== null && s !== void 0 ? s : {};
|
|
4139
4143
|
switch (p[l] = y, a) {
|
|
4140
4144
|
case "added":
|
|
@@ -4146,8 +4150,8 @@ function Au(t, e) {
|
|
|
4146
4150
|
}
|
|
4147
4151
|
}
|
|
4148
4152
|
for (const a of Object.keys(o)) {
|
|
4149
|
-
const { oldValue: u, newValue:
|
|
4150
|
-
u ===
|
|
4153
|
+
const { oldValue: u, newValue: c } = o[a];
|
|
4154
|
+
u === c && delete o[a];
|
|
4151
4155
|
}
|
|
4152
4156
|
return o;
|
|
4153
4157
|
}
|
|
@@ -4256,12 +4260,12 @@ class Cu {
|
|
|
4256
4260
|
});
|
|
4257
4261
|
return;
|
|
4258
4262
|
}
|
|
4259
|
-
const
|
|
4263
|
+
const c = Object.keys(e)[0], d = ((a = (o = e[c]) === null || o === void 0 ? void 0 : o.$) === null || a === void 0 ? void 0 : a.order) || { serverCreatedAt: "asc" }, [f, l] = Object.entries(d)[0];
|
|
4260
4264
|
this.subs.updateInPlace((p) => {
|
|
4261
4265
|
p[n] = {
|
|
4262
4266
|
query: e,
|
|
4263
4267
|
hash: n,
|
|
4264
|
-
table:
|
|
4268
|
+
table: c,
|
|
4265
4269
|
orderDirection: l,
|
|
4266
4270
|
orderField: f,
|
|
4267
4271
|
createdAt: Date.now(),
|
|
@@ -4312,19 +4316,19 @@ class Cu {
|
|
|
4312
4316
|
attrs: this.createStore([]).attrs
|
|
4313
4317
|
};
|
|
4314
4318
|
a.values = u;
|
|
4315
|
-
const
|
|
4316
|
-
for (const
|
|
4317
|
-
const f = this.createStore(
|
|
4319
|
+
const c = u.entities;
|
|
4320
|
+
for (const d of i) {
|
|
4321
|
+
const f = this.createStore(d);
|
|
4318
4322
|
u.attrs = f.attrs;
|
|
4319
4323
|
const l = Zt(a, f);
|
|
4320
|
-
|
|
4324
|
+
c.push({
|
|
4321
4325
|
store: f,
|
|
4322
4326
|
entity: l,
|
|
4323
4327
|
serverCreatedAt: Hr(a, f, l.id)
|
|
4324
4328
|
}), o.push(l);
|
|
4325
4329
|
}
|
|
4326
|
-
this.subs.updateInPlace((
|
|
4327
|
-
|
|
4330
|
+
this.subs.updateInPlace((d) => {
|
|
4331
|
+
d[s] = a, d[s].updatedAt = Date.now();
|
|
4328
4332
|
}), a.values && this.notifyCbs(s, {
|
|
4329
4333
|
type: ve.InitialSyncBatch,
|
|
4330
4334
|
data: wt(a, a.values.entities),
|
|
@@ -4372,12 +4376,12 @@ class Cu {
|
|
|
4372
4376
|
this.log.error("Missing state for sub", a, e);
|
|
4373
4377
|
return;
|
|
4374
4378
|
}
|
|
4375
|
-
for (const
|
|
4376
|
-
if (u.txId && u.txId >=
|
|
4379
|
+
for (const c of e.txes) {
|
|
4380
|
+
if (u.txId && u.txId >= c["tx-id"])
|
|
4377
4381
|
continue;
|
|
4378
|
-
u.txId =
|
|
4379
|
-
const
|
|
4380
|
-
for (const g of
|
|
4382
|
+
u.txId = c["tx-id"];
|
|
4383
|
+
const d = [], f = {};
|
|
4384
|
+
for (const g of c.changes) {
|
|
4381
4385
|
const m = (n = f[g.triple[0]]) !== null && n !== void 0 ? n : [];
|
|
4382
4386
|
f[g.triple[0]] = m, m.push(g);
|
|
4383
4387
|
}
|
|
@@ -4397,7 +4401,7 @@ class Cu {
|
|
|
4397
4401
|
oldEntity: S.entity,
|
|
4398
4402
|
newEntity: I,
|
|
4399
4403
|
changedFields: x || {}
|
|
4400
|
-
}), S.entity = I) :
|
|
4404
|
+
}), S.entity = I) : d.push(E), delete f[g];
|
|
4401
4405
|
continue e;
|
|
4402
4406
|
}
|
|
4403
4407
|
}
|
|
@@ -4421,7 +4425,7 @@ class Cu {
|
|
|
4421
4425
|
}), b.push(S);
|
|
4422
4426
|
}
|
|
4423
4427
|
const _ = [];
|
|
4424
|
-
for (const g of
|
|
4428
|
+
for (const g of d.sort().reverse())
|
|
4425
4429
|
_.push(p[g].entity), p.splice(g, 1);
|
|
4426
4430
|
const w = ju(a, this.createStore);
|
|
4427
4431
|
ku(a, w, p), this.notifyCbs(o, {
|
|
@@ -4432,8 +4436,8 @@ class Cu {
|
|
|
4432
4436
|
updated: y
|
|
4433
4437
|
});
|
|
4434
4438
|
}
|
|
4435
|
-
this.subs.updateInPlace((
|
|
4436
|
-
|
|
4439
|
+
this.subs.updateInPlace((c) => {
|
|
4440
|
+
c[o] = a, c[o].updatedAt = Date.now();
|
|
4437
4441
|
});
|
|
4438
4442
|
}
|
|
4439
4443
|
clearSubscriptionData(e, n) {
|
|
@@ -4472,24 +4476,24 @@ var F = function(t, e, n, r) {
|
|
|
4472
4476
|
});
|
|
4473
4477
|
}
|
|
4474
4478
|
return new (n || (n = Promise))(function(s, o) {
|
|
4475
|
-
function a(
|
|
4479
|
+
function a(d) {
|
|
4476
4480
|
try {
|
|
4477
|
-
|
|
4481
|
+
c(r.next(d));
|
|
4478
4482
|
} catch (f) {
|
|
4479
4483
|
o(f);
|
|
4480
4484
|
}
|
|
4481
4485
|
}
|
|
4482
|
-
function u(
|
|
4486
|
+
function u(d) {
|
|
4483
4487
|
try {
|
|
4484
|
-
|
|
4488
|
+
c(r.throw(d));
|
|
4485
4489
|
} catch (f) {
|
|
4486
4490
|
o(f);
|
|
4487
4491
|
}
|
|
4488
4492
|
}
|
|
4489
|
-
function d
|
|
4490
|
-
|
|
4493
|
+
function c(d) {
|
|
4494
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
4491
4495
|
}
|
|
4492
|
-
|
|
4496
|
+
c((r = r.apply(t, e || [])).next());
|
|
4493
4497
|
});
|
|
4494
4498
|
}, Pu = function(t, e) {
|
|
4495
4499
|
var n = {};
|
|
@@ -4573,39 +4577,39 @@ function Zr(t) {
|
|
|
4573
4577
|
class qu {
|
|
4574
4578
|
constructor(e, n = Ki, r = qi, i, s) {
|
|
4575
4579
|
var o, a, u;
|
|
4576
|
-
if (this._isOnline = !0, this._isShutdown = !1, this.status = le.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 = (
|
|
4580
|
+
if (this._isOnline = !0, this._isShutdown = !1, this.status = le.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) => {
|
|
4577
4581
|
var l, p;
|
|
4578
|
-
switch (
|
|
4582
|
+
switch (c) {
|
|
4579
4583
|
case "pendingMutations": {
|
|
4580
|
-
const y = (l =
|
|
4581
|
-
return (
|
|
4584
|
+
const y = (l = d == null ? void 0 : d.entries()) !== null && l !== void 0 ? l : [], b = (p = f == null ? void 0 : f.entries()) !== null && p !== void 0 ? p : [], _ = new Map([...y, ...b]);
|
|
4585
|
+
return (d ? this._rewriteMutationsSorted(this.attrs, d) : []).forEach(([g, m]) => {
|
|
4582
4586
|
var E;
|
|
4583
4587
|
!(!((E = f == null ? void 0 : f.pendingMutations) === null || E === void 0) && E.has(g)) && !m["tx-id"] && this._sendMutation(g, m);
|
|
4584
4588
|
}), _;
|
|
4585
4589
|
}
|
|
4586
4590
|
default:
|
|
4587
|
-
return f ||
|
|
4591
|
+
return f || d;
|
|
4588
4592
|
}
|
|
4589
|
-
}, this.getPreviousResult = (
|
|
4590
|
-
var
|
|
4591
|
-
const f = z(
|
|
4592
|
-
return (
|
|
4593
|
-
}, this.notifyOne = (
|
|
4594
|
-
var
|
|
4595
|
-
const l = (
|
|
4596
|
-
y != null && y.data && (this._dataForQueryCache[
|
|
4597
|
-
}, this.notifyOneQueryOnce = (
|
|
4598
|
-
var
|
|
4599
|
-
const l = (
|
|
4593
|
+
}, this.getPreviousResult = (c) => {
|
|
4594
|
+
var d;
|
|
4595
|
+
const f = z(c);
|
|
4596
|
+
return (d = this.dataForQuery(f)) === null || d === void 0 ? void 0 : d.data;
|
|
4597
|
+
}, this.notifyOne = (c) => {
|
|
4598
|
+
var d, f;
|
|
4599
|
+
const l = (d = this.queryCbs[c]) !== null && d !== void 0 ? d : [], p = (f = this._dataForQueryCache[c]) === null || f === void 0 ? void 0 : f.data, y = this.dataForQuery(c);
|
|
4600
|
+
y != null && y.data && (this._dataForQueryCache[c] = y, !Ot(y.data, p) && l.forEach((b) => b.cb(y.data)));
|
|
4601
|
+
}, this.notifyOneQueryOnce = (c) => {
|
|
4602
|
+
var d, f;
|
|
4603
|
+
const l = (d = this.queryOnceDfds[c]) !== null && d !== void 0 ? d : [], p = (f = this.dataForQuery(c)) === null || f === void 0 ? void 0 : f.data;
|
|
4600
4604
|
l.forEach((y) => {
|
|
4601
|
-
this._completeQueryOnce(y.q,
|
|
4605
|
+
this._completeQueryOnce(y.q, c, y.dfd), y.dfd.resolve(p);
|
|
4602
4606
|
});
|
|
4603
|
-
}, this.notifyQueryError = (
|
|
4604
|
-
(this.queryCbs[
|
|
4605
|
-
}, this.pushTx = (
|
|
4606
|
-
this.config.disableValidation || mu(
|
|
4607
|
+
}, this.notifyQueryError = (c, d) => {
|
|
4608
|
+
(this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
|
|
4609
|
+
}, this.pushTx = (c) => {
|
|
4610
|
+
this.config.disableValidation || mu(c, this.config.schema);
|
|
4607
4611
|
try {
|
|
4608
|
-
const
|
|
4612
|
+
const d = Wa({
|
|
4609
4613
|
attrs: this.optimisticAttrs(),
|
|
4610
4614
|
schema: this.config.schema,
|
|
4611
4615
|
stores: Object.values(this.querySubs.currentValue).map((f) => {
|
|
@@ -4613,17 +4617,17 @@ class qu {
|
|
|
4613
4617
|
return (l = f == null ? void 0 : f.result) === null || l === void 0 ? void 0 : l.store;
|
|
4614
4618
|
}),
|
|
4615
4619
|
useDateObjects: this.config.useDateObjects
|
|
4616
|
-
},
|
|
4617
|
-
return this.pushOps(
|
|
4618
|
-
} catch (
|
|
4619
|
-
return this.pushOps([],
|
|
4620
|
+
}, c);
|
|
4621
|
+
return this.pushOps(d);
|
|
4622
|
+
} catch (d) {
|
|
4623
|
+
return this.pushOps([], d);
|
|
4620
4624
|
}
|
|
4621
|
-
}, this.pushOps = (
|
|
4625
|
+
}, this.pushOps = (c, d) => {
|
|
4622
4626
|
const f = K(), l = [...this._pendingMutations().values()], p = Math.max(0, ...l.map((_) => _.order || 0)) + 1, y = {
|
|
4623
4627
|
op: "transact",
|
|
4624
|
-
"tx-steps":
|
|
4628
|
+
"tx-steps": c,
|
|
4625
4629
|
created: Date.now(),
|
|
4626
|
-
error:
|
|
4630
|
+
error: d,
|
|
4627
4631
|
order: p
|
|
4628
4632
|
};
|
|
4629
4633
|
this._updatePendingMutations((_) => {
|
|
@@ -4631,10 +4635,10 @@ class qu {
|
|
|
4631
4635
|
});
|
|
4632
4636
|
const b = new Lr();
|
|
4633
4637
|
return this.mutationDeferredStore.set(f, b), this._sendMutation(f, y), this.notifyAll(), b.promise;
|
|
4634
|
-
}, this._transportOnOpen = (
|
|
4635
|
-
const
|
|
4636
|
-
if (this._transport !==
|
|
4637
|
-
this._log.info("[socket][open]",
|
|
4638
|
+
}, this._transportOnOpen = (c) => {
|
|
4639
|
+
const d = c.target;
|
|
4640
|
+
if (this._transport !== d) {
|
|
4641
|
+
this._log.info("[socket][open]", d.id, "skip; this is no longer the current transport");
|
|
4638
4642
|
return;
|
|
4639
4643
|
}
|
|
4640
4644
|
this._log.info("[socket][open]", this._transport.id), this._setStatus(le.OPENED), this.getCurrentUser().then((f) => {
|
|
@@ -4652,26 +4656,26 @@ class qu {
|
|
|
4652
4656
|
"__admin-token": this.config.__adminToken
|
|
4653
4657
|
});
|
|
4654
4658
|
}).catch((f) => {
|
|
4655
|
-
this._log.error("[socket][error]",
|
|
4659
|
+
this._log.error("[socket][error]", d.id, f);
|
|
4656
4660
|
});
|
|
4657
|
-
}, this._transportOnMessage = (
|
|
4658
|
-
const
|
|
4659
|
-
if (this._transport !==
|
|
4660
|
-
this._log.info("[socket][message]",
|
|
4661
|
+
}, this._transportOnMessage = (c) => {
|
|
4662
|
+
const d = c.target, f = c.message;
|
|
4663
|
+
if (this._transport !== d) {
|
|
4664
|
+
this._log.info("[socket][message]", d.id, f, "skip; this is no longer the current transport");
|
|
4661
4665
|
return;
|
|
4662
4666
|
}
|
|
4663
|
-
if (!this._wsOk &&
|
|
4664
|
-
for (const l of
|
|
4665
|
-
this._handleReceive(
|
|
4667
|
+
if (!this._wsOk && d.type === "ws" && (this._wsOk = !0), this._transportType = "ws", Array.isArray(c.message))
|
|
4668
|
+
for (const l of c.message)
|
|
4669
|
+
this._handleReceive(d.id, l);
|
|
4666
4670
|
else
|
|
4667
|
-
this._handleReceive(
|
|
4668
|
-
}, this._transportOnError = (
|
|
4669
|
-
const
|
|
4670
|
-
if (this._transport !==
|
|
4671
|
-
this._log.info("[socket][error]",
|
|
4671
|
+
this._handleReceive(d.id, c.message);
|
|
4672
|
+
}, this._transportOnError = (c) => {
|
|
4673
|
+
const d = c.target;
|
|
4674
|
+
if (this._transport !== d) {
|
|
4675
|
+
this._log.info("[socket][error]", d.id, "skip; this is no longer the current transport");
|
|
4672
4676
|
return;
|
|
4673
4677
|
}
|
|
4674
|
-
this._log.error("[socket][error]",
|
|
4678
|
+
this._log.error("[socket][error]", d.id, c);
|
|
4675
4679
|
}, this._scheduleReconnect = () => {
|
|
4676
4680
|
!this._wsOk && this._transportType !== "sse" && (this._transportType = "sse", this._reconnectTimeoutMs = 0), setTimeout(() => {
|
|
4677
4681
|
if (this._reconnectTimeoutMs = Math.min(this._reconnectTimeoutMs + 1e3, 1e4), !this._isOnline) {
|
|
@@ -4680,29 +4684,29 @@ class qu {
|
|
|
4680
4684
|
}
|
|
4681
4685
|
this._startSocket();
|
|
4682
4686
|
}, this._reconnectTimeoutMs);
|
|
4683
|
-
}, this._transportOnClose = (
|
|
4684
|
-
const
|
|
4685
|
-
if (this._transport !==
|
|
4686
|
-
this._log.info("[socket][close]",
|
|
4687
|
+
}, this._transportOnClose = (c) => {
|
|
4688
|
+
const d = c.target;
|
|
4689
|
+
if (this._transport !== d) {
|
|
4690
|
+
this._log.info("[socket][close]", d.id, "skip; this is no longer the current transport");
|
|
4687
4691
|
return;
|
|
4688
4692
|
}
|
|
4689
4693
|
this._setStatus(le.CLOSED);
|
|
4690
4694
|
for (const f of Object.values(this._rooms))
|
|
4691
4695
|
f.isConnected = !1;
|
|
4692
4696
|
if (this._isShutdown) {
|
|
4693
|
-
this._log.info("[socket][close]",
|
|
4697
|
+
this._log.info("[socket][close]", d.id, "Reactor has been shut down and will not reconnect");
|
|
4694
4698
|
return;
|
|
4695
4699
|
}
|
|
4696
|
-
this._log.info("[socket][close]",
|
|
4700
|
+
this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
|
|
4697
4701
|
}, this._EventSource = s, this.config = Object.assign(Object.assign({}, xu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : Mu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : Ru, this._log = lu(e.verbose || Vn || Wi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Bn }), this.config.schema && (this._linkIndex = Nr(this.config.schema)), !!Du()) {
|
|
4698
4702
|
if (!e.appId)
|
|
4699
4703
|
throw new Error("Instant must be initialized with an appId.");
|
|
4700
4704
|
if (!Fe(e.appId))
|
|
4701
4705
|
throw new Error(`Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`);
|
|
4702
|
-
typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", (
|
|
4703
|
-
var
|
|
4706
|
+
typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", (c) => F(this, void 0, void 0, function* () {
|
|
4707
|
+
var d;
|
|
4704
4708
|
try {
|
|
4705
|
-
if (((
|
|
4709
|
+
if (((d = c.data) === null || d === void 0 ? void 0 : d.type) === "auth") {
|
|
4706
4710
|
const f = yield this.getCurrentUser();
|
|
4707
4711
|
this.updateUser(f.user);
|
|
4708
4712
|
}
|
|
@@ -4711,9 +4715,9 @@ class qu {
|
|
|
4711
4715
|
}
|
|
4712
4716
|
}))), this._initStorage(n), this._syncTable = new Cu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
|
|
4713
4717
|
useDateObjects: this.config.useDateObjects
|
|
4714
|
-
}, this._log, (
|
|
4715
|
-
this._isOnline =
|
|
4716
|
-
|
|
4718
|
+
}, this._log, (c) => Et(this.attrs, c, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((c) => {
|
|
4719
|
+
this._isOnline = c, this._startSocket(), r.listen((d) => {
|
|
4720
|
+
d !== this._isOnline && (this._log.info("[network] online =", d), this._isOnline = d, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", le.CLOSED), this._setStatus(le.CLOSED)));
|
|
4717
4721
|
});
|
|
4718
4722
|
}), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
|
|
4719
4723
|
}
|
|
@@ -4804,13 +4808,13 @@ class qu {
|
|
|
4804
4808
|
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];
|
|
4805
4809
|
if (this._broadcastQueue[e] = [], i && this._trySetPresence(e, i), s)
|
|
4806
4810
|
for (const o of s) {
|
|
4807
|
-
const { topic: a, roomType: u, data:
|
|
4808
|
-
this._tryBroadcast(e, u, a,
|
|
4811
|
+
const { topic: a, roomType: u, data: c } = o;
|
|
4812
|
+
this._tryBroadcast(e, u, a, c);
|
|
4809
4813
|
}
|
|
4810
4814
|
}
|
|
4811
4815
|
_handleReceive(e, n) {
|
|
4812
4816
|
var r, i, s, o, a, u;
|
|
4813
|
-
const
|
|
4817
|
+
const c = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
|
|
4814
4818
|
switch (Jr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
|
|
4815
4819
|
case "init-ok": {
|
|
4816
4820
|
this._setStatus(le.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
|
|
@@ -4828,7 +4832,7 @@ class qu {
|
|
|
4828
4832
|
const { q: l, result: p } = n, y = z(l);
|
|
4829
4833
|
if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
|
|
4830
4834
|
break;
|
|
4831
|
-
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"], _ = (u = (a = p == null ? void 0 : p[0]) === null || a === void 0 ? void 0 : a.data) === null || u === void 0 ? void 0 : u.aggregate, w = Fr(p), g = Et(this.attrs, w,
|
|
4835
|
+
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"], _ = (u = (a = p == null ? void 0 : p[0]) === null || a === void 0 ? void 0 : a.data) === null || u === void 0 ? void 0 : u.aggregate, w = Fr(p), g = Et(this.attrs, w, c, this._linkIndex, this.config.useDateObjects);
|
|
4832
4836
|
this.querySubs.updateInPlace((m) => {
|
|
4833
4837
|
if (!m[y]) {
|
|
4834
4838
|
this._log.info("Missing value in querySubs", { hash: y, q: l });
|
|
@@ -4868,7 +4872,7 @@ class qu {
|
|
|
4868
4872
|
});
|
|
4869
4873
|
const _ = Zr(b.entries()), w = l.map((g) => {
|
|
4870
4874
|
var m, E, S, I;
|
|
4871
|
-
const x = g["instaql-query"], B = g["instaql-result"], Ve = z(x), lt = Fr(B), Ft = Et(this.attrs, lt,
|
|
4875
|
+
const x = g["instaql-query"], B = g["instaql-result"], Ve = z(x), lt = Fr(B), Ft = Et(this.attrs, lt, c, this._linkIndex, this.config.useDateObjects), Nt = this._applyOptimisticUpdates(Ft, _, y), ht = (E = (m = B == null ? void 0 : B[0]) === null || m === void 0 ? void 0 : m.data) === null || E === void 0 ? void 0 : E["page-info"], ce = (I = (S = B == null ? void 0 : B[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
|
|
4872
4876
|
return { q: x, hash: Ve, store: Nt, pageInfo: ht, aggregate: ce };
|
|
4873
4877
|
});
|
|
4874
4878
|
w.forEach(({ hash: g, q: m, store: E, pageInfo: S, aggregate: I }) => {
|
|
@@ -4927,8 +4931,8 @@ class qu {
|
|
|
4927
4931
|
break;
|
|
4928
4932
|
}
|
|
4929
4933
|
case "join-room-error":
|
|
4930
|
-
const
|
|
4931
|
-
f && (f.error = n.error), this._notifyPresenceSubs(
|
|
4934
|
+
const d = n["room-id"], f = this._rooms[d];
|
|
4935
|
+
f && (f.error = n.error), this._notifyPresenceSubs(d);
|
|
4932
4936
|
break;
|
|
4933
4937
|
case "error":
|
|
4934
4938
|
this._handleReceiveError(n);
|
|
@@ -4968,18 +4972,18 @@ class qu {
|
|
|
4968
4972
|
_handleReceiveError(e) {
|
|
4969
4973
|
var n, r, i, s, o, a, u;
|
|
4970
4974
|
console.log("error", e);
|
|
4971
|
-
const
|
|
4972
|
-
this._inFlightMutationEventIds.delete(
|
|
4973
|
-
const
|
|
4975
|
+
const c = e["client-event-id"];
|
|
4976
|
+
this._inFlightMutationEventIds.delete(c);
|
|
4977
|
+
const d = this._pendingMutations().get(c), f = {
|
|
4974
4978
|
message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa."
|
|
4975
4979
|
};
|
|
4976
|
-
if (e.hint && (f.hint = e.hint),
|
|
4977
|
-
this._handleMutationError("error",
|
|
4980
|
+
if (e.hint && (f.hint = e.hint), d) {
|
|
4981
|
+
this._handleMutationError("error", c, e);
|
|
4978
4982
|
return;
|
|
4979
4983
|
}
|
|
4980
4984
|
if (!((n = e["original-event"]) === null || n === void 0) && n.hasOwnProperty("q") && ((r = e["original-event"]) === null || r === void 0 ? void 0 : r.op) === "add-query") {
|
|
4981
4985
|
const y = (i = e["original-event"]) === null || i === void 0 ? void 0 : i.q, b = z(y);
|
|
4982
|
-
this.notifyQueryError(z(y), f), this.notifyQueryOnceError(y, b,
|
|
4986
|
+
this.notifyQueryError(z(y), f), this.notifyQueryOnceError(y, b, c, f);
|
|
4983
4987
|
return;
|
|
4984
4988
|
}
|
|
4985
4989
|
if (((s = e["original-event"]) === null || s === void 0 ? void 0 : s.op) === "init") {
|
|
@@ -5077,17 +5081,17 @@ class qu {
|
|
|
5077
5081
|
return n;
|
|
5078
5082
|
if (!n)
|
|
5079
5083
|
return /* @__PURE__ */ new Map();
|
|
5080
|
-
const i = (
|
|
5081
|
-
const [f, l, p] =
|
|
5084
|
+
const i = (d) => {
|
|
5085
|
+
const [f, l, p] = d["forward-identity"];
|
|
5082
5086
|
return V(e, l, p);
|
|
5083
|
-
}, s = (
|
|
5084
|
-
const [f, l, p] =
|
|
5087
|
+
}, s = (d) => {
|
|
5088
|
+
const [f, l, p] = d["forward-identity"];
|
|
5085
5089
|
return Ae(e, l, p);
|
|
5086
5090
|
}, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
|
|
5087
5091
|
let a = !1;
|
|
5088
|
-
const u = (
|
|
5092
|
+
const u = (d, f) => {
|
|
5089
5093
|
const l = [];
|
|
5090
|
-
for (const p of
|
|
5094
|
+
for (const p of d) {
|
|
5091
5095
|
const [y] = p;
|
|
5092
5096
|
if (y === "add-attr") {
|
|
5093
5097
|
const [_, w] = p, g = i(w);
|
|
@@ -5110,11 +5114,11 @@ class qu {
|
|
|
5110
5114
|
const b = a ? Ta(o, p) : p;
|
|
5111
5115
|
l.push(b);
|
|
5112
5116
|
}
|
|
5113
|
-
return a ? l :
|
|
5114
|
-
},
|
|
5115
|
-
for (const [
|
|
5116
|
-
|
|
5117
|
-
return a ?
|
|
5117
|
+
return a ? l : d;
|
|
5118
|
+
}, c = /* @__PURE__ */ new Map();
|
|
5119
|
+
for (const [d, f] of n.entries())
|
|
5120
|
+
c.set(d, Object.assign(Object.assign({}, f), { "tx-steps": u(f["tx-steps"], f["tx-id"]) }));
|
|
5121
|
+
return a ? c : n;
|
|
5118
5122
|
}
|
|
5119
5123
|
_rewriteMutationsSorted(e, n) {
|
|
5120
5124
|
return Zr(this._rewriteMutations(e, n).entries());
|
|
@@ -5128,8 +5132,8 @@ class qu {
|
|
|
5128
5132
|
if (a === "add-attr")
|
|
5129
5133
|
i.push(u);
|
|
5130
5134
|
else if (a === "update-attr" && u.id && (!((e = this.attrs) === null || e === void 0) && e[u.id])) {
|
|
5131
|
-
const
|
|
5132
|
-
i.push(
|
|
5135
|
+
const c = Object.assign(Object.assign({}, this.attrs[u.id]), u);
|
|
5136
|
+
i.push(c);
|
|
5133
5137
|
}
|
|
5134
5138
|
const s = [
|
|
5135
5139
|
...Object.values(this.attrs || {}),
|
|
@@ -5147,10 +5151,10 @@ class qu {
|
|
|
5147
5151
|
const r = this.querySubs.version(), i = this.querySubs.currentValue, s = this.kv.version(), o = this._pendingMutations(), { q: a, result: u } = i[e] || {};
|
|
5148
5152
|
if (!u)
|
|
5149
5153
|
return;
|
|
5150
|
-
const
|
|
5151
|
-
if (
|
|
5152
|
-
return
|
|
5153
|
-
const { store:
|
|
5154
|
+
const c = this._dataForQueryCache[e];
|
|
5155
|
+
if (c && r === c.querySubVersion && s === c.pendingMutationsVersion)
|
|
5156
|
+
return c;
|
|
5157
|
+
const { store: d, pageInfo: f, aggregate: l, processedTxId: p } = u, y = this._rewriteMutationsSorted(d.attrs, o), b = this._applyOptimisticUpdates(d, y, p);
|
|
5154
5158
|
return { data: Ui({ store: b, pageInfo: f, aggregate: l }, a), querySubVersion: r, pendingMutationsVersion: s };
|
|
5155
5159
|
}
|
|
5156
5160
|
_applyOptimisticUpdates(e, n, r) {
|
|
@@ -5337,13 +5341,13 @@ class qu {
|
|
|
5337
5341
|
return null;
|
|
5338
5342
|
this._replaceUrlAfterOAuth();
|
|
5339
5343
|
try {
|
|
5340
|
-
const u = yield this._getCurrentUser(),
|
|
5344
|
+
const u = yield this._getCurrentUser(), c = (u == null ? void 0 : u.type) === "guest", { user: d } = yield Dr({
|
|
5341
5345
|
apiURI: this.config.apiURI,
|
|
5342
5346
|
appId: this.config.appId,
|
|
5343
5347
|
code: a,
|
|
5344
|
-
refreshToken:
|
|
5348
|
+
refreshToken: c ? u.refresh_token : void 0
|
|
5345
5349
|
});
|
|
5346
|
-
return this.setCurrentUser(
|
|
5350
|
+
return this.setCurrentUser(d), null;
|
|
5347
5351
|
} catch (u) {
|
|
5348
5352
|
return ((e = u == null ? void 0 : u.body) === null || e === void 0 ? void 0 : e.type) === "record-not-found" && ((r = (n = u == null ? void 0 : u.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 = u == null ? void 0 : u.body) === null || i === void 0 ? void 0 : i.message) || "Error logging in." } };
|
|
5349
5353
|
}
|
|
@@ -5651,8 +5655,8 @@ class qu {
|
|
|
5651
5655
|
r.initialPresence || r.initialData
|
|
5652
5656
|
), o = Object.assign(Object.assign({}, r), { roomId: n, cb: i, prev: null });
|
|
5653
5657
|
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), () => {
|
|
5654
|
-
var a, u,
|
|
5655
|
-
this._presence[n].handlers = (
|
|
5658
|
+
var a, u, c;
|
|
5659
|
+
this._presence[n].handlers = (c = (u = (a = this._presence[n]) === null || a === void 0 ? void 0 : a.handlers) === null || u === void 0 ? void 0 : u.filter((d) => d !== o)) !== null && c !== void 0 ? c : [], s();
|
|
5656
5660
|
};
|
|
5657
5661
|
}
|
|
5658
5662
|
_notifyPresenceSubs(e) {
|
|
@@ -5668,22 +5672,22 @@ class qu {
|
|
|
5668
5672
|
_patchPresencePeers(e, n) {
|
|
5669
5673
|
var r, i, s;
|
|
5670
5674
|
const o = ((i = (r = this._presence[e]) === null || r === void 0 ? void 0 : r.result) === null || i === void 0 ? void 0 : i.peers) || {};
|
|
5671
|
-
let a = Object.fromEntries(Object.entries(o).map(([
|
|
5675
|
+
let a = Object.fromEntries(Object.entries(o).map(([c, d]) => [c, { data: d }]));
|
|
5672
5676
|
(s = this._presence[e]) === null || s === void 0 || s.result;
|
|
5673
|
-
const u = Pt(a, (
|
|
5674
|
-
for (let [
|
|
5677
|
+
const u = Pt(a, (c) => {
|
|
5678
|
+
for (let [d, f, l] of n)
|
|
5675
5679
|
switch (f) {
|
|
5676
5680
|
case "+":
|
|
5677
|
-
Ks(
|
|
5681
|
+
Ks(c, d, l);
|
|
5678
5682
|
break;
|
|
5679
5683
|
case "r":
|
|
5680
|
-
Sr(
|
|
5684
|
+
Sr(c, d, l);
|
|
5681
5685
|
break;
|
|
5682
5686
|
case "-":
|
|
5683
|
-
wi(
|
|
5687
|
+
wi(c, d);
|
|
5684
5688
|
break;
|
|
5685
5689
|
}
|
|
5686
|
-
delete
|
|
5690
|
+
delete c[this._sessionId];
|
|
5687
5691
|
});
|
|
5688
5692
|
this._setPresencePeers(e, u);
|
|
5689
5693
|
}
|
|
@@ -5726,8 +5730,8 @@ class qu {
|
|
|
5726
5730
|
_notifyBroadcastSubs(e, n, r) {
|
|
5727
5731
|
var i, s, o;
|
|
5728
5732
|
(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((a) => {
|
|
5729
|
-
var u,
|
|
5730
|
-
const y = (u = r.data) === null || u === void 0 ? void 0 : u.data, b = r.data["peer-id"] === this._sessionId ? (
|
|
5733
|
+
var u, c, d, f, l, p;
|
|
5734
|
+
const y = (u = r.data) === null || u === void 0 ? void 0 : u.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"]];
|
|
5731
5735
|
return a(y, b);
|
|
5732
5736
|
});
|
|
5733
5737
|
}
|
|
@@ -5823,9 +5827,9 @@ function Zi(t, e) {
|
|
|
5823
5827
|
entityName: u.forward.on,
|
|
5824
5828
|
cardinality: u.reverse.has
|
|
5825
5829
|
};
|
|
5826
|
-
return Object.fromEntries(Object.entries(t).map(([u,
|
|
5830
|
+
return Object.fromEntries(Object.entries(t).map(([u, c]) => [
|
|
5827
5831
|
u,
|
|
5828
|
-
new Ut(
|
|
5832
|
+
new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[u]), o.rev[u]))
|
|
5829
5833
|
]));
|
|
5830
5834
|
}
|
|
5831
5835
|
function Ju({ entities: t, links: e, rooms: n }) {
|
|
@@ -5858,12 +5862,12 @@ let mt;
|
|
|
5858
5862
|
function Zu(t, e) {
|
|
5859
5863
|
mt == null || mt.dispose();
|
|
5860
5864
|
const n = ic(e), r = tc(e, a), i = ec(Xu(t));
|
|
5861
|
-
function s(
|
|
5865
|
+
function s(d) {
|
|
5862
5866
|
var f;
|
|
5863
|
-
|
|
5867
|
+
d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && a();
|
|
5864
5868
|
}
|
|
5865
|
-
function o(
|
|
5866
|
-
const f =
|
|
5869
|
+
function o(d) {
|
|
5870
|
+
const f = d.shiftKey && d.ctrlKey && d.key === "0", l = d.key === "Escape" || d.key === "Esc";
|
|
5867
5871
|
(f || l && n.isVisible()) && a();
|
|
5868
5872
|
}
|
|
5869
5873
|
function a() {
|
|
@@ -5872,12 +5876,12 @@ function Zu(t, e) {
|
|
|
5872
5876
|
function u() {
|
|
5873
5877
|
n.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", s);
|
|
5874
5878
|
}
|
|
5875
|
-
function
|
|
5879
|
+
function c() {
|
|
5876
5880
|
document.body.appendChild(n.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", s), mt = {
|
|
5877
5881
|
dispose: u
|
|
5878
5882
|
};
|
|
5879
5883
|
}
|
|
5880
|
-
return
|
|
5884
|
+
return c();
|
|
5881
5885
|
}
|
|
5882
5886
|
function Xu(t) {
|
|
5883
5887
|
return `${Vn || zi ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
@@ -6171,8 +6175,8 @@ function hc(t, e, n, r, i) {
|
|
|
6171
6175
|
const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), a = mn[wn(o)];
|
|
6172
6176
|
if (a)
|
|
6173
6177
|
return lc(a, o.schema) && a._reactor.updateSchema(o.schema), a;
|
|
6174
|
-
const u = new qu(Object.assign(Object.assign(Object.assign({}, sc), o), { cardinalityInference: !!o.schema }), e || Ki, n || qi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Bn }), i),
|
|
6175
|
-
return mn[wn(o)] =
|
|
6178
|
+
const u = new qu(Object.assign(Object.assign(Object.assign({}, sc), o), { cardinalityInference: !!o.schema }), e || Ki, n || qi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Bn }), i), c = new fc(u);
|
|
6179
|
+
return mn[wn(o)] = c, pc(o.appId, o.devtool), c;
|
|
6176
6180
|
}
|
|
6177
6181
|
function pc(t, e) {
|
|
6178
6182
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
@@ -6195,11 +6199,11 @@ function yc() {
|
|
|
6195
6199
|
if (ti) return He;
|
|
6196
6200
|
ti = 1;
|
|
6197
6201
|
var t = ci, 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 };
|
|
6198
|
-
function o(a, u,
|
|
6199
|
-
var
|
|
6200
|
-
|
|
6201
|
-
for (
|
|
6202
|
-
if (a && a.defaultProps) for (
|
|
6202
|
+
function o(a, u, c) {
|
|
6203
|
+
var d, f = {}, l = null, p = null;
|
|
6204
|
+
c !== void 0 && (l = "" + c), u.key !== void 0 && (l = "" + u.key), u.ref !== void 0 && (p = u.ref);
|
|
6205
|
+
for (d in u) r.call(u, d) && !s.hasOwnProperty(d) && (f[d] = u[d]);
|
|
6206
|
+
if (a && a.defaultProps) for (d in u = a.defaultProps, u) f[d] === void 0 && (f[d] = u[d]);
|
|
6203
6207
|
return { $$typeof: e, type: a, key: l, ref: p, props: f, _owner: i.current };
|
|
6204
6208
|
}
|
|
6205
6209
|
return He.Fragment = n, He.jsx = o, He.jsxs = o, He;
|
|
@@ -6219,7 +6223,7 @@ function bc() {
|
|
|
6219
6223
|
* LICENSE file in the root directory of this source tree.
|
|
6220
6224
|
*/
|
|
6221
6225
|
return t.NODE_ENV !== "production" && function() {
|
|
6222
|
-
var e = ci, 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"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"),
|
|
6226
|
+
var e = ci, 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"), a = Symbol.for("react.provider"), u = 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";
|
|
6223
6227
|
function w(h) {
|
|
6224
6228
|
if (h === null || typeof h != "object")
|
|
6225
6229
|
return null;
|
|
@@ -6247,7 +6251,7 @@ function bc() {
|
|
|
6247
6251
|
var S = !1, I = !1, x = !1, B = !1, Ve = !1, lt;
|
|
6248
6252
|
lt = Symbol.for("react.module.reference");
|
|
6249
6253
|
function Ft(h) {
|
|
6250
|
-
return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h ===
|
|
6254
|
+
return !!(typeof h == "string" || typeof h == "function" || h === i || h === o || Ve || h === s || h === d || h === f || B || h === y || S || I || x || typeof h == "object" && h !== null && (h.$$typeof === p || h.$$typeof === l || h.$$typeof === a || h.$$typeof === u || h.$$typeof === c || // This needs to include all possible module reference object
|
|
6251
6255
|
// types supported by any Flight configuration anywhere since
|
|
6252
6256
|
// we don't know which Flight build this will end up being used
|
|
6253
6257
|
// with.
|
|
@@ -6279,7 +6283,7 @@ function bc() {
|
|
|
6279
6283
|
return "Profiler";
|
|
6280
6284
|
case s:
|
|
6281
6285
|
return "StrictMode";
|
|
6282
|
-
case
|
|
6286
|
+
case d:
|
|
6283
6287
|
return "Suspense";
|
|
6284
6288
|
case f:
|
|
6285
6289
|
return "SuspenseList";
|
|
@@ -6292,7 +6296,7 @@ function bc() {
|
|
|
6292
6296
|
case a:
|
|
6293
6297
|
var v = h;
|
|
6294
6298
|
return ht(v._context) + ".Provider";
|
|
6295
|
-
case
|
|
6299
|
+
case c:
|
|
6296
6300
|
return Nt(h, h.render, "ForwardRef");
|
|
6297
6301
|
case l:
|
|
6298
6302
|
var O = h.displayName || null;
|
|
@@ -6475,14 +6479,14 @@ function bc() {
|
|
|
6475
6479
|
if (typeof h == "string")
|
|
6476
6480
|
return pt(h);
|
|
6477
6481
|
switch (h) {
|
|
6478
|
-
case
|
|
6482
|
+
case d:
|
|
6479
6483
|
return pt("Suspense");
|
|
6480
6484
|
case f:
|
|
6481
6485
|
return pt("SuspenseList");
|
|
6482
6486
|
}
|
|
6483
6487
|
if (typeof h == "object")
|
|
6484
6488
|
switch (h.$$typeof) {
|
|
6485
|
-
case
|
|
6489
|
+
case c:
|
|
6486
6490
|
return rs(h.render);
|
|
6487
6491
|
case l:
|
|
6488
6492
|
return bt(h.type, T, v);
|
|
@@ -6722,7 +6726,7 @@ Check the top-level render call using <` + v + ">.");
|
|
|
6722
6726
|
var v;
|
|
6723
6727
|
if (typeof T == "function")
|
|
6724
6728
|
v = T.propTypes;
|
|
6725
|
-
else if (typeof T == "object" && (T.$$typeof ===
|
|
6729
|
+
else if (typeof T == "object" && (T.$$typeof === c || // Note: Memo only checks outer props here.
|
|
6726
6730
|
// Inner props are checked in the reconciler.
|
|
6727
6731
|
T.$$typeof === l))
|
|
6728
6732
|
v = T.propTypes;
|
|
@@ -6821,16 +6825,16 @@ function ri(t) {
|
|
|
6821
6825
|
function Tc(t, e, n) {
|
|
6822
6826
|
e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
|
|
6823
6827
|
const r = e ? dc(e) : null, i = z(r), s = at(ri(t._reactor.getPreviousResult(r))), o = ge(
|
|
6824
|
-
(u) => (s.current = ri(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (
|
|
6828
|
+
(u) => (s.current = ri(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
|
|
6825
6829
|
s.current = Object.assign({
|
|
6826
|
-
isLoading: !
|
|
6830
|
+
isLoading: !d,
|
|
6827
6831
|
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6828
6832
|
data: void 0,
|
|
6829
6833
|
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6830
6834
|
pageInfo: void 0,
|
|
6831
6835
|
// @ts-expect-error: ts thinks this will always be overwritten
|
|
6832
6836
|
error: void 0
|
|
6833
|
-
},
|
|
6837
|
+
}, d), u();
|
|
6834
6838
|
}) : () => {
|
|
6835
6839
|
}),
|
|
6836
6840
|
// Build a new subscribe function if the query changes
|
|
@@ -6877,8 +6881,8 @@ function Oc(t, e = {}) {
|
|
|
6877
6881
|
isLoading: !0
|
|
6878
6882
|
};
|
|
6879
6883
|
});
|
|
6880
|
-
je(() => t.core._reactor.subscribePresence(t.type, t.id, e, (
|
|
6881
|
-
s(
|
|
6884
|
+
je(() => t.core._reactor.subscribePresence(t.type, t.id, e, (c) => {
|
|
6885
|
+
s(c);
|
|
6882
6886
|
}), [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()]);
|
|
6883
6887
|
const o = ge((u) => {
|
|
6884
6888
|
t.core._reactor.publishPresence(t.type, t.id, u);
|
|
@@ -6892,28 +6896,28 @@ function Ac(t, e, n = {}) {
|
|
|
6892
6896
|
const r = wc(), i = Se.usePresence(t, {
|
|
6893
6897
|
keys: [e]
|
|
6894
6898
|
}), s = nn(() => {
|
|
6895
|
-
var
|
|
6899
|
+
var d;
|
|
6896
6900
|
const f = t._core._reactor.getPresence(t.type, t.id);
|
|
6897
|
-
return n != null && n.writeOnly ? [] : Object.values((
|
|
6898
|
-
}, [n == null ? void 0 : n.writeOnly, i]), o = ge((
|
|
6901
|
+
return n != null && n.writeOnly ? [] : Object.values((d = f == null ? void 0 : f.peers) !== null && d !== void 0 ? d : {}).filter((l) => l[e] === !0);
|
|
6902
|
+
}, [n == null ? void 0 : n.writeOnly, i]), o = ge((d) => {
|
|
6899
6903
|
var f;
|
|
6900
6904
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
6901
|
-
[e]:
|
|
6902
|
-
}),
|
|
6905
|
+
[e]: d
|
|
6906
|
+
}), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : mc, () => {
|
|
6903
6907
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
6904
6908
|
[e]: null
|
|
6905
6909
|
});
|
|
6906
6910
|
}));
|
|
6907
|
-
}, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), a = ge((
|
|
6908
|
-
const l = !((n == null ? void 0 : n.stopOnEnter) &&
|
|
6911
|
+
}, [t.type, t.id, e, n == null ? void 0 : n.timeout, r]), a = ge((d) => {
|
|
6912
|
+
const l = !((n == null ? void 0 : n.stopOnEnter) && d.key === "Enter");
|
|
6909
6913
|
o(l);
|
|
6910
6914
|
}, [n.stopOnEnter, o]), u = ge(() => {
|
|
6911
6915
|
o(!1);
|
|
6912
|
-
}, [o]),
|
|
6916
|
+
}, [o]), c = nn(() => ({ onKeyDown: a, onBlur: u }), [a, u]);
|
|
6913
6917
|
return {
|
|
6914
6918
|
active: s,
|
|
6915
6919
|
setActive: o,
|
|
6916
|
-
inputProps:
|
|
6920
|
+
inputProps: c
|
|
6917
6921
|
};
|
|
6918
6922
|
}
|
|
6919
6923
|
const Se = {
|
|
@@ -6937,24 +6941,24 @@ var kc = function(t, e, n, r) {
|
|
|
6937
6941
|
});
|
|
6938
6942
|
}
|
|
6939
6943
|
return new (n || (n = Promise))(function(s, o) {
|
|
6940
|
-
function a(
|
|
6944
|
+
function a(d) {
|
|
6941
6945
|
try {
|
|
6942
|
-
|
|
6946
|
+
c(r.next(d));
|
|
6943
6947
|
} catch (f) {
|
|
6944
6948
|
o(f);
|
|
6945
6949
|
}
|
|
6946
6950
|
}
|
|
6947
|
-
function u(
|
|
6951
|
+
function u(d) {
|
|
6948
6952
|
try {
|
|
6949
|
-
|
|
6953
|
+
c(r.throw(d));
|
|
6950
6954
|
} catch (f) {
|
|
6951
6955
|
o(f);
|
|
6952
6956
|
}
|
|
6953
6957
|
}
|
|
6954
|
-
function d
|
|
6955
|
-
|
|
6958
|
+
function c(d) {
|
|
6959
|
+
d.done ? s(d.value) : i(d.value).then(a, u);
|
|
6956
6960
|
}
|
|
6957
|
-
|
|
6961
|
+
c((r = r.apply(t, e || [])).next());
|
|
6958
6962
|
});
|
|
6959
6963
|
};
|
|
6960
6964
|
const Cc = {
|
|
@@ -7051,8 +7055,8 @@ function Ic(t) {
|
|
|
7051
7055
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
7052
7056
|
);
|
|
7053
7057
|
const { onEvent: e = en, onError: n = en, onRetry: r = en, onComment: i } = t;
|
|
7054
|
-
let s = "", o = !0, a, u = "",
|
|
7055
|
-
function
|
|
7058
|
+
let s = "", o = !0, a, u = "", c = "";
|
|
7059
|
+
function d(b) {
|
|
7056
7060
|
const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [w, g] = Mc(`${s}${_}`);
|
|
7057
7061
|
for (const m of w)
|
|
7058
7062
|
f(m);
|
|
@@ -7078,7 +7082,7 @@ function Ic(t) {
|
|
|
7078
7082
|
function l(b, _, w) {
|
|
7079
7083
|
switch (b) {
|
|
7080
7084
|
case "event":
|
|
7081
|
-
|
|
7085
|
+
c = _;
|
|
7082
7086
|
break;
|
|
7083
7087
|
case "data":
|
|
7084
7088
|
u = `${u}${_}
|
|
@@ -7109,17 +7113,17 @@ function Ic(t) {
|
|
|
7109
7113
|
function p() {
|
|
7110
7114
|
u.length > 0 && e({
|
|
7111
7115
|
id: a,
|
|
7112
|
-
event:
|
|
7116
|
+
event: c || void 0,
|
|
7113
7117
|
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
7114
7118
|
// then remove the last character from the data buffer.
|
|
7115
7119
|
data: u.endsWith(`
|
|
7116
7120
|
`) ? u.slice(0, -1) : u
|
|
7117
|
-
}), a = void 0, u = "",
|
|
7121
|
+
}), a = void 0, u = "", c = "";
|
|
7118
7122
|
}
|
|
7119
7123
|
function y(b = {}) {
|
|
7120
|
-
s && b.consume && f(s), o = !0, a = void 0, u = "",
|
|
7124
|
+
s && b.consume && f(s), o = !0, a = void 0, u = "", c = "", s = "";
|
|
7121
7125
|
}
|
|
7122
|
-
return { feed:
|
|
7126
|
+
return { feed: d, reset: y };
|
|
7123
7127
|
}
|
|
7124
7128
|
function Mc(t) {
|
|
7125
7129
|
const e = [];
|
|
@@ -7207,17 +7211,17 @@ class jt extends EventTarget {
|
|
|
7207
7211
|
super(), N(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, N(this, J), N(this, Oe), N(this, Re), N(this, At), N(this, Rt), N(this, st), N(this, De), N(this, ot, null), N(this, _e), N(this, xe), N(this, Le, null), N(this, $e, null), N(this, et, null), N(this, En, async (s) => {
|
|
7208
7212
|
var o;
|
|
7209
7213
|
A(this, xe).reset();
|
|
7210
|
-
const { body: a, redirected: u, status:
|
|
7211
|
-
if (
|
|
7214
|
+
const { body: a, redirected: u, status: c, headers: d } = s;
|
|
7215
|
+
if (c === 204) {
|
|
7212
7216
|
he(this, se, tt).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
7213
7217
|
return;
|
|
7214
7218
|
}
|
|
7215
|
-
if (u ? $(this, Re, new URL(s.url)) : $(this, Re, void 0),
|
|
7216
|
-
he(this, se, tt).call(this, `Non-200 status code (${
|
|
7219
|
+
if (u ? $(this, Re, new URL(s.url)) : $(this, Re, void 0), c !== 200) {
|
|
7220
|
+
he(this, se, tt).call(this, `Non-200 status code (${c})`, c);
|
|
7217
7221
|
return;
|
|
7218
7222
|
}
|
|
7219
|
-
if (!(
|
|
7220
|
-
he(this, se, tt).call(this, 'Invalid content type, expected "text/event-stream"',
|
|
7223
|
+
if (!(d.get("content-type") || "").startsWith("text/event-stream")) {
|
|
7224
|
+
he(this, se, tt).call(this, 'Invalid content type, expected "text/event-stream"', c);
|
|
7221
7225
|
return;
|
|
7222
7226
|
}
|
|
7223
7227
|
if (A(this, J) === this.CLOSED)
|
|
@@ -7225,7 +7229,7 @@ class jt extends EventTarget {
|
|
|
7225
7229
|
$(this, J, this.OPEN);
|
|
7226
7230
|
const f = new Event("open");
|
|
7227
7231
|
if ((o = A(this, et)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
|
|
7228
|
-
he(this, se, tt).call(this, "Invalid response body, expected a web ReadableStream",
|
|
7232
|
+
he(this, se, tt).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
|
|
7229
7233
|
return;
|
|
7230
7234
|
}
|
|
7231
7235
|
const l = new TextDecoder(), p = a.getReader();
|
|
@@ -7430,15 +7434,15 @@ function zc({
|
|
|
7430
7434
|
children: o,
|
|
7431
7435
|
renderCursor: a,
|
|
7432
7436
|
propagate: u,
|
|
7433
|
-
zIndex:
|
|
7437
|
+
zIndex: c
|
|
7434
7438
|
}) {
|
|
7435
|
-
const
|
|
7436
|
-
keys: [
|
|
7439
|
+
const d = e || `cursors-space-default--${String(n.type)}-${n.id}`, f = n.usePresence({
|
|
7440
|
+
keys: [d]
|
|
7437
7441
|
}), l = n._core._reactor.getPresence(n.type, n.id);
|
|
7438
7442
|
function p(g, m) {
|
|
7439
7443
|
const E = m.clientX, S = m.clientY, I = (E - g.left) / g.width * 100, x = (S - g.top) / g.height * 100;
|
|
7440
7444
|
f.publishPresence({
|
|
7441
|
-
[
|
|
7445
|
+
[d]: {
|
|
7442
7446
|
x: E,
|
|
7443
7447
|
y: S,
|
|
7444
7448
|
xPercent: I,
|
|
@@ -7454,7 +7458,7 @@ function zc({
|
|
|
7454
7458
|
}
|
|
7455
7459
|
function b(g) {
|
|
7456
7460
|
f.publishPresence({
|
|
7457
|
-
[
|
|
7461
|
+
[d]: void 0
|
|
7458
7462
|
});
|
|
7459
7463
|
}
|
|
7460
7464
|
function _(g) {
|
|
@@ -7469,7 +7473,7 @@ function zc({
|
|
|
7469
7473
|
}
|
|
7470
7474
|
function w(g) {
|
|
7471
7475
|
f.publishPresence({
|
|
7472
|
-
[
|
|
7476
|
+
[d]: void 0
|
|
7473
7477
|
});
|
|
7474
7478
|
}
|
|
7475
7479
|
return js(
|
|
@@ -7493,10 +7497,10 @@ function zc({
|
|
|
7493
7497
|
style: {
|
|
7494
7498
|
...ui,
|
|
7495
7499
|
...Uc,
|
|
7496
|
-
zIndex:
|
|
7500
|
+
zIndex: c !== void 0 ? c : Lc
|
|
7497
7501
|
},
|
|
7498
7502
|
children: Object.entries(f.peers).map(([g, m]) => {
|
|
7499
|
-
const E = m[
|
|
7503
|
+
const E = m[d];
|
|
7500
7504
|
return E ? /* @__PURE__ */ W.jsx(
|
|
7501
7505
|
"div",
|
|
7502
7506
|
{
|
|
@@ -7515,7 +7519,7 @@ function zc({
|
|
|
7515
7519
|
) : null;
|
|
7516
7520
|
})
|
|
7517
7521
|
},
|
|
7518
|
-
|
|
7522
|
+
d
|
|
7519
7523
|
)
|
|
7520
7524
|
]
|
|
7521
7525
|
);
|