@instantdb/solidjs 1.0.1 → 1.0.2-branch-edge-runtime.24356557026.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/dist/standalone/index.js +931 -899
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +3 -3
package/dist/standalone/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Kr = Object.defineProperty;
|
|
2
2
|
var qr = (t, e, n) => e in t ? Kr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var h = (t, e, n) => qr(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
function
|
|
4
|
+
function H(t) {
|
|
5
5
|
if (typeof t == "number")
|
|
6
6
|
return (Math.abs(t * 2654435761) >>> 0).toString(16);
|
|
7
7
|
if (typeof t == "boolean")
|
|
@@ -20,7 +20,7 @@ function W(t) {
|
|
|
20
20
|
let e = 2166136261;
|
|
21
21
|
for (let n = 0; n < t.length; n++) {
|
|
22
22
|
e ^= (n + 1) * 2654435761;
|
|
23
|
-
const r =
|
|
23
|
+
const r = H(t[n]);
|
|
24
24
|
for (let s = 0; s < r.length; s++)
|
|
25
25
|
e ^= r.charCodeAt(s), e *= 16777619, e = e >>> 0;
|
|
26
26
|
}
|
|
@@ -33,20 +33,20 @@ function W(t) {
|
|
|
33
33
|
const s = n[r];
|
|
34
34
|
if (t[s] === void 0)
|
|
35
35
|
continue;
|
|
36
|
-
const i =
|
|
36
|
+
const i = H(s);
|
|
37
37
|
e ^= parseInt(i, 16), e *= 16777619, e = e >>> 0;
|
|
38
|
-
const o =
|
|
38
|
+
const o = H(t[s]);
|
|
39
39
|
e ^= parseInt(o, 16), e *= 16777619, e = e >>> 0;
|
|
40
40
|
}
|
|
41
41
|
return e.toString(16);
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return H(String(t));
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const z = {
|
|
46
46
|
Remove: "remove",
|
|
47
47
|
Replace: "replace",
|
|
48
48
|
Add: "add"
|
|
49
|
-
}, Qn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), zr = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Ze = Symbol.iterator,
|
|
49
|
+
}, Qn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), zr = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Ze = Symbol.iterator, oe = {
|
|
50
50
|
mutable: "mutable",
|
|
51
51
|
immutable: "immutable"
|
|
52
52
|
}, Gt = {};
|
|
@@ -70,30 +70,30 @@ function Ht(t) {
|
|
|
70
70
|
function Jt(t) {
|
|
71
71
|
return Object.getPrototypeOf(t) === Map.prototype;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function ie(t) {
|
|
74
74
|
var e;
|
|
75
75
|
return (e = t.copy) !== null && e !== void 0 ? e : t.original;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return !!
|
|
77
|
+
function Te(t) {
|
|
78
|
+
return !!E(t);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function E(t) {
|
|
81
81
|
return typeof t != "object" ? null : t == null ? void 0 : t[Qn];
|
|
82
82
|
}
|
|
83
83
|
function Yt(t) {
|
|
84
84
|
var e;
|
|
85
|
-
const n =
|
|
85
|
+
const n = E(t);
|
|
86
86
|
return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function ue(t, e) {
|
|
89
89
|
if (!t || typeof t != "object")
|
|
90
90
|
return !1;
|
|
91
91
|
let n;
|
|
92
|
-
return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t,
|
|
92
|
+
return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, oe)) === oe.immutable || typeof n == "function");
|
|
93
93
|
}
|
|
94
94
|
function Bn(t, e = []) {
|
|
95
95
|
if (Object.hasOwnProperty.call(t, "key")) {
|
|
96
|
-
const n = t.parent.copy, r =
|
|
96
|
+
const n = t.parent.copy, r = E(ge(n, t.key));
|
|
97
97
|
if (r !== null && (r == null ? void 0 : r.original) !== t.original)
|
|
98
98
|
return null;
|
|
99
99
|
const s = t.parent.type === 3, i = s ? Array.from(t.parent.setMap.keys()).indexOf(t.key) : t.key;
|
|
@@ -114,17 +114,17 @@ function Bn(t, e = []) {
|
|
|
114
114
|
function ve(t) {
|
|
115
115
|
return Array.isArray(t) ? 1 : t instanceof Map ? 2 : t instanceof Set ? 3 : 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function ge(t, e) {
|
|
118
118
|
return ve(t) === 2 ? t.get(e) : t[e];
|
|
119
119
|
}
|
|
120
120
|
function We(t, e, n) {
|
|
121
121
|
ve(t) === 2 ? t.set(e, n) : t[e] = n;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
const n =
|
|
125
|
-
return (n ?
|
|
123
|
+
function St(t, e) {
|
|
124
|
+
const n = E(t);
|
|
125
|
+
return (n ? ie(n) : t)[e];
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function ye(t, e) {
|
|
128
128
|
return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
|
|
129
129
|
}
|
|
130
130
|
function Mt(t) {
|
|
@@ -141,7 +141,7 @@ function me(t, e) {
|
|
|
141
141
|
function Wr(t, e) {
|
|
142
142
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
143
143
|
const r = e[n];
|
|
144
|
-
if (t =
|
|
144
|
+
if (t = ge(ve(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
|
|
145
145
|
throw new Error(`Cannot resolve patch at '${e.join("/")}'.`);
|
|
146
146
|
}
|
|
147
147
|
return t;
|
|
@@ -179,8 +179,8 @@ function Gn(t, e) {
|
|
|
179
179
|
return new r(t);
|
|
180
180
|
}
|
|
181
181
|
return new Map(t);
|
|
182
|
-
} else if (e != null && e.mark && (n = e.mark(t,
|
|
183
|
-
if (n ===
|
|
182
|
+
} else if (e != null && e.mark && (n = e.mark(t, oe), n !== void 0) && n !== oe.mutable) {
|
|
183
|
+
if (n === oe.immutable)
|
|
184
184
|
return Vr(t);
|
|
185
185
|
if (typeof n == "function") {
|
|
186
186
|
if (e.enablePatches || e.enableAutoFreeze)
|
|
@@ -198,11 +198,11 @@ function Gn(t, e) {
|
|
|
198
198
|
} else
|
|
199
199
|
throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function X(t) {
|
|
202
202
|
t.copy || (t.copy = Gn(t.original, t.options));
|
|
203
203
|
}
|
|
204
204
|
function Re(t) {
|
|
205
|
-
if (!
|
|
205
|
+
if (!ue(t))
|
|
206
206
|
return Yt(t);
|
|
207
207
|
if (Array.isArray(t))
|
|
208
208
|
return t.map(Re);
|
|
@@ -231,11 +231,11 @@ function Re(t) {
|
|
|
231
231
|
return e;
|
|
232
232
|
}
|
|
233
233
|
function Xe(t) {
|
|
234
|
-
return
|
|
234
|
+
return Te(t) ? Re(t) : t;
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function de(t) {
|
|
237
237
|
var e;
|
|
238
|
-
t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent &&
|
|
238
|
+
t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && de(t.parent));
|
|
239
239
|
}
|
|
240
240
|
function fn() {
|
|
241
241
|
throw new Error("Cannot modify frozen object");
|
|
@@ -257,7 +257,7 @@ function Ce(t, e, n, r, s) {
|
|
|
257
257
|
} else
|
|
258
258
|
r.push(o);
|
|
259
259
|
}
|
|
260
|
-
if (Object.isFrozen(t) ||
|
|
260
|
+
if (Object.isFrozen(t) || Te(t)) {
|
|
261
261
|
r.pop(), s.pop();
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
@@ -300,14 +300,14 @@ function Zt(t, e) {
|
|
|
300
300
|
t.forEach((r, s) => e(s, r, t));
|
|
301
301
|
}
|
|
302
302
|
function Hn(t, e, n) {
|
|
303
|
-
if (
|
|
303
|
+
if (Te(t) || !ue(t, n) || e.has(t) || Object.isFrozen(t))
|
|
304
304
|
return;
|
|
305
305
|
const r = t instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
|
|
306
306
|
if (e.add(t), Zt(t, (i, o) => {
|
|
307
307
|
var a;
|
|
308
|
-
if (
|
|
309
|
-
const c =
|
|
310
|
-
|
|
308
|
+
if (Te(o)) {
|
|
309
|
+
const c = E(o);
|
|
310
|
+
X(c);
|
|
311
311
|
const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
|
|
312
312
|
We(r ? s : t, i, u);
|
|
313
313
|
} else
|
|
@@ -321,7 +321,7 @@ function Hn(t, e, n) {
|
|
|
321
321
|
}
|
|
322
322
|
function Br(t, e) {
|
|
323
323
|
const n = t.type === 3 ? t.setMap : t.copy;
|
|
324
|
-
t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Hn(
|
|
324
|
+
t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Hn(ge(n, e), t.finalities.handledSet, t.options);
|
|
325
325
|
}
|
|
326
326
|
function jt(t) {
|
|
327
327
|
t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
|
|
@@ -338,17 +338,17 @@ function $t(t, e, n, r) {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
function Xt(t, e, n, r) {
|
|
341
|
-
const s =
|
|
341
|
+
const s = E(n);
|
|
342
342
|
s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
|
|
343
343
|
var a;
|
|
344
344
|
const c = t.type === 3 ? t.setMap : t.copy;
|
|
345
|
-
if (
|
|
345
|
+
if (ye(ge(c, e), n)) {
|
|
346
346
|
let u = s.original;
|
|
347
347
|
s.copy && (u = s.copy), jt(t), $t(t, r, i, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(u, s.original)), We(c, e, u);
|
|
348
348
|
}
|
|
349
|
-
}), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)),
|
|
349
|
+
}), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ue(n, t.options) && t.finalities.draft.push(() => {
|
|
350
350
|
const i = t.type === 3 ? t.setMap : t.copy;
|
|
351
|
-
|
|
351
|
+
ye(ge(i, e), n) && Br(t, e);
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
function Gr(t, e, n, r, s) {
|
|
@@ -358,12 +358,12 @@ function Gr(t, e, n, r, s) {
|
|
|
358
358
|
if (o.get(u.toString()) && c[u] !== i[u]) {
|
|
359
359
|
const l = e.concat([u]), f = me(l, s);
|
|
360
360
|
n.push({
|
|
361
|
-
op:
|
|
361
|
+
op: z.Replace,
|
|
362
362
|
path: f,
|
|
363
363
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
364
364
|
value: Xe(c[u])
|
|
365
365
|
}), r.push({
|
|
366
|
-
op:
|
|
366
|
+
op: z.Replace,
|
|
367
367
|
path: f,
|
|
368
368
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
369
369
|
value: Xe(i[u])
|
|
@@ -372,7 +372,7 @@ function Gr(t, e, n, r, s) {
|
|
|
372
372
|
for (let u = i.length; u < c.length; u += 1) {
|
|
373
373
|
const l = e.concat([u]), f = me(l, s);
|
|
374
374
|
n.push({
|
|
375
|
-
op:
|
|
375
|
+
op: z.Add,
|
|
376
376
|
path: f,
|
|
377
377
|
// If it is a draft, it needs to be deep cloned, and it may also be non-draft.
|
|
378
378
|
value: Xe(c[u])
|
|
@@ -383,7 +383,7 @@ function Gr(t, e, n, r, s) {
|
|
|
383
383
|
if (u) {
|
|
384
384
|
const l = e.concat(["length"]), f = me(l, s);
|
|
385
385
|
r.push({
|
|
386
|
-
op:
|
|
386
|
+
op: z.Replace,
|
|
387
387
|
path: f,
|
|
388
388
|
value: i.length
|
|
389
389
|
});
|
|
@@ -391,7 +391,7 @@ function Gr(t, e, n, r, s) {
|
|
|
391
391
|
for (let l = c.length; i.length < l; l -= 1) {
|
|
392
392
|
const f = e.concat([l - 1]), d = me(f, s);
|
|
393
393
|
r.push({
|
|
394
|
-
op:
|
|
394
|
+
op: z.Remove,
|
|
395
395
|
path: d
|
|
396
396
|
});
|
|
397
397
|
}
|
|
@@ -399,11 +399,11 @@ function Gr(t, e, n, r, s) {
|
|
|
399
399
|
}
|
|
400
400
|
function Hr({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
|
|
401
401
|
n.forEach((a, c) => {
|
|
402
|
-
const u =
|
|
403
|
-
if (
|
|
402
|
+
const u = ge(t, c), l = Xe(ge(e, c)), f = a ? Ke(t, c) ? z.Replace : z.Add : z.Remove;
|
|
403
|
+
if (ye(u, l) && f === z.Replace)
|
|
404
404
|
return;
|
|
405
405
|
const d = r.concat(c), p = me(d, o);
|
|
406
|
-
s.push(f ===
|
|
406
|
+
s.push(f === z.Remove ? { op: f, path: p } : { op: f, path: p, value: l }), i.push(f === z.Add ? { op: z.Remove, path: p } : f === z.Remove ? { op: z.Add, path: p, value: u } : { op: z.Replace, path: p, value: u });
|
|
407
407
|
});
|
|
408
408
|
}
|
|
409
409
|
function Jr({ original: t, copy: e }, n, r, s, i) {
|
|
@@ -412,11 +412,11 @@ function Jr({ original: t, copy: e }, n, r, s, i) {
|
|
|
412
412
|
if (!e.has(a)) {
|
|
413
413
|
const c = n.concat([o]), u = me(c, i);
|
|
414
414
|
r.push({
|
|
415
|
-
op:
|
|
415
|
+
op: z.Remove,
|
|
416
416
|
path: u,
|
|
417
417
|
value: a
|
|
418
418
|
}), s.unshift({
|
|
419
|
-
op:
|
|
419
|
+
op: z.Add,
|
|
420
420
|
path: u,
|
|
421
421
|
value: a
|
|
422
422
|
});
|
|
@@ -426,11 +426,11 @@ function Jr({ original: t, copy: e }, n, r, s, i) {
|
|
|
426
426
|
if (!t.has(a)) {
|
|
427
427
|
const c = n.concat([o]), u = me(c, i);
|
|
428
428
|
r.push({
|
|
429
|
-
op:
|
|
429
|
+
op: z.Add,
|
|
430
430
|
path: u,
|
|
431
431
|
value: a
|
|
432
432
|
}), s.unshift({
|
|
433
|
-
op:
|
|
433
|
+
op: z.Remove,
|
|
434
434
|
path: u,
|
|
435
435
|
value: a
|
|
436
436
|
});
|
|
@@ -451,44 +451,44 @@ function ze(t, e, n, r) {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
const nt = (t, e, n = !1) => {
|
|
454
|
-
if (typeof t == "object" && t !== null && (!
|
|
454
|
+
if (typeof t == "object" && t !== null && (!ue(t, e) || n))
|
|
455
455
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
456
456
|
}, xt = {
|
|
457
457
|
get size() {
|
|
458
|
-
return
|
|
458
|
+
return ie(E(this)).size;
|
|
459
459
|
},
|
|
460
460
|
has(t) {
|
|
461
|
-
return
|
|
461
|
+
return ie(E(this)).has(t);
|
|
462
462
|
},
|
|
463
463
|
set(t, e) {
|
|
464
|
-
const n =
|
|
465
|
-
return (!r.has(t) || !
|
|
464
|
+
const n = E(this), r = ie(n);
|
|
465
|
+
return (!r.has(t) || !ye(r.get(t), e)) && (X(n), de(n), n.assignedMap.set(t, !0), n.copy.set(t, e), Xt(n, t, e, ze)), this;
|
|
466
466
|
},
|
|
467
467
|
delete(t) {
|
|
468
468
|
if (!this.has(t))
|
|
469
469
|
return !1;
|
|
470
|
-
const e =
|
|
471
|
-
return
|
|
470
|
+
const e = E(this);
|
|
471
|
+
return X(e), de(e), e.original.has(t) ? e.assignedMap.set(t, !1) : e.assignedMap.delete(t), e.copy.delete(t), !0;
|
|
472
472
|
},
|
|
473
473
|
clear() {
|
|
474
|
-
const t =
|
|
474
|
+
const t = E(this);
|
|
475
475
|
if (this.size) {
|
|
476
|
-
|
|
476
|
+
X(t), de(t), t.assignedMap = /* @__PURE__ */ new Map();
|
|
477
477
|
for (const [e] of t.original)
|
|
478
478
|
t.assignedMap.set(e, !1);
|
|
479
479
|
t.copy.clear();
|
|
480
480
|
}
|
|
481
481
|
},
|
|
482
482
|
forEach(t, e) {
|
|
483
|
-
const n =
|
|
484
|
-
|
|
483
|
+
const n = E(this);
|
|
484
|
+
ie(n).forEach((r, s) => {
|
|
485
485
|
t.call(e, this.get(s), s, this);
|
|
486
486
|
});
|
|
487
487
|
},
|
|
488
488
|
get(t) {
|
|
489
489
|
var e, n;
|
|
490
|
-
const r =
|
|
491
|
-
if (r.options.strict && nt(s, r.options, i), i || r.finalized || !
|
|
490
|
+
const r = E(this), s = ie(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, oe)) === oe.mutable;
|
|
491
|
+
if (r.options.strict && nt(s, r.options, i), i || r.finalized || !ue(s, r.options) || s !== r.original.get(t))
|
|
492
492
|
return s;
|
|
493
493
|
const o = Gt.createDraft({
|
|
494
494
|
original: s,
|
|
@@ -497,10 +497,10 @@ const nt = (t, e, n = !1) => {
|
|
|
497
497
|
finalities: r.finalities,
|
|
498
498
|
options: r.options
|
|
499
499
|
});
|
|
500
|
-
return
|
|
500
|
+
return X(r), r.copy.set(t, o), o;
|
|
501
501
|
},
|
|
502
502
|
keys() {
|
|
503
|
-
return
|
|
503
|
+
return ie(E(this)).keys();
|
|
504
504
|
},
|
|
505
505
|
values() {
|
|
506
506
|
const t = this.keys();
|
|
@@ -541,8 +541,8 @@ const nt = (t, e, n = !1) => {
|
|
|
541
541
|
return i;
|
|
542
542
|
const o = i.value;
|
|
543
543
|
let a = t.setMap.get(o);
|
|
544
|
-
const c =
|
|
545
|
-
if (t.options.strict && nt(o, t.options, u), !u && !c &&
|
|
544
|
+
const c = E(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, oe)) === oe.mutable;
|
|
545
|
+
if (t.options.strict && nt(o, t.options, u), !u && !c && ue(o, t.options) && !t.finalized && t.original.has(o)) {
|
|
546
546
|
const l = Gt.createDraft({
|
|
547
547
|
original: o,
|
|
548
548
|
parentDraft: t,
|
|
@@ -558,40 +558,40 @@ const nt = (t, e, n = !1) => {
|
|
|
558
558
|
};
|
|
559
559
|
}, rt = {
|
|
560
560
|
get size() {
|
|
561
|
-
return
|
|
561
|
+
return E(this).setMap.size;
|
|
562
562
|
},
|
|
563
563
|
has(t) {
|
|
564
|
-
const e =
|
|
564
|
+
const e = E(this);
|
|
565
565
|
if (e.setMap.has(t))
|
|
566
566
|
return !0;
|
|
567
|
-
|
|
568
|
-
const n =
|
|
567
|
+
X(e);
|
|
568
|
+
const n = E(t);
|
|
569
569
|
return !!(n && e.setMap.has(n.original));
|
|
570
570
|
},
|
|
571
571
|
add(t) {
|
|
572
|
-
const e =
|
|
573
|
-
return this.has(t) || (
|
|
572
|
+
const e = E(this);
|
|
573
|
+
return this.has(t) || (X(e), de(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), Xt(e, t, t, ze)), this;
|
|
574
574
|
},
|
|
575
575
|
delete(t) {
|
|
576
576
|
if (!this.has(t))
|
|
577
577
|
return !1;
|
|
578
|
-
const e =
|
|
579
|
-
|
|
580
|
-
const n =
|
|
578
|
+
const e = E(this);
|
|
579
|
+
X(e), de(e);
|
|
580
|
+
const n = E(t);
|
|
581
581
|
return n && e.setMap.has(n.original) ? (e.assignedMap.set(n.original, !1), e.setMap.delete(n.original)) : (!n && e.setMap.has(t) ? e.assignedMap.set(t, !1) : e.assignedMap.delete(t), e.setMap.delete(t));
|
|
582
582
|
},
|
|
583
583
|
clear() {
|
|
584
584
|
if (!this.size)
|
|
585
585
|
return;
|
|
586
|
-
const t =
|
|
587
|
-
|
|
586
|
+
const t = E(this);
|
|
587
|
+
X(t), de(t);
|
|
588
588
|
for (const e of t.original)
|
|
589
589
|
t.assignedMap.set(e, !1);
|
|
590
590
|
t.setMap.clear();
|
|
591
591
|
},
|
|
592
592
|
values() {
|
|
593
|
-
const t =
|
|
594
|
-
|
|
593
|
+
const t = E(this);
|
|
594
|
+
X(t);
|
|
595
595
|
const e = t.setMap.keys();
|
|
596
596
|
return {
|
|
597
597
|
[Symbol.iterator]: () => this.values(),
|
|
@@ -599,8 +599,8 @@ const nt = (t, e, n = !1) => {
|
|
|
599
599
|
};
|
|
600
600
|
},
|
|
601
601
|
entries() {
|
|
602
|
-
const t =
|
|
603
|
-
|
|
602
|
+
const t = E(this);
|
|
603
|
+
X(t);
|
|
604
604
|
const e = t.setMap.keys();
|
|
605
605
|
return {
|
|
606
606
|
[Symbol.iterator]: () => this.entries(),
|
|
@@ -656,10 +656,10 @@ const Zr = Reflect.ownKeys(rt), Jn = /* @__PURE__ */ new WeakSet(), Yn = {
|
|
|
656
656
|
let o;
|
|
657
657
|
if (t.options.mark) {
|
|
658
658
|
const u = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
|
|
659
|
-
if (o = t.options.mark(u,
|
|
659
|
+
if (o = t.options.mark(u, oe), o === oe.mutable)
|
|
660
660
|
return t.options.strict && nt(u, t.options, !0), u;
|
|
661
661
|
}
|
|
662
|
-
const a =
|
|
662
|
+
const a = ie(t);
|
|
663
663
|
if (a instanceof Map && Yr.includes(e)) {
|
|
664
664
|
if (e === "size")
|
|
665
665
|
return Object.getOwnPropertyDescriptor(xt, "size").get.call(t.proxy);
|
|
@@ -682,18 +682,18 @@ const Zr = Reflect.ownKeys(rt), Jn = /* @__PURE__ */ new WeakSet(), Yn = {
|
|
|
682
682
|
) : void 0;
|
|
683
683
|
}
|
|
684
684
|
const c = a[e];
|
|
685
|
-
if (t.options.strict && nt(c, t.options), t.finalized || !
|
|
685
|
+
if (t.options.strict && nt(c, t.options), t.finalized || !ue(c, t.options))
|
|
686
686
|
return c;
|
|
687
|
-
if (c ===
|
|
688
|
-
if (
|
|
687
|
+
if (c === St(t.original, e)) {
|
|
688
|
+
if (X(t), t.copy[e] = en({
|
|
689
689
|
original: t.original[e],
|
|
690
690
|
parentDraft: t,
|
|
691
691
|
key: t.type === 1 ? Number(e) : e,
|
|
692
692
|
finalities: t.finalities,
|
|
693
693
|
options: t.options
|
|
694
694
|
}), typeof o == "function") {
|
|
695
|
-
const u =
|
|
696
|
-
return
|
|
695
|
+
const u = E(t.copy[e]);
|
|
696
|
+
return X(u), de(u), u.copy;
|
|
697
697
|
}
|
|
698
698
|
return t.copy[e];
|
|
699
699
|
}
|
|
@@ -706,20 +706,20 @@ const Zr = Reflect.ownKeys(rt), Jn = /* @__PURE__ */ new WeakSet(), Yn = {
|
|
|
706
706
|
let s;
|
|
707
707
|
if (t.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
|
|
708
708
|
throw new Error("Only supports setting array indices and the 'length' property.");
|
|
709
|
-
const i = ln(
|
|
709
|
+
const i = ln(ie(t), e);
|
|
710
710
|
if (i != null && i.set)
|
|
711
711
|
return i.set.call(t.proxy, n), !0;
|
|
712
|
-
const o =
|
|
713
|
-
return a &&
|
|
712
|
+
const o = St(ie(t), e), a = E(o);
|
|
713
|
+
return a && ye(a.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (ye(n, o) && (n !== void 0 || Ke(t.original, e)) || (X(t), de(t), Ke(t.original, e) && ye(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Xt(t, e, n, ze)), !0);
|
|
714
714
|
},
|
|
715
715
|
has(t, e) {
|
|
716
|
-
return e in
|
|
716
|
+
return e in ie(t);
|
|
717
717
|
},
|
|
718
718
|
ownKeys(t) {
|
|
719
|
-
return Reflect.ownKeys(
|
|
719
|
+
return Reflect.ownKeys(ie(t));
|
|
720
720
|
},
|
|
721
721
|
getOwnPropertyDescriptor(t, e) {
|
|
722
|
-
const n =
|
|
722
|
+
const n = ie(t), r = Reflect.getOwnPropertyDescriptor(n, e);
|
|
723
723
|
return r && {
|
|
724
724
|
writable: !0,
|
|
725
725
|
configurable: t.type !== 1 || e !== "length",
|
|
@@ -738,7 +738,7 @@ const Zr = Reflect.ownKeys(rt), Jn = /* @__PURE__ */ new WeakSet(), Yn = {
|
|
|
738
738
|
},
|
|
739
739
|
deleteProperty(t, e) {
|
|
740
740
|
var n;
|
|
741
|
-
return t.type === 1 ? Yn.set.call(this, t, e, void 0, t.proxy) : (
|
|
741
|
+
return t.type === 1 ? Yn.set.call(this, t, e, void 0, t.proxy) : (St(t.original, e) !== void 0 || e in t.original ? (X(t), de(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
|
|
742
742
|
}
|
|
743
743
|
};
|
|
744
744
|
function en(t) {
|
|
@@ -760,19 +760,19 @@ function en(t) {
|
|
|
760
760
|
const l = n;
|
|
761
761
|
l.finalities.draft.push((f, d) => {
|
|
762
762
|
var p, y;
|
|
763
|
-
const
|
|
763
|
+
const b = E(c);
|
|
764
764
|
let w = l.type === 3 ? l.setMap : l.copy;
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
767
|
-
let
|
|
768
|
-
|
|
765
|
+
const _ = ge(w, r), g = E(_);
|
|
766
|
+
if (g) {
|
|
767
|
+
let m = g.original;
|
|
768
|
+
g.operated && (m = Yt(_)), jt(g), $t(g, ze, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(m, g.original)), We(w, r, m);
|
|
769
769
|
}
|
|
770
|
-
(y =
|
|
771
|
-
|
|
770
|
+
(y = b.callbacks) === null || y === void 0 || y.forEach((m) => {
|
|
771
|
+
m(f, d);
|
|
772
772
|
});
|
|
773
773
|
});
|
|
774
774
|
} else {
|
|
775
|
-
const l =
|
|
775
|
+
const l = E(c);
|
|
776
776
|
l.finalities.draft.push((f, d) => {
|
|
777
777
|
jt(l), $t(l, ze, f, d);
|
|
778
778
|
});
|
|
@@ -782,15 +782,15 @@ function en(t) {
|
|
|
782
782
|
Gt.createDraft = en;
|
|
783
783
|
function Xr(t, e, n, r, s) {
|
|
784
784
|
var i;
|
|
785
|
-
const o =
|
|
785
|
+
const o = E(t), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : t, c = !!e.length;
|
|
786
786
|
if (o != null && o.operated)
|
|
787
787
|
for (; o.finalities.draft.length > 0; )
|
|
788
788
|
o.finalities.draft.pop()(n, r);
|
|
789
789
|
const u = c ? e[0] : o ? o.operated ? o.copy : o.original : t;
|
|
790
790
|
return o && Mt(o), s && Ce(u, u, o == null ? void 0 : o.options.updatedValues), [
|
|
791
791
|
u,
|
|
792
|
-
n && c ? [{ op:
|
|
793
|
-
r && c ? [{ op:
|
|
792
|
+
n && c ? [{ op: z.Replace, path: [], value: e[0] }] : n,
|
|
793
|
+
r && c ? [{ op: z.Replace, path: [], value: a }] : r
|
|
794
794
|
];
|
|
795
795
|
}
|
|
796
796
|
function es(t, e) {
|
|
@@ -802,7 +802,7 @@ function es(t, e) {
|
|
|
802
802
|
};
|
|
803
803
|
let s, i;
|
|
804
804
|
e.enablePatches && (s = [], i = []);
|
|
805
|
-
const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t,
|
|
805
|
+
const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, oe)) === oe.mutable || !ue(t, e) ? t : en({
|
|
806
806
|
original: t,
|
|
807
807
|
parentDraft: null,
|
|
808
808
|
finalities: r,
|
|
@@ -819,7 +819,7 @@ function es(t, e) {
|
|
|
819
819
|
function Rt(t) {
|
|
820
820
|
const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: s = !0 } = t;
|
|
821
821
|
Zt(n, (i, o, a) => {
|
|
822
|
-
const c =
|
|
822
|
+
const c = E(o);
|
|
823
823
|
if (c && e && c.finalities === e.finalities) {
|
|
824
824
|
t.isContainDraft = !0;
|
|
825
825
|
const u = c.original;
|
|
@@ -833,8 +833,8 @@ function Rt(t) {
|
|
|
833
833
|
}
|
|
834
834
|
function Zn(t) {
|
|
835
835
|
var e;
|
|
836
|
-
const n =
|
|
837
|
-
if (!
|
|
836
|
+
const n = E(t);
|
|
837
|
+
if (!ue(t, n == null ? void 0 : n.options))
|
|
838
838
|
return t;
|
|
839
839
|
const r = ve(t);
|
|
840
840
|
if (n && !n.operated)
|
|
@@ -853,7 +853,7 @@ function Zn(t) {
|
|
|
853
853
|
} else
|
|
854
854
|
s = t;
|
|
855
855
|
if (Zt(s, (o, a) => {
|
|
856
|
-
if (n &&
|
|
856
|
+
if (n && ye(ge(n.original, o), a))
|
|
857
857
|
return;
|
|
858
858
|
const c = Zn(a);
|
|
859
859
|
c !== a && (s === t && i(), We(s, o, c));
|
|
@@ -864,28 +864,28 @@ function Zn(t) {
|
|
|
864
864
|
return s;
|
|
865
865
|
}
|
|
866
866
|
function hn(t) {
|
|
867
|
-
if (!
|
|
867
|
+
if (!Te(t))
|
|
868
868
|
throw new Error(`current() is only used for Draft, parameter: ${t}`);
|
|
869
869
|
return Zn(t);
|
|
870
870
|
}
|
|
871
871
|
const ts = (t) => function e(n, r, s) {
|
|
872
872
|
var i, o, a;
|
|
873
873
|
if (typeof n == "function" && typeof r != "function")
|
|
874
|
-
return function(
|
|
875
|
-
return e(
|
|
874
|
+
return function(S, ...M) {
|
|
875
|
+
return e(S, (O) => n.call(this, O, ...M), r);
|
|
876
876
|
};
|
|
877
877
|
const c = n, u = r;
|
|
878
878
|
let l = s;
|
|
879
879
|
if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
|
|
880
880
|
throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
|
|
881
881
|
l = Object.assign(Object.assign({}, t), l);
|
|
882
|
-
const f =
|
|
883
|
-
for (const
|
|
884
|
-
if (typeof
|
|
885
|
-
throw new Error(`Invalid mark: ${
|
|
886
|
-
const
|
|
887
|
-
if (
|
|
888
|
-
return
|
|
882
|
+
const f = Te(c) ? hn(c) : c, d = Array.isArray(l.mark) ? (S, M) => {
|
|
883
|
+
for (const O of l.mark) {
|
|
884
|
+
if (typeof O != "function")
|
|
885
|
+
throw new Error(`Invalid mark: ${O}, 'mark' should be a function.`);
|
|
886
|
+
const k = O(S, M);
|
|
887
|
+
if (k)
|
|
888
|
+
return k;
|
|
889
889
|
}
|
|
890
890
|
} : l.mark, p = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, y = (o = l.strict) !== null && o !== void 0 ? o : !1, w = {
|
|
891
891
|
enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
|
|
@@ -893,50 +893,50 @@ const ts = (t) => function e(n, r, s) {
|
|
|
893
893
|
strict: y,
|
|
894
894
|
enablePatches: p
|
|
895
895
|
};
|
|
896
|
-
if (!
|
|
896
|
+
if (!ue(f, w) && typeof f == "object" && f !== null)
|
|
897
897
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
898
|
-
const [
|
|
898
|
+
const [_, g] = es(f, w);
|
|
899
899
|
if (typeof r != "function") {
|
|
900
|
-
if (!
|
|
900
|
+
if (!ue(f, w))
|
|
901
901
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
902
|
-
return [
|
|
902
|
+
return [_, g];
|
|
903
903
|
}
|
|
904
|
-
let
|
|
904
|
+
let m;
|
|
905
905
|
try {
|
|
906
|
-
|
|
907
|
-
} catch (
|
|
908
|
-
throw Mt(
|
|
909
|
-
}
|
|
910
|
-
const
|
|
911
|
-
const
|
|
912
|
-
if (!
|
|
913
|
-
if (
|
|
906
|
+
m = u(_);
|
|
907
|
+
} catch (S) {
|
|
908
|
+
throw Mt(E(_)), S;
|
|
909
|
+
}
|
|
910
|
+
const I = (S) => {
|
|
911
|
+
const M = E(_);
|
|
912
|
+
if (!Te(S)) {
|
|
913
|
+
if (S !== void 0 && !ye(S, _) && (M != null && M.operated))
|
|
914
914
|
throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
|
|
915
|
-
const
|
|
916
|
-
if (
|
|
917
|
-
const
|
|
918
|
-
return w.strict && typeof
|
|
919
|
-
rootDraft:
|
|
920
|
-
value:
|
|
915
|
+
const k = S == null ? void 0 : S[zr];
|
|
916
|
+
if (k) {
|
|
917
|
+
const F = k[0];
|
|
918
|
+
return w.strict && typeof S == "object" && S !== null && Rt({
|
|
919
|
+
rootDraft: M,
|
|
920
|
+
value: S,
|
|
921
921
|
useRawReturn: !0
|
|
922
|
-
}),
|
|
922
|
+
}), g([F]);
|
|
923
923
|
}
|
|
924
|
-
if (
|
|
925
|
-
return typeof
|
|
926
|
-
}
|
|
927
|
-
if (
|
|
928
|
-
return
|
|
929
|
-
const
|
|
930
|
-
if (w ===
|
|
931
|
-
if (
|
|
924
|
+
if (S !== void 0)
|
|
925
|
+
return typeof S == "object" && S !== null && Rt({ rootDraft: M, value: S }), g([S]);
|
|
926
|
+
}
|
|
927
|
+
if (S === _ || S === void 0)
|
|
928
|
+
return g([]);
|
|
929
|
+
const O = E(S);
|
|
930
|
+
if (w === O.options) {
|
|
931
|
+
if (O.operated)
|
|
932
932
|
throw new Error("Cannot return a modified child draft.");
|
|
933
|
-
return
|
|
933
|
+
return g([hn(S)]);
|
|
934
934
|
}
|
|
935
|
-
return
|
|
935
|
+
return g([S]);
|
|
936
936
|
};
|
|
937
|
-
return
|
|
938
|
-
throw Mt(
|
|
939
|
-
}) :
|
|
937
|
+
return m instanceof Promise ? m.then(I, (S) => {
|
|
938
|
+
throw Mt(E(_)), S;
|
|
939
|
+
}) : I(m);
|
|
940
940
|
}, st = ts();
|
|
941
941
|
Object.prototype.constructor.toString();
|
|
942
942
|
function Xn(t, e) {
|
|
@@ -1336,7 +1336,7 @@ function dt(t) {
|
|
|
1336
1336
|
throw new Error(`Invalid date value \`${t}\`. Expected a date, number, or string, got type ${typeof t}.`);
|
|
1337
1337
|
}
|
|
1338
1338
|
}
|
|
1339
|
-
class
|
|
1339
|
+
class Se {
|
|
1340
1340
|
constructor(e, n) {
|
|
1341
1341
|
h(this, "attrs");
|
|
1342
1342
|
h(this, "linkIndex");
|
|
@@ -1369,7 +1369,7 @@ class Te {
|
|
|
1369
1369
|
for (const e of Object.values(this.attrs))
|
|
1370
1370
|
if (rn(e)) {
|
|
1371
1371
|
const [n, r, s] = e["forward-identity"];
|
|
1372
|
-
|
|
1372
|
+
te(this.blobAttrs, [r, s], e);
|
|
1373
1373
|
}
|
|
1374
1374
|
return this._blobAttrs;
|
|
1375
1375
|
}
|
|
@@ -1380,7 +1380,7 @@ class Te {
|
|
|
1380
1380
|
for (const e of Object.values(this.attrs))
|
|
1381
1381
|
if (e["primary?"]) {
|
|
1382
1382
|
const [n, r] = e["forward-identity"];
|
|
1383
|
-
|
|
1383
|
+
te(this._primaryKeys, [r], e);
|
|
1384
1384
|
}
|
|
1385
1385
|
return this._primaryKeys;
|
|
1386
1386
|
}
|
|
@@ -1390,7 +1390,7 @@ class Te {
|
|
|
1390
1390
|
this._forwardIdents = /* @__PURE__ */ new Map();
|
|
1391
1391
|
for (const e of Object.values(this.attrs)) {
|
|
1392
1392
|
const n = e["forward-identity"], [r, s, i] = n;
|
|
1393
|
-
|
|
1393
|
+
te(this._forwardIdents, [s, i], e);
|
|
1394
1394
|
}
|
|
1395
1395
|
return this._forwardIdents;
|
|
1396
1396
|
}
|
|
@@ -1402,7 +1402,7 @@ class Te {
|
|
|
1402
1402
|
const n = e["reverse-identity"];
|
|
1403
1403
|
if (n) {
|
|
1404
1404
|
const [r, s, i] = n;
|
|
1405
|
-
|
|
1405
|
+
te(this._revIdents, [s, i], e);
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
1408
|
return this._revIdents;
|
|
@@ -1411,7 +1411,7 @@ class Te {
|
|
|
1411
1411
|
return { attrs: this.attrs, linkIndex: this.linkIndex };
|
|
1412
1412
|
}
|
|
1413
1413
|
}
|
|
1414
|
-
function
|
|
1414
|
+
function Ss(t) {
|
|
1415
1415
|
return t.cardinality === "one";
|
|
1416
1416
|
}
|
|
1417
1417
|
function nn(t) {
|
|
@@ -1423,7 +1423,7 @@ function rn(t) {
|
|
|
1423
1423
|
function $e(t, e) {
|
|
1424
1424
|
return e.reduce((n, r) => n && n.get(r), t);
|
|
1425
1425
|
}
|
|
1426
|
-
function
|
|
1426
|
+
function ce(t, e) {
|
|
1427
1427
|
if (e.length === 0)
|
|
1428
1428
|
throw new Error("path must have at least one element");
|
|
1429
1429
|
if (e.length === 1) {
|
|
@@ -1431,9 +1431,9 @@ function oe(t, e) {
|
|
|
1431
1431
|
return;
|
|
1432
1432
|
}
|
|
1433
1433
|
const [n, ...r] = e;
|
|
1434
|
-
t.has(n) &&
|
|
1434
|
+
t.has(n) && ce(t.get(n), r);
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1436
|
+
function te(t, e, n) {
|
|
1437
1437
|
let r = t;
|
|
1438
1438
|
const s = e.length - 1;
|
|
1439
1439
|
for (let i = 0; i < s; i++) {
|
|
@@ -1452,13 +1452,13 @@ function nr(t, e, n) {
|
|
|
1452
1452
|
console.warn("no such attr", c, a);
|
|
1453
1453
|
continue;
|
|
1454
1454
|
}
|
|
1455
|
-
l["checked-data-type"] === "date" && n && (u = dt(u), o[2] = u), nn(l) &&
|
|
1455
|
+
l["checked-data-type"] === "date" && n && (u = dt(u), o[2] = u), nn(l) && te(i, [u, c, a], o), te(r, [a, c, u], o), te(s, [c, a, u], o);
|
|
1456
1456
|
}
|
|
1457
1457
|
return { eav: r, aev: s, vae: i };
|
|
1458
1458
|
}
|
|
1459
1459
|
function rr(t) {
|
|
1460
1460
|
return {
|
|
1461
|
-
triples:
|
|
1461
|
+
triples: ne(t.eav, 3),
|
|
1462
1462
|
cardinalityInference: t.cardinalityInference,
|
|
1463
1463
|
useDateObjects: t.useDateObjects,
|
|
1464
1464
|
version: 1
|
|
@@ -1469,11 +1469,11 @@ function sr(t, e) {
|
|
|
1469
1469
|
}
|
|
1470
1470
|
function ir(t, e) {
|
|
1471
1471
|
if (t)
|
|
1472
|
-
return new
|
|
1472
|
+
return new Se(t.attrs, t.linkIndex);
|
|
1473
1473
|
if (e && "__type" in e)
|
|
1474
|
-
return new
|
|
1474
|
+
return new Se(e.attrs, e.linkIndex);
|
|
1475
1475
|
}
|
|
1476
|
-
function
|
|
1476
|
+
function Ts(t, e) {
|
|
1477
1477
|
return $e(t.eav, [e]) !== void 0;
|
|
1478
1478
|
}
|
|
1479
1479
|
function Ue(t, e, n, r) {
|
|
@@ -1487,7 +1487,7 @@ function Ve(t, e) {
|
|
|
1487
1487
|
const [o, a] = e[0], c = t.aev.get(o);
|
|
1488
1488
|
if (!c)
|
|
1489
1489
|
return null;
|
|
1490
|
-
n = (s =
|
|
1490
|
+
n = (s = ne(c, 2).find((l) => l[2] === a)) == null ? void 0 : s[0];
|
|
1491
1491
|
} else
|
|
1492
1492
|
n = e[0];
|
|
1493
1493
|
if (!n)
|
|
@@ -1497,7 +1497,7 @@ function Ve(t, e) {
|
|
|
1497
1497
|
const [o, a] = r, c = t.aev.get(o);
|
|
1498
1498
|
if (!c)
|
|
1499
1499
|
return null;
|
|
1500
|
-
const l = (i =
|
|
1500
|
+
const l = (i = ne(c, 2).find((b) => b[2] === a)) == null ? void 0 : i[0];
|
|
1501
1501
|
if (!l)
|
|
1502
1502
|
return null;
|
|
1503
1503
|
const [f, d, p, ...y] = e;
|
|
@@ -1512,7 +1512,7 @@ function or(t, e, n) {
|
|
|
1512
1512
|
if (!r)
|
|
1513
1513
|
return;
|
|
1514
1514
|
const [s, i, o] = r, a = e.getAttr(i);
|
|
1515
|
-
a && (
|
|
1515
|
+
a && (ce(t.eav, [s, i, o]), ce(t.aev, [i, s, o]), nn(a) && ce(t.vae, [o, i, s]));
|
|
1516
1516
|
}
|
|
1517
1517
|
let vs = 0;
|
|
1518
1518
|
function ar(t, e, n) {
|
|
@@ -1531,7 +1531,7 @@ function cr(t, e, n) {
|
|
|
1531
1531
|
return;
|
|
1532
1532
|
a["checked-data-type"] === "date" && t.useDateObjects && (o = dt(o));
|
|
1533
1533
|
const c = $e(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? ar(t, a, r), l = [s, i, o, u];
|
|
1534
|
-
|
|
1534
|
+
Ss(a) ? (te(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), te(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (te(t.eav, [s, i, o], l), te(t.aev, [i, s, o], l)), nn(a) && te(t.vae, [o, i, s], l);
|
|
1535
1535
|
}
|
|
1536
1536
|
function As(t, e, n) {
|
|
1537
1537
|
var p;
|
|
@@ -1555,7 +1555,7 @@ function As(t, e, n) {
|
|
|
1555
1555
|
f,
|
|
1556
1556
|
ar(t, a, u)
|
|
1557
1557
|
];
|
|
1558
|
-
|
|
1558
|
+
te(t.eav, [s, i], /* @__PURE__ */ new Map([[f, d]])), te(t.aev, [i, s], /* @__PURE__ */ new Map([[f, d]]));
|
|
1559
1559
|
}
|
|
1560
1560
|
function Ut(t, e, n) {
|
|
1561
1561
|
var u, l;
|
|
@@ -1566,23 +1566,23 @@ function Ut(t, e, n) {
|
|
|
1566
1566
|
if (a) {
|
|
1567
1567
|
for (const f of a.keys()) {
|
|
1568
1568
|
const d = e.getAttr(f);
|
|
1569
|
-
d && d["on-delete-reverse"] === "cascade" &&
|
|
1569
|
+
d && d["on-delete-reverse"] === "cascade" && ne(a.get(f), 1).forEach(([p, y, b]) => {
|
|
1570
1570
|
var w;
|
|
1571
|
-
return Ut(t, e, [
|
|
1571
|
+
return Ut(t, e, [b, (w = d["reverse-identity"]) == null ? void 0 : w[1]]);
|
|
1572
1572
|
}), // Fall back to deleting everything if we've rehydrated tx-steps from
|
|
1573
1573
|
// the store that didn't set `etype` in deleteEntity
|
|
1574
1574
|
(!s || // If we don't know about the attr, let's just get rid of it
|
|
1575
1575
|
!d || // Make sure it matches the etype
|
|
1576
|
-
((u = d["forward-identity"]) == null ? void 0 : u[1]) === s) && (
|
|
1576
|
+
((u = d["forward-identity"]) == null ? void 0 : u[1]) === s) && (ce(t.aev, [f, o]), ce(t.eav, [o, f]));
|
|
1577
1577
|
}
|
|
1578
|
-
a.size === 0 &&
|
|
1578
|
+
a.size === 0 && ce(t.eav, [o]);
|
|
1579
1579
|
}
|
|
1580
|
-
const c = t.vae.get(o) &&
|
|
1580
|
+
const c = t.vae.get(o) && ne(t.vae.get(o), 2);
|
|
1581
1581
|
c && c.forEach((f) => {
|
|
1582
|
-
var w,
|
|
1583
|
-
const [d, p, y] = f,
|
|
1584
|
-
(!s || !
|
|
1585
|
-
}), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 &&
|
|
1582
|
+
var w, _, g;
|
|
1583
|
+
const [d, p, y] = f, b = e.getAttr(p);
|
|
1584
|
+
(!s || !b || ((w = b["reverse-identity"]) == null ? void 0 : w[1]) === s) && (ce(t.eav, [d, p, y]), ce(t.aev, [p, d, y]), ce(t.vae, [y, p, d])), b && b["on-delete"] === "cascade" && ((_ = b["reverse-identity"]) == null ? void 0 : _[1]) === s && Ut(t, e, [d, (g = b["forward-identity"]) == null ? void 0 : g[1]]);
|
|
1585
|
+
}), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && ce(t.vae, [o]);
|
|
1586
1586
|
}
|
|
1587
1587
|
function ur(t, e, n) {
|
|
1588
1588
|
const r = nr(e, n, t.useDateObjects);
|
|
@@ -1594,7 +1594,7 @@ function ks(t, [e]) {
|
|
|
1594
1594
|
t.addAttr(e);
|
|
1595
1595
|
}
|
|
1596
1596
|
function lr(t) {
|
|
1597
|
-
return
|
|
1597
|
+
return ne(t.eav, 3);
|
|
1598
1598
|
}
|
|
1599
1599
|
function Os(t, e, [n]) {
|
|
1600
1600
|
if (!e.getAttr(n))
|
|
@@ -1637,7 +1637,7 @@ function Cs(t, e, n) {
|
|
|
1637
1637
|
throw new Error(`unhandled transaction action: ${r}`);
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
|
-
function
|
|
1640
|
+
function ne(t, e, n = []) {
|
|
1641
1641
|
if (!t || e === 0)
|
|
1642
1642
|
return n;
|
|
1643
1643
|
if (e === 1) {
|
|
@@ -1646,7 +1646,7 @@ function ee(t, e, n = []) {
|
|
|
1646
1646
|
return n;
|
|
1647
1647
|
}
|
|
1648
1648
|
for (const r of t.values())
|
|
1649
|
-
|
|
1649
|
+
ne(r, e - 1, n);
|
|
1650
1650
|
return n;
|
|
1651
1651
|
}
|
|
1652
1652
|
function Qe(t, e, n) {
|
|
@@ -1674,7 +1674,7 @@ function Qe(t, e, n) {
|
|
|
1674
1674
|
return r;
|
|
1675
1675
|
}
|
|
1676
1676
|
if (n != null && n.$comparator)
|
|
1677
|
-
return
|
|
1677
|
+
return ne(e, 1).filter(n.$op);
|
|
1678
1678
|
const s = n.in || n.$in || [n];
|
|
1679
1679
|
for (const o of s) {
|
|
1680
1680
|
const a = e.get(o);
|
|
@@ -1691,11 +1691,11 @@ function Ps(t, [e, n, r]) {
|
|
|
1691
1691
|
switch (Es(e, n, r)) {
|
|
1692
1692
|
case "e": {
|
|
1693
1693
|
const a = t.eav.get(e);
|
|
1694
|
-
return
|
|
1694
|
+
return ne(a, 2);
|
|
1695
1695
|
}
|
|
1696
1696
|
case "ea": {
|
|
1697
1697
|
const a = (i = t.eav.get(e)) == null ? void 0 : i.get(n);
|
|
1698
|
-
return
|
|
1698
|
+
return ne(a, 1);
|
|
1699
1699
|
}
|
|
1700
1700
|
case "eav": {
|
|
1701
1701
|
const a = (o = t.eav.get(e)) == null ? void 0 : o.get(n);
|
|
@@ -1712,7 +1712,7 @@ function Ps(t, [e, n, r]) {
|
|
|
1712
1712
|
}
|
|
1713
1713
|
case "a": {
|
|
1714
1714
|
const a = t.aev.get(n);
|
|
1715
|
-
return
|
|
1715
|
+
return ne(a, 2);
|
|
1716
1716
|
}
|
|
1717
1717
|
case "av": {
|
|
1718
1718
|
const a = t.aev.get(n);
|
|
@@ -1731,7 +1731,7 @@ function Ps(t, [e, n, r]) {
|
|
|
1731
1731
|
return a;
|
|
1732
1732
|
}
|
|
1733
1733
|
default:
|
|
1734
|
-
return
|
|
1734
|
+
return ne(t.eav, 3);
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
1737
|
function Ms(t, e, n) {
|
|
@@ -1740,13 +1740,13 @@ function Ms(t, e, n) {
|
|
|
1740
1740
|
if (!e)
|
|
1741
1741
|
return r;
|
|
1742
1742
|
for (const [i, o] of e.entries()) {
|
|
1743
|
-
const a = (s = t.eav.get(n)) == null ? void 0 : s.get(o.id), c =
|
|
1743
|
+
const a = (s = t.eav.get(n)) == null ? void 0 : s.get(o.id), c = ne(a, 1);
|
|
1744
1744
|
for (const u of c)
|
|
1745
1745
|
r[i] = u[2];
|
|
1746
1746
|
}
|
|
1747
1747
|
return r;
|
|
1748
1748
|
}
|
|
1749
|
-
function
|
|
1749
|
+
function W(t, e, n) {
|
|
1750
1750
|
var r;
|
|
1751
1751
|
return (r = t.forwardIdents.get(e)) == null ? void 0 : r.get(n);
|
|
1752
1752
|
}
|
|
@@ -1795,7 +1795,7 @@ function xs(t, e, n) {
|
|
|
1795
1795
|
});
|
|
1796
1796
|
}, {
|
|
1797
1797
|
mark: (s) => {
|
|
1798
|
-
if (s instanceof
|
|
1798
|
+
if (s instanceof Se)
|
|
1799
1799
|
return "immutable";
|
|
1800
1800
|
}
|
|
1801
1801
|
});
|
|
@@ -1866,21 +1866,21 @@ const Vs = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a
|
|
|
1866
1866
|
function Me(t) {
|
|
1867
1867
|
return typeof t == "string" && Vs.test(t);
|
|
1868
1868
|
}
|
|
1869
|
-
const
|
|
1869
|
+
const B = [];
|
|
1870
1870
|
for (let t = 0; t < 256; ++t)
|
|
1871
|
-
|
|
1871
|
+
B.push((t + 256).toString(16).slice(1));
|
|
1872
1872
|
function Qs(t, e = 0) {
|
|
1873
|
-
return (
|
|
1873
|
+
return (B[t[e + 0]] + B[t[e + 1]] + B[t[e + 2]] + B[t[e + 3]] + "-" + B[t[e + 4]] + B[t[e + 5]] + "-" + B[t[e + 6]] + B[t[e + 7]] + "-" + B[t[e + 8]] + B[t[e + 9]] + "-" + B[t[e + 10]] + B[t[e + 11]] + B[t[e + 12]] + B[t[e + 13]] + B[t[e + 14]] + B[t[e + 15]]).toLowerCase();
|
|
1874
1874
|
}
|
|
1875
|
-
let
|
|
1875
|
+
let Tt;
|
|
1876
1876
|
const Bs = new Uint8Array(16);
|
|
1877
1877
|
function Gs() {
|
|
1878
|
-
if (!
|
|
1878
|
+
if (!Tt) {
|
|
1879
1879
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1880
1880
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1881
|
-
|
|
1881
|
+
Tt = crypto.getRandomValues.bind(crypto);
|
|
1882
1882
|
}
|
|
1883
|
-
return
|
|
1883
|
+
return Tt(Bs);
|
|
1884
1884
|
}
|
|
1885
1885
|
const Hs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), wn = { randomUUID: Hs };
|
|
1886
1886
|
function Js(t, e, n) {
|
|
@@ -1911,7 +1911,7 @@ function Ys(t, e) {
|
|
|
1911
1911
|
function Zs(t, e) {
|
|
1912
1912
|
return Ys(_n(t), _n(e));
|
|
1913
1913
|
}
|
|
1914
|
-
function
|
|
1914
|
+
function N() {
|
|
1915
1915
|
return Js();
|
|
1916
1916
|
}
|
|
1917
1917
|
function Xs(t, e) {
|
|
@@ -1960,7 +1960,7 @@ function oi(t, e, n) {
|
|
|
1960
1960
|
return t.map((r) => r === e ? n : r);
|
|
1961
1961
|
}
|
|
1962
1962
|
function hr(t, e, n, r, s) {
|
|
1963
|
-
const i =
|
|
1963
|
+
const i = W(e, n, s), o = Ae(e, n, s), a = i || o;
|
|
1964
1964
|
if (!a)
|
|
1965
1965
|
throw new je(`Could not find attr for ${[n, s]}`);
|
|
1966
1966
|
if (a["value-type"] !== "ref")
|
|
@@ -1978,7 +1978,7 @@ function hr(t, e, n, r, s) {
|
|
|
1978
1978
|
];
|
|
1979
1979
|
return [i ? f : u, d, p, a, !!i];
|
|
1980
1980
|
}
|
|
1981
|
-
function
|
|
1981
|
+
function Sn(t, e) {
|
|
1982
1982
|
if (typeof e != "string")
|
|
1983
1983
|
return function(o) {
|
|
1984
1984
|
return !1;
|
|
@@ -2029,7 +2029,7 @@ function ai(t, e) {
|
|
|
2029
2029
|
}
|
|
2030
2030
|
};
|
|
2031
2031
|
if (e.hasOwnProperty("$like")) {
|
|
2032
|
-
const r =
|
|
2032
|
+
const r = Sn(!0, e.$like);
|
|
2033
2033
|
return {
|
|
2034
2034
|
$comparator: !0,
|
|
2035
2035
|
$op: function(i) {
|
|
@@ -2038,7 +2038,7 @@ function ai(t, e) {
|
|
|
2038
2038
|
};
|
|
2039
2039
|
}
|
|
2040
2040
|
if (e.hasOwnProperty("$ilike")) {
|
|
2041
|
-
const r =
|
|
2041
|
+
const r = Sn(!1, e.$ilike);
|
|
2042
2042
|
return {
|
|
2043
2043
|
$comparator: !0,
|
|
2044
2044
|
$op: function(i) {
|
|
@@ -2049,11 +2049,11 @@ function ai(t, e) {
|
|
|
2049
2049
|
return e;
|
|
2050
2050
|
}
|
|
2051
2051
|
function ci(t, e, n, r, s, i) {
|
|
2052
|
-
const o =
|
|
2052
|
+
const o = W(e, n, s), a = Ae(e, n, s), c = o || a;
|
|
2053
2053
|
if (!c)
|
|
2054
2054
|
throw new je(`No attr for etype = ${n} label = ${s}`);
|
|
2055
2055
|
if (i != null && i.hasOwnProperty("$isNull")) {
|
|
2056
|
-
const u =
|
|
2056
|
+
const u = W(e, n, "id");
|
|
2057
2057
|
if (!u)
|
|
2058
2058
|
throw new je(`No attr for etype = ${n} label = id`);
|
|
2059
2059
|
return [
|
|
@@ -2072,8 +2072,8 @@ function ci(t, e, n, r, s, i) {
|
|
|
2072
2072
|
}
|
|
2073
2073
|
function ui(t, e, n, r, s) {
|
|
2074
2074
|
const [i, o, a] = s.reduce((c, u) => {
|
|
2075
|
-
const [l, f, d] = c, [p, y,
|
|
2076
|
-
return [p, y, [...d,
|
|
2075
|
+
const [l, f, d] = c, [p, y, b] = hr(t, e, l, f, u);
|
|
2076
|
+
return [p, y, [...d, b]];
|
|
2077
2077
|
}, [n, r, []]);
|
|
2078
2078
|
return [i, o, a];
|
|
2079
2079
|
}
|
|
@@ -2096,7 +2096,7 @@ function hi(t, e, n) {
|
|
|
2096
2096
|
return e == i ? i : `${i}-${n}`;
|
|
2097
2097
|
};
|
|
2098
2098
|
}
|
|
2099
|
-
function
|
|
2099
|
+
function Tn(t, e, n, r, s, i) {
|
|
2100
2100
|
const o = t(r, s), a = i.map((c, u) => {
|
|
2101
2101
|
const l = hi(t, o, u);
|
|
2102
2102
|
return pr(l, n, r, s, c);
|
|
@@ -2117,9 +2117,9 @@ function vn(t, e, n, r, s) {
|
|
|
2117
2117
|
function pr(t, e, n, r, s) {
|
|
2118
2118
|
return Object.entries(s).flatMap(([i, o]) => {
|
|
2119
2119
|
if (fi([i, o]))
|
|
2120
|
-
return
|
|
2120
|
+
return Tn(t, "or", e, n, r, o);
|
|
2121
2121
|
if (di([i, o]))
|
|
2122
|
-
return
|
|
2122
|
+
return Tn(t, "and", e, n, r, o);
|
|
2123
2123
|
if (i === "$entityIdStartsWith")
|
|
2124
2124
|
return [];
|
|
2125
2125
|
const a = i.split(".");
|
|
@@ -2159,20 +2159,20 @@ function wi(t, e, n, { etype: r, level: s, form: i }, o) {
|
|
|
2159
2159
|
const a = Object.keys(i).filter((c) => c !== "$");
|
|
2160
2160
|
return a.length ? Object.entries(o).map(function([u, l]) {
|
|
2161
2161
|
return a.map(function(p) {
|
|
2162
|
-
var
|
|
2163
|
-
const y = !!(e.cardinalityInference && ((
|
|
2162
|
+
var b, w, _;
|
|
2163
|
+
const y = !!(e.cardinalityInference && ((_ = (w = (b = n.linkIndex) == null ? void 0 : b[r]) == null ? void 0 : w[p]) != null && _.isSingular));
|
|
2164
2164
|
try {
|
|
2165
|
-
const [
|
|
2166
|
-
etype:
|
|
2167
|
-
level:
|
|
2165
|
+
const [g, m, I] = gi(t, n, r, s, p, u), S = gr(e, n, {
|
|
2166
|
+
etype: g,
|
|
2167
|
+
level: m,
|
|
2168
2168
|
form: i[p],
|
|
2169
|
-
join:
|
|
2170
|
-
}),
|
|
2171
|
-
return { [p]:
|
|
2172
|
-
} catch (
|
|
2173
|
-
if (
|
|
2169
|
+
join: I
|
|
2170
|
+
}), M = y ? S[0] : S;
|
|
2171
|
+
return { [p]: M };
|
|
2172
|
+
} catch (g) {
|
|
2173
|
+
if (g instanceof je)
|
|
2174
2174
|
return { [p]: y ? void 0 : [] };
|
|
2175
|
-
throw
|
|
2175
|
+
throw g;
|
|
2176
2176
|
}
|
|
2177
2177
|
}).reduce(function(p, y) {
|
|
2178
2178
|
return { ...p, ...y };
|
|
@@ -2203,21 +2203,21 @@ function mi(t, e, n, r) {
|
|
|
2203
2203
|
const s = yr(t, e, r);
|
|
2204
2204
|
return n === "desc" ? s > 0 : s < 0;
|
|
2205
2205
|
}
|
|
2206
|
-
function
|
|
2206
|
+
function Si(t, e, n, r) {
|
|
2207
2207
|
const s = yr(t, e, r);
|
|
2208
2208
|
return n === "desc" ? s < 0 : s > 0;
|
|
2209
2209
|
}
|
|
2210
|
-
function
|
|
2210
|
+
function Ti(t, e) {
|
|
2211
2211
|
const n = e[1];
|
|
2212
2212
|
return t.getAttr(n);
|
|
2213
2213
|
}
|
|
2214
2214
|
function vi(t, e, n) {
|
|
2215
2215
|
const r = Object.keys(n)[0];
|
|
2216
|
-
return
|
|
2216
|
+
return W(t, e, r);
|
|
2217
2217
|
}
|
|
2218
2218
|
function Ai(t, e, n, r) {
|
|
2219
2219
|
if (n)
|
|
2220
|
-
return
|
|
2220
|
+
return Ti(t, n);
|
|
2221
2221
|
if (r)
|
|
2222
2222
|
return vi(t, e, r);
|
|
2223
2223
|
}
|
|
@@ -2227,41 +2227,41 @@ function ki(t, e, n) {
|
|
|
2227
2227
|
return js(t, e);
|
|
2228
2228
|
const r = /* @__PURE__ */ new Map();
|
|
2229
2229
|
for (const o of n.fields) {
|
|
2230
|
-
const a =
|
|
2230
|
+
const a = W(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
|
|
2231
2231
|
c && rn(a) && r.set(c, a);
|
|
2232
2232
|
}
|
|
2233
2233
|
if (!r.has("id")) {
|
|
2234
|
-
const o =
|
|
2234
|
+
const o = W(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
|
|
2235
2235
|
a && r.set(a, o);
|
|
2236
2236
|
}
|
|
2237
2237
|
return r;
|
|
2238
2238
|
}
|
|
2239
2239
|
function Oi(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
|
|
2240
|
-
var
|
|
2241
|
-
const o = (
|
|
2240
|
+
var b, w;
|
|
2241
|
+
const o = (b = i == null ? void 0 : i.$) == null ? void 0 : b.order, a = br(i), c = Ii(i);
|
|
2242
2242
|
let u = zs(t, s);
|
|
2243
2243
|
const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], d = Ai(e, n, l, o);
|
|
2244
2244
|
if (d && ((w = d == null ? void 0 : d["forward-identity"]) == null ? void 0 : w[2]) !== "id") {
|
|
2245
|
-
const
|
|
2246
|
-
u = u.map(([
|
|
2247
|
-
var
|
|
2248
|
-
let
|
|
2249
|
-
return
|
|
2245
|
+
const _ = d["checked-data-type"] === "date", g = d.id;
|
|
2246
|
+
u = u.map(([m]) => {
|
|
2247
|
+
var S, M, O, k, F;
|
|
2248
|
+
let I = (F = (k = (O = (M = (S = t.eav.get(m)) == null ? void 0 : S.get(g)) == null ? void 0 : M.values()) == null ? void 0 : O.next()) == null ? void 0 : k.value) == null ? void 0 : F[2];
|
|
2249
|
+
return _ && (I = Nt(I)), [m, I];
|
|
2250
2250
|
});
|
|
2251
2251
|
}
|
|
2252
|
-
u.sort(c === "asc" ? function(
|
|
2253
|
-
return it(
|
|
2254
|
-
} : function(
|
|
2255
|
-
return it(
|
|
2252
|
+
u.sort(c === "asc" ? function(g, m) {
|
|
2253
|
+
return it(g, m, d == null ? void 0 : d["checked-data-type"]);
|
|
2254
|
+
} : function(g, m) {
|
|
2255
|
+
return it(m, g, d == null ? void 0 : d["checked-data-type"]);
|
|
2256
2256
|
});
|
|
2257
2257
|
let p = {};
|
|
2258
2258
|
const y = ki(e, n, s);
|
|
2259
|
-
for (const
|
|
2260
|
-
const [
|
|
2261
|
-
if (p[
|
|
2259
|
+
for (const _ of u) {
|
|
2260
|
+
const [g] = _;
|
|
2261
|
+
if (p[g] || !a && l && d && mi(l, d, c, _) || !a && f && d && Si(f, d, c, _))
|
|
2262
2262
|
continue;
|
|
2263
|
-
const
|
|
2264
|
-
|
|
2263
|
+
const m = Ms(t, y, g);
|
|
2264
|
+
m && (p[g] = m);
|
|
2265
2265
|
}
|
|
2266
2266
|
return p;
|
|
2267
2267
|
}
|
|
@@ -2276,7 +2276,7 @@ function br(t) {
|
|
|
2276
2276
|
return !e && !n && !r;
|
|
2277
2277
|
}
|
|
2278
2278
|
function Ci(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
|
|
2279
|
-
var d, p, y,
|
|
2279
|
+
var d, p, y, b, w;
|
|
2280
2280
|
if (!br(s) && (!o || !o["start-cursor"]))
|
|
2281
2281
|
return [];
|
|
2282
2282
|
const a = li(yi(e, n, r, (d = s.$) == null ? void 0 : d.where), i), c = bi(ht, n, r), u = (p = s.$) == null ? void 0 : p.fields, l = Oi(t, e, {
|
|
@@ -2284,11 +2284,11 @@ function Ci(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
|
|
|
2284
2284
|
pageInfo: o,
|
|
2285
2285
|
form: s,
|
|
2286
2286
|
dq: { where: a, find: c, fields: u }
|
|
2287
|
-
}), f = ((y = s.$) == null ? void 0 : y.limit) || ((
|
|
2287
|
+
}), f = ((y = s.$) == null ? void 0 : y.limit) || ((b = s.$) == null ? void 0 : b.first) || ((w = s.$) == null ? void 0 : w.last);
|
|
2288
2288
|
if (f != null) {
|
|
2289
2289
|
r > 0 && ni && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
|
|
2290
|
-
const
|
|
2291
|
-
return
|
|
2290
|
+
const _ = Object.entries(l);
|
|
2291
|
+
return _.length <= f ? l : Object.fromEntries(_.slice(0, f));
|
|
2292
2292
|
}
|
|
2293
2293
|
return l;
|
|
2294
2294
|
}
|
|
@@ -2426,7 +2426,7 @@ function Ui(t) {
|
|
|
2426
2426
|
function Li(t, e, n) {
|
|
2427
2427
|
return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2428
2428
|
// before assuming it's a ref lookup.
|
|
2429
|
-
!
|
|
2429
|
+
!W(t, e, n);
|
|
2430
2430
|
}
|
|
2431
2431
|
function qt(t) {
|
|
2432
2432
|
const [e, n, ...r] = t.split(".");
|
|
@@ -2436,8 +2436,8 @@ function qt(t) {
|
|
|
2436
2436
|
}
|
|
2437
2437
|
function Fi(t, e, n) {
|
|
2438
2438
|
if (!Li(t, e, n))
|
|
2439
|
-
return
|
|
2440
|
-
const r = qt(n), s =
|
|
2439
|
+
return W(t, e, n);
|
|
2440
|
+
const r = qt(n), s = W(t, e, r) || Ae(t, e, r);
|
|
2441
2441
|
if (s && s["value-type"] !== "ref")
|
|
2442
2442
|
throw new Error(`${n} does not reference a valid link attribute.`);
|
|
2443
2443
|
return s;
|
|
@@ -2445,7 +2445,7 @@ function Fi(t, e, n) {
|
|
|
2445
2445
|
function zt(t) {
|
|
2446
2446
|
return typeof t == "string" && !ot(t) ? null : typeof t == "string" && ot(t) ? Kt(t) : Ui(t);
|
|
2447
2447
|
}
|
|
2448
|
-
function
|
|
2448
|
+
function re(t, e, n) {
|
|
2449
2449
|
const r = zt(n);
|
|
2450
2450
|
if (r === null)
|
|
2451
2451
|
return n;
|
|
@@ -2456,52 +2456,52 @@ function te(t, e, n) {
|
|
|
2456
2456
|
}
|
|
2457
2457
|
function _r(t, e, n, r) {
|
|
2458
2458
|
var o;
|
|
2459
|
-
const s =
|
|
2459
|
+
const s = re(t, e, n);
|
|
2460
2460
|
return Array.isArray(s) ? [[
|
|
2461
2461
|
"add-triple",
|
|
2462
2462
|
s,
|
|
2463
|
-
(o =
|
|
2463
|
+
(o = W(t, e, "id")) == null ? void 0 : o.id,
|
|
2464
2464
|
s
|
|
2465
2465
|
]].concat(r) : r;
|
|
2466
2466
|
}
|
|
2467
2467
|
function Ni({ attrsStore: t }, [e, n, r]) {
|
|
2468
2468
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2469
|
-
const a = Array.isArray(o) ? o : [o], c =
|
|
2469
|
+
const a = Array.isArray(o) ? o : [o], c = W(t, e, i), u = Ae(t, e, i);
|
|
2470
2470
|
return a.map((l) => c ? [
|
|
2471
2471
|
"add-triple",
|
|
2472
|
-
|
|
2472
|
+
re(t, e, n),
|
|
2473
2473
|
c.id,
|
|
2474
2474
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2475
2475
|
// already exist
|
|
2476
|
-
|
|
2476
|
+
re(t, c["reverse-identity"][1], l)
|
|
2477
2477
|
] : [
|
|
2478
2478
|
"add-triple",
|
|
2479
2479
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2480
2480
|
// already exist
|
|
2481
|
-
|
|
2481
|
+
re(t, u["forward-identity"][1], l),
|
|
2482
2482
|
u == null ? void 0 : u.id,
|
|
2483
|
-
|
|
2483
|
+
re(t, e, n)
|
|
2484
2484
|
]);
|
|
2485
2485
|
});
|
|
2486
2486
|
return _r(t, e, n, s);
|
|
2487
2487
|
}
|
|
2488
2488
|
function Ki({ attrsStore: t }, [e, n, r]) {
|
|
2489
2489
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2490
|
-
const a = Array.isArray(o) ? o : [o], c =
|
|
2490
|
+
const a = Array.isArray(o) ? o : [o], c = W(t, e, i), u = Ae(t, e, i);
|
|
2491
2491
|
return a.map((l) => c ? [
|
|
2492
2492
|
"retract-triple",
|
|
2493
|
-
|
|
2493
|
+
re(t, e, n),
|
|
2494
2494
|
c.id,
|
|
2495
2495
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2496
2496
|
// already exist
|
|
2497
|
-
|
|
2497
|
+
re(t, c["reverse-identity"][1], l)
|
|
2498
2498
|
] : [
|
|
2499
2499
|
"retract-triple",
|
|
2500
2500
|
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
2501
2501
|
// already exist
|
|
2502
|
-
|
|
2502
|
+
re(t, u["forward-identity"][1], l),
|
|
2503
2503
|
u.id,
|
|
2504
|
-
|
|
2504
|
+
re(t, e, n)
|
|
2505
2505
|
]);
|
|
2506
2506
|
});
|
|
2507
2507
|
return _r(t, e, n, s);
|
|
@@ -2513,7 +2513,7 @@ function qi(t, e, n, r) {
|
|
|
2513
2513
|
for (const a of t || []) {
|
|
2514
2514
|
const c = a == null ? void 0 : a.aev.get(i);
|
|
2515
2515
|
if (c) {
|
|
2516
|
-
for (const [u, l, f] of
|
|
2516
|
+
for (const [u, l, f] of ne(c, 2))
|
|
2517
2517
|
if (f === o)
|
|
2518
2518
|
return !0;
|
|
2519
2519
|
}
|
|
@@ -2533,16 +2533,16 @@ function mr({ stores: t, attrsStore: e }, [n, r, s, i]) {
|
|
|
2533
2533
|
return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : qi(t, e, n, r) ? { mode: "update" } : null;
|
|
2534
2534
|
}
|
|
2535
2535
|
function zi(t, e) {
|
|
2536
|
-
const { attrsStore: n } = t, [r, s, i, o] = e, a = tn(i), c =
|
|
2536
|
+
const { attrsStore: n } = t, [r, s, i, o] = e, a = tn(i), c = re(n, r, s);
|
|
2537
2537
|
return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
|
|
2538
|
-
const d =
|
|
2538
|
+
const d = W(n, r, l);
|
|
2539
2539
|
return d["checked-data-type"] === "date" && t.useDateObjects && (f = dt(f)), ["add-triple", c, d.id, f, { mode: "create" }];
|
|
2540
2540
|
});
|
|
2541
2541
|
}
|
|
2542
2542
|
function Wi(t, e) {
|
|
2543
|
-
const { attrsStore: n } = t, [r, s, i, o] = e, a = tn(i), c =
|
|
2543
|
+
const { attrsStore: n } = t, [r, s, i, o] = e, a = tn(i), c = re(n, r, s), u = mr(t, [r, c, i, o]);
|
|
2544
2544
|
return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
|
|
2545
|
-
const p =
|
|
2545
|
+
const p = W(n, r, f);
|
|
2546
2546
|
return p["checked-data-type"] === "date" && t.useDateObjects && (d = dt(d)), [
|
|
2547
2547
|
"add-triple",
|
|
2548
2548
|
c,
|
|
@@ -2553,11 +2553,11 @@ function Wi(t, e) {
|
|
|
2553
2553
|
});
|
|
2554
2554
|
}
|
|
2555
2555
|
function Vi({ attrsStore: t }, [e, n]) {
|
|
2556
|
-
return [["delete-entity",
|
|
2556
|
+
return [["delete-entity", re(t, e, n), e]];
|
|
2557
2557
|
}
|
|
2558
2558
|
function Qi(t, e) {
|
|
2559
|
-
const { attrsStore: n } = t, [r, s, i, o] = e, a = tn(i), c =
|
|
2560
|
-
const y =
|
|
2559
|
+
const { attrsStore: n } = t, [r, s, i, o] = e, a = tn(i), c = re(n, r, s), u = mr(t, [r, c, i, o]), l = Object.entries(a).map(([d, p]) => {
|
|
2560
|
+
const y = W(n, r, d);
|
|
2561
2561
|
return [
|
|
2562
2562
|
"deep-merge-triple",
|
|
2563
2563
|
c,
|
|
@@ -2569,13 +2569,13 @@ function Qi(t, e) {
|
|
|
2569
2569
|
return [[
|
|
2570
2570
|
"add-triple",
|
|
2571
2571
|
c,
|
|
2572
|
-
|
|
2572
|
+
W(n, r, "id").id,
|
|
2573
2573
|
c,
|
|
2574
2574
|
...u ? [u] : []
|
|
2575
2575
|
]].concat(l);
|
|
2576
2576
|
}
|
|
2577
2577
|
function Bi({ attrsStore: t }, [e, n, r]) {
|
|
2578
|
-
return [["rule-params",
|
|
2578
|
+
return [["rule-params", re(t, e, n), e, r]];
|
|
2579
2579
|
}
|
|
2580
2580
|
function Gi(t) {
|
|
2581
2581
|
const [e, n, r, s, i] = t;
|
|
@@ -2631,7 +2631,7 @@ function Yi(t, e, n) {
|
|
|
2631
2631
|
};
|
|
2632
2632
|
}
|
|
2633
2633
|
function Be(t, e, n, r) {
|
|
2634
|
-
const s = t ? Yi(t, e, n) : null, i =
|
|
2634
|
+
const s = t ? Yi(t, e, n) : null, i = N(), a = [N(), e, n];
|
|
2635
2635
|
return {
|
|
2636
2636
|
id: i,
|
|
2637
2637
|
"forward-identity": a,
|
|
@@ -2653,8 +2653,8 @@ function Xi(t, e, n) {
|
|
|
2653
2653
|
throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
|
|
2654
2654
|
const { forward: s, reverse: i } = r;
|
|
2655
2655
|
return {
|
|
2656
|
-
"forward-identity": [
|
|
2657
|
-
"reverse-identity": [
|
|
2656
|
+
"forward-identity": [N(), s.on, s.label],
|
|
2657
|
+
"reverse-identity": [N(), i.on, i.label],
|
|
2658
2658
|
cardinality: s.has === "one" ? "one" : "many",
|
|
2659
2659
|
"unique?": i.has === "one",
|
|
2660
2660
|
"on-delete": s.onDelete,
|
|
@@ -2662,7 +2662,7 @@ function Xi(t, e, n) {
|
|
|
2662
2662
|
};
|
|
2663
2663
|
}
|
|
2664
2664
|
function An(t, e, n, r) {
|
|
2665
|
-
const s = t ? Xi(t, e, n) : null, i =
|
|
2665
|
+
const s = t ? Xi(t, e, n) : null, i = N(), o = [N(), e, n], a = [N(), n, e];
|
|
2666
2666
|
return {
|
|
2667
2667
|
id: i,
|
|
2668
2668
|
// @ts-ignore: ts thinks it's any[]
|
|
@@ -2713,13 +2713,13 @@ function io(t) {
|
|
|
2713
2713
|
function oo({ attrsStore: t, schema: e }, n) {
|
|
2714
2714
|
var d, p;
|
|
2715
2715
|
const r = /* @__PURE__ */ new Set(), s = [], i = [];
|
|
2716
|
-
function o(y,
|
|
2717
|
-
return
|
|
2716
|
+
function o(y, b) {
|
|
2717
|
+
return W(t, y, b) || s.find((w) => w["forward-identity"][1] === y && w["forward-identity"][2] === b);
|
|
2718
2718
|
}
|
|
2719
|
-
function a(y,
|
|
2720
|
-
return Ae(t, y,
|
|
2721
|
-
var
|
|
2722
|
-
return ((
|
|
2719
|
+
function a(y, b) {
|
|
2720
|
+
return Ae(t, y, b) || s.find((w) => {
|
|
2721
|
+
var _, g;
|
|
2722
|
+
return ((_ = w["reverse-identity"]) == null ? void 0 : _[1]) === y && ((g = w["reverse-identity"]) == null ? void 0 : g[2]) === b;
|
|
2723
2723
|
});
|
|
2724
2724
|
}
|
|
2725
2725
|
function c(y) {
|
|
@@ -2728,55 +2728,55 @@ function oo({ attrsStore: t, schema: e }, n) {
|
|
|
2728
2728
|
function u(y) {
|
|
2729
2729
|
y && "isUnsynced" in y && y.isUnsynced && !r.has(y.id) && (s.push(y), i.push(["add-attr", y]), r.add(y.id));
|
|
2730
2730
|
}
|
|
2731
|
-
function l(y,
|
|
2732
|
-
return
|
|
2731
|
+
function l(y, b) {
|
|
2732
|
+
return b.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2733
2733
|
// before assuming it's a ref lookup.
|
|
2734
|
-
!o(y,
|
|
2734
|
+
!o(y, b);
|
|
2735
2735
|
}
|
|
2736
|
-
function f(y,
|
|
2737
|
-
const w = o(y,
|
|
2738
|
-
u(w), u(
|
|
2736
|
+
function f(y, b) {
|
|
2737
|
+
const w = o(y, b), _ = a(y, b);
|
|
2738
|
+
u(w), u(_), !w && !_ && c(An(e, y, b, so));
|
|
2739
2739
|
}
|
|
2740
2740
|
for (const y of n)
|
|
2741
|
-
for (const { etype:
|
|
2742
|
-
const
|
|
2743
|
-
if (
|
|
2744
|
-
f(
|
|
2745
|
-
const
|
|
2746
|
-
u(
|
|
2747
|
-
const
|
|
2748
|
-
if (l(
|
|
2749
|
-
f(
|
|
2741
|
+
for (const { etype: b, lookupPair: w, linkLabel: _ } of io(y)) {
|
|
2742
|
+
const g = w[0];
|
|
2743
|
+
if (_) {
|
|
2744
|
+
f(b, _);
|
|
2745
|
+
const m = o(b, _), I = a(b, _);
|
|
2746
|
+
u(m), u(I);
|
|
2747
|
+
const S = ((d = m == null ? void 0 : m["reverse-identity"]) == null ? void 0 : d[1]) || ((p = I == null ? void 0 : I["forward-identity"]) == null ? void 0 : p[1]) || _;
|
|
2748
|
+
if (l(S, g))
|
|
2749
|
+
f(S, qt(g));
|
|
2750
2750
|
else {
|
|
2751
|
-
const
|
|
2752
|
-
|
|
2751
|
+
const M = o(S, g);
|
|
2752
|
+
M || c(Be(e, S, g, Wt)), u(M);
|
|
2753
2753
|
}
|
|
2754
|
-
} else if (l(
|
|
2755
|
-
f(
|
|
2754
|
+
} else if (l(b, g))
|
|
2755
|
+
f(b, qt(g));
|
|
2756
2756
|
else {
|
|
2757
|
-
const
|
|
2758
|
-
|
|
2757
|
+
const m = o(b, g);
|
|
2758
|
+
m || c(Be(e, b, g, Wt)), u(m);
|
|
2759
2759
|
}
|
|
2760
2760
|
}
|
|
2761
2761
|
for (const y of n) {
|
|
2762
|
-
const [
|
|
2763
|
-
if (eo.has(
|
|
2764
|
-
const
|
|
2765
|
-
u(
|
|
2766
|
-
for (const
|
|
2767
|
-
const
|
|
2768
|
-
if (u(
|
|
2769
|
-
const
|
|
2770
|
-
!
|
|
2762
|
+
const [b, w, _, g] = y;
|
|
2763
|
+
if (eo.has(b)) {
|
|
2764
|
+
const m = o(w, "id");
|
|
2765
|
+
u(m), m || c(Be(e, w, "id", { "unique?": !0 }));
|
|
2766
|
+
for (const I of Object.keys(g)) {
|
|
2767
|
+
const S = o(w, I);
|
|
2768
|
+
if (u(S), no.has(b) && (S || c(Be(e, w, I, I === "id" ? { "unique?": !0 } : null))), to.has(b)) {
|
|
2769
|
+
const M = a(w, I);
|
|
2770
|
+
!S && !M && c(An(e, w, I)), u(M);
|
|
2771
2771
|
}
|
|
2772
2772
|
}
|
|
2773
2773
|
}
|
|
2774
2774
|
}
|
|
2775
2775
|
if (s.length) {
|
|
2776
2776
|
const y = { ...t.attrs };
|
|
2777
|
-
for (const
|
|
2778
|
-
y[
|
|
2779
|
-
return [new
|
|
2777
|
+
for (const b of s)
|
|
2778
|
+
y[b.id] = b;
|
|
2779
|
+
return [new Se(y, t.linkIndex), i];
|
|
2780
2780
|
}
|
|
2781
2781
|
return [t, i];
|
|
2782
2782
|
}
|
|
@@ -2964,13 +2964,13 @@ class Vt {
|
|
|
2964
2964
|
for (const [d, p] of Object.entries(r.objects))
|
|
2965
2965
|
!n.has(d) && p.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedOldCount++);
|
|
2966
2966
|
const a = Object.entries(r.objects);
|
|
2967
|
-
a.sort(([d, p], [y,
|
|
2967
|
+
a.sort(([d, p], [y, b]) => p.updatedAt - b.updatedAt);
|
|
2968
2968
|
const c = a.filter(([d]) => !n.has(d));
|
|
2969
2969
|
if (a.length > this._gcOpts.maxEntries)
|
|
2970
2970
|
for (const [d] of c.slice(0, a.length - this._gcOpts.maxEntries))
|
|
2971
2971
|
s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedThresholdCount++;
|
|
2972
2972
|
const u = Object.entries(r.objects);
|
|
2973
|
-
u.sort(([d, p], [y,
|
|
2973
|
+
u.sort(([d, p], [y, b]) => p.updatedAt - b.updatedAt);
|
|
2974
2974
|
const l = u.filter(([d]) => !n.has(d));
|
|
2975
2975
|
let f = u.reduce((d, [p, y]) => d + y.size, 0);
|
|
2976
2976
|
for (; f > 0 && f > this._gcOpts.maxSize && l.length; ) {
|
|
@@ -3072,16 +3072,16 @@ async function po(t, e, n) {
|
|
|
3072
3072
|
var l, f, d;
|
|
3073
3073
|
const a = {};
|
|
3074
3074
|
for (const [p, y] of Object.entries(r)) {
|
|
3075
|
-
const
|
|
3076
|
-
if (
|
|
3077
|
-
const
|
|
3078
|
-
createdAt:
|
|
3079
|
-
updatedAt:
|
|
3080
|
-
size: ((d = (f = (l =
|
|
3075
|
+
const b = typeof y == "string" ? JSON.parse(y) : y;
|
|
3076
|
+
if (b.lastAccessed) {
|
|
3077
|
+
const _ = {
|
|
3078
|
+
createdAt: b.lastAccessed,
|
|
3079
|
+
updatedAt: b.lastAccessed,
|
|
3080
|
+
size: ((d = (f = (l = b.result) == null ? void 0 : l.store) == null ? void 0 : f.triples) == null ? void 0 : d.length) ?? 0
|
|
3081
3081
|
};
|
|
3082
|
-
a[p] =
|
|
3082
|
+
a[p] = _;
|
|
3083
3083
|
}
|
|
3084
|
-
const w = n.put(
|
|
3084
|
+
const w = n.put(b, p);
|
|
3085
3085
|
s.add(w);
|
|
3086
3086
|
}
|
|
3087
3087
|
const c = { objects: a }, u = n.put(c, Ee);
|
|
@@ -3109,14 +3109,14 @@ async function yo(t, e) {
|
|
|
3109
3109
|
y.onerror = (w) => {
|
|
3110
3110
|
f(w);
|
|
3111
3111
|
};
|
|
3112
|
-
const
|
|
3112
|
+
const b = [];
|
|
3113
3113
|
y.onsuccess = () => {
|
|
3114
3114
|
const w = y.result;
|
|
3115
3115
|
if (w) {
|
|
3116
|
-
const
|
|
3117
|
-
|
|
3116
|
+
const _ = w.key, g = w.value;
|
|
3117
|
+
b.push([_, g]), w.continue();
|
|
3118
3118
|
} else
|
|
3119
|
-
l(
|
|
3119
|
+
l(b);
|
|
3120
3120
|
}, y.onerror = (w) => {
|
|
3121
3121
|
f(w);
|
|
3122
3122
|
};
|
|
@@ -3146,7 +3146,7 @@ async function yo(t, e) {
|
|
|
3146
3146
|
});
|
|
3147
3147
|
}
|
|
3148
3148
|
const In = /* @__PURE__ */ new Map();
|
|
3149
|
-
class
|
|
3149
|
+
class Sr extends co {
|
|
3150
3150
|
constructor(n, r) {
|
|
3151
3151
|
super(n, r);
|
|
3152
3152
|
h(this, "dbName");
|
|
@@ -3245,7 +3245,7 @@ class Tr extends co {
|
|
|
3245
3245
|
});
|
|
3246
3246
|
}
|
|
3247
3247
|
}
|
|
3248
|
-
class
|
|
3248
|
+
class Tr {
|
|
3249
3249
|
static async getIsOnline() {
|
|
3250
3250
|
return navigator.onLine;
|
|
3251
3251
|
}
|
|
@@ -3260,20 +3260,20 @@ class Sr {
|
|
|
3260
3260
|
};
|
|
3261
3261
|
}
|
|
3262
3262
|
}
|
|
3263
|
-
class
|
|
3263
|
+
class Y extends Error {
|
|
3264
3264
|
constructor(n, r, s) {
|
|
3265
3265
|
super(n);
|
|
3266
3266
|
h(this, "hint");
|
|
3267
3267
|
h(this, "traceId");
|
|
3268
3268
|
this.hint = r, s && (this.traceId = s);
|
|
3269
3269
|
const i = new.target.prototype;
|
|
3270
|
-
Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
3270
|
+
Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, Y), this.name = "InstantError";
|
|
3271
3271
|
}
|
|
3272
3272
|
get [Symbol.toStringTag]() {
|
|
3273
3273
|
return "InstantError";
|
|
3274
3274
|
}
|
|
3275
3275
|
}
|
|
3276
|
-
class pt extends
|
|
3276
|
+
class pt extends Y {
|
|
3277
3277
|
constructor(n) {
|
|
3278
3278
|
var i;
|
|
3279
3279
|
const r = ((i = n.body) == null ? void 0 : i.message) || `API Error (${n.status})`;
|
|
@@ -3287,19 +3287,19 @@ class pt extends J {
|
|
|
3287
3287
|
return "InstantAPIError";
|
|
3288
3288
|
}
|
|
3289
3289
|
}
|
|
3290
|
-
async function
|
|
3290
|
+
async function le(t, e) {
|
|
3291
3291
|
const n = await fetch(t, e), r = await n.json();
|
|
3292
3292
|
return n.status === 200 ? Promise.resolve(r) : Promise.reject(new pt({ status: n.status, body: r }));
|
|
3293
3293
|
}
|
|
3294
3294
|
function bo({ apiURI: t, appId: e, email: n }) {
|
|
3295
|
-
return
|
|
3295
|
+
return le(`${t}/runtime/auth/send_magic_code`, {
|
|
3296
3296
|
method: "POST",
|
|
3297
3297
|
headers: { "content-type": "application/json" },
|
|
3298
3298
|
body: JSON.stringify({ "app-id": e, email: n })
|
|
3299
3299
|
});
|
|
3300
3300
|
}
|
|
3301
3301
|
async function go({ apiURI: t, appId: e, email: n, code: r, refreshToken: s, extraFields: i }) {
|
|
3302
|
-
return await
|
|
3302
|
+
return await le(`${t}/runtime/auth/verify_magic_code`, {
|
|
3303
3303
|
method: "POST",
|
|
3304
3304
|
headers: { "content-type": "application/json" },
|
|
3305
3305
|
body: JSON.stringify({
|
|
@@ -3312,7 +3312,7 @@ async function go({ apiURI: t, appId: e, email: n, code: r, refreshToken: s, ext
|
|
|
3312
3312
|
});
|
|
3313
3313
|
}
|
|
3314
3314
|
async function wo({ apiURI: t, appId: e, refreshToken: n }) {
|
|
3315
|
-
return await
|
|
3315
|
+
return await le(`${t}/runtime/auth/verify_refresh_token`, {
|
|
3316
3316
|
method: "POST",
|
|
3317
3317
|
headers: { "content-type": "application/json" },
|
|
3318
3318
|
body: JSON.stringify({
|
|
@@ -3322,7 +3322,7 @@ async function wo({ apiURI: t, appId: e, refreshToken: n }) {
|
|
|
3322
3322
|
});
|
|
3323
3323
|
}
|
|
3324
3324
|
async function _o({ apiURI: t, appId: e }) {
|
|
3325
|
-
return await
|
|
3325
|
+
return await le(`${t}/runtime/auth/sign_in_guest`, {
|
|
3326
3326
|
method: "POST",
|
|
3327
3327
|
headers: { "content-type": "application/json" },
|
|
3328
3328
|
body: JSON.stringify({
|
|
@@ -3331,7 +3331,7 @@ async function _o({ apiURI: t, appId: e }) {
|
|
|
3331
3331
|
});
|
|
3332
3332
|
}
|
|
3333
3333
|
async function Cn({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken: s, extraFields: i }) {
|
|
3334
|
-
return await
|
|
3334
|
+
return await le(`${t}/runtime/oauth/token`, {
|
|
3335
3335
|
method: "POST",
|
|
3336
3336
|
headers: { "content-type": "application/json" },
|
|
3337
3337
|
body: JSON.stringify({
|
|
@@ -3344,7 +3344,7 @@ async function Cn({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken:
|
|
|
3344
3344
|
});
|
|
3345
3345
|
}
|
|
3346
3346
|
async function mo({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, refreshToken: i, extraFields: o }) {
|
|
3347
|
-
return await
|
|
3347
|
+
return await le(`${t}/runtime/oauth/id_token`, {
|
|
3348
3348
|
method: "POST",
|
|
3349
3349
|
headers: { "content-type": "application/json" },
|
|
3350
3350
|
body: JSON.stringify({
|
|
@@ -3357,8 +3357,8 @@ async function mo({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, re
|
|
|
3357
3357
|
})
|
|
3358
3358
|
});
|
|
3359
3359
|
}
|
|
3360
|
-
async function
|
|
3361
|
-
return await
|
|
3360
|
+
async function So({ apiURI: t, appId: e, refreshToken: n }) {
|
|
3361
|
+
return await le(`${t}/runtime/signout`, {
|
|
3362
3362
|
method: "POST",
|
|
3363
3363
|
headers: {
|
|
3364
3364
|
"content-type": "application/json"
|
|
@@ -3369,21 +3369,21 @@ async function To({ apiURI: t, appId: e, refreshToken: n }) {
|
|
|
3369
3369
|
})
|
|
3370
3370
|
});
|
|
3371
3371
|
}
|
|
3372
|
-
async function
|
|
3372
|
+
async function To({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
|
|
3373
3373
|
const a = {
|
|
3374
3374
|
app_id: e,
|
|
3375
3375
|
path: n,
|
|
3376
3376
|
authorization: `Bearer ${s}`,
|
|
3377
3377
|
"content-type": i || r.type
|
|
3378
3378
|
};
|
|
3379
|
-
return o && (a["content-disposition"] = o), await
|
|
3379
|
+
return o && (a["content-disposition"] = o), await le(`${t}/storage/upload`, {
|
|
3380
3380
|
method: "PUT",
|
|
3381
3381
|
headers: a,
|
|
3382
3382
|
body: r
|
|
3383
3383
|
});
|
|
3384
3384
|
}
|
|
3385
3385
|
async function vo({ apiURI: t, appId: e, path: n, refreshToken: r }) {
|
|
3386
|
-
const { data: s } = await
|
|
3386
|
+
const { data: s } = await le(`${t}/storage/files?app_id=${e}&filename=${encodeURIComponent(n)}`, {
|
|
3387
3387
|
method: "DELETE",
|
|
3388
3388
|
headers: {
|
|
3389
3389
|
"content-type": "application/json",
|
|
@@ -3393,7 +3393,7 @@ async function vo({ apiURI: t, appId: e, path: n, refreshToken: r }) {
|
|
|
3393
3393
|
return s;
|
|
3394
3394
|
}
|
|
3395
3395
|
async function Ao({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata: s = {} }) {
|
|
3396
|
-
const { data: i } = await
|
|
3396
|
+
const { data: i } = await le(`${t}/storage/signed-upload-url`, {
|
|
3397
3397
|
method: "POST",
|
|
3398
3398
|
headers: {
|
|
3399
3399
|
"content-type": "application/json",
|
|
@@ -3416,7 +3416,7 @@ async function ko(t, e) {
|
|
|
3416
3416
|
})).ok;
|
|
3417
3417
|
}
|
|
3418
3418
|
async function Oo({ apiURI: t, appId: e, path: n, refreshToken: r }) {
|
|
3419
|
-
const { data: s } = await
|
|
3419
|
+
const { data: s } = await le(`${t}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(n)}`, {
|
|
3420
3420
|
method: "GET",
|
|
3421
3421
|
headers: {
|
|
3422
3422
|
"content-type": "application/json",
|
|
@@ -3503,7 +3503,7 @@ function jn(t) {
|
|
|
3503
3503
|
}, e;
|
|
3504
3504
|
}, {});
|
|
3505
3505
|
}
|
|
3506
|
-
const cn = "v1.0.1";
|
|
3506
|
+
const cn = "v1.0.2-branch-edge-runtime.24356557026.1";
|
|
3507
3507
|
function Eo(t, e) {
|
|
3508
3508
|
return {
|
|
3509
3509
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
@@ -3514,7 +3514,7 @@ function Eo(t, e) {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
};
|
|
3516
3516
|
}
|
|
3517
|
-
class
|
|
3517
|
+
class ee {
|
|
3518
3518
|
constructor(e, n, r, s = { indexed: !1, unique: !1 }) {
|
|
3519
3519
|
h(this, "valueType");
|
|
3520
3520
|
h(this, "required");
|
|
@@ -3529,19 +3529,19 @@ class Y {
|
|
|
3529
3529
|
* and enforced for backend
|
|
3530
3530
|
*/
|
|
3531
3531
|
clientRequired() {
|
|
3532
|
-
return new
|
|
3532
|
+
return new ee(this.valueType, !1, this.isIndexed, this.config);
|
|
3533
3533
|
}
|
|
3534
3534
|
optional() {
|
|
3535
|
-
return new
|
|
3535
|
+
return new ee(this.valueType, !1, this.isIndexed, this.config);
|
|
3536
3536
|
}
|
|
3537
3537
|
unique() {
|
|
3538
|
-
return new
|
|
3538
|
+
return new ee(this.valueType, this.required, this.isIndexed, {
|
|
3539
3539
|
...this.config,
|
|
3540
3540
|
unique: !0
|
|
3541
3541
|
});
|
|
3542
3542
|
}
|
|
3543
3543
|
indexed() {
|
|
3544
|
-
return new
|
|
3544
|
+
return new ee(this.valueType, this.required, !0, {
|
|
3545
3545
|
...this.config,
|
|
3546
3546
|
indexed: !0
|
|
3547
3547
|
});
|
|
@@ -3587,7 +3587,7 @@ class bt {
|
|
|
3587
3587
|
return new bt(this.entities, this.links, {});
|
|
3588
3588
|
}
|
|
3589
3589
|
}
|
|
3590
|
-
class
|
|
3590
|
+
class D extends Error {
|
|
3591
3591
|
constructor(e, n) {
|
|
3592
3592
|
const r = n ? `At path '${n}': ${e}` : e;
|
|
3593
3593
|
super(r), this.name = "QueryValidationError";
|
|
@@ -3624,13 +3624,13 @@ const $n = [
|
|
|
3624
3624
|
}, Mo = (t, e, n, r, s, i, o) => {
|
|
3625
3625
|
const a = i.valueType === "json", c = (u, l, f) => {
|
|
3626
3626
|
if (!Or(f, l, a))
|
|
3627
|
-
throw new
|
|
3627
|
+
throw new D(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
|
|
3628
3628
|
};
|
|
3629
3629
|
switch (t) {
|
|
3630
3630
|
case "in":
|
|
3631
3631
|
case "$in":
|
|
3632
3632
|
if (!Array.isArray(e))
|
|
3633
|
-
throw new
|
|
3633
|
+
throw new D(`Operator '${t}' for attribute '${r}' in entity '${s}' must be an array, but received: ${typeof e}`, o);
|
|
3634
3634
|
for (const u of e)
|
|
3635
3635
|
c(t, n, u);
|
|
3636
3636
|
break;
|
|
@@ -3645,13 +3645,13 @@ const $n = [
|
|
|
3645
3645
|
case "$like":
|
|
3646
3646
|
case "$ilike":
|
|
3647
3647
|
if (c(t, "string", e), t === "$ilike" && !i.isIndexed)
|
|
3648
|
-
throw new
|
|
3648
|
+
throw new D(`Operator '${t}' can only be used with indexed attributes, but '${r}' in entity '${s}' is not indexed`, o);
|
|
3649
3649
|
break;
|
|
3650
3650
|
case "$isNull":
|
|
3651
3651
|
c(t, "boolean", e);
|
|
3652
3652
|
break;
|
|
3653
3653
|
default:
|
|
3654
|
-
throw new
|
|
3654
|
+
throw new D(`Unknown operator '${t}' for attribute '${r}' in entity '${s}'`, o);
|
|
3655
3655
|
}
|
|
3656
3656
|
}, Pe = (t, e, n, r, s) => {
|
|
3657
3657
|
const i = Po(n), o = n.valueType === "json";
|
|
@@ -3662,42 +3662,42 @@ const $n = [
|
|
|
3662
3662
|
for (const [u, l] of Object.entries(c))
|
|
3663
3663
|
Mo(u, l, i, e, r, n, `${s}.${u}`);
|
|
3664
3664
|
} else if (!Or(t, i, o))
|
|
3665
|
-
throw new
|
|
3665
|
+
throw new D(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`, s);
|
|
3666
3666
|
}, jo = (t, e, n, r, s) => {
|
|
3667
3667
|
const i = t.split(".");
|
|
3668
3668
|
if (i.length < 2)
|
|
3669
|
-
throw new
|
|
3669
|
+
throw new D(`Invalid dot notation path '${t}'. Must contain at least one dot.`, s);
|
|
3670
3670
|
let o = n;
|
|
3671
3671
|
for (let l = 0; l < i.length - 1; l++) {
|
|
3672
3672
|
const f = i[l], d = r.entities[o];
|
|
3673
3673
|
if (!d)
|
|
3674
|
-
throw new
|
|
3674
|
+
throw new D(`Entity '${o}' does not exist in schema while traversing dot notation path '${t}'.`, s);
|
|
3675
3675
|
const p = d.links[f];
|
|
3676
3676
|
if (!p) {
|
|
3677
3677
|
const y = Object.keys(d.links);
|
|
3678
|
-
throw new
|
|
3678
|
+
throw new D(`Link '${f}' does not exist on entity '${o}' in dot notation path '${t}'. Available links: ${y.length > 0 ? y.join(", ") : "none"}`, s);
|
|
3679
3679
|
}
|
|
3680
3680
|
o = p.entityName;
|
|
3681
3681
|
}
|
|
3682
3682
|
const a = i[i.length - 1], c = r.entities[o];
|
|
3683
3683
|
if (!c)
|
|
3684
|
-
throw new
|
|
3684
|
+
throw new D(`Target entity '${o}' does not exist in schema for dot notation path '${t}'.`, s);
|
|
3685
3685
|
if (a === "id") {
|
|
3686
3686
|
if (typeof e == "string" && !Me(e))
|
|
3687
|
-
throw new
|
|
3688
|
-
Pe(e, t, new
|
|
3687
|
+
throw new D(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3688
|
+
Pe(e, t, new ee("string", !1, !0), n, s);
|
|
3689
3689
|
return;
|
|
3690
3690
|
}
|
|
3691
3691
|
const u = c.attrs[a];
|
|
3692
3692
|
if (Object.keys(c.links).includes(a)) {
|
|
3693
3693
|
if (typeof e == "string" && !Me(e))
|
|
3694
|
-
throw new
|
|
3695
|
-
Pe(e, t, new
|
|
3694
|
+
throw new D(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, s);
|
|
3695
|
+
Pe(e, t, new ee("string", !1, !0), n, s);
|
|
3696
3696
|
return;
|
|
3697
3697
|
}
|
|
3698
3698
|
if (!u) {
|
|
3699
3699
|
const l = Object.keys(c.attrs);
|
|
3700
|
-
throw new
|
|
3700
|
+
throw new D(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
|
|
3701
3701
|
}
|
|
3702
3702
|
Pe(e, t, u, n, s);
|
|
3703
3703
|
}, Ir = (t, e, n, r) => {
|
|
@@ -3709,7 +3709,7 @@ const $n = [
|
|
|
3709
3709
|
continue;
|
|
3710
3710
|
}
|
|
3711
3711
|
if (s === "id") {
|
|
3712
|
-
Pe(i, "id", new
|
|
3712
|
+
Pe(i, "id", new ee("string", !1, !0), e, `${r}.id`);
|
|
3713
3713
|
continue;
|
|
3714
3714
|
}
|
|
3715
3715
|
if (s.includes(".")) {
|
|
@@ -3722,21 +3722,21 @@ const $n = [
|
|
|
3722
3722
|
const a = o.attrs[s], c = o.links[s];
|
|
3723
3723
|
if (!a && !c) {
|
|
3724
3724
|
const u = Object.keys(o.attrs), l = Object.keys(o.links);
|
|
3725
|
-
throw new
|
|
3725
|
+
throw new D(`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}`);
|
|
3726
3726
|
}
|
|
3727
3727
|
if (a)
|
|
3728
3728
|
Pe(i, s, a, e, `${r}.${s}`);
|
|
3729
3729
|
else if (c) {
|
|
3730
3730
|
if (typeof i == "string" && !Me(i))
|
|
3731
|
-
throw new
|
|
3732
|
-
const u = new
|
|
3731
|
+
throw new D(`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`, `${r}.${s}`);
|
|
3732
|
+
const u = new ee("string", !1, !0);
|
|
3733
3733
|
Pe(i, s, u, e, `${r}.${s}`);
|
|
3734
3734
|
}
|
|
3735
3735
|
}
|
|
3736
3736
|
}, $o = (t, e, n, r, s = 0) => {
|
|
3737
3737
|
for (const o of Object.keys(t))
|
|
3738
3738
|
if (!$n.includes(o))
|
|
3739
|
-
throw new
|
|
3739
|
+
throw new D(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${$n.join(", ")}. Found: ${o}`, r);
|
|
3740
3740
|
const i = [
|
|
3741
3741
|
// 'limit', // only supported client side
|
|
3742
3742
|
"offset",
|
|
@@ -3749,21 +3749,21 @@ const $n = [
|
|
|
3749
3749
|
];
|
|
3750
3750
|
for (const o of i)
|
|
3751
3751
|
if (t[o] !== void 0 && s > 0)
|
|
3752
|
-
throw new
|
|
3752
|
+
throw new D(`'${o}' can only be used on top-level namespaces. It cannot be used in nested queries.`, r);
|
|
3753
3753
|
if (t.where && n) {
|
|
3754
3754
|
if (typeof t.where != "object" || t.where === null)
|
|
3755
|
-
throw new
|
|
3755
|
+
throw new D(`'where' clause must be an object in entity '${e}', but received: ${typeof t.where}`, r ? `${r}.where` : void 0);
|
|
3756
3756
|
Ir(t.where, e, n, r ? `${r}.where` : "where");
|
|
3757
3757
|
}
|
|
3758
3758
|
}, Cr = (t, e, n, r, s = 0) => {
|
|
3759
3759
|
var i;
|
|
3760
3760
|
if (!t || typeof t != "object")
|
|
3761
|
-
throw new
|
|
3761
|
+
throw new D(`Query part for entity '${e}' must be an object, but received: ${typeof t}`, r);
|
|
3762
3762
|
for (const o of Object.keys(t))
|
|
3763
3763
|
if (o !== "$") {
|
|
3764
3764
|
if (n && !(o in n.entities[e].links)) {
|
|
3765
3765
|
const c = Object.keys(n.entities[e].links);
|
|
3766
|
-
throw new
|
|
3766
|
+
throw new D(`Link '${o}' does not exist on entity '${e}'. Available links: ${c.length > 0 ? c.join(", ") : "none"}`, `${r}.${o}`);
|
|
3767
3767
|
}
|
|
3768
3768
|
const a = t[o];
|
|
3769
3769
|
if (typeof a == "object" && a !== null) {
|
|
@@ -3773,35 +3773,35 @@ const $n = [
|
|
|
3773
3773
|
} else {
|
|
3774
3774
|
const a = t[o];
|
|
3775
3775
|
if (typeof a != "object" || a === null)
|
|
3776
|
-
throw new
|
|
3776
|
+
throw new D(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
|
|
3777
3777
|
$o(a, e, n, `${r}.$`, s);
|
|
3778
3778
|
}
|
|
3779
3779
|
}, xn = (t, e) => {
|
|
3780
3780
|
if (typeof t != "object" || t === null)
|
|
3781
|
-
throw new
|
|
3781
|
+
throw new D(`Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`);
|
|
3782
3782
|
if (Array.isArray(t))
|
|
3783
|
-
throw new
|
|
3783
|
+
throw new D(`Query must be an object, but received: ${typeof t}`);
|
|
3784
3784
|
const n = t;
|
|
3785
3785
|
for (const r of Object.keys(n)) {
|
|
3786
3786
|
if (Array.isArray(t[r]))
|
|
3787
|
-
throw new
|
|
3787
|
+
throw new D(`Query keys must be strings, but found key of type: ${typeof r}`, r);
|
|
3788
3788
|
if (typeof r != "string")
|
|
3789
|
-
throw new
|
|
3789
|
+
throw new D(`Query keys must be strings, but found key of type: ${typeof r}`, r);
|
|
3790
3790
|
if (r !== "$$ruleParams") {
|
|
3791
3791
|
if (e && !e.entities[r]) {
|
|
3792
3792
|
const s = Object.keys(e.entities);
|
|
3793
|
-
throw new
|
|
3793
|
+
throw new D(`Entity '${r}' does not exist in schema. Available entities: ${s.length > 0 ? s.join(", ") : "none"}`, r);
|
|
3794
3794
|
}
|
|
3795
3795
|
Cr(n[r], r, e, r, 0);
|
|
3796
3796
|
}
|
|
3797
3797
|
}
|
|
3798
3798
|
}, Rn = (t) => typeof t != "string" ? !1 : ot(t) ? !0 : Me(t);
|
|
3799
|
-
class
|
|
3799
|
+
class ae extends Error {
|
|
3800
3800
|
constructor(e) {
|
|
3801
3801
|
super(e), this.name = "TransactionValidationError";
|
|
3802
3802
|
}
|
|
3803
3803
|
}
|
|
3804
|
-
const Er = (t) => t.length > 0 ? t.join(", ") : "none", xo = (t, e) => new
|
|
3804
|
+
const Er = (t) => t.length > 0 ? t.join(", ") : "none", xo = (t, e) => new ae(`Entity '${t}' does not exist in schema. Available entities: ${Er(e)}`), vt = {
|
|
3805
3805
|
string: (t) => typeof t == "string",
|
|
3806
3806
|
number: (t) => typeof t == "number" && !isNaN(t),
|
|
3807
3807
|
boolean: (t) => typeof t == "boolean",
|
|
@@ -3818,30 +3818,30 @@ const Er = (t) => t.length > 0 ? t.join(", ") : "none", xo = (t, e) => new ie(`E
|
|
|
3818
3818
|
}, At = (t, e, n) => {
|
|
3819
3819
|
const r = Pr(t, n);
|
|
3820
3820
|
if (typeof e != "object" || e === null)
|
|
3821
|
-
throw new
|
|
3821
|
+
throw new ae(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
|
|
3822
3822
|
for (const [s, i] of Object.entries(e)) {
|
|
3823
3823
|
if (s === "id")
|
|
3824
3824
|
continue;
|
|
3825
3825
|
const o = r.attrs[s];
|
|
3826
3826
|
if (o && !Ro(i, o))
|
|
3827
|
-
throw new
|
|
3827
|
+
throw new ae(`Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`);
|
|
3828
3828
|
}
|
|
3829
3829
|
}, Dn = (t, e, n) => {
|
|
3830
3830
|
const r = Pr(t, n);
|
|
3831
3831
|
if (typeof e != "object" || e === null)
|
|
3832
|
-
throw new
|
|
3832
|
+
throw new ae(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
|
|
3833
3833
|
for (const [s, i] of Object.entries(e)) {
|
|
3834
3834
|
if (!r.links[s]) {
|
|
3835
3835
|
const a = Object.keys(r.links);
|
|
3836
|
-
throw new
|
|
3836
|
+
throw new ae(`Link '${s}' does not exist on entity '${t}'. Available links: ${Er(a)}`);
|
|
3837
3837
|
}
|
|
3838
3838
|
if (i != null) {
|
|
3839
3839
|
if (Array.isArray(i)) {
|
|
3840
3840
|
for (const a of i)
|
|
3841
3841
|
if (!Rn(a))
|
|
3842
|
-
throw new
|
|
3842
|
+
throw new ae(`Invalid entity ID in link '${s}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
|
|
3843
3843
|
} else if (!Rn(i))
|
|
3844
|
-
throw new
|
|
3844
|
+
throw new ae(`Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`);
|
|
3845
3845
|
}
|
|
3846
3846
|
}
|
|
3847
3847
|
}, Do = {
|
|
@@ -3857,21 +3857,21 @@ const Er = (t) => t.length > 0 ? t.join(", ") : "none", xo = (t, e) => new ie(`E
|
|
|
3857
3857
|
return;
|
|
3858
3858
|
const [n, r, s, i] = t;
|
|
3859
3859
|
if (!Array.isArray(s) && !Me(s))
|
|
3860
|
-
throw new
|
|
3860
|
+
throw new ae(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
|
|
3861
3861
|
if (typeof r != "string")
|
|
3862
|
-
throw new
|
|
3862
|
+
throw new ae(`Entity name must be a string, but received: ${typeof r}`);
|
|
3863
3863
|
const o = Do[n];
|
|
3864
3864
|
o && i !== void 0 && o(r, i, e);
|
|
3865
3865
|
}, Lo = (t, e) => {
|
|
3866
3866
|
const n = Array.isArray(t) ? t : [t];
|
|
3867
3867
|
for (const r of n) {
|
|
3868
3868
|
if (!r || typeof r != "object")
|
|
3869
|
-
throw new
|
|
3869
|
+
throw new ae(`Transaction chunk must be an object, but received: ${typeof r}`);
|
|
3870
3870
|
if (!Array.isArray(r.__ops))
|
|
3871
|
-
throw new
|
|
3871
|
+
throw new ae(`Transaction chunk must have __ops array, but received: ${typeof r.__ops}`);
|
|
3872
3872
|
for (const s of r.__ops) {
|
|
3873
3873
|
if (!Array.isArray(s))
|
|
3874
|
-
throw new
|
|
3874
|
+
throw new ae(`Transaction operation must be an array, but received: ${typeof s}`);
|
|
3875
3875
|
Uo(s, e);
|
|
3876
3876
|
}
|
|
3877
3877
|
}
|
|
@@ -4046,7 +4046,7 @@ function kt(t, e, n) {
|
|
|
4046
4046
|
}
|
|
4047
4047
|
function Ln(t, e, n, r) {
|
|
4048
4048
|
var o;
|
|
4049
|
-
const s = (o =
|
|
4049
|
+
const s = (o = W(n, t.table, "id")) == null ? void 0 : o.id;
|
|
4050
4050
|
if (!s)
|
|
4051
4051
|
return -1;
|
|
4052
4052
|
const i = $e(e.eav, [r, s, r]);
|
|
@@ -4095,7 +4095,7 @@ function Wo(t, e) {
|
|
|
4095
4095
|
var r;
|
|
4096
4096
|
if (t.orderFieldType)
|
|
4097
4097
|
return t.orderFieldType;
|
|
4098
|
-
const n = t.orderField === "serverCreatedAt" ? "number" : (r =
|
|
4098
|
+
const n = t.orderField === "serverCreatedAt" ? "number" : (r = W(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
|
|
4099
4099
|
return t.orderFieldType = n, n;
|
|
4100
4100
|
}
|
|
4101
4101
|
function Vo(t, e, n) {
|
|
@@ -4154,7 +4154,7 @@ class Qo {
|
|
|
4154
4154
|
this.subs.flush();
|
|
4155
4155
|
}
|
|
4156
4156
|
subscribe(e, n) {
|
|
4157
|
-
const r =
|
|
4157
|
+
const r = H(e);
|
|
4158
4158
|
return this.callbacks[r] = this.callbacks[r] || [], this.callbacks[r].push(n), this.initSubscription(e, r, n), (s) => {
|
|
4159
4159
|
this.unsubscribe(r, n, s == null ? void 0 : s.keepSubscription);
|
|
4160
4160
|
};
|
|
@@ -4170,7 +4170,7 @@ class Qo {
|
|
|
4170
4170
|
}
|
|
4171
4171
|
}
|
|
4172
4172
|
sendStart(e) {
|
|
4173
|
-
this.trySend(
|
|
4173
|
+
this.trySend(N(), {
|
|
4174
4174
|
op: "start-sync",
|
|
4175
4175
|
q: e
|
|
4176
4176
|
});
|
|
@@ -4184,7 +4184,7 @@ class Qo {
|
|
|
4184
4184
|
});
|
|
4185
4185
|
}
|
|
4186
4186
|
sendRemove(e, n) {
|
|
4187
|
-
this.trySend(
|
|
4187
|
+
this.trySend(N(), {
|
|
4188
4188
|
op: "remove-sync",
|
|
4189
4189
|
"subscription-id": e.subscriptionId,
|
|
4190
4190
|
"keep-subscription": n
|
|
@@ -4222,7 +4222,7 @@ class Qo {
|
|
|
4222
4222
|
}
|
|
4223
4223
|
}
|
|
4224
4224
|
onStartSyncOk(e) {
|
|
4225
|
-
const n = e["subscription-id"], r = e.q, s =
|
|
4225
|
+
const n = e["subscription-id"], r = e.q, s = H(r);
|
|
4226
4226
|
this.idToHash[n] = s, this.subs.updateInPlace((i) => {
|
|
4227
4227
|
const o = i[s];
|
|
4228
4228
|
if (!o)
|
|
@@ -4317,8 +4317,8 @@ class Qo {
|
|
|
4317
4317
|
i.txId = a["tx-id"];
|
|
4318
4318
|
const c = [], u = {};
|
|
4319
4319
|
for (const w of a.changes) {
|
|
4320
|
-
const
|
|
4321
|
-
u[w.triple[0]] =
|
|
4320
|
+
const _ = u[w.triple[0]] ?? [];
|
|
4321
|
+
u[w.triple[0]] = _, _.push(w);
|
|
4322
4322
|
}
|
|
4323
4323
|
const l = s.values ?? {
|
|
4324
4324
|
entities: [],
|
|
@@ -4326,44 +4326,44 @@ class Qo {
|
|
|
4326
4326
|
}, f = l.entities;
|
|
4327
4327
|
s.values = l;
|
|
4328
4328
|
const d = [];
|
|
4329
|
-
e: for (const [w,
|
|
4330
|
-
for (let
|
|
4331
|
-
const
|
|
4332
|
-
if (
|
|
4333
|
-
Fn(
|
|
4334
|
-
const
|
|
4335
|
-
|
|
4336
|
-
oldEntity:
|
|
4337
|
-
newEntity:
|
|
4338
|
-
changedFields:
|
|
4339
|
-
}),
|
|
4329
|
+
e: for (const [w, _] of Object.entries(u))
|
|
4330
|
+
for (let g = 0; g < f.length; g++) {
|
|
4331
|
+
const m = f[g];
|
|
4332
|
+
if (Ts(m.store, w)) {
|
|
4333
|
+
Fn(m.store, l.attrsStore, _);
|
|
4334
|
+
const I = kt(s, m.store, l.attrsStore), S = zo(m.store, l.attrsStore, _)[w];
|
|
4335
|
+
I ? (d.push({
|
|
4336
|
+
oldEntity: m.entity,
|
|
4337
|
+
newEntity: I,
|
|
4338
|
+
changedFields: S || {}
|
|
4339
|
+
}), m.entity = I) : c.push(g), delete u[w];
|
|
4340
4340
|
continue e;
|
|
4341
4341
|
}
|
|
4342
4342
|
}
|
|
4343
4343
|
const p = [];
|
|
4344
|
-
for (const [w,
|
|
4345
|
-
const
|
|
4346
|
-
Fn(
|
|
4347
|
-
const
|
|
4348
|
-
if (!
|
|
4344
|
+
for (const [w, _] of Object.entries(u)) {
|
|
4345
|
+
const g = this.createStore([]);
|
|
4346
|
+
Fn(g, l.attrsStore, _);
|
|
4347
|
+
const m = kt(s, g, l.attrsStore);
|
|
4348
|
+
if (!m) {
|
|
4349
4349
|
this.log.error("No entity found after applying change", {
|
|
4350
4350
|
sub: s,
|
|
4351
|
-
changes:
|
|
4352
|
-
store:
|
|
4351
|
+
changes: _,
|
|
4352
|
+
store: g
|
|
4353
4353
|
});
|
|
4354
4354
|
continue;
|
|
4355
4355
|
}
|
|
4356
4356
|
f.push({
|
|
4357
|
-
store:
|
|
4358
|
-
entity:
|
|
4359
|
-
serverCreatedAt: Ln(s,
|
|
4360
|
-
}), p.push(
|
|
4357
|
+
store: g,
|
|
4358
|
+
entity: m,
|
|
4359
|
+
serverCreatedAt: Ln(s, g, l.attrsStore, m.id)
|
|
4360
|
+
}), p.push(m);
|
|
4361
4361
|
}
|
|
4362
4362
|
const y = [];
|
|
4363
4363
|
for (const w of c.sort().reverse())
|
|
4364
4364
|
y.push(f[w].entity), f.splice(w, 1);
|
|
4365
|
-
const
|
|
4366
|
-
Vo(s,
|
|
4365
|
+
const b = Wo(s, this.getAttrs);
|
|
4366
|
+
Vo(s, b, f), this.notifyCbs(r, {
|
|
4367
4367
|
type: _e.SyncTransaction,
|
|
4368
4368
|
data: Ge(s, (o = s.values) == null ? void 0 : o.entities),
|
|
4369
4369
|
added: p,
|
|
@@ -4387,7 +4387,7 @@ class Qo {
|
|
|
4387
4387
|
}
|
|
4388
4388
|
}
|
|
4389
4389
|
onStartSyncError(e) {
|
|
4390
|
-
const n =
|
|
4390
|
+
const n = H(e["original-event"].q), r = {
|
|
4391
4391
|
message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa.",
|
|
4392
4392
|
status: e.status,
|
|
4393
4393
|
type: e.type,
|
|
@@ -4407,197 +4407,197 @@ class Qo {
|
|
|
4407
4407
|
function Bo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStream: s }) {
|
|
4408
4408
|
const i = e.clientId;
|
|
4409
4409
|
let o = null, a = null, c = null;
|
|
4410
|
-
const u =
|
|
4410
|
+
const u = N();
|
|
4411
4411
|
let l = !1, f = !1;
|
|
4412
4412
|
const d = [], p = [], y = [];
|
|
4413
|
-
let
|
|
4414
|
-
const
|
|
4415
|
-
function
|
|
4413
|
+
let b = !1, w = 0, _ = 0;
|
|
4414
|
+
const g = [], m = new TextEncoder();
|
|
4415
|
+
function I() {
|
|
4416
4416
|
f = !0;
|
|
4417
|
-
for (const
|
|
4418
|
-
|
|
4417
|
+
for (const T of d)
|
|
4418
|
+
T(a ?? void 0);
|
|
4419
4419
|
}
|
|
4420
|
-
function T
|
|
4421
|
-
return d.push(
|
|
4422
|
-
const
|
|
4423
|
-
|
|
4420
|
+
function S(T) {
|
|
4421
|
+
return d.push(T), f && T(a ?? void 0), () => {
|
|
4422
|
+
const v = d.indexOf(T);
|
|
4423
|
+
v !== -1 && d.splice(v, 1);
|
|
4424
4424
|
};
|
|
4425
4425
|
}
|
|
4426
|
-
function
|
|
4427
|
-
return y.push(
|
|
4428
|
-
const
|
|
4429
|
-
|
|
4426
|
+
function M(T) {
|
|
4427
|
+
return y.push(T), () => {
|
|
4428
|
+
const v = y.indexOf(T);
|
|
4429
|
+
v !== -1 && y.splice(v, 1);
|
|
4430
4430
|
};
|
|
4431
4431
|
}
|
|
4432
|
-
e.waitUntil && e.waitUntil(new Promise((
|
|
4433
|
-
y.push(
|
|
4432
|
+
e.waitUntil && e.waitUntil(new Promise((T) => {
|
|
4433
|
+
y.push(T);
|
|
4434
4434
|
}));
|
|
4435
|
-
function
|
|
4436
|
-
for (const
|
|
4435
|
+
function O() {
|
|
4436
|
+
for (const T of y)
|
|
4437
4437
|
try {
|
|
4438
|
-
|
|
4438
|
+
T();
|
|
4439
4439
|
} catch {
|
|
4440
4440
|
}
|
|
4441
4441
|
}
|
|
4442
|
-
function
|
|
4443
|
-
return p.push(
|
|
4444
|
-
const
|
|
4445
|
-
|
|
4442
|
+
function k(T) {
|
|
4443
|
+
return p.push(T), o && T(o), () => {
|
|
4444
|
+
const v = p.indexOf(T);
|
|
4445
|
+
v !== -1 && p.splice(v, 1);
|
|
4446
4446
|
};
|
|
4447
4447
|
}
|
|
4448
|
-
function
|
|
4449
|
-
o =
|
|
4450
|
-
for (const
|
|
4451
|
-
|
|
4448
|
+
function F(T) {
|
|
4449
|
+
o = T;
|
|
4450
|
+
for (const v of p)
|
|
4451
|
+
v(o);
|
|
4452
4452
|
}
|
|
4453
|
-
function
|
|
4454
|
-
|
|
4453
|
+
function x() {
|
|
4454
|
+
b = !0;
|
|
4455
4455
|
}
|
|
4456
|
-
function
|
|
4457
|
-
let
|
|
4458
|
-
for (const { byteLen:
|
|
4459
|
-
const
|
|
4460
|
-
if (
|
|
4456
|
+
function L(T) {
|
|
4457
|
+
let v = w, R = 0, q = 0;
|
|
4458
|
+
for (const { byteLen: V } of g) {
|
|
4459
|
+
const se = v + V;
|
|
4460
|
+
if (se > T)
|
|
4461
4461
|
break;
|
|
4462
|
-
|
|
4462
|
+
v = se, R++, q += V;
|
|
4463
4463
|
}
|
|
4464
|
-
|
|
4464
|
+
R > 0 && (w += q, _ -= q, g.splice(0, R));
|
|
4465
4465
|
}
|
|
4466
|
-
function
|
|
4467
|
-
a =
|
|
4466
|
+
function U(T, v) {
|
|
4467
|
+
a = v, I(), T.error(v), O();
|
|
4468
4468
|
}
|
|
4469
|
-
async function
|
|
4470
|
-
const
|
|
4469
|
+
async function Q() {
|
|
4470
|
+
const T = await n({
|
|
4471
4471
|
clientId: i,
|
|
4472
4472
|
reconnectToken: u,
|
|
4473
4473
|
ruleParams: e.ruleParams
|
|
4474
4474
|
});
|
|
4475
|
-
switch (
|
|
4475
|
+
switch (T.type) {
|
|
4476
4476
|
case "ok": {
|
|
4477
|
-
const { streamId:
|
|
4478
|
-
o =
|
|
4479
|
-
streamId:
|
|
4480
|
-
chunks:
|
|
4477
|
+
const { streamId: v, offset: R } = T;
|
|
4478
|
+
o = v, L(R), g.length && r({
|
|
4479
|
+
streamId: v,
|
|
4480
|
+
chunks: g.map((q) => q.chunk),
|
|
4481
4481
|
offset: w
|
|
4482
|
-
}),
|
|
4482
|
+
}), b = !1;
|
|
4483
4483
|
break;
|
|
4484
4484
|
}
|
|
4485
4485
|
case "disconnect": {
|
|
4486
|
-
|
|
4486
|
+
x();
|
|
4487
4487
|
break;
|
|
4488
4488
|
}
|
|
4489
4489
|
case "error": {
|
|
4490
|
-
c &&
|
|
4490
|
+
c && U(c, T.error);
|
|
4491
4491
|
break;
|
|
4492
4492
|
}
|
|
4493
4493
|
}
|
|
4494
4494
|
}
|
|
4495
|
-
function
|
|
4496
|
-
|
|
4495
|
+
function K() {
|
|
4496
|
+
x(), Q();
|
|
4497
4497
|
}
|
|
4498
|
-
function
|
|
4499
|
-
|
|
4498
|
+
function A({ offset: T, done: v }) {
|
|
4499
|
+
L(T), v && (l = !0, O());
|
|
4500
4500
|
}
|
|
4501
|
-
function
|
|
4502
|
-
return l ? (
|
|
4501
|
+
function P(T) {
|
|
4502
|
+
return l ? (U(T, new Y("Stream has been closed.")), null) : o || (U(T, new Y("Stream has not been initialized.")), null);
|
|
4503
4503
|
}
|
|
4504
|
-
async function
|
|
4505
|
-
c =
|
|
4506
|
-
let
|
|
4507
|
-
for (;
|
|
4508
|
-
let
|
|
4509
|
-
|
|
4510
|
-
const
|
|
4504
|
+
async function C(T) {
|
|
4505
|
+
c = T;
|
|
4506
|
+
let v = !0, R = 0;
|
|
4507
|
+
for (; v; ) {
|
|
4508
|
+
let q = Date.now() + Math.min(15e3, 500 * (R - 1));
|
|
4509
|
+
v = !1;
|
|
4510
|
+
const V = await n({
|
|
4511
4511
|
clientId: e.clientId,
|
|
4512
4512
|
reconnectToken: u,
|
|
4513
4513
|
ruleParams: e.ruleParams
|
|
4514
4514
|
});
|
|
4515
|
-
switch (
|
|
4515
|
+
switch (V.type) {
|
|
4516
4516
|
case "ok": {
|
|
4517
|
-
const { streamId:
|
|
4517
|
+
const { streamId: se, offset: mt } = V;
|
|
4518
4518
|
if (mt !== 0) {
|
|
4519
|
-
const we = new
|
|
4520
|
-
|
|
4519
|
+
const we = new Y("Write stream is corrupted");
|
|
4520
|
+
U(T, we);
|
|
4521
4521
|
return;
|
|
4522
4522
|
}
|
|
4523
|
-
|
|
4524
|
-
onDisconnect:
|
|
4525
|
-
onFlush:
|
|
4526
|
-
onConnectionReconnect:
|
|
4527
|
-
onAppendFailed:
|
|
4528
|
-
}),
|
|
4523
|
+
F(se), s(se, {
|
|
4524
|
+
onDisconnect: x,
|
|
4525
|
+
onFlush: A,
|
|
4526
|
+
onConnectionReconnect: Q,
|
|
4527
|
+
onAppendFailed: K
|
|
4528
|
+
}), b = !1;
|
|
4529
4529
|
return;
|
|
4530
4530
|
}
|
|
4531
4531
|
case "disconnect": {
|
|
4532
|
-
|
|
4533
|
-
setTimeout(
|
|
4532
|
+
v = !0, x(), R++, await new Promise((se) => {
|
|
4533
|
+
setTimeout(se, Math.max(0, q - Date.now()));
|
|
4534
4534
|
});
|
|
4535
4535
|
break;
|
|
4536
4536
|
}
|
|
4537
4537
|
case "error": {
|
|
4538
|
-
|
|
4538
|
+
U(T, V.error);
|
|
4539
4539
|
return;
|
|
4540
4540
|
}
|
|
4541
4541
|
}
|
|
4542
4542
|
}
|
|
4543
4543
|
}
|
|
4544
|
-
class
|
|
4545
|
-
constructor(
|
|
4546
|
-
super(
|
|
4544
|
+
class j extends t {
|
|
4545
|
+
constructor(v, R) {
|
|
4546
|
+
super(v, R);
|
|
4547
4547
|
}
|
|
4548
4548
|
async streamId() {
|
|
4549
|
-
return o || new Promise((
|
|
4550
|
-
const
|
|
4551
|
-
for (const we of
|
|
4549
|
+
return o || new Promise((v, R) => {
|
|
4550
|
+
const q = [], V = () => {
|
|
4551
|
+
for (const we of q)
|
|
4552
4552
|
we();
|
|
4553
|
-
},
|
|
4554
|
-
|
|
4553
|
+
}, se = (we) => {
|
|
4554
|
+
v(we), V();
|
|
4555
4555
|
}, mt = (we) => {
|
|
4556
|
-
|
|
4556
|
+
R(we || new Y("Stream is closed.")), V();
|
|
4557
4557
|
};
|
|
4558
|
-
|
|
4558
|
+
q.push(k(se)), q.push(S(mt));
|
|
4559
4559
|
});
|
|
4560
4560
|
}
|
|
4561
4561
|
}
|
|
4562
4562
|
return {
|
|
4563
|
-
stream: new
|
|
4563
|
+
stream: new j({
|
|
4564
4564
|
// TODO(dww): accept a storage so that write streams can survive across
|
|
4565
4565
|
// browser restarts
|
|
4566
|
-
async start(
|
|
4566
|
+
async start(T) {
|
|
4567
4567
|
try {
|
|
4568
|
-
await
|
|
4569
|
-
} catch (
|
|
4570
|
-
|
|
4568
|
+
await C(T);
|
|
4569
|
+
} catch (v) {
|
|
4570
|
+
U(T, v);
|
|
4571
4571
|
}
|
|
4572
4572
|
},
|
|
4573
|
-
write(
|
|
4574
|
-
const
|
|
4575
|
-
if (
|
|
4576
|
-
const
|
|
4577
|
-
|
|
4578
|
-
const
|
|
4579
|
-
|
|
4573
|
+
write(T, v) {
|
|
4574
|
+
const R = P(v);
|
|
4575
|
+
if (R) {
|
|
4576
|
+
const q = m.encode(T).length;
|
|
4577
|
+
g.push({ chunk: T, byteLen: q });
|
|
4578
|
+
const V = w + _;
|
|
4579
|
+
_ += q, b || r({ streamId: R, chunks: [T], offset: V });
|
|
4580
4580
|
}
|
|
4581
4581
|
},
|
|
4582
4582
|
close() {
|
|
4583
4583
|
o ? r({
|
|
4584
4584
|
streamId: o,
|
|
4585
4585
|
chunks: [],
|
|
4586
|
-
offset: w +
|
|
4586
|
+
offset: w + _,
|
|
4587
4587
|
isDone: !0
|
|
4588
|
-
}) :
|
|
4588
|
+
}) : O(), I();
|
|
4589
4589
|
},
|
|
4590
|
-
abort(
|
|
4590
|
+
abort(T) {
|
|
4591
4591
|
o ? r({
|
|
4592
4592
|
streamId: o,
|
|
4593
4593
|
chunks: [],
|
|
4594
|
-
offset: w +
|
|
4594
|
+
offset: w + _,
|
|
4595
4595
|
isDone: !0,
|
|
4596
|
-
abortReason:
|
|
4597
|
-
}) :
|
|
4596
|
+
abortReason: T
|
|
4597
|
+
}) : O(), I();
|
|
4598
4598
|
}
|
|
4599
4599
|
}),
|
|
4600
|
-
addCompleteCb:
|
|
4600
|
+
addCompleteCb: M,
|
|
4601
4601
|
closed() {
|
|
4602
4602
|
return f;
|
|
4603
4603
|
}
|
|
@@ -4641,123 +4641,155 @@ function Ho({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
|
4641
4641
|
let s = e.byteOffset || 0, i = !1;
|
|
4642
4642
|
const o = new TextDecoder("utf-8"), a = new TextEncoder();
|
|
4643
4643
|
let c, u = !1;
|
|
4644
|
-
const l = [];
|
|
4645
|
-
|
|
4644
|
+
const l = [], f = [];
|
|
4645
|
+
let d = null, p = null;
|
|
4646
|
+
function y(O) {
|
|
4646
4647
|
u = !0;
|
|
4647
|
-
for (const
|
|
4648
|
-
|
|
4648
|
+
for (const k of l)
|
|
4649
|
+
k(O);
|
|
4650
|
+
}
|
|
4651
|
+
function b(O) {
|
|
4652
|
+
return l.push(O), () => {
|
|
4653
|
+
const k = l.indexOf(O);
|
|
4654
|
+
k !== -1 && l.splice(k, 1);
|
|
4655
|
+
};
|
|
4649
4656
|
}
|
|
4650
|
-
function
|
|
4651
|
-
return
|
|
4652
|
-
const
|
|
4653
|
-
|
|
4657
|
+
function w(O) {
|
|
4658
|
+
return f.push(O), d && O(d), () => {
|
|
4659
|
+
const k = f.indexOf(O);
|
|
4660
|
+
k !== -1 && f.splice(k, 1);
|
|
4654
4661
|
};
|
|
4655
4662
|
}
|
|
4656
|
-
function
|
|
4657
|
-
|
|
4663
|
+
function _(O, k) {
|
|
4664
|
+
p = k, O.error(k), y(k);
|
|
4658
4665
|
}
|
|
4659
|
-
let
|
|
4660
|
-
async function
|
|
4661
|
-
c =
|
|
4662
|
-
const
|
|
4663
|
-
for await (const
|
|
4666
|
+
let g = 0;
|
|
4667
|
+
async function m(O, k) {
|
|
4668
|
+
c = N();
|
|
4669
|
+
const F = { ...O || {}, eventId: c };
|
|
4670
|
+
for await (const x of n(F)) {
|
|
4664
4671
|
if (i)
|
|
4665
4672
|
return;
|
|
4666
|
-
if (
|
|
4673
|
+
if (x.type === "reconnect")
|
|
4667
4674
|
return { retry: !0 };
|
|
4668
|
-
if (
|
|
4669
|
-
|
|
4675
|
+
if (x.type === "error") {
|
|
4676
|
+
_(k, x.error);
|
|
4670
4677
|
return;
|
|
4671
4678
|
}
|
|
4672
|
-
if (
|
|
4673
|
-
|
|
4679
|
+
if (x.offset > s) {
|
|
4680
|
+
_(k, new Y("Stream is corrupted.")), i = !0;
|
|
4674
4681
|
return;
|
|
4675
4682
|
}
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4683
|
+
d = x.streamId;
|
|
4684
|
+
for (const U of f)
|
|
4685
|
+
U(d);
|
|
4686
|
+
let L = s - x.offset;
|
|
4687
|
+
if (x.files && x.files.length) {
|
|
4688
|
+
const U = new AbortController();
|
|
4689
|
+
let Q = fetch(x.files[0].url, {
|
|
4690
|
+
signal: U.signal
|
|
4681
4691
|
});
|
|
4682
|
-
for (let
|
|
4683
|
-
const
|
|
4684
|
-
if (
|
|
4685
|
-
if (
|
|
4686
|
-
|
|
4692
|
+
for (let K = 0; K < x.files.length; K++) {
|
|
4693
|
+
const A = x.files[K + 1], C = await Q;
|
|
4694
|
+
if (A && (Q = fetch(A.url, { signal: U.signal })), !C.ok) {
|
|
4695
|
+
if (g++, g > 10) {
|
|
4696
|
+
_(k, new Y("Unable to process stream."));
|
|
4687
4697
|
return;
|
|
4688
4698
|
}
|
|
4689
4699
|
return { retry: !0 };
|
|
4690
4700
|
}
|
|
4691
|
-
if (
|
|
4692
|
-
const
|
|
4701
|
+
if (C.body) {
|
|
4702
|
+
const j = C.body.getReader();
|
|
4693
4703
|
try {
|
|
4694
4704
|
for (; ; ) {
|
|
4695
|
-
const { done:
|
|
4696
|
-
if (
|
|
4705
|
+
const { done: $, value: T } = await j.read();
|
|
4706
|
+
if ($)
|
|
4697
4707
|
break;
|
|
4698
4708
|
if (i) {
|
|
4699
|
-
|
|
4709
|
+
U.abort();
|
|
4700
4710
|
return;
|
|
4701
4711
|
}
|
|
4702
|
-
let
|
|
4703
|
-
if (
|
|
4712
|
+
let v = T;
|
|
4713
|
+
if (L > 0 && (v = T.subarray(L), L -= T.length - v.length), !v.length)
|
|
4704
4714
|
continue;
|
|
4705
|
-
s +=
|
|
4706
|
-
const
|
|
4707
|
-
|
|
4715
|
+
s += v.length;
|
|
4716
|
+
const R = o.decode(v);
|
|
4717
|
+
k.enqueue(R);
|
|
4708
4718
|
}
|
|
4709
4719
|
} finally {
|
|
4710
|
-
|
|
4720
|
+
j.releaseLock();
|
|
4711
4721
|
}
|
|
4712
4722
|
} else {
|
|
4713
|
-
const
|
|
4714
|
-
let
|
|
4723
|
+
const j = await C.arrayBuffer();
|
|
4724
|
+
let $ = j;
|
|
4715
4725
|
if (i) {
|
|
4716
|
-
|
|
4726
|
+
U.abort();
|
|
4717
4727
|
return;
|
|
4718
4728
|
}
|
|
4719
|
-
if (
|
|
4729
|
+
if (L > 0 && ($ = new Uint8Array(j).subarray(L), L -= j.byteLength - $.length), !$.byteLength)
|
|
4720
4730
|
continue;
|
|
4721
|
-
s +=
|
|
4722
|
-
const
|
|
4723
|
-
|
|
4731
|
+
s += $.byteLength;
|
|
4732
|
+
const T = o.decode($);
|
|
4733
|
+
k.enqueue(T);
|
|
4724
4734
|
}
|
|
4725
4735
|
}
|
|
4726
4736
|
}
|
|
4727
|
-
if (
|
|
4728
|
-
let
|
|
4729
|
-
if (
|
|
4730
|
-
const
|
|
4731
|
-
if (
|
|
4737
|
+
if (g = 0, x.content) {
|
|
4738
|
+
let U = x.content, Q = a.encode(x.content);
|
|
4739
|
+
if (L > 0) {
|
|
4740
|
+
const K = Q.subarray(L);
|
|
4741
|
+
if (L -= Q.length - K.length, !K.length)
|
|
4732
4742
|
continue;
|
|
4733
|
-
|
|
4743
|
+
Q = K, U = o.decode(K);
|
|
4734
4744
|
}
|
|
4735
|
-
s +=
|
|
4745
|
+
s += Q.length, k.enqueue(U);
|
|
4736
4746
|
}
|
|
4737
4747
|
}
|
|
4738
4748
|
}
|
|
4739
|
-
async function
|
|
4740
|
-
let
|
|
4741
|
-
for (;
|
|
4742
|
-
|
|
4743
|
-
let
|
|
4744
|
-
const
|
|
4745
|
-
|
|
4746
|
-
setTimeout(
|
|
4749
|
+
async function I(O) {
|
|
4750
|
+
let k = !0, F = 0;
|
|
4751
|
+
for (; k; ) {
|
|
4752
|
+
k = !1;
|
|
4753
|
+
let x = Date.now() + Math.min(15e3, 500 * (F - 1));
|
|
4754
|
+
const L = await m({ ...e, offset: s }, O);
|
|
4755
|
+
L != null && L.retry && (k = !0, F++, x < Date.now() - 3e5 && (F = 0), await new Promise((U) => {
|
|
4756
|
+
setTimeout(U, Math.max(0, x - Date.now()));
|
|
4747
4757
|
}));
|
|
4748
4758
|
}
|
|
4749
|
-
!i && !u && (
|
|
4759
|
+
!i && !u && (O.close(), y());
|
|
4760
|
+
}
|
|
4761
|
+
class S extends t {
|
|
4762
|
+
constructor(k, F) {
|
|
4763
|
+
super(k, F);
|
|
4764
|
+
}
|
|
4765
|
+
async streamId() {
|
|
4766
|
+
if (d)
|
|
4767
|
+
return d;
|
|
4768
|
+
if (p)
|
|
4769
|
+
throw p;
|
|
4770
|
+
return new Promise((k, F) => {
|
|
4771
|
+
const x = [], L = () => {
|
|
4772
|
+
for (const K of x)
|
|
4773
|
+
K();
|
|
4774
|
+
}, U = (K) => {
|
|
4775
|
+
k(K), L();
|
|
4776
|
+
}, Q = (K) => {
|
|
4777
|
+
F(K || new Y("Stream is closed.")), L();
|
|
4778
|
+
};
|
|
4779
|
+
x.push(w(U)), x.push(b(Q));
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4750
4782
|
}
|
|
4751
4783
|
return {
|
|
4752
|
-
stream: new
|
|
4753
|
-
start(
|
|
4754
|
-
|
|
4784
|
+
stream: new S({
|
|
4785
|
+
start(O) {
|
|
4786
|
+
I(O);
|
|
4755
4787
|
},
|
|
4756
|
-
cancel(
|
|
4757
|
-
i = !0, c && r({ eventId: c }),
|
|
4788
|
+
cancel(O) {
|
|
4789
|
+
i = !0, c && r({ eventId: c }), y();
|
|
4758
4790
|
}
|
|
4759
4791
|
}),
|
|
4760
|
-
addCloseCb:
|
|
4792
|
+
addCloseCb: b,
|
|
4761
4793
|
closed() {
|
|
4762
4794
|
return u;
|
|
4763
4795
|
}
|
|
@@ -4799,7 +4831,7 @@ class Jo {
|
|
|
4799
4831
|
}), n;
|
|
4800
4832
|
}
|
|
4801
4833
|
startWriteStream(e) {
|
|
4802
|
-
const n =
|
|
4834
|
+
const n = N();
|
|
4803
4835
|
let r = null;
|
|
4804
4836
|
const s = new Promise((o) => {
|
|
4805
4837
|
r = o;
|
|
@@ -4823,7 +4855,7 @@ class Jo {
|
|
|
4823
4855
|
offset: s,
|
|
4824
4856
|
done: !!r
|
|
4825
4857
|
};
|
|
4826
|
-
i && (o["abort-reason"] = i), this.trySend(
|
|
4858
|
+
i && (o["abort-reason"] = i), this.trySend(N(), o);
|
|
4827
4859
|
}
|
|
4828
4860
|
onAppendFailed(e) {
|
|
4829
4861
|
const n = this.writeStreams[e["stream-id"]];
|
|
@@ -4858,10 +4890,9 @@ class Jo {
|
|
|
4858
4890
|
op: "unsubscribe-stream",
|
|
4859
4891
|
"subscribe-event-id": e
|
|
4860
4892
|
};
|
|
4861
|
-
this.trySend(
|
|
4893
|
+
this.trySend(N(), n), delete this.readStreamIterators[e];
|
|
4862
4894
|
}
|
|
4863
4895
|
onStreamAppend(e) {
|
|
4864
|
-
var s;
|
|
4865
4896
|
const n = e["client-event-id"], r = this.readStreamIterators[n];
|
|
4866
4897
|
if (!r) {
|
|
4867
4898
|
this.log.info("No iterator for read stream", e);
|
|
@@ -4870,21 +4901,22 @@ class Jo {
|
|
|
4870
4901
|
if (e.error) {
|
|
4871
4902
|
e.retry ? r.push({ type: "reconnect" }) : r.push({
|
|
4872
4903
|
type: "error",
|
|
4873
|
-
error: new
|
|
4904
|
+
error: new Y(e.error)
|
|
4874
4905
|
}), r.close(), delete this.readStreamIterators[n];
|
|
4875
4906
|
return;
|
|
4876
4907
|
}
|
|
4877
|
-
|
|
4908
|
+
r.push({
|
|
4878
4909
|
type: "append",
|
|
4879
4910
|
offset: e.offset,
|
|
4880
4911
|
files: e.files,
|
|
4881
|
-
content: e.content
|
|
4912
|
+
content: e.content,
|
|
4913
|
+
streamId: e["stream-id"]
|
|
4882
4914
|
}), e.done && (r.close(), delete this.readStreamIterators[n]);
|
|
4883
4915
|
}
|
|
4884
4916
|
onConnectionStatusChange(e) {
|
|
4885
4917
|
for (const n of Object.values(this.startWriteStreamCbs))
|
|
4886
4918
|
n({ type: "disconnect" });
|
|
4887
|
-
if (this.startWriteStreamCbs = {}, e !==
|
|
4919
|
+
if (this.startWriteStreamCbs = {}, e !== fe.AUTHENTICATED)
|
|
4888
4920
|
for (const { onDisconnect: n } of Object.values(this.writeStreams))
|
|
4889
4921
|
n();
|
|
4890
4922
|
else {
|
|
@@ -4907,7 +4939,7 @@ class Jo {
|
|
|
4907
4939
|
const r = e["client-event-id"], s = this.startWriteStreamCbs[r];
|
|
4908
4940
|
s && (s({
|
|
4909
4941
|
type: "error",
|
|
4910
|
-
error: new
|
|
4942
|
+
error: new Y(e.message || "Unknown error", e.hint)
|
|
4911
4943
|
}), delete this.startWriteStreamCbs[r]);
|
|
4912
4944
|
break;
|
|
4913
4945
|
}
|
|
@@ -4915,7 +4947,7 @@ class Jo {
|
|
|
4915
4947
|
const r = e["client-event-id"], s = this.readStreamIterators[r];
|
|
4916
4948
|
s && (s.push({
|
|
4917
4949
|
type: "error",
|
|
4918
|
-
error: new
|
|
4950
|
+
error: new Y(e.message || "Unknown error", e.hint)
|
|
4919
4951
|
}), s.close(), delete this.readStreamIterators[r]);
|
|
4920
4952
|
break;
|
|
4921
4953
|
}
|
|
@@ -4925,7 +4957,7 @@ class Jo {
|
|
|
4925
4957
|
return this.activeStreams.size > 0;
|
|
4926
4958
|
}
|
|
4927
4959
|
}
|
|
4928
|
-
const
|
|
4960
|
+
const fe = {
|
|
4929
4961
|
CONNECTING: "connecting",
|
|
4930
4962
|
OPENED: "opened",
|
|
4931
4963
|
AUTHENTICATED: "authenticated",
|
|
@@ -5013,12 +5045,12 @@ function Ct(t) {
|
|
|
5013
5045
|
});
|
|
5014
5046
|
}
|
|
5015
5047
|
class ua {
|
|
5016
|
-
constructor(e, n =
|
|
5048
|
+
constructor(e, n = Sr, r = Tr, s, i) {
|
|
5017
5049
|
/** @type {s.AttrsStore | undefined} */
|
|
5018
5050
|
h(this, "attrs");
|
|
5019
5051
|
h(this, "_isOnline", !0);
|
|
5020
5052
|
h(this, "_isShutdown", !1);
|
|
5021
|
-
h(this, "status",
|
|
5053
|
+
h(this, "status", fe.CONNECTING);
|
|
5022
5054
|
/** @type {PersistedObject<string, QuerySub, QuerySubInStorage>} */
|
|
5023
5055
|
h(this, "querySubs");
|
|
5024
5056
|
/** @type {PersistedObject} */
|
|
@@ -5090,7 +5122,7 @@ class ua {
|
|
|
5090
5122
|
// Queries
|
|
5091
5123
|
h(this, "getPreviousResult", (e) => {
|
|
5092
5124
|
var r;
|
|
5093
|
-
const n =
|
|
5125
|
+
const n = H(e);
|
|
5094
5126
|
return (r = this.dataForQuery(n)) == null ? void 0 : r.data;
|
|
5095
5127
|
});
|
|
5096
5128
|
/** Re-run instaql and call all callbacks with new data */
|
|
@@ -5133,7 +5165,7 @@ class ua {
|
|
|
5133
5165
|
* @returns
|
|
5134
5166
|
*/
|
|
5135
5167
|
h(this, "pushOps", (e, n) => {
|
|
5136
|
-
const r =
|
|
5168
|
+
const r = N(), s = [...this._pendingMutations().values()], i = Math.max(0, ...s.map((c) => c.order || 0)) + 1, o = {
|
|
5137
5169
|
op: "transact",
|
|
5138
5170
|
"tx-steps": e,
|
|
5139
5171
|
created: Date.now(),
|
|
@@ -5152,9 +5184,9 @@ class ua {
|
|
|
5152
5184
|
this._log.info("[socket][open]", n.id, "skip; this is no longer the current transport");
|
|
5153
5185
|
return;
|
|
5154
5186
|
}
|
|
5155
|
-
this._log.info("[socket][open]", this._transport.id), this._setStatus(
|
|
5187
|
+
this._log.info("[socket][open]", this._transport.id), this._setStatus(fe.OPENED), this.getCurrentUser().then((r) => {
|
|
5156
5188
|
var s;
|
|
5157
|
-
this._trySend(
|
|
5189
|
+
this._trySend(N(), {
|
|
5158
5190
|
op: "init",
|
|
5159
5191
|
"app-id": this.config.appId,
|
|
5160
5192
|
"refresh-token": (s = r.user) == null ? void 0 : s.refresh_token,
|
|
@@ -5205,7 +5237,7 @@ class ua {
|
|
|
5205
5237
|
this._log.info("[socket][close]", n.id, "skip; this is no longer the current transport");
|
|
5206
5238
|
return;
|
|
5207
5239
|
}
|
|
5208
|
-
this._setStatus(
|
|
5240
|
+
this._setStatus(fe.CLOSED);
|
|
5209
5241
|
for (const r of Object.values(this._rooms))
|
|
5210
5242
|
r.isConnected = !1;
|
|
5211
5243
|
if (this._isShutdown) {
|
|
@@ -5247,7 +5279,7 @@ class ua {
|
|
|
5247
5279
|
this.syncUserToEndpoint(o.user);
|
|
5248
5280
|
}, ea), r.getIsOnline().then((o) => {
|
|
5249
5281
|
this._isOnline = o, this._startSocket(), r.listen((a) => {
|
|
5250
|
-
a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to",
|
|
5282
|
+
a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", fe.CLOSED), this._setStatus(fe.CLOSED)));
|
|
5251
5283
|
});
|
|
5252
5284
|
}), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
|
|
5253
5285
|
}
|
|
@@ -5344,7 +5376,7 @@ class ua {
|
|
|
5344
5376
|
status: o ?? 0
|
|
5345
5377
|
}));
|
|
5346
5378
|
} else
|
|
5347
|
-
s.reject(new
|
|
5379
|
+
s.reject(new Y((r == null ? void 0 : r.message) || "Unknown error", r == null ? void 0 : r.hint));
|
|
5348
5380
|
}
|
|
5349
5381
|
_setStatus(e, n) {
|
|
5350
5382
|
this.status = e, this._errorMessage = n, this.notifyConnectionStatusSubs(e), this._instantStream.onConnectionStatusChange(e);
|
|
@@ -5368,7 +5400,7 @@ class ua {
|
|
|
5368
5400
|
_addQueryData(e, n, r) {
|
|
5369
5401
|
if (!this.attrs)
|
|
5370
5402
|
throw new Error("Attrs in reactor have not been set");
|
|
5371
|
-
const s =
|
|
5403
|
+
const s = H(e), i = this.ensureAttrs(), o = Ue(this.attrs, n.triples, r, this.config.useDateObjects);
|
|
5372
5404
|
this.querySubs.updateInPlace((a) => {
|
|
5373
5405
|
a[s] = {
|
|
5374
5406
|
result: {
|
|
@@ -5387,35 +5419,35 @@ class ua {
|
|
|
5387
5419
|
const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
|
|
5388
5420
|
switch (Nn[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
|
|
5389
5421
|
case "init-ok": {
|
|
5390
|
-
this._setStatus(
|
|
5422
|
+
this._setStatus(fe.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
|
|
5391
5423
|
for (const p of Object.keys(this._rooms)) {
|
|
5392
|
-
const y = (i = (s = this._presence[p]) == null ? void 0 : s.result) == null ? void 0 : i.user,
|
|
5393
|
-
this._tryJoinRoom(
|
|
5424
|
+
const y = (i = (s = this._presence[p]) == null ? void 0 : s.result) == null ? void 0 : i.user, b = (o = this._rooms[p]) == null ? void 0 : o.roomType;
|
|
5425
|
+
this._tryJoinRoom(b, p, y);
|
|
5394
5426
|
}
|
|
5395
5427
|
break;
|
|
5396
5428
|
}
|
|
5397
5429
|
case "add-query-exists": {
|
|
5398
|
-
this.notifyOneQueryOnce(
|
|
5430
|
+
this.notifyOneQueryOnce(H(n.q));
|
|
5399
5431
|
break;
|
|
5400
5432
|
}
|
|
5401
5433
|
case "add-query-ok": {
|
|
5402
|
-
const { q: p, result: y } = n,
|
|
5403
|
-
if (!this._hasQueryListeners() && !this.querySubs.currentValue[
|
|
5434
|
+
const { q: p, result: y } = n, b = H(p);
|
|
5435
|
+
if (!this._hasQueryListeners() && !this.querySubs.currentValue[b])
|
|
5404
5436
|
break;
|
|
5405
|
-
const w = (c = (a = y == null ? void 0 : y[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"],
|
|
5406
|
-
this.querySubs.updateInPlace((
|
|
5407
|
-
if (!
|
|
5408
|
-
this._log.info("Missing value in querySubs", { hash:
|
|
5437
|
+
const w = (c = (a = y == null ? void 0 : y[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], _ = (l = (u = y == null ? void 0 : y[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, g = Mn(y), m = this.ensureAttrs(), I = Ue(m, g, r, this.config.useDateObjects);
|
|
5438
|
+
this.querySubs.updateInPlace((S) => {
|
|
5439
|
+
if (!S[b]) {
|
|
5440
|
+
this._log.info("Missing value in querySubs", { hash: b, q: p });
|
|
5409
5441
|
return;
|
|
5410
5442
|
}
|
|
5411
|
-
|
|
5412
|
-
store:
|
|
5413
|
-
attrsStore:
|
|
5443
|
+
S[b].result = {
|
|
5444
|
+
store: I,
|
|
5445
|
+
attrsStore: m,
|
|
5414
5446
|
pageInfo: w,
|
|
5415
|
-
aggregate:
|
|
5447
|
+
aggregate: _,
|
|
5416
5448
|
processedTxId: n["processed-tx-id"]
|
|
5417
5449
|
};
|
|
5418
|
-
}), this._cleanupPendingMutationsQueries(), this.notifyOne(
|
|
5450
|
+
}), this._cleanupPendingMutationsQueries(), this.notifyOne(b), this.notifyOneQueryOnce(b), this._cleanupPendingMutationsTimeout();
|
|
5419
5451
|
break;
|
|
5420
5452
|
}
|
|
5421
5453
|
case "start-sync-ok": {
|
|
@@ -5451,40 +5483,40 @@ class ua {
|
|
|
5451
5483
|
break;
|
|
5452
5484
|
}
|
|
5453
5485
|
case "refresh-ok": {
|
|
5454
|
-
const { computations: p, attrs: y } = n,
|
|
5486
|
+
const { computations: p, attrs: y } = n, b = n["processed-tx-id"];
|
|
5455
5487
|
y && this._setAttrs(y), this._cleanupPendingMutationsTimeout();
|
|
5456
|
-
const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(),
|
|
5457
|
-
w !== this._pendingMutations() && this.kv.updateInPlace((
|
|
5458
|
-
|
|
5488
|
+
const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), b);
|
|
5489
|
+
w !== this._pendingMutations() && this.kv.updateInPlace((m) => {
|
|
5490
|
+
m.pendingMutations = w;
|
|
5459
5491
|
});
|
|
5460
|
-
const
|
|
5461
|
-
var
|
|
5462
|
-
const
|
|
5492
|
+
const _ = Ct(w.entries()), g = p.map((m) => {
|
|
5493
|
+
var K, A, P, C;
|
|
5494
|
+
const I = m["instaql-query"], S = m["instaql-result"], M = H(I), O = Mn(S), k = this.ensureAttrs(), F = Ue(k, O, r, this.config.useDateObjects), { store: x, attrsStore: L } = this._applyOptimisticUpdates(F, k, _, b), U = (A = (K = S == null ? void 0 : S[0]) == null ? void 0 : K.data) == null ? void 0 : A["page-info"], Q = (C = (P = S == null ? void 0 : S[0]) == null ? void 0 : P.data) == null ? void 0 : C.aggregate;
|
|
5463
5495
|
return {
|
|
5464
|
-
q:
|
|
5465
|
-
hash:
|
|
5466
|
-
store:
|
|
5467
|
-
attrsStore:
|
|
5468
|
-
pageInfo:
|
|
5469
|
-
aggregate:
|
|
5496
|
+
q: I,
|
|
5497
|
+
hash: M,
|
|
5498
|
+
store: x,
|
|
5499
|
+
attrsStore: L,
|
|
5500
|
+
pageInfo: U,
|
|
5501
|
+
aggregate: Q
|
|
5470
5502
|
};
|
|
5471
5503
|
});
|
|
5472
|
-
|
|
5473
|
-
this.querySubs.updateInPlace((
|
|
5474
|
-
if (!
|
|
5475
|
-
this._log.error("Missing value in querySubs", { hash:
|
|
5504
|
+
g.forEach(({ hash: m, q: I, store: S, attrsStore: M, pageInfo: O, aggregate: k }) => {
|
|
5505
|
+
this.querySubs.updateInPlace((F) => {
|
|
5506
|
+
if (!F[m]) {
|
|
5507
|
+
this._log.error("Missing value in querySubs", { hash: m, q: I });
|
|
5476
5508
|
return;
|
|
5477
5509
|
}
|
|
5478
|
-
|
|
5479
|
-
store:
|
|
5480
|
-
attrsStore:
|
|
5481
|
-
pageInfo:
|
|
5482
|
-
aggregate:
|
|
5483
|
-
processedTxId:
|
|
5510
|
+
F[m].result = {
|
|
5511
|
+
store: S,
|
|
5512
|
+
attrsStore: M,
|
|
5513
|
+
pageInfo: O,
|
|
5514
|
+
aggregate: k,
|
|
5515
|
+
processedTxId: b
|
|
5484
5516
|
};
|
|
5485
5517
|
});
|
|
5486
|
-
}), this._cleanupPendingMutationsQueries(),
|
|
5487
|
-
this.notifyOne(
|
|
5518
|
+
}), this._cleanupPendingMutationsQueries(), g.forEach(({ hash: m }) => {
|
|
5519
|
+
this.notifyOne(m);
|
|
5488
5520
|
});
|
|
5489
5521
|
break;
|
|
5490
5522
|
}
|
|
@@ -5494,22 +5526,22 @@ class ua {
|
|
|
5494
5526
|
const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(p);
|
|
5495
5527
|
if (!w)
|
|
5496
5528
|
break;
|
|
5497
|
-
this._updatePendingMutations((
|
|
5498
|
-
|
|
5499
|
-
...
|
|
5529
|
+
this._updatePendingMutations((g) => {
|
|
5530
|
+
g.set(p, {
|
|
5531
|
+
...g.get(p),
|
|
5500
5532
|
"tx-id": y,
|
|
5501
5533
|
confirmed: Date.now()
|
|
5502
5534
|
});
|
|
5503
5535
|
});
|
|
5504
|
-
const
|
|
5505
|
-
for (const
|
|
5506
|
-
if (
|
|
5507
|
-
const
|
|
5508
|
-
|
|
5536
|
+
const _ = [];
|
|
5537
|
+
for (const g of w["tx-steps"])
|
|
5538
|
+
if (g[0] === "add-attr") {
|
|
5539
|
+
const m = g[1];
|
|
5540
|
+
_.push(m);
|
|
5509
5541
|
}
|
|
5510
|
-
if (
|
|
5511
|
-
const
|
|
5512
|
-
this._setAttrs([...
|
|
5542
|
+
if (_.length) {
|
|
5543
|
+
const g = Object.values(this.ensureAttrs().attrs);
|
|
5544
|
+
this._setAttrs([...g, ..._]);
|
|
5513
5545
|
}
|
|
5514
5546
|
this._finishTransaction("synced", p), this._cleanupPendingMutationsTimeout();
|
|
5515
5547
|
break;
|
|
@@ -5599,8 +5631,8 @@ class ua {
|
|
|
5599
5631
|
return;
|
|
5600
5632
|
}
|
|
5601
5633
|
if ((a = e["original-event"]) != null && a.hasOwnProperty("q") && ((c = e["original-event"]) == null ? void 0 : c.op) === "add-query") {
|
|
5602
|
-
const p = (u = e["original-event"]) == null ? void 0 : u.q, y =
|
|
5603
|
-
this.notifyQueryError(
|
|
5634
|
+
const p = (u = e["original-event"]) == null ? void 0 : u.q, y = H(p);
|
|
5635
|
+
this.notifyQueryError(H(p), s), this.notifyQueryOnceError(p, y, n, s);
|
|
5604
5636
|
return;
|
|
5605
5637
|
}
|
|
5606
5638
|
if (((l = e["original-event"]) == null ? void 0 : l.op) === "init") {
|
|
@@ -5608,7 +5640,7 @@ class ua {
|
|
|
5608
5640
|
this.changeCurrentUser(null);
|
|
5609
5641
|
return;
|
|
5610
5642
|
}
|
|
5611
|
-
this._setStatus(
|
|
5643
|
+
this._setStatus(fe.ERRORED, s), this.notifyAll();
|
|
5612
5644
|
return;
|
|
5613
5645
|
}
|
|
5614
5646
|
switch ((d = e["original-event"]) == null ? void 0 : d.op) {
|
|
@@ -5638,10 +5670,10 @@ class ua {
|
|
|
5638
5670
|
i && (i.dfd.reject(s), this._completeQueryOnce(e, n, i.dfd));
|
|
5639
5671
|
}
|
|
5640
5672
|
_setAttrs(e) {
|
|
5641
|
-
this.attrs = new
|
|
5673
|
+
this.attrs = new Se(e.reduce((n, r) => (n[r.id] = r, n), {}), this._linkIndex), this.notifyAttrsSubs();
|
|
5642
5674
|
}
|
|
5643
5675
|
_startQuerySub(e, n) {
|
|
5644
|
-
const r =
|
|
5676
|
+
const r = N();
|
|
5645
5677
|
return this.querySubs.updateInPlace((s) => {
|
|
5646
5678
|
s[n] = s[n] || { q: e, result: null, eventId: r }, s[n].lastAccessed = Date.now();
|
|
5647
5679
|
}), this._trySendAuthed(r, { op: "add-query", q: e }), r;
|
|
@@ -5661,7 +5693,7 @@ class ua {
|
|
|
5661
5693
|
*/
|
|
5662
5694
|
subscribeQuery(e, n, r) {
|
|
5663
5695
|
this.config.disableValidation || xn(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
|
|
5664
|
-
const s =
|
|
5696
|
+
const s = H(e), i = this.getPreviousResult(e);
|
|
5665
5697
|
return i && n(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
|
|
5666
5698
|
this._unsubQuery(e, s, n);
|
|
5667
5699
|
};
|
|
@@ -5673,7 +5705,7 @@ class ua {
|
|
|
5673
5705
|
return r.reject(new Error("We can't run `queryOnce`, because the device is offline.")), r.promise;
|
|
5674
5706
|
if (!this.querySubs)
|
|
5675
5707
|
return r.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), r.promise;
|
|
5676
|
-
const s =
|
|
5708
|
+
const s = H(e), i = this._startQuerySub(e, s);
|
|
5677
5709
|
return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), Yo), r.promise;
|
|
5678
5710
|
}
|
|
5679
5711
|
_completeQueryOnce(e, n, r) {
|
|
@@ -5687,7 +5719,7 @@ class ua {
|
|
|
5687
5719
|
return !!((n = this.queryCbs[e]) != null && n.length || (r = this.queryOnceDfds[e]) != null && r.length);
|
|
5688
5720
|
}
|
|
5689
5721
|
_cleanupQuery(e, n) {
|
|
5690
|
-
this._hasQueryListeners(n) || (delete this.queryCbs[n], delete this.queryOnceDfds[n], delete this._dataForQueryCache[n], this.querySubs.unloadKey(n), this._trySendAuthed(
|
|
5722
|
+
this._hasQueryListeners(n) || (delete this.queryCbs[n], delete this.queryOnceDfds[n], delete this._dataForQueryCache[n], this.querySubs.unloadKey(n), this._trySendAuthed(N(), { op: "remove-query", q: e }));
|
|
5691
5723
|
}
|
|
5692
5724
|
// When we `pushTx`, it's possible that we don't yet have `this.attrs`
|
|
5693
5725
|
// This means that `tx-steps` in `pendingMutations` will include `add-attr`
|
|
@@ -5713,7 +5745,7 @@ class ua {
|
|
|
5713
5745
|
return /* @__PURE__ */ new Map();
|
|
5714
5746
|
const s = (l) => {
|
|
5715
5747
|
const [f, d, p] = l["forward-identity"];
|
|
5716
|
-
return
|
|
5748
|
+
return W(e, d, p);
|
|
5717
5749
|
}, i = (l) => {
|
|
5718
5750
|
const [f, d, p] = l["forward-identity"];
|
|
5719
5751
|
return Ae(e, d, p);
|
|
@@ -5724,15 +5756,15 @@ class ua {
|
|
|
5724
5756
|
for (const p of l) {
|
|
5725
5757
|
const [y] = p;
|
|
5726
5758
|
if (y === "add-attr") {
|
|
5727
|
-
const [w,
|
|
5728
|
-
if (
|
|
5729
|
-
o.attrIdMap[
|
|
5759
|
+
const [w, _] = p, g = s(_);
|
|
5760
|
+
if (g && _.id !== g.id) {
|
|
5761
|
+
o.attrIdMap[_.id] = g.id, a = !0;
|
|
5730
5762
|
continue;
|
|
5731
5763
|
}
|
|
5732
|
-
if (
|
|
5733
|
-
const
|
|
5734
|
-
if (
|
|
5735
|
-
o.attrIdMap[
|
|
5764
|
+
if (_["value-type"] === "ref") {
|
|
5765
|
+
const m = i(_);
|
|
5766
|
+
if (m) {
|
|
5767
|
+
o.attrIdMap[_.id] = m.id, o.refSwapAttrIds.add(_.id), a = !0;
|
|
5736
5768
|
continue;
|
|
5737
5769
|
}
|
|
5738
5770
|
}
|
|
@@ -5741,8 +5773,8 @@ class ua {
|
|
|
5741
5773
|
a = !0;
|
|
5742
5774
|
continue;
|
|
5743
5775
|
}
|
|
5744
|
-
const
|
|
5745
|
-
d.push(
|
|
5776
|
+
const b = a ? Di(o, p) : p;
|
|
5777
|
+
d.push(b);
|
|
5746
5778
|
}
|
|
5747
5779
|
return a ? d : l;
|
|
5748
5780
|
}, u = /* @__PURE__ */ new Map();
|
|
@@ -5772,13 +5804,13 @@ class ua {
|
|
|
5772
5804
|
r.push(u);
|
|
5773
5805
|
}
|
|
5774
5806
|
if (!n.size && !r.length)
|
|
5775
|
-
return this.attrs || new
|
|
5807
|
+
return this.attrs || new Se({}, this._linkIndex);
|
|
5776
5808
|
const s = { ...((o = this.attrs) == null ? void 0 : o.attrs) || {} };
|
|
5777
5809
|
for (const a of r)
|
|
5778
5810
|
s[a.id] = a;
|
|
5779
5811
|
for (const a of n)
|
|
5780
5812
|
delete s[a];
|
|
5781
|
-
return new
|
|
5813
|
+
return new Se(s, this._linkIndex);
|
|
5782
5814
|
}
|
|
5783
5815
|
/** Runs instaql on a query and a store */
|
|
5784
5816
|
dataForQuery(e, n = !0) {
|
|
@@ -5794,10 +5826,10 @@ class ua {
|
|
|
5794
5826
|
if (l && s === l.querySubVersion && o === l.pendingMutationsVersion)
|
|
5795
5827
|
return l;
|
|
5796
5828
|
let f = u.store, d = u.attrsStore;
|
|
5797
|
-
const { pageInfo: p, aggregate: y, processedTxId:
|
|
5829
|
+
const { pageInfo: p, aggregate: y, processedTxId: b } = u, w = this._rewriteMutationsSorted(d, a);
|
|
5798
5830
|
if (n) {
|
|
5799
|
-
const
|
|
5800
|
-
f =
|
|
5831
|
+
const g = this._applyOptimisticUpdates(f, d, w, b);
|
|
5832
|
+
f = g.store, d = g.attrsStore;
|
|
5801
5833
|
}
|
|
5802
5834
|
return { data: wr({ store: f, attrsStore: d, pageInfo: p, aggregate: y }, c), querySubVersion: s, pendingMutationsVersion: o };
|
|
5803
5835
|
}
|
|
@@ -5836,7 +5868,7 @@ class ua {
|
|
|
5836
5868
|
});
|
|
5837
5869
|
return;
|
|
5838
5870
|
}
|
|
5839
|
-
if (this.status !==
|
|
5871
|
+
if (this.status !== fe.AUTHENTICATED) {
|
|
5840
5872
|
this._finishTransaction("enqueued", e);
|
|
5841
5873
|
return;
|
|
5842
5874
|
}
|
|
@@ -5894,7 +5926,7 @@ class ua {
|
|
|
5894
5926
|
});
|
|
5895
5927
|
}
|
|
5896
5928
|
_trySendAuthed(...e) {
|
|
5897
|
-
this.status ===
|
|
5929
|
+
this.status === fe.AUTHENTICATED && this._trySend(...e);
|
|
5898
5930
|
}
|
|
5899
5931
|
_trySend(e, n, r) {
|
|
5900
5932
|
if (this._transport.isOpen()) {
|
|
@@ -5945,7 +5977,7 @@ class ua {
|
|
|
5945
5977
|
const r = await this.kv.waitForKeyToLoad(n);
|
|
5946
5978
|
if (r)
|
|
5947
5979
|
return r;
|
|
5948
|
-
const s =
|
|
5980
|
+
const s = N();
|
|
5949
5981
|
return this.kv.updateInPlace((i) => {
|
|
5950
5982
|
i[n] || (i[n] = s);
|
|
5951
5983
|
}), await this.kv.waitForKeyToLoad(n);
|
|
@@ -6032,7 +6064,7 @@ class ua {
|
|
|
6032
6064
|
async getAuth() {
|
|
6033
6065
|
const { user: e, error: n } = await this.getCurrentUser();
|
|
6034
6066
|
if (n)
|
|
6035
|
-
throw new
|
|
6067
|
+
throw new Y("Could not get current user: " + n.message);
|
|
6036
6068
|
return e ?? null;
|
|
6037
6069
|
}
|
|
6038
6070
|
subscribeConnectionStatus(e) {
|
|
@@ -6198,7 +6230,7 @@ class ua {
|
|
|
6198
6230
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
6199
6231
|
return;
|
|
6200
6232
|
}
|
|
6201
|
-
|
|
6233
|
+
So({
|
|
6202
6234
|
apiURI: this.config.apiURI,
|
|
6203
6235
|
appId: this.config.appId,
|
|
6204
6236
|
refreshToken: r
|
|
@@ -6325,14 +6357,14 @@ class ua {
|
|
|
6325
6357
|
i.result.user = o, s.isConnected && (this._trySetPresence(n, o), this._notifyPresenceSubs(n));
|
|
6326
6358
|
}
|
|
6327
6359
|
_trySetPresence(e, n) {
|
|
6328
|
-
this._trySendAuthed(
|
|
6360
|
+
this._trySendAuthed(N(), {
|
|
6329
6361
|
op: "set-presence",
|
|
6330
6362
|
"room-id": e,
|
|
6331
6363
|
data: n
|
|
6332
6364
|
});
|
|
6333
6365
|
}
|
|
6334
6366
|
_tryJoinRoom(e, n, r) {
|
|
6335
|
-
this._trySendAuthed(
|
|
6367
|
+
this._trySendAuthed(N(), {
|
|
6336
6368
|
op: "join-room",
|
|
6337
6369
|
"room-type": e,
|
|
6338
6370
|
"room-id": n,
|
|
@@ -6340,7 +6372,7 @@ class ua {
|
|
|
6340
6372
|
}), delete this._roomsPendingLeave[n];
|
|
6341
6373
|
}
|
|
6342
6374
|
_tryLeaveRoom(e) {
|
|
6343
|
-
this._trySendAuthed(
|
|
6375
|
+
this._trySendAuthed(N(), { op: "leave-room", "room-id": e });
|
|
6344
6376
|
}
|
|
6345
6377
|
_trySetRoomConnected(e, n) {
|
|
6346
6378
|
const r = this._rooms[e];
|
|
@@ -6414,7 +6446,7 @@ class ua {
|
|
|
6414
6446
|
}
|
|
6415
6447
|
}
|
|
6416
6448
|
_tryBroadcast(e, n, r, s) {
|
|
6417
|
-
this._trySendAuthed(
|
|
6449
|
+
this._trySendAuthed(N(), {
|
|
6418
6450
|
op: "client-broadcast",
|
|
6419
6451
|
"room-id": e,
|
|
6420
6452
|
roomType: n,
|
|
@@ -6431,8 +6463,8 @@ class ua {
|
|
|
6431
6463
|
_notifyBroadcastSubs(e, n, r) {
|
|
6432
6464
|
var s, i, o;
|
|
6433
6465
|
(o = (i = (s = this._broadcastSubs) == null ? void 0 : s[e]) == null ? void 0 : i[n]) == null || o.forEach((a) => {
|
|
6434
|
-
var l, f, d, p, y,
|
|
6435
|
-
const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (d = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : d.user : (
|
|
6466
|
+
var l, f, d, p, y, b;
|
|
6467
|
+
const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (d = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : d.user : (b = (y = (p = this._presence[e]) == null ? void 0 : p.result) == null ? void 0 : y.peers) == null ? void 0 : b[r.data["peer-id"]];
|
|
6436
6468
|
return a(c, u);
|
|
6437
6469
|
});
|
|
6438
6470
|
}
|
|
@@ -6441,7 +6473,7 @@ class ua {
|
|
|
6441
6473
|
async uploadFile(e, n, r) {
|
|
6442
6474
|
var o;
|
|
6443
6475
|
const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
|
|
6444
|
-
return
|
|
6476
|
+
return To({
|
|
6445
6477
|
...r,
|
|
6446
6478
|
apiURI: this.config.apiURI,
|
|
6447
6479
|
appId: this.config.appId,
|
|
@@ -6499,22 +6531,22 @@ function fa(t) {
|
|
|
6499
6531
|
return new yt(t, {});
|
|
6500
6532
|
}
|
|
6501
6533
|
function da() {
|
|
6502
|
-
return new
|
|
6534
|
+
return new ee("string", !0, !1);
|
|
6503
6535
|
}
|
|
6504
6536
|
function ha() {
|
|
6505
|
-
return new
|
|
6537
|
+
return new ee("number", !0, !1);
|
|
6506
6538
|
}
|
|
6507
6539
|
function pa() {
|
|
6508
|
-
return new
|
|
6540
|
+
return new ee("boolean", !0, !1);
|
|
6509
6541
|
}
|
|
6510
6542
|
function ya() {
|
|
6511
|
-
return new
|
|
6543
|
+
return new ee("date", !0, !1);
|
|
6512
6544
|
}
|
|
6513
6545
|
function ba() {
|
|
6514
|
-
return new
|
|
6546
|
+
return new ee("json", !0, !1);
|
|
6515
6547
|
}
|
|
6516
6548
|
function ga() {
|
|
6517
|
-
return new
|
|
6549
|
+
return new ee("json", !0, !1);
|
|
6518
6550
|
}
|
|
6519
6551
|
function jr(t, e) {
|
|
6520
6552
|
var s, i, o, a;
|
|
@@ -6564,7 +6596,7 @@ const dc = {
|
|
|
6564
6596
|
let Je;
|
|
6565
6597
|
function _a(t, e) {
|
|
6566
6598
|
Je == null || Je.dispose();
|
|
6567
|
-
const n = ka(e), r =
|
|
6599
|
+
const n = ka(e), r = Ta(e, a), s = Sa(ma(t));
|
|
6568
6600
|
function i(l) {
|
|
6569
6601
|
var f;
|
|
6570
6602
|
l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
|
|
@@ -6589,7 +6621,7 @@ function _a(t, e) {
|
|
|
6589
6621
|
function ma(t) {
|
|
6590
6622
|
return `${an || Ar ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
6591
6623
|
}
|
|
6592
|
-
function
|
|
6624
|
+
function Sa(t) {
|
|
6593
6625
|
const e = document.createElement("iframe");
|
|
6594
6626
|
return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
6595
6627
|
width: "100%",
|
|
@@ -6598,7 +6630,7 @@ function Ta(t) {
|
|
|
6598
6630
|
border: "none"
|
|
6599
6631
|
}), { element: e };
|
|
6600
6632
|
}
|
|
6601
|
-
function
|
|
6633
|
+
function Ta(t, e) {
|
|
6602
6634
|
const n = `
|
|
6603
6635
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6604
6636
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -6739,207 +6771,207 @@ const Ia = (t) => JSON.stringify(t), Fe = (t, e = !1) => JSON.stringify([t, e]),
|
|
|
6739
6771
|
];
|
|
6740
6772
|
return { chunks: n, data: r };
|
|
6741
6773
|
}, Et = ["bootstrap", "bootstrap", "bootstrap", 1], ja = (t, e, n, r) => {
|
|
6742
|
-
var
|
|
6743
|
-
const { entityName: s, entityQuery: i } = $a(e), o = ((
|
|
6744
|
-
let d = !1, p = !0, y = null,
|
|
6745
|
-
const w = (
|
|
6746
|
-
n({ error:
|
|
6747
|
-
},
|
|
6774
|
+
var L, U, Q, K;
|
|
6775
|
+
const { entityName: s, entityQuery: i } = $a(e), o = ((L = i.$) == null ? void 0 : L.limit) || 10, a = s, c = Pa((U = i.$) == null ? void 0 : U.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
6776
|
+
let d = !1, p = !0, y = null, b = null;
|
|
6777
|
+
const w = (A) => {
|
|
6778
|
+
n({ error: A, data: void 0, canLoadNextPage: !1 });
|
|
6779
|
+
}, _ = () => {
|
|
6748
6780
|
if (!p)
|
|
6749
6781
|
return;
|
|
6750
|
-
const { chunks:
|
|
6782
|
+
const { chunks: A, data: P } = Ma(u, l);
|
|
6751
6783
|
n({
|
|
6752
|
-
data: { [a]:
|
|
6784
|
+
data: { [a]: P },
|
|
6753
6785
|
// @ts-expect-error hidden debug variable
|
|
6754
|
-
chunks:
|
|
6786
|
+
chunks: A,
|
|
6755
6787
|
canLoadNextPage: Ea(u)
|
|
6756
6788
|
});
|
|
6757
|
-
},
|
|
6758
|
-
u.set(Fe(
|
|
6759
|
-
},
|
|
6760
|
-
l.set(Fe(
|
|
6761
|
-
},
|
|
6762
|
-
var
|
|
6763
|
-
const { cursor:
|
|
6764
|
-
|
|
6765
|
-
const
|
|
6789
|
+
}, g = (A, P) => {
|
|
6790
|
+
u.set(Fe(A, P.afterInclusive), P), _();
|
|
6791
|
+
}, m = (A, P) => {
|
|
6792
|
+
l.set(Fe(A), P), k(), _();
|
|
6793
|
+
}, I = (A, P) => {
|
|
6794
|
+
var T, v;
|
|
6795
|
+
const { cursor: C } = Kn(A), j = f.get(Ie("reverse", C));
|
|
6796
|
+
j == null || j();
|
|
6797
|
+
const $ = t.subscribeQuery({
|
|
6766
6798
|
[a]: {
|
|
6767
6799
|
...i,
|
|
6768
6800
|
$: {
|
|
6769
|
-
after:
|
|
6770
|
-
before:
|
|
6801
|
+
after: C,
|
|
6802
|
+
before: P.endCursor,
|
|
6771
6803
|
beforeInclusive: !0,
|
|
6772
|
-
where: (
|
|
6773
|
-
fields: (
|
|
6804
|
+
where: (T = i.$) == null ? void 0 : T.where,
|
|
6805
|
+
fields: (v = i.$) == null ? void 0 : v.fields,
|
|
6774
6806
|
order: qn(c)
|
|
6775
6807
|
}
|
|
6776
6808
|
}
|
|
6777
|
-
}, (
|
|
6778
|
-
if (
|
|
6779
|
-
return w(
|
|
6780
|
-
const
|
|
6781
|
-
xe(
|
|
6782
|
-
data:
|
|
6809
|
+
}, (R) => {
|
|
6810
|
+
if (R.error)
|
|
6811
|
+
return w(R.error);
|
|
6812
|
+
const q = R.data[a], V = R.pageInfo[a];
|
|
6813
|
+
xe(q && V, "Expected query subscription to contain rows and pageInfo"), m(C, {
|
|
6814
|
+
data: q,
|
|
6783
6815
|
status: "frozen",
|
|
6784
|
-
hasMore:
|
|
6785
|
-
endCursor:
|
|
6816
|
+
hasMore: V.hasNextPage,
|
|
6817
|
+
endCursor: V.endCursor
|
|
6786
6818
|
});
|
|
6787
6819
|
}, r);
|
|
6788
|
-
f.set(Ie("reverse",
|
|
6789
|
-
},
|
|
6790
|
-
var
|
|
6791
|
-
const
|
|
6820
|
+
f.set(Ie("reverse", C), $);
|
|
6821
|
+
}, S = (A) => {
|
|
6822
|
+
var C, j;
|
|
6823
|
+
const P = t.subscribeQuery({
|
|
6792
6824
|
[a]: {
|
|
6793
6825
|
...i,
|
|
6794
6826
|
$: {
|
|
6795
6827
|
limit: o,
|
|
6796
|
-
after:
|
|
6797
|
-
where: (
|
|
6798
|
-
fields: (
|
|
6828
|
+
after: A,
|
|
6829
|
+
where: (C = i.$) == null ? void 0 : C.where,
|
|
6830
|
+
fields: (j = i.$) == null ? void 0 : j.fields,
|
|
6799
6831
|
order: qn(c)
|
|
6800
6832
|
}
|
|
6801
6833
|
}
|
|
6802
|
-
}, (
|
|
6803
|
-
if (
|
|
6804
|
-
return w(
|
|
6805
|
-
const
|
|
6806
|
-
xe(
|
|
6807
|
-
data:
|
|
6834
|
+
}, ($) => {
|
|
6835
|
+
if ($.error)
|
|
6836
|
+
return w($.error);
|
|
6837
|
+
const T = $.data[a], v = $.pageInfo[a];
|
|
6838
|
+
xe(T && v, "Expected rows and pageInfo"), m(A, {
|
|
6839
|
+
data: T,
|
|
6808
6840
|
status: "bootstrapping",
|
|
6809
|
-
hasMore:
|
|
6810
|
-
endCursor:
|
|
6841
|
+
hasMore: v.hasNextPage,
|
|
6842
|
+
endCursor: v.endCursor
|
|
6811
6843
|
});
|
|
6812
6844
|
}, r);
|
|
6813
|
-
f.set(Ie("reverse",
|
|
6814
|
-
},
|
|
6815
|
-
var
|
|
6816
|
-
const
|
|
6845
|
+
f.set(Ie("reverse", A), P);
|
|
6846
|
+
}, M = (A, P = !1) => {
|
|
6847
|
+
var j, $;
|
|
6848
|
+
const C = t.subscribeQuery({
|
|
6817
6849
|
[a]: {
|
|
6818
6850
|
...i,
|
|
6819
6851
|
$: {
|
|
6820
6852
|
limit: o,
|
|
6821
|
-
after:
|
|
6822
|
-
afterInclusive:
|
|
6823
|
-
where: (
|
|
6824
|
-
fields: (
|
|
6853
|
+
after: A,
|
|
6854
|
+
afterInclusive: P,
|
|
6855
|
+
where: (j = i.$) == null ? void 0 : j.where,
|
|
6856
|
+
fields: ($ = i.$) == null ? void 0 : $.fields,
|
|
6825
6857
|
order: c
|
|
6826
6858
|
}
|
|
6827
6859
|
}
|
|
6828
|
-
}, (
|
|
6829
|
-
if (
|
|
6830
|
-
return w(
|
|
6831
|
-
const
|
|
6832
|
-
xe(
|
|
6833
|
-
data:
|
|
6860
|
+
}, (T) => {
|
|
6861
|
+
if (T.error)
|
|
6862
|
+
return w(T.error);
|
|
6863
|
+
const v = T.data[a], R = T.pageInfo[a];
|
|
6864
|
+
xe(v && R, "Page info and rows"), g(A, {
|
|
6865
|
+
data: v,
|
|
6834
6866
|
status: "bootstrapping",
|
|
6835
|
-
hasMore:
|
|
6836
|
-
endCursor:
|
|
6837
|
-
afterInclusive:
|
|
6867
|
+
hasMore: R.hasNextPage,
|
|
6868
|
+
endCursor: R.endCursor,
|
|
6869
|
+
afterInclusive: P
|
|
6838
6870
|
});
|
|
6839
6871
|
}, r);
|
|
6840
|
-
f.set(Ie("forward",
|
|
6841
|
-
},
|
|
6842
|
-
var
|
|
6843
|
-
const
|
|
6844
|
-
|
|
6845
|
-
const
|
|
6846
|
-
if (!(
|
|
6872
|
+
f.set(Ie("forward", A, P), C);
|
|
6873
|
+
}, O = (A, P = !1) => {
|
|
6874
|
+
var v, R;
|
|
6875
|
+
const C = Fe(A, P), j = f.get(Ie("forward", A, P));
|
|
6876
|
+
j == null || j();
|
|
6877
|
+
const $ = u.get(C);
|
|
6878
|
+
if (!($ != null && $.endCursor))
|
|
6847
6879
|
return;
|
|
6848
|
-
const
|
|
6880
|
+
const T = t.subscribeQuery({
|
|
6849
6881
|
[a]: {
|
|
6850
6882
|
...i,
|
|
6851
6883
|
$: {
|
|
6852
|
-
after:
|
|
6853
|
-
afterInclusive:
|
|
6854
|
-
before:
|
|
6884
|
+
after: A,
|
|
6885
|
+
afterInclusive: $.afterInclusive,
|
|
6886
|
+
before: $.endCursor,
|
|
6855
6887
|
beforeInclusive: !0,
|
|
6856
|
-
where: (
|
|
6857
|
-
fields: (
|
|
6888
|
+
where: (v = i.$) == null ? void 0 : v.where,
|
|
6889
|
+
fields: (R = i.$) == null ? void 0 : R.fields,
|
|
6858
6890
|
order: c
|
|
6859
6891
|
}
|
|
6860
6892
|
}
|
|
6861
|
-
}, (
|
|
6862
|
-
if (
|
|
6863
|
-
return w(
|
|
6864
|
-
const
|
|
6865
|
-
xe(
|
|
6866
|
-
data:
|
|
6893
|
+
}, (q) => {
|
|
6894
|
+
if (q.error)
|
|
6895
|
+
return w(q.error);
|
|
6896
|
+
const V = q.data[a], se = q.pageInfo[a];
|
|
6897
|
+
xe(V && se, "Expected rows and pageInfo"), g(A, {
|
|
6898
|
+
data: V,
|
|
6867
6899
|
status: "frozen",
|
|
6868
|
-
hasMore:
|
|
6869
|
-
endCursor:
|
|
6870
|
-
afterInclusive:
|
|
6900
|
+
hasMore: se.hasNextPage,
|
|
6901
|
+
endCursor: se.endCursor,
|
|
6902
|
+
afterInclusive: $.afterInclusive
|
|
6871
6903
|
});
|
|
6872
6904
|
}, r);
|
|
6873
|
-
f.set(Ie("forward",
|
|
6874
|
-
},
|
|
6875
|
-
const
|
|
6876
|
-
if (!
|
|
6905
|
+
f.set(Ie("forward", A, P), T);
|
|
6906
|
+
}, k = () => {
|
|
6907
|
+
const A = Array.from(l.entries()).at(-1);
|
|
6908
|
+
if (!A)
|
|
6877
6909
|
return;
|
|
6878
|
-
const [
|
|
6879
|
-
if (!(
|
|
6910
|
+
const [P, C] = A;
|
|
6911
|
+
if (!(C != null && C.hasMore) || !Ca(C))
|
|
6880
6912
|
return;
|
|
6881
|
-
const
|
|
6882
|
-
|
|
6883
|
-
},
|
|
6884
|
-
const
|
|
6885
|
-
if (!
|
|
6913
|
+
const j = `${P}:${Ia(C.endCursor)}`;
|
|
6914
|
+
j != y && (y = j, I(P, C), S(C.endCursor));
|
|
6915
|
+
}, F = () => {
|
|
6916
|
+
const A = Array.from(u.entries()).at(-1);
|
|
6917
|
+
if (!A)
|
|
6886
6918
|
return;
|
|
6887
|
-
const [
|
|
6888
|
-
if (!
|
|
6919
|
+
const [P, C] = A;
|
|
6920
|
+
if (!C.endCursor)
|
|
6889
6921
|
return;
|
|
6890
|
-
const { cursor:
|
|
6891
|
-
|
|
6922
|
+
const { cursor: j, afterInclusive: $ } = Kn(P);
|
|
6923
|
+
O(j, $), M(C.endCursor);
|
|
6892
6924
|
};
|
|
6893
|
-
return
|
|
6925
|
+
return b = t.subscribeQuery({
|
|
6894
6926
|
[a]: {
|
|
6895
6927
|
...i,
|
|
6896
6928
|
$: {
|
|
6897
6929
|
limit: o,
|
|
6898
|
-
where: (
|
|
6899
|
-
fields: (
|
|
6930
|
+
where: (Q = i.$) == null ? void 0 : Q.where,
|
|
6931
|
+
fields: (K = i.$) == null ? void 0 : K.fields,
|
|
6900
6932
|
order: c
|
|
6901
6933
|
}
|
|
6902
6934
|
}
|
|
6903
|
-
}, async (
|
|
6904
|
-
var
|
|
6935
|
+
}, async (A) => {
|
|
6936
|
+
var $;
|
|
6905
6937
|
if (d)
|
|
6906
6938
|
return;
|
|
6907
|
-
if (
|
|
6908
|
-
return w(
|
|
6909
|
-
const
|
|
6910
|
-
if (xe(
|
|
6911
|
-
|
|
6912
|
-
data:
|
|
6939
|
+
if (A.error)
|
|
6940
|
+
return w(A.error);
|
|
6941
|
+
const P = A.pageInfo[a], C = ($ = A == null ? void 0 : A.data) == null ? void 0 : $[a];
|
|
6942
|
+
if (xe(C && P, "Expected rows and pageInfo"), C.length < o) {
|
|
6943
|
+
g(Et, {
|
|
6944
|
+
data: C,
|
|
6913
6945
|
status: "pre-bootstrap"
|
|
6914
6946
|
});
|
|
6915
6947
|
return;
|
|
6916
6948
|
}
|
|
6917
|
-
const
|
|
6918
|
-
if (!
|
|
6919
|
-
|
|
6920
|
-
data:
|
|
6949
|
+
const j = P.startCursor;
|
|
6950
|
+
if (!j) {
|
|
6951
|
+
g(Et, {
|
|
6952
|
+
data: C,
|
|
6921
6953
|
status: "pre-bootstrap"
|
|
6922
6954
|
});
|
|
6923
6955
|
return;
|
|
6924
6956
|
}
|
|
6925
|
-
u.delete(Fe(Et)),
|
|
6957
|
+
u.delete(Fe(Et)), M(j, !0), S(P.startCursor), d = !0;
|
|
6926
6958
|
}, r), {
|
|
6927
6959
|
unsubscribe: () => {
|
|
6928
6960
|
if (p) {
|
|
6929
|
-
p = !1,
|
|
6930
|
-
for (const
|
|
6931
|
-
|
|
6961
|
+
p = !1, b == null || b(), b = null;
|
|
6962
|
+
for (const A of f.values())
|
|
6963
|
+
A == null || A();
|
|
6932
6964
|
f.clear();
|
|
6933
6965
|
}
|
|
6934
6966
|
},
|
|
6935
|
-
loadNextPage:
|
|
6967
|
+
loadNextPage: F
|
|
6936
6968
|
};
|
|
6937
6969
|
}, $a = (t) => {
|
|
6938
6970
|
if (Object.keys(t).length !== 1)
|
|
6939
|
-
throw new
|
|
6971
|
+
throw new D("subscribeInfiniteQuery expects exactly one entity");
|
|
6940
6972
|
const [n, r] = Object.entries(t)[0];
|
|
6941
6973
|
if (!n || !r)
|
|
6942
|
-
throw new
|
|
6974
|
+
throw new D("No query provided for infinite query");
|
|
6943
6975
|
return { entityName: n, entityQuery: r };
|
|
6944
6976
|
}, xa = {
|
|
6945
6977
|
apiURI: "https://api.instantdb.com",
|
|
@@ -7369,7 +7401,7 @@ function Wn(t) {
|
|
|
7369
7401
|
const e = zn.get(t);
|
|
7370
7402
|
if (e)
|
|
7371
7403
|
return e;
|
|
7372
|
-
const n =
|
|
7404
|
+
const n = H(t);
|
|
7373
7405
|
return zn.set(t, n), n;
|
|
7374
7406
|
}
|
|
7375
7407
|
function qa(t, e) {
|
|
@@ -7388,7 +7420,7 @@ function za(t, e, n, r, s) {
|
|
|
7388
7420
|
...xa,
|
|
7389
7421
|
...i,
|
|
7390
7422
|
cardinalityInference: !!i.schema
|
|
7391
|
-
}, e ||
|
|
7423
|
+
}, e || Sr, n || Tr, { ...r || {}, "@instantdb/core": cn }, s), c = new Ka(a);
|
|
7392
7424
|
return Bt[Qt(i)] = c, Wa(i.appId, i.devtool), c;
|
|
7393
7425
|
}
|
|
7394
7426
|
function Wa(t, e) {
|
|
@@ -7406,8 +7438,8 @@ const Va = !1, Qa = (t, e) => t === e, at = {
|
|
|
7406
7438
|
};
|
|
7407
7439
|
let $r = Ur;
|
|
7408
7440
|
const ke = 1, ct = 2, Ba = {};
|
|
7409
|
-
var
|
|
7410
|
-
let Pt = null, Ga = null,
|
|
7441
|
+
var J = null;
|
|
7442
|
+
let Pt = null, Ga = null, G = null, Z = null, be = null, gt = 0;
|
|
7411
7443
|
function Ne(t, e) {
|
|
7412
7444
|
e = e ? Object.assign({}, at, e) : at;
|
|
7413
7445
|
const n = {
|
|
@@ -7418,10 +7450,10 @@ function Ne(t, e) {
|
|
|
7418
7450
|
}, r = (s) => (typeof s == "function" && (s = s(n.value)), Rr(n, s));
|
|
7419
7451
|
return [xr.bind(n), r];
|
|
7420
7452
|
}
|
|
7421
|
-
function
|
|
7453
|
+
function he(t, e, n) {
|
|
7422
7454
|
$r = Za;
|
|
7423
7455
|
const r = Dr(t, e, !1, ke);
|
|
7424
|
-
r.user = !0,
|
|
7456
|
+
r.user = !0, be ? be.push(r) : wt(r);
|
|
7425
7457
|
}
|
|
7426
7458
|
function un(t, e, n) {
|
|
7427
7459
|
n = n ? Object.assign({}, at, n) : at;
|
|
@@ -7429,28 +7461,28 @@ function un(t, e, n) {
|
|
|
7429
7461
|
return r.observers = null, r.observerSlots = null, r.comparator = n.equals || void 0, wt(r), xr.bind(r);
|
|
7430
7462
|
}
|
|
7431
7463
|
function Ha(t) {
|
|
7432
|
-
if (
|
|
7433
|
-
const e =
|
|
7434
|
-
|
|
7464
|
+
if (G === null) return t();
|
|
7465
|
+
const e = G;
|
|
7466
|
+
G = null;
|
|
7435
7467
|
try {
|
|
7436
7468
|
return t();
|
|
7437
7469
|
} finally {
|
|
7438
|
-
|
|
7470
|
+
G = e;
|
|
7439
7471
|
}
|
|
7440
7472
|
}
|
|
7441
|
-
function
|
|
7442
|
-
return
|
|
7473
|
+
function pe(t) {
|
|
7474
|
+
return J === null || (J.cleanups === null ? J.cleanups = [t] : J.cleanups.push(t)), t;
|
|
7443
7475
|
}
|
|
7444
7476
|
function xr() {
|
|
7445
7477
|
if (this.sources && this.state)
|
|
7446
7478
|
if (this.state === ke) wt(this);
|
|
7447
7479
|
else {
|
|
7448
|
-
const t =
|
|
7449
|
-
|
|
7480
|
+
const t = Z;
|
|
7481
|
+
Z = null, _t(() => lt(this)), Z = t;
|
|
7450
7482
|
}
|
|
7451
|
-
if (
|
|
7483
|
+
if (G) {
|
|
7452
7484
|
const t = this.observers ? this.observers.length : 0;
|
|
7453
|
-
|
|
7485
|
+
G.sources ? (G.sources.push(this), G.sourceSlots.push(t)) : (G.sources = [this], G.sourceSlots = [t]), this.observers ? (this.observers.push(G), this.observerSlots.push(G.sources.length - 1)) : (this.observers = [G], this.observerSlots = [G.sources.length - 1]);
|
|
7454
7486
|
}
|
|
7455
7487
|
return this.value;
|
|
7456
7488
|
}
|
|
@@ -7459,10 +7491,10 @@ function Rr(t, e, n) {
|
|
|
7459
7491
|
return (!t.comparator || !t.comparator(r, e)) && (t.value = e, t.observers && t.observers.length && _t(() => {
|
|
7460
7492
|
for (let s = 0; s < t.observers.length; s += 1) {
|
|
7461
7493
|
const i = t.observers[s], o = Pt && Pt.running;
|
|
7462
|
-
o && Pt.disposed.has(i), (o ? !i.tState : !i.state) && (i.pure ?
|
|
7494
|
+
o && Pt.disposed.has(i), (o ? !i.tState : !i.state) && (i.pure ? Z.push(i) : be.push(i), i.observers && Lr(i)), o || (i.state = ke);
|
|
7463
7495
|
}
|
|
7464
|
-
if (
|
|
7465
|
-
throw
|
|
7496
|
+
if (Z.length > 1e6)
|
|
7497
|
+
throw Z = [], new Error();
|
|
7466
7498
|
})), e;
|
|
7467
7499
|
}
|
|
7468
7500
|
function wt(t) {
|
|
@@ -7473,14 +7505,14 @@ function wt(t) {
|
|
|
7473
7505
|
}
|
|
7474
7506
|
function Ja(t, e, n) {
|
|
7475
7507
|
let r;
|
|
7476
|
-
const s =
|
|
7477
|
-
|
|
7508
|
+
const s = J, i = G;
|
|
7509
|
+
G = J = t;
|
|
7478
7510
|
try {
|
|
7479
7511
|
r = t.fn(e);
|
|
7480
7512
|
} catch (o) {
|
|
7481
7513
|
return t.pure && (t.state = ke, t.owned && t.owned.forEach(ft), t.owned = null), t.updatedAt = n + 1, Fr(o);
|
|
7482
7514
|
} finally {
|
|
7483
|
-
|
|
7515
|
+
G = i, J = s;
|
|
7484
7516
|
}
|
|
7485
7517
|
(!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? Rr(t, r) : t.value = r, t.updatedAt = n);
|
|
7486
7518
|
}
|
|
@@ -7494,11 +7526,11 @@ function Dr(t, e, n, r = ke, s) {
|
|
|
7494
7526
|
sourceSlots: null,
|
|
7495
7527
|
cleanups: null,
|
|
7496
7528
|
value: e,
|
|
7497
|
-
owner:
|
|
7498
|
-
context:
|
|
7529
|
+
owner: J,
|
|
7530
|
+
context: J ? J.context : null,
|
|
7499
7531
|
pure: n
|
|
7500
7532
|
};
|
|
7501
|
-
return
|
|
7533
|
+
return J === null || J !== Ba && (J.owned ? J.owned.push(i) : J.owned = [i]), i;
|
|
7502
7534
|
}
|
|
7503
7535
|
function ut(t) {
|
|
7504
7536
|
if (t.state === 0) return;
|
|
@@ -7511,25 +7543,25 @@ function ut(t) {
|
|
|
7511
7543
|
if (t = e[n], t.state === ke)
|
|
7512
7544
|
wt(t);
|
|
7513
7545
|
else if (t.state === ct) {
|
|
7514
|
-
const r =
|
|
7515
|
-
|
|
7546
|
+
const r = Z;
|
|
7547
|
+
Z = null, _t(() => lt(t, e[0])), Z = r;
|
|
7516
7548
|
}
|
|
7517
7549
|
}
|
|
7518
7550
|
function _t(t, e) {
|
|
7519
|
-
if (
|
|
7551
|
+
if (Z) return t();
|
|
7520
7552
|
let n = !1;
|
|
7521
|
-
|
|
7553
|
+
Z = [], be ? n = !0 : be = [], gt++;
|
|
7522
7554
|
try {
|
|
7523
7555
|
const r = t();
|
|
7524
7556
|
return Ya(n), r;
|
|
7525
7557
|
} catch (r) {
|
|
7526
|
-
n || (
|
|
7558
|
+
n || (be = null), Z = null, Fr(r);
|
|
7527
7559
|
}
|
|
7528
7560
|
}
|
|
7529
7561
|
function Ya(t) {
|
|
7530
|
-
if (
|
|
7531
|
-
const e =
|
|
7532
|
-
|
|
7562
|
+
if (Z && (Ur(Z), Z = null), t) return;
|
|
7563
|
+
const e = be;
|
|
7564
|
+
be = null, e.length && _t(() => $r(e));
|
|
7533
7565
|
}
|
|
7534
7566
|
function Ur(t) {
|
|
7535
7567
|
for (let e = 0; e < t.length; e++) ut(t[e]);
|
|
@@ -7555,7 +7587,7 @@ function lt(t, e) {
|
|
|
7555
7587
|
function Lr(t) {
|
|
7556
7588
|
for (let e = 0; e < t.observers.length; e += 1) {
|
|
7557
7589
|
const n = t.observers[e];
|
|
7558
|
-
n.state || (n.state = ct, n.pure ?
|
|
7590
|
+
n.state || (n.state = ct, n.pure ? Z.push(n) : be.push(n), n.observers && Lr(n));
|
|
7559
7591
|
}
|
|
7560
7592
|
}
|
|
7561
7593
|
function ft(t) {
|
|
@@ -7587,12 +7619,12 @@ function Xa(t) {
|
|
|
7587
7619
|
cause: t
|
|
7588
7620
|
});
|
|
7589
7621
|
}
|
|
7590
|
-
function Fr(t, e =
|
|
7622
|
+
function Fr(t, e = J) {
|
|
7591
7623
|
throw Xa(t);
|
|
7592
7624
|
}
|
|
7593
7625
|
const ec = 1e3;
|
|
7594
7626
|
function tc(t, e, n) {
|
|
7595
|
-
|
|
7627
|
+
he(() => {
|
|
7596
7628
|
const r = t.core._reactor.subscribeTopic(
|
|
7597
7629
|
t.type,
|
|
7598
7630
|
t.id,
|
|
@@ -7601,13 +7633,13 @@ function tc(t, e, n) {
|
|
|
7601
7633
|
n(s, i);
|
|
7602
7634
|
}
|
|
7603
7635
|
);
|
|
7604
|
-
|
|
7636
|
+
pe(r);
|
|
7605
7637
|
});
|
|
7606
7638
|
}
|
|
7607
7639
|
function nc(t, e) {
|
|
7608
|
-
return
|
|
7640
|
+
return he(() => {
|
|
7609
7641
|
const n = t.core._reactor.joinRoom(t.type, t.id);
|
|
7610
|
-
|
|
7642
|
+
pe(n);
|
|
7611
7643
|
}), (n) => {
|
|
7612
7644
|
t.core._reactor.publishTopic({
|
|
7613
7645
|
roomType: t.type,
|
|
@@ -7624,7 +7656,7 @@ function rc(t, e = {}) {
|
|
|
7624
7656
|
isLoading: !0
|
|
7625
7657
|
}
|
|
7626
7658
|
);
|
|
7627
|
-
|
|
7659
|
+
he(() => {
|
|
7628
7660
|
const i = t.core._reactor.subscribePresence(
|
|
7629
7661
|
t.type,
|
|
7630
7662
|
t.id,
|
|
@@ -7633,7 +7665,7 @@ function rc(t, e = {}) {
|
|
|
7633
7665
|
r(o);
|
|
7634
7666
|
}
|
|
7635
7667
|
);
|
|
7636
|
-
|
|
7668
|
+
pe(i);
|
|
7637
7669
|
});
|
|
7638
7670
|
const s = (i) => {
|
|
7639
7671
|
t.core._reactor.publishPresence(t.type, t.id, i);
|
|
@@ -7644,14 +7676,14 @@ function rc(t, e = {}) {
|
|
|
7644
7676
|
}));
|
|
7645
7677
|
}
|
|
7646
7678
|
function sc(t, e, n) {
|
|
7647
|
-
|
|
7679
|
+
he(() => {
|
|
7648
7680
|
const r = t.core._reactor.joinRoom(
|
|
7649
7681
|
t.type,
|
|
7650
7682
|
t.id,
|
|
7651
7683
|
e
|
|
7652
7684
|
);
|
|
7653
|
-
|
|
7654
|
-
}),
|
|
7685
|
+
pe(r);
|
|
7686
|
+
}), he(() => {
|
|
7655
7687
|
n ? n.forEach((r) => typeof r == "function" ? r() : r) : JSON.stringify(e), t.core._reactor.publishPresence(t.type, t.id, e);
|
|
7656
7688
|
});
|
|
7657
7689
|
}
|
|
@@ -7675,7 +7707,7 @@ function ic(t, e, n = {}) {
|
|
|
7675
7707
|
});
|
|
7676
7708
|
}, (n == null ? void 0 : n.timeout) ?? ec)));
|
|
7677
7709
|
};
|
|
7678
|
-
return
|
|
7710
|
+
return pe(() => {
|
|
7679
7711
|
r && (clearTimeout(r), r = null), o(!1);
|
|
7680
7712
|
}), {
|
|
7681
7713
|
active: i,
|
|
@@ -7770,7 +7802,7 @@ class uc {
|
|
|
7770
7802
|
*/
|
|
7771
7803
|
h(this, "useQuery", (e, n) => {
|
|
7772
7804
|
const [r, s] = Ne(Vn);
|
|
7773
|
-
return
|
|
7805
|
+
return he(() => {
|
|
7774
7806
|
const i = typeof e == "function" ? e() : e;
|
|
7775
7807
|
if (!i) {
|
|
7776
7808
|
s(
|
|
@@ -7797,7 +7829,7 @@ class uc {
|
|
|
7797
7829
|
)
|
|
7798
7830
|
);
|
|
7799
7831
|
});
|
|
7800
|
-
|
|
7832
|
+
pe(u);
|
|
7801
7833
|
}), r;
|
|
7802
7834
|
});
|
|
7803
7835
|
/**
|
|
@@ -7815,11 +7847,11 @@ class uc {
|
|
|
7815
7847
|
const [e, n] = Ne(
|
|
7816
7848
|
this.core._reactor._currentUserCached ?? ac
|
|
7817
7849
|
);
|
|
7818
|
-
return
|
|
7850
|
+
return he(() => {
|
|
7819
7851
|
const r = this.core.subscribeAuth((s) => {
|
|
7820
7852
|
n({ isLoading: !1, ...s });
|
|
7821
7853
|
});
|
|
7822
|
-
|
|
7854
|
+
pe(r);
|
|
7823
7855
|
}), e;
|
|
7824
7856
|
});
|
|
7825
7857
|
/**
|
|
@@ -7838,7 +7870,7 @@ class uc {
|
|
|
7838
7870
|
return un(() => {
|
|
7839
7871
|
const { user: n } = e();
|
|
7840
7872
|
if (!n)
|
|
7841
|
-
throw new
|
|
7873
|
+
throw new Y(
|
|
7842
7874
|
"useUser must be used within an auth-protected route"
|
|
7843
7875
|
);
|
|
7844
7876
|
return n;
|
|
@@ -7858,11 +7890,11 @@ class uc {
|
|
|
7858
7890
|
const [e, n] = Ne(
|
|
7859
7891
|
this.core._reactor.status
|
|
7860
7892
|
);
|
|
7861
|
-
return
|
|
7893
|
+
return he(() => {
|
|
7862
7894
|
const r = this.core.subscribeConnectionStatus((s) => {
|
|
7863
7895
|
n(() => s);
|
|
7864
7896
|
});
|
|
7865
|
-
|
|
7897
|
+
pe(r);
|
|
7866
7898
|
}), e;
|
|
7867
7899
|
});
|
|
7868
7900
|
/**
|
|
@@ -7877,11 +7909,11 @@ class uc {
|
|
|
7877
7909
|
*/
|
|
7878
7910
|
h(this, "useLocalId", (e) => {
|
|
7879
7911
|
const [n, r] = Ne(null);
|
|
7880
|
-
return
|
|
7912
|
+
return he(() => {
|
|
7881
7913
|
let s = !0;
|
|
7882
7914
|
this.getLocalId(e).then((i) => {
|
|
7883
7915
|
s && r(() => i);
|
|
7884
|
-
}),
|
|
7916
|
+
}), pe(() => {
|
|
7885
7917
|
s = !1;
|
|
7886
7918
|
});
|
|
7887
7919
|
}), n;
|
|
@@ -7937,7 +7969,7 @@ export {
|
|
|
7937
7969
|
_e as SyncTableCallbackEventType,
|
|
7938
7970
|
hc as createInstantRouteHandler,
|
|
7939
7971
|
dc as i,
|
|
7940
|
-
|
|
7972
|
+
N as id,
|
|
7941
7973
|
pc as init,
|
|
7942
7974
|
$i as lookup,
|
|
7943
7975
|
fc as tx
|