@instantdb/react 0.22.144 → 0.22.145
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 +100 -89
- package/dist/standalone/index.umd.cjs +5 -5
- package/package.json +4 -4
package/dist/standalone/index.js
CHANGED
|
@@ -238,7 +238,7 @@ function Oe(n) {
|
|
|
238
238
|
function gr() {
|
|
239
239
|
throw new Error("Cannot modify frozen object");
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Be(n, e, t, r, s) {
|
|
242
242
|
{
|
|
243
243
|
t = t ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], s = s ?? [];
|
|
244
244
|
const o = t.has(n) ? t.get(n) : n;
|
|
@@ -262,24 +262,24 @@ function Ve(n, e, t, r, s) {
|
|
|
262
262
|
switch (We(n)) {
|
|
263
263
|
case 2:
|
|
264
264
|
for (const [a, c] of n)
|
|
265
|
-
|
|
265
|
+
Be(a, a, t, r, s), Be(c, a, t, r, s);
|
|
266
266
|
n.set = n.clear = n.delete = gr;
|
|
267
267
|
break;
|
|
268
268
|
case 3:
|
|
269
269
|
for (const a of n)
|
|
270
|
-
|
|
270
|
+
Be(a, a, t, r, s);
|
|
271
271
|
n.add = n.clear = n.delete = gr;
|
|
272
272
|
break;
|
|
273
273
|
case 1:
|
|
274
274
|
Object.freeze(n);
|
|
275
275
|
let o = 0;
|
|
276
276
|
for (const a of n)
|
|
277
|
-
|
|
277
|
+
Be(a, o, t, r, s), o += 1;
|
|
278
278
|
break;
|
|
279
279
|
default:
|
|
280
280
|
Object.freeze(n), Object.keys(n).forEach((a) => {
|
|
281
281
|
const c = n[a];
|
|
282
|
-
|
|
282
|
+
Be(c, a, t, r, s);
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
r.pop(), s.pop();
|
|
@@ -785,7 +785,7 @@ function Ri(n, e, t, r, s) {
|
|
|
785
785
|
for (; o.finalities.draft.length > 0; )
|
|
786
786
|
o.finalities.draft.pop()(t, r);
|
|
787
787
|
const u = c ? e[0] : o ? o.operated ? o.copy : o.original : n;
|
|
788
|
-
return o && pn(o), s &&
|
|
788
|
+
return o && pn(o), s && Be(u, u, o == null ? void 0 : o.options.updatedValues), [
|
|
789
789
|
u,
|
|
790
790
|
t && c ? [{ op: z.Replace, path: [], value: e[0] }] : t,
|
|
791
791
|
r && c ? [{ op: z.Replace, path: [], value: a }] : r
|
|
@@ -1418,7 +1418,7 @@ function Qn(n) {
|
|
|
1418
1418
|
function Hn(n) {
|
|
1419
1419
|
return n["value-type"] === "blob";
|
|
1420
1420
|
}
|
|
1421
|
-
function
|
|
1421
|
+
function tt(n, e) {
|
|
1422
1422
|
return e.reduce((t, r) => t && t.get(r), n);
|
|
1423
1423
|
}
|
|
1424
1424
|
function me(n, e) {
|
|
@@ -1472,7 +1472,7 @@ function _s(n, e) {
|
|
|
1472
1472
|
return new Le(e.attrs, e.linkIndex);
|
|
1473
1473
|
}
|
|
1474
1474
|
function to(n, e) {
|
|
1475
|
-
return
|
|
1475
|
+
return tt(n.eav, [e]) !== void 0;
|
|
1476
1476
|
}
|
|
1477
1477
|
function ct(n, e, t, r) {
|
|
1478
1478
|
const s = ys(n, e, r);
|
|
@@ -1516,7 +1516,7 @@ let no = 0;
|
|
|
1516
1516
|
function ws(n, e, t) {
|
|
1517
1517
|
const [r, s, i] = t;
|
|
1518
1518
|
let o;
|
|
1519
|
-
const a =
|
|
1519
|
+
const a = tt(n.eav, [r, s, i]);
|
|
1520
1520
|
return a && (o = a[3]), o || Date.now() * 10 + no++;
|
|
1521
1521
|
}
|
|
1522
1522
|
function Ts(n, e, t) {
|
|
@@ -1528,7 +1528,7 @@ function Ts(n, e, t) {
|
|
|
1528
1528
|
if (!a)
|
|
1529
1529
|
return;
|
|
1530
1530
|
a["checked-data-type"] === "date" && n.useDateObjects && (o = qt(o));
|
|
1531
|
-
const c =
|
|
1531
|
+
const c = tt(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? ws(n, a, r), l = [s, i, o, u];
|
|
1532
1532
|
eo(a) ? (ce(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), ce(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (ce(n.eav, [s, i, o], l), ce(n.aev, [i, s, o], l)), Qn(a) && ce(n.vae, [o, i, s], l);
|
|
1533
1533
|
}
|
|
1534
1534
|
function ro(n, e, t) {
|
|
@@ -1541,7 +1541,7 @@ function ro(n, e, t) {
|
|
|
1541
1541
|
return;
|
|
1542
1542
|
if (!Hn(a))
|
|
1543
1543
|
throw new Error("merge operation is not supported for links");
|
|
1544
|
-
const c =
|
|
1544
|
+
const c = tt(n.eav, [s, i]);
|
|
1545
1545
|
if (!c)
|
|
1546
1546
|
return;
|
|
1547
1547
|
const u = (y = c.values().next()) == null ? void 0 : y.value;
|
|
@@ -1766,7 +1766,7 @@ function ho(n, e, t) {
|
|
|
1766
1766
|
return;
|
|
1767
1767
|
const [s, i, o] = r;
|
|
1768
1768
|
if (e.getAttr(i))
|
|
1769
|
-
return
|
|
1769
|
+
return tt(n.eav, [s, i]);
|
|
1770
1770
|
}
|
|
1771
1771
|
function po(n, e, t) {
|
|
1772
1772
|
const r = t.filter(([s, i, o, a, c]) => {
|
|
@@ -1861,7 +1861,7 @@ function Eo(n, e, t) {
|
|
|
1861
1861
|
return uo(n, Jn(t, e));
|
|
1862
1862
|
}
|
|
1863
1863
|
const Oo = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
1864
|
-
function
|
|
1864
|
+
function Xe(n) {
|
|
1865
1865
|
return typeof n == "string" && Oo.test(n);
|
|
1866
1866
|
}
|
|
1867
1867
|
const Y = [];
|
|
@@ -1936,7 +1936,7 @@ function ht(n) {
|
|
|
1936
1936
|
function zt(n, e) {
|
|
1937
1937
|
return `?${n}-${e}`;
|
|
1938
1938
|
}
|
|
1939
|
-
class
|
|
1939
|
+
class et extends Error {
|
|
1940
1940
|
constructor(e) {
|
|
1941
1941
|
super(e), this.name = "AttrNotFoundError";
|
|
1942
1942
|
}
|
|
@@ -1944,7 +1944,7 @@ class Xe extends Error {
|
|
|
1944
1944
|
function Uo(n, e) {
|
|
1945
1945
|
const t = Es(n, e);
|
|
1946
1946
|
if (!t)
|
|
1947
|
-
throw new
|
|
1947
|
+
throw new et(`Could not find id attr for ${e}`);
|
|
1948
1948
|
return t;
|
|
1949
1949
|
}
|
|
1950
1950
|
function Ar(n, e, t, r) {
|
|
@@ -1964,7 +1964,7 @@ function Fo(n, e, t) {
|
|
|
1964
1964
|
function ks(n, e, t, r, s) {
|
|
1965
1965
|
const i = B(e, t, s), o = Ke(e, t, s), a = i || o;
|
|
1966
1966
|
if (!a)
|
|
1967
|
-
throw new
|
|
1967
|
+
throw new et(`Could not find attr for ${[t, s]}`);
|
|
1968
1968
|
if (a["value-type"] !== "ref")
|
|
1969
1969
|
throw new Error(`Attr ${a.id} is not a ref`);
|
|
1970
1970
|
const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], p = r + 1, y = i ? [
|
|
@@ -2053,11 +2053,11 @@ function No(n, e) {
|
|
|
2053
2053
|
function Wo(n, e, t, r, s, i) {
|
|
2054
2054
|
const o = B(e, t, s), a = Ke(e, t, s), c = o || a;
|
|
2055
2055
|
if (!c)
|
|
2056
|
-
throw new
|
|
2056
|
+
throw new et(`No attr for etype = ${t} label = ${s}`);
|
|
2057
2057
|
if (i != null && i.hasOwnProperty("$isNull")) {
|
|
2058
2058
|
const u = B(e, t, "id");
|
|
2059
2059
|
if (!u)
|
|
2060
|
-
throw new
|
|
2060
|
+
throw new et(`No attr for etype = ${t} label = id`);
|
|
2061
2061
|
return [
|
|
2062
2062
|
n(t, r),
|
|
2063
2063
|
u.id,
|
|
@@ -2172,7 +2172,7 @@ function Yo(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
|
2172
2172
|
}), A = b ? v[0] : v;
|
|
2173
2173
|
return { [y]: A };
|
|
2174
2174
|
} catch (_) {
|
|
2175
|
-
if (_ instanceof
|
|
2175
|
+
if (_ instanceof et)
|
|
2176
2176
|
return { [y]: b ? void 0 : [] };
|
|
2177
2177
|
throw _;
|
|
2178
2178
|
}
|
|
@@ -2290,7 +2290,7 @@ function aa(n, e, t) {
|
|
|
2290
2290
|
try {
|
|
2291
2291
|
return oa(n, e, t);
|
|
2292
2292
|
} catch (r) {
|
|
2293
|
-
if (r instanceof
|
|
2293
|
+
if (r instanceof et)
|
|
2294
2294
|
return {};
|
|
2295
2295
|
throw r;
|
|
2296
2296
|
}
|
|
@@ -3485,7 +3485,7 @@ function Lr(n) {
|
|
|
3485
3485
|
}, e;
|
|
3486
3486
|
}, {});
|
|
3487
3487
|
}
|
|
3488
|
-
const Xn = "v0.22.
|
|
3488
|
+
const Xn = "v0.22.145";
|
|
3489
3489
|
function oc(n, e) {
|
|
3490
3490
|
return {
|
|
3491
3491
|
info: n ? (...t) => console.info(...t, e()) : () => {
|
|
@@ -3633,7 +3633,7 @@ const Fr = [
|
|
|
3633
3633
|
default:
|
|
3634
3634
|
throw new F(`Unknown operator '${n}' for attribute '${r}' in entity '${s}'`, o);
|
|
3635
3635
|
}
|
|
3636
|
-
},
|
|
3636
|
+
}, Ye = (n, e, t, r, s) => {
|
|
3637
3637
|
const i = ac(t), o = t.valueType === "json";
|
|
3638
3638
|
if (typeof n == "object" && n !== null && !Array.isArray(n)) {
|
|
3639
3639
|
if (o)
|
|
@@ -3663,23 +3663,23 @@ const Fr = [
|
|
|
3663
3663
|
if (!c)
|
|
3664
3664
|
throw new F(`Target entity '${o}' does not exist in schema for dot notation path '${n}'.`, s);
|
|
3665
3665
|
if (a === "id") {
|
|
3666
|
-
if (typeof e == "string" && !
|
|
3666
|
+
if (typeof e == "string" && !Xe(e))
|
|
3667
3667
|
throw new F(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3668
|
-
|
|
3668
|
+
Ye(e, n, new re("string", !1, !0), t, s);
|
|
3669
3669
|
return;
|
|
3670
3670
|
}
|
|
3671
3671
|
const u = c.attrs[a];
|
|
3672
3672
|
if (Object.keys(c.links).includes(a)) {
|
|
3673
|
-
if (typeof e == "string" && !
|
|
3673
|
+
if (typeof e == "string" && !Xe(e))
|
|
3674
3674
|
throw new F(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3675
|
-
|
|
3675
|
+
Ye(e, n, new re("string", !1, !0), t, s);
|
|
3676
3676
|
return;
|
|
3677
3677
|
}
|
|
3678
3678
|
if (!u) {
|
|
3679
3679
|
const l = Object.keys(c.attrs);
|
|
3680
3680
|
throw new F(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${n}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
|
|
3681
3681
|
}
|
|
3682
|
-
|
|
3682
|
+
Ye(e, n, u, t, s);
|
|
3683
3683
|
}, Ns = (n, e, t, r) => {
|
|
3684
3684
|
for (const [s, i] of Object.entries(n)) {
|
|
3685
3685
|
if (s === "or" || s === "and") {
|
|
@@ -3689,7 +3689,7 @@ const Fr = [
|
|
|
3689
3689
|
continue;
|
|
3690
3690
|
}
|
|
3691
3691
|
if (s === "id") {
|
|
3692
|
-
|
|
3692
|
+
Ye(i, "id", new re("string", !1, !0), e, `${r}.id`);
|
|
3693
3693
|
continue;
|
|
3694
3694
|
}
|
|
3695
3695
|
if (s.includes(".")) {
|
|
@@ -3705,12 +3705,12 @@ const Fr = [
|
|
|
3705
3705
|
throw new F(`Attribute or link '${s}' does not exist on entity '${e}'. Available attributes: ${u.length > 0 ? u.join(", ") : "none"}. Available links: ${l.length > 0 ? l.join(", ") : "none"}`, `${r}.${s}`);
|
|
3706
3706
|
}
|
|
3707
3707
|
if (a)
|
|
3708
|
-
|
|
3708
|
+
Ye(i, s, a, e, `${r}.${s}`);
|
|
3709
3709
|
else if (c) {
|
|
3710
|
-
if (typeof i == "string" && !
|
|
3710
|
+
if (typeof i == "string" && !Xe(i))
|
|
3711
3711
|
throw new F(`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`, `${r}.${s}`);
|
|
3712
3712
|
const u = new re("string", !1, !0);
|
|
3713
|
-
|
|
3713
|
+
Ye(i, s, u, e, `${r}.${s}`);
|
|
3714
3714
|
}
|
|
3715
3715
|
}
|
|
3716
3716
|
}, lc = (n, e, t, r, s = 0) => {
|
|
@@ -3773,7 +3773,7 @@ const Fr = [
|
|
|
3773
3773
|
Ws(t[r], r, e, r, 0);
|
|
3774
3774
|
}
|
|
3775
3775
|
}
|
|
3776
|
-
}, Wr = (n) => typeof n != "string" ? !1 : Wt(n) ? !0 :
|
|
3776
|
+
}, Wr = (n) => typeof n != "string" ? !1 : Wt(n) ? !0 : Xe(n);
|
|
3777
3777
|
class ye extends Error {
|
|
3778
3778
|
constructor(e) {
|
|
3779
3779
|
super(e), this.name = "TransactionValidationError";
|
|
@@ -3834,7 +3834,7 @@ const Ks = (n) => n.length > 0 ? n.join(", ") : "none", fc = (n, e) => new ye(`E
|
|
|
3834
3834
|
if (!e)
|
|
3835
3835
|
return;
|
|
3836
3836
|
const [t, r, s, i] = n;
|
|
3837
|
-
if (!Array.isArray(s) && !
|
|
3837
|
+
if (!Array.isArray(s) && !Xe(s))
|
|
3838
3838
|
throw new ye(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
|
|
3839
3839
|
if (typeof r != "string")
|
|
3840
3840
|
throw new ye(`Entity name must be a string, but received: ${typeof r}`);
|
|
@@ -4027,7 +4027,7 @@ function zr(n, e, t, r) {
|
|
|
4027
4027
|
const s = (o = B(t, n.table, "id")) == null ? void 0 : o.id;
|
|
4028
4028
|
if (!s)
|
|
4029
4029
|
return -1;
|
|
4030
|
-
const i =
|
|
4030
|
+
const i = tt(e.eav, [r, s, r]);
|
|
4031
4031
|
return i ? i[3] : -1;
|
|
4032
4032
|
}
|
|
4033
4033
|
function Vr(n, e, t) {
|
|
@@ -4492,8 +4492,8 @@ function Ec({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
|
|
|
4492
4492
|
});
|
|
4493
4493
|
switch (ie.type) {
|
|
4494
4494
|
case "ok": {
|
|
4495
|
-
const { streamId: he, offset:
|
|
4496
|
-
if (
|
|
4495
|
+
const { streamId: he, offset: nt } = ie;
|
|
4496
|
+
if (nt !== 0) {
|
|
4497
4497
|
const Re = new ne("Write stream is corrupted");
|
|
4498
4498
|
be(k, Re);
|
|
4499
4499
|
return;
|
|
@@ -4530,10 +4530,10 @@ function Ec({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
|
|
|
4530
4530
|
Re();
|
|
4531
4531
|
}, he = (Re) => {
|
|
4532
4532
|
P(Re), ie();
|
|
4533
|
-
},
|
|
4533
|
+
}, nt = () => {
|
|
4534
4534
|
Q(new ne("Stream is closed.")), ie();
|
|
4535
4535
|
};
|
|
4536
|
-
J.push(x(he)), J.push(O(
|
|
4536
|
+
J.push(x(he)), J.push(O(nt));
|
|
4537
4537
|
});
|
|
4538
4538
|
}
|
|
4539
4539
|
}
|
|
@@ -4904,7 +4904,7 @@ const Ee = {
|
|
|
4904
4904
|
}, Cc = 3e4, Ic = 3e4, Pc = 200, Mc = 1e3 * 60, Rc = {
|
|
4905
4905
|
apiURI: "https://api.instantdb.com",
|
|
4906
4906
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
4907
|
-
}, un = "_instant_oauth_redirect",
|
|
4907
|
+
}, un = "_instant_oauth_redirect", Ve = "currentUser";
|
|
4908
4908
|
function jc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
|
|
4909
4909
|
if (!s)
|
|
4910
4910
|
return new qr(`${r}?app_id=${e}`);
|
|
@@ -5185,13 +5185,15 @@ class Nc {
|
|
|
5185
5185
|
if (this._EventSource = i, this.config = { ...Rc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ic, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Pc, this._log = oc(e.verbose || Zn || Ds, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": Xn }, this.config.schema && (this._linkIndex = Lr(this.config.schema)), !!xc()) {
|
|
5186
5186
|
if (!e.appId)
|
|
5187
5187
|
throw new Error("Instant must be initialized with an appId.");
|
|
5188
|
-
if (!
|
|
5188
|
+
if (!Xe(e.appId))
|
|
5189
5189
|
throw new Error(`Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`);
|
|
5190
5190
|
typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", async (o) => {
|
|
5191
5191
|
var a;
|
|
5192
5192
|
try {
|
|
5193
5193
|
if (((a = o.data) == null ? void 0 : a.type) === "auth") {
|
|
5194
|
-
const c = await this.getCurrentUser(
|
|
5194
|
+
const c = await this.getCurrentUser({
|
|
5195
|
+
forceReadFromStorage: !0
|
|
5196
|
+
});
|
|
5195
5197
|
await this.updateUser(c.user).catch((u) => {
|
|
5196
5198
|
this._log.error("[error] update user", u);
|
|
5197
5199
|
});
|
|
@@ -5274,7 +5276,7 @@ class Nc {
|
|
|
5274
5276
|
gc: null
|
|
5275
5277
|
}), this.kv.onKeyLoaded = (t) => {
|
|
5276
5278
|
t === "pendingMutations" && this.notifyAll();
|
|
5277
|
-
}, this.kv.waitForKeyToLoad("pendingMutations"), this.kv.waitForKeyToLoad(
|
|
5279
|
+
}, this.kv.waitForKeyToLoad("pendingMutations"), this.kv.waitForKeyToLoad(Ve), this._beforeUnloadCbs.push(() => {
|
|
5278
5280
|
this.kv.flush(), this.querySubs.flush();
|
|
5279
5281
|
});
|
|
5280
5282
|
}
|
|
@@ -5985,7 +5987,7 @@ class Nc {
|
|
|
5985
5987
|
const { user: e, error: t } = await this.getCurrentUser();
|
|
5986
5988
|
if (t)
|
|
5987
5989
|
throw new ne("Could not get current user: " + t.message);
|
|
5988
|
-
return e;
|
|
5990
|
+
return e ?? null;
|
|
5989
5991
|
}
|
|
5990
5992
|
subscribeConnectionStatus(e) {
|
|
5991
5993
|
return this.connectionStatusCbs.push(e), () => {
|
|
@@ -6014,38 +6016,47 @@ class Nc {
|
|
|
6014
6016
|
}
|
|
6015
6017
|
async setCurrentUser(e) {
|
|
6016
6018
|
this.kv.updateInPlace((t) => {
|
|
6017
|
-
t[
|
|
6018
|
-
}), await this.kv.waitForKeyToLoad(
|
|
6019
|
+
t[Ve] = e;
|
|
6020
|
+
}), await this.kv.waitForKeyToLoad(Ve);
|
|
6019
6021
|
}
|
|
6020
6022
|
getCurrentUserCached() {
|
|
6021
6023
|
return this._currentUserCached;
|
|
6022
6024
|
}
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6025
|
+
/**
|
|
6026
|
+
* @param {{ forceReadFromStorage?: boolean }} [opts]
|
|
6027
|
+
* @returns {Promise<User | undefined>}
|
|
6028
|
+
*/
|
|
6029
|
+
async _getCurrentUser(e) {
|
|
6030
|
+
e != null && e.forceReadFromStorage && await this.kv.unloadKey(Ve);
|
|
6031
|
+
const t = await this.kv.waitForKeyToLoad(Ve);
|
|
6032
|
+
return typeof t == "string" ? JSON.parse(t) : t;
|
|
6026
6033
|
}
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6034
|
+
/**
|
|
6035
|
+
* @param {{ forceReadFromStorage?: boolean }} [opts]
|
|
6036
|
+
* @returns {Promise<AuthState>}
|
|
6037
|
+
*/
|
|
6038
|
+
async getCurrentUser(e) {
|
|
6039
|
+
const t = await this._waitForOAuthCallbackResponse();
|
|
6040
|
+
if (t != null && t.error) {
|
|
6041
|
+
const r = { error: t.error, user: void 0 };
|
|
6042
|
+
return this._currentUserCached = { isLoading: !1, ...r }, this._currentUserCached;
|
|
6032
6043
|
}
|
|
6033
6044
|
try {
|
|
6034
|
-
const
|
|
6045
|
+
const s = { user: await this._getCurrentUser(e), error: void 0 };
|
|
6035
6046
|
return this._currentUserCached = {
|
|
6036
6047
|
isLoading: !1,
|
|
6037
|
-
...
|
|
6038
|
-
},
|
|
6039
|
-
} catch (
|
|
6048
|
+
...s
|
|
6049
|
+
}, this._currentUserCached;
|
|
6050
|
+
} catch (r) {
|
|
6040
6051
|
return {
|
|
6041
6052
|
user: void 0,
|
|
6042
6053
|
isLoading: !1,
|
|
6043
|
-
error: { message: (
|
|
6054
|
+
error: { message: (r == null ? void 0 : r.message) || "Error loading user" }
|
|
6044
6055
|
};
|
|
6045
6056
|
}
|
|
6046
6057
|
}
|
|
6047
6058
|
async _hasCurrentUser() {
|
|
6048
|
-
const e = await this.kv.waitForKeyToLoad(
|
|
6059
|
+
const e = await this.kv.waitForKeyToLoad(Ve);
|
|
6049
6060
|
return typeof e == "string" ? JSON.parse(e) != null : e != null;
|
|
6050
6061
|
}
|
|
6051
6062
|
async changeCurrentUser(e) {
|
|
@@ -6054,7 +6065,7 @@ class Nc {
|
|
|
6054
6065
|
if (!Rt(t, e)) {
|
|
6055
6066
|
await this.setCurrentUser(e), await this.updateUser(e);
|
|
6056
6067
|
try {
|
|
6057
|
-
(r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
|
|
6068
|
+
await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
|
|
6058
6069
|
} catch (s) {
|
|
6059
6070
|
console.error("Error posting message to broadcast channel", s);
|
|
6060
6071
|
}
|
|
@@ -6099,13 +6110,13 @@ class Nc {
|
|
|
6099
6110
|
});
|
|
6100
6111
|
}
|
|
6101
6112
|
async signInWithMagicCode({ email: e, code: t }) {
|
|
6102
|
-
var o;
|
|
6113
|
+
var o, a;
|
|
6103
6114
|
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Qa({
|
|
6104
6115
|
apiURI: this.config.apiURI,
|
|
6105
6116
|
appId: this.config.appId,
|
|
6106
6117
|
email: e,
|
|
6107
6118
|
code: t,
|
|
6108
|
-
refreshToken: s ? r.user.refresh_token : void 0
|
|
6119
|
+
refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
|
|
6109
6120
|
});
|
|
6110
6121
|
return await this.changeCurrentUser(i.user), i;
|
|
6111
6122
|
}
|
|
@@ -6164,13 +6175,13 @@ class Nc {
|
|
|
6164
6175
|
* @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
|
|
6165
6176
|
*/
|
|
6166
6177
|
async exchangeCodeForToken({ code: e, codeVerifier: t }) {
|
|
6167
|
-
var o;
|
|
6178
|
+
var o, a;
|
|
6168
6179
|
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await xr({
|
|
6169
6180
|
apiURI: this.config.apiURI,
|
|
6170
6181
|
appId: this.config.appId,
|
|
6171
6182
|
code: e,
|
|
6172
6183
|
codeVerifier: t,
|
|
6173
|
-
refreshToken: s ? r.user.refresh_token : void 0
|
|
6184
|
+
refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
|
|
6174
6185
|
});
|
|
6175
6186
|
return await this.changeCurrentUser(i.user), i;
|
|
6176
6187
|
}
|
|
@@ -7196,7 +7207,7 @@ function bu() {
|
|
|
7196
7207
|
function he() {
|
|
7197
7208
|
}
|
|
7198
7209
|
he.__reactDisabledLog = !0;
|
|
7199
|
-
function
|
|
7210
|
+
function nt() {
|
|
7200
7211
|
{
|
|
7201
7212
|
if (ve === 0) {
|
|
7202
7213
|
Me = console.log, Qt = console.info, k = console.warn, P = console.error, Q = console.group, J = console.groupCollapsed, ie = console.groupEnd;
|
|
@@ -7286,7 +7297,7 @@ function bu() {
|
|
|
7286
7297
|
var $ = Error.prepareStackTrace;
|
|
7287
7298
|
Error.prepareStackTrace = void 0;
|
|
7288
7299
|
var D;
|
|
7289
|
-
D = Ht.current, Ht.current = null,
|
|
7300
|
+
D = Ht.current, Ht.current = null, nt();
|
|
7290
7301
|
try {
|
|
7291
7302
|
if (T) {
|
|
7292
7303
|
var j = function() {
|
|
@@ -7380,7 +7391,7 @@ function bu() {
|
|
|
7380
7391
|
}
|
|
7381
7392
|
return "";
|
|
7382
7393
|
}
|
|
7383
|
-
var
|
|
7394
|
+
var rt = Object.prototype.hasOwnProperty, nr = {}, rr = _.ReactDebugCurrentFrame;
|
|
7384
7395
|
function Et(d) {
|
|
7385
7396
|
if (d) {
|
|
7386
7397
|
var T = d._owner, E = vt(d.type, d._source, T ? T.type : null);
|
|
@@ -7390,7 +7401,7 @@ function bu() {
|
|
|
7390
7401
|
}
|
|
7391
7402
|
function Ys(d, T, E, C, $) {
|
|
7392
7403
|
{
|
|
7393
|
-
var D = Function.call.bind(
|
|
7404
|
+
var D = Function.call.bind(rt);
|
|
7394
7405
|
for (var j in d)
|
|
7395
7406
|
if (D(d, j)) {
|
|
7396
7407
|
var M = void 0;
|
|
@@ -7438,7 +7449,7 @@ function bu() {
|
|
|
7438
7449
|
__source: !0
|
|
7439
7450
|
}, ar, cr;
|
|
7440
7451
|
function ni(d) {
|
|
7441
|
-
if (
|
|
7452
|
+
if (rt.call(d, "ref")) {
|
|
7442
7453
|
var T = Object.getOwnPropertyDescriptor(d, "ref").get;
|
|
7443
7454
|
if (T && T.isReactWarning)
|
|
7444
7455
|
return !1;
|
|
@@ -7446,7 +7457,7 @@ function bu() {
|
|
|
7446
7457
|
return d.ref !== void 0;
|
|
7447
7458
|
}
|
|
7448
7459
|
function ri(d) {
|
|
7449
|
-
if (
|
|
7460
|
+
if (rt.call(d, "key")) {
|
|
7450
7461
|
var T = Object.getOwnPropertyDescriptor(d, "key").get;
|
|
7451
7462
|
if (T && T.isReactWarning)
|
|
7452
7463
|
return !1;
|
|
@@ -7512,7 +7523,7 @@ function bu() {
|
|
|
7512
7523
|
var D, j = {}, M = null, ee = null;
|
|
7513
7524
|
E !== void 0 && (ir(E), M = "" + E), ri(T) && (ir(T.key), M = "" + T.key), ni(T) && (ee = T.ref, si(T, $));
|
|
7514
7525
|
for (D in T)
|
|
7515
|
-
|
|
7526
|
+
rt.call(T, D) && !ti.hasOwnProperty(D) && (j[D] = T[D]);
|
|
7516
7527
|
if (d && d.defaultProps) {
|
|
7517
7528
|
var q = d.defaultProps;
|
|
7518
7529
|
for (D in q)
|
|
@@ -7663,7 +7674,7 @@ Check the top-level render call using <` + E + ">.");
|
|
|
7663
7674
|
else
|
|
7664
7675
|
hr(pe, d);
|
|
7665
7676
|
}
|
|
7666
|
-
if (
|
|
7677
|
+
if (rt.call(T, "key")) {
|
|
7667
7678
|
var je = L(d), oe = Object.keys(T).filter(function(_i) {
|
|
7668
7679
|
return _i !== "key";
|
|
7669
7680
|
}), nn = oe.length > 0 ? "{key: someKey, " + oe.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
@@ -8337,19 +8348,19 @@ function es(n) {
|
|
|
8337
8348
|
}
|
|
8338
8349
|
var Bs = (n) => {
|
|
8339
8350
|
throw TypeError(n);
|
|
8340
|
-
}, er = (n, e, t) => e.has(n) || Bs("Cannot " + t), I = (n, e, t) => (er(n, e, "read from private field"), t ? t.call(n) : e.get(n)), G = (n, e, t) => e.has(n) ? Bs("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), N = (n, e, t, r) => (er(n, e, "write to private field"), e.set(n, t), t), Ae = (n, e, t) => (er(n, e, "access private method"), t), ae, De,
|
|
8351
|
+
}, er = (n, e, t) => e.has(n) || Bs("Cannot " + t), I = (n, e, t) => (er(n, e, "read from private field"), t ? t.call(n) : e.get(n)), G = (n, e, t) => e.has(n) ? Bs("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), N = (n, e, t, r) => (er(n, e, "write to private field"), e.set(n, t), t), Ae = (n, e, t) => (er(n, e, "access private method"), t), ae, De, Ge, $t, Kt, yt, Je, bt, Ie, Qe, Ze, He, lt, _e, jn, xn, $n, ts, Dn, Un, ft, Ln, Fn;
|
|
8341
8352
|
class Dt extends EventTarget {
|
|
8342
8353
|
constructor(e, t) {
|
|
8343
8354
|
var r, s;
|
|
8344
|
-
super(), G(this, _e), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, G(this, ae), G(this, De), G(this,
|
|
8355
|
+
super(), G(this, _e), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, G(this, ae), G(this, De), G(this, Ge), G(this, $t), G(this, Kt), G(this, yt), G(this, Je), G(this, bt, null), G(this, Ie), G(this, Qe), G(this, Ze, null), G(this, He, null), G(this, lt, null), G(this, xn, async (i) => {
|
|
8345
8356
|
var o;
|
|
8346
|
-
I(this,
|
|
8357
|
+
I(this, Qe).reset();
|
|
8347
8358
|
const { body: a, redirected: c, status: u, headers: l } = i;
|
|
8348
8359
|
if (u === 204) {
|
|
8349
8360
|
Ae(this, _e, ft).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
8350
8361
|
return;
|
|
8351
8362
|
}
|
|
8352
|
-
if (c ? N(this,
|
|
8363
|
+
if (c ? N(this, Ge, new URL(i.url)) : N(this, Ge, void 0), u !== 200) {
|
|
8353
8364
|
Ae(this, _e, ft).call(this, `Non-200 status code (${u})`, u);
|
|
8354
8365
|
return;
|
|
8355
8366
|
}
|
|
@@ -8369,7 +8380,7 @@ class Dt extends EventTarget {
|
|
|
8369
8380
|
let b = !0;
|
|
8370
8381
|
do {
|
|
8371
8382
|
const { done: g, value: m } = await y.read();
|
|
8372
|
-
m && I(this,
|
|
8383
|
+
m && I(this, Qe).feed(p.decode(m, { stream: !g })), g && (b = !1, I(this, Qe).reset(), Ae(this, _e, Ln).call(this));
|
|
8373
8384
|
} while (b);
|
|
8374
8385
|
}), G(this, $n, (i) => {
|
|
8375
8386
|
N(this, Ie, void 0), !(i.name === "AbortError" || i.type === "aborted") && Ae(this, _e, Ln).call(this, Rn(i));
|
|
@@ -8377,14 +8388,14 @@ class Dt extends EventTarget {
|
|
|
8377
8388
|
typeof i.id == "string" && N(this, bt, i.id);
|
|
8378
8389
|
const o = new MessageEvent(i.event || "message", {
|
|
8379
8390
|
data: i.data,
|
|
8380
|
-
origin: I(this,
|
|
8391
|
+
origin: I(this, Ge) ? I(this, Ge).origin : I(this, De).origin,
|
|
8381
8392
|
lastEventId: i.id || ""
|
|
8382
8393
|
});
|
|
8383
|
-
I(this,
|
|
8394
|
+
I(this, He) && (!i.event || i.event === "message") && I(this, He).call(this, o), this.dispatchEvent(o);
|
|
8384
8395
|
}), G(this, Un, (i) => {
|
|
8385
8396
|
N(this, yt, i);
|
|
8386
8397
|
}), G(this, Fn, () => {
|
|
8387
|
-
N(this,
|
|
8398
|
+
N(this, Je, void 0), I(this, ae) === this.CONNECTING && Ae(this, _e, jn).call(this);
|
|
8388
8399
|
});
|
|
8389
8400
|
try {
|
|
8390
8401
|
if (e instanceof URL)
|
|
@@ -8396,7 +8407,7 @@ class Dt extends EventTarget {
|
|
|
8396
8407
|
} catch {
|
|
8397
8408
|
throw Mu("An invalid or illegal string was specified");
|
|
8398
8409
|
}
|
|
8399
|
-
N(this,
|
|
8410
|
+
N(this, Qe, Iu({
|
|
8400
8411
|
onEvent: I(this, Dn),
|
|
8401
8412
|
onRetry: I(this, Un)
|
|
8402
8413
|
})), N(this, ae, this.CONNECTING), N(this, yt, 3e3), N(this, Kt, (r = t == null ? void 0 : t.fetch) != null ? r : globalThis.fetch), N(this, $t, (s = t == null ? void 0 : t.withCredentials) != null ? s : !1), Ae(this, _e, jn).call(this);
|
|
@@ -8434,17 +8445,17 @@ class Dt extends EventTarget {
|
|
|
8434
8445
|
}
|
|
8435
8446
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
8436
8447
|
get onerror() {
|
|
8437
|
-
return I(this,
|
|
8448
|
+
return I(this, Ze);
|
|
8438
8449
|
}
|
|
8439
8450
|
set onerror(e) {
|
|
8440
|
-
N(this,
|
|
8451
|
+
N(this, Ze, e);
|
|
8441
8452
|
}
|
|
8442
8453
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
8443
8454
|
get onmessage() {
|
|
8444
|
-
return I(this,
|
|
8455
|
+
return I(this, He);
|
|
8445
8456
|
}
|
|
8446
8457
|
set onmessage(e) {
|
|
8447
|
-
N(this,
|
|
8458
|
+
N(this, He, e);
|
|
8448
8459
|
}
|
|
8449
8460
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
8450
8461
|
get onopen() {
|
|
@@ -8469,10 +8480,10 @@ class Dt extends EventTarget {
|
|
|
8469
8480
|
* @public
|
|
8470
8481
|
*/
|
|
8471
8482
|
close() {
|
|
8472
|
-
I(this,
|
|
8483
|
+
I(this, Je) && clearTimeout(I(this, Je)), I(this, ae) !== this.CLOSED && (I(this, Ie) && I(this, Ie).abort(), N(this, ae, this.CLOSED), N(this, Ie, void 0));
|
|
8473
8484
|
}
|
|
8474
8485
|
}
|
|
8475
|
-
ae = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(),
|
|
8486
|
+
ae = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Ge = /* @__PURE__ */ new WeakMap(), $t = /* @__PURE__ */ new WeakMap(), Kt = /* @__PURE__ */ new WeakMap(), yt = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap(), bt = /* @__PURE__ */ new WeakMap(), Ie = /* @__PURE__ */ new WeakMap(), Qe = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), _e = /* @__PURE__ */ new WeakSet(), /**
|
|
8476
8487
|
* Connect to the given URL and start receiving events
|
|
8477
8488
|
*
|
|
8478
8489
|
* @internal
|
|
@@ -8508,7 +8519,7 @@ ft = function(n, e) {
|
|
|
8508
8519
|
var t;
|
|
8509
8520
|
I(this, ae) !== this.CLOSED && N(this, ae, this.CLOSED);
|
|
8510
8521
|
const r = new Xr("error", { code: e, message: n });
|
|
8511
|
-
(t = I(this,
|
|
8522
|
+
(t = I(this, Ze)) == null || t.call(this, r), this.dispatchEvent(r);
|
|
8512
8523
|
}, /**
|
|
8513
8524
|
* Schedules a reconnection attempt against the EventSource endpoint.
|
|
8514
8525
|
*
|
|
@@ -8522,7 +8533,7 @@ Ln = function(n, e) {
|
|
|
8522
8533
|
return;
|
|
8523
8534
|
N(this, ae, this.CONNECTING);
|
|
8524
8535
|
const r = new Xr("error", { code: e, message: n });
|
|
8525
|
-
(t = I(this,
|
|
8536
|
+
(t = I(this, Ze)) == null || t.call(this, r), this.dispatchEvent(r), N(this, Je, setTimeout(I(this, Fn), I(this, yt)));
|
|
8526
8537
|
}, Fn = /* @__PURE__ */ new WeakMap(), /**
|
|
8527
8538
|
* ReadyState representing an EventSource currently trying to connect
|
|
8528
8539
|
*
|