@instantdb/react-common 0.22.89-experimental.uuidfix.20281951052.1 → 0.22.89-experimental.uuidfix.20282614127.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone/index.js +262 -263
- package/dist/standalone/index.umd.cjs +8 -8
- package/package.json +3 -3
package/dist/standalone/index.js
CHANGED
|
@@ -2504,22 +2504,21 @@ function Ws() {
|
|
|
2504
2504
|
const Bs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Vn = { randomUUID: Bs };
|
|
2505
2505
|
function Gs(t, e, n) {
|
|
2506
2506
|
var i;
|
|
2507
|
+
if (Vn.randomUUID && !t)
|
|
2508
|
+
return Vn.randomUUID();
|
|
2507
2509
|
t = t || {};
|
|
2508
2510
|
const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Ws();
|
|
2509
2511
|
if (r.length < 16)
|
|
2510
2512
|
throw new Error("Random bytes length must be >= 16");
|
|
2511
2513
|
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, zs(r);
|
|
2512
2514
|
}
|
|
2513
|
-
function Qs(t, e, n) {
|
|
2514
|
-
return Vn.randomUUID ? Vn.randomUUID() : Gs(t);
|
|
2515
|
-
}
|
|
2516
2515
|
function Wn(t) {
|
|
2517
2516
|
const e = t.replace(/-/g, ""), n = [];
|
|
2518
2517
|
for (let r = 0; r < e.length; r += 2)
|
|
2519
2518
|
n.push(parseInt(e.substring(r, r + 2), 16));
|
|
2520
2519
|
return n;
|
|
2521
2520
|
}
|
|
2522
|
-
function
|
|
2521
|
+
function Qs(t, e) {
|
|
2523
2522
|
for (let n = 0; n < t.length; n++) {
|
|
2524
2523
|
if (t[n] < e[n])
|
|
2525
2524
|
return -1;
|
|
@@ -2528,17 +2527,17 @@ function Hs(t, e) {
|
|
|
2528
2527
|
}
|
|
2529
2528
|
return 0;
|
|
2530
2529
|
}
|
|
2531
|
-
function
|
|
2532
|
-
return
|
|
2530
|
+
function Hs(t, e) {
|
|
2531
|
+
return Qs(Wn(t), Wn(e));
|
|
2533
2532
|
}
|
|
2534
2533
|
function N() {
|
|
2535
|
-
return
|
|
2534
|
+
return Gs();
|
|
2536
2535
|
}
|
|
2537
|
-
function
|
|
2536
|
+
function Ys(t, e) {
|
|
2538
2537
|
return t.localeCompare(e);
|
|
2539
2538
|
}
|
|
2540
|
-
function
|
|
2541
|
-
let t =
|
|
2539
|
+
function Js() {
|
|
2540
|
+
let t = Ys;
|
|
2542
2541
|
if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
|
|
2543
2542
|
try {
|
|
2544
2543
|
t = Intl.Collator("en-US").compare;
|
|
@@ -2546,10 +2545,10 @@ function Zs() {
|
|
|
2546
2545
|
}
|
|
2547
2546
|
return t;
|
|
2548
2547
|
}
|
|
2549
|
-
const
|
|
2550
|
-
let
|
|
2548
|
+
const Zs = Js();
|
|
2549
|
+
let Xs = 0;
|
|
2551
2550
|
function Ne(t) {
|
|
2552
|
-
return yt(`_${t}`,
|
|
2551
|
+
return yt(`_${t}`, Xs++);
|
|
2553
2552
|
}
|
|
2554
2553
|
function yt(t, e) {
|
|
2555
2554
|
return `?${t}-${e}`;
|
|
@@ -2559,24 +2558,24 @@ class ke extends Error {
|
|
|
2559
2558
|
super(e), this.name = "AttrNotFoundError";
|
|
2560
2559
|
}
|
|
2561
2560
|
}
|
|
2562
|
-
function
|
|
2561
|
+
function eo(t, e) {
|
|
2563
2562
|
const n = Kr(t, e);
|
|
2564
2563
|
if (!n)
|
|
2565
2564
|
throw new ke(`Could not find id attr for ${e}`);
|
|
2566
2565
|
return n;
|
|
2567
2566
|
}
|
|
2568
2567
|
function Bn(t, e, n, r) {
|
|
2569
|
-
return [
|
|
2568
|
+
return [to(t, e, n, r)];
|
|
2570
2569
|
}
|
|
2571
|
-
function
|
|
2570
|
+
function to(t, e, n, r) {
|
|
2572
2571
|
return [
|
|
2573
2572
|
t(n, r),
|
|
2574
|
-
|
|
2573
|
+
eo(e, n).id,
|
|
2575
2574
|
t(n, r),
|
|
2576
2575
|
t("time", r)
|
|
2577
2576
|
];
|
|
2578
2577
|
}
|
|
2579
|
-
function
|
|
2578
|
+
function no(t, e, n) {
|
|
2580
2579
|
return t.map((r) => r === e ? n : r);
|
|
2581
2580
|
}
|
|
2582
2581
|
function zr(t, e, n, r, i) {
|
|
@@ -2608,7 +2607,7 @@ function Gn(t, e) {
|
|
|
2608
2607
|
return typeof o != "string" ? !1 : i.test(o);
|
|
2609
2608
|
};
|
|
2610
2609
|
}
|
|
2611
|
-
function
|
|
2610
|
+
function ro(t, e) {
|
|
2612
2611
|
if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
|
|
2613
2612
|
return e;
|
|
2614
2613
|
const n = t["checked-data-type"] === "date";
|
|
@@ -2668,7 +2667,7 @@ function io(t, e) {
|
|
|
2668
2667
|
}
|
|
2669
2668
|
return e;
|
|
2670
2669
|
}
|
|
2671
|
-
function
|
|
2670
|
+
function io(t, e, n, r, i, s) {
|
|
2672
2671
|
const o = F(e, n, i), u = me(e, n, i), a = o || u;
|
|
2673
2672
|
if (!a)
|
|
2674
2673
|
throw new ke(`No attr for etype = ${n} label = ${i}`);
|
|
@@ -2686,11 +2685,11 @@ function so(t, e, n, r, i, s) {
|
|
|
2686
2685
|
return o ? [
|
|
2687
2686
|
t(n, r),
|
|
2688
2687
|
a.id,
|
|
2689
|
-
|
|
2688
|
+
ro(a, s),
|
|
2690
2689
|
Ne("time")
|
|
2691
2690
|
] : [s, a.id, t(n, r), Ne("time")];
|
|
2692
2691
|
}
|
|
2693
|
-
function
|
|
2692
|
+
function so(t, e, n, r, i) {
|
|
2694
2693
|
const [s, o, u] = i.reduce((a, c) => {
|
|
2695
2694
|
const [d, f, l] = a, [p, y, b] = zr(t, e, d, f, c);
|
|
2696
2695
|
return [p, y, [...l, b]];
|
|
@@ -2698,19 +2697,19 @@ function oo(t, e, n, r, i) {
|
|
|
2698
2697
|
return [s, o, u];
|
|
2699
2698
|
}
|
|
2700
2699
|
function qt(t, e, n, r, i, s) {
|
|
2701
|
-
const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] =
|
|
2700
|
+
const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = so(t, e, n, r, o), f = io(t, e, a, c, u, s);
|
|
2702
2701
|
return d.concat([f]);
|
|
2703
2702
|
}
|
|
2704
|
-
function
|
|
2703
|
+
function oo(t, e) {
|
|
2705
2704
|
return e ? [e].concat(t) : t;
|
|
2706
2705
|
}
|
|
2707
|
-
function
|
|
2706
|
+
function uo([t, e]) {
|
|
2708
2707
|
return t === "or" && Array.isArray(e);
|
|
2709
2708
|
}
|
|
2710
|
-
function
|
|
2709
|
+
function ao([t, e]) {
|
|
2711
2710
|
return t === "and" && Array.isArray(e);
|
|
2712
2711
|
}
|
|
2713
|
-
function
|
|
2712
|
+
function co(t, e, n) {
|
|
2714
2713
|
return (r, i) => {
|
|
2715
2714
|
const s = t(r, i);
|
|
2716
2715
|
return e == s ? s : `${s}-${n}`;
|
|
@@ -2718,27 +2717,27 @@ function fo(t, e, n) {
|
|
|
2718
2717
|
}
|
|
2719
2718
|
function Qn(t, e, n, r, i, s) {
|
|
2720
2719
|
const o = t(r, i), u = s.map((a, c) => {
|
|
2721
|
-
const d =
|
|
2720
|
+
const d = co(t, o, c);
|
|
2722
2721
|
return Vr(d, n, r, i, a);
|
|
2723
2722
|
});
|
|
2724
2723
|
return { [e]: { patterns: u, joinSym: o } };
|
|
2725
2724
|
}
|
|
2726
|
-
function
|
|
2725
|
+
function fo(t) {
|
|
2727
2726
|
const e = [];
|
|
2728
2727
|
for (let n = 1; n <= t.length; n++)
|
|
2729
2728
|
e.push(t.slice(0, n));
|
|
2730
2729
|
return e;
|
|
2731
2730
|
}
|
|
2732
2731
|
function Hn(t, e, n, r, i) {
|
|
2733
|
-
return
|
|
2732
|
+
return fo(i).map((s) => qt(t, e, n, r, s, {
|
|
2734
2733
|
$isNull: !0
|
|
2735
2734
|
}));
|
|
2736
2735
|
}
|
|
2737
2736
|
function Vr(t, e, n, r, i) {
|
|
2738
2737
|
return Object.entries(i).flatMap(([s, o]) => {
|
|
2739
|
-
if (
|
|
2738
|
+
if (uo([s, o]))
|
|
2740
2739
|
return Qn(t, "or", e, n, r, o);
|
|
2741
|
-
if (
|
|
2740
|
+
if (ao([s, o]))
|
|
2742
2741
|
return Qn(t, "and", e, n, r, o);
|
|
2743
2742
|
if (s === "$entityIdStartsWith")
|
|
2744
2743
|
return [];
|
|
@@ -2764,25 +2763,25 @@ function Vr(t, e, n, r, i) {
|
|
|
2764
2763
|
] : qt(t, e, n, r, u, o);
|
|
2765
2764
|
});
|
|
2766
2765
|
}
|
|
2767
|
-
function
|
|
2766
|
+
function lo(t, e, n, r) {
|
|
2768
2767
|
const i = yt;
|
|
2769
2768
|
return r ? Vr(i, t, e, n, r).concat(Bn(i, t, e, n)) : Bn(i, t, e, n);
|
|
2770
2769
|
}
|
|
2771
|
-
function
|
|
2770
|
+
function ho(t, e, n) {
|
|
2772
2771
|
return [t(e, n), t("time", n)];
|
|
2773
2772
|
}
|
|
2774
|
-
function
|
|
2775
|
-
const [o, u, a, c, d] = zr(t, e, n, r, i), f =
|
|
2773
|
+
function po(t, e, n, r, i, s) {
|
|
2774
|
+
const [o, u, a, c, d] = zr(t, e, n, r, i), f = no(a, t(n, r), s);
|
|
2776
2775
|
return [o, u, f, c, d];
|
|
2777
2776
|
}
|
|
2778
|
-
function
|
|
2777
|
+
function yo(t, e, n, { etype: r, level: i, form: s }, o) {
|
|
2779
2778
|
const u = Object.keys(s).filter((a) => a !== "$");
|
|
2780
2779
|
return u.length ? Object.entries(o).map(function([c, d]) {
|
|
2781
2780
|
return u.map(function(p) {
|
|
2782
2781
|
var y, b, _;
|
|
2783
2782
|
const w = !!(e.cardinalityInference && (!((_ = (b = (y = n.linkIndex) === null || y === void 0 ? void 0 : y[r]) === null || b === void 0 ? void 0 : b[p]) === null || _ === void 0) && _.isSingular));
|
|
2784
2783
|
try {
|
|
2785
|
-
const [g, v, A] =
|
|
2784
|
+
const [g, v, A] = po(t, n, r, i, p, c), S = Br(e, n, {
|
|
2786
2785
|
etype: g,
|
|
2787
2786
|
level: v,
|
|
2788
2787
|
form: s[p],
|
|
@@ -2799,11 +2798,11 @@ function bo(t, e, n, { etype: r, level: i, form: s }, o) {
|
|
|
2799
2798
|
}, d);
|
|
2800
2799
|
}) : Object.values(o);
|
|
2801
2800
|
}
|
|
2802
|
-
function
|
|
2803
|
-
return n === "string" ?
|
|
2801
|
+
function bo(t, e, n) {
|
|
2802
|
+
return n === "string" ? Zs(t, e) : t > e ? 1 : -1;
|
|
2804
2803
|
}
|
|
2805
2804
|
function Le(t, e, n, r, i) {
|
|
2806
|
-
return e === r || e == null && r == null ?
|
|
2805
|
+
return e === r || e == null && r == null ? Hs(t, n) : r == null ? 1 : e == null ? -1 : bo(e, r, i);
|
|
2807
2806
|
}
|
|
2808
2807
|
function lt([t, e], [n, r], i) {
|
|
2809
2808
|
return Le(t, e, n, r, i);
|
|
@@ -2811,7 +2810,7 @@ function lt([t, e], [n, r], i) {
|
|
|
2811
2810
|
function zt(t) {
|
|
2812
2811
|
return t == null ? t : new Date(t).getTime();
|
|
2813
2812
|
}
|
|
2814
|
-
function
|
|
2813
|
+
function _o(t, e, n, r) {
|
|
2815
2814
|
var i;
|
|
2816
2815
|
const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
|
|
2817
2816
|
if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
|
|
@@ -2819,21 +2818,21 @@ function go(t, e, n, r) {
|
|
|
2819
2818
|
const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? zt(f) : f, y = l === "date" ? zt(u) : u;
|
|
2820
2819
|
return lt([d, p], [s, y], l) === c;
|
|
2821
2820
|
}
|
|
2822
|
-
function
|
|
2821
|
+
function go(t, e) {
|
|
2823
2822
|
const n = e[1];
|
|
2824
2823
|
return t.getAttr(n);
|
|
2825
2824
|
}
|
|
2826
|
-
function
|
|
2825
|
+
function To(t, e, n) {
|
|
2827
2826
|
const r = Object.keys(n)[0];
|
|
2828
2827
|
return F(t, e, r);
|
|
2829
2828
|
}
|
|
2830
|
-
function
|
|
2829
|
+
function wo(t, e, n, r) {
|
|
2831
2830
|
if (n)
|
|
2832
|
-
return
|
|
2831
|
+
return go(t, n);
|
|
2833
2832
|
if (r)
|
|
2834
|
-
return
|
|
2833
|
+
return To(t, e, r);
|
|
2835
2834
|
}
|
|
2836
|
-
function
|
|
2835
|
+
function mo(t, e, n) {
|
|
2837
2836
|
var r, i;
|
|
2838
2837
|
if (!Array.isArray(n.fields))
|
|
2839
2838
|
return Cs(t, e);
|
|
@@ -2848,11 +2847,11 @@ function vo(t, e, n) {
|
|
|
2848
2847
|
}
|
|
2849
2848
|
return s;
|
|
2850
2849
|
}
|
|
2851
|
-
function
|
|
2850
|
+
function vo(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
|
|
2852
2851
|
var o, u;
|
|
2853
|
-
const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Wr(s), d =
|
|
2852
|
+
const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Wr(s), d = So(s);
|
|
2854
2853
|
let f = Ns(t, i);
|
|
2855
|
-
const l = r == null ? void 0 : r["start-cursor"], p =
|
|
2854
|
+
const l = r == null ? void 0 : r["start-cursor"], p = wo(e, n, l, a);
|
|
2856
2855
|
if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
|
|
2857
2856
|
const _ = p["checked-data-type"] === "date", w = p.id;
|
|
2858
2857
|
f = f.map(([g]) => {
|
|
@@ -2867,17 +2866,17 @@ function So(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
|
|
|
2867
2866
|
return lt(g, w, p == null ? void 0 : p["checked-data-type"]);
|
|
2868
2867
|
});
|
|
2869
2868
|
let y = {};
|
|
2870
|
-
const b =
|
|
2869
|
+
const b = mo(e, n, i);
|
|
2871
2870
|
for (const _ of f) {
|
|
2872
2871
|
const [w] = _;
|
|
2873
|
-
if (y[w] || !c && l && p &&
|
|
2872
|
+
if (y[w] || !c && l && p && _o(l, p, d, _))
|
|
2874
2873
|
continue;
|
|
2875
2874
|
const g = js(t, b, w);
|
|
2876
2875
|
g && (y[w] = g);
|
|
2877
2876
|
}
|
|
2878
2877
|
return y;
|
|
2879
2878
|
}
|
|
2880
|
-
function
|
|
2879
|
+
function So(t) {
|
|
2881
2880
|
var e;
|
|
2882
2881
|
const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
|
|
2883
2882
|
return n && n[Object.keys(n)[0]] || "asc";
|
|
@@ -2887,11 +2886,11 @@ function Wr(t) {
|
|
|
2887
2886
|
const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
|
|
2888
2887
|
return !i && !s && !o;
|
|
2889
2888
|
}
|
|
2890
|
-
function
|
|
2889
|
+
function Oo(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
|
|
2891
2890
|
var u, a, c, d, f;
|
|
2892
2891
|
if (!Wr(i) && (!o || !o["start-cursor"]))
|
|
2893
2892
|
return [];
|
|
2894
|
-
const l =
|
|
2893
|
+
const l = oo(lo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = ho(yt, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = vo(t, e, {
|
|
2895
2894
|
etype: n,
|
|
2896
2895
|
pageInfo: o,
|
|
2897
2896
|
form: i,
|
|
@@ -2904,9 +2903,9 @@ function Ao(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
|
|
|
2904
2903
|
}
|
|
2905
2904
|
return b;
|
|
2906
2905
|
}
|
|
2907
|
-
function
|
|
2906
|
+
function Ao(t, e, n) {
|
|
2908
2907
|
try {
|
|
2909
|
-
return
|
|
2908
|
+
return Oo(t, e, n);
|
|
2910
2909
|
} catch (r) {
|
|
2911
2910
|
if (r instanceof ke)
|
|
2912
2911
|
return {};
|
|
@@ -2914,10 +2913,10 @@ function Eo(t, e, n) {
|
|
|
2914
2913
|
}
|
|
2915
2914
|
}
|
|
2916
2915
|
function Br(t, e, n) {
|
|
2917
|
-
const r =
|
|
2918
|
-
return
|
|
2916
|
+
const r = Ao(t, e, n);
|
|
2917
|
+
return yo(yt, t, e, n, r);
|
|
2919
2918
|
}
|
|
2920
|
-
function
|
|
2919
|
+
function Eo(t) {
|
|
2921
2920
|
const e = {};
|
|
2922
2921
|
for (const [n, r] of Object.entries(t))
|
|
2923
2922
|
e[n] = {
|
|
@@ -2937,9 +2936,9 @@ function Gr({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
|
|
|
2937
2936
|
pageInfo: n == null ? void 0 : n[c]
|
|
2938
2937
|
})), a;
|
|
2939
2938
|
}, {}) };
|
|
2940
|
-
return n && (o.pageInfo =
|
|
2939
|
+
return n && (o.pageInfo = Eo(n)), r && (o.aggregate = r), o;
|
|
2941
2940
|
}
|
|
2942
|
-
function
|
|
2941
|
+
function ko() {
|
|
2943
2942
|
const e = {
|
|
2944
2943
|
__etype: 1,
|
|
2945
2944
|
__ops: 1,
|
|
@@ -2953,7 +2952,7 @@ function jo() {
|
|
|
2953
2952
|
};
|
|
2954
2953
|
return new Set(Object.keys(e));
|
|
2955
2954
|
}
|
|
2956
|
-
const
|
|
2955
|
+
const jo = ko();
|
|
2957
2956
|
function Vt(t, e, n) {
|
|
2958
2957
|
const r = {
|
|
2959
2958
|
__etype: t,
|
|
@@ -2965,7 +2964,7 @@ function Vt(t, e, n) {
|
|
|
2965
2964
|
return n;
|
|
2966
2965
|
if (s === "__etype")
|
|
2967
2966
|
return t;
|
|
2968
|
-
if (
|
|
2967
|
+
if (jo.has(s))
|
|
2969
2968
|
return (o, u) => Vt(t, e, [
|
|
2970
2969
|
...n,
|
|
2971
2970
|
u ? [s, t, e, o, u] : [s, t, e, o]
|
|
@@ -2980,7 +2979,7 @@ function Qr(t) {
|
|
|
2980
2979
|
const [e, n, ...r] = t.split("__");
|
|
2981
2980
|
return [n, JSON.parse(r.join("__"))];
|
|
2982
2981
|
}
|
|
2983
|
-
function
|
|
2982
|
+
function Co(t) {
|
|
2984
2983
|
return new Proxy({
|
|
2985
2984
|
__etype: t
|
|
2986
2985
|
}, {
|
|
@@ -2995,15 +2994,15 @@ function Io(t) {
|
|
|
2995
2994
|
function cn() {
|
|
2996
2995
|
return new Proxy({}, {
|
|
2997
2996
|
get(t, e) {
|
|
2998
|
-
return
|
|
2997
|
+
return Co(e);
|
|
2999
2998
|
}
|
|
3000
2999
|
});
|
|
3001
3000
|
}
|
|
3002
3001
|
cn();
|
|
3003
|
-
function
|
|
3002
|
+
function Io(t) {
|
|
3004
3003
|
return t.__ops;
|
|
3005
3004
|
}
|
|
3006
|
-
function
|
|
3005
|
+
function Po(t, e) {
|
|
3007
3006
|
const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
|
|
3008
3007
|
for (const o of e) {
|
|
3009
3008
|
const u = n[o];
|
|
@@ -3022,7 +3021,7 @@ function Mo(t, e) {
|
|
|
3022
3021
|
}
|
|
3023
3022
|
return i;
|
|
3024
3023
|
}
|
|
3025
|
-
function
|
|
3024
|
+
function Mo(t) {
|
|
3026
3025
|
if (Array.isArray(t))
|
|
3027
3026
|
return t;
|
|
3028
3027
|
const e = Object.entries(t);
|
|
@@ -3030,7 +3029,7 @@ function Ro(t) {
|
|
|
3030
3029
|
throw new Error("lookup must be an object with a single unique attr and value.");
|
|
3031
3030
|
return e[0];
|
|
3032
3031
|
}
|
|
3033
|
-
function
|
|
3032
|
+
function Ro(t, e, n) {
|
|
3034
3033
|
return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
3035
3034
|
// before assuming it's a ref lookup.
|
|
3036
3035
|
!F(t, e, n);
|
|
@@ -3041,8 +3040,8 @@ function Wt(t) {
|
|
|
3041
3040
|
throw new Error(`${t} is not a valid lookup attribute.`);
|
|
3042
3041
|
return e;
|
|
3043
3042
|
}
|
|
3044
|
-
function
|
|
3045
|
-
if (
|
|
3043
|
+
function $o(t, e, n) {
|
|
3044
|
+
if (!Ro(t, e, n))
|
|
3046
3045
|
return F(t, e, n);
|
|
3047
3046
|
const r = Wt(n), i = F(t, e, r) || me(t, e, r);
|
|
3048
3047
|
if (i && i["value-type"] !== "ref")
|
|
@@ -3050,13 +3049,13 @@ function Do(t, e, n) {
|
|
|
3050
3049
|
return i;
|
|
3051
3050
|
}
|
|
3052
3051
|
function Bt(t) {
|
|
3053
|
-
return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Qr(t) :
|
|
3052
|
+
return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Qr(t) : Mo(t);
|
|
3054
3053
|
}
|
|
3055
3054
|
function Q(t, e, n) {
|
|
3056
3055
|
const r = Bt(n);
|
|
3057
3056
|
if (r === null)
|
|
3058
3057
|
return n;
|
|
3059
|
-
const [i, s] = r, o =
|
|
3058
|
+
const [i, s] = r, o = $o(t, e, i);
|
|
3060
3059
|
if (!o || !o["unique?"])
|
|
3061
3060
|
throw new Error(`${i} is not a unique attribute.`);
|
|
3062
3061
|
return [o.id, s];
|
|
@@ -3071,7 +3070,7 @@ function Hr(t, e, n, r) {
|
|
|
3071
3070
|
s
|
|
3072
3071
|
]].concat(r) : r;
|
|
3073
3072
|
}
|
|
3074
|
-
function
|
|
3073
|
+
function Do({ attrsStore: t }, [e, n, r]) {
|
|
3075
3074
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
3076
3075
|
const u = Array.isArray(o) ? o : [o], a = F(t, e, s), c = me(t, e, s);
|
|
3077
3076
|
return u.map((d) => a ? [
|
|
@@ -3092,7 +3091,7 @@ function xo({ attrsStore: t }, [e, n, r]) {
|
|
|
3092
3091
|
});
|
|
3093
3092
|
return Hr(t, e, n, i);
|
|
3094
3093
|
}
|
|
3095
|
-
function
|
|
3094
|
+
function xo({ attrsStore: t }, [e, n, r]) {
|
|
3096
3095
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
3097
3096
|
const u = Array.isArray(o) ? o : [o], a = F(t, e, s), c = me(t, e, s);
|
|
3098
3097
|
return u.map((d) => a ? [
|
|
@@ -3113,7 +3112,7 @@ function Uo({ attrsStore: t }, [e, n, r]) {
|
|
|
3113
3112
|
});
|
|
3114
3113
|
return Hr(t, e, n, i);
|
|
3115
3114
|
}
|
|
3116
|
-
function
|
|
3115
|
+
function Uo(t, e, n, r) {
|
|
3117
3116
|
var i;
|
|
3118
3117
|
if (Array.isArray(r)) {
|
|
3119
3118
|
const [s, o] = r;
|
|
@@ -3137,16 +3136,16 @@ function Lo(t, e, n, r) {
|
|
|
3137
3136
|
return !1;
|
|
3138
3137
|
}
|
|
3139
3138
|
function Yr({ stores: t, attrsStore: e }, [n, r, i, s]) {
|
|
3140
|
-
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null :
|
|
3139
|
+
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Uo(t, e, n, r) ? { mode: "update" } : null;
|
|
3141
3140
|
}
|
|
3142
|
-
function
|
|
3141
|
+
function Lo(t, e) {
|
|
3143
3142
|
const { attrsStore: n } = t, [r, i, s, o] = e, u = sn(s), a = Q(n, r, i);
|
|
3144
3143
|
return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
|
|
3145
3144
|
const l = F(n, r, d);
|
|
3146
3145
|
return l["checked-data-type"] === "date" && t.useDateObjects && (f = pt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
|
|
3147
3146
|
});
|
|
3148
3147
|
}
|
|
3149
|
-
function
|
|
3148
|
+
function Fo(t, e) {
|
|
3150
3149
|
const { attrsStore: n } = t, [r, i, s, o] = e, u = sn(s), a = Q(n, r, i), c = Yr(t, [r, a, s, o]);
|
|
3151
3150
|
return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
|
|
3152
3151
|
const p = F(n, r, f);
|
|
@@ -3159,10 +3158,10 @@ function No(t, e) {
|
|
|
3159
3158
|
];
|
|
3160
3159
|
});
|
|
3161
3160
|
}
|
|
3162
|
-
function
|
|
3161
|
+
function No({ attrsStore: t }, [e, n]) {
|
|
3163
3162
|
return [["delete-entity", Q(t, e, n), e]];
|
|
3164
3163
|
}
|
|
3165
|
-
function
|
|
3164
|
+
function Ko(t, e) {
|
|
3166
3165
|
const { attrsStore: n } = t, [r, i, s, o] = e, u = sn(s), a = Q(n, r, i), c = Yr(t, [r, a, s, o]), d = Object.entries(u).map(([l, p]) => {
|
|
3167
3166
|
const y = F(n, r, l);
|
|
3168
3167
|
return [
|
|
@@ -3181,38 +3180,38 @@ function qo(t, e) {
|
|
|
3181
3180
|
...c ? [c] : []
|
|
3182
3181
|
]].concat(d);
|
|
3183
3182
|
}
|
|
3184
|
-
function
|
|
3183
|
+
function qo({ attrsStore: t }, [e, n, r]) {
|
|
3185
3184
|
return [["rule-params", Q(t, e, n), e, r]];
|
|
3186
3185
|
}
|
|
3187
|
-
function
|
|
3186
|
+
function zo(t) {
|
|
3188
3187
|
const [e, n, r, i, s] = t;
|
|
3189
3188
|
if (!i)
|
|
3190
3189
|
return t;
|
|
3191
3190
|
const o = Object.assign({}, i);
|
|
3192
3191
|
return delete o.id, [e, n, r, o, ...s ? [s] : []];
|
|
3193
3192
|
}
|
|
3194
|
-
function
|
|
3195
|
-
const [n, ...r] =
|
|
3193
|
+
function Vo(t, e) {
|
|
3194
|
+
const [n, ...r] = zo(e);
|
|
3196
3195
|
switch (n) {
|
|
3197
3196
|
case "merge":
|
|
3198
|
-
return
|
|
3197
|
+
return Ko(t, r);
|
|
3199
3198
|
case "create":
|
|
3200
|
-
return
|
|
3199
|
+
return Lo(t, r);
|
|
3201
3200
|
case "update":
|
|
3202
|
-
return
|
|
3201
|
+
return Fo(t, r);
|
|
3203
3202
|
case "link":
|
|
3204
|
-
return
|
|
3203
|
+
return Do(t, r);
|
|
3205
3204
|
case "unlink":
|
|
3206
|
-
return
|
|
3205
|
+
return xo(t, r);
|
|
3207
3206
|
case "delete":
|
|
3208
|
-
return
|
|
3207
|
+
return No(t, r);
|
|
3209
3208
|
case "ruleParams":
|
|
3210
|
-
return
|
|
3209
|
+
return qo(t, r);
|
|
3211
3210
|
default:
|
|
3212
3211
|
throw new Error(`unsupported action ${n}`);
|
|
3213
3212
|
}
|
|
3214
3213
|
}
|
|
3215
|
-
function
|
|
3214
|
+
function Wo(t) {
|
|
3216
3215
|
switch (t) {
|
|
3217
3216
|
case "string":
|
|
3218
3217
|
case "date":
|
|
@@ -3223,14 +3222,14 @@ function Bo(t) {
|
|
|
3223
3222
|
return;
|
|
3224
3223
|
}
|
|
3225
3224
|
}
|
|
3226
|
-
function
|
|
3225
|
+
function Bo(t, e, n) {
|
|
3227
3226
|
var r, i;
|
|
3228
3227
|
const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
|
|
3229
3228
|
if (n === "id")
|
|
3230
3229
|
return null;
|
|
3231
3230
|
if (!s)
|
|
3232
3231
|
throw new Error(`${e}.${n} does not exist in your schema`);
|
|
3233
|
-
const { unique: o, indexed: u } = s == null ? void 0 : s.config, a =
|
|
3232
|
+
const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Wo(s == null ? void 0 : s.valueType);
|
|
3234
3233
|
return {
|
|
3235
3234
|
"index?": u,
|
|
3236
3235
|
"unique?": o,
|
|
@@ -3238,14 +3237,14 @@ function Go(t, e, n) {
|
|
|
3238
3237
|
};
|
|
3239
3238
|
}
|
|
3240
3239
|
function nt(t, e, n, r) {
|
|
3241
|
-
const i = t ?
|
|
3240
|
+
const i = t ? Bo(t, e, n) : null, s = N(), u = [N(), e, n];
|
|
3242
3241
|
return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
|
|
3243
3242
|
}
|
|
3244
|
-
function
|
|
3243
|
+
function Go(t, e, n) {
|
|
3245
3244
|
return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
|
|
3246
3245
|
}
|
|
3247
|
-
function
|
|
3248
|
-
const r =
|
|
3246
|
+
function Qo(t, e, n) {
|
|
3247
|
+
const r = Go(t, e, n);
|
|
3249
3248
|
if (!r)
|
|
3250
3249
|
throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
|
|
3251
3250
|
const { forward: i, reverse: s } = r;
|
|
@@ -3259,7 +3258,7 @@ function Ho(t, e, n) {
|
|
|
3259
3258
|
};
|
|
3260
3259
|
}
|
|
3261
3260
|
function Yn(t, e, n, r) {
|
|
3262
|
-
const i = t ?
|
|
3261
|
+
const i = t ? Qo(t, e, n) : null, s = N(), o = [N(), e, n], u = [N(), n, e];
|
|
3263
3262
|
return Object.assign(Object.assign({
|
|
3264
3263
|
id: s,
|
|
3265
3264
|
// @ts-ignore: ts thinks it's any[]
|
|
@@ -3274,7 +3273,7 @@ function Yn(t, e, n, r) {
|
|
|
3274
3273
|
isUnsynced: !0
|
|
3275
3274
|
}, i || {}), r || {});
|
|
3276
3275
|
}
|
|
3277
|
-
const
|
|
3276
|
+
const Ho = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Yo = /* @__PURE__ */ new Set(["link", "unlink"]), Jo = /* @__PURE__ */ new Set(["create", "update", "merge"]), Zo = /* @__PURE__ */ new Set([
|
|
3278
3277
|
"link",
|
|
3279
3278
|
"unlink",
|
|
3280
3279
|
"create",
|
|
@@ -3282,10 +3281,10 @@ const Yo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
|
|
|
3282
3281
|
"merge",
|
|
3283
3282
|
"delete",
|
|
3284
3283
|
"ruleParams"
|
|
3285
|
-
]), Gt = { "unique?": !0, "index?": !0 },
|
|
3286
|
-
function
|
|
3284
|
+
]), Gt = { "unique?": !0, "index?": !0 }, Xo = Object.assign(Object.assign({}, Gt), { cardinality: "one" });
|
|
3285
|
+
function eu(t) {
|
|
3287
3286
|
const e = [], [n, r, i, s] = t;
|
|
3288
|
-
if (!
|
|
3287
|
+
if (!Zo.has(n))
|
|
3289
3288
|
return e;
|
|
3290
3289
|
const o = Bt(i);
|
|
3291
3290
|
if (o && e.push({ etype: r, lookupPair: o }), n === "link")
|
|
@@ -3302,7 +3301,7 @@ function tu(t) {
|
|
|
3302
3301
|
}
|
|
3303
3302
|
return e;
|
|
3304
3303
|
}
|
|
3305
|
-
function
|
|
3304
|
+
function tu({ attrsStore: t, schema: e }, n) {
|
|
3306
3305
|
var r, i;
|
|
3307
3306
|
const s = /* @__PURE__ */ new Set(), o = [], u = [];
|
|
3308
3307
|
function a(y, b) {
|
|
@@ -3327,10 +3326,10 @@ function nu({ attrsStore: t, schema: e }, n) {
|
|
|
3327
3326
|
}
|
|
3328
3327
|
function p(y, b) {
|
|
3329
3328
|
const _ = a(y, b), w = c(y, b);
|
|
3330
|
-
f(_), f(w), !_ && !w && d(Yn(e, y, b,
|
|
3329
|
+
f(_), f(w), !_ && !w && d(Yn(e, y, b, Xo));
|
|
3331
3330
|
}
|
|
3332
3331
|
for (const y of n)
|
|
3333
|
-
for (const { etype: b, lookupPair: _, linkLabel: w } of
|
|
3332
|
+
for (const { etype: b, lookupPair: _, linkLabel: w } of eu(y)) {
|
|
3334
3333
|
const g = _[0];
|
|
3335
3334
|
if (w) {
|
|
3336
3335
|
p(b, w);
|
|
@@ -3352,12 +3351,12 @@ function nu({ attrsStore: t, schema: e }, n) {
|
|
|
3352
3351
|
}
|
|
3353
3352
|
for (const y of n) {
|
|
3354
3353
|
const [b, _, w, g] = y;
|
|
3355
|
-
if (
|
|
3354
|
+
if (Ho.has(b)) {
|
|
3356
3355
|
const v = a(_, "id");
|
|
3357
3356
|
f(v), v || d(nt(e, _, "id", { "unique?": !0 }));
|
|
3358
3357
|
for (const A of Object.keys(g)) {
|
|
3359
3358
|
const S = a(_, A);
|
|
3360
|
-
if (f(S),
|
|
3359
|
+
if (f(S), Jo.has(b) && (S || d(nt(e, _, A, A === "id" ? { "unique?": !0 } : null))), Yo.has(b)) {
|
|
3361
3360
|
const C = c(_, A);
|
|
3362
3361
|
!S && !C && d(Yn(e, _, A)), f(C);
|
|
3363
3362
|
}
|
|
@@ -3372,8 +3371,8 @@ function nu({ attrsStore: t, schema: e }, n) {
|
|
|
3372
3371
|
}
|
|
3373
3372
|
return [t, u];
|
|
3374
3373
|
}
|
|
3375
|
-
function
|
|
3376
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((a) =>
|
|
3374
|
+
function nu(t, e) {
|
|
3375
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Io(a)), [i, s] = tu(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Vo(o, a));
|
|
3377
3376
|
return [...s, ...u];
|
|
3378
3377
|
}
|
|
3379
3378
|
var re = function(t, e, n, r) {
|
|
@@ -3407,7 +3406,7 @@ function Jn(t, e) {
|
|
|
3407
3406
|
typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
|
|
3408
3407
|
}
|
|
3409
3408
|
const Ke = "__meta";
|
|
3410
|
-
class
|
|
3409
|
+
class ru {
|
|
3411
3410
|
constructor(e, n) {
|
|
3412
3411
|
}
|
|
3413
3412
|
}
|
|
@@ -3679,13 +3678,13 @@ var ue = function(t, e, n, r) {
|
|
|
3679
3678
|
c((r = r.apply(t, e || [])).next());
|
|
3680
3679
|
});
|
|
3681
3680
|
};
|
|
3682
|
-
const
|
|
3683
|
-
function
|
|
3681
|
+
const iu = 6, su = ["kv", "querySubs", "syncSubs"];
|
|
3682
|
+
function ou(t) {
|
|
3684
3683
|
return function(n) {
|
|
3685
3684
|
console.error("Error in IndexedDB event", { source: t, event: n });
|
|
3686
3685
|
};
|
|
3687
3686
|
}
|
|
3688
|
-
function
|
|
3687
|
+
function uu(t) {
|
|
3689
3688
|
return ue(this, void 0, void 0, function* () {
|
|
3690
3689
|
return new Promise((e) => {
|
|
3691
3690
|
const n = indexedDB.open(t);
|
|
@@ -3701,7 +3700,7 @@ function au(t) {
|
|
|
3701
3700
|
});
|
|
3702
3701
|
});
|
|
3703
3702
|
}
|
|
3704
|
-
function
|
|
3703
|
+
function au(t, e, n) {
|
|
3705
3704
|
return ue(this, void 0, void 0, function* () {
|
|
3706
3705
|
const r = (
|
|
3707
3706
|
// Backwards compatibility for older versions where we JSON.stringified before storing
|
|
@@ -3745,9 +3744,9 @@ function Zn(t, e, n) {
|
|
|
3745
3744
|
});
|
|
3746
3745
|
});
|
|
3747
3746
|
}
|
|
3748
|
-
function
|
|
3747
|
+
function cu(t, e) {
|
|
3749
3748
|
return ue(this, void 0, void 0, function* () {
|
|
3750
|
-
const n = yield
|
|
3749
|
+
const n = yield uu(`instant_${t}_5`);
|
|
3751
3750
|
if (!n)
|
|
3752
3751
|
return;
|
|
3753
3752
|
const r = yield new Promise((d, f) => {
|
|
@@ -3770,7 +3769,7 @@ function du(t, e) {
|
|
|
3770
3769
|
for (const [d, f] of r)
|
|
3771
3770
|
switch (d) {
|
|
3772
3771
|
case "querySubs": {
|
|
3773
|
-
const l =
|
|
3772
|
+
const l = au(d, f, o);
|
|
3774
3773
|
u.push(l);
|
|
3775
3774
|
break;
|
|
3776
3775
|
}
|
|
@@ -3793,9 +3792,9 @@ function du(t, e) {
|
|
|
3793
3792
|
});
|
|
3794
3793
|
}
|
|
3795
3794
|
const Xn = /* @__PURE__ */ new Map();
|
|
3796
|
-
class Jr extends
|
|
3795
|
+
class Jr extends ru {
|
|
3797
3796
|
constructor(e, n) {
|
|
3798
|
-
super(e, n), this.dbName = `instant_${e}_${
|
|
3797
|
+
super(e, n), this.dbName = `instant_${e}_${iu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
|
|
3799
3798
|
}
|
|
3800
3799
|
_init() {
|
|
3801
3800
|
return new Promise((e, n) => {
|
|
@@ -3806,8 +3805,8 @@ class Jr extends iu {
|
|
|
3806
3805
|
}, i.onsuccess = (s) => {
|
|
3807
3806
|
const u = s.target.result;
|
|
3808
3807
|
if (r) {
|
|
3809
|
-
const a =
|
|
3810
|
-
|
|
3808
|
+
const a = cu(this._appId, u).catch((c) => {
|
|
3809
|
+
ou("Error upgrading store from version 5 to 6.")(c);
|
|
3811
3810
|
});
|
|
3812
3811
|
Xn.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
|
|
3813
3812
|
} else {
|
|
@@ -3821,7 +3820,7 @@ class Jr extends iu {
|
|
|
3821
3820
|
}
|
|
3822
3821
|
_upgradeStore(e) {
|
|
3823
3822
|
const r = e.target.result;
|
|
3824
|
-
for (const i of
|
|
3823
|
+
for (const i of su)
|
|
3825
3824
|
r.objectStoreNames.contains(i) || r.createObjectStore(i);
|
|
3826
3825
|
}
|
|
3827
3826
|
getItem(e) {
|
|
@@ -3896,7 +3895,7 @@ class Jr extends iu {
|
|
|
3896
3895
|
});
|
|
3897
3896
|
}
|
|
3898
3897
|
}
|
|
3899
|
-
var
|
|
3898
|
+
var du = function(t, e, n, r) {
|
|
3900
3899
|
function i(s) {
|
|
3901
3900
|
return s instanceof n ? s : new n(function(o) {
|
|
3902
3901
|
o(s);
|
|
@@ -3925,7 +3924,7 @@ var fu = function(t, e, n, r) {
|
|
|
3925
3924
|
};
|
|
3926
3925
|
class Zr {
|
|
3927
3926
|
static getIsOnline() {
|
|
3928
|
-
return
|
|
3927
|
+
return du(this, void 0, void 0, function* () {
|
|
3929
3928
|
return navigator.onLine;
|
|
3930
3929
|
});
|
|
3931
3930
|
}
|
|
@@ -3950,7 +3949,7 @@ class je extends Error {
|
|
|
3950
3949
|
return "InstantError";
|
|
3951
3950
|
}
|
|
3952
3951
|
}
|
|
3953
|
-
var
|
|
3952
|
+
var fu = function(t, e, n, r) {
|
|
3954
3953
|
function i(s) {
|
|
3955
3954
|
return s instanceof n ? s : new n(function(o) {
|
|
3956
3955
|
o(s);
|
|
@@ -3990,7 +3989,7 @@ class bt extends je {
|
|
|
3990
3989
|
}
|
|
3991
3990
|
}
|
|
3992
3991
|
function te(t, e) {
|
|
3993
|
-
return
|
|
3992
|
+
return fu(this, void 0, void 0, function* () {
|
|
3994
3993
|
const n = yield fetch(t, e), r = yield n.json();
|
|
3995
3994
|
return n.status === 200 ? Promise.resolve(r) : Promise.reject(new bt({ status: n.status, body: r }));
|
|
3996
3995
|
});
|
|
@@ -4022,14 +4021,14 @@ var Ie = function(t, e, n, r) {
|
|
|
4022
4021
|
c((r = r.apply(t, e || [])).next());
|
|
4023
4022
|
});
|
|
4024
4023
|
};
|
|
4025
|
-
function
|
|
4024
|
+
function lu({ apiURI: t, appId: e, email: n }) {
|
|
4026
4025
|
return te(`${t}/runtime/auth/send_magic_code`, {
|
|
4027
4026
|
method: "POST",
|
|
4028
4027
|
headers: { "content-type": "application/json" },
|
|
4029
4028
|
body: JSON.stringify({ "app-id": e, email: n })
|
|
4030
4029
|
});
|
|
4031
4030
|
}
|
|
4032
|
-
function
|
|
4031
|
+
function hu(t) {
|
|
4033
4032
|
return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
|
|
4034
4033
|
return yield te(`${e}/runtime/auth/verify_magic_code`, {
|
|
4035
4034
|
method: "POST",
|
|
@@ -4042,7 +4041,7 @@ function pu(t) {
|
|
|
4042
4041
|
});
|
|
4043
4042
|
});
|
|
4044
4043
|
}
|
|
4045
|
-
function
|
|
4044
|
+
function pu(t) {
|
|
4046
4045
|
return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
|
|
4047
4046
|
return yield te(`${e}/runtime/auth/verify_refresh_token`, {
|
|
4048
4047
|
method: "POST",
|
|
@@ -4054,7 +4053,7 @@ function yu(t) {
|
|
|
4054
4053
|
});
|
|
4055
4054
|
});
|
|
4056
4055
|
}
|
|
4057
|
-
function
|
|
4056
|
+
function yu(t) {
|
|
4058
4057
|
return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
|
|
4059
4058
|
return yield te(`${e}/runtime/auth/sign_in_guest`, {
|
|
4060
4059
|
method: "POST",
|
|
@@ -4079,7 +4078,7 @@ function er(t) {
|
|
|
4079
4078
|
});
|
|
4080
4079
|
});
|
|
4081
4080
|
}
|
|
4082
|
-
function
|
|
4081
|
+
function bu(t) {
|
|
4083
4082
|
return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
|
|
4084
4083
|
return yield te(`${e}/runtime/oauth/id_token`, {
|
|
4085
4084
|
method: "POST",
|
|
@@ -4094,7 +4093,7 @@ function _u(t) {
|
|
|
4094
4093
|
});
|
|
4095
4094
|
});
|
|
4096
4095
|
}
|
|
4097
|
-
function
|
|
4096
|
+
function _u(t) {
|
|
4098
4097
|
return Ie(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
|
|
4099
4098
|
return yield te(`${e}/runtime/signout`, {
|
|
4100
4099
|
method: "POST",
|
|
@@ -4135,7 +4134,7 @@ var Be = function(t, e, n, r) {
|
|
|
4135
4134
|
c((r = r.apply(t, e || [])).next());
|
|
4136
4135
|
});
|
|
4137
4136
|
};
|
|
4138
|
-
function
|
|
4137
|
+
function gu(t) {
|
|
4139
4138
|
return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
|
|
4140
4139
|
const a = {
|
|
4141
4140
|
app_id: n,
|
|
@@ -4150,7 +4149,7 @@ function Tu(t) {
|
|
|
4150
4149
|
});
|
|
4151
4150
|
});
|
|
4152
4151
|
}
|
|
4153
|
-
function
|
|
4152
|
+
function Tu(t) {
|
|
4154
4153
|
return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
|
|
4155
4154
|
const { data: s } = yield te(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
|
|
4156
4155
|
method: "DELETE",
|
|
@@ -4162,7 +4161,7 @@ function wu(t) {
|
|
|
4162
4161
|
return s;
|
|
4163
4162
|
});
|
|
4164
4163
|
}
|
|
4165
|
-
function
|
|
4164
|
+
function wu(t) {
|
|
4166
4165
|
return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
|
|
4167
4166
|
const { data: o } = yield te(`${e}/storage/signed-upload-url`, {
|
|
4168
4167
|
method: "POST",
|
|
@@ -4178,7 +4177,7 @@ function mu(t) {
|
|
|
4178
4177
|
return o;
|
|
4179
4178
|
});
|
|
4180
4179
|
}
|
|
4181
|
-
function
|
|
4180
|
+
function mu(t, e) {
|
|
4182
4181
|
return Be(this, void 0, void 0, function* () {
|
|
4183
4182
|
return (yield fetch(t, {
|
|
4184
4183
|
method: "PUT",
|
|
@@ -4189,7 +4188,7 @@ function vu(t, e) {
|
|
|
4189
4188
|
})).ok;
|
|
4190
4189
|
});
|
|
4191
4190
|
}
|
|
4192
|
-
function
|
|
4191
|
+
function vu(t) {
|
|
4193
4192
|
return Be(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
|
|
4194
4193
|
const { data: s } = yield te(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
|
|
4195
4194
|
method: "GET",
|
|
@@ -4211,7 +4210,7 @@ function tr(t, e) {
|
|
|
4211
4210
|
n[r] = t[r];
|
|
4212
4211
|
}), n;
|
|
4213
4212
|
}
|
|
4214
|
-
function
|
|
4213
|
+
function Su(t, e, n) {
|
|
4215
4214
|
var r, i;
|
|
4216
4215
|
const s = {
|
|
4217
4216
|
peers: {}
|
|
@@ -4229,7 +4228,7 @@ function Ou(t, e, n) {
|
|
|
4229
4228
|
}
|
|
4230
4229
|
return s;
|
|
4231
4230
|
}
|
|
4232
|
-
function
|
|
4231
|
+
function Ou(t, e) {
|
|
4233
4232
|
if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Nn(t.user, e.user)) || !Cr(t.peers, e.peers))
|
|
4234
4233
|
return !0;
|
|
4235
4234
|
for (const r of Object.keys(t.peers))
|
|
@@ -4277,8 +4276,8 @@ function ir(t) {
|
|
|
4277
4276
|
}, e;
|
|
4278
4277
|
}, {});
|
|
4279
4278
|
}
|
|
4280
|
-
const ni = "v0.22.89-experimental.uuidfix.
|
|
4281
|
-
function
|
|
4279
|
+
const ni = "v0.22.89-experimental.uuidfix.20282614127.1";
|
|
4280
|
+
function Au(t, e) {
|
|
4282
4281
|
return {
|
|
4283
4282
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
4284
4283
|
},
|
|
@@ -4327,7 +4326,7 @@ const sr = [
|
|
|
4327
4326
|
"before",
|
|
4328
4327
|
"fields",
|
|
4329
4328
|
"aggregate"
|
|
4330
|
-
],
|
|
4329
|
+
], Eu = (t) => t.valueType || "unknown", ri = (t, e, n = !1) => {
|
|
4331
4330
|
if (n || t == null)
|
|
4332
4331
|
return !0;
|
|
4333
4332
|
switch (e) {
|
|
@@ -4342,7 +4341,7 @@ const sr = [
|
|
|
4342
4341
|
default:
|
|
4343
4342
|
return !0;
|
|
4344
4343
|
}
|
|
4345
|
-
},
|
|
4344
|
+
}, ku = (t, e, n, r, i, s, o) => {
|
|
4346
4345
|
const u = s.valueType === "json", a = (c, d, f) => {
|
|
4347
4346
|
if (!ri(f, d, u))
|
|
4348
4347
|
throw new M(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
|
|
@@ -4375,16 +4374,16 @@ const sr = [
|
|
|
4375
4374
|
throw new M(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
|
|
4376
4375
|
}
|
|
4377
4376
|
}, Ae = (t, e, n, r, i) => {
|
|
4378
|
-
const s =
|
|
4377
|
+
const s = Eu(n), o = n.valueType === "json";
|
|
4379
4378
|
if (typeof t == "object" && t !== null && !Array.isArray(t)) {
|
|
4380
4379
|
if (o)
|
|
4381
4380
|
return;
|
|
4382
4381
|
const a = t;
|
|
4383
4382
|
for (const [c, d] of Object.entries(a))
|
|
4384
|
-
|
|
4383
|
+
ku(c, d, s, e, r, n, `${i}.${c}`);
|
|
4385
4384
|
} else if (!ri(t, s, o))
|
|
4386
4385
|
throw new M(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
|
|
4387
|
-
},
|
|
4386
|
+
}, ju = (t, e, n, r, i) => {
|
|
4388
4387
|
const s = t.split(".");
|
|
4389
4388
|
if (s.length < 2)
|
|
4390
4389
|
throw new M(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
|
|
@@ -4434,7 +4433,7 @@ const sr = [
|
|
|
4434
4433
|
continue;
|
|
4435
4434
|
}
|
|
4436
4435
|
if (i.includes(".")) {
|
|
4437
|
-
|
|
4436
|
+
ju(i, s, e, n, `${r}.${i}`);
|
|
4438
4437
|
continue;
|
|
4439
4438
|
}
|
|
4440
4439
|
const o = n.entities[e];
|
|
@@ -4454,7 +4453,7 @@ const sr = [
|
|
|
4454
4453
|
Ae(s, i, c, e, `${r}.${i}`);
|
|
4455
4454
|
}
|
|
4456
4455
|
}
|
|
4457
|
-
},
|
|
4456
|
+
}, Cu = (t, e, n, r, i = 0) => {
|
|
4458
4457
|
for (const o of Object.keys(t))
|
|
4459
4458
|
if (!sr.includes(o))
|
|
4460
4459
|
throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${sr.join(", ")}. Found: ${o}`, r);
|
|
@@ -4493,7 +4492,7 @@ const sr = [
|
|
|
4493
4492
|
const u = t[o];
|
|
4494
4493
|
if (typeof u != "object" || u === null)
|
|
4495
4494
|
throw new M(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
|
|
4496
|
-
|
|
4495
|
+
Cu(u, e, n, `${r}.$`, i);
|
|
4497
4496
|
}
|
|
4498
4497
|
}, or = (t, e) => {
|
|
4499
4498
|
if (typeof t != "object" || t === null)
|
|
@@ -4520,19 +4519,19 @@ class Z extends Error {
|
|
|
4520
4519
|
super(e), this.name = "TransactionValidationError";
|
|
4521
4520
|
}
|
|
4522
4521
|
}
|
|
4523
|
-
const oi = (t) => t.length > 0 ? t.join(", ") : "none",
|
|
4522
|
+
const oi = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${oi(e)}`), ar = {
|
|
4524
4523
|
string: (t) => typeof t == "string",
|
|
4525
4524
|
number: (t) => typeof t == "number" && !isNaN(t),
|
|
4526
4525
|
boolean: (t) => typeof t == "boolean",
|
|
4527
4526
|
date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
|
|
4528
4527
|
json: () => !0
|
|
4529
|
-
},
|
|
4528
|
+
}, Pu = (t, e) => {
|
|
4530
4529
|
var n, r;
|
|
4531
4530
|
return t == null ? !0 : (r = (n = ar[e.valueType]) === null || n === void 0 ? void 0 : n.call(ar, t)) !== null && r !== void 0 ? r : !1;
|
|
4532
4531
|
}, ui = (t, e) => {
|
|
4533
4532
|
const n = e.entities[t];
|
|
4534
4533
|
if (!n)
|
|
4535
|
-
throw
|
|
4534
|
+
throw Iu(t, Object.keys(e.entities));
|
|
4536
4535
|
return n;
|
|
4537
4536
|
}, jt = (t, e, n) => {
|
|
4538
4537
|
const r = ui(t, n);
|
|
@@ -4542,7 +4541,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Pu = (t, e) => new Z(`En
|
|
|
4542
4541
|
if (i === "id")
|
|
4543
4542
|
continue;
|
|
4544
4543
|
const o = r.attrs[i];
|
|
4545
|
-
if (o && !
|
|
4544
|
+
if (o && !Pu(s, o))
|
|
4546
4545
|
throw new Z(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
|
|
4547
4546
|
}
|
|
4548
4547
|
}, cr = (t, e, n) => {
|
|
@@ -4563,7 +4562,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Pu = (t, e) => new Z(`En
|
|
|
4563
4562
|
throw new Z(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
|
|
4564
4563
|
}
|
|
4565
4564
|
}
|
|
4566
|
-
},
|
|
4565
|
+
}, Mu = {
|
|
4567
4566
|
create: jt,
|
|
4568
4567
|
update: jt,
|
|
4569
4568
|
merge: jt,
|
|
@@ -4571,7 +4570,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Pu = (t, e) => new Z(`En
|
|
|
4571
4570
|
unlink: cr,
|
|
4572
4571
|
delete: () => {
|
|
4573
4572
|
}
|
|
4574
|
-
},
|
|
4573
|
+
}, Ru = (t, e) => {
|
|
4575
4574
|
if (!e)
|
|
4576
4575
|
return;
|
|
4577
4576
|
const [n, r, i, s] = t;
|
|
@@ -4579,9 +4578,9 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Pu = (t, e) => new Z(`En
|
|
|
4579
4578
|
throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
|
|
4580
4579
|
if (typeof r != "string")
|
|
4581
4580
|
throw new Z(`Entity name must be a string, but received: ${typeof r}`);
|
|
4582
|
-
const o =
|
|
4581
|
+
const o = Mu[n];
|
|
4583
4582
|
o && s !== void 0 && o(r, s, e);
|
|
4584
|
-
},
|
|
4583
|
+
}, $u = (t, e) => {
|
|
4585
4584
|
const n = Array.isArray(t) ? t : [t];
|
|
4586
4585
|
for (const r of n) {
|
|
4587
4586
|
if (!r || typeof r != "object")
|
|
@@ -4591,7 +4590,7 @@ const oi = (t) => t.length > 0 ? t.join(", ") : "none", Pu = (t, e) => new Z(`En
|
|
|
4591
4590
|
for (const i of r.__ops) {
|
|
4592
4591
|
if (!Array.isArray(i))
|
|
4593
4592
|
throw new Z(`Transaction operation must be an array, but received: ${typeof i}`);
|
|
4594
|
-
|
|
4593
|
+
Ru(i, e);
|
|
4595
4594
|
}
|
|
4596
4595
|
}
|
|
4597
4596
|
};
|
|
@@ -4653,7 +4652,7 @@ class fr {
|
|
|
4653
4652
|
return this.conn.send(JSON.stringify(e));
|
|
4654
4653
|
}
|
|
4655
4654
|
}
|
|
4656
|
-
class
|
|
4655
|
+
class Du {
|
|
4657
4656
|
constructor(e, n) {
|
|
4658
4657
|
this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${ai++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
|
|
4659
4658
|
this.initParams || this.handleError();
|
|
@@ -4766,7 +4765,7 @@ var lr = function(t, e, n, r) {
|
|
|
4766
4765
|
c((r = r.apply(t, e || [])).next());
|
|
4767
4766
|
});
|
|
4768
4767
|
};
|
|
4769
|
-
function
|
|
4768
|
+
function xu(t, e) {
|
|
4770
4769
|
const n = t.values;
|
|
4771
4770
|
if (n) {
|
|
4772
4771
|
const r = Dr(n.attrsStore, null);
|
|
@@ -4778,7 +4777,7 @@ function Uu(t, e) {
|
|
|
4778
4777
|
}
|
|
4779
4778
|
return t;
|
|
4780
4779
|
}
|
|
4781
|
-
function
|
|
4780
|
+
function Uu(t, e) {
|
|
4782
4781
|
var n;
|
|
4783
4782
|
if (e.values) {
|
|
4784
4783
|
const r = [];
|
|
@@ -4790,7 +4789,7 @@ function Lu(t, e) {
|
|
|
4790
4789
|
} else
|
|
4791
4790
|
return e;
|
|
4792
4791
|
}
|
|
4793
|
-
function
|
|
4792
|
+
function Lu(t, e, n) {
|
|
4794
4793
|
var r, i;
|
|
4795
4794
|
const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
|
|
4796
4795
|
return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
|
|
@@ -4817,7 +4816,7 @@ function pr(t, e, n) {
|
|
|
4817
4816
|
break;
|
|
4818
4817
|
}
|
|
4819
4818
|
}
|
|
4820
|
-
function
|
|
4819
|
+
function Fu(t, e, n) {
|
|
4821
4820
|
var r, i, s, o;
|
|
4822
4821
|
const u = {};
|
|
4823
4822
|
for (const { action: a, triple: c } of n) {
|
|
@@ -4845,14 +4844,14 @@ function Nu(t, e, n) {
|
|
|
4845
4844
|
function rt(t, e) {
|
|
4846
4845
|
return { [t.table]: e.map((n) => n.entity) };
|
|
4847
4846
|
}
|
|
4848
|
-
function
|
|
4847
|
+
function Nu(t, e) {
|
|
4849
4848
|
var n;
|
|
4850
4849
|
if (t.orderFieldType)
|
|
4851
4850
|
return t.orderFieldType;
|
|
4852
4851
|
const r = t.orderField === "serverCreatedAt" ? "number" : (n = F(e(), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
|
|
4853
4852
|
return t.orderFieldType = r, r;
|
|
4854
4853
|
}
|
|
4855
|
-
function
|
|
4854
|
+
function Ku(t, e, n) {
|
|
4856
4855
|
const r = e;
|
|
4857
4856
|
if (t.orderField === "serverCreatedAt") {
|
|
4858
4857
|
n.sort(t.orderDirection === "asc" ? function(o, u) {
|
|
@@ -4873,13 +4872,13 @@ var pe;
|
|
|
4873
4872
|
(function(t) {
|
|
4874
4873
|
t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
|
|
4875
4874
|
})(pe || (pe = {}));
|
|
4876
|
-
class
|
|
4875
|
+
class qu {
|
|
4877
4876
|
constructor(e, n, r, i, s, o) {
|
|
4878
4877
|
this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.getAttrs = o, this.subs = new Qt({
|
|
4879
4878
|
persister: n,
|
|
4880
|
-
merge:
|
|
4881
|
-
serialize:
|
|
4882
|
-
parse: (u, a) =>
|
|
4879
|
+
merge: Lu,
|
|
4880
|
+
serialize: Uu,
|
|
4881
|
+
parse: (u, a) => xu(a, this.config.useDateObjects),
|
|
4883
4882
|
objectSize: (u) => {
|
|
4884
4883
|
var a;
|
|
4885
4884
|
return ((a = u.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
|
|
@@ -5081,7 +5080,7 @@ class zu {
|
|
|
5081
5080
|
const S = p[A];
|
|
5082
5081
|
if (Ts(S.store, g)) {
|
|
5083
5082
|
pr(S.store, l.attrsStore, v);
|
|
5084
|
-
const C = Ct(u, S.store, l.attrsStore), $ =
|
|
5083
|
+
const C = Ct(u, S.store, l.attrsStore), $ = Fu(S.store, l.attrsStore, v)[g];
|
|
5085
5084
|
C ? (y.push({
|
|
5086
5085
|
oldEntity: S.entity,
|
|
5087
5086
|
newEntity: C,
|
|
@@ -5112,8 +5111,8 @@ class zu {
|
|
|
5112
5111
|
const _ = [];
|
|
5113
5112
|
for (const g of d.sort().reverse())
|
|
5114
5113
|
_.push(p[g].entity), p.splice(g, 1);
|
|
5115
|
-
const w =
|
|
5116
|
-
|
|
5114
|
+
const w = Nu(u, this.getAttrs);
|
|
5115
|
+
Ku(u, w, p), this.notifyCbs(o, {
|
|
5117
5116
|
type: pe.SyncTransaction,
|
|
5118
5117
|
data: rt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
|
|
5119
5118
|
added: b,
|
|
@@ -5194,23 +5193,23 @@ const oe = {
|
|
|
5194
5193
|
AUTHENTICATED: "authenticated",
|
|
5195
5194
|
CLOSED: "closed",
|
|
5196
5195
|
ERRORED: "errored"
|
|
5197
|
-
},
|
|
5196
|
+
}, zu = 3e4, Vu = 3e4, Wu = 200, Bu = {
|
|
5198
5197
|
apiURI: "https://api.instantdb.com",
|
|
5199
5198
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
5200
5199
|
}, It = "_instant_oauth_redirect", De = "currentUser";
|
|
5201
|
-
function
|
|
5200
|
+
function Gu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
|
|
5202
5201
|
if (!i)
|
|
5203
5202
|
return new fr(`${r}?app_id=${e}`);
|
|
5204
5203
|
switch (t) {
|
|
5205
5204
|
case "ws":
|
|
5206
5205
|
return new fr(`${r}?app_id=${e}`);
|
|
5207
5206
|
case "sse":
|
|
5208
|
-
return new
|
|
5207
|
+
return new Du(i, `${n}/runtime/sse?app_id=${e}`);
|
|
5209
5208
|
default:
|
|
5210
5209
|
throw new Error("Unknown transport type " + t);
|
|
5211
5210
|
}
|
|
5212
5211
|
}
|
|
5213
|
-
function
|
|
5212
|
+
function Qu() {
|
|
5214
5213
|
return typeof window < "u" || typeof chrome < "u";
|
|
5215
5214
|
}
|
|
5216
5215
|
const yr = {
|
|
@@ -5219,7 +5218,7 @@ const yr = {
|
|
|
5219
5218
|
"refresh-presence": !0,
|
|
5220
5219
|
"patch-presence": !0
|
|
5221
5220
|
};
|
|
5222
|
-
function
|
|
5221
|
+
function Hu(t, e) {
|
|
5223
5222
|
var n;
|
|
5224
5223
|
const r = typeof t == "string" ? JSON.parse(t) : t;
|
|
5225
5224
|
if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
|
|
@@ -5231,7 +5230,7 @@ function Yu(t, e) {
|
|
|
5231
5230
|
}
|
|
5232
5231
|
return r;
|
|
5233
5232
|
}
|
|
5234
|
-
function
|
|
5233
|
+
function Yu(t, e) {
|
|
5235
5234
|
const { result: n } = e, i = ci(e, ["result"]);
|
|
5236
5235
|
if (n) {
|
|
5237
5236
|
const s = Object.assign(Object.assign({}, n), { store: Rr(n.store), attrsStore: n.attrsStore.toJSON() });
|
|
@@ -5239,7 +5238,7 @@ function Ju(t, e) {
|
|
|
5239
5238
|
}
|
|
5240
5239
|
return i;
|
|
5241
5240
|
}
|
|
5242
|
-
function
|
|
5241
|
+
function Ju(t, e) {
|
|
5243
5242
|
switch (t) {
|
|
5244
5243
|
case "pendingMutations":
|
|
5245
5244
|
return new Map(typeof e == "string" ? JSON.parse(e) : e);
|
|
@@ -5247,7 +5246,7 @@ function Zu(t, e) {
|
|
|
5247
5246
|
return e;
|
|
5248
5247
|
}
|
|
5249
5248
|
}
|
|
5250
|
-
function
|
|
5249
|
+
function Zu(t, e) {
|
|
5251
5250
|
switch (t) {
|
|
5252
5251
|
case "pendingMutations":
|
|
5253
5252
|
return [...e.entries()];
|
|
@@ -5255,7 +5254,7 @@ function Xu(t, e) {
|
|
|
5255
5254
|
return e;
|
|
5256
5255
|
}
|
|
5257
5256
|
}
|
|
5258
|
-
function
|
|
5257
|
+
function Xu(t, e, n) {
|
|
5259
5258
|
const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
|
|
5260
5259
|
return r && !i && n && (n.result = r), n || e;
|
|
5261
5260
|
}
|
|
@@ -5265,7 +5264,7 @@ function br(t) {
|
|
|
5265
5264
|
return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
|
|
5266
5265
|
});
|
|
5267
5266
|
}
|
|
5268
|
-
class
|
|
5267
|
+
class ea {
|
|
5269
5268
|
constructor(e, n = Jr, r = Zr, i, s) {
|
|
5270
5269
|
var o, u, a;
|
|
5271
5270
|
if (this._isOnline = !0, this._isShutdown = !1, this.status = oe.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) => {
|
|
@@ -5298,9 +5297,9 @@ class ta {
|
|
|
5298
5297
|
}, this.notifyQueryError = (c, d) => {
|
|
5299
5298
|
(this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
|
|
5300
5299
|
}, this.pushTx = (c) => {
|
|
5301
|
-
this.config.disableValidation ||
|
|
5300
|
+
this.config.disableValidation || $u(c, this.config.schema);
|
|
5302
5301
|
try {
|
|
5303
|
-
const d =
|
|
5302
|
+
const d = nu({
|
|
5304
5303
|
attrsStore: this.optimisticAttrs(),
|
|
5305
5304
|
schema: this.config.schema,
|
|
5306
5305
|
stores: Object.values(this.querySubs.currentValue).map((f) => {
|
|
@@ -5389,7 +5388,7 @@ class ta {
|
|
|
5389
5388
|
return;
|
|
5390
5389
|
}
|
|
5391
5390
|
this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
|
|
5392
|
-
}, this._EventSource = s, this.config = Object.assign(Object.assign({},
|
|
5391
|
+
}, this._EventSource = s, this.config = Object.assign(Object.assign({}, Bu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Vu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Wu, this._log = Au(e.verbose || dn || Xr, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": ni }), this.config.schema && (this._linkIndex = ir(this.config.schema)), !!Qu()) {
|
|
5393
5392
|
if (!e.appId)
|
|
5394
5393
|
throw new Error("Instant must be initialized with an appId.");
|
|
5395
5394
|
if (!Ee(e.appId))
|
|
@@ -5404,7 +5403,7 @@ class ta {
|
|
|
5404
5403
|
} catch (f) {
|
|
5405
5404
|
this._log.error("[error] handle broadcast channel", f);
|
|
5406
5405
|
}
|
|
5407
|
-
}))), this._initStorage(n), this._syncTable = new
|
|
5406
|
+
}))), this._initStorage(n), this._syncTable = new qu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
|
|
5408
5407
|
useDateObjects: this.config.useDateObjects
|
|
5409
5408
|
}, this._log, (c) => at(this.ensureAttrs(), c, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((c) => {
|
|
5410
5409
|
this._isOnline = c, this._startSocket(), r.listen((d) => {
|
|
@@ -5434,9 +5433,9 @@ class ta {
|
|
|
5434
5433
|
_initStorage(e) {
|
|
5435
5434
|
this.querySubs = new Qt({
|
|
5436
5435
|
persister: new e(this.config.appId, "querySubs"),
|
|
5437
|
-
merge:
|
|
5438
|
-
serialize:
|
|
5439
|
-
parse: (n, r) =>
|
|
5436
|
+
merge: Xu,
|
|
5437
|
+
serialize: Yu,
|
|
5438
|
+
parse: (n, r) => Hu(r, this.config.useDateObjects),
|
|
5440
5439
|
// objectSize
|
|
5441
5440
|
objectSize: (n) => {
|
|
5442
5441
|
var r, i, s, o;
|
|
@@ -5455,8 +5454,8 @@ class ta {
|
|
|
5455
5454
|
}), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Qt({
|
|
5456
5455
|
persister: new e(this.config.appId, "kv"),
|
|
5457
5456
|
merge: this._onMergeKv,
|
|
5458
|
-
serialize:
|
|
5459
|
-
parse:
|
|
5457
|
+
serialize: Zu,
|
|
5458
|
+
parse: Ju,
|
|
5460
5459
|
objectSize: () => 0,
|
|
5461
5460
|
logger: this._log,
|
|
5462
5461
|
saveThrottleMs: 100,
|
|
@@ -5769,7 +5768,7 @@ class ta {
|
|
|
5769
5768
|
if (!this.querySubs)
|
|
5770
5769
|
return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
|
|
5771
5770
|
const s = q(e), o = this._startQuerySub(e, s);
|
|
5772
|
-
return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")),
|
|
5771
|
+
return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), zu), i.promise;
|
|
5773
5772
|
}
|
|
5774
5773
|
_completeQueryOnce(e, n, r) {
|
|
5775
5774
|
this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
|
|
@@ -5836,7 +5835,7 @@ class ta {
|
|
|
5836
5835
|
u = !0;
|
|
5837
5836
|
continue;
|
|
5838
5837
|
}
|
|
5839
|
-
const b = u ?
|
|
5838
|
+
const b = u ? Po(o, p) : p;
|
|
5840
5839
|
l.push(b);
|
|
5841
5840
|
}
|
|
5842
5841
|
return u ? l : d;
|
|
@@ -6002,7 +6001,7 @@ class ta {
|
|
|
6002
6001
|
return;
|
|
6003
6002
|
}
|
|
6004
6003
|
const e = this._transport;
|
|
6005
|
-
this._transport =
|
|
6004
|
+
this._transport = Gu({
|
|
6006
6005
|
transportType: this._transportType,
|
|
6007
6006
|
appId: this.config.appId,
|
|
6008
6007
|
apiURI: this.config.apiURI,
|
|
@@ -6205,7 +6204,7 @@ class ta {
|
|
|
6205
6204
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
|
|
6206
6205
|
}
|
|
6207
6206
|
sendMagicCode({ email: e }) {
|
|
6208
|
-
return
|
|
6207
|
+
return lu({
|
|
6209
6208
|
apiURI: this.config.apiURI,
|
|
6210
6209
|
appId: this.config.appId,
|
|
6211
6210
|
email: e
|
|
@@ -6214,7 +6213,7 @@ class ta {
|
|
|
6214
6213
|
signInWithMagicCode(e) {
|
|
6215
6214
|
return L(this, arguments, void 0, function* ({ email: n, code: r }) {
|
|
6216
6215
|
var i;
|
|
6217
|
-
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield
|
|
6216
|
+
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield hu({
|
|
6218
6217
|
apiURI: this.config.apiURI,
|
|
6219
6218
|
appId: this.config.appId,
|
|
6220
6219
|
email: n,
|
|
@@ -6226,7 +6225,7 @@ class ta {
|
|
|
6226
6225
|
}
|
|
6227
6226
|
signInWithCustomToken(e) {
|
|
6228
6227
|
return L(this, void 0, void 0, function* () {
|
|
6229
|
-
const n = yield
|
|
6228
|
+
const n = yield pu({
|
|
6230
6229
|
apiURI: this.config.apiURI,
|
|
6231
6230
|
appId: this.config.appId,
|
|
6232
6231
|
refreshToken: e
|
|
@@ -6236,7 +6235,7 @@ class ta {
|
|
|
6236
6235
|
}
|
|
6237
6236
|
signInAsGuest() {
|
|
6238
6237
|
return L(this, void 0, void 0, function* () {
|
|
6239
|
-
const e = yield
|
|
6238
|
+
const e = yield yu({
|
|
6240
6239
|
apiURI: this.config.apiURI,
|
|
6241
6240
|
appId: this.config.appId
|
|
6242
6241
|
});
|
|
@@ -6252,7 +6251,7 @@ class ta {
|
|
|
6252
6251
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
6253
6252
|
return;
|
|
6254
6253
|
}
|
|
6255
|
-
|
|
6254
|
+
_u({
|
|
6256
6255
|
apiURI: this.config.apiURI,
|
|
6257
6256
|
appId: this.config.appId,
|
|
6258
6257
|
refreshToken: i
|
|
@@ -6310,7 +6309,7 @@ class ta {
|
|
|
6310
6309
|
signInWithIdToken(e) {
|
|
6311
6310
|
return L(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
|
|
6312
6311
|
var s;
|
|
6313
|
-
const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield
|
|
6312
|
+
const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield bu({
|
|
6314
6313
|
apiURI: this.config.apiURI,
|
|
6315
6314
|
appId: this.config.appId,
|
|
6316
6315
|
idToken: n,
|
|
@@ -6351,7 +6350,7 @@ class ta {
|
|
|
6351
6350
|
// TODO: look into typing again
|
|
6352
6351
|
getPresence(e, n, r = {}) {
|
|
6353
6352
|
const i = this._rooms[n], s = this._presence[n];
|
|
6354
|
-
return !i || !s || !s.result ? null : Object.assign(Object.assign({},
|
|
6353
|
+
return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Su(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
|
|
6355
6354
|
}
|
|
6356
6355
|
// TODO: look into typing again
|
|
6357
6356
|
publishPresence(e, n, r) {
|
|
@@ -6401,7 +6400,7 @@ class ta {
|
|
|
6401
6400
|
}
|
|
6402
6401
|
_notifyPresenceSub(e, n) {
|
|
6403
6402
|
const r = this.getPresence("", e, n);
|
|
6404
|
-
r && (n.prev && !
|
|
6403
|
+
r && (n.prev && !Ou(r, n.prev) || (n.prev = r, n.cb(r)));
|
|
6405
6404
|
}
|
|
6406
6405
|
_patchPresencePeers(e, n) {
|
|
6407
6406
|
var r, i, s;
|
|
@@ -6475,14 +6474,14 @@ class ta {
|
|
|
6475
6474
|
return L(this, void 0, void 0, function* () {
|
|
6476
6475
|
var i;
|
|
6477
6476
|
const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
|
|
6478
|
-
return
|
|
6477
|
+
return gu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
|
|
6479
6478
|
});
|
|
6480
6479
|
}
|
|
6481
6480
|
deleteFile(e) {
|
|
6482
6481
|
return L(this, void 0, void 0, function* () {
|
|
6483
6482
|
var n;
|
|
6484
6483
|
const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
|
|
6485
|
-
return yield
|
|
6484
|
+
return yield Tu({
|
|
6486
6485
|
apiURI: this.config.apiURI,
|
|
6487
6486
|
appId: this.config.appId,
|
|
6488
6487
|
path: e,
|
|
@@ -6495,20 +6494,20 @@ class ta {
|
|
|
6495
6494
|
upload(e, n) {
|
|
6496
6495
|
return L(this, void 0, void 0, function* () {
|
|
6497
6496
|
var r;
|
|
6498
|
-
const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield
|
|
6497
|
+
const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield wu({
|
|
6499
6498
|
apiURI: this.config.apiURI,
|
|
6500
6499
|
appId: this.config.appId,
|
|
6501
6500
|
fileName: o,
|
|
6502
6501
|
refreshToken: s
|
|
6503
6502
|
});
|
|
6504
|
-
return yield
|
|
6503
|
+
return yield mu(u, n);
|
|
6505
6504
|
});
|
|
6506
6505
|
}
|
|
6507
6506
|
getDownloadUrl(e) {
|
|
6508
6507
|
return L(this, void 0, void 0, function* () {
|
|
6509
6508
|
var n;
|
|
6510
6509
|
const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
|
|
6511
|
-
return yield
|
|
6510
|
+
return yield vu({
|
|
6512
6511
|
apiURI: this.config.apiURI,
|
|
6513
6512
|
appId: this.config.appId,
|
|
6514
6513
|
path: e,
|
|
@@ -6518,9 +6517,9 @@ class ta {
|
|
|
6518
6517
|
}
|
|
6519
6518
|
}
|
|
6520
6519
|
let it;
|
|
6521
|
-
function
|
|
6520
|
+
function ta(t, e) {
|
|
6522
6521
|
it == null || it.dispose();
|
|
6523
|
-
const n =
|
|
6522
|
+
const n = ua(e), r = ia(e, u), i = ra(na(t));
|
|
6524
6523
|
function s(d) {
|
|
6525
6524
|
var f;
|
|
6526
6525
|
d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
|
|
@@ -6542,10 +6541,10 @@ function na(t, e) {
|
|
|
6542
6541
|
}
|
|
6543
6542
|
return c();
|
|
6544
6543
|
}
|
|
6545
|
-
function
|
|
6544
|
+
function na(t) {
|
|
6546
6545
|
return `${dn || ei ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
6547
6546
|
}
|
|
6548
|
-
function
|
|
6547
|
+
function ra(t) {
|
|
6549
6548
|
const e = document.createElement("iframe");
|
|
6550
6549
|
return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
6551
6550
|
width: "100%",
|
|
@@ -6554,7 +6553,7 @@ function ia(t) {
|
|
|
6554
6553
|
border: "none"
|
|
6555
6554
|
}), { element: e };
|
|
6556
6555
|
}
|
|
6557
|
-
function
|
|
6556
|
+
function ia(t, e) {
|
|
6558
6557
|
const n = `
|
|
6559
6558
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6560
6559
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -6564,7 +6563,7 @@ function sa(t, e) {
|
|
|
6564
6563
|
return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
|
|
6565
6564
|
// pos
|
|
6566
6565
|
position: "fixed"
|
|
6567
|
-
},
|
|
6566
|
+
}, sa(t.position)), {
|
|
6568
6567
|
height: "32px",
|
|
6569
6568
|
width: "32px",
|
|
6570
6569
|
// layout
|
|
@@ -6579,7 +6578,7 @@ function sa(t, e) {
|
|
|
6579
6578
|
cursor: "pointer"
|
|
6580
6579
|
})), r.addEventListener("click", e), { element: r };
|
|
6581
6580
|
}
|
|
6582
|
-
function
|
|
6581
|
+
function sa(t) {
|
|
6583
6582
|
switch (t) {
|
|
6584
6583
|
case "bottom-left":
|
|
6585
6584
|
return { bottom: "24px", left: "24px" };
|
|
@@ -6591,7 +6590,7 @@ function oa(t) {
|
|
|
6591
6590
|
return { top: "24px", left: "24px" };
|
|
6592
6591
|
}
|
|
6593
6592
|
}
|
|
6594
|
-
function
|
|
6593
|
+
function oa(t) {
|
|
6595
6594
|
switch (t) {
|
|
6596
6595
|
case "bottom-left":
|
|
6597
6596
|
return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
|
|
@@ -6603,23 +6602,23 @@ function ua(t) {
|
|
|
6603
6602
|
return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
|
|
6604
6603
|
}
|
|
6605
6604
|
}
|
|
6606
|
-
function
|
|
6605
|
+
function ua(t) {
|
|
6607
6606
|
const e = document.createElement("div");
|
|
6608
|
-
Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" },
|
|
6607
|
+
Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, oa(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
|
|
6609
6608
|
function n() {
|
|
6610
6609
|
return e.style.display !== "none";
|
|
6611
6610
|
}
|
|
6612
6611
|
return { element: e, isVisible: n };
|
|
6613
6612
|
}
|
|
6614
|
-
const
|
|
6613
|
+
const aa = {
|
|
6615
6614
|
apiURI: "https://api.instantdb.com",
|
|
6616
6615
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
6617
6616
|
};
|
|
6618
|
-
function
|
|
6617
|
+
function ca() {
|
|
6619
6618
|
var t;
|
|
6620
6619
|
return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
6621
6620
|
}
|
|
6622
|
-
function
|
|
6621
|
+
function da() {
|
|
6623
6622
|
var t;
|
|
6624
6623
|
return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
|
|
6625
6624
|
}
|
|
@@ -6627,23 +6626,23 @@ function Ht(t) {
|
|
|
6627
6626
|
const e = t.__adminToken;
|
|
6628
6627
|
return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
|
|
6629
6628
|
}
|
|
6630
|
-
const Yt =
|
|
6631
|
-
class
|
|
6629
|
+
const Yt = da(), _r = ca();
|
|
6630
|
+
class fa {
|
|
6632
6631
|
constructor(e) {
|
|
6633
6632
|
this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
|
|
6634
6633
|
}
|
|
6635
6634
|
}
|
|
6636
|
-
class
|
|
6635
|
+
class la {
|
|
6637
6636
|
constructor(e) {
|
|
6638
6637
|
this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
|
|
6639
6638
|
}
|
|
6640
6639
|
}
|
|
6641
|
-
function
|
|
6640
|
+
function ha(t) {
|
|
6642
6641
|
return JSON.parse(JSON.stringify(t));
|
|
6643
6642
|
}
|
|
6644
|
-
class
|
|
6643
|
+
class pa {
|
|
6645
6644
|
constructor(e) {
|
|
6646
|
-
this.tx = cn(), this._reactor = e, this.auth = new
|
|
6645
|
+
this.tx = cn(), this._reactor = e, this.auth = new fa(this._reactor), this.storage = new la(this._reactor);
|
|
6647
6646
|
}
|
|
6648
6647
|
/**
|
|
6649
6648
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -6826,24 +6825,24 @@ function gr(t) {
|
|
|
6826
6825
|
const n = q(t);
|
|
6827
6826
|
return _r.set(t, n), n;
|
|
6828
6827
|
}
|
|
6829
|
-
function
|
|
6828
|
+
function ya(t, e) {
|
|
6830
6829
|
return gr(t._reactor.config.schema) !== gr(e);
|
|
6831
6830
|
}
|
|
6832
|
-
function
|
|
6831
|
+
function ba(t, e, n, r, i) {
|
|
6833
6832
|
var s;
|
|
6834
6833
|
const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = Yt[Ht(o)];
|
|
6835
6834
|
if (u)
|
|
6836
|
-
return
|
|
6837
|
-
const a = new
|
|
6838
|
-
return Yt[Ht(o)] = c,
|
|
6835
|
+
return ya(u, o.schema) && u._reactor.updateSchema(o.schema), u;
|
|
6836
|
+
const a = new ea(Object.assign(Object.assign(Object.assign({}, aa), o), { cardinalityInference: !!o.schema }), e || Jr, n || Zr, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": ni }), i), c = new pa(a);
|
|
6837
|
+
return Yt[Ht(o)] = c, _a(o.appId, o.devtool), c;
|
|
6839
6838
|
}
|
|
6840
|
-
function
|
|
6839
|
+
function _a(t, e) {
|
|
6841
6840
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
6842
6841
|
return;
|
|
6843
6842
|
const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
|
|
6844
|
-
n.allowedHosts.includes(window.location.hostname) &&
|
|
6843
|
+
n.allowedHosts.includes(window.location.hostname) && ta(t, n);
|
|
6845
6844
|
}
|
|
6846
|
-
const
|
|
6845
|
+
const ga = {
|
|
6847
6846
|
isLoading: !0,
|
|
6848
6847
|
data: void 0,
|
|
6849
6848
|
pageInfo: void 0,
|
|
@@ -6858,9 +6857,9 @@ function Tr(t) {
|
|
|
6858
6857
|
...t || {}
|
|
6859
6858
|
};
|
|
6860
6859
|
}
|
|
6861
|
-
function
|
|
6860
|
+
function Ta(t, e, n) {
|
|
6862
6861
|
e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
|
|
6863
|
-
const r = e ?
|
|
6862
|
+
const r = e ? ha(e) : null, i = q(r), s = qe(
|
|
6864
6863
|
Tr(t._reactor.getPreviousResult(r))
|
|
6865
6864
|
), o = fe(
|
|
6866
6865
|
(a) => (s.current = Tr(
|
|
@@ -6884,10 +6883,10 @@ function wa(t, e, n) {
|
|
|
6884
6883
|
return { state: Pt(
|
|
6885
6884
|
o,
|
|
6886
6885
|
() => s.current,
|
|
6887
|
-
() =>
|
|
6886
|
+
() => ga
|
|
6888
6887
|
), query: r };
|
|
6889
6888
|
}
|
|
6890
|
-
function
|
|
6889
|
+
function wa() {
|
|
6891
6890
|
const t = qe(null);
|
|
6892
6891
|
ge(() => {
|
|
6893
6892
|
n();
|
|
@@ -6900,8 +6899,8 @@ function ma() {
|
|
|
6900
6899
|
}
|
|
6901
6900
|
return { set: e, clear: n };
|
|
6902
6901
|
}
|
|
6903
|
-
const
|
|
6904
|
-
function
|
|
6902
|
+
const ma = 1e3;
|
|
6903
|
+
function va(t, e, n) {
|
|
6905
6904
|
const r = qe(n);
|
|
6906
6905
|
r.current = n, ge(() => t.core._reactor.subscribeTopic(
|
|
6907
6906
|
t.id,
|
|
@@ -6911,7 +6910,7 @@ function Sa(t, e, n) {
|
|
|
6911
6910
|
}
|
|
6912
6911
|
), [t.id, e]);
|
|
6913
6912
|
}
|
|
6914
|
-
function
|
|
6913
|
+
function Sa(t, e) {
|
|
6915
6914
|
return ge(() => t.core._reactor.joinRoom(t.id), [t.id]), fe(
|
|
6916
6915
|
(r) => {
|
|
6917
6916
|
t.core._reactor.publishTopic({
|
|
@@ -6924,7 +6923,7 @@ function Oa(t, e) {
|
|
|
6924
6923
|
[t.id, e]
|
|
6925
6924
|
);
|
|
6926
6925
|
}
|
|
6927
|
-
function
|
|
6926
|
+
function Oa(t, e = {}) {
|
|
6928
6927
|
var o, u;
|
|
6929
6928
|
const [n, r] = mr(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
|
|
6930
6929
|
peers: {},
|
|
@@ -6949,11 +6948,11 @@ function Aa(t, e = {}) {
|
|
|
6949
6948
|
publishPresence: i
|
|
6950
6949
|
}), [n, i]);
|
|
6951
6950
|
}
|
|
6952
|
-
function
|
|
6951
|
+
function Aa(t, e, n) {
|
|
6953
6952
|
ge(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ge(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
|
|
6954
6953
|
}
|
|
6955
|
-
function
|
|
6956
|
-
const r =
|
|
6954
|
+
function Ea(t, e, n = {}) {
|
|
6955
|
+
const r = wa(), i = ye.usePresence(t, {
|
|
6957
6956
|
keys: [e]
|
|
6958
6957
|
}), s = Mt(() => {
|
|
6959
6958
|
const d = t._core._reactor.getPresence(
|
|
@@ -6967,7 +6966,7 @@ function ka(t, e, n = {}) {
|
|
|
6967
6966
|
(d) => {
|
|
6968
6967
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
6969
6968
|
[e]: d
|
|
6970
|
-
}), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ??
|
|
6969
|
+
}), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? ma, () => {
|
|
6971
6970
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
6972
6971
|
[e]: null
|
|
6973
6972
|
});
|
|
@@ -6990,25 +6989,25 @@ function ka(t, e, n = {}) {
|
|
|
6990
6989
|
};
|
|
6991
6990
|
}
|
|
6992
6991
|
const ye = {
|
|
6993
|
-
useTopicEffect:
|
|
6994
|
-
usePublishTopic:
|
|
6995
|
-
usePresence:
|
|
6996
|
-
useSyncPresence:
|
|
6997
|
-
useTypingIndicator:
|
|
6992
|
+
useTopicEffect: va,
|
|
6993
|
+
usePublishTopic: Sa,
|
|
6994
|
+
usePresence: Oa,
|
|
6995
|
+
useSyncPresence: Aa,
|
|
6996
|
+
useTypingIndicator: Ea
|
|
6998
6997
|
};
|
|
6999
|
-
class
|
|
6998
|
+
class ka {
|
|
7000
6999
|
constructor(e, n, r) {
|
|
7001
7000
|
this.useTopicEffect = (i, s) => {
|
|
7002
7001
|
ye.useTopicEffect(this, i, s);
|
|
7003
7002
|
}, this.usePublishTopic = (i) => ye.usePublishTopic(this, i), this.usePresence = (i = {}) => ye.usePresence(this, i), this.useSyncPresence = (i, s) => ye.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => ye.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
|
|
7004
7003
|
}
|
|
7005
7004
|
}
|
|
7006
|
-
const
|
|
7005
|
+
const ja = {
|
|
7007
7006
|
isLoading: !0,
|
|
7008
7007
|
user: void 0,
|
|
7009
7008
|
error: void 0
|
|
7010
7009
|
};
|
|
7011
|
-
class
|
|
7010
|
+
class Ia {
|
|
7012
7011
|
constructor(e, n) {
|
|
7013
7012
|
this.tx = cn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
|
|
7014
7013
|
const [i, s] = mr(null);
|
|
@@ -7018,7 +7017,7 @@ class Pa {
|
|
|
7018
7017
|
s(u);
|
|
7019
7018
|
})();
|
|
7020
7019
|
}, [r]), i;
|
|
7021
|
-
}, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) =>
|
|
7020
|
+
}, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => Ta(this.core, r, i).state, this.useAuth = () => {
|
|
7022
7021
|
const r = qe(
|
|
7023
7022
|
this.core._reactor._currentUserCached
|
|
7024
7023
|
), i = fe((o) => this.core.subscribeAuth((a) => {
|
|
@@ -7027,7 +7026,7 @@ class Pa {
|
|
|
7027
7026
|
return Pt(
|
|
7028
7027
|
i,
|
|
7029
7028
|
() => r.current,
|
|
7030
|
-
() =>
|
|
7029
|
+
() => ja
|
|
7031
7030
|
);
|
|
7032
7031
|
}, this.useUser = () => {
|
|
7033
7032
|
const { user: r } = this.useAuth();
|
|
@@ -7054,7 +7053,7 @@ class Pa {
|
|
|
7054
7053
|
}, this.SignedOut = ({ children: r }) => {
|
|
7055
7054
|
const i = this.useAuth();
|
|
7056
7055
|
return i.isLoading || i.error || i.user ? null : /* @__PURE__ */ et.jsx(et.Fragment, { children: r });
|
|
7057
|
-
}, this.core =
|
|
7056
|
+
}, this.core = ba(
|
|
7058
7057
|
e,
|
|
7059
7058
|
// @ts-expect-error because TS can't resolve subclass statics
|
|
7060
7059
|
this.constructor.Storage,
|
|
@@ -7078,7 +7077,7 @@ class Pa {
|
|
|
7078
7077
|
* const { peers } = db.rooms.usePresence(room);
|
|
7079
7078
|
*/
|
|
7080
7079
|
room(e = "_defaultRoomType", n = "_defaultRoomId") {
|
|
7081
|
-
return new
|
|
7080
|
+
return new ka(this.core, e, n);
|
|
7082
7081
|
}
|
|
7083
7082
|
/**
|
|
7084
7083
|
* One time query for the logged in state. This is useful
|
|
@@ -7095,5 +7094,5 @@ class Pa {
|
|
|
7095
7094
|
}
|
|
7096
7095
|
}
|
|
7097
7096
|
export {
|
|
7098
|
-
|
|
7097
|
+
Ia as InstantReactAbstractDatabase
|
|
7099
7098
|
};
|