@instantdb/react-common 0.22.162 → 0.22.163
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 +109 -94
- package/dist/standalone/index.umd.cjs +9 -9
- package/package.json +3 -3
package/dist/standalone/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var Rs = Object.defineProperty;
|
|
2
2
|
var js = (n, e, t) => e in n ? Rs(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
3
|
var h = (n, e, t) => js(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import mr, { useRef as
|
|
5
|
-
var Wt = { exports: {} },
|
|
4
|
+
import mr, { useRef as Ne, useCallback as ve, useSyncExternalStore as Kt, useEffect as Pe, useMemo as qt, useState as wr } from "react";
|
|
5
|
+
var Wt = { exports: {} }, Be = {};
|
|
6
6
|
/**
|
|
7
7
|
* @license React
|
|
8
8
|
* react-jsx-runtime.production.min.js
|
|
@@ -14,7 +14,7 @@ var Wt = { exports: {} }, Ve = {};
|
|
|
14
14
|
*/
|
|
15
15
|
var xn;
|
|
16
16
|
function Ds() {
|
|
17
|
-
if (xn) return
|
|
17
|
+
if (xn) return Be;
|
|
18
18
|
xn = 1;
|
|
19
19
|
var n = mr, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
20
20
|
function o(a, c, u) {
|
|
@@ -24,11 +24,11 @@ function Ds() {
|
|
|
24
24
|
if (a && a.defaultProps) for (l in c = a.defaultProps, c) f[l] === void 0 && (f[l] = c[l]);
|
|
25
25
|
return { $$typeof: e, type: a, key: p, ref: y, props: f, _owner: s.current };
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return Be.Fragment = t, Be.jsx = o, Be.jsxs = o, Be;
|
|
28
28
|
}
|
|
29
|
-
var
|
|
29
|
+
var Qe = {}, Un;
|
|
30
30
|
function $s() {
|
|
31
|
-
if (Un) return
|
|
31
|
+
if (Un) return Qe;
|
|
32
32
|
Un = 1;
|
|
33
33
|
var n = {};
|
|
34
34
|
/**
|
|
@@ -157,7 +157,7 @@ function $s() {
|
|
|
157
157
|
J++;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function ze() {
|
|
161
161
|
{
|
|
162
162
|
if (J--, J === 0) {
|
|
163
163
|
var d = {
|
|
@@ -277,7 +277,7 @@ function $s() {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
} finally {
|
|
280
|
-
kt = !1, he.current = $,
|
|
280
|
+
kt = !1, he.current = $, ze(), Error.prepareStackTrace = D;
|
|
281
281
|
}
|
|
282
282
|
var $e = d ? d.displayName || d.name : "", Oe = $e ? st($e) : "";
|
|
283
283
|
return typeof d == "function" && it.set(d, Oe), Oe;
|
|
@@ -318,7 +318,7 @@ function $s() {
|
|
|
318
318
|
}
|
|
319
319
|
return "";
|
|
320
320
|
}
|
|
321
|
-
var
|
|
321
|
+
var Ve = Object.prototype.hasOwnProperty, Sn = {}, vn = _.ReactDebugCurrentFrame;
|
|
322
322
|
function at(d) {
|
|
323
323
|
if (d) {
|
|
324
324
|
var m = d._owner, A = ot(d.type, d._source, m ? m.type : null);
|
|
@@ -328,7 +328,7 @@ function $s() {
|
|
|
328
328
|
}
|
|
329
329
|
function ls(d, m, A, E, D) {
|
|
330
330
|
{
|
|
331
|
-
var $ = Function.call.bind(
|
|
331
|
+
var $ = Function.call.bind(Ve);
|
|
332
332
|
for (var R in d)
|
|
333
333
|
if ($(d, R)) {
|
|
334
334
|
var P = void 0;
|
|
@@ -376,7 +376,7 @@ function $s() {
|
|
|
376
376
|
__source: !0
|
|
377
377
|
}, kn, Cn;
|
|
378
378
|
function ys(d) {
|
|
379
|
-
if (
|
|
379
|
+
if (Ve.call(d, "ref")) {
|
|
380
380
|
var m = Object.getOwnPropertyDescriptor(d, "ref").get;
|
|
381
381
|
if (m && m.isReactWarning)
|
|
382
382
|
return !1;
|
|
@@ -384,7 +384,7 @@ function $s() {
|
|
|
384
384
|
return d.ref !== void 0;
|
|
385
385
|
}
|
|
386
386
|
function bs(d) {
|
|
387
|
-
if (
|
|
387
|
+
if (Ve.call(d, "key")) {
|
|
388
388
|
var m = Object.getOwnPropertyDescriptor(d, "key").get;
|
|
389
389
|
if (m && m.isReactWarning)
|
|
390
390
|
return !1;
|
|
@@ -450,7 +450,7 @@ function $s() {
|
|
|
450
450
|
var $, R = {}, P = null, Z = null;
|
|
451
451
|
A !== void 0 && (On(A), P = "" + A), bs(m) && (On(m.key), P = "" + m.key), ys(m) && (Z = m.ref, _s(m, D));
|
|
452
452
|
for ($ in m)
|
|
453
|
-
|
|
453
|
+
Ve.call(m, $) && !ps.hasOwnProperty($) && (R[$] = m[$]);
|
|
454
454
|
if (d && d.defaultProps) {
|
|
455
455
|
var N = d.defaultProps;
|
|
456
456
|
for ($ in N)
|
|
@@ -601,7 +601,7 @@ Check the top-level render call using <` + A + ">.");
|
|
|
601
601
|
else
|
|
602
602
|
jn(le, d);
|
|
603
603
|
}
|
|
604
|
-
if (
|
|
604
|
+
if (Ve.call(m, "key")) {
|
|
605
605
|
var Oe = F(d), re = Object.keys(m).filter(function(Ms) {
|
|
606
606
|
return Ms !== "key";
|
|
607
607
|
}), Rt = re.length > 0 ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
@@ -625,8 +625,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
625
625
|
return $n(d, m, A, !1);
|
|
626
626
|
}
|
|
627
627
|
var Cs = ks, Is = Es;
|
|
628
|
-
|
|
629
|
-
}(),
|
|
628
|
+
Qe.Fragment = s, Qe.jsx = Cs, Qe.jsxs = Is;
|
|
629
|
+
}(), Qe;
|
|
630
630
|
}
|
|
631
631
|
var xs = {};
|
|
632
632
|
xs.NODE_ENV === "production" ? Wt.exports = Ds() : Wt.exports = $s();
|
|
@@ -677,7 +677,7 @@ const K = {
|
|
|
677
677
|
mutable: "mutable",
|
|
678
678
|
immutable: "immutable"
|
|
679
679
|
}, cn = {};
|
|
680
|
-
function
|
|
680
|
+
function Ze(n, e) {
|
|
681
681
|
return n instanceof Map ? n.has(e) : Object.prototype.hasOwnProperty.call(n, e);
|
|
682
682
|
}
|
|
683
683
|
function Ln(n, e) {
|
|
@@ -724,7 +724,7 @@ function Sr(n, e = []) {
|
|
|
724
724
|
if (r !== null && (r == null ? void 0 : r.original) !== n.original)
|
|
725
725
|
return null;
|
|
726
726
|
const s = n.parent.type === 3, i = s ? Array.from(n.parent.setMap.keys()).indexOf(n.key) : n.key;
|
|
727
|
-
if (!(s && t.size > i ||
|
|
727
|
+
if (!(s && t.size > i || Ze(t, i)))
|
|
728
728
|
return null;
|
|
729
729
|
e.push(i);
|
|
730
730
|
}
|
|
@@ -828,15 +828,15 @@ function vr(n, e) {
|
|
|
828
828
|
function X(n) {
|
|
829
829
|
n.copy || (n.copy = vr(n.original, n.options));
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function Ge(n) {
|
|
832
832
|
if (!ye(n))
|
|
833
833
|
return fn(n);
|
|
834
834
|
if (Array.isArray(n))
|
|
835
|
-
return n.map(
|
|
835
|
+
return n.map(Ge);
|
|
836
836
|
if (n instanceof Map) {
|
|
837
837
|
const t = Array.from(n.entries()).map(([r, s]) => [
|
|
838
838
|
r,
|
|
839
|
-
|
|
839
|
+
Ge(s)
|
|
840
840
|
]);
|
|
841
841
|
if (!ln(n)) {
|
|
842
842
|
const r = Object.getPrototypeOf(n).constructor;
|
|
@@ -845,7 +845,7 @@ function Qe(n) {
|
|
|
845
845
|
return new Map(t);
|
|
846
846
|
}
|
|
847
847
|
if (n instanceof Set) {
|
|
848
|
-
const t = Array.from(n).map(
|
|
848
|
+
const t = Array.from(n).map(Ge);
|
|
849
849
|
if (!un(n)) {
|
|
850
850
|
const r = Object.getPrototypeOf(n).constructor;
|
|
851
851
|
return new r(t);
|
|
@@ -854,11 +854,11 @@ function Qe(n) {
|
|
|
854
854
|
}
|
|
855
855
|
const e = Object.create(Object.getPrototypeOf(n));
|
|
856
856
|
for (const t in n)
|
|
857
|
-
e[t] =
|
|
857
|
+
e[t] = Ge(n[t]);
|
|
858
858
|
return e;
|
|
859
859
|
}
|
|
860
860
|
function pt(n) {
|
|
861
|
-
return Me(n) ?
|
|
861
|
+
return Me(n) ? Ge(n) : n;
|
|
862
862
|
}
|
|
863
863
|
function ge(n) {
|
|
864
864
|
var e;
|
|
@@ -1026,7 +1026,7 @@ function qs(n, e, t, r, s) {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
function Ws({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
|
|
1028
1028
|
t.forEach((a, c) => {
|
|
1029
|
-
const u = Se(n, c), l = pt(Se(e, c)), f = a ?
|
|
1029
|
+
const u = Se(n, c), l = pt(Se(e, c)), f = a ? Ze(n, c) ? K.Replace : K.Add : K.Remove;
|
|
1030
1030
|
if (Te(u, l) && f === K.Replace)
|
|
1031
1031
|
return;
|
|
1032
1032
|
const p = r.concat(c), y = Ce(p, o);
|
|
@@ -1301,7 +1301,7 @@ const Bs = Reflect.ownKeys(gt), Or = /* @__PURE__ */ new WeakSet(), Er = {
|
|
|
1301
1301
|
if (u)
|
|
1302
1302
|
return u.bind(n.proxy);
|
|
1303
1303
|
}
|
|
1304
|
-
if (!
|
|
1304
|
+
if (!Ze(a, e)) {
|
|
1305
1305
|
const u = Ln(a, e);
|
|
1306
1306
|
return u ? "value" in u ? u.value : (
|
|
1307
1307
|
// !case: support for getter
|
|
@@ -1337,7 +1337,7 @@ const Bs = Reflect.ownKeys(gt), Or = /* @__PURE__ */ new WeakSet(), Er = {
|
|
|
1337
1337
|
if (i != null && i.set)
|
|
1338
1338
|
return i.set.call(n.proxy, t), !0;
|
|
1339
1339
|
const o = jt(ae(n), e), a = M(o);
|
|
1340
|
-
return a && Te(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Te(t, o) && (t !== void 0 ||
|
|
1340
|
+
return a && Te(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Te(t, o) && (t !== void 0 || Ze(n.original, e)) || (X(n), ge(n), Ze(n.original, e) && Te(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, hn(n, e, t, et)), !0);
|
|
1341
1341
|
},
|
|
1342
1342
|
has(n, e) {
|
|
1343
1343
|
return e in ae(n);
|
|
@@ -1577,7 +1577,7 @@ function yt(n, e) {
|
|
|
1577
1577
|
return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Cr(n, e) ? Object.keys(n).every((t) => yt(n[t], e[t])) : !1;
|
|
1578
1578
|
}
|
|
1579
1579
|
function yn(n) {
|
|
1580
|
-
if (!
|
|
1580
|
+
if (!He(n))
|
|
1581
1581
|
return n;
|
|
1582
1582
|
const e = {};
|
|
1583
1583
|
for (const [t, r] of Object.entries(n))
|
|
@@ -1585,7 +1585,7 @@ function yn(n) {
|
|
|
1585
1585
|
return e;
|
|
1586
1586
|
}
|
|
1587
1587
|
function Ir(n, e) {
|
|
1588
|
-
if (!
|
|
1588
|
+
if (!He(n) || !He(e))
|
|
1589
1589
|
return e;
|
|
1590
1590
|
const t = { ...n };
|
|
1591
1591
|
for (const r of Object.keys(e)) {
|
|
@@ -1595,12 +1595,12 @@ function Ir(n, e) {
|
|
|
1595
1595
|
delete t[r];
|
|
1596
1596
|
continue;
|
|
1597
1597
|
}
|
|
1598
|
-
const s =
|
|
1598
|
+
const s = He(n[r]) && He(e[r]);
|
|
1599
1599
|
t[r] = s ? Ir(n[r], e[r]) : e[r];
|
|
1600
1600
|
}
|
|
1601
1601
|
return t;
|
|
1602
1602
|
}
|
|
1603
|
-
function
|
|
1603
|
+
function He(n) {
|
|
1604
1604
|
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
1605
1605
|
}
|
|
1606
1606
|
function Js(n, e, t) {
|
|
@@ -2047,7 +2047,7 @@ function bn(n) {
|
|
|
2047
2047
|
function _n(n) {
|
|
2048
2048
|
return n["value-type"] === "blob";
|
|
2049
2049
|
}
|
|
2050
|
-
function
|
|
2050
|
+
function We(n, e) {
|
|
2051
2051
|
return e.reduce((t, r) => t && t.get(r), n);
|
|
2052
2052
|
}
|
|
2053
2053
|
function pe(n, e) {
|
|
@@ -2092,7 +2092,7 @@ function Rr(n) {
|
|
|
2092
2092
|
};
|
|
2093
2093
|
}
|
|
2094
2094
|
function jr(n, e) {
|
|
2095
|
-
return
|
|
2095
|
+
return Je(n, e.triples, e.cardinalityInference, e.useDateObjects);
|
|
2096
2096
|
}
|
|
2097
2097
|
function Dr(n, e) {
|
|
2098
2098
|
if (n)
|
|
@@ -2101,9 +2101,9 @@ function Dr(n, e) {
|
|
|
2101
2101
|
return new Ie(e.attrs, e.linkIndex);
|
|
2102
2102
|
}
|
|
2103
2103
|
function bi(n, e) {
|
|
2104
|
-
return
|
|
2104
|
+
return We(n.eav, [e]) !== void 0;
|
|
2105
2105
|
}
|
|
2106
|
-
function
|
|
2106
|
+
function Je(n, e, t, r) {
|
|
2107
2107
|
const s = Mr(n, e, r);
|
|
2108
2108
|
return s.cardinalityInference = t, s.useDateObjects = r, s;
|
|
2109
2109
|
}
|
|
@@ -2145,7 +2145,7 @@ let _i = 0;
|
|
|
2145
2145
|
function xr(n, e, t) {
|
|
2146
2146
|
const [r, s, i] = t;
|
|
2147
2147
|
let o;
|
|
2148
|
-
const a =
|
|
2148
|
+
const a = We(n.eav, [r, s, i]);
|
|
2149
2149
|
return a && (o = a[3]), o || Date.now() * 10 + _i++;
|
|
2150
2150
|
}
|
|
2151
2151
|
function Ur(n, e, t) {
|
|
@@ -2157,7 +2157,7 @@ function Ur(n, e, t) {
|
|
|
2157
2157
|
if (!a)
|
|
2158
2158
|
return;
|
|
2159
2159
|
a["checked-data-type"] === "date" && n.useDateObjects && (o = St(o));
|
|
2160
|
-
const c =
|
|
2160
|
+
const c = We(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? xr(n, a, r), l = [s, i, o, u];
|
|
2161
2161
|
yi(a) ? (se(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), se(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (se(n.eav, [s, i, o], l), se(n.aev, [i, s, o], l)), bn(a) && se(n.vae, [o, i, s], l);
|
|
2162
2162
|
}
|
|
2163
2163
|
function gi(n, e, t) {
|
|
@@ -2170,7 +2170,7 @@ function gi(n, e, t) {
|
|
|
2170
2170
|
return;
|
|
2171
2171
|
if (!_n(a))
|
|
2172
2172
|
throw new Error("merge operation is not supported for links");
|
|
2173
|
-
const c =
|
|
2173
|
+
const c = We(n.eav, [s, i]);
|
|
2174
2174
|
if (!c)
|
|
2175
2175
|
return;
|
|
2176
2176
|
const u = (y = c.values().next()) == null ? void 0 : y.value;
|
|
@@ -2395,7 +2395,7 @@ function ki(n, e, t) {
|
|
|
2395
2395
|
return;
|
|
2396
2396
|
const [s, i, o] = r;
|
|
2397
2397
|
if (e.getAttr(i))
|
|
2398
|
-
return
|
|
2398
|
+
return We(n.eav, [s, i]);
|
|
2399
2399
|
}
|
|
2400
2400
|
function Ci(n, e, t) {
|
|
2401
2401
|
const r = t.filter(([s, i, o, a, c]) => {
|
|
@@ -2490,7 +2490,7 @@ function Li(n, e, t) {
|
|
|
2490
2490
|
return Ai(n, gn(t, e));
|
|
2491
2491
|
}
|
|
2492
2492
|
const Fi = /^(?:[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;
|
|
2493
|
-
function
|
|
2493
|
+
function Ke(n) {
|
|
2494
2494
|
return typeof n == "string" && Fi.test(n);
|
|
2495
2495
|
}
|
|
2496
2496
|
const H = [];
|
|
@@ -2555,13 +2555,13 @@ function Gi() {
|
|
|
2555
2555
|
}
|
|
2556
2556
|
const Hi = Gi();
|
|
2557
2557
|
let Ji = !0, Yi = 0;
|
|
2558
|
-
function
|
|
2558
|
+
function Xe(n) {
|
|
2559
2559
|
return vt(`_${n}`, Yi++);
|
|
2560
2560
|
}
|
|
2561
2561
|
function vt(n, e) {
|
|
2562
2562
|
return `?${n}-${e}`;
|
|
2563
2563
|
}
|
|
2564
|
-
class
|
|
2564
|
+
class qe extends Error {
|
|
2565
2565
|
constructor(e) {
|
|
2566
2566
|
super(e), this.name = "AttrNotFoundError";
|
|
2567
2567
|
}
|
|
@@ -2569,7 +2569,7 @@ class Ke extends Error {
|
|
|
2569
2569
|
function Zi(n, e) {
|
|
2570
2570
|
const t = Nr(n, e);
|
|
2571
2571
|
if (!t)
|
|
2572
|
-
throw new
|
|
2572
|
+
throw new qe(`Could not find id attr for ${e}`);
|
|
2573
2573
|
return t;
|
|
2574
2574
|
}
|
|
2575
2575
|
function Gn(n, e, t, r) {
|
|
@@ -2589,19 +2589,19 @@ function eo(n, e, t) {
|
|
|
2589
2589
|
function qr(n, e, t, r, s) {
|
|
2590
2590
|
const i = W(e, t, s), o = je(e, t, s), a = i || o;
|
|
2591
2591
|
if (!a)
|
|
2592
|
-
throw new
|
|
2592
|
+
throw new qe(`Could not find attr for ${[t, s]}`);
|
|
2593
2593
|
if (a["value-type"] !== "ref")
|
|
2594
2594
|
throw new Error(`Attr ${a.id} is not a ref`);
|
|
2595
2595
|
const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], p = r + 1, y = i ? [
|
|
2596
2596
|
n(u, r),
|
|
2597
2597
|
a.id,
|
|
2598
2598
|
n(f, p),
|
|
2599
|
-
|
|
2599
|
+
Xe("time")
|
|
2600
2600
|
] : [
|
|
2601
2601
|
n(u, p),
|
|
2602
2602
|
a.id,
|
|
2603
2603
|
n(f, r),
|
|
2604
|
-
|
|
2604
|
+
Xe("time")
|
|
2605
2605
|
];
|
|
2606
2606
|
return [i ? f : u, p, y, a, !!i];
|
|
2607
2607
|
}
|
|
@@ -2678,24 +2678,24 @@ function to(n, e) {
|
|
|
2678
2678
|
function no(n, e, t, r, s, i) {
|
|
2679
2679
|
const o = W(e, t, s), a = je(e, t, s), c = o || a;
|
|
2680
2680
|
if (!c)
|
|
2681
|
-
throw new
|
|
2681
|
+
throw new qe(`No attr for etype = ${t} label = ${s}`);
|
|
2682
2682
|
if (i != null && i.hasOwnProperty("$isNull")) {
|
|
2683
2683
|
const u = W(e, t, "id");
|
|
2684
2684
|
if (!u)
|
|
2685
|
-
throw new
|
|
2685
|
+
throw new qe(`No attr for etype = ${t} label = id`);
|
|
2686
2686
|
return [
|
|
2687
2687
|
n(t, r),
|
|
2688
2688
|
u.id,
|
|
2689
2689
|
{ $isNull: { attrId: c.id, isNull: i.$isNull, reverse: !o } },
|
|
2690
|
-
|
|
2690
|
+
Xe("time")
|
|
2691
2691
|
];
|
|
2692
2692
|
}
|
|
2693
2693
|
return o ? [
|
|
2694
2694
|
n(t, r),
|
|
2695
2695
|
c.id,
|
|
2696
2696
|
to(c, i),
|
|
2697
|
-
|
|
2698
|
-
] : [i, c.id, n(t, r),
|
|
2697
|
+
Xe("time")
|
|
2698
|
+
] : [i, c.id, n(t, r), Xe("time")];
|
|
2699
2699
|
}
|
|
2700
2700
|
function ro(n, e, t, r, s) {
|
|
2701
2701
|
const [i, o, a] = s.reduce((c, u) => {
|
|
@@ -2797,7 +2797,7 @@ function ho(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
|
2797
2797
|
}), k = b ? v[0] : v;
|
|
2798
2798
|
return { [y]: k };
|
|
2799
2799
|
} catch (_) {
|
|
2800
|
-
if (_ instanceof
|
|
2800
|
+
if (_ instanceof qe)
|
|
2801
2801
|
return { [y]: b ? void 0 : [] };
|
|
2802
2802
|
throw _;
|
|
2803
2803
|
}
|
|
@@ -2809,11 +2809,11 @@ function ho(n, e, t, { etype: r, level: s, form: i }, o) {
|
|
|
2809
2809
|
function po(n, e, t) {
|
|
2810
2810
|
return t === "string" ? Hi(n, e) : n > e ? 1 : -1;
|
|
2811
2811
|
}
|
|
2812
|
-
function
|
|
2812
|
+
function Ye(n, e, t, r, s) {
|
|
2813
2813
|
return e === r || e == null && r == null ? Bi(n, t) : r == null ? 1 : e == null ? -1 : po(e, r, s);
|
|
2814
2814
|
}
|
|
2815
2815
|
function wt([n, e], [t, r], s) {
|
|
2816
|
-
return
|
|
2816
|
+
return Ye(n, e, t, r, s);
|
|
2817
2817
|
}
|
|
2818
2818
|
function Xt(n) {
|
|
2819
2819
|
return n == null ? n : new Date(n).getTime();
|
|
@@ -2915,7 +2915,7 @@ function vo(n, e, t) {
|
|
|
2915
2915
|
try {
|
|
2916
2916
|
return So(n, e, t);
|
|
2917
2917
|
} catch (r) {
|
|
2918
|
-
if (r instanceof
|
|
2918
|
+
if (r instanceof qe)
|
|
2919
2919
|
return {};
|
|
2920
2920
|
throw r;
|
|
2921
2921
|
}
|
|
@@ -3406,7 +3406,7 @@ function ta(n, e) {
|
|
|
3406
3406
|
function Xn(n, e) {
|
|
3407
3407
|
typeof requestIdleCallback > "u" ? n() : requestIdleCallback(n, { timeout: e });
|
|
3408
3408
|
}
|
|
3409
|
-
const
|
|
3409
|
+
const Le = "__meta";
|
|
3410
3410
|
class na {
|
|
3411
3411
|
constructor(e, t) {
|
|
3412
3412
|
}
|
|
@@ -3444,7 +3444,7 @@ class sn {
|
|
|
3444
3444
|
var e;
|
|
3445
3445
|
this._meta.loadingPromise && await this._meta.loadingPromise;
|
|
3446
3446
|
try {
|
|
3447
|
-
const t = this._persister.getItem(
|
|
3447
|
+
const t = this._persister.getItem(Le);
|
|
3448
3448
|
this._meta.loadingPromise = t;
|
|
3449
3449
|
const r = await t;
|
|
3450
3450
|
this._meta.isLoading = !1, this._meta.error = null, this._meta.loadingPromise = null, this._meta.attempts = 0;
|
|
@@ -3526,7 +3526,7 @@ class sn {
|
|
|
3526
3526
|
const p = this._persister.removeItem(f);
|
|
3527
3527
|
t.push(p.then(() => 1)), this._loadedKeys.delete(f), this._pendingSaveKeys.delete(f);
|
|
3528
3528
|
}
|
|
3529
|
-
const a = [], c = [[
|
|
3529
|
+
const a = [], c = [[Le, s]], u = s.objects ?? {};
|
|
3530
3530
|
s.objects = u;
|
|
3531
3531
|
for (const f of o)
|
|
3532
3532
|
if (this._loadedKeys.has(f)) {
|
|
@@ -3555,7 +3555,7 @@ class sn {
|
|
|
3555
3555
|
if (!this._gcOpts)
|
|
3556
3556
|
return;
|
|
3557
3557
|
const e = new Set(await this._persister.getAllKeys());
|
|
3558
|
-
e.delete(
|
|
3558
|
+
e.delete(Le);
|
|
3559
3559
|
const t = new Set(Object.keys(this.currentValue));
|
|
3560
3560
|
for (const p of Object.keys(this._loadingKeys))
|
|
3561
3561
|
t.add(p);
|
|
@@ -3650,6 +3650,14 @@ class sn {
|
|
|
3650
3650
|
this._subs = this._subs.filter((t) => t !== e);
|
|
3651
3651
|
};
|
|
3652
3652
|
}
|
|
3653
|
+
// Removes any keys that we haven't loaded--used when
|
|
3654
|
+
// changing users to make sure we clean out all user data
|
|
3655
|
+
async clearUnloadedKeys() {
|
|
3656
|
+
let e = !1;
|
|
3657
|
+
for (const t of await this._persister.getAllKeys())
|
|
3658
|
+
t === Le || t in this.currentValue || (this._pendingSaveKeys.add(t), e = !0);
|
|
3659
|
+
e && await this._enqueuePersist();
|
|
3660
|
+
}
|
|
3653
3661
|
}
|
|
3654
3662
|
const ra = 6, sa = ["kv", "querySubs", "syncSubs"];
|
|
3655
3663
|
function ia(n) {
|
|
@@ -3695,7 +3703,7 @@ async function aa(n, e, t) {
|
|
|
3695
3703
|
const T = t.put(g, y);
|
|
3696
3704
|
s.add(T);
|
|
3697
3705
|
}
|
|
3698
|
-
const c = { objects: a }, u = t.put(c,
|
|
3706
|
+
const c = { objects: a }, u = t.put(c, Le);
|
|
3699
3707
|
s.add(u);
|
|
3700
3708
|
for (const y of s)
|
|
3701
3709
|
y.onsuccess = () => {
|
|
@@ -3751,7 +3759,7 @@ async function ca(n, e) {
|
|
|
3751
3759
|
break;
|
|
3752
3760
|
}
|
|
3753
3761
|
}
|
|
3754
|
-
const u = er(
|
|
3762
|
+
const u = er(Le, c, i);
|
|
3755
3763
|
a.push(u), await Promise.all(a), await new Promise((l, f) => {
|
|
3756
3764
|
s.oncomplete = (p) => l(p), s.onerror = (p) => f(p), s.onabort = (p) => f(p);
|
|
3757
3765
|
});
|
|
@@ -4111,7 +4119,7 @@ function or(n) {
|
|
|
4111
4119
|
}, e;
|
|
4112
4120
|
}, {});
|
|
4113
4121
|
}
|
|
4114
|
-
const es = "v0.22.
|
|
4122
|
+
const es = "v0.22.163";
|
|
4115
4123
|
function Sa(n, e) {
|
|
4116
4124
|
return {
|
|
4117
4125
|
info: n ? (...t) => console.info(...t, e()) : () => {
|
|
@@ -4219,7 +4227,7 @@ const ar = [
|
|
|
4219
4227
|
default:
|
|
4220
4228
|
throw new U(`Unknown operator '${n}' for attribute '${r}' in entity '${s}'`, o);
|
|
4221
4229
|
}
|
|
4222
|
-
},
|
|
4230
|
+
}, Fe = (n, e, t, r, s) => {
|
|
4223
4231
|
const i = va(t), o = t.valueType === "json";
|
|
4224
4232
|
if (typeof n == "object" && n !== null && !Array.isArray(n)) {
|
|
4225
4233
|
if (o)
|
|
@@ -4249,23 +4257,23 @@ const ar = [
|
|
|
4249
4257
|
if (!c)
|
|
4250
4258
|
throw new U(`Target entity '${o}' does not exist in schema for dot notation path '${n}'.`, s);
|
|
4251
4259
|
if (a === "id") {
|
|
4252
|
-
if (typeof e == "string" && !
|
|
4260
|
+
if (typeof e == "string" && !Ke(e))
|
|
4253
4261
|
throw new U(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
4254
|
-
|
|
4262
|
+
Fe(e, n, new we("string", !1, !0), t, s);
|
|
4255
4263
|
return;
|
|
4256
4264
|
}
|
|
4257
4265
|
const u = c.attrs[a];
|
|
4258
4266
|
if (Object.keys(c.links).includes(a)) {
|
|
4259
|
-
if (typeof e == "string" && !
|
|
4267
|
+
if (typeof e == "string" && !Ke(e))
|
|
4260
4268
|
throw new U(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
4261
|
-
|
|
4269
|
+
Fe(e, n, new we("string", !1, !0), t, s);
|
|
4262
4270
|
return;
|
|
4263
4271
|
}
|
|
4264
4272
|
if (!u) {
|
|
4265
4273
|
const l = Object.keys(c.attrs);
|
|
4266
4274
|
throw new U(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${n}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
|
|
4267
4275
|
}
|
|
4268
|
-
|
|
4276
|
+
Fe(e, n, u, t, s);
|
|
4269
4277
|
}, ns = (n, e, t, r) => {
|
|
4270
4278
|
for (const [s, i] of Object.entries(n)) {
|
|
4271
4279
|
if (s === "or" || s === "and") {
|
|
@@ -4275,7 +4283,7 @@ const ar = [
|
|
|
4275
4283
|
continue;
|
|
4276
4284
|
}
|
|
4277
4285
|
if (s === "id") {
|
|
4278
|
-
|
|
4286
|
+
Fe(i, "id", new we("string", !1, !0), e, `${r}.id`);
|
|
4279
4287
|
continue;
|
|
4280
4288
|
}
|
|
4281
4289
|
if (s.includes(".")) {
|
|
@@ -4291,12 +4299,12 @@ const ar = [
|
|
|
4291
4299
|
throw new U(`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}`);
|
|
4292
4300
|
}
|
|
4293
4301
|
if (a)
|
|
4294
|
-
|
|
4302
|
+
Fe(i, s, a, e, `${r}.${s}`);
|
|
4295
4303
|
else if (c) {
|
|
4296
|
-
if (typeof i == "string" && !
|
|
4304
|
+
if (typeof i == "string" && !Ke(i))
|
|
4297
4305
|
throw new U(`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`, `${r}.${s}`);
|
|
4298
4306
|
const u = new we("string", !1, !0);
|
|
4299
|
-
|
|
4307
|
+
Fe(i, s, u, e, `${r}.${s}`);
|
|
4300
4308
|
}
|
|
4301
4309
|
}
|
|
4302
4310
|
}, Ea = (n, e, t, r, s = 0) => {
|
|
@@ -4359,7 +4367,7 @@ const ar = [
|
|
|
4359
4367
|
rs(t[r], r, e, r, 0);
|
|
4360
4368
|
}
|
|
4361
4369
|
}
|
|
4362
|
-
}, ur = (n) => typeof n != "string" ? !1 : Tt(n) ? !0 :
|
|
4370
|
+
}, ur = (n) => typeof n != "string" ? !1 : Tt(n) ? !0 : Ke(n);
|
|
4363
4371
|
class fe extends Error {
|
|
4364
4372
|
constructor(e) {
|
|
4365
4373
|
super(e), this.name = "TransactionValidationError";
|
|
@@ -4420,7 +4428,7 @@ const ss = (n) => n.length > 0 ? n.join(", ") : "none", ka = (n, e) => new fe(`E
|
|
|
4420
4428
|
if (!e)
|
|
4421
4429
|
return;
|
|
4422
4430
|
const [t, r, s, i] = n;
|
|
4423
|
-
if (!Array.isArray(s) && !
|
|
4431
|
+
if (!Array.isArray(s) && !Ke(s))
|
|
4424
4432
|
throw new fe(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
|
|
4425
4433
|
if (typeof r != "string")
|
|
4426
4434
|
throw new fe(`Entity name must be a string, but received: ${typeof r}`);
|
|
@@ -4613,7 +4621,7 @@ function dr(n, e, t, r) {
|
|
|
4613
4621
|
const s = (o = W(t, n.table, "id")) == null ? void 0 : o.id;
|
|
4614
4622
|
if (!s)
|
|
4615
4623
|
return -1;
|
|
4616
|
-
const i =
|
|
4624
|
+
const i = We(e.eav, [r, s, r]);
|
|
4617
4625
|
return i ? i[3] : -1;
|
|
4618
4626
|
}
|
|
4619
4627
|
function hr(n, e, t) {
|
|
@@ -4666,17 +4674,17 @@ function La(n, e, t) {
|
|
|
4666
4674
|
const r = e;
|
|
4667
4675
|
if (n.orderField === "serverCreatedAt") {
|
|
4668
4676
|
t.sort(n.orderDirection === "asc" ? function(o, a) {
|
|
4669
|
-
return
|
|
4677
|
+
return Ye(o.entity.id, o.serverCreatedAt, a.entity.id, a.serverCreatedAt, r);
|
|
4670
4678
|
} : function(o, a) {
|
|
4671
|
-
return
|
|
4679
|
+
return Ye(a.entity.id, a.serverCreatedAt, o.entity.id, o.serverCreatedAt, r);
|
|
4672
4680
|
});
|
|
4673
4681
|
return;
|
|
4674
4682
|
}
|
|
4675
4683
|
const s = n.orderField;
|
|
4676
4684
|
t.sort(n.orderDirection === "asc" ? function(o, a) {
|
|
4677
|
-
return
|
|
4685
|
+
return Ye(o.entity.id, o.entity[s], a.entity.id, a.entity[s], r);
|
|
4678
4686
|
} : function(o, a) {
|
|
4679
|
-
return
|
|
4687
|
+
return Ye(a.entity.id, a.entity[s], o.entity.id, o.entity[s], r);
|
|
4680
4688
|
});
|
|
4681
4689
|
}
|
|
4682
4690
|
var Ee;
|
|
@@ -5078,8 +5086,8 @@ function Na({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
|
|
|
5078
5086
|
});
|
|
5079
5087
|
switch (ne.type) {
|
|
5080
5088
|
case "ok": {
|
|
5081
|
-
const { streamId: de, offset:
|
|
5082
|
-
if (
|
|
5089
|
+
const { streamId: de, offset: ze } = ne;
|
|
5090
|
+
if (ze !== 0) {
|
|
5083
5091
|
const he = new ee("Write stream is corrupted");
|
|
5084
5092
|
Y(O, he);
|
|
5085
5093
|
return;
|
|
@@ -5116,10 +5124,10 @@ function Na({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
|
|
|
5116
5124
|
he();
|
|
5117
5125
|
}, de = (he) => {
|
|
5118
5126
|
I(he), ne();
|
|
5119
|
-
},
|
|
5127
|
+
}, ze = (he) => {
|
|
5120
5128
|
B(he || new ee("Stream is closed.")), ne();
|
|
5121
5129
|
};
|
|
5122
|
-
G.push(x(de)), G.push(v(
|
|
5130
|
+
G.push(x(de)), G.push(v(ze));
|
|
5123
5131
|
});
|
|
5124
5132
|
}
|
|
5125
5133
|
}
|
|
@@ -5781,7 +5789,7 @@ class nc {
|
|
|
5781
5789
|
if (this._EventSource = i, this.config = { ...Ga, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Va, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Ba, this._log = Sa(e.verbose || wn || Yr, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": es }, this.config.schema && (this._linkIndex = or(this.config.schema)), !!Ja()) {
|
|
5782
5790
|
if (!e.appId)
|
|
5783
5791
|
throw new Error("Instant must be initialized with an appId.");
|
|
5784
|
-
if (!
|
|
5792
|
+
if (!Ke(e.appId))
|
|
5785
5793
|
throw new Error(`Instant must be initialized with a valid appId. \`${e.appId}\` is not a valid uuid.`);
|
|
5786
5794
|
typeof BroadcastChannel == "function" && (this._broadcastChannel = new BroadcastChannel("@instantdb"), this._broadcastChannel.addEventListener("message", async (o) => {
|
|
5787
5795
|
var a;
|
|
@@ -5799,7 +5807,7 @@ class nc {
|
|
|
5799
5807
|
}
|
|
5800
5808
|
})), this._initStorage(t), this._syncTable = new Fa(this._trySendAuthed.bind(this), new t(this.config.appId, "syncSubs"), {
|
|
5801
5809
|
useDateObjects: this.config.useDateObjects
|
|
5802
|
-
}, this._log, (o) =>
|
|
5810
|
+
}, this._log, (o) => Je(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new Wa({
|
|
5803
5811
|
WStream: this.config.WritableStream || WritableStream,
|
|
5804
5812
|
RStream: this.config.ReadableStream || ReadableStream,
|
|
5805
5813
|
trySend: this._trySendAuthed.bind(this),
|
|
@@ -5932,7 +5940,7 @@ class nc {
|
|
|
5932
5940
|
_addQueryData(e, t, r) {
|
|
5933
5941
|
if (!this.attrs)
|
|
5934
5942
|
throw new Error("Attrs in reactor have not been set");
|
|
5935
|
-
const s = Q(e), i = this.ensureAttrs(), o =
|
|
5943
|
+
const s = Q(e), i = this.ensureAttrs(), o = Je(this.attrs, t.triples, r, this.config.useDateObjects);
|
|
5936
5944
|
this.querySubs.updateInPlace((a) => {
|
|
5937
5945
|
a[s] = {
|
|
5938
5946
|
result: {
|
|
@@ -5966,7 +5974,7 @@ class nc {
|
|
|
5966
5974
|
const { q: y, result: b } = t, g = Q(y);
|
|
5967
5975
|
if (!this._hasQueryListeners() && !this.querySubs.currentValue[g])
|
|
5968
5976
|
break;
|
|
5969
|
-
const T = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, _ = ir(b), w = this.ensureAttrs(), C =
|
|
5977
|
+
const T = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, _ = ir(b), w = this.ensureAttrs(), C = Je(w, _, r, this.config.useDateObjects);
|
|
5970
5978
|
this.querySubs.updateInPlace((v) => {
|
|
5971
5979
|
if (!v[g]) {
|
|
5972
5980
|
this._log.info("Missing value in querySubs", { hash: g, q: y });
|
|
@@ -6023,7 +6031,7 @@ class nc {
|
|
|
6023
6031
|
});
|
|
6024
6032
|
const S = Ft(T.entries()), _ = y.map((w) => {
|
|
6025
6033
|
var F, V, J, me;
|
|
6026
|
-
const C = w["instaql-query"], v = w["instaql-result"], k = Q(C), j = ir(v), x = this.ensureAttrs(), z =
|
|
6034
|
+
const C = w["instaql-query"], v = w["instaql-result"], k = Q(C), j = ir(v), x = this.ensureAttrs(), z = Je(x, j, r, this.config.useDateObjects), { store: ue, attrsStore: Ae } = this._applyOptimisticUpdates(z, x, S, g), Y = (V = (F = v == null ? void 0 : v[0]) == null ? void 0 : F.data) == null ? void 0 : V["page-info"], te = (me = (J = v == null ? void 0 : v[0]) == null ? void 0 : J.data) == null ? void 0 : me.aggregate;
|
|
6027
6035
|
return {
|
|
6028
6036
|
q: C,
|
|
6029
6037
|
hash: k,
|
|
@@ -6703,6 +6711,13 @@ class nc {
|
|
|
6703
6711
|
Object.keys(r).forEach((s) => {
|
|
6704
6712
|
delete r[s].result;
|
|
6705
6713
|
});
|
|
6714
|
+
}), this.querySubs.clearUnloadedKeys(), this._updatePendingMutations((r) => {
|
|
6715
|
+
for (const [s, i] of r.entries())
|
|
6716
|
+
this.mutationDeferredStore.get(s) && this._finishTransaction("error", s, {
|
|
6717
|
+
message: "User changed while transaction was in progress.",
|
|
6718
|
+
type: "user-changed"
|
|
6719
|
+
});
|
|
6720
|
+
r.clear();
|
|
6706
6721
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(t);
|
|
6707
6722
|
}
|
|
6708
6723
|
sendMagicCode({ email: e }) {
|
|
@@ -7577,9 +7592,9 @@ function gr(n) {
|
|
|
7577
7592
|
}
|
|
7578
7593
|
function Tc(n, e, t, r) {
|
|
7579
7594
|
e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
|
|
7580
|
-
const s = e ? bc(e) : null, i = Q(s), o =
|
|
7595
|
+
const s = e ? bc(e) : null, i = Q(s), o = Ne(
|
|
7581
7596
|
gr(n._reactor.getPreviousResult(s))
|
|
7582
|
-
), a =
|
|
7597
|
+
), a = Ne(_r), c = ve(
|
|
7583
7598
|
(l) => (o.current = gr(
|
|
7584
7599
|
n._reactor.getPreviousResult(s)
|
|
7585
7600
|
), l(), s ? n.subscribeQuery(s, (p) => {
|
|
@@ -7611,7 +7626,7 @@ function Tc(n, e, t, r) {
|
|
|
7611
7626
|
), query: s, queryHash: i };
|
|
7612
7627
|
}
|
|
7613
7628
|
function Sc() {
|
|
7614
|
-
const n =
|
|
7629
|
+
const n = Ne(null);
|
|
7615
7630
|
Pe(() => {
|
|
7616
7631
|
t();
|
|
7617
7632
|
}, []);
|
|
@@ -7625,7 +7640,7 @@ function Sc() {
|
|
|
7625
7640
|
}
|
|
7626
7641
|
const vc = 1e3;
|
|
7627
7642
|
function Ac(n, e, t) {
|
|
7628
|
-
const r =
|
|
7643
|
+
const r = Ne(t);
|
|
7629
7644
|
r.current = t, Pe(() => n.core._reactor.subscribeTopic(
|
|
7630
7645
|
n.type,
|
|
7631
7646
|
n.id,
|
|
@@ -7989,7 +8004,7 @@ class Nt {
|
|
|
7989
8004
|
* }
|
|
7990
8005
|
*/
|
|
7991
8006
|
h(this, "useConnectionStatus", () => {
|
|
7992
|
-
const e =
|
|
8007
|
+
const e = Ne(
|
|
7993
8008
|
this.core._reactor.status
|
|
7994
8009
|
), t = ve((s) => this.core.subscribeConnectionStatus((o) => {
|
|
7995
8010
|
o !== e.current && (e.current = o, s());
|
|
@@ -8070,7 +8085,7 @@ class Nt {
|
|
|
8070
8085
|
return new Ic(this.core, e, t);
|
|
8071
8086
|
}
|
|
8072
8087
|
_useAuth() {
|
|
8073
|
-
const e =
|
|
8088
|
+
const e = Ne(
|
|
8074
8089
|
this.core._reactor._currentUserCached
|
|
8075
8090
|
), t = ve((s) => this.core.subscribeAuth((o) => {
|
|
8076
8091
|
e.current = { isLoading: !1, ...o }, s();
|