@instantdb/react-common 0.22.76 → 0.22.77
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 +336 -327
- package/dist/standalone/index.umd.cjs +8 -8
- package/package.json +3 -3
package/dist/standalone/index.js
CHANGED
|
@@ -1873,13 +1873,21 @@ function hs(t) {
|
|
|
1873
1873
|
return null;
|
|
1874
1874
|
}
|
|
1875
1875
|
function ps(t) {
|
|
1876
|
+
const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
|
|
1877
|
+
if (n) {
|
|
1878
|
+
const [, r, i, s, o, u] = n, a = i.padStart(2, "0"), d = s.padStart(2, "0"), c = `${r}-${a}-${d}T${u}`;
|
|
1879
|
+
return new Date(c);
|
|
1880
|
+
}
|
|
1881
|
+
return null;
|
|
1882
|
+
}
|
|
1883
|
+
function ys(t) {
|
|
1876
1884
|
const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
|
|
1877
1885
|
if (!o)
|
|
1878
1886
|
throw new Error(`Unable to parse time from: ${t}`);
|
|
1879
1887
|
let [, u, a, d, c] = o;
|
|
1880
1888
|
return u = Number(u), a = Number(a), d = Number(d), c === "PM" && u !== 12 ? u += 12 : c === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, d));
|
|
1881
1889
|
}
|
|
1882
|
-
function
|
|
1890
|
+
function bs(t) {
|
|
1883
1891
|
switch (t) {
|
|
1884
1892
|
case "epoch":
|
|
1885
1893
|
return /* @__PURE__ */ new Date(0);
|
|
@@ -1891,27 +1899,28 @@ function ys(t) {
|
|
|
1891
1899
|
return null;
|
|
1892
1900
|
}
|
|
1893
1901
|
}
|
|
1894
|
-
function
|
|
1902
|
+
function _s(t) {
|
|
1895
1903
|
const e = t.match(Wn);
|
|
1896
1904
|
if (!e)
|
|
1897
1905
|
return null;
|
|
1898
1906
|
const [n] = e, r = is[n], i = new Date(t.replace(Wn, "Z"));
|
|
1899
1907
|
return new Date(i.getTime() - r * 1e3);
|
|
1900
1908
|
}
|
|
1901
|
-
const
|
|
1909
|
+
const gs = [
|
|
1902
1910
|
as,
|
|
1903
1911
|
ds,
|
|
1904
1912
|
ls,
|
|
1905
|
-
|
|
1913
|
+
ys,
|
|
1906
1914
|
fs,
|
|
1907
1915
|
os,
|
|
1908
1916
|
hs,
|
|
1909
1917
|
cs,
|
|
1910
1918
|
ss,
|
|
1911
|
-
|
|
1912
|
-
|
|
1919
|
+
bs,
|
|
1920
|
+
_s,
|
|
1921
|
+
ps
|
|
1913
1922
|
];
|
|
1914
|
-
function
|
|
1923
|
+
function Ts(t, e) {
|
|
1915
1924
|
try {
|
|
1916
1925
|
const n = t(e);
|
|
1917
1926
|
return n instanceof Date && !isNaN(n.getTime()) ? n : null;
|
|
@@ -1920,14 +1929,14 @@ function gs(t, e) {
|
|
|
1920
1929
|
}
|
|
1921
1930
|
}
|
|
1922
1931
|
function Nt(t) {
|
|
1923
|
-
for (const e of
|
|
1924
|
-
const n =
|
|
1932
|
+
for (const e of gs) {
|
|
1933
|
+
const n = Ts(e, t);
|
|
1925
1934
|
if (n)
|
|
1926
1935
|
return n;
|
|
1927
1936
|
}
|
|
1928
1937
|
return null;
|
|
1929
1938
|
}
|
|
1930
|
-
function
|
|
1939
|
+
function ms(t) {
|
|
1931
1940
|
try {
|
|
1932
1941
|
const e = JSON.parse(t);
|
|
1933
1942
|
return typeof e == "string" ? Nt(e) : null;
|
|
@@ -1942,7 +1951,7 @@ function pt(t) {
|
|
|
1942
1951
|
if (t instanceof Date)
|
|
1943
1952
|
return t;
|
|
1944
1953
|
if (typeof t == "string") {
|
|
1945
|
-
const e = Nt(t) ||
|
|
1954
|
+
const e = Nt(t) || ms(t) || Nt(t.trim());
|
|
1946
1955
|
if (!e)
|
|
1947
1956
|
throw new Error(`Unable to parse \`${t}\` as a date.`);
|
|
1948
1957
|
return e;
|
|
@@ -1951,7 +1960,7 @@ function pt(t) {
|
|
|
1951
1960
|
throw new Error(`Invalid date value \`${t}\`. Expected a date, number, or string, got type ${typeof t}.`);
|
|
1952
1961
|
}
|
|
1953
1962
|
}
|
|
1954
|
-
function
|
|
1963
|
+
function ws(t) {
|
|
1955
1964
|
return t.cardinality === "one";
|
|
1956
1965
|
}
|
|
1957
1966
|
function an(t) {
|
|
@@ -2024,7 +2033,7 @@ function Ur(t) {
|
|
|
2024
2033
|
function Lr(t) {
|
|
2025
2034
|
return at(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
|
|
2026
2035
|
}
|
|
2027
|
-
function
|
|
2036
|
+
function vs(t, e) {
|
|
2028
2037
|
return Ce(t.eav, [e]) !== void 0;
|
|
2029
2038
|
}
|
|
2030
2039
|
function dn(t) {
|
|
@@ -2068,12 +2077,12 @@ function Fr(t, e) {
|
|
|
2068
2077
|
const [r, i, s] = n, o = ke(t.attrs, i);
|
|
2069
2078
|
o && (X(t.eav, [r, i, s]), X(t.aev, [i, r, s]), an(o) && X(t.vae, [s, i, r]));
|
|
2070
2079
|
}
|
|
2071
|
-
let
|
|
2080
|
+
let Ss = 0;
|
|
2072
2081
|
function Nr(t, e, n) {
|
|
2073
2082
|
const [r, i, s] = n;
|
|
2074
2083
|
let o;
|
|
2075
2084
|
const u = Ce(t.ea, [r, i, s]);
|
|
2076
|
-
return u && (o = u[3]), o || Date.now() * 10 +
|
|
2085
|
+
return u && (o = u[3]), o || Date.now() * 10 + Ss++;
|
|
2077
2086
|
}
|
|
2078
2087
|
function Kr(t, e) {
|
|
2079
2088
|
var n;
|
|
@@ -2086,9 +2095,9 @@ function Kr(t, e) {
|
|
|
2086
2095
|
return;
|
|
2087
2096
|
u["checked-data-type"] === "date" && t.useDateObjects && (o = pt(o));
|
|
2088
2097
|
const a = Ce(t.eav, [i, s, o]), d = (n = a == null ? void 0 : a[3]) !== null && n !== void 0 ? n : Nr(t, u, r), c = [i, s, o, d];
|
|
2089
|
-
|
|
2098
|
+
ws(u) ? (B(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), B(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (B(t.eav, [i, s, o], c), B(t.aev, [s, i, o], c)), an(u) && B(t.vae, [o, s, i], c);
|
|
2090
2099
|
}
|
|
2091
|
-
function
|
|
2100
|
+
function Os(t, e) {
|
|
2092
2101
|
var n;
|
|
2093
2102
|
const r = Be(t, e);
|
|
2094
2103
|
if (!r)
|
|
@@ -2145,30 +2154,30 @@ function qr(t, e) {
|
|
|
2145
2154
|
t[r] = n[r];
|
|
2146
2155
|
});
|
|
2147
2156
|
}
|
|
2148
|
-
function
|
|
2157
|
+
function Es(t, [e]) {
|
|
2149
2158
|
t.attrs[e.id] = e, dn(t);
|
|
2150
2159
|
}
|
|
2151
2160
|
function zr(t) {
|
|
2152
2161
|
return G(t.eav, 3);
|
|
2153
2162
|
}
|
|
2154
|
-
function
|
|
2163
|
+
function As(t, [e]) {
|
|
2155
2164
|
if (!t.attrs[e])
|
|
2156
2165
|
return;
|
|
2157
2166
|
const n = zr(t).filter(([r, i]) => i !== e);
|
|
2158
2167
|
delete t.attrs[e], dn(t), qr(t, n);
|
|
2159
2168
|
}
|
|
2160
|
-
function
|
|
2169
|
+
function js(t, [e]) {
|
|
2161
2170
|
const n = t.attrs[e.id];
|
|
2162
2171
|
n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), dn(t), qr(t, zr(t)));
|
|
2163
2172
|
}
|
|
2164
|
-
function
|
|
2173
|
+
function ks(t, e) {
|
|
2165
2174
|
const [n, ...r] = e;
|
|
2166
2175
|
switch (n) {
|
|
2167
2176
|
case "add-triple":
|
|
2168
2177
|
Kr(t, r);
|
|
2169
2178
|
break;
|
|
2170
2179
|
case "deep-merge-triple":
|
|
2171
|
-
|
|
2180
|
+
Os(t, r);
|
|
2172
2181
|
break;
|
|
2173
2182
|
case "retract-triple":
|
|
2174
2183
|
Fr(t, r);
|
|
@@ -2177,13 +2186,13 @@ function js(t, e) {
|
|
|
2177
2186
|
Kt(t, r);
|
|
2178
2187
|
break;
|
|
2179
2188
|
case "add-attr":
|
|
2180
|
-
|
|
2189
|
+
Es(t, r);
|
|
2181
2190
|
break;
|
|
2182
2191
|
case "delete-attr":
|
|
2183
|
-
|
|
2192
|
+
As(t, r);
|
|
2184
2193
|
break;
|
|
2185
2194
|
case "update-attr":
|
|
2186
|
-
|
|
2195
|
+
js(t, r);
|
|
2187
2196
|
break;
|
|
2188
2197
|
case "restore-attr":
|
|
2189
2198
|
break;
|
|
@@ -2238,13 +2247,13 @@ function tt(t, e, n) {
|
|
|
2238
2247
|
}
|
|
2239
2248
|
return s;
|
|
2240
2249
|
}
|
|
2241
|
-
function
|
|
2250
|
+
function Cs(t, e, n) {
|
|
2242
2251
|
let r = "";
|
|
2243
2252
|
return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
|
|
2244
2253
|
}
|
|
2245
|
-
function
|
|
2254
|
+
function Ps(t, [e, n, r]) {
|
|
2246
2255
|
var i, s;
|
|
2247
|
-
switch (
|
|
2256
|
+
switch (Cs(e, n, r)) {
|
|
2248
2257
|
case "e": {
|
|
2249
2258
|
const u = t.eav.get(e);
|
|
2250
2259
|
return G(u, 2);
|
|
@@ -2290,7 +2299,7 @@ function Cs(t, [e, n, r]) {
|
|
|
2290
2299
|
return G(t.eav, 3);
|
|
2291
2300
|
}
|
|
2292
2301
|
}
|
|
2293
|
-
function
|
|
2302
|
+
function Is(t, e, n) {
|
|
2294
2303
|
var r;
|
|
2295
2304
|
const i = {};
|
|
2296
2305
|
for (const [s, o] of e.entries()) {
|
|
@@ -2308,7 +2317,7 @@ function Vr(t, e, n) {
|
|
|
2308
2317
|
var r;
|
|
2309
2318
|
return (r = t.attrIndexes.revIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
|
|
2310
2319
|
}
|
|
2311
|
-
function
|
|
2320
|
+
function Ms(t, e) {
|
|
2312
2321
|
return t.attrIndexes.blobAttrs.get(e);
|
|
2313
2322
|
}
|
|
2314
2323
|
function Wr(t, e) {
|
|
@@ -2316,7 +2325,7 @@ function Wr(t, e) {
|
|
|
2316
2325
|
const r = t.attrIndexes.primaryKeys.get(e);
|
|
2317
2326
|
return r || ((n = t.attrIndexes.forwardIdents.get(e)) === null || n === void 0 ? void 0 : n.get("id"));
|
|
2318
2327
|
}
|
|
2319
|
-
function
|
|
2328
|
+
function Rs(t, e) {
|
|
2320
2329
|
const n = Be(t, e);
|
|
2321
2330
|
if (!n)
|
|
2322
2331
|
return;
|
|
@@ -2324,7 +2333,7 @@ function Ms(t, e) {
|
|
|
2324
2333
|
if (ke(t.attrs, i))
|
|
2325
2334
|
return Ce(t.eav, [r, i]);
|
|
2326
2335
|
}
|
|
2327
|
-
function
|
|
2336
|
+
function $s(t, e) {
|
|
2328
2337
|
const n = e.filter(([r, i, s, o, u]) => {
|
|
2329
2338
|
if (r !== "add-triple" && r !== "deep-merge-triple")
|
|
2330
2339
|
return !0;
|
|
@@ -2335,20 +2344,20 @@ function Rs(t, e) {
|
|
|
2335
2344
|
const c = ke(t.attrs, s);
|
|
2336
2345
|
if (c) {
|
|
2337
2346
|
const f = Wr(t, c["forward-identity"][1]);
|
|
2338
|
-
d = !!
|
|
2347
|
+
d = !!Rs(t, [i, f.id, i]);
|
|
2339
2348
|
}
|
|
2340
2349
|
return !(a === "create" && d || a === "update" && !d);
|
|
2341
2350
|
});
|
|
2342
2351
|
return ft(t, (r) => {
|
|
2343
2352
|
n.forEach((i) => {
|
|
2344
|
-
|
|
2353
|
+
ks(r, i);
|
|
2345
2354
|
});
|
|
2346
2355
|
});
|
|
2347
2356
|
}
|
|
2348
|
-
function
|
|
2357
|
+
function xs(t) {
|
|
2349
2358
|
return typeof t == "string" && t.startsWith("?");
|
|
2350
2359
|
}
|
|
2351
|
-
function
|
|
2360
|
+
function Ds(t, e, n) {
|
|
2352
2361
|
if (n.hasOwnProperty(t)) {
|
|
2353
2362
|
const r = n[t];
|
|
2354
2363
|
return Br(r, e, n);
|
|
@@ -2358,15 +2367,15 @@ function xs(t, e, n) {
|
|
|
2358
2367
|
function Bn(t, e, n) {
|
|
2359
2368
|
return t === e ? n : null;
|
|
2360
2369
|
}
|
|
2361
|
-
function
|
|
2370
|
+
function Us(t) {
|
|
2362
2371
|
switch (typeof t) {
|
|
2363
2372
|
case "string":
|
|
2364
|
-
return t.startsWith("?") ?
|
|
2373
|
+
return t.startsWith("?") ? Ds : Bn;
|
|
2365
2374
|
default:
|
|
2366
2375
|
return Bn;
|
|
2367
2376
|
}
|
|
2368
2377
|
}
|
|
2369
|
-
const
|
|
2378
|
+
const Ls = [
|
|
2370
2379
|
"in",
|
|
2371
2380
|
"$in",
|
|
2372
2381
|
"$not",
|
|
@@ -2374,69 +2383,69 @@ const Us = [
|
|
|
2374
2383
|
"$comparator"
|
|
2375
2384
|
// covers all of $gt, $lt, etc.
|
|
2376
2385
|
];
|
|
2377
|
-
function
|
|
2378
|
-
for (const e of
|
|
2386
|
+
function Fs(t) {
|
|
2387
|
+
for (const e of Ls)
|
|
2379
2388
|
if (t.hasOwnProperty(e))
|
|
2380
2389
|
return !0;
|
|
2381
2390
|
return !1;
|
|
2382
2391
|
}
|
|
2383
2392
|
function Br(t, e, n) {
|
|
2384
|
-
return n ? typeof t == "object" ?
|
|
2393
|
+
return n ? typeof t == "object" ? Fs(t) ? n : null : Us(t)(t, e, n) : null;
|
|
2385
2394
|
}
|
|
2386
|
-
function
|
|
2395
|
+
function Ns(t, e, n) {
|
|
2387
2396
|
return t.reduce((r, i, s) => {
|
|
2388
2397
|
const o = e[s];
|
|
2389
2398
|
return Br(i, o, r);
|
|
2390
2399
|
}, n);
|
|
2391
2400
|
}
|
|
2392
|
-
function Ns(t, e, n) {
|
|
2393
|
-
return zs(t, e, n).map((r) => Fs(e, r, n)).filter((r) => r);
|
|
2394
|
-
}
|
|
2395
2401
|
function Ks(t, e, n) {
|
|
2396
|
-
return
|
|
2402
|
+
return Vs(t, e, n).map((r) => Ns(e, r, n)).filter((r) => r);
|
|
2403
|
+
}
|
|
2404
|
+
function qs(t, e, n) {
|
|
2405
|
+
return e.or ? e.or.patterns.flatMap((r) => qt(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => qt(t, i, r), n) : n.flatMap((r) => Ks(t, e, r));
|
|
2397
2406
|
}
|
|
2398
2407
|
function qt(t, e, n = [{}]) {
|
|
2399
|
-
return e.reduce((r, i) =>
|
|
2408
|
+
return e.reduce((r, i) => qs(t, i, r), n);
|
|
2400
2409
|
}
|
|
2401
2410
|
function fn(t, e) {
|
|
2402
|
-
return Array.isArray(e) ? e.map((n) => fn(t, n)) :
|
|
2411
|
+
return Array.isArray(e) ? e.map((n) => fn(t, n)) : xs(e) ? t[e] : e;
|
|
2403
2412
|
}
|
|
2404
|
-
function
|
|
2413
|
+
function zs(t, { find: e, where: n }) {
|
|
2405
2414
|
return qt(t, n).map((i) => fn(i, e));
|
|
2406
2415
|
}
|
|
2407
|
-
function
|
|
2408
|
-
return
|
|
2416
|
+
function Vs(t, e, n) {
|
|
2417
|
+
return Ps(t, fn(n, e));
|
|
2409
2418
|
}
|
|
2410
|
-
const
|
|
2419
|
+
const Ws = /^(?:[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;
|
|
2411
2420
|
function Ee(t) {
|
|
2412
|
-
return typeof t == "string" &&
|
|
2421
|
+
return typeof t == "string" && Ws.test(t);
|
|
2413
2422
|
}
|
|
2414
2423
|
const F = [];
|
|
2415
2424
|
for (let t = 0; t < 256; ++t)
|
|
2416
2425
|
F.push((t + 256).toString(16).slice(1));
|
|
2417
|
-
function
|
|
2426
|
+
function Bs(t, e = 0) {
|
|
2418
2427
|
return (F[t[e + 0]] + F[t[e + 1]] + F[t[e + 2]] + F[t[e + 3]] + "-" + F[t[e + 4]] + F[t[e + 5]] + "-" + F[t[e + 6]] + F[t[e + 7]] + "-" + F[t[e + 8]] + F[t[e + 9]] + "-" + F[t[e + 10]] + F[t[e + 11]] + F[t[e + 12]] + F[t[e + 13]] + F[t[e + 14]] + F[t[e + 15]]).toLowerCase();
|
|
2419
2428
|
}
|
|
2420
2429
|
let kt;
|
|
2421
|
-
const
|
|
2422
|
-
function
|
|
2430
|
+
const Gs = new Uint8Array(16);
|
|
2431
|
+
function Qs() {
|
|
2423
2432
|
if (!kt) {
|
|
2424
2433
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
2425
2434
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
2426
2435
|
kt = crypto.getRandomValues.bind(crypto);
|
|
2427
2436
|
}
|
|
2428
|
-
return kt(
|
|
2437
|
+
return kt(Gs);
|
|
2429
2438
|
}
|
|
2430
|
-
const
|
|
2431
|
-
function
|
|
2439
|
+
const Hs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Gn = { randomUUID: Hs };
|
|
2440
|
+
function Ys(t, e, n) {
|
|
2432
2441
|
var i;
|
|
2433
2442
|
if (Gn.randomUUID && !t)
|
|
2434
2443
|
return Gn.randomUUID();
|
|
2435
2444
|
t = t || {};
|
|
2436
|
-
const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ??
|
|
2445
|
+
const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Qs();
|
|
2437
2446
|
if (r.length < 16)
|
|
2438
2447
|
throw new Error("Random bytes length must be >= 16");
|
|
2439
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
2448
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Bs(r);
|
|
2440
2449
|
}
|
|
2441
2450
|
function Qn(t) {
|
|
2442
2451
|
const e = t.replace(/-/g, ""), n = [];
|
|
@@ -2444,7 +2453,7 @@ function Qn(t) {
|
|
|
2444
2453
|
n.push(parseInt(e.substring(r, r + 2), 16));
|
|
2445
2454
|
return n;
|
|
2446
2455
|
}
|
|
2447
|
-
function
|
|
2456
|
+
function Js(t, e) {
|
|
2448
2457
|
for (let n = 0; n < t.length; n++) {
|
|
2449
2458
|
if (t[n] < e[n])
|
|
2450
2459
|
return -1;
|
|
@@ -2453,17 +2462,17 @@ function Ys(t, e) {
|
|
|
2453
2462
|
}
|
|
2454
2463
|
return 0;
|
|
2455
2464
|
}
|
|
2456
|
-
function
|
|
2457
|
-
return
|
|
2465
|
+
function Zs(t, e) {
|
|
2466
|
+
return Js(Qn(t), Qn(e));
|
|
2458
2467
|
}
|
|
2459
2468
|
function L() {
|
|
2460
|
-
return
|
|
2469
|
+
return Ys();
|
|
2461
2470
|
}
|
|
2462
|
-
function
|
|
2471
|
+
function Xs(t, e) {
|
|
2463
2472
|
return t.localeCompare(e);
|
|
2464
2473
|
}
|
|
2465
|
-
function
|
|
2466
|
-
let t =
|
|
2474
|
+
function eo() {
|
|
2475
|
+
let t = Xs;
|
|
2467
2476
|
if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
|
|
2468
2477
|
try {
|
|
2469
2478
|
t = Intl.Collator("en-US").compare;
|
|
@@ -2471,10 +2480,10 @@ function Xs() {
|
|
|
2471
2480
|
}
|
|
2472
2481
|
return t;
|
|
2473
2482
|
}
|
|
2474
|
-
const
|
|
2475
|
-
let
|
|
2483
|
+
const to = eo();
|
|
2484
|
+
let no = 0;
|
|
2476
2485
|
function Ke(t) {
|
|
2477
|
-
return yt(`_${t}`,
|
|
2486
|
+
return yt(`_${t}`, no++);
|
|
2478
2487
|
}
|
|
2479
2488
|
function yt(t, e) {
|
|
2480
2489
|
return `?${t}-${e}`;
|
|
@@ -2484,24 +2493,24 @@ class Ae extends Error {
|
|
|
2484
2493
|
super(e), this.name = "AttrNotFoundError";
|
|
2485
2494
|
}
|
|
2486
2495
|
}
|
|
2487
|
-
function
|
|
2496
|
+
function ro(t, e) {
|
|
2488
2497
|
const n = Wr(t, e);
|
|
2489
2498
|
if (!n)
|
|
2490
2499
|
throw new Ae(`Could not find id attr for ${e}`);
|
|
2491
2500
|
return n;
|
|
2492
2501
|
}
|
|
2493
2502
|
function Hn(t, e, n, r) {
|
|
2494
|
-
return [
|
|
2503
|
+
return [io(t, e, n, r)];
|
|
2495
2504
|
}
|
|
2496
|
-
function
|
|
2505
|
+
function io(t, e, n, r) {
|
|
2497
2506
|
return [
|
|
2498
2507
|
t(n, r),
|
|
2499
|
-
|
|
2508
|
+
ro(e, n).id,
|
|
2500
2509
|
t(n, r),
|
|
2501
2510
|
t("time", r)
|
|
2502
2511
|
];
|
|
2503
2512
|
}
|
|
2504
|
-
function
|
|
2513
|
+
function so(t, e, n) {
|
|
2505
2514
|
return t.map((r) => r === e ? n : r);
|
|
2506
2515
|
}
|
|
2507
2516
|
function Gr(t, e, n, r, i) {
|
|
@@ -2533,7 +2542,7 @@ function Yn(t, e) {
|
|
|
2533
2542
|
return typeof o != "string" ? !1 : i.test(o);
|
|
2534
2543
|
};
|
|
2535
2544
|
}
|
|
2536
|
-
function
|
|
2545
|
+
function oo(t, e) {
|
|
2537
2546
|
if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
|
|
2538
2547
|
return e;
|
|
2539
2548
|
const n = t["checked-data-type"] === "date";
|
|
@@ -2593,7 +2602,7 @@ function so(t, e) {
|
|
|
2593
2602
|
}
|
|
2594
2603
|
return e;
|
|
2595
2604
|
}
|
|
2596
|
-
function
|
|
2605
|
+
function uo(t, e, n, r, i, s) {
|
|
2597
2606
|
const o = fe(e, n, i), u = Vr(e, n, i), a = o || u;
|
|
2598
2607
|
if (!a)
|
|
2599
2608
|
throw new Ae(`No attr for etype = ${n} label = ${i}`);
|
|
@@ -2611,11 +2620,11 @@ function oo(t, e, n, r, i, s) {
|
|
|
2611
2620
|
return o ? [
|
|
2612
2621
|
t(n, r),
|
|
2613
2622
|
a.id,
|
|
2614
|
-
|
|
2623
|
+
oo(a, s),
|
|
2615
2624
|
Ke("time")
|
|
2616
2625
|
] : [s, a.id, t(n, r), Ke("time")];
|
|
2617
2626
|
}
|
|
2618
|
-
function
|
|
2627
|
+
function ao(t, e, n, r, i) {
|
|
2619
2628
|
const [s, o, u] = i.reduce((a, d) => {
|
|
2620
2629
|
const [c, f, l] = a, [p, y, b] = Gr(t, e, c, f, d);
|
|
2621
2630
|
return [p, y, [...l, b]];
|
|
@@ -2623,19 +2632,19 @@ function uo(t, e, n, r, i) {
|
|
|
2623
2632
|
return [s, o, u];
|
|
2624
2633
|
}
|
|
2625
2634
|
function zt(t, e, n, r, i, s) {
|
|
2626
|
-
const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] =
|
|
2635
|
+
const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = ao(t, e, n, r, o), f = uo(t, e, a, d, u, s);
|
|
2627
2636
|
return c.concat([f]);
|
|
2628
2637
|
}
|
|
2629
|
-
function
|
|
2638
|
+
function co(t, e) {
|
|
2630
2639
|
return e ? [e].concat(t) : t;
|
|
2631
2640
|
}
|
|
2632
|
-
function
|
|
2641
|
+
function fo([t, e]) {
|
|
2633
2642
|
return t === "or" && Array.isArray(e);
|
|
2634
2643
|
}
|
|
2635
|
-
function
|
|
2644
|
+
function lo([t, e]) {
|
|
2636
2645
|
return t === "and" && Array.isArray(e);
|
|
2637
2646
|
}
|
|
2638
|
-
function
|
|
2647
|
+
function ho(t, e, n) {
|
|
2639
2648
|
return (r, i) => {
|
|
2640
2649
|
const s = t(r, i);
|
|
2641
2650
|
return e == s ? s : `${s}-${n}`;
|
|
@@ -2643,25 +2652,25 @@ function lo(t, e, n) {
|
|
|
2643
2652
|
}
|
|
2644
2653
|
function Jn(t, e, n, r, i, s) {
|
|
2645
2654
|
const o = t(r, i), u = s.map((a, d) => {
|
|
2646
|
-
const c =
|
|
2655
|
+
const c = ho(t, o, d);
|
|
2647
2656
|
return Qr(c, n, r, i, a);
|
|
2648
2657
|
});
|
|
2649
2658
|
return { [e]: { patterns: u, joinSym: o } };
|
|
2650
2659
|
}
|
|
2651
|
-
function
|
|
2660
|
+
function po(t) {
|
|
2652
2661
|
const e = [];
|
|
2653
2662
|
for (let n = 1; n <= t.length; n++)
|
|
2654
2663
|
e.push(t.slice(0, n));
|
|
2655
2664
|
return e;
|
|
2656
2665
|
}
|
|
2657
2666
|
function Zn(t, e, n, r, i) {
|
|
2658
|
-
return
|
|
2667
|
+
return po(i).map((s) => zt(t, e, n, r, s, { $isNull: !0 }));
|
|
2659
2668
|
}
|
|
2660
2669
|
function Qr(t, e, n, r, i) {
|
|
2661
2670
|
return Object.entries(i).flatMap(([s, o]) => {
|
|
2662
|
-
if (co([s, o]))
|
|
2663
|
-
return Jn(t, "or", e, n, r, o);
|
|
2664
2671
|
if (fo([s, o]))
|
|
2672
|
+
return Jn(t, "or", e, n, r, o);
|
|
2673
|
+
if (lo([s, o]))
|
|
2665
2674
|
return Jn(t, "and", e, n, r, o);
|
|
2666
2675
|
if (s === "$entityIdStartsWith")
|
|
2667
2676
|
return [];
|
|
@@ -2687,25 +2696,25 @@ function Qr(t, e, n, r, i) {
|
|
|
2687
2696
|
] : zt(t, e, n, r, u, o);
|
|
2688
2697
|
});
|
|
2689
2698
|
}
|
|
2690
|
-
function
|
|
2699
|
+
function yo(t, e, n, r) {
|
|
2691
2700
|
const i = yt;
|
|
2692
2701
|
return r ? Qr(i, t, e, n, r).concat(Hn(i, t, e, n)) : Hn(i, t, e, n);
|
|
2693
2702
|
}
|
|
2694
|
-
function
|
|
2703
|
+
function bo(t, e, n) {
|
|
2695
2704
|
return [t(e, n), t("time", n)];
|
|
2696
2705
|
}
|
|
2697
|
-
function
|
|
2698
|
-
const [o, u, a, d, c] = Gr(t, e, n, r, i), f =
|
|
2706
|
+
function _o(t, e, n, r, i, s) {
|
|
2707
|
+
const [o, u, a, d, c] = Gr(t, e, n, r, i), f = so(a, t(n, r), s);
|
|
2699
2708
|
return [o, u, f, d, c];
|
|
2700
2709
|
}
|
|
2701
|
-
function
|
|
2710
|
+
function go(t, e, { etype: n, level: r, form: i }, s) {
|
|
2702
2711
|
const o = Object.keys(i).filter((u) => u !== "$");
|
|
2703
2712
|
return o.length ? Object.entries(s).map(function([a, d]) {
|
|
2704
2713
|
return o.map(function(l) {
|
|
2705
2714
|
var p, y, b;
|
|
2706
2715
|
const g = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[l]) === null || b === void 0) && b.isSingular));
|
|
2707
2716
|
try {
|
|
2708
|
-
const [m, T, v] =
|
|
2717
|
+
const [m, T, v] = _o(t, e, n, r, l, a), k = Yr(e, {
|
|
2709
2718
|
etype: m,
|
|
2710
2719
|
level: T,
|
|
2711
2720
|
form: i[l],
|
|
@@ -2722,11 +2731,11 @@ function _o(t, e, { etype: n, level: r, form: i }, s) {
|
|
|
2722
2731
|
}, d);
|
|
2723
2732
|
}) : Object.values(s);
|
|
2724
2733
|
}
|
|
2725
|
-
function
|
|
2726
|
-
return n === "string" ?
|
|
2734
|
+
function To(t, e, n) {
|
|
2735
|
+
return n === "string" ? to(t, e) : t > e ? 1 : -1;
|
|
2727
2736
|
}
|
|
2728
2737
|
function Fe(t, e, n, r, i) {
|
|
2729
|
-
return e === r || e == null && r == null ?
|
|
2738
|
+
return e === r || e == null && r == null ? Zs(t, n) : r == null ? 1 : e == null ? -1 : To(e, r, i);
|
|
2730
2739
|
}
|
|
2731
2740
|
function lt([t, e], [n, r], i) {
|
|
2732
2741
|
return Fe(t, e, n, r, i);
|
|
@@ -2734,7 +2743,7 @@ function lt([t, e], [n, r], i) {
|
|
|
2734
2743
|
function Vt(t) {
|
|
2735
2744
|
return t == null ? t : new Date(t).getTime();
|
|
2736
2745
|
}
|
|
2737
|
-
function
|
|
2746
|
+
function mo(t, e, n, r) {
|
|
2738
2747
|
var i;
|
|
2739
2748
|
const [s, o, u, a] = t, d = n === "desc" ? 1 : -1;
|
|
2740
2749
|
if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
|
|
@@ -2742,24 +2751,24 @@ function To(t, e, n, r) {
|
|
|
2742
2751
|
const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? Vt(f) : f, y = l === "date" ? Vt(u) : u;
|
|
2743
2752
|
return lt([c, p], [s, y], l) === d;
|
|
2744
2753
|
}
|
|
2745
|
-
function
|
|
2754
|
+
function wo(t, e) {
|
|
2746
2755
|
const n = e[1];
|
|
2747
2756
|
return t.attrs[n];
|
|
2748
2757
|
}
|
|
2749
|
-
function
|
|
2758
|
+
function vo(t, e, n) {
|
|
2750
2759
|
const r = Object.keys(n)[0];
|
|
2751
2760
|
return fe(t, e, r);
|
|
2752
2761
|
}
|
|
2753
|
-
function
|
|
2762
|
+
function So(t, e, n, r) {
|
|
2754
2763
|
if (n)
|
|
2755
|
-
return
|
|
2764
|
+
return wo(t, n);
|
|
2756
2765
|
if (r)
|
|
2757
|
-
return
|
|
2766
|
+
return vo(t, e, r);
|
|
2758
2767
|
}
|
|
2759
|
-
function
|
|
2768
|
+
function Oo(t, e, n) {
|
|
2760
2769
|
var r, i;
|
|
2761
2770
|
if (!Array.isArray(n.fields))
|
|
2762
|
-
return
|
|
2771
|
+
return Ms(t, e);
|
|
2763
2772
|
const s = /* @__PURE__ */ new Map();
|
|
2764
2773
|
for (const o of n.fields) {
|
|
2765
2774
|
const u = fe(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
|
|
@@ -2771,11 +2780,11 @@ function So(t, e, n) {
|
|
|
2771
2780
|
}
|
|
2772
2781
|
return s;
|
|
2773
2782
|
}
|
|
2774
|
-
function
|
|
2783
|
+
function Eo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
|
|
2775
2784
|
var s, o;
|
|
2776
|
-
const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Hr(i), d =
|
|
2777
|
-
let c =
|
|
2778
|
-
const f = n == null ? void 0 : n["start-cursor"], l =
|
|
2785
|
+
const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Hr(i), d = Ao(i);
|
|
2786
|
+
let c = zs(t, r);
|
|
2787
|
+
const f = n == null ? void 0 : n["start-cursor"], l = So(t, e, f, u);
|
|
2779
2788
|
if (l && ((o = l == null ? void 0 : l["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
|
|
2780
2789
|
const b = l["checked-data-type"] === "date", g = l.id;
|
|
2781
2790
|
c = c.map(([m]) => {
|
|
@@ -2790,17 +2799,17 @@ function Oo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
|
|
|
2790
2799
|
return lt(m, g, l == null ? void 0 : l["checked-data-type"]);
|
|
2791
2800
|
});
|
|
2792
2801
|
let p = {};
|
|
2793
|
-
const y =
|
|
2802
|
+
const y = Oo(t, e, r);
|
|
2794
2803
|
for (const b of c) {
|
|
2795
2804
|
const [g] = b;
|
|
2796
|
-
if (p[g] || !a && f && l &&
|
|
2805
|
+
if (p[g] || !a && f && l && mo(f, l, d, b))
|
|
2797
2806
|
continue;
|
|
2798
|
-
const m =
|
|
2807
|
+
const m = Is(t, y, g);
|
|
2799
2808
|
m && (p[g] = m);
|
|
2800
2809
|
}
|
|
2801
2810
|
return p;
|
|
2802
2811
|
}
|
|
2803
|
-
function
|
|
2812
|
+
function Ao(t) {
|
|
2804
2813
|
var e;
|
|
2805
2814
|
const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
|
|
2806
2815
|
return n && n[Object.keys(n)[0]] || "asc";
|
|
@@ -2810,11 +2819,11 @@ function Hr(t) {
|
|
|
2810
2819
|
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;
|
|
2811
2820
|
return !i && !s && !o;
|
|
2812
2821
|
}
|
|
2813
|
-
function
|
|
2822
|
+
function jo(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
|
|
2814
2823
|
var o, u, a, d, c;
|
|
2815
2824
|
if (!Hr(r) && (!s || !s["start-cursor"]))
|
|
2816
2825
|
return [];
|
|
2817
|
-
const f =
|
|
2826
|
+
const f = co(yo(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = bo(yt, e, n), p = (u = r.$) === null || u === void 0 ? void 0 : u.fields, y = Eo(t, {
|
|
2818
2827
|
etype: e,
|
|
2819
2828
|
pageInfo: s,
|
|
2820
2829
|
form: r,
|
|
@@ -2827,9 +2836,9 @@ function Ao(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
|
|
|
2827
2836
|
}
|
|
2828
2837
|
return y;
|
|
2829
2838
|
}
|
|
2830
|
-
function
|
|
2839
|
+
function ko(t, e) {
|
|
2831
2840
|
try {
|
|
2832
|
-
return
|
|
2841
|
+
return jo(t, e);
|
|
2833
2842
|
} catch (n) {
|
|
2834
2843
|
if (n instanceof Ae)
|
|
2835
2844
|
return {};
|
|
@@ -2837,10 +2846,10 @@ function jo(t, e) {
|
|
|
2837
2846
|
}
|
|
2838
2847
|
}
|
|
2839
2848
|
function Yr(t, e) {
|
|
2840
|
-
const n =
|
|
2841
|
-
return
|
|
2849
|
+
const n = ko(t, e);
|
|
2850
|
+
return go(yt, t, e, n);
|
|
2842
2851
|
}
|
|
2843
|
-
function
|
|
2852
|
+
function Co(t) {
|
|
2844
2853
|
const e = {};
|
|
2845
2854
|
for (const [n, r] of Object.entries(t))
|
|
2846
2855
|
e[n] = {
|
|
@@ -2860,9 +2869,9 @@ function Jr({ store: t, pageInfo: e, aggregate: n }, r) {
|
|
|
2860
2869
|
pageInfo: e == null ? void 0 : e[a]
|
|
2861
2870
|
})), u;
|
|
2862
2871
|
}, {}) };
|
|
2863
|
-
return e && (s.pageInfo =
|
|
2872
|
+
return e && (s.pageInfo = Co(e)), n && (s.aggregate = n), s;
|
|
2864
2873
|
}
|
|
2865
|
-
function
|
|
2874
|
+
function Po() {
|
|
2866
2875
|
const e = {
|
|
2867
2876
|
__etype: 1,
|
|
2868
2877
|
__ops: 1,
|
|
@@ -2876,7 +2885,7 @@ function Co() {
|
|
|
2876
2885
|
};
|
|
2877
2886
|
return new Set(Object.keys(e));
|
|
2878
2887
|
}
|
|
2879
|
-
const
|
|
2888
|
+
const Io = Po();
|
|
2880
2889
|
function Wt(t, e, n) {
|
|
2881
2890
|
const r = {
|
|
2882
2891
|
__etype: t,
|
|
@@ -2888,7 +2897,7 @@ function Wt(t, e, n) {
|
|
|
2888
2897
|
return n;
|
|
2889
2898
|
if (s === "__etype")
|
|
2890
2899
|
return t;
|
|
2891
|
-
if (
|
|
2900
|
+
if (Io.has(s))
|
|
2892
2901
|
return (o, u) => Wt(t, e, [
|
|
2893
2902
|
...n,
|
|
2894
2903
|
u ? [s, t, e, o, u] : [s, t, e, o]
|
|
@@ -2903,7 +2912,7 @@ function Zr(t) {
|
|
|
2903
2912
|
const [e, n, ...r] = t.split("__");
|
|
2904
2913
|
return [n, JSON.parse(r.join("__"))];
|
|
2905
2914
|
}
|
|
2906
|
-
function
|
|
2915
|
+
function Mo(t) {
|
|
2907
2916
|
return new Proxy({
|
|
2908
2917
|
__etype: t
|
|
2909
2918
|
}, {
|
|
@@ -2918,15 +2927,15 @@ function Io(t) {
|
|
|
2918
2927
|
function ln() {
|
|
2919
2928
|
return new Proxy({}, {
|
|
2920
2929
|
get(t, e) {
|
|
2921
|
-
return
|
|
2930
|
+
return Mo(e);
|
|
2922
2931
|
}
|
|
2923
2932
|
});
|
|
2924
2933
|
}
|
|
2925
2934
|
ln();
|
|
2926
|
-
function
|
|
2935
|
+
function Ro(t) {
|
|
2927
2936
|
return t.__ops;
|
|
2928
2937
|
}
|
|
2929
|
-
function
|
|
2938
|
+
function $o(t, e) {
|
|
2930
2939
|
const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
|
|
2931
2940
|
for (const o of e) {
|
|
2932
2941
|
const u = n[o];
|
|
@@ -2960,7 +2969,7 @@ function _e(t, e, n) {
|
|
|
2960
2969
|
return o === e && u === n;
|
|
2961
2970
|
});
|
|
2962
2971
|
}
|
|
2963
|
-
function
|
|
2972
|
+
function xo(t) {
|
|
2964
2973
|
if (Array.isArray(t))
|
|
2965
2974
|
return t;
|
|
2966
2975
|
const e = Object.entries(t);
|
|
@@ -2979,7 +2988,7 @@ function Gt(t) {
|
|
|
2979
2988
|
throw new Error(`${t} is not a valid lookup attribute.`);
|
|
2980
2989
|
return e;
|
|
2981
2990
|
}
|
|
2982
|
-
function
|
|
2991
|
+
function Do(t, e, n) {
|
|
2983
2992
|
if (!Bt(t, e, n))
|
|
2984
2993
|
return K(t, e, n);
|
|
2985
2994
|
const r = Gt(n), i = K(t, e, r) || _e(t, e, r);
|
|
@@ -2988,13 +2997,13 @@ function xo(t, e, n) {
|
|
|
2988
2997
|
return i;
|
|
2989
2998
|
}
|
|
2990
2999
|
function Qt(t) {
|
|
2991
|
-
return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Zr(t) :
|
|
3000
|
+
return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Zr(t) : xo(t);
|
|
2992
3001
|
}
|
|
2993
3002
|
function Q(t, e, n) {
|
|
2994
3003
|
const r = Qt(n);
|
|
2995
3004
|
if (r === null)
|
|
2996
3005
|
return n;
|
|
2997
|
-
const [i, s] = r, o =
|
|
3006
|
+
const [i, s] = r, o = Do(t, e, i);
|
|
2998
3007
|
if (!o || !o["unique?"])
|
|
2999
3008
|
throw new Error(`${i} is not a unique attribute.`);
|
|
3000
3009
|
return [o.id, s];
|
|
@@ -3008,7 +3017,7 @@ function Xr(t, e, n, r) {
|
|
|
3008
3017
|
i
|
|
3009
3018
|
]].concat(r) : r;
|
|
3010
3019
|
}
|
|
3011
|
-
function
|
|
3020
|
+
function Uo({ attrs: t }, [e, n, r]) {
|
|
3012
3021
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
3013
3022
|
const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = _e(t, e, s);
|
|
3014
3023
|
return u.map((c) => a ? [
|
|
@@ -3025,7 +3034,7 @@ function Do({ attrs: t }, [e, n, r]) {
|
|
|
3025
3034
|
});
|
|
3026
3035
|
return Xr(t, e, n, i);
|
|
3027
3036
|
}
|
|
3028
|
-
function
|
|
3037
|
+
function Lo({ attrs: t }, [e, n, r]) {
|
|
3029
3038
|
const i = Object.entries(r).flatMap(([s, o]) => {
|
|
3030
3039
|
const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = _e(t, e, s);
|
|
3031
3040
|
return u.map((c) => a ? [
|
|
@@ -3042,7 +3051,7 @@ function Uo({ attrs: t }, [e, n, r]) {
|
|
|
3042
3051
|
});
|
|
3043
3052
|
return Xr(t, e, n, i);
|
|
3044
3053
|
}
|
|
3045
|
-
function
|
|
3054
|
+
function Fo(t, e, n) {
|
|
3046
3055
|
if (Array.isArray(n)) {
|
|
3047
3056
|
const [r, i] = n;
|
|
3048
3057
|
for (const s of t || []) {
|
|
@@ -3065,16 +3074,16 @@ function Lo(t, e, n) {
|
|
|
3065
3074
|
return !1;
|
|
3066
3075
|
}
|
|
3067
3076
|
function ei({ stores: t, attrs: e }, [n, r, i, s]) {
|
|
3068
|
-
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null :
|
|
3077
|
+
return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Fo(t, n, r) ? { mode: "update" } : null;
|
|
3069
3078
|
}
|
|
3070
|
-
function
|
|
3079
|
+
function No(t, e) {
|
|
3071
3080
|
const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = un(o), d = Q(r, i, s);
|
|
3072
3081
|
return [["id", d]].concat(Object.entries(a)).map(([f, l]) => {
|
|
3073
3082
|
const p = K(r, i, f);
|
|
3074
3083
|
return p["checked-data-type"] === "date" && t.useDateObjects && (l = pt(l)), ["add-triple", d, p.id, l, { mode: "create" }];
|
|
3075
3084
|
});
|
|
3076
3085
|
}
|
|
3077
|
-
function
|
|
3086
|
+
function Ko(t, e) {
|
|
3078
3087
|
const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = un(o), d = Q(r, i, s), c = ei(t, [i, d, o, u]);
|
|
3079
3088
|
return [["id", d]].concat(Object.entries(a)).map(([l, p]) => {
|
|
3080
3089
|
const y = K(r, i, l);
|
|
@@ -3087,10 +3096,10 @@ function No(t, e) {
|
|
|
3087
3096
|
];
|
|
3088
3097
|
});
|
|
3089
3098
|
}
|
|
3090
|
-
function
|
|
3099
|
+
function qo({ attrs: t }, [e, n]) {
|
|
3091
3100
|
return [["delete-entity", Q(t, e, n), e]];
|
|
3092
3101
|
}
|
|
3093
|
-
function
|
|
3102
|
+
function zo(t, e) {
|
|
3094
3103
|
const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = un(o), d = Q(r, i, s), c = ei(t, [i, d, o, u]), f = Object.entries(a).map(([p, y]) => {
|
|
3095
3104
|
const b = K(r, i, p);
|
|
3096
3105
|
return [
|
|
@@ -3109,38 +3118,38 @@ function qo(t, e) {
|
|
|
3109
3118
|
...c ? [c] : []
|
|
3110
3119
|
]].concat(f);
|
|
3111
3120
|
}
|
|
3112
|
-
function
|
|
3121
|
+
function Vo({ attrs: t }, [e, n, r]) {
|
|
3113
3122
|
return [["rule-params", Q(t, e, n), e, r]];
|
|
3114
3123
|
}
|
|
3115
|
-
function
|
|
3124
|
+
function Wo(t) {
|
|
3116
3125
|
const [e, n, r, i, s] = t;
|
|
3117
3126
|
if (!i)
|
|
3118
3127
|
return t;
|
|
3119
3128
|
const o = Object.assign({}, i);
|
|
3120
3129
|
return delete o.id, [e, n, r, o, ...s ? [s] : []];
|
|
3121
3130
|
}
|
|
3122
|
-
function
|
|
3123
|
-
const [n, ...r] =
|
|
3131
|
+
function Bo(t, e) {
|
|
3132
|
+
const [n, ...r] = Wo(e);
|
|
3124
3133
|
switch (n) {
|
|
3125
3134
|
case "merge":
|
|
3126
|
-
return
|
|
3135
|
+
return zo(t, r);
|
|
3127
3136
|
case "create":
|
|
3128
|
-
return Fo(t, r);
|
|
3129
|
-
case "update":
|
|
3130
3137
|
return No(t, r);
|
|
3138
|
+
case "update":
|
|
3139
|
+
return Ko(t, r);
|
|
3131
3140
|
case "link":
|
|
3132
|
-
return Do(t, r);
|
|
3133
|
-
case "unlink":
|
|
3134
3141
|
return Uo(t, r);
|
|
3142
|
+
case "unlink":
|
|
3143
|
+
return Lo(t, r);
|
|
3135
3144
|
case "delete":
|
|
3136
|
-
return
|
|
3145
|
+
return qo(t, r);
|
|
3137
3146
|
case "ruleParams":
|
|
3138
|
-
return
|
|
3147
|
+
return Vo(t, r);
|
|
3139
3148
|
default:
|
|
3140
3149
|
throw new Error(`unsupported action ${n}`);
|
|
3141
3150
|
}
|
|
3142
3151
|
}
|
|
3143
|
-
function
|
|
3152
|
+
function Go(t) {
|
|
3144
3153
|
switch (t) {
|
|
3145
3154
|
case "string":
|
|
3146
3155
|
case "date":
|
|
@@ -3151,14 +3160,14 @@ function Bo(t) {
|
|
|
3151
3160
|
return;
|
|
3152
3161
|
}
|
|
3153
3162
|
}
|
|
3154
|
-
function
|
|
3163
|
+
function Qo(t, e, n) {
|
|
3155
3164
|
var r, i;
|
|
3156
3165
|
const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
|
|
3157
3166
|
if (n === "id")
|
|
3158
3167
|
return null;
|
|
3159
3168
|
if (!s)
|
|
3160
3169
|
throw new Error(`${e}.${n} does not exist in your schema`);
|
|
3161
|
-
const { unique: o, indexed: u } = s == null ? void 0 : s.config, a =
|
|
3170
|
+
const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Go(s == null ? void 0 : s.valueType);
|
|
3162
3171
|
return {
|
|
3163
3172
|
"index?": u,
|
|
3164
3173
|
"unique?": o,
|
|
@@ -3166,14 +3175,14 @@ function Go(t, e, n) {
|
|
|
3166
3175
|
};
|
|
3167
3176
|
}
|
|
3168
3177
|
function nt(t, e, n, r) {
|
|
3169
|
-
const i = t ?
|
|
3178
|
+
const i = t ? Qo(t, e, n) : null, s = L(), u = [L(), e, n];
|
|
3170
3179
|
return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
|
|
3171
3180
|
}
|
|
3172
|
-
function
|
|
3181
|
+
function Ho(t, e, n) {
|
|
3173
3182
|
return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
|
|
3174
3183
|
}
|
|
3175
|
-
function
|
|
3176
|
-
const r =
|
|
3184
|
+
function Yo(t, e, n) {
|
|
3185
|
+
const r = Ho(t, e, n);
|
|
3177
3186
|
if (!r)
|
|
3178
3187
|
throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
|
|
3179
3188
|
const { forward: i, reverse: s } = r;
|
|
@@ -3187,10 +3196,10 @@ function Ho(t, e, n) {
|
|
|
3187
3196
|
};
|
|
3188
3197
|
}
|
|
3189
3198
|
function Xn(t, e, n, r) {
|
|
3190
|
-
const i = t ?
|
|
3199
|
+
const i = t ? Yo(t, e, n) : null, s = L(), o = [L(), e, n], u = [L(), n, e];
|
|
3191
3200
|
return Object.assign(Object.assign({ id: s, "forward-identity": o, "reverse-identity": u, "value-type": "ref", cardinality: "many", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
|
|
3192
3201
|
}
|
|
3193
|
-
const
|
|
3202
|
+
const Jo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Zo = /* @__PURE__ */ new Set(["link", "unlink"]), Xo = /* @__PURE__ */ new Set(["create", "update", "merge"]), eu = /* @__PURE__ */ new Set([
|
|
3194
3203
|
"link",
|
|
3195
3204
|
"unlink",
|
|
3196
3205
|
"create",
|
|
@@ -3198,10 +3207,10 @@ const Yo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
|
|
|
3198
3207
|
"merge",
|
|
3199
3208
|
"delete",
|
|
3200
3209
|
"ruleParams"
|
|
3201
|
-
]), Ht = { "unique?": !0, "index?": !0 },
|
|
3202
|
-
function
|
|
3210
|
+
]), Ht = { "unique?": !0, "index?": !0 }, tu = Object.assign(Object.assign({}, Ht), { cardinality: "one" });
|
|
3211
|
+
function nu(t) {
|
|
3203
3212
|
const e = [], [n, r, i, s] = t;
|
|
3204
|
-
if (!
|
|
3213
|
+
if (!eu.has(n))
|
|
3205
3214
|
return e;
|
|
3206
3215
|
const o = Qt(i);
|
|
3207
3216
|
if (o && e.push({ etype: r, lookupPair: o }), n === "link")
|
|
@@ -3218,7 +3227,7 @@ function tu(t) {
|
|
|
3218
3227
|
}
|
|
3219
3228
|
return e;
|
|
3220
3229
|
}
|
|
3221
|
-
function
|
|
3230
|
+
function ru({ attrs: t, schema: e }, n) {
|
|
3222
3231
|
var r, i;
|
|
3223
3232
|
const [s, o, u] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
|
|
3224
3233
|
function a(f) {
|
|
@@ -3229,10 +3238,10 @@ function nu({ attrs: t, schema: e }, n) {
|
|
|
3229
3238
|
}
|
|
3230
3239
|
function c(f, l) {
|
|
3231
3240
|
const p = K(o, f, l), y = _e(o, f, l);
|
|
3232
|
-
d(p), d(y), !p && !y && a(Xn(e, f, l,
|
|
3241
|
+
d(p), d(y), !p && !y && a(Xn(e, f, l, tu));
|
|
3233
3242
|
}
|
|
3234
3243
|
for (const f of n)
|
|
3235
|
-
for (const { etype: l, lookupPair: p, linkLabel: y } of
|
|
3244
|
+
for (const { etype: l, lookupPair: p, linkLabel: y } of nu(f)) {
|
|
3236
3245
|
const b = p[0];
|
|
3237
3246
|
if (y) {
|
|
3238
3247
|
c(l, y);
|
|
@@ -3254,12 +3263,12 @@ function nu({ attrs: t, schema: e }, n) {
|
|
|
3254
3263
|
}
|
|
3255
3264
|
for (const f of n) {
|
|
3256
3265
|
const [l, p, y, b] = f;
|
|
3257
|
-
if (
|
|
3266
|
+
if (Jo.has(l)) {
|
|
3258
3267
|
const g = K(o, p, "id");
|
|
3259
3268
|
d(g), g || a(nt(e, p, "id", { "unique?": !0 }));
|
|
3260
3269
|
for (const m of Object.keys(b)) {
|
|
3261
3270
|
const T = K(o, p, m);
|
|
3262
|
-
if (d(T),
|
|
3271
|
+
if (d(T), Xo.has(l) && (T || a(nt(e, p, m, m === "id" ? { "unique?": !0 } : null))), Zo.has(l)) {
|
|
3263
3272
|
const v = _e(o, p, m);
|
|
3264
3273
|
!T && !v && a(Xn(e, p, m)), d(v);
|
|
3265
3274
|
}
|
|
@@ -3268,8 +3277,8 @@ function nu({ attrs: t, schema: e }, n) {
|
|
|
3268
3277
|
}
|
|
3269
3278
|
return [o, u];
|
|
3270
3279
|
}
|
|
3271
|
-
function
|
|
3272
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((a) =>
|
|
3280
|
+
function iu(t, e) {
|
|
3281
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Ro(a)), [i, s] = ru(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), u = r.flatMap((a) => Bo(o, a));
|
|
3273
3282
|
return [...s, ...u];
|
|
3274
3283
|
}
|
|
3275
3284
|
var re = function(t, e, n, r) {
|
|
@@ -3303,7 +3312,7 @@ function er(t, e) {
|
|
|
3303
3312
|
typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
|
|
3304
3313
|
}
|
|
3305
3314
|
const qe = "__meta";
|
|
3306
|
-
class
|
|
3315
|
+
class su {
|
|
3307
3316
|
constructor(e, n) {
|
|
3308
3317
|
}
|
|
3309
3318
|
}
|
|
@@ -3578,13 +3587,13 @@ var oe = function(t, e, n, r) {
|
|
|
3578
3587
|
d((r = r.apply(t, e || [])).next());
|
|
3579
3588
|
});
|
|
3580
3589
|
};
|
|
3581
|
-
const
|
|
3582
|
-
function
|
|
3590
|
+
const ou = 6, uu = ["kv", "querySubs", "syncSubs"];
|
|
3591
|
+
function au(t) {
|
|
3583
3592
|
return function(n) {
|
|
3584
3593
|
console.error("Error in IndexedDB event", { source: t, event: n });
|
|
3585
3594
|
};
|
|
3586
3595
|
}
|
|
3587
|
-
function
|
|
3596
|
+
function cu(t) {
|
|
3588
3597
|
return oe(this, void 0, void 0, function* () {
|
|
3589
3598
|
return new Promise((e) => {
|
|
3590
3599
|
const n = indexedDB.open(t);
|
|
@@ -3600,7 +3609,7 @@ function au(t) {
|
|
|
3600
3609
|
});
|
|
3601
3610
|
});
|
|
3602
3611
|
}
|
|
3603
|
-
function
|
|
3612
|
+
function du(t, e, n) {
|
|
3604
3613
|
return oe(this, void 0, void 0, function* () {
|
|
3605
3614
|
const r = (
|
|
3606
3615
|
// Backwards compatibility for older versions where we JSON.stringified before storing
|
|
@@ -3644,9 +3653,9 @@ function tr(t, e, n) {
|
|
|
3644
3653
|
});
|
|
3645
3654
|
});
|
|
3646
3655
|
}
|
|
3647
|
-
function
|
|
3656
|
+
function fu(t, e) {
|
|
3648
3657
|
return oe(this, void 0, void 0, function* () {
|
|
3649
|
-
const n = yield
|
|
3658
|
+
const n = yield cu(`instant_${t}_5`);
|
|
3650
3659
|
if (!n)
|
|
3651
3660
|
return;
|
|
3652
3661
|
const r = yield new Promise((c, f) => {
|
|
@@ -3669,7 +3678,7 @@ function du(t, e) {
|
|
|
3669
3678
|
for (const [c, f] of r)
|
|
3670
3679
|
switch (c) {
|
|
3671
3680
|
case "querySubs": {
|
|
3672
|
-
const l =
|
|
3681
|
+
const l = du(c, f, o);
|
|
3673
3682
|
u.push(l);
|
|
3674
3683
|
break;
|
|
3675
3684
|
}
|
|
@@ -3692,9 +3701,9 @@ function du(t, e) {
|
|
|
3692
3701
|
});
|
|
3693
3702
|
}
|
|
3694
3703
|
const nr = /* @__PURE__ */ new Map();
|
|
3695
|
-
class ti extends
|
|
3704
|
+
class ti extends su {
|
|
3696
3705
|
constructor(e, n) {
|
|
3697
|
-
super(e, n), this.dbName = `instant_${e}_${
|
|
3706
|
+
super(e, n), this.dbName = `instant_${e}_${ou}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
|
|
3698
3707
|
}
|
|
3699
3708
|
_init() {
|
|
3700
3709
|
return new Promise((e, n) => {
|
|
@@ -3705,8 +3714,8 @@ class ti extends iu {
|
|
|
3705
3714
|
}, i.onsuccess = (s) => {
|
|
3706
3715
|
const u = s.target.result;
|
|
3707
3716
|
if (r) {
|
|
3708
|
-
const a =
|
|
3709
|
-
|
|
3717
|
+
const a = fu(this._appId, u).catch((d) => {
|
|
3718
|
+
au("Error upgrading store from version 5 to 6.")(d);
|
|
3710
3719
|
});
|
|
3711
3720
|
nr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
|
|
3712
3721
|
} else {
|
|
@@ -3720,7 +3729,7 @@ class ti extends iu {
|
|
|
3720
3729
|
}
|
|
3721
3730
|
_upgradeStore(e) {
|
|
3722
3731
|
const r = e.target.result;
|
|
3723
|
-
for (const i of
|
|
3732
|
+
for (const i of uu)
|
|
3724
3733
|
r.objectStoreNames.contains(i) || r.createObjectStore(i);
|
|
3725
3734
|
}
|
|
3726
3735
|
getItem(e) {
|
|
@@ -3795,7 +3804,7 @@ class ti extends iu {
|
|
|
3795
3804
|
});
|
|
3796
3805
|
}
|
|
3797
3806
|
}
|
|
3798
|
-
var
|
|
3807
|
+
var lu = function(t, e, n, r) {
|
|
3799
3808
|
function i(s) {
|
|
3800
3809
|
return s instanceof n ? s : new n(function(o) {
|
|
3801
3810
|
o(s);
|
|
@@ -3824,7 +3833,7 @@ var fu = function(t, e, n, r) {
|
|
|
3824
3833
|
};
|
|
3825
3834
|
class ni {
|
|
3826
3835
|
static getIsOnline() {
|
|
3827
|
-
return
|
|
3836
|
+
return lu(this, void 0, void 0, function* () {
|
|
3828
3837
|
return navigator.onLine;
|
|
3829
3838
|
});
|
|
3830
3839
|
}
|
|
@@ -3849,7 +3858,7 @@ class je extends Error {
|
|
|
3849
3858
|
return "InstantError";
|
|
3850
3859
|
}
|
|
3851
3860
|
}
|
|
3852
|
-
var
|
|
3861
|
+
var hu = function(t, e, n, r) {
|
|
3853
3862
|
function i(s) {
|
|
3854
3863
|
return s instanceof n ? s : new n(function(o) {
|
|
3855
3864
|
o(s);
|
|
@@ -3889,7 +3898,7 @@ class bt extends je {
|
|
|
3889
3898
|
}
|
|
3890
3899
|
}
|
|
3891
3900
|
function te(t, e) {
|
|
3892
|
-
return
|
|
3901
|
+
return hu(this, void 0, void 0, function* () {
|
|
3893
3902
|
const n = yield fetch(t, e), r = yield n.json();
|
|
3894
3903
|
return n.status === 200 ? Promise.resolve(r) : Promise.reject(new bt({ status: n.status, body: r }));
|
|
3895
3904
|
});
|
|
@@ -3921,14 +3930,14 @@ var Pe = function(t, e, n, r) {
|
|
|
3921
3930
|
d((r = r.apply(t, e || [])).next());
|
|
3922
3931
|
});
|
|
3923
3932
|
};
|
|
3924
|
-
function
|
|
3933
|
+
function pu({ apiURI: t, appId: e, email: n }) {
|
|
3925
3934
|
return te(`${t}/runtime/auth/send_magic_code`, {
|
|
3926
3935
|
method: "POST",
|
|
3927
3936
|
headers: { "content-type": "application/json" },
|
|
3928
3937
|
body: JSON.stringify({ "app-id": e, email: n })
|
|
3929
3938
|
});
|
|
3930
3939
|
}
|
|
3931
|
-
function
|
|
3940
|
+
function yu(t) {
|
|
3932
3941
|
return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
|
|
3933
3942
|
return yield te(`${e}/runtime/auth/verify_magic_code`, {
|
|
3934
3943
|
method: "POST",
|
|
@@ -3941,7 +3950,7 @@ function pu(t) {
|
|
|
3941
3950
|
});
|
|
3942
3951
|
});
|
|
3943
3952
|
}
|
|
3944
|
-
function
|
|
3953
|
+
function bu(t) {
|
|
3945
3954
|
return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
|
|
3946
3955
|
return yield te(`${e}/runtime/auth/verify_refresh_token`, {
|
|
3947
3956
|
method: "POST",
|
|
@@ -3953,7 +3962,7 @@ function yu(t) {
|
|
|
3953
3962
|
});
|
|
3954
3963
|
});
|
|
3955
3964
|
}
|
|
3956
|
-
function
|
|
3965
|
+
function _u(t) {
|
|
3957
3966
|
return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
|
|
3958
3967
|
return yield te(`${e}/runtime/auth/sign_in_guest`, {
|
|
3959
3968
|
method: "POST",
|
|
@@ -3978,7 +3987,7 @@ function rr(t) {
|
|
|
3978
3987
|
});
|
|
3979
3988
|
});
|
|
3980
3989
|
}
|
|
3981
|
-
function
|
|
3990
|
+
function gu(t) {
|
|
3982
3991
|
return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
|
|
3983
3992
|
return yield te(`${e}/runtime/oauth/id_token`, {
|
|
3984
3993
|
method: "POST",
|
|
@@ -3993,7 +4002,7 @@ function _u(t) {
|
|
|
3993
4002
|
});
|
|
3994
4003
|
});
|
|
3995
4004
|
}
|
|
3996
|
-
function
|
|
4005
|
+
function Tu(t) {
|
|
3997
4006
|
return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
|
|
3998
4007
|
return yield te(`${e}/runtime/signout`, {
|
|
3999
4008
|
method: "POST",
|
|
@@ -4034,7 +4043,7 @@ var Ge = function(t, e, n, r) {
|
|
|
4034
4043
|
d((r = r.apply(t, e || [])).next());
|
|
4035
4044
|
});
|
|
4036
4045
|
};
|
|
4037
|
-
function
|
|
4046
|
+
function mu(t) {
|
|
4038
4047
|
return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
|
|
4039
4048
|
const a = {
|
|
4040
4049
|
app_id: n,
|
|
@@ -4049,7 +4058,7 @@ function Tu(t) {
|
|
|
4049
4058
|
});
|
|
4050
4059
|
});
|
|
4051
4060
|
}
|
|
4052
|
-
function
|
|
4061
|
+
function wu(t) {
|
|
4053
4062
|
return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
|
|
4054
4063
|
const { data: s } = yield te(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
|
|
4055
4064
|
method: "DELETE",
|
|
@@ -4061,7 +4070,7 @@ function mu(t) {
|
|
|
4061
4070
|
return s;
|
|
4062
4071
|
});
|
|
4063
4072
|
}
|
|
4064
|
-
function
|
|
4073
|
+
function vu(t) {
|
|
4065
4074
|
return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
|
|
4066
4075
|
const { data: o } = yield te(`${e}/storage/signed-upload-url`, {
|
|
4067
4076
|
method: "POST",
|
|
@@ -4077,7 +4086,7 @@ function wu(t) {
|
|
|
4077
4086
|
return o;
|
|
4078
4087
|
});
|
|
4079
4088
|
}
|
|
4080
|
-
function
|
|
4089
|
+
function Su(t, e) {
|
|
4081
4090
|
return Ge(this, void 0, void 0, function* () {
|
|
4082
4091
|
return (yield fetch(t, {
|
|
4083
4092
|
method: "PUT",
|
|
@@ -4088,7 +4097,7 @@ function vu(t, e) {
|
|
|
4088
4097
|
})).ok;
|
|
4089
4098
|
});
|
|
4090
4099
|
}
|
|
4091
|
-
function
|
|
4100
|
+
function Ou(t) {
|
|
4092
4101
|
return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
|
|
4093
4102
|
const { data: s } = yield te(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
|
|
4094
4103
|
method: "GET",
|
|
@@ -4110,7 +4119,7 @@ function ir(t, e) {
|
|
|
4110
4119
|
n[r] = t[r];
|
|
4111
4120
|
}), n;
|
|
4112
4121
|
}
|
|
4113
|
-
function
|
|
4122
|
+
function Eu(t, e, n) {
|
|
4114
4123
|
var r, i;
|
|
4115
4124
|
const s = {
|
|
4116
4125
|
peers: {}
|
|
@@ -4128,7 +4137,7 @@ function Ou(t, e, n) {
|
|
|
4128
4137
|
}
|
|
4129
4138
|
return s;
|
|
4130
4139
|
}
|
|
4131
|
-
function
|
|
4140
|
+
function Au(t, e) {
|
|
4132
4141
|
if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !zn(t.user, e.user)) || !Mr(t.peers, e.peers))
|
|
4133
4142
|
return !0;
|
|
4134
4143
|
for (const r of Object.keys(t.peers))
|
|
@@ -4176,8 +4185,8 @@ function ur(t) {
|
|
|
4176
4185
|
}, e;
|
|
4177
4186
|
}, {});
|
|
4178
4187
|
}
|
|
4179
|
-
const oi = "v0.22.
|
|
4180
|
-
function
|
|
4188
|
+
const oi = "v0.22.77";
|
|
4189
|
+
function ju(t, e) {
|
|
4181
4190
|
return {
|
|
4182
4191
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
4183
4192
|
},
|
|
@@ -4226,7 +4235,7 @@ const ar = [
|
|
|
4226
4235
|
"before",
|
|
4227
4236
|
"fields",
|
|
4228
4237
|
"aggregate"
|
|
4229
|
-
],
|
|
4238
|
+
], ku = (t) => t.valueType || "unknown", ui = (t, e, n = !1) => {
|
|
4230
4239
|
if (n || t == null)
|
|
4231
4240
|
return !0;
|
|
4232
4241
|
switch (e) {
|
|
@@ -4241,7 +4250,7 @@ const ar = [
|
|
|
4241
4250
|
default:
|
|
4242
4251
|
return !0;
|
|
4243
4252
|
}
|
|
4244
|
-
},
|
|
4253
|
+
}, Cu = (t, e, n, r, i, s, o) => {
|
|
4245
4254
|
const u = s.valueType === "json", a = (d, c, f) => {
|
|
4246
4255
|
if (!ui(f, c, u))
|
|
4247
4256
|
throw new M(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
|
|
@@ -4274,16 +4283,16 @@ const ar = [
|
|
|
4274
4283
|
throw new M(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
|
|
4275
4284
|
}
|
|
4276
4285
|
}, Oe = (t, e, n, r, i) => {
|
|
4277
|
-
const s =
|
|
4286
|
+
const s = ku(n), o = n.valueType === "json";
|
|
4278
4287
|
if (typeof t == "object" && t !== null && !Array.isArray(t)) {
|
|
4279
4288
|
if (o)
|
|
4280
4289
|
return;
|
|
4281
4290
|
const a = t;
|
|
4282
4291
|
for (const [d, c] of Object.entries(a))
|
|
4283
|
-
|
|
4292
|
+
Cu(d, c, s, e, r, n, `${i}.${d}`);
|
|
4284
4293
|
} else if (!ui(t, s, o))
|
|
4285
4294
|
throw new M(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
|
|
4286
|
-
},
|
|
4295
|
+
}, Pu = (t, e, n, r, i) => {
|
|
4287
4296
|
const s = t.split(".");
|
|
4288
4297
|
if (s.length < 2)
|
|
4289
4298
|
throw new M(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
|
|
@@ -4333,7 +4342,7 @@ const ar = [
|
|
|
4333
4342
|
continue;
|
|
4334
4343
|
}
|
|
4335
4344
|
if (i.includes(".")) {
|
|
4336
|
-
|
|
4345
|
+
Pu(i, s, e, n, `${r}.${i}`);
|
|
4337
4346
|
continue;
|
|
4338
4347
|
}
|
|
4339
4348
|
const o = n.entities[e];
|
|
@@ -4353,7 +4362,7 @@ const ar = [
|
|
|
4353
4362
|
Oe(s, i, d, e, `${r}.${i}`);
|
|
4354
4363
|
}
|
|
4355
4364
|
}
|
|
4356
|
-
},
|
|
4365
|
+
}, Iu = (t, e, n, r, i = 0) => {
|
|
4357
4366
|
for (const o of Object.keys(t))
|
|
4358
4367
|
if (!ar.includes(o))
|
|
4359
4368
|
throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${ar.join(", ")}. Found: ${o}`, r);
|
|
@@ -4392,7 +4401,7 @@ const ar = [
|
|
|
4392
4401
|
const u = t[o];
|
|
4393
4402
|
if (typeof u != "object" || u === null)
|
|
4394
4403
|
throw new M(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
|
|
4395
|
-
|
|
4404
|
+
Iu(u, e, n, `${r}.$`, i);
|
|
4396
4405
|
}
|
|
4397
4406
|
}, cr = (t, e) => {
|
|
4398
4407
|
if (typeof t != "object" || t === null)
|
|
@@ -4419,19 +4428,19 @@ class Z extends Error {
|
|
|
4419
4428
|
super(e), this.name = "TransactionValidationError";
|
|
4420
4429
|
}
|
|
4421
4430
|
}
|
|
4422
|
-
const di = (t) => t.length > 0 ? t.join(", ") : "none",
|
|
4431
|
+
const di = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${di(e)}`), fr = {
|
|
4423
4432
|
string: (t) => typeof t == "string",
|
|
4424
4433
|
number: (t) => typeof t == "number" && !isNaN(t),
|
|
4425
4434
|
boolean: (t) => typeof t == "boolean",
|
|
4426
4435
|
date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
|
|
4427
4436
|
json: () => !0
|
|
4428
|
-
},
|
|
4437
|
+
}, Ru = (t, e) => {
|
|
4429
4438
|
var n, r;
|
|
4430
4439
|
return t == null ? !0 : (r = (n = fr[e.valueType]) === null || n === void 0 ? void 0 : n.call(fr, t)) !== null && r !== void 0 ? r : !1;
|
|
4431
4440
|
}, fi = (t, e) => {
|
|
4432
4441
|
const n = e.entities[t];
|
|
4433
4442
|
if (!n)
|
|
4434
|
-
throw
|
|
4443
|
+
throw Mu(t, Object.keys(e.entities));
|
|
4435
4444
|
return n;
|
|
4436
4445
|
}, Ct = (t, e, n) => {
|
|
4437
4446
|
const r = fi(t, n);
|
|
@@ -4441,7 +4450,7 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
|
|
|
4441
4450
|
if (i === "id")
|
|
4442
4451
|
continue;
|
|
4443
4452
|
const o = r.attrs[i];
|
|
4444
|
-
if (o && !
|
|
4453
|
+
if (o && !Ru(s, o))
|
|
4445
4454
|
throw new Z(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
|
|
4446
4455
|
}
|
|
4447
4456
|
}, lr = (t, e, n) => {
|
|
@@ -4462,7 +4471,7 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
|
|
|
4462
4471
|
throw new Z(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
|
|
4463
4472
|
}
|
|
4464
4473
|
}
|
|
4465
|
-
},
|
|
4474
|
+
}, $u = {
|
|
4466
4475
|
create: Ct,
|
|
4467
4476
|
update: Ct,
|
|
4468
4477
|
merge: Ct,
|
|
@@ -4470,7 +4479,7 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
|
|
|
4470
4479
|
unlink: lr,
|
|
4471
4480
|
delete: () => {
|
|
4472
4481
|
}
|
|
4473
|
-
},
|
|
4482
|
+
}, xu = (t, e) => {
|
|
4474
4483
|
if (!e)
|
|
4475
4484
|
return;
|
|
4476
4485
|
const [n, r, i, s] = t;
|
|
@@ -4478,9 +4487,9 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
|
|
|
4478
4487
|
throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
|
|
4479
4488
|
if (typeof r != "string")
|
|
4480
4489
|
throw new Z(`Entity name must be a string, but received: ${typeof r}`);
|
|
4481
|
-
const o =
|
|
4490
|
+
const o = $u[n];
|
|
4482
4491
|
o && s !== void 0 && o(r, s, e);
|
|
4483
|
-
},
|
|
4492
|
+
}, Du = (t, e) => {
|
|
4484
4493
|
const n = Array.isArray(t) ? t : [t];
|
|
4485
4494
|
for (const r of n) {
|
|
4486
4495
|
if (!r || typeof r != "object")
|
|
@@ -4490,7 +4499,7 @@ const di = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`En
|
|
|
4490
4499
|
for (const i of r.__ops) {
|
|
4491
4500
|
if (!Array.isArray(i))
|
|
4492
4501
|
throw new Z(`Transaction operation must be an array, but received: ${typeof i}`);
|
|
4493
|
-
|
|
4502
|
+
xu(i, e);
|
|
4494
4503
|
}
|
|
4495
4504
|
}
|
|
4496
4505
|
};
|
|
@@ -4552,7 +4561,7 @@ class pr {
|
|
|
4552
4561
|
return this.conn.send(JSON.stringify(e));
|
|
4553
4562
|
}
|
|
4554
4563
|
}
|
|
4555
|
-
class
|
|
4564
|
+
class Uu {
|
|
4556
4565
|
constructor(e, n) {
|
|
4557
4566
|
this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${li++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
|
|
4558
4567
|
this.initParams || this.handleError();
|
|
@@ -4665,14 +4674,14 @@ var yr = function(t, e, n, r) {
|
|
|
4665
4674
|
d((r = r.apply(t, e || [])).next());
|
|
4666
4675
|
});
|
|
4667
4676
|
};
|
|
4668
|
-
function
|
|
4677
|
+
function Lu(t, e) {
|
|
4669
4678
|
const n = t.values;
|
|
4670
4679
|
if (n)
|
|
4671
4680
|
for (const r of n.entities || [])
|
|
4672
4681
|
r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Lr(r.store);
|
|
4673
4682
|
return t;
|
|
4674
4683
|
}
|
|
4675
|
-
function
|
|
4684
|
+
function Fu(t, e) {
|
|
4676
4685
|
var n, r;
|
|
4677
4686
|
if (!((n = e.values) === null || n === void 0) && n.entities) {
|
|
4678
4687
|
const i = [];
|
|
@@ -4684,7 +4693,7 @@ function Lu(t, e) {
|
|
|
4684
4693
|
} else
|
|
4685
4694
|
return e;
|
|
4686
4695
|
}
|
|
4687
|
-
function
|
|
4696
|
+
function Nu(t, e, n) {
|
|
4688
4697
|
var r, i;
|
|
4689
4698
|
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;
|
|
4690
4699
|
return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
|
|
@@ -4711,7 +4720,7 @@ function _r(t, e) {
|
|
|
4711
4720
|
break;
|
|
4712
4721
|
}
|
|
4713
4722
|
}
|
|
4714
|
-
function
|
|
4723
|
+
function Ku(t, e) {
|
|
4715
4724
|
var n, r, i, s;
|
|
4716
4725
|
const o = {};
|
|
4717
4726
|
for (const { action: u, triple: a } of e) {
|
|
@@ -4739,14 +4748,14 @@ function Nu(t, e) {
|
|
|
4739
4748
|
function rt(t, e) {
|
|
4740
4749
|
return { [t.table]: e.map((n) => n.entity) };
|
|
4741
4750
|
}
|
|
4742
|
-
function
|
|
4751
|
+
function qu(t, e) {
|
|
4743
4752
|
var n;
|
|
4744
4753
|
if (t.orderFieldType)
|
|
4745
4754
|
return t.orderFieldType;
|
|
4746
4755
|
const r = t.orderField === "serverCreatedAt" ? "number" : (n = fe(e([]), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
|
|
4747
4756
|
return t.orderFieldType = r, r;
|
|
4748
4757
|
}
|
|
4749
|
-
function
|
|
4758
|
+
function zu(t, e, n) {
|
|
4750
4759
|
const r = e;
|
|
4751
4760
|
if (t.orderField === "serverCreatedAt") {
|
|
4752
4761
|
n.sort(t.orderDirection === "asc" ? function(o, u) {
|
|
@@ -4767,13 +4776,13 @@ var pe;
|
|
|
4767
4776
|
(function(t) {
|
|
4768
4777
|
t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
|
|
4769
4778
|
})(pe || (pe = {}));
|
|
4770
|
-
class
|
|
4779
|
+
class Vu {
|
|
4771
4780
|
constructor(e, n, r, i, s) {
|
|
4772
4781
|
this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new Yt({
|
|
4773
4782
|
persister: n,
|
|
4774
|
-
merge:
|
|
4775
|
-
serialize:
|
|
4776
|
-
parse: (o, u) =>
|
|
4783
|
+
merge: Nu,
|
|
4784
|
+
serialize: Fu,
|
|
4785
|
+
parse: (o, u) => Lu(u, this.config.useDateObjects),
|
|
4777
4786
|
objectSize: (o) => {
|
|
4778
4787
|
var u;
|
|
4779
4788
|
return ((u = o.values) === null || u === void 0 ? void 0 : u.entities.length) || 0;
|
|
@@ -4975,9 +4984,9 @@ class zu {
|
|
|
4975
4984
|
e: for (const [T, v] of Object.entries(f))
|
|
4976
4985
|
for (let k = 0; k < p.length; k++) {
|
|
4977
4986
|
const S = p[k];
|
|
4978
|
-
if (
|
|
4987
|
+
if (vs(S.store, T)) {
|
|
4979
4988
|
_r(S.store, v);
|
|
4980
|
-
const I = Pt(u, S.store), R =
|
|
4989
|
+
const I = Pt(u, S.store), R = Ku(S.store, v)[T];
|
|
4981
4990
|
I ? (y.push({
|
|
4982
4991
|
oldEntity: S.entity,
|
|
4983
4992
|
newEntity: I,
|
|
@@ -5008,8 +5017,8 @@ class zu {
|
|
|
5008
5017
|
const g = [];
|
|
5009
5018
|
for (const T of c.sort().reverse())
|
|
5010
5019
|
g.push(p[T].entity), p.splice(T, 1);
|
|
5011
|
-
const m =
|
|
5012
|
-
|
|
5020
|
+
const m = qu(u, this.createStore);
|
|
5021
|
+
zu(u, m, p), this.notifyCbs(o, {
|
|
5013
5022
|
type: pe.SyncTransaction,
|
|
5014
5023
|
data: rt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
|
|
5015
5024
|
added: b,
|
|
@@ -5076,7 +5085,7 @@ var U = function(t, e, n, r) {
|
|
|
5076
5085
|
}
|
|
5077
5086
|
d((r = r.apply(t, e || [])).next());
|
|
5078
5087
|
});
|
|
5079
|
-
},
|
|
5088
|
+
}, Wu = function(t, e) {
|
|
5080
5089
|
var n = {};
|
|
5081
5090
|
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
|
|
5082
5091
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -5090,23 +5099,23 @@ const se = {
|
|
|
5090
5099
|
AUTHENTICATED: "authenticated",
|
|
5091
5100
|
CLOSED: "closed",
|
|
5092
5101
|
ERRORED: "errored"
|
|
5093
|
-
},
|
|
5102
|
+
}, Bu = 3e4, Gu = 3e4, Qu = 200, Hu = {
|
|
5094
5103
|
apiURI: "https://api.instantdb.com",
|
|
5095
5104
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
5096
5105
|
}, It = "_instant_oauth_redirect", De = "currentUser";
|
|
5097
|
-
function
|
|
5106
|
+
function Yu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
|
|
5098
5107
|
if (!i)
|
|
5099
5108
|
return new pr(`${r}?app_id=${e}`);
|
|
5100
5109
|
switch (t) {
|
|
5101
5110
|
case "ws":
|
|
5102
5111
|
return new pr(`${r}?app_id=${e}`);
|
|
5103
5112
|
case "sse":
|
|
5104
|
-
return new
|
|
5113
|
+
return new Uu(i, `${n}/runtime/sse?app_id=${e}`);
|
|
5105
5114
|
default:
|
|
5106
5115
|
throw new Error("Unknown transport type " + t);
|
|
5107
5116
|
}
|
|
5108
5117
|
}
|
|
5109
|
-
function
|
|
5118
|
+
function Ju() {
|
|
5110
5119
|
return typeof window < "u" || typeof chrome < "u";
|
|
5111
5120
|
}
|
|
5112
5121
|
const gr = {
|
|
@@ -5115,7 +5124,7 @@ const gr = {
|
|
|
5115
5124
|
"refresh-presence": !0,
|
|
5116
5125
|
"patch-presence": !0
|
|
5117
5126
|
};
|
|
5118
|
-
function
|
|
5127
|
+
function Zu(t, e) {
|
|
5119
5128
|
var n;
|
|
5120
5129
|
const r = typeof t == "string" ? JSON.parse(t) : t;
|
|
5121
5130
|
if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
|
|
@@ -5124,12 +5133,12 @@ function Ju(t, e) {
|
|
|
5124
5133
|
}
|
|
5125
5134
|
return r;
|
|
5126
5135
|
}
|
|
5127
|
-
function
|
|
5136
|
+
function Xu(t, e) {
|
|
5128
5137
|
var n;
|
|
5129
5138
|
const r = Object.assign({}, e);
|
|
5130
5139
|
return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Ur(e.result.store) })), r;
|
|
5131
5140
|
}
|
|
5132
|
-
function
|
|
5141
|
+
function ea(t, e) {
|
|
5133
5142
|
switch (t) {
|
|
5134
5143
|
case "pendingMutations":
|
|
5135
5144
|
return new Map(typeof e == "string" ? JSON.parse(e) : e);
|
|
@@ -5137,7 +5146,7 @@ function Xu(t, e) {
|
|
|
5137
5146
|
return e;
|
|
5138
5147
|
}
|
|
5139
5148
|
}
|
|
5140
|
-
function
|
|
5149
|
+
function ta(t, e) {
|
|
5141
5150
|
switch (t) {
|
|
5142
5151
|
case "pendingMutations":
|
|
5143
5152
|
return [...e.entries()];
|
|
@@ -5145,7 +5154,7 @@ function ea(t, e) {
|
|
|
5145
5154
|
return e;
|
|
5146
5155
|
}
|
|
5147
5156
|
}
|
|
5148
|
-
function
|
|
5157
|
+
function na(t, e, n) {
|
|
5149
5158
|
const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
|
|
5150
5159
|
return r && !i && n && (n.result = r), n || e;
|
|
5151
5160
|
}
|
|
@@ -5155,7 +5164,7 @@ function Tr(t) {
|
|
|
5155
5164
|
return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
|
|
5156
5165
|
});
|
|
5157
5166
|
}
|
|
5158
|
-
class
|
|
5167
|
+
class ra {
|
|
5159
5168
|
constructor(e, n = ti, r = ni, i, s) {
|
|
5160
5169
|
var o, u, a;
|
|
5161
5170
|
if (this._isOnline = !0, this._isShutdown = !1, this.status = se.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 = (d, c, f) => {
|
|
@@ -5188,9 +5197,9 @@ class na {
|
|
|
5188
5197
|
}, this.notifyQueryError = (d, c) => {
|
|
5189
5198
|
(this.queryCbs[d] || []).forEach((l) => l.cb({ error: c }));
|
|
5190
5199
|
}, this.pushTx = (d) => {
|
|
5191
|
-
this.config.disableValidation ||
|
|
5200
|
+
this.config.disableValidation || Du(d, this.config.schema);
|
|
5192
5201
|
try {
|
|
5193
|
-
const c =
|
|
5202
|
+
const c = iu({
|
|
5194
5203
|
attrs: this.optimisticAttrs(),
|
|
5195
5204
|
schema: this.config.schema,
|
|
5196
5205
|
stores: Object.values(this.querySubs.currentValue).map((f) => {
|
|
@@ -5279,7 +5288,7 @@ class na {
|
|
|
5279
5288
|
return;
|
|
5280
5289
|
}
|
|
5281
5290
|
this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
|
|
5282
|
-
}, this._EventSource = s, this.config = Object.assign(Object.assign({},
|
|
5291
|
+
}, this._EventSource = s, this.config = Object.assign(Object.assign({}, Hu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Gu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Qu, this._log = ju(e.verbose || hn || ri, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": oi }), this.config.schema && (this._linkIndex = ur(this.config.schema)), !!Ju()) {
|
|
5283
5292
|
if (!e.appId)
|
|
5284
5293
|
throw new Error("Instant must be initialized with an appId.");
|
|
5285
5294
|
if (!Ee(e.appId))
|
|
@@ -5294,7 +5303,7 @@ class na {
|
|
|
5294
5303
|
} catch (f) {
|
|
5295
5304
|
this._log.error("[error] handle broadcast channel", f);
|
|
5296
5305
|
}
|
|
5297
|
-
}))), this._initStorage(n), this._syncTable = new
|
|
5306
|
+
}))), this._initStorage(n), this._syncTable = new Vu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
|
|
5298
5307
|
useDateObjects: this.config.useDateObjects
|
|
5299
5308
|
}, this._log, (d) => at(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
|
|
5300
5309
|
this._isOnline = d, this._startSocket(), r.listen((c) => {
|
|
@@ -5319,9 +5328,9 @@ class na {
|
|
|
5319
5328
|
_initStorage(e) {
|
|
5320
5329
|
this.querySubs = new Yt({
|
|
5321
5330
|
persister: new e(this.config.appId, "querySubs"),
|
|
5322
|
-
merge:
|
|
5323
|
-
serialize:
|
|
5324
|
-
parse: (n, r) =>
|
|
5331
|
+
merge: na,
|
|
5332
|
+
serialize: Xu,
|
|
5333
|
+
parse: (n, r) => Zu(r, this.config.useDateObjects),
|
|
5325
5334
|
// objectSize
|
|
5326
5335
|
objectSize: (n) => {
|
|
5327
5336
|
var r, i, s, o;
|
|
@@ -5340,8 +5349,8 @@ class na {
|
|
|
5340
5349
|
}), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Yt({
|
|
5341
5350
|
persister: new e(this.config.appId, "kv"),
|
|
5342
5351
|
merge: this._onMergeKv,
|
|
5343
|
-
serialize:
|
|
5344
|
-
parse:
|
|
5352
|
+
serialize: ta,
|
|
5353
|
+
parse: ea,
|
|
5345
5354
|
objectSize: () => 0,
|
|
5346
5355
|
logger: this._log,
|
|
5347
5356
|
saveThrottleMs: 100,
|
|
@@ -5372,7 +5381,7 @@ class na {
|
|
|
5372
5381
|
if (s)
|
|
5373
5382
|
i.resolve({ status: e, eventId: n });
|
|
5374
5383
|
else if (r != null && r.type) {
|
|
5375
|
-
const { status: o } = r, u =
|
|
5384
|
+
const { status: o } = r, u = Wu(r, ["status"]);
|
|
5376
5385
|
i.reject(new bt({
|
|
5377
5386
|
// @ts-expect-error body.type is not constant typed
|
|
5378
5387
|
body: u,
|
|
@@ -5631,7 +5640,7 @@ class na {
|
|
|
5631
5640
|
if (!this.querySubs)
|
|
5632
5641
|
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;
|
|
5633
5642
|
const s = N(e), o = this._startQuerySub(e, s);
|
|
5634
|
-
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")),
|
|
5643
|
+
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")), Bu), i.promise;
|
|
5635
5644
|
}
|
|
5636
5645
|
_completeQueryOnce(e, n, r) {
|
|
5637
5646
|
this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
|
|
@@ -5692,7 +5701,7 @@ class na {
|
|
|
5692
5701
|
u = !0;
|
|
5693
5702
|
continue;
|
|
5694
5703
|
}
|
|
5695
|
-
const b = u ?
|
|
5704
|
+
const b = u ? $o(o, p) : p;
|
|
5696
5705
|
l.push(b);
|
|
5697
5706
|
}
|
|
5698
5707
|
return u ? l : c;
|
|
@@ -5740,7 +5749,7 @@ class na {
|
|
|
5740
5749
|
}
|
|
5741
5750
|
_applyOptimisticUpdates(e, n, r) {
|
|
5742
5751
|
for (const [i, s] of n)
|
|
5743
|
-
(!s["tx-id"] || r && s["tx-id"] > r) && (e =
|
|
5752
|
+
(!s["tx-id"] || r && s["tx-id"] > r) && (e = $s(e, s["tx-steps"]));
|
|
5744
5753
|
return e;
|
|
5745
5754
|
}
|
|
5746
5755
|
/** Re-compute all subscriptions */
|
|
@@ -5849,7 +5858,7 @@ class na {
|
|
|
5849
5858
|
return;
|
|
5850
5859
|
}
|
|
5851
5860
|
const e = this._transport;
|
|
5852
|
-
this._transport =
|
|
5861
|
+
this._transport = Yu({
|
|
5853
5862
|
transportType: this._transportType,
|
|
5854
5863
|
appId: this.config.appId,
|
|
5855
5864
|
apiURI: this.config.apiURI,
|
|
@@ -6052,7 +6061,7 @@ class na {
|
|
|
6052
6061
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
|
|
6053
6062
|
}
|
|
6054
6063
|
sendMagicCode({ email: e }) {
|
|
6055
|
-
return
|
|
6064
|
+
return pu({
|
|
6056
6065
|
apiURI: this.config.apiURI,
|
|
6057
6066
|
appId: this.config.appId,
|
|
6058
6067
|
email: e
|
|
@@ -6061,7 +6070,7 @@ class na {
|
|
|
6061
6070
|
signInWithMagicCode(e) {
|
|
6062
6071
|
return U(this, arguments, void 0, function* ({ email: n, code: r }) {
|
|
6063
6072
|
var i;
|
|
6064
|
-
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield
|
|
6073
|
+
const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield yu({
|
|
6065
6074
|
apiURI: this.config.apiURI,
|
|
6066
6075
|
appId: this.config.appId,
|
|
6067
6076
|
email: n,
|
|
@@ -6073,7 +6082,7 @@ class na {
|
|
|
6073
6082
|
}
|
|
6074
6083
|
signInWithCustomToken(e) {
|
|
6075
6084
|
return U(this, void 0, void 0, function* () {
|
|
6076
|
-
const n = yield
|
|
6085
|
+
const n = yield bu({
|
|
6077
6086
|
apiURI: this.config.apiURI,
|
|
6078
6087
|
appId: this.config.appId,
|
|
6079
6088
|
refreshToken: e
|
|
@@ -6083,7 +6092,7 @@ class na {
|
|
|
6083
6092
|
}
|
|
6084
6093
|
signInAsGuest() {
|
|
6085
6094
|
return U(this, void 0, void 0, function* () {
|
|
6086
|
-
const e = yield
|
|
6095
|
+
const e = yield _u({
|
|
6087
6096
|
apiURI: this.config.apiURI,
|
|
6088
6097
|
appId: this.config.appId
|
|
6089
6098
|
});
|
|
@@ -6099,7 +6108,7 @@ class na {
|
|
|
6099
6108
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
6100
6109
|
return;
|
|
6101
6110
|
}
|
|
6102
|
-
|
|
6111
|
+
Tu({
|
|
6103
6112
|
apiURI: this.config.apiURI,
|
|
6104
6113
|
appId: this.config.appId,
|
|
6105
6114
|
refreshToken: i
|
|
@@ -6157,7 +6166,7 @@ class na {
|
|
|
6157
6166
|
signInWithIdToken(e) {
|
|
6158
6167
|
return U(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
|
|
6159
6168
|
var s;
|
|
6160
|
-
const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield
|
|
6169
|
+
const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield gu({
|
|
6161
6170
|
apiURI: this.config.apiURI,
|
|
6162
6171
|
appId: this.config.appId,
|
|
6163
6172
|
idToken: n,
|
|
@@ -6198,7 +6207,7 @@ class na {
|
|
|
6198
6207
|
// TODO: look into typing again
|
|
6199
6208
|
getPresence(e, n, r = {}) {
|
|
6200
6209
|
const i = this._rooms[n], s = this._presence[n];
|
|
6201
|
-
return !i || !s || !s.result ? null : Object.assign(Object.assign({},
|
|
6210
|
+
return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Eu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
|
|
6202
6211
|
}
|
|
6203
6212
|
// TODO: look into typing again
|
|
6204
6213
|
publishPresence(e, n, r) {
|
|
@@ -6248,7 +6257,7 @@ class na {
|
|
|
6248
6257
|
}
|
|
6249
6258
|
_notifyPresenceSub(e, n) {
|
|
6250
6259
|
const r = this.getPresence("", e, n);
|
|
6251
|
-
r && (n.prev && !
|
|
6260
|
+
r && (n.prev && !Au(r, n.prev) || (n.prev = r, n.cb(r)));
|
|
6252
6261
|
}
|
|
6253
6262
|
_patchPresencePeers(e, n) {
|
|
6254
6263
|
var r, i, s;
|
|
@@ -6322,14 +6331,14 @@ class na {
|
|
|
6322
6331
|
return U(this, void 0, void 0, function* () {
|
|
6323
6332
|
var i;
|
|
6324
6333
|
const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
|
|
6325
|
-
return
|
|
6334
|
+
return mu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
|
|
6326
6335
|
});
|
|
6327
6336
|
}
|
|
6328
6337
|
deleteFile(e) {
|
|
6329
6338
|
return U(this, void 0, void 0, function* () {
|
|
6330
6339
|
var n;
|
|
6331
6340
|
const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
|
|
6332
|
-
return yield
|
|
6341
|
+
return yield wu({
|
|
6333
6342
|
apiURI: this.config.apiURI,
|
|
6334
6343
|
appId: this.config.appId,
|
|
6335
6344
|
path: e,
|
|
@@ -6342,20 +6351,20 @@ class na {
|
|
|
6342
6351
|
upload(e, n) {
|
|
6343
6352
|
return U(this, void 0, void 0, function* () {
|
|
6344
6353
|
var r;
|
|
6345
|
-
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
|
|
6354
|
+
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 vu({
|
|
6346
6355
|
apiURI: this.config.apiURI,
|
|
6347
6356
|
appId: this.config.appId,
|
|
6348
6357
|
fileName: o,
|
|
6349
6358
|
refreshToken: s
|
|
6350
6359
|
});
|
|
6351
|
-
return yield
|
|
6360
|
+
return yield Su(u, n);
|
|
6352
6361
|
});
|
|
6353
6362
|
}
|
|
6354
6363
|
getDownloadUrl(e) {
|
|
6355
6364
|
return U(this, void 0, void 0, function* () {
|
|
6356
6365
|
var n;
|
|
6357
6366
|
const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
|
|
6358
|
-
return yield
|
|
6367
|
+
return yield Ou({
|
|
6359
6368
|
apiURI: this.config.apiURI,
|
|
6360
6369
|
appId: this.config.appId,
|
|
6361
6370
|
path: e,
|
|
@@ -6365,9 +6374,9 @@ class na {
|
|
|
6365
6374
|
}
|
|
6366
6375
|
}
|
|
6367
6376
|
let it;
|
|
6368
|
-
function
|
|
6377
|
+
function ia(t, e) {
|
|
6369
6378
|
it == null || it.dispose();
|
|
6370
|
-
const n =
|
|
6379
|
+
const n = da(e), r = ua(e, u), i = oa(sa(t));
|
|
6371
6380
|
function s(c) {
|
|
6372
6381
|
var f;
|
|
6373
6382
|
c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
|
|
@@ -6389,10 +6398,10 @@ function ra(t, e) {
|
|
|
6389
6398
|
}
|
|
6390
6399
|
return d();
|
|
6391
6400
|
}
|
|
6392
|
-
function
|
|
6401
|
+
function sa(t) {
|
|
6393
6402
|
return `${hn || ii ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
6394
6403
|
}
|
|
6395
|
-
function
|
|
6404
|
+
function oa(t) {
|
|
6396
6405
|
const e = document.createElement("iframe");
|
|
6397
6406
|
return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
6398
6407
|
width: "100%",
|
|
@@ -6401,7 +6410,7 @@ function sa(t) {
|
|
|
6401
6410
|
border: "none"
|
|
6402
6411
|
}), { element: e };
|
|
6403
6412
|
}
|
|
6404
|
-
function
|
|
6413
|
+
function ua(t, e) {
|
|
6405
6414
|
const n = `
|
|
6406
6415
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6407
6416
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -6411,7 +6420,7 @@ function oa(t, e) {
|
|
|
6411
6420
|
return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
|
|
6412
6421
|
// pos
|
|
6413
6422
|
position: "fixed"
|
|
6414
|
-
},
|
|
6423
|
+
}, aa(t.position)), {
|
|
6415
6424
|
height: "32px",
|
|
6416
6425
|
width: "32px",
|
|
6417
6426
|
// layout
|
|
@@ -6426,7 +6435,7 @@ function oa(t, e) {
|
|
|
6426
6435
|
cursor: "pointer"
|
|
6427
6436
|
})), r.addEventListener("click", e), { element: r };
|
|
6428
6437
|
}
|
|
6429
|
-
function
|
|
6438
|
+
function aa(t) {
|
|
6430
6439
|
switch (t) {
|
|
6431
6440
|
case "bottom-left":
|
|
6432
6441
|
return { bottom: "24px", left: "24px" };
|
|
@@ -6438,7 +6447,7 @@ function ua(t) {
|
|
|
6438
6447
|
return { top: "24px", left: "24px" };
|
|
6439
6448
|
}
|
|
6440
6449
|
}
|
|
6441
|
-
function
|
|
6450
|
+
function ca(t) {
|
|
6442
6451
|
switch (t) {
|
|
6443
6452
|
case "bottom-left":
|
|
6444
6453
|
return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
|
|
@@ -6450,23 +6459,23 @@ function aa(t) {
|
|
|
6450
6459
|
return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
|
|
6451
6460
|
}
|
|
6452
6461
|
}
|
|
6453
|
-
function
|
|
6462
|
+
function da(t) {
|
|
6454
6463
|
const e = document.createElement("div");
|
|
6455
|
-
Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" },
|
|
6464
|
+
Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, ca(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";
|
|
6456
6465
|
function n() {
|
|
6457
6466
|
return e.style.display !== "none";
|
|
6458
6467
|
}
|
|
6459
6468
|
return { element: e, isVisible: n };
|
|
6460
6469
|
}
|
|
6461
|
-
const
|
|
6470
|
+
const fa = {
|
|
6462
6471
|
apiURI: "https://api.instantdb.com",
|
|
6463
6472
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
6464
6473
|
};
|
|
6465
|
-
function
|
|
6474
|
+
function la() {
|
|
6466
6475
|
var t;
|
|
6467
6476
|
return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
6468
6477
|
}
|
|
6469
|
-
function
|
|
6478
|
+
function ha() {
|
|
6470
6479
|
var t;
|
|
6471
6480
|
return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
|
|
6472
6481
|
}
|
|
@@ -6474,23 +6483,23 @@ function Jt(t) {
|
|
|
6474
6483
|
const e = t.__adminToken;
|
|
6475
6484
|
return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
|
|
6476
6485
|
}
|
|
6477
|
-
const Zt =
|
|
6478
|
-
class
|
|
6486
|
+
const Zt = ha(), mr = la();
|
|
6487
|
+
class pa {
|
|
6479
6488
|
constructor(e) {
|
|
6480
6489
|
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);
|
|
6481
6490
|
}
|
|
6482
6491
|
}
|
|
6483
|
-
class
|
|
6492
|
+
class ya {
|
|
6484
6493
|
constructor(e) {
|
|
6485
6494
|
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);
|
|
6486
6495
|
}
|
|
6487
6496
|
}
|
|
6488
|
-
function
|
|
6497
|
+
function ba(t) {
|
|
6489
6498
|
return JSON.parse(JSON.stringify(t));
|
|
6490
6499
|
}
|
|
6491
|
-
class
|
|
6500
|
+
class _a {
|
|
6492
6501
|
constructor(e) {
|
|
6493
|
-
this.tx = ln(), this._reactor = e, this.auth = new
|
|
6502
|
+
this.tx = ln(), this._reactor = e, this.auth = new pa(this._reactor), this.storage = new ya(this._reactor);
|
|
6494
6503
|
}
|
|
6495
6504
|
/**
|
|
6496
6505
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -6673,24 +6682,24 @@ function wr(t) {
|
|
|
6673
6682
|
const n = N(t);
|
|
6674
6683
|
return mr.set(t, n), n;
|
|
6675
6684
|
}
|
|
6676
|
-
function
|
|
6685
|
+
function ga(t, e) {
|
|
6677
6686
|
return wr(t._reactor.config.schema) !== wr(e);
|
|
6678
6687
|
}
|
|
6679
|
-
function
|
|
6688
|
+
function Ta(t, e, n, r, i) {
|
|
6680
6689
|
var s;
|
|
6681
6690
|
const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = Zt[Jt(o)];
|
|
6682
6691
|
if (u)
|
|
6683
|
-
return
|
|
6684
|
-
const a = new
|
|
6685
|
-
return Zt[Jt(o)] = d,
|
|
6692
|
+
return ga(u, o.schema) && u._reactor.updateSchema(o.schema), u;
|
|
6693
|
+
const a = new ra(Object.assign(Object.assign(Object.assign({}, fa), o), { cardinalityInference: !!o.schema }), e || ti, n || ni, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": oi }), i), d = new _a(a);
|
|
6694
|
+
return Zt[Jt(o)] = d, ma(o.appId, o.devtool), d;
|
|
6686
6695
|
}
|
|
6687
|
-
function
|
|
6696
|
+
function ma(t, e) {
|
|
6688
6697
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
6689
6698
|
return;
|
|
6690
6699
|
const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
|
|
6691
|
-
n.allowedHosts.includes(window.location.hostname) &&
|
|
6700
|
+
n.allowedHosts.includes(window.location.hostname) && ia(t, n);
|
|
6692
6701
|
}
|
|
6693
|
-
const
|
|
6702
|
+
const wa = {
|
|
6694
6703
|
isLoading: !0,
|
|
6695
6704
|
data: void 0,
|
|
6696
6705
|
pageInfo: void 0,
|
|
@@ -6705,9 +6714,9 @@ function vr(t) {
|
|
|
6705
6714
|
...t || {}
|
|
6706
6715
|
};
|
|
6707
6716
|
}
|
|
6708
|
-
function
|
|
6717
|
+
function va(t, e, n) {
|
|
6709
6718
|
e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
|
|
6710
|
-
const r = e ?
|
|
6719
|
+
const r = e ? ba(e) : null, i = N(r), s = ze(
|
|
6711
6720
|
vr(t._reactor.getPreviousResult(r))
|
|
6712
6721
|
), o = de(
|
|
6713
6722
|
(a) => (s.current = vr(
|
|
@@ -6731,10 +6740,10 @@ function wa(t, e, n) {
|
|
|
6731
6740
|
return { state: Mt(
|
|
6732
6741
|
o,
|
|
6733
6742
|
() => s.current,
|
|
6734
|
-
() =>
|
|
6743
|
+
() => wa
|
|
6735
6744
|
), query: r };
|
|
6736
6745
|
}
|
|
6737
|
-
function
|
|
6746
|
+
function Sa() {
|
|
6738
6747
|
const t = ze(null);
|
|
6739
6748
|
ge(() => {
|
|
6740
6749
|
n();
|
|
@@ -6747,8 +6756,8 @@ function va() {
|
|
|
6747
6756
|
}
|
|
6748
6757
|
return { set: e, clear: n };
|
|
6749
6758
|
}
|
|
6750
|
-
const
|
|
6751
|
-
function
|
|
6759
|
+
const Oa = 1e3;
|
|
6760
|
+
function Ea(t, e, n) {
|
|
6752
6761
|
const r = ze(n);
|
|
6753
6762
|
r.current = n, ge(() => t.core._reactor.subscribeTopic(
|
|
6754
6763
|
t.id,
|
|
@@ -6758,7 +6767,7 @@ function Oa(t, e, n) {
|
|
|
6758
6767
|
}
|
|
6759
6768
|
), [t.id, e]);
|
|
6760
6769
|
}
|
|
6761
|
-
function
|
|
6770
|
+
function Aa(t, e) {
|
|
6762
6771
|
return ge(() => t.core._reactor.joinRoom(t.id), [t.id]), de(
|
|
6763
6772
|
(r) => {
|
|
6764
6773
|
t.core._reactor.publishTopic({
|
|
@@ -6771,7 +6780,7 @@ function Ea(t, e) {
|
|
|
6771
6780
|
[t.id, e]
|
|
6772
6781
|
);
|
|
6773
6782
|
}
|
|
6774
|
-
function
|
|
6783
|
+
function ja(t, e = {}) {
|
|
6775
6784
|
var o, u;
|
|
6776
6785
|
const [n, r] = Or(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
|
|
6777
6786
|
peers: {},
|
|
@@ -6796,11 +6805,11 @@ function Aa(t, e = {}) {
|
|
|
6796
6805
|
publishPresence: i
|
|
6797
6806
|
}), [n, i]);
|
|
6798
6807
|
}
|
|
6799
|
-
function
|
|
6808
|
+
function ka(t, e, n) {
|
|
6800
6809
|
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)]);
|
|
6801
6810
|
}
|
|
6802
|
-
function
|
|
6803
|
-
const r =
|
|
6811
|
+
function Ca(t, e, n = {}) {
|
|
6812
|
+
const r = Sa(), i = ye.usePresence(t, {
|
|
6804
6813
|
keys: [e]
|
|
6805
6814
|
}), s = Rt(() => {
|
|
6806
6815
|
const c = t._core._reactor.getPresence(
|
|
@@ -6814,7 +6823,7 @@ function ka(t, e, n = {}) {
|
|
|
6814
6823
|
(c) => {
|
|
6815
6824
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
6816
6825
|
[e]: c
|
|
6817
|
-
}), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ??
|
|
6826
|
+
}), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? Oa, () => {
|
|
6818
6827
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
6819
6828
|
[e]: null
|
|
6820
6829
|
});
|
|
@@ -6837,25 +6846,25 @@ function ka(t, e, n = {}) {
|
|
|
6837
6846
|
};
|
|
6838
6847
|
}
|
|
6839
6848
|
const ye = {
|
|
6840
|
-
useTopicEffect:
|
|
6841
|
-
usePublishTopic:
|
|
6842
|
-
usePresence:
|
|
6843
|
-
useSyncPresence:
|
|
6844
|
-
useTypingIndicator:
|
|
6849
|
+
useTopicEffect: Ea,
|
|
6850
|
+
usePublishTopic: Aa,
|
|
6851
|
+
usePresence: ja,
|
|
6852
|
+
useSyncPresence: ka,
|
|
6853
|
+
useTypingIndicator: Ca
|
|
6845
6854
|
};
|
|
6846
|
-
class
|
|
6855
|
+
class Pa {
|
|
6847
6856
|
constructor(e, n, r) {
|
|
6848
6857
|
this.useTopicEffect = (i, s) => {
|
|
6849
6858
|
ye.useTopicEffect(this, i, s);
|
|
6850
6859
|
}, 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;
|
|
6851
6860
|
}
|
|
6852
6861
|
}
|
|
6853
|
-
const
|
|
6862
|
+
const Ia = {
|
|
6854
6863
|
isLoading: !0,
|
|
6855
6864
|
user: void 0,
|
|
6856
6865
|
error: void 0
|
|
6857
6866
|
};
|
|
6858
|
-
class
|
|
6867
|
+
class Ra {
|
|
6859
6868
|
constructor(e, n) {
|
|
6860
6869
|
this.tx = ln(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
|
|
6861
6870
|
const [i, s] = Or(null);
|
|
@@ -6865,7 +6874,7 @@ class Ma {
|
|
|
6865
6874
|
s(u);
|
|
6866
6875
|
})();
|
|
6867
6876
|
}, [r]), i;
|
|
6868
|
-
}, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) =>
|
|
6877
|
+
}, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => va(this.core, r, i).state, this.useAuth = () => {
|
|
6869
6878
|
const r = ze(
|
|
6870
6879
|
this.core._reactor._currentUserCached
|
|
6871
6880
|
), i = de((o) => this.core.subscribeAuth((a) => {
|
|
@@ -6874,7 +6883,7 @@ class Ma {
|
|
|
6874
6883
|
return Mt(
|
|
6875
6884
|
i,
|
|
6876
6885
|
() => r.current,
|
|
6877
|
-
() =>
|
|
6886
|
+
() => Ia
|
|
6878
6887
|
);
|
|
6879
6888
|
}, this.useUser = () => {
|
|
6880
6889
|
const { user: r } = this.useAuth();
|
|
@@ -6901,7 +6910,7 @@ class Ma {
|
|
|
6901
6910
|
}, this.SignedOut = ({ children: r }) => {
|
|
6902
6911
|
const i = this.useAuth();
|
|
6903
6912
|
return i.isLoading || i.error || i.user ? null : /* @__PURE__ */ et.jsx(et.Fragment, { children: r });
|
|
6904
|
-
}, this.core =
|
|
6913
|
+
}, this.core = Ta(
|
|
6905
6914
|
e,
|
|
6906
6915
|
// @ts-expect-error because TS can't resolve subclass statics
|
|
6907
6916
|
this.constructor.Storage,
|
|
@@ -6925,7 +6934,7 @@ class Ma {
|
|
|
6925
6934
|
* const { peers } = db.rooms.usePresence(room);
|
|
6926
6935
|
*/
|
|
6927
6936
|
room(e = "_defaultRoomType", n = "_defaultRoomId") {
|
|
6928
|
-
return new
|
|
6937
|
+
return new Pa(this.core, e, n);
|
|
6929
6938
|
}
|
|
6930
6939
|
/**
|
|
6931
6940
|
* One time query for the logged in state. This is useful
|
|
@@ -6942,5 +6951,5 @@ class Ma {
|
|
|
6942
6951
|
}
|
|
6943
6952
|
}
|
|
6944
6953
|
export {
|
|
6945
|
-
|
|
6954
|
+
Ra as InstantReactAbstractDatabase
|
|
6946
6955
|
};
|