@instantdb/solidjs 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/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @instantdb/solidjs@0.22.
|
|
2
|
+
> @instantdb/solidjs@0.22.145 build /home/runner/work/instant/instant/client/packages/solidjs
|
|
3
3
|
> rm -rf dist; npm run build:tshy && npm run build:standalone && npm run check-exports
|
|
4
4
|
|
|
5
5
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
|
|
6
6
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
|
|
7
7
|
|
|
8
|
-
> @instantdb/solidjs@0.22.
|
|
8
|
+
> @instantdb/solidjs@0.22.145 build:tshy
|
|
9
9
|
> tshy
|
|
10
10
|
|
|
11
11
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
|
|
12
12
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
|
|
13
13
|
|
|
14
|
-
> @instantdb/solidjs@0.22.
|
|
14
|
+
> @instantdb/solidjs@0.22.145 build:standalone
|
|
15
15
|
> vite build
|
|
16
16
|
|
|
17
17
|
[36mvite v5.4.14 [32mbuilding for production...[36m[39m
|
|
@@ -19,17 +19,17 @@ transforming...
|
|
|
19
19
|
[32m✓[39m 69 modules transformed.
|
|
20
20
|
rendering chunks...
|
|
21
21
|
computing gzip size...
|
|
22
|
-
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m151.
|
|
23
|
-
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m229.
|
|
24
|
-
[32m✓ built in 1.
|
|
22
|
+
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m151.61 kB[22m[1m[22m[2m │ gzip: 46.08 kB[22m
|
|
23
|
+
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m229.84 kB[22m[1m[22m[2m │ gzip: 59.39 kB[22m
|
|
24
|
+
[32m✓ built in 1.77s[39m
|
|
25
25
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
|
|
26
26
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
|
|
27
27
|
|
|
28
|
-
> @instantdb/solidjs@0.22.
|
|
28
|
+
> @instantdb/solidjs@0.22.145 check-exports
|
|
29
29
|
> attw --pack .
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@instantdb/solidjs v0.22.
|
|
32
|
+
@instantdb/solidjs v0.22.145
|
|
33
33
|
|
|
34
34
|
Build tools:
|
|
35
35
|
- @arethetypeswrong/cli@^0.17.4
|
package/dist/standalone/index.js
CHANGED
|
@@ -237,7 +237,7 @@ function re(t) {
|
|
|
237
237
|
function nn() {
|
|
238
238
|
throw new Error("Cannot modify frozen object");
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Se(t, e, n, r, s) {
|
|
241
241
|
{
|
|
242
242
|
n = n ?? /* @__PURE__ */ new WeakMap(), r = r ?? [], s = s ?? [];
|
|
243
243
|
const o = n.has(t) ? n.get(t) : t;
|
|
@@ -261,24 +261,24 @@ function Te(t, e, n, r, s) {
|
|
|
261
261
|
switch (we(t)) {
|
|
262
262
|
case 2:
|
|
263
263
|
for (const [a, c] of t)
|
|
264
|
-
|
|
264
|
+
Se(a, a, n, r, s), Se(c, a, n, r, s);
|
|
265
265
|
t.set = t.clear = t.delete = nn;
|
|
266
266
|
break;
|
|
267
267
|
case 3:
|
|
268
268
|
for (const a of t)
|
|
269
|
-
|
|
269
|
+
Se(a, a, n, r, s);
|
|
270
270
|
t.add = t.clear = t.delete = nn;
|
|
271
271
|
break;
|
|
272
272
|
case 1:
|
|
273
273
|
Object.freeze(t);
|
|
274
274
|
let o = 0;
|
|
275
275
|
for (const a of t)
|
|
276
|
-
|
|
276
|
+
Se(a, o, n, r, s), o += 1;
|
|
277
277
|
break;
|
|
278
278
|
default:
|
|
279
279
|
Object.freeze(t), Object.keys(t).forEach((a) => {
|
|
280
280
|
const c = t[a];
|
|
281
|
-
|
|
281
|
+
Se(c, a, n, r, s);
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
r.pop(), s.pop();
|
|
@@ -784,7 +784,7 @@ function qr(t, e, n, r, s) {
|
|
|
784
784
|
for (; o.finalities.draft.length > 0; )
|
|
785
785
|
o.finalities.draft.pop()(n, r);
|
|
786
786
|
const u = c ? e[0] : o ? o.operated ? o.copy : o.original : t;
|
|
787
|
-
return o && vt(o), s &&
|
|
787
|
+
return o && vt(o), s && Se(u, u, o == null ? void 0 : o.options.updatedValues), [
|
|
788
788
|
u,
|
|
789
789
|
n && c ? [{ op: M.Replace, path: [], value: e[0] }] : n,
|
|
790
790
|
r && c ? [{ op: M.Replace, path: [], value: a }] : r
|
|
@@ -1417,7 +1417,7 @@ function Gt(t) {
|
|
|
1417
1417
|
function Ht(t) {
|
|
1418
1418
|
return t["value-type"] === "blob";
|
|
1419
1419
|
}
|
|
1420
|
-
function
|
|
1420
|
+
function ke(t, e) {
|
|
1421
1421
|
return e.reduce((n, r) => n && n.get(r), t);
|
|
1422
1422
|
}
|
|
1423
1423
|
function X(t, e) {
|
|
@@ -1471,7 +1471,7 @@ function Hn(t, e) {
|
|
|
1471
1471
|
return new be(e.attrs, e.linkIndex);
|
|
1472
1472
|
}
|
|
1473
1473
|
function fs(t, e) {
|
|
1474
|
-
return
|
|
1474
|
+
return ke(t.eav, [e]) !== void 0;
|
|
1475
1475
|
}
|
|
1476
1476
|
function Pe(t, e, n, r) {
|
|
1477
1477
|
const s = Qn(t, e, r);
|
|
@@ -1515,7 +1515,7 @@ let ds = 0;
|
|
|
1515
1515
|
function Yn(t, e, n) {
|
|
1516
1516
|
const [r, s, i] = n;
|
|
1517
1517
|
let o;
|
|
1518
|
-
const a =
|
|
1518
|
+
const a = ke(t.eav, [r, s, i]);
|
|
1519
1519
|
return a && (o = a[3]), o || Date.now() * 10 + ds++;
|
|
1520
1520
|
}
|
|
1521
1521
|
function Zn(t, e, n) {
|
|
@@ -1527,7 +1527,7 @@ function Zn(t, e, n) {
|
|
|
1527
1527
|
if (!a)
|
|
1528
1528
|
return;
|
|
1529
1529
|
a["checked-data-type"] === "date" && t.useDateObjects && (o = ot(o));
|
|
1530
|
-
const c =
|
|
1530
|
+
const c = ke(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Yn(t, a, r), l = [s, i, o, u];
|
|
1531
1531
|
ls(a) ? (V(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), V(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (V(t.eav, [s, i, o], l), V(t.aev, [i, s, o], l)), Gt(a) && V(t.vae, [o, i, s], l);
|
|
1532
1532
|
}
|
|
1533
1533
|
function hs(t, e, n) {
|
|
@@ -1540,7 +1540,7 @@ function hs(t, e, n) {
|
|
|
1540
1540
|
return;
|
|
1541
1541
|
if (!Ht(a))
|
|
1542
1542
|
throw new Error("merge operation is not supported for links");
|
|
1543
|
-
const c =
|
|
1543
|
+
const c = ke(t.eav, [s, i]);
|
|
1544
1544
|
if (!c)
|
|
1545
1545
|
return;
|
|
1546
1546
|
const u = (p = c.values().next()) == null ? void 0 : p.value;
|
|
@@ -1765,7 +1765,7 @@ function Ss(t, e, n) {
|
|
|
1765
1765
|
return;
|
|
1766
1766
|
const [s, i, o] = r;
|
|
1767
1767
|
if (e.getAttr(i))
|
|
1768
|
-
return
|
|
1768
|
+
return ke(t.eav, [s, i]);
|
|
1769
1769
|
}
|
|
1770
1770
|
function vs(t, e, n) {
|
|
1771
1771
|
const r = n.filter(([s, i, o, a, c]) => {
|
|
@@ -1860,7 +1860,7 @@ function Ds(t, e, n) {
|
|
|
1860
1860
|
return _s(t, Jt(n, e));
|
|
1861
1861
|
}
|
|
1862
1862
|
const $s = /^(?:[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;
|
|
1863
|
-
function
|
|
1863
|
+
function Ae(t) {
|
|
1864
1864
|
return typeof t == "string" && $s.test(t);
|
|
1865
1865
|
}
|
|
1866
1866
|
const $ = [];
|
|
@@ -1931,7 +1931,7 @@ function $e(t) {
|
|
|
1931
1931
|
function at(t, e) {
|
|
1932
1932
|
return `?${t}-${e}`;
|
|
1933
1933
|
}
|
|
1934
|
-
class
|
|
1934
|
+
class Oe extends Error {
|
|
1935
1935
|
constructor(e) {
|
|
1936
1936
|
super(e), this.name = "AttrNotFoundError";
|
|
1937
1937
|
}
|
|
@@ -1939,7 +1939,7 @@ class Ae extends Error {
|
|
|
1939
1939
|
function Bs(t, e) {
|
|
1940
1940
|
const n = tr(t, e);
|
|
1941
1941
|
if (!n)
|
|
1942
|
-
throw new
|
|
1942
|
+
throw new Oe(`Could not find id attr for ${e}`);
|
|
1943
1943
|
return n;
|
|
1944
1944
|
}
|
|
1945
1945
|
function dn(t, e, n, r) {
|
|
@@ -1959,7 +1959,7 @@ function Hs(t, e, n) {
|
|
|
1959
1959
|
function rr(t, e, n, r, s) {
|
|
1960
1960
|
const i = D(e, n, s), o = _e(e, n, s), a = i || o;
|
|
1961
1961
|
if (!a)
|
|
1962
|
-
throw new
|
|
1962
|
+
throw new Oe(`Could not find attr for ${[n, s]}`);
|
|
1963
1963
|
if (a["value-type"] !== "ref")
|
|
1964
1964
|
throw new Error(`Attr ${a.id} is not a ref`);
|
|
1965
1965
|
const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], h = r + 1, p = i ? [
|
|
@@ -2048,11 +2048,11 @@ function Js(t, e) {
|
|
|
2048
2048
|
function Ys(t, e, n, r, s, i) {
|
|
2049
2049
|
const o = D(e, n, s), a = _e(e, n, s), c = o || a;
|
|
2050
2050
|
if (!c)
|
|
2051
|
-
throw new
|
|
2051
|
+
throw new Oe(`No attr for etype = ${n} label = ${s}`);
|
|
2052
2052
|
if (i != null && i.hasOwnProperty("$isNull")) {
|
|
2053
2053
|
const u = D(e, n, "id");
|
|
2054
2054
|
if (!u)
|
|
2055
|
-
throw new
|
|
2055
|
+
throw new Oe(`No attr for etype = ${n} label = id`);
|
|
2056
2056
|
return [
|
|
2057
2057
|
t(n, r),
|
|
2058
2058
|
u.id,
|
|
@@ -2167,7 +2167,7 @@ function ai(t, e, n, { etype: r, level: s, form: i }, o) {
|
|
|
2167
2167
|
}), S = y ? T[0] : T;
|
|
2168
2168
|
return { [p]: S };
|
|
2169
2169
|
} catch (g) {
|
|
2170
|
-
if (g instanceof
|
|
2170
|
+
if (g instanceof Oe)
|
|
2171
2171
|
return { [p]: y ? void 0 : [] };
|
|
2172
2172
|
throw g;
|
|
2173
2173
|
}
|
|
@@ -2285,7 +2285,7 @@ function gi(t, e, n) {
|
|
|
2285
2285
|
try {
|
|
2286
2286
|
return bi(t, e, n);
|
|
2287
2287
|
} catch (r) {
|
|
2288
|
-
if (r instanceof
|
|
2288
|
+
if (r instanceof Oe)
|
|
2289
2289
|
return {};
|
|
2290
2290
|
throw r;
|
|
2291
2291
|
}
|
|
@@ -3480,7 +3480,7 @@ function An(t) {
|
|
|
3480
3480
|
}, e;
|
|
3481
3481
|
}, {});
|
|
3482
3482
|
}
|
|
3483
|
-
const Xt = "v0.22.
|
|
3483
|
+
const Xt = "v0.22.145";
|
|
3484
3484
|
function go(t, e) {
|
|
3485
3485
|
return {
|
|
3486
3486
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
@@ -3628,7 +3628,7 @@ const On = [
|
|
|
3628
3628
|
default:
|
|
3629
3629
|
throw new E(`Unknown operator '${t}' for attribute '${r}' in entity '${s}'`, o);
|
|
3630
3630
|
}
|
|
3631
|
-
},
|
|
3631
|
+
}, ve = (t, e, n, r, s) => {
|
|
3632
3632
|
const i = wo(n), o = n.valueType === "json";
|
|
3633
3633
|
if (typeof t == "object" && t !== null && !Array.isArray(t)) {
|
|
3634
3634
|
if (o)
|
|
@@ -3658,23 +3658,23 @@ const On = [
|
|
|
3658
3658
|
if (!c)
|
|
3659
3659
|
throw new E(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, s);
|
|
3660
3660
|
if (a === "id") {
|
|
3661
|
-
if (typeof e == "string" && !
|
|
3661
|
+
if (typeof e == "string" && !Ae(e))
|
|
3662
3662
|
throw new E(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3663
|
-
|
|
3663
|
+
ve(e, t, new z("string", !1, !0), n, s);
|
|
3664
3664
|
return;
|
|
3665
3665
|
}
|
|
3666
3666
|
const u = c.attrs[a];
|
|
3667
3667
|
if (Object.keys(c.links).includes(a)) {
|
|
3668
|
-
if (typeof e == "string" && !
|
|
3668
|
+
if (typeof e == "string" && !Ae(e))
|
|
3669
3669
|
throw new E(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3670
|
-
|
|
3670
|
+
ve(e, t, new z("string", !1, !0), n, s);
|
|
3671
3671
|
return;
|
|
3672
3672
|
}
|
|
3673
3673
|
if (!u) {
|
|
3674
3674
|
const l = Object.keys(c.attrs);
|
|
3675
3675
|
throw new E(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
|
|
3676
3676
|
}
|
|
3677
|
-
|
|
3677
|
+
ve(e, t, u, n, s);
|
|
3678
3678
|
}, br = (t, e, n, r) => {
|
|
3679
3679
|
for (const [s, i] of Object.entries(t)) {
|
|
3680
3680
|
if (s === "or" || s === "and") {
|
|
@@ -3684,7 +3684,7 @@ const On = [
|
|
|
3684
3684
|
continue;
|
|
3685
3685
|
}
|
|
3686
3686
|
if (s === "id") {
|
|
3687
|
-
|
|
3687
|
+
ve(i, "id", new z("string", !1, !0), e, `${r}.id`);
|
|
3688
3688
|
continue;
|
|
3689
3689
|
}
|
|
3690
3690
|
if (s.includes(".")) {
|
|
@@ -3700,12 +3700,12 @@ const On = [
|
|
|
3700
3700
|
throw new E(`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}`);
|
|
3701
3701
|
}
|
|
3702
3702
|
if (a)
|
|
3703
|
-
|
|
3703
|
+
ve(i, s, a, e, `${r}.${s}`);
|
|
3704
3704
|
else if (c) {
|
|
3705
|
-
if (typeof i == "string" && !
|
|
3705
|
+
if (typeof i == "string" && !Ae(i))
|
|
3706
3706
|
throw new E(`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`, `${r}.${s}`);
|
|
3707
3707
|
const u = new z("string", !1, !0);
|
|
3708
|
-
|
|
3708
|
+
ve(i, s, u, e, `${r}.${s}`);
|
|
3709
3709
|
}
|
|
3710
3710
|
}
|
|
3711
3711
|
}, To = (t, e, n, r, s = 0) => {
|
|
@@ -3768,7 +3768,7 @@ const On = [
|
|
|
3768
3768
|
gr(n[r], r, e, r, 0);
|
|
3769
3769
|
}
|
|
3770
3770
|
}
|
|
3771
|
-
}, In = (t) => typeof t != "string" ? !1 : et(t) ? !0 :
|
|
3771
|
+
}, In = (t) => typeof t != "string" ? !1 : et(t) ? !0 : Ae(t);
|
|
3772
3772
|
class J extends Error {
|
|
3773
3773
|
constructor(e) {
|
|
3774
3774
|
super(e), this.name = "TransactionValidationError";
|
|
@@ -3829,7 +3829,7 @@ const wr = (t) => t.length > 0 ? t.join(", ") : "none", So = (t, e) => new J(`En
|
|
|
3829
3829
|
if (!e)
|
|
3830
3830
|
return;
|
|
3831
3831
|
const [n, r, s, i] = t;
|
|
3832
|
-
if (!Array.isArray(s) && !
|
|
3832
|
+
if (!Array.isArray(s) && !Ae(s))
|
|
3833
3833
|
throw new J(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
|
|
3834
3834
|
if (typeof r != "string")
|
|
3835
3835
|
throw new J(`Entity name must be a string, but received: ${typeof r}`);
|
|
@@ -4022,7 +4022,7 @@ function Pn(t, e, n, r) {
|
|
|
4022
4022
|
const s = (o = D(n, t.table, "id")) == null ? void 0 : o.id;
|
|
4023
4023
|
if (!s)
|
|
4024
4024
|
return -1;
|
|
4025
|
-
const i =
|
|
4025
|
+
const i = ke(e.eav, [r, s, r]);
|
|
4026
4026
|
return i ? i[3] : -1;
|
|
4027
4027
|
}
|
|
4028
4028
|
function Mn(t, e, n) {
|
|
@@ -4489,8 +4489,8 @@ function Ro({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4489
4489
|
case "ok": {
|
|
4490
4490
|
const { streamId: oe, offset: pt } = Z;
|
|
4491
4491
|
if (pt !== 0) {
|
|
4492
|
-
const
|
|
4493
|
-
se(v,
|
|
4492
|
+
const Ie = new q("Write stream is corrupted");
|
|
4493
|
+
se(v, Ie);
|
|
4494
4494
|
return;
|
|
4495
4495
|
}
|
|
4496
4496
|
C(oe), s(oe, {
|
|
@@ -4521,10 +4521,10 @@ function Ro({ WStream: t, opts: e, startStream: n, appendStream: r, registerStre
|
|
|
4521
4521
|
async streamId() {
|
|
4522
4522
|
return o || new Promise((k, N) => {
|
|
4523
4523
|
const W = [], Z = () => {
|
|
4524
|
-
for (const
|
|
4525
|
-
|
|
4526
|
-
}, oe = (
|
|
4527
|
-
k(
|
|
4524
|
+
for (const Ie of W)
|
|
4525
|
+
Ie();
|
|
4526
|
+
}, oe = (Ie) => {
|
|
4527
|
+
k(Ie), Z();
|
|
4528
4528
|
}, pt = () => {
|
|
4529
4529
|
N(new q("Stream is closed.")), Z();
|
|
4530
4530
|
};
|
|
@@ -4899,7 +4899,7 @@ const ne = {
|
|
|
4899
4899
|
}, Fo = 3e4, No = 3e4, Ko = 200, qo = 1e3 * 60, zo = {
|
|
4900
4900
|
apiURI: "https://api.instantdb.com",
|
|
4901
4901
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
4902
|
-
}, mt = "_instant_oauth_redirect",
|
|
4902
|
+
}, mt = "_instant_oauth_redirect", Te = "currentUser";
|
|
4903
4903
|
function Wo({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
|
|
4904
4904
|
if (!s)
|
|
4905
4905
|
return new Cn(`${r}?app_id=${e}`);
|
|
@@ -5180,13 +5180,15 @@ class Yo {
|
|
|
5180
5180
|
if (this._EventSource = i, this.config = { ...zo, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? No, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Ko, this._log = go(e.verbose || Zt || dr, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": Xt }, this.config.schema && (this._linkIndex = An(this.config.schema)), !!Vo()) {
|
|
5181
5181
|
if (!e.appId)
|
|
5182
5182
|
throw new Error("Instant must be initialized with an appId.");
|
|
5183
|
-
if (!
|
|
5183
|
+
if (!Ae(e.appId))
|
|
5184
5184
|
throw new Error(`Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`);
|
|
5185
5185
|
typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", async (o) => {
|
|
5186
5186
|
var a;
|
|
5187
5187
|
try {
|
|
5188
5188
|
if (((a = o.data) == null ? void 0 : a.type) === "auth") {
|
|
5189
|
-
const c = await this.getCurrentUser(
|
|
5189
|
+
const c = await this.getCurrentUser({
|
|
5190
|
+
forceReadFromStorage: !0
|
|
5191
|
+
});
|
|
5190
5192
|
await this.updateUser(c.user).catch((u) => {
|
|
5191
5193
|
this._log.error("[error] update user", u);
|
|
5192
5194
|
});
|
|
@@ -5269,7 +5271,7 @@ class Yo {
|
|
|
5269
5271
|
gc: null
|
|
5270
5272
|
}), this.kv.onKeyLoaded = (n) => {
|
|
5271
5273
|
n === "pendingMutations" && this.notifyAll();
|
|
5272
|
-
}, this.kv.waitForKeyToLoad("pendingMutations"), this.kv.waitForKeyToLoad(
|
|
5274
|
+
}, this.kv.waitForKeyToLoad("pendingMutations"), this.kv.waitForKeyToLoad(Te), this._beforeUnloadCbs.push(() => {
|
|
5273
5275
|
this.kv.flush(), this.querySubs.flush();
|
|
5274
5276
|
});
|
|
5275
5277
|
}
|
|
@@ -5980,7 +5982,7 @@ class Yo {
|
|
|
5980
5982
|
const { user: e, error: n } = await this.getCurrentUser();
|
|
5981
5983
|
if (n)
|
|
5982
5984
|
throw new q("Could not get current user: " + n.message);
|
|
5983
|
-
return e;
|
|
5985
|
+
return e ?? null;
|
|
5984
5986
|
}
|
|
5985
5987
|
subscribeConnectionStatus(e) {
|
|
5986
5988
|
return this.connectionStatusCbs.push(e), () => {
|
|
@@ -6009,38 +6011,47 @@ class Yo {
|
|
|
6009
6011
|
}
|
|
6010
6012
|
async setCurrentUser(e) {
|
|
6011
6013
|
this.kv.updateInPlace((n) => {
|
|
6012
|
-
n[
|
|
6013
|
-
}), await this.kv.waitForKeyToLoad(
|
|
6014
|
+
n[Te] = e;
|
|
6015
|
+
}), await this.kv.waitForKeyToLoad(Te);
|
|
6014
6016
|
}
|
|
6015
6017
|
getCurrentUserCached() {
|
|
6016
6018
|
return this._currentUserCached;
|
|
6017
6019
|
}
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6020
|
+
/**
|
|
6021
|
+
* @param {{ forceReadFromStorage?: boolean }} [opts]
|
|
6022
|
+
* @returns {Promise<User | undefined>}
|
|
6023
|
+
*/
|
|
6024
|
+
async _getCurrentUser(e) {
|
|
6025
|
+
e != null && e.forceReadFromStorage && await this.kv.unloadKey(Te);
|
|
6026
|
+
const n = await this.kv.waitForKeyToLoad(Te);
|
|
6027
|
+
return typeof n == "string" ? JSON.parse(n) : n;
|
|
6021
6028
|
}
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6029
|
+
/**
|
|
6030
|
+
* @param {{ forceReadFromStorage?: boolean }} [opts]
|
|
6031
|
+
* @returns {Promise<AuthState>}
|
|
6032
|
+
*/
|
|
6033
|
+
async getCurrentUser(e) {
|
|
6034
|
+
const n = await this._waitForOAuthCallbackResponse();
|
|
6035
|
+
if (n != null && n.error) {
|
|
6036
|
+
const r = { error: n.error, user: void 0 };
|
|
6037
|
+
return this._currentUserCached = { isLoading: !1, ...r }, this._currentUserCached;
|
|
6027
6038
|
}
|
|
6028
6039
|
try {
|
|
6029
|
-
const
|
|
6040
|
+
const s = { user: await this._getCurrentUser(e), error: void 0 };
|
|
6030
6041
|
return this._currentUserCached = {
|
|
6031
6042
|
isLoading: !1,
|
|
6032
|
-
...
|
|
6033
|
-
},
|
|
6034
|
-
} catch (
|
|
6043
|
+
...s
|
|
6044
|
+
}, this._currentUserCached;
|
|
6045
|
+
} catch (r) {
|
|
6035
6046
|
return {
|
|
6036
6047
|
user: void 0,
|
|
6037
6048
|
isLoading: !1,
|
|
6038
|
-
error: { message: (
|
|
6049
|
+
error: { message: (r == null ? void 0 : r.message) || "Error loading user" }
|
|
6039
6050
|
};
|
|
6040
6051
|
}
|
|
6041
6052
|
}
|
|
6042
6053
|
async _hasCurrentUser() {
|
|
6043
|
-
const e = await this.kv.waitForKeyToLoad(
|
|
6054
|
+
const e = await this.kv.waitForKeyToLoad(Te);
|
|
6044
6055
|
return typeof e == "string" ? JSON.parse(e) != null : e != null;
|
|
6045
6056
|
}
|
|
6046
6057
|
async changeCurrentUser(e) {
|
|
@@ -6049,7 +6060,7 @@ class Yo {
|
|
|
6049
6060
|
if (!Ge(n, e)) {
|
|
6050
6061
|
await this.setCurrentUser(e), await this.updateUser(e);
|
|
6051
6062
|
try {
|
|
6052
|
-
(r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
|
|
6063
|
+
await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
|
|
6053
6064
|
} catch (s) {
|
|
6054
6065
|
console.error("Error posting message to broadcast channel", s);
|
|
6055
6066
|
}
|
|
@@ -6094,13 +6105,13 @@ class Yo {
|
|
|
6094
6105
|
});
|
|
6095
6106
|
}
|
|
6096
6107
|
async signInWithMagicCode({ email: e, code: n }) {
|
|
6097
|
-
var o;
|
|
6108
|
+
var o, a;
|
|
6098
6109
|
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await so({
|
|
6099
6110
|
apiURI: this.config.apiURI,
|
|
6100
6111
|
appId: this.config.appId,
|
|
6101
6112
|
email: e,
|
|
6102
6113
|
code: n,
|
|
6103
|
-
refreshToken: s ? r.user.refresh_token : void 0
|
|
6114
|
+
refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
|
|
6104
6115
|
});
|
|
6105
6116
|
return await this.changeCurrentUser(i.user), i;
|
|
6106
6117
|
}
|
|
@@ -6159,13 +6170,13 @@ class Yo {
|
|
|
6159
6170
|
* @param {string} [params.codeVerifier] - The code verifier used to generate the code challenge.
|
|
6160
6171
|
*/
|
|
6161
6172
|
async exchangeCodeForToken({ code: e, codeVerifier: n }) {
|
|
6162
|
-
var o;
|
|
6173
|
+
var o, a;
|
|
6163
6174
|
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await mn({
|
|
6164
6175
|
apiURI: this.config.apiURI,
|
|
6165
6176
|
appId: this.config.appId,
|
|
6166
6177
|
code: e,
|
|
6167
6178
|
codeVerifier: n,
|
|
6168
|
-
refreshToken: s ? r.user.refresh_token : void 0
|
|
6179
|
+
refreshToken: s ? (a = r == null ? void 0 : r.user) == null ? void 0 : a.refresh_token : void 0
|
|
6169
6180
|
});
|
|
6170
6181
|
return await this.changeCurrentUser(i.user), i;
|
|
6171
6182
|
}
|