@instantdb/solidjs 0.22.149 → 0.22.150
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 +805 -805
- package/dist/standalone/index.umd.cjs +3 -3
- package/package.json +3 -3
package/dist/standalone/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (t, e, n) =>
|
|
1
|
+
var Mr = Object.defineProperty;
|
|
2
|
+
var jr = (t, e, n) => e in t ? Mr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var d = (t, e, n) => jr(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
function x(t) {
|
|
5
5
|
if (typeof t == "number")
|
|
6
6
|
return (Math.abs(t * 2654435761) >>> 0).toString(16);
|
|
@@ -43,7 +43,7 @@ const M = {
|
|
|
43
43
|
Remove: "remove",
|
|
44
44
|
Replace: "replace",
|
|
45
45
|
Add: "add"
|
|
46
|
-
}, xn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"),
|
|
46
|
+
}, xn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Dr = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Qe = Symbol.iterator, J = {
|
|
47
47
|
mutable: "mutable",
|
|
48
48
|
immutable: "immutable"
|
|
49
49
|
}, Nt = {};
|
|
@@ -67,7 +67,7 @@ function Kt(t) {
|
|
|
67
67
|
function qt(t) {
|
|
68
68
|
return Object.getPrototypeOf(t) === Map.prototype;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function H(t) {
|
|
71
71
|
var e;
|
|
72
72
|
return (e = t.copy) !== null && e !== void 0 ? e : t.original;
|
|
73
73
|
}
|
|
@@ -82,11 +82,11 @@ function zt(t) {
|
|
|
82
82
|
const n = O(t);
|
|
83
83
|
return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function te(t, e) {
|
|
86
86
|
if (!t || typeof t != "object")
|
|
87
87
|
return !1;
|
|
88
88
|
let n;
|
|
89
|
-
return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t,
|
|
89
|
+
return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, J)) === J.immutable || typeof n == "function");
|
|
90
90
|
}
|
|
91
91
|
function Un(t, e = []) {
|
|
92
92
|
if (Object.hasOwnProperty.call(t, "key")) {
|
|
@@ -102,7 +102,7 @@ function Un(t, e = []) {
|
|
|
102
102
|
return Un(t.parent, e);
|
|
103
103
|
e.reverse();
|
|
104
104
|
try {
|
|
105
|
-
|
|
105
|
+
$r(t.copy, e);
|
|
106
106
|
} catch {
|
|
107
107
|
return null;
|
|
108
108
|
}
|
|
@@ -119,7 +119,7 @@ function Ue(t, e, n) {
|
|
|
119
119
|
}
|
|
120
120
|
function yt(t, e) {
|
|
121
121
|
const n = O(t);
|
|
122
|
-
return (n ?
|
|
122
|
+
return (n ? H(n) : t)[e];
|
|
123
123
|
}
|
|
124
124
|
function ue(t, e) {
|
|
125
125
|
return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
|
|
@@ -135,7 +135,7 @@ function ye(t, e) {
|
|
|
135
135
|
return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
136
136
|
}).join("/");
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function $r(t, e) {
|
|
139
139
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
140
140
|
const r = e[n];
|
|
141
141
|
if (t = fe(we(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
|
|
@@ -143,7 +143,7 @@ function Dr(t, e) {
|
|
|
143
143
|
}
|
|
144
144
|
return t;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function Rr(t) {
|
|
147
147
|
const e = Object.create(Object.getPrototypeOf(t));
|
|
148
148
|
return Reflect.ownKeys(t).forEach((n) => {
|
|
149
149
|
let r = Reflect.getOwnPropertyDescriptor(t, n);
|
|
@@ -159,7 +159,7 @@ function $r(t) {
|
|
|
159
159
|
}), Reflect.defineProperty(e, n, r);
|
|
160
160
|
}), e;
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const xr = Object.prototype.propertyIsEnumerable;
|
|
163
163
|
function Ln(t, e) {
|
|
164
164
|
let n;
|
|
165
165
|
if (Array.isArray(t))
|
|
@@ -176,9 +176,9 @@ function Ln(t, e) {
|
|
|
176
176
|
return new r(t);
|
|
177
177
|
}
|
|
178
178
|
return new Map(t);
|
|
179
|
-
} else if (e != null && e.mark && (n = e.mark(t,
|
|
180
|
-
if (n ===
|
|
181
|
-
return
|
|
179
|
+
} else if (e != null && e.mark && (n = e.mark(t, J), n !== void 0) && n !== J.mutable) {
|
|
180
|
+
if (n === J.immutable)
|
|
181
|
+
return Rr(t);
|
|
182
182
|
if (typeof n == "function") {
|
|
183
183
|
if (e.enablePatches || e.enableAutoFreeze)
|
|
184
184
|
throw new Error("You can't use mark and patches or auto freeze together.");
|
|
@@ -190,7 +190,7 @@ function Ln(t, e) {
|
|
|
190
190
|
return Object.keys(t).forEach((s) => {
|
|
191
191
|
r[s] = t[s];
|
|
192
192
|
}), Object.getOwnPropertySymbols(t).forEach((s) => {
|
|
193
|
-
|
|
193
|
+
xr.call(t, s) && (r[s] = t[s]);
|
|
194
194
|
}), r;
|
|
195
195
|
} else
|
|
196
196
|
throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
|
|
@@ -199,7 +199,7 @@ function K(t) {
|
|
|
199
199
|
t.copy || (t.copy = Ln(t.original, t.options));
|
|
200
200
|
}
|
|
201
201
|
function Ee(t) {
|
|
202
|
-
if (!
|
|
202
|
+
if (!te(t))
|
|
203
203
|
return zt(t);
|
|
204
204
|
if (Array.isArray(t))
|
|
205
205
|
return t.map(Ee);
|
|
@@ -230,9 +230,9 @@ function Ee(t) {
|
|
|
230
230
|
function Be(t) {
|
|
231
231
|
return ge(t) ? Ee(t) : t;
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function se(t) {
|
|
234
234
|
var e;
|
|
235
|
-
t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent &&
|
|
235
|
+
t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && se(t.parent));
|
|
236
236
|
}
|
|
237
237
|
function nn() {
|
|
238
238
|
throw new Error("Cannot modify frozen object");
|
|
@@ -297,7 +297,7 @@ function Wt(t, e) {
|
|
|
297
297
|
t.forEach((r, s) => e(s, r, t));
|
|
298
298
|
}
|
|
299
299
|
function Fn(t, e, n) {
|
|
300
|
-
if (ge(t) || !
|
|
300
|
+
if (ge(t) || !te(t, n) || e.has(t) || Object.isFrozen(t))
|
|
301
301
|
return;
|
|
302
302
|
const r = t instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
|
|
303
303
|
if (e.add(t), Wt(t, (i, o) => {
|
|
@@ -316,7 +316,7 @@ function Fn(t, e, n) {
|
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function Ur(t, e) {
|
|
320
320
|
const n = t.type === 3 ? t.setMap : t.copy;
|
|
321
321
|
t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Fn(fe(n, e), t.finalities.handledSet, t.options);
|
|
322
322
|
}
|
|
@@ -343,12 +343,12 @@ function Vt(t, e, n, r) {
|
|
|
343
343
|
let u = s.original;
|
|
344
344
|
s.copy && (u = s.copy), At(t), Ot(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)), Ue(c, e, u);
|
|
345
345
|
}
|
|
346
|
-
}), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)),
|
|
346
|
+
}), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), te(n, t.options) && t.finalities.draft.push(() => {
|
|
347
347
|
const i = t.type === 3 ? t.setMap : t.copy;
|
|
348
|
-
ue(fe(i, e), n) &&
|
|
348
|
+
ue(fe(i, e), n) && Ur(t, e);
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function Lr(t, e, n, r, s) {
|
|
352
352
|
let { original: i, assignedMap: o, options: a } = t, c = t.copy;
|
|
353
353
|
c.length < i.length && ([i, c] = [c, i], [n, r] = [r, n]);
|
|
354
354
|
for (let u = 0; u < i.length; u += 1)
|
|
@@ -394,7 +394,7 @@ function Ur(t, e, n, r, s) {
|
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
function
|
|
397
|
+
function Fr({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
|
|
398
398
|
n.forEach((a, c) => {
|
|
399
399
|
const u = fe(t, c), l = Be(fe(e, c)), f = a ? De(t, c) ? M.Replace : M.Add : M.Remove;
|
|
400
400
|
if (ue(u, l) && f === M.Replace)
|
|
@@ -403,7 +403,7 @@ function Lr({ original: t, copy: e, assignedMap: n }, r, s, i, o) {
|
|
|
403
403
|
s.push(f === M.Remove ? { op: f, path: p } : { op: f, path: p, value: l }), i.push(f === M.Add ? { op: M.Remove, path: p } : f === M.Remove ? { op: M.Add, path: p, value: u } : { op: M.Replace, path: p, value: u });
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function Nr({ original: t, copy: e }, n, r, s, i) {
|
|
407
407
|
let o = 0;
|
|
408
408
|
t.forEach((a) => {
|
|
409
409
|
if (!e.has(a)) {
|
|
@@ -440,37 +440,37 @@ function xe(t, e, n, r) {
|
|
|
440
440
|
switch (t.type) {
|
|
441
441
|
case 0:
|
|
442
442
|
case 2:
|
|
443
|
-
return
|
|
443
|
+
return Fr(t, e, n, r, s);
|
|
444
444
|
case 1:
|
|
445
|
-
return
|
|
445
|
+
return Lr(t, e, n, r, s);
|
|
446
446
|
case 3:
|
|
447
|
-
return
|
|
447
|
+
return Nr(t, e, n, r, s);
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
const Je = (t, e, n = !1) => {
|
|
451
|
-
if (typeof t == "object" && t !== null && (!
|
|
451
|
+
if (typeof t == "object" && t !== null && (!te(t, e) || n))
|
|
452
452
|
throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
|
|
453
453
|
}, kt = {
|
|
454
454
|
get size() {
|
|
455
|
-
return
|
|
455
|
+
return H(O(this)).size;
|
|
456
456
|
},
|
|
457
457
|
has(t) {
|
|
458
|
-
return
|
|
458
|
+
return H(O(this)).has(t);
|
|
459
459
|
},
|
|
460
460
|
set(t, e) {
|
|
461
|
-
const n = O(this), r =
|
|
462
|
-
return (!r.has(t) || !ue(r.get(t), e)) && (K(n),
|
|
461
|
+
const n = O(this), r = H(n);
|
|
462
|
+
return (!r.has(t) || !ue(r.get(t), e)) && (K(n), se(n), n.assignedMap.set(t, !0), n.copy.set(t, e), Vt(n, t, e, xe)), this;
|
|
463
463
|
},
|
|
464
464
|
delete(t) {
|
|
465
465
|
if (!this.has(t))
|
|
466
466
|
return !1;
|
|
467
467
|
const e = O(this);
|
|
468
|
-
return K(e),
|
|
468
|
+
return K(e), se(e), e.original.has(t) ? e.assignedMap.set(t, !1) : e.assignedMap.delete(t), e.copy.delete(t), !0;
|
|
469
469
|
},
|
|
470
470
|
clear() {
|
|
471
471
|
const t = O(this);
|
|
472
472
|
if (this.size) {
|
|
473
|
-
K(t),
|
|
473
|
+
K(t), se(t), t.assignedMap = /* @__PURE__ */ new Map();
|
|
474
474
|
for (const [e] of t.original)
|
|
475
475
|
t.assignedMap.set(e, !1);
|
|
476
476
|
t.copy.clear();
|
|
@@ -478,14 +478,14 @@ const Je = (t, e, n = !1) => {
|
|
|
478
478
|
},
|
|
479
479
|
forEach(t, e) {
|
|
480
480
|
const n = O(this);
|
|
481
|
-
|
|
481
|
+
H(n).forEach((r, s) => {
|
|
482
482
|
t.call(e, this.get(s), s, this);
|
|
483
483
|
});
|
|
484
484
|
},
|
|
485
485
|
get(t) {
|
|
486
486
|
var e, n;
|
|
487
|
-
const r = O(this), s =
|
|
488
|
-
if (r.options.strict && Je(s, r.options, i), i || r.finalized || !
|
|
487
|
+
const r = O(this), s = H(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, J)) === J.mutable;
|
|
488
|
+
if (r.options.strict && Je(s, r.options, i), i || r.finalized || !te(s, r.options) || s !== r.original.get(t))
|
|
489
489
|
return s;
|
|
490
490
|
const o = Nt.createDraft({
|
|
491
491
|
original: s,
|
|
@@ -497,7 +497,7 @@ const Je = (t, e, n = !1) => {
|
|
|
497
497
|
return K(r), r.copy.set(t, o), o;
|
|
498
498
|
},
|
|
499
499
|
keys() {
|
|
500
|
-
return
|
|
500
|
+
return H(O(this)).keys();
|
|
501
501
|
},
|
|
502
502
|
values() {
|
|
503
503
|
const t = this.keys();
|
|
@@ -531,15 +531,15 @@ const Je = (t, e, n = !1) => {
|
|
|
531
531
|
[Qe]() {
|
|
532
532
|
return this.entries();
|
|
533
533
|
}
|
|
534
|
-
},
|
|
534
|
+
}, Kr = Reflect.ownKeys(kt), rn = (t, e, { isValuesIterator: n }) => () => {
|
|
535
535
|
var r, s;
|
|
536
536
|
const i = e.next();
|
|
537
537
|
if (i.done)
|
|
538
538
|
return i;
|
|
539
539
|
const o = i.value;
|
|
540
540
|
let a = t.setMap.get(o);
|
|
541
|
-
const c = O(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a,
|
|
542
|
-
if (t.options.strict && Je(o, t.options, u), !u && !c &&
|
|
541
|
+
const c = O(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, J)) === J.mutable;
|
|
542
|
+
if (t.options.strict && Je(o, t.options, u), !u && !c && te(o, t.options) && !t.finalized && t.original.has(o)) {
|
|
543
543
|
const l = Nt.createDraft({
|
|
544
544
|
original: o,
|
|
545
545
|
parentDraft: t,
|
|
@@ -567,13 +567,13 @@ const Je = (t, e, n = !1) => {
|
|
|
567
567
|
},
|
|
568
568
|
add(t) {
|
|
569
569
|
const e = O(this);
|
|
570
|
-
return this.has(t) || (K(e),
|
|
570
|
+
return this.has(t) || (K(e), se(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), Vt(e, t, t, xe)), this;
|
|
571
571
|
},
|
|
572
572
|
delete(t) {
|
|
573
573
|
if (!this.has(t))
|
|
574
574
|
return !1;
|
|
575
575
|
const e = O(this);
|
|
576
|
-
K(e),
|
|
576
|
+
K(e), se(e);
|
|
577
577
|
const n = O(t);
|
|
578
578
|
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));
|
|
579
579
|
},
|
|
@@ -581,7 +581,7 @@ const Je = (t, e, n = !1) => {
|
|
|
581
581
|
if (!this.size)
|
|
582
582
|
return;
|
|
583
583
|
const t = O(this);
|
|
584
|
-
K(t),
|
|
584
|
+
K(t), se(t);
|
|
585
585
|
for (const e of t.original)
|
|
586
586
|
t.assignedMap.set(e, !1);
|
|
587
587
|
t.setMap.clear();
|
|
@@ -642,7 +642,7 @@ Set.prototype.difference && Object.assign(Ye, {
|
|
|
642
642
|
return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
|
|
643
643
|
}
|
|
644
644
|
});
|
|
645
|
-
const
|
|
645
|
+
const qr = Reflect.ownKeys(Ye), Nn = /* @__PURE__ */ new WeakSet(), Kn = {
|
|
646
646
|
get(t, e, n) {
|
|
647
647
|
var r, s;
|
|
648
648
|
const i = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
|
|
@@ -653,18 +653,18 @@ const Kr = Reflect.ownKeys(Ye), Nn = /* @__PURE__ */ new WeakSet(), Kn = {
|
|
|
653
653
|
let o;
|
|
654
654
|
if (t.options.mark) {
|
|
655
655
|
const u = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
|
|
656
|
-
if (o = t.options.mark(u,
|
|
656
|
+
if (o = t.options.mark(u, J), o === J.mutable)
|
|
657
657
|
return t.options.strict && Je(u, t.options, !0), u;
|
|
658
658
|
}
|
|
659
|
-
const a =
|
|
660
|
-
if (a instanceof Map &&
|
|
659
|
+
const a = H(t);
|
|
660
|
+
if (a instanceof Map && Kr.includes(e)) {
|
|
661
661
|
if (e === "size")
|
|
662
662
|
return Object.getOwnPropertyDescriptor(kt, "size").get.call(t.proxy);
|
|
663
663
|
const u = kt[e];
|
|
664
664
|
if (u)
|
|
665
665
|
return u.bind(t.proxy);
|
|
666
666
|
}
|
|
667
|
-
if (a instanceof Set &&
|
|
667
|
+
if (a instanceof Set && qr.includes(e)) {
|
|
668
668
|
if (e === "size")
|
|
669
669
|
return Object.getOwnPropertyDescriptor(Ye, "size").get.call(t.proxy);
|
|
670
670
|
const u = Ye[e];
|
|
@@ -679,7 +679,7 @@ const Kr = Reflect.ownKeys(Ye), Nn = /* @__PURE__ */ new WeakSet(), Kn = {
|
|
|
679
679
|
) : void 0;
|
|
680
680
|
}
|
|
681
681
|
const c = a[e];
|
|
682
|
-
if (t.options.strict && Je(c, t.options), t.finalized || !
|
|
682
|
+
if (t.options.strict && Je(c, t.options), t.finalized || !te(c, t.options))
|
|
683
683
|
return c;
|
|
684
684
|
if (c === yt(t.original, e)) {
|
|
685
685
|
if (K(t), t.copy[e] = Qt({
|
|
@@ -690,7 +690,7 @@ const Kr = Reflect.ownKeys(Ye), Nn = /* @__PURE__ */ new WeakSet(), Kn = {
|
|
|
690
690
|
options: t.options
|
|
691
691
|
}), typeof o == "function") {
|
|
692
692
|
const u = O(t.copy[e]);
|
|
693
|
-
return K(u),
|
|
693
|
+
return K(u), se(u), u.copy;
|
|
694
694
|
}
|
|
695
695
|
return t.copy[e];
|
|
696
696
|
}
|
|
@@ -703,20 +703,20 @@ const Kr = Reflect.ownKeys(Ye), Nn = /* @__PURE__ */ new WeakSet(), Kn = {
|
|
|
703
703
|
let s;
|
|
704
704
|
if (t.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
|
|
705
705
|
throw new Error("Only supports setting array indices and the 'length' property.");
|
|
706
|
-
const i = tn(
|
|
706
|
+
const i = tn(H(t), e);
|
|
707
707
|
if (i != null && i.set)
|
|
708
708
|
return i.set.call(t.proxy, n), !0;
|
|
709
|
-
const o = yt(
|
|
710
|
-
return a && ue(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) : (ue(n, o) && (n !== void 0 || De(t.original, e)) || (K(t),
|
|
709
|
+
const o = yt(H(t), e), a = O(o);
|
|
710
|
+
return a && ue(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) : (ue(n, o) && (n !== void 0 || De(t.original, e)) || (K(t), se(t), De(t.original, e) && ue(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Vt(t, e, n, xe)), !0);
|
|
711
711
|
},
|
|
712
712
|
has(t, e) {
|
|
713
|
-
return e in
|
|
713
|
+
return e in H(t);
|
|
714
714
|
},
|
|
715
715
|
ownKeys(t) {
|
|
716
|
-
return Reflect.ownKeys(
|
|
716
|
+
return Reflect.ownKeys(H(t));
|
|
717
717
|
},
|
|
718
718
|
getOwnPropertyDescriptor(t, e) {
|
|
719
|
-
const n =
|
|
719
|
+
const n = H(t), r = Reflect.getOwnPropertyDescriptor(n, e);
|
|
720
720
|
return r && {
|
|
721
721
|
writable: !0,
|
|
722
722
|
configurable: t.type !== 1 || e !== "length",
|
|
@@ -735,7 +735,7 @@ const Kr = Reflect.ownKeys(Ye), Nn = /* @__PURE__ */ new WeakSet(), Kn = {
|
|
|
735
735
|
},
|
|
736
736
|
deleteProperty(t, e) {
|
|
737
737
|
var n;
|
|
738
|
-
return t.type === 1 ? Kn.set.call(this, t, e, void 0, t.proxy) : (yt(t.original, e) !== void 0 || e in t.original ? (K(t),
|
|
738
|
+
return t.type === 1 ? Kn.set.call(this, t, e, void 0, t.proxy) : (yt(t.original, e) !== void 0 || e in t.original ? (K(t), se(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);
|
|
739
739
|
}
|
|
740
740
|
};
|
|
741
741
|
function Qt(t) {
|
|
@@ -757,14 +757,14 @@ function Qt(t) {
|
|
|
757
757
|
const l = n;
|
|
758
758
|
l.finalities.draft.push((f, h) => {
|
|
759
759
|
var p, y;
|
|
760
|
-
const
|
|
760
|
+
const g = O(c);
|
|
761
761
|
let w = l.type === 3 ? l.setMap : l.copy;
|
|
762
|
-
const _ = fe(w, r),
|
|
763
|
-
if (
|
|
764
|
-
let m =
|
|
765
|
-
|
|
762
|
+
const _ = fe(w, r), b = O(_);
|
|
763
|
+
if (b) {
|
|
764
|
+
let m = b.original;
|
|
765
|
+
b.operated && (m = zt(_)), At(b), Ot(b, xe, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(m, b.original)), Ue(w, r, m);
|
|
766
766
|
}
|
|
767
|
-
(y =
|
|
767
|
+
(y = g.callbacks) === null || y === void 0 || y.forEach((m) => {
|
|
768
768
|
m(f, h);
|
|
769
769
|
});
|
|
770
770
|
});
|
|
@@ -777,7 +777,7 @@ function Qt(t) {
|
|
|
777
777
|
return c;
|
|
778
778
|
}
|
|
779
779
|
Nt.createDraft = Qt;
|
|
780
|
-
function
|
|
780
|
+
function zr(t, e, n, r, s) {
|
|
781
781
|
var i;
|
|
782
782
|
const o = O(t), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : t, c = !!e.length;
|
|
783
783
|
if (o != null && o.operated)
|
|
@@ -790,7 +790,7 @@ function qr(t, e, n, r, s) {
|
|
|
790
790
|
r && c ? [{ op: M.Replace, path: [], value: a }] : r
|
|
791
791
|
];
|
|
792
792
|
}
|
|
793
|
-
function
|
|
793
|
+
function Wr(t, e) {
|
|
794
794
|
var n;
|
|
795
795
|
const r = {
|
|
796
796
|
draft: [],
|
|
@@ -799,7 +799,7 @@ function zr(t, e) {
|
|
|
799
799
|
};
|
|
800
800
|
let s, i;
|
|
801
801
|
e.enablePatches && (s = [], i = []);
|
|
802
|
-
const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t,
|
|
802
|
+
const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, J)) === J.mutable || !te(t, e) ? t : Qt({
|
|
803
803
|
original: t,
|
|
804
804
|
parentDraft: null,
|
|
805
805
|
finalities: r,
|
|
@@ -808,7 +808,7 @@ function zr(t, e) {
|
|
|
808
808
|
return [
|
|
809
809
|
a,
|
|
810
810
|
(c = []) => {
|
|
811
|
-
const [u, l, f] =
|
|
811
|
+
const [u, l, f] = zr(a, c, s, i, e.enableAutoFreeze);
|
|
812
812
|
return e.enablePatches ? [u, l, f] : u;
|
|
813
813
|
}
|
|
814
814
|
];
|
|
@@ -831,7 +831,7 @@ function It(t) {
|
|
|
831
831
|
function qn(t) {
|
|
832
832
|
var e;
|
|
833
833
|
const n = O(t);
|
|
834
|
-
if (!
|
|
834
|
+
if (!te(t, n == null ? void 0 : n.options))
|
|
835
835
|
return t;
|
|
836
836
|
const r = we(t);
|
|
837
837
|
if (n && !n.operated)
|
|
@@ -865,22 +865,22 @@ function sn(t) {
|
|
|
865
865
|
throw new Error(`current() is only used for Draft, parameter: ${t}`);
|
|
866
866
|
return qn(t);
|
|
867
867
|
}
|
|
868
|
-
const
|
|
868
|
+
const Vr = (t) => function e(n, r, s) {
|
|
869
869
|
var i, o, a;
|
|
870
870
|
if (typeof n == "function" && typeof r != "function")
|
|
871
|
-
return function(T, ...
|
|
872
|
-
return e(T, (I) => n.call(this, I, ...
|
|
871
|
+
return function(T, ...v) {
|
|
872
|
+
return e(T, (I) => n.call(this, I, ...v), r);
|
|
873
873
|
};
|
|
874
874
|
const c = n, u = r;
|
|
875
875
|
let l = s;
|
|
876
876
|
if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
|
|
877
877
|
throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
|
|
878
878
|
l = Object.assign(Object.assign({}, t), l);
|
|
879
|
-
const f = ge(c) ? sn(c) : c, h = Array.isArray(l.mark) ? (T,
|
|
879
|
+
const f = ge(c) ? sn(c) : c, h = Array.isArray(l.mark) ? (T, v) => {
|
|
880
880
|
for (const I of l.mark) {
|
|
881
881
|
if (typeof I != "function")
|
|
882
882
|
throw new Error(`Invalid mark: ${I}, 'mark' should be a function.`);
|
|
883
|
-
const C = I(T,
|
|
883
|
+
const C = I(T, v);
|
|
884
884
|
if (C)
|
|
885
885
|
return C;
|
|
886
886
|
}
|
|
@@ -890,13 +890,13 @@ const Wr = (t) => function e(n, r, s) {
|
|
|
890
890
|
strict: y,
|
|
891
891
|
enablePatches: p
|
|
892
892
|
};
|
|
893
|
-
if (!
|
|
893
|
+
if (!te(f, w) && typeof f == "object" && f !== null)
|
|
894
894
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
895
|
-
const [_,
|
|
895
|
+
const [_, b] = Wr(f, w);
|
|
896
896
|
if (typeof r != "function") {
|
|
897
|
-
if (!
|
|
897
|
+
if (!te(f, w))
|
|
898
898
|
throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
|
|
899
|
-
return [_,
|
|
899
|
+
return [_, b];
|
|
900
900
|
}
|
|
901
901
|
let m;
|
|
902
902
|
try {
|
|
@@ -905,36 +905,36 @@ const Wr = (t) => function e(n, r, s) {
|
|
|
905
905
|
throw vt(O(_)), T;
|
|
906
906
|
}
|
|
907
907
|
const A = (T) => {
|
|
908
|
-
const
|
|
908
|
+
const v = O(_);
|
|
909
909
|
if (!ge(T)) {
|
|
910
|
-
if (T !== void 0 && !ue(T, _) && (
|
|
910
|
+
if (T !== void 0 && !ue(T, _) && (v != null && v.operated))
|
|
911
911
|
throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
|
|
912
|
-
const C = T == null ? void 0 : T[
|
|
912
|
+
const C = T == null ? void 0 : T[Dr];
|
|
913
913
|
if (C) {
|
|
914
|
-
const
|
|
914
|
+
const D = C[0];
|
|
915
915
|
return w.strict && typeof T == "object" && T !== null && It({
|
|
916
|
-
rootDraft:
|
|
916
|
+
rootDraft: v,
|
|
917
917
|
value: T,
|
|
918
918
|
useRawReturn: !0
|
|
919
|
-
}),
|
|
919
|
+
}), b([D]);
|
|
920
920
|
}
|
|
921
921
|
if (T !== void 0)
|
|
922
|
-
return typeof T == "object" && T !== null && It({ rootDraft:
|
|
922
|
+
return typeof T == "object" && T !== null && It({ rootDraft: v, value: T }), b([T]);
|
|
923
923
|
}
|
|
924
924
|
if (T === _ || T === void 0)
|
|
925
|
-
return
|
|
925
|
+
return b([]);
|
|
926
926
|
const I = O(T);
|
|
927
927
|
if (w === I.options) {
|
|
928
928
|
if (I.operated)
|
|
929
929
|
throw new Error("Cannot return a modified child draft.");
|
|
930
|
-
return
|
|
930
|
+
return b([sn(T)]);
|
|
931
931
|
}
|
|
932
|
-
return
|
|
932
|
+
return b([T]);
|
|
933
933
|
};
|
|
934
934
|
return m instanceof Promise ? m.then(A, (T) => {
|
|
935
935
|
throw vt(O(_)), T;
|
|
936
936
|
}) : A(m);
|
|
937
|
-
}, Ze =
|
|
937
|
+
}, Ze = Vr();
|
|
938
938
|
Object.prototype.constructor.toString();
|
|
939
939
|
function zn(t, e) {
|
|
940
940
|
const n = Object.keys(t), r = Object.keys(e);
|
|
@@ -973,7 +973,7 @@ function Wn(t, e) {
|
|
|
973
973
|
function Ce(t) {
|
|
974
974
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
975
975
|
}
|
|
976
|
-
function
|
|
976
|
+
function Qr(t, e, n) {
|
|
977
977
|
if (!t || e.length === 0)
|
|
978
978
|
return;
|
|
979
979
|
let r = t || {};
|
|
@@ -1003,13 +1003,13 @@ function Vn(t, e) {
|
|
|
1003
1003
|
Array.isArray(t) ? t.splice(n, 1) : delete t[n];
|
|
1004
1004
|
return;
|
|
1005
1005
|
}
|
|
1006
|
-
Vn(t[n], r),
|
|
1006
|
+
Vn(t[n], r), Br(t[n]) && delete t[n];
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
function
|
|
1009
|
+
function Br(t) {
|
|
1010
1010
|
return t && Object.keys(t).length === 0;
|
|
1011
1011
|
}
|
|
1012
|
-
const cn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/,
|
|
1012
|
+
const cn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, Gr = {
|
|
1013
1013
|
ZULU: 0,
|
|
1014
1014
|
YEKT: 18e3,
|
|
1015
1015
|
YEKST: 21600,
|
|
@@ -1205,39 +1205,39 @@ const cn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
|
|
|
1205
1205
|
ACSST: 37800,
|
|
1206
1206
|
ACDT: 37800
|
|
1207
1207
|
};
|
|
1208
|
-
function
|
|
1208
|
+
function Hr(t) {
|
|
1209
1209
|
return new Date(t);
|
|
1210
1210
|
}
|
|
1211
|
-
function
|
|
1211
|
+
function Jr(t) {
|
|
1212
1212
|
return /* @__PURE__ */ new Date(t + "Z");
|
|
1213
1213
|
}
|
|
1214
|
-
const
|
|
1215
|
-
function
|
|
1216
|
-
const e = t.match(
|
|
1214
|
+
const Yr = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
|
|
1215
|
+
function Zr(t) {
|
|
1216
|
+
const e = t.match(Yr);
|
|
1217
1217
|
if (!e)
|
|
1218
1218
|
return null;
|
|
1219
1219
|
const [n, r, s, i] = e;
|
|
1220
1220
|
return r <= 0 || s <= 0 || i <= 0 ? null : r > 999 ? new Date(Date.UTC(r, s - 1, i, 0, 0, 0, 0)) : new Date(Date.UTC(i, r - 1, s, 0, 0, 0, 0));
|
|
1221
1221
|
}
|
|
1222
|
-
function
|
|
1222
|
+
function Xr(t) {
|
|
1223
1223
|
const [e, n] = t.split(" ");
|
|
1224
1224
|
return /* @__PURE__ */ new Date(e + "T" + n + "Z");
|
|
1225
1225
|
}
|
|
1226
|
-
function
|
|
1226
|
+
function es(t) {
|
|
1227
1227
|
const [e, n] = t.split(" ");
|
|
1228
1228
|
return /* @__PURE__ */ new Date(e + "T" + n + "Z");
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1230
|
+
function ts(t) {
|
|
1231
1231
|
return new Date(t);
|
|
1232
1232
|
}
|
|
1233
|
-
function
|
|
1233
|
+
function ns(t) {
|
|
1234
1234
|
const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
|
|
1235
1235
|
if (!t.match(e))
|
|
1236
1236
|
throw new Error(`Unable to parse \`${t}\` as a date.`);
|
|
1237
1237
|
const r = /* @__PURE__ */ new Date(t + " UTC");
|
|
1238
1238
|
return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate(), 0, 0, 0, 0));
|
|
1239
1239
|
}
|
|
1240
|
-
function
|
|
1240
|
+
function rs(t) {
|
|
1241
1241
|
const e = /^(.+T.+)([+-])(\d{2})$/, n = t.match(e);
|
|
1242
1242
|
if (n) {
|
|
1243
1243
|
const [, r, s, i] = n, o = `${r}${s}${i}:00`;
|
|
@@ -1245,7 +1245,7 @@ function ns(t) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
return null;
|
|
1247
1247
|
}
|
|
1248
|
-
function
|
|
1248
|
+
function ss(t) {
|
|
1249
1249
|
const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, n = t.match(e);
|
|
1250
1250
|
if (n) {
|
|
1251
1251
|
const [, r, s, i, o, a] = n, c = s.padStart(2, "0"), u = i.padStart(2, "0"), l = `${r}-${c}-${u}T${a}`;
|
|
@@ -1253,14 +1253,14 @@ function rs(t) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
return null;
|
|
1255
1255
|
}
|
|
1256
|
-
function
|
|
1256
|
+
function is(t) {
|
|
1257
1257
|
const [e, n] = t.split(", "), [r, s, i] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
|
|
1258
1258
|
if (!o)
|
|
1259
1259
|
throw new Error(`Unable to parse time from: ${t}`);
|
|
1260
1260
|
let [, a, c, u, l] = o;
|
|
1261
1261
|
return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
|
|
1262
1262
|
}
|
|
1263
|
-
function
|
|
1263
|
+
function os(t) {
|
|
1264
1264
|
switch (t) {
|
|
1265
1265
|
case "epoch":
|
|
1266
1266
|
return /* @__PURE__ */ new Date(0);
|
|
@@ -1272,28 +1272,28 @@ function is(t) {
|
|
|
1272
1272
|
return null;
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
|
-
function
|
|
1275
|
+
function as(t) {
|
|
1276
1276
|
const e = t.match(cn);
|
|
1277
1277
|
if (!e)
|
|
1278
1278
|
return null;
|
|
1279
|
-
const [n] = e, r =
|
|
1279
|
+
const [n] = e, r = Gr[n], s = new Date(t.replace(cn, "Z"));
|
|
1280
1280
|
return new Date(s.getTime() - r * 1e3);
|
|
1281
1281
|
}
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1284
|
-
Xr,
|
|
1285
|
-
ts,
|
|
1286
|
-
ss,
|
|
1282
|
+
const cs = [
|
|
1283
|
+
Zr,
|
|
1287
1284
|
es,
|
|
1288
|
-
Hr,
|
|
1289
1285
|
ns,
|
|
1290
|
-
Zr,
|
|
1291
|
-
Gr,
|
|
1292
1286
|
is,
|
|
1287
|
+
ts,
|
|
1288
|
+
Jr,
|
|
1289
|
+
rs,
|
|
1290
|
+
Xr,
|
|
1291
|
+
Hr,
|
|
1293
1292
|
os,
|
|
1294
|
-
|
|
1293
|
+
as,
|
|
1294
|
+
ss
|
|
1295
1295
|
];
|
|
1296
|
-
function
|
|
1296
|
+
function us(t, e) {
|
|
1297
1297
|
try {
|
|
1298
1298
|
const n = t(e);
|
|
1299
1299
|
return n instanceof Date && !isNaN(n.getTime()) ? n : null;
|
|
@@ -1302,14 +1302,14 @@ function cs(t, e) {
|
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
1304
|
function Et(t) {
|
|
1305
|
-
for (const e of
|
|
1306
|
-
const n =
|
|
1305
|
+
for (const e of cs) {
|
|
1306
|
+
const n = us(e, t);
|
|
1307
1307
|
if (n)
|
|
1308
1308
|
return n;
|
|
1309
1309
|
}
|
|
1310
1310
|
return null;
|
|
1311
1311
|
}
|
|
1312
|
-
function
|
|
1312
|
+
function ls(t) {
|
|
1313
1313
|
try {
|
|
1314
1314
|
const e = JSON.parse(t);
|
|
1315
1315
|
return typeof e == "string" ? Et(e) : null;
|
|
@@ -1324,7 +1324,7 @@ function ot(t) {
|
|
|
1324
1324
|
if (t instanceof Date)
|
|
1325
1325
|
return t;
|
|
1326
1326
|
if (typeof t == "string") {
|
|
1327
|
-
const e = Et(t) ||
|
|
1327
|
+
const e = Et(t) || ls(t) || Et(t.trim());
|
|
1328
1328
|
if (!e)
|
|
1329
1329
|
throw new Error(`Unable to parse \`${t}\` as a date.`);
|
|
1330
1330
|
return e;
|
|
@@ -1408,7 +1408,7 @@ class be {
|
|
|
1408
1408
|
return { attrs: this.attrs, linkIndex: this.linkIndex };
|
|
1409
1409
|
}
|
|
1410
1410
|
}
|
|
1411
|
-
function
|
|
1411
|
+
function fs(t) {
|
|
1412
1412
|
return t.cardinality === "one";
|
|
1413
1413
|
}
|
|
1414
1414
|
function Gt(t) {
|
|
@@ -1420,7 +1420,7 @@ function Ht(t) {
|
|
|
1420
1420
|
function ke(t, e) {
|
|
1421
1421
|
return e.reduce((n, r) => n && n.get(r), t);
|
|
1422
1422
|
}
|
|
1423
|
-
function
|
|
1423
|
+
function ee(t, e) {
|
|
1424
1424
|
if (e.length === 0)
|
|
1425
1425
|
throw new Error("path must have at least one element");
|
|
1426
1426
|
if (e.length === 1) {
|
|
@@ -1428,7 +1428,7 @@ function X(t, e) {
|
|
|
1428
1428
|
return;
|
|
1429
1429
|
}
|
|
1430
1430
|
const [n, ...r] = e;
|
|
1431
|
-
t.has(n) &&
|
|
1431
|
+
t.has(n) && ee(t.get(n), r);
|
|
1432
1432
|
}
|
|
1433
1433
|
function V(t, e, n) {
|
|
1434
1434
|
let r = t;
|
|
@@ -1470,7 +1470,7 @@ function Hn(t, e) {
|
|
|
1470
1470
|
if (e && "__type" in e)
|
|
1471
1471
|
return new be(e.attrs, e.linkIndex);
|
|
1472
1472
|
}
|
|
1473
|
-
function
|
|
1473
|
+
function ds(t, e) {
|
|
1474
1474
|
return ke(t.eav, [e]) !== void 0;
|
|
1475
1475
|
}
|
|
1476
1476
|
function Pe(t, e, n, r) {
|
|
@@ -1494,7 +1494,7 @@ function Le(t, e) {
|
|
|
1494
1494
|
const [o, a] = r, c = t.aev.get(o);
|
|
1495
1495
|
if (!c)
|
|
1496
1496
|
return null;
|
|
1497
|
-
const l = (i = Q(c, 2).find((
|
|
1497
|
+
const l = (i = Q(c, 2).find((g) => g[2] === a)) == null ? void 0 : i[0];
|
|
1498
1498
|
if (!l)
|
|
1499
1499
|
return null;
|
|
1500
1500
|
const [f, h, p, ...y] = e;
|
|
@@ -1509,14 +1509,14 @@ function Jn(t, e, n) {
|
|
|
1509
1509
|
if (!r)
|
|
1510
1510
|
return;
|
|
1511
1511
|
const [s, i, o] = r, a = e.getAttr(i);
|
|
1512
|
-
a && (
|
|
1512
|
+
a && (ee(t.eav, [s, i, o]), ee(t.aev, [i, s, o]), Gt(a) && ee(t.vae, [o, i, s]));
|
|
1513
1513
|
}
|
|
1514
|
-
let
|
|
1514
|
+
let hs = 0;
|
|
1515
1515
|
function Yn(t, e, n) {
|
|
1516
1516
|
const [r, s, i] = n;
|
|
1517
1517
|
let o;
|
|
1518
1518
|
const a = ke(t.eav, [r, s, i]);
|
|
1519
|
-
return a && (o = a[3]), o || Date.now() * 10 +
|
|
1519
|
+
return a && (o = a[3]), o || Date.now() * 10 + hs++;
|
|
1520
1520
|
}
|
|
1521
1521
|
function Zn(t, e, n) {
|
|
1522
1522
|
const r = Le(t, n);
|
|
@@ -1528,9 +1528,9 @@ function Zn(t, e, n) {
|
|
|
1528
1528
|
return;
|
|
1529
1529
|
a["checked-data-type"] === "date" && t.useDateObjects && (o = ot(o));
|
|
1530
1530
|
const c = ke(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Yn(t, a, r), l = [s, i, o, u];
|
|
1531
|
-
|
|
1531
|
+
fs(a) ? (V(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), V(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (V(t.eav, [s, i, o], l), V(t.aev, [i, s, o], l)), Gt(a) && V(t.vae, [o, i, s], l);
|
|
1532
1532
|
}
|
|
1533
|
-
function
|
|
1533
|
+
function ps(t, e, n) {
|
|
1534
1534
|
var p;
|
|
1535
1535
|
const r = Le(t, n);
|
|
1536
1536
|
if (!r)
|
|
@@ -1563,23 +1563,23 @@ function Ct(t, e, n) {
|
|
|
1563
1563
|
if (a) {
|
|
1564
1564
|
for (const f of a.keys()) {
|
|
1565
1565
|
const h = e.getAttr(f);
|
|
1566
|
-
h && h["on-delete-reverse"] === "cascade" && Q(a.get(f), 1).forEach(([p, y,
|
|
1566
|
+
h && h["on-delete-reverse"] === "cascade" && Q(a.get(f), 1).forEach(([p, y, g]) => {
|
|
1567
1567
|
var w;
|
|
1568
|
-
return Ct(t, e, [
|
|
1568
|
+
return Ct(t, e, [g, (w = h["reverse-identity"]) == null ? void 0 : w[1]]);
|
|
1569
1569
|
}), // Fall back to deleting everything if we've rehydrated tx-steps from
|
|
1570
1570
|
// the store that didn't set `etype` in deleteEntity
|
|
1571
1571
|
(!s || // If we don't know about the attr, let's just get rid of it
|
|
1572
1572
|
!h || // Make sure it matches the etype
|
|
1573
|
-
((u = h["forward-identity"]) == null ? void 0 : u[1]) === s) && (
|
|
1573
|
+
((u = h["forward-identity"]) == null ? void 0 : u[1]) === s) && (ee(t.aev, [f, o]), ee(t.eav, [o, f]));
|
|
1574
1574
|
}
|
|
1575
|
-
a.size === 0 &&
|
|
1575
|
+
a.size === 0 && ee(t.eav, [o]);
|
|
1576
1576
|
}
|
|
1577
1577
|
const c = t.vae.get(o) && Q(t.vae.get(o), 2);
|
|
1578
1578
|
c && c.forEach((f) => {
|
|
1579
|
-
var w, _,
|
|
1580
|
-
const [h, p, y] = f,
|
|
1581
|
-
(!s || !
|
|
1582
|
-
}), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 &&
|
|
1579
|
+
var w, _, b;
|
|
1580
|
+
const [h, p, y] = f, g = e.getAttr(p);
|
|
1581
|
+
(!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (ee(t.eav, [h, p, y]), ee(t.aev, [p, h, y]), ee(t.vae, [y, p, h])), g && g["on-delete"] === "cascade" && ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s && Ct(t, e, [h, (b = g["forward-identity"]) == null ? void 0 : b[1]]);
|
|
1582
|
+
}), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && ee(t.vae, [o]);
|
|
1583
1583
|
}
|
|
1584
1584
|
function Xn(t, e, n) {
|
|
1585
1585
|
const r = Qn(e, n, t.useDateObjects);
|
|
@@ -1587,29 +1587,29 @@ function Xn(t, e, n) {
|
|
|
1587
1587
|
t[s] = r[s];
|
|
1588
1588
|
});
|
|
1589
1589
|
}
|
|
1590
|
-
function
|
|
1590
|
+
function ys(t, [e]) {
|
|
1591
1591
|
t.addAttr(e);
|
|
1592
1592
|
}
|
|
1593
1593
|
function er(t) {
|
|
1594
1594
|
return Q(t.eav, 3);
|
|
1595
1595
|
}
|
|
1596
|
-
function
|
|
1596
|
+
function bs(t, e, [n]) {
|
|
1597
1597
|
if (!e.getAttr(n))
|
|
1598
1598
|
return;
|
|
1599
1599
|
const r = er(t).filter(([s, i]) => i !== n);
|
|
1600
1600
|
e.deleteAttr(n), Xn(t, e, r);
|
|
1601
1601
|
}
|
|
1602
|
-
function
|
|
1602
|
+
function gs(t, e, [n]) {
|
|
1603
1603
|
e.getAttr(n.id) && (e.updateAttr(n), Xn(t, e, er(t)));
|
|
1604
1604
|
}
|
|
1605
|
-
function
|
|
1605
|
+
function ws(t, e, n) {
|
|
1606
1606
|
const [r, ...s] = n;
|
|
1607
1607
|
switch (r) {
|
|
1608
1608
|
case "add-triple":
|
|
1609
1609
|
Zn(t, e, s);
|
|
1610
1610
|
break;
|
|
1611
1611
|
case "deep-merge-triple":
|
|
1612
|
-
|
|
1612
|
+
ps(t, e, s);
|
|
1613
1613
|
break;
|
|
1614
1614
|
case "retract-triple":
|
|
1615
1615
|
Jn(t, e, s);
|
|
@@ -1618,13 +1618,13 @@ function gs(t, e, n) {
|
|
|
1618
1618
|
Ct(t, e, s);
|
|
1619
1619
|
break;
|
|
1620
1620
|
case "add-attr":
|
|
1621
|
-
|
|
1621
|
+
ys(e, s);
|
|
1622
1622
|
break;
|
|
1623
1623
|
case "delete-attr":
|
|
1624
|
-
|
|
1624
|
+
bs(t, e, s);
|
|
1625
1625
|
break;
|
|
1626
1626
|
case "update-attr":
|
|
1627
|
-
|
|
1627
|
+
gs(t, e, s);
|
|
1628
1628
|
break;
|
|
1629
1629
|
case "restore-attr":
|
|
1630
1630
|
break;
|
|
@@ -1679,13 +1679,13 @@ function Ke(t, e, n) {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
return r;
|
|
1681
1681
|
}
|
|
1682
|
-
function
|
|
1682
|
+
function _s(t, e, n) {
|
|
1683
1683
|
let r = "";
|
|
1684
1684
|
return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
|
|
1685
1685
|
}
|
|
1686
|
-
function
|
|
1686
|
+
function ms(t, [e, n, r]) {
|
|
1687
1687
|
var i, o;
|
|
1688
|
-
switch (
|
|
1688
|
+
switch (_s(e, n, r)) {
|
|
1689
1689
|
case "e": {
|
|
1690
1690
|
const a = t.eav.get(e);
|
|
1691
1691
|
return Q(a, 2);
|
|
@@ -1731,7 +1731,7 @@ function _s(t, [e, n, r]) {
|
|
|
1731
1731
|
return Q(t.eav, 3);
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
1734
|
-
function
|
|
1734
|
+
function Ts(t, e, n) {
|
|
1735
1735
|
var s;
|
|
1736
1736
|
const r = {};
|
|
1737
1737
|
if (!e)
|
|
@@ -1743,7 +1743,7 @@ function ms(t, e, n) {
|
|
|
1743
1743
|
}
|
|
1744
1744
|
return r;
|
|
1745
1745
|
}
|
|
1746
|
-
function
|
|
1746
|
+
function j(t, e, n) {
|
|
1747
1747
|
var r;
|
|
1748
1748
|
return (r = t.forwardIdents.get(e)) == null ? void 0 : r.get(n);
|
|
1749
1749
|
}
|
|
@@ -1751,7 +1751,7 @@ function _e(t, e, n) {
|
|
|
1751
1751
|
var r;
|
|
1752
1752
|
return (r = t.revIdents.get(e)) == null ? void 0 : r.get(n);
|
|
1753
1753
|
}
|
|
1754
|
-
function
|
|
1754
|
+
function Ss(t, e) {
|
|
1755
1755
|
return t.blobAttrs.get(e);
|
|
1756
1756
|
}
|
|
1757
1757
|
function tr(t, e) {
|
|
@@ -1759,7 +1759,7 @@ function tr(t, e) {
|
|
|
1759
1759
|
const n = t.primaryKeys.get(e);
|
|
1760
1760
|
return n || ((r = t.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
|
|
1761
1761
|
}
|
|
1762
|
-
function
|
|
1762
|
+
function vs(t, e, n) {
|
|
1763
1763
|
const r = Le(t, n);
|
|
1764
1764
|
if (!r)
|
|
1765
1765
|
return;
|
|
@@ -1767,7 +1767,7 @@ function Ss(t, e, n) {
|
|
|
1767
1767
|
if (e.getAttr(i))
|
|
1768
1768
|
return ke(t.eav, [s, i]);
|
|
1769
1769
|
}
|
|
1770
|
-
function
|
|
1770
|
+
function As(t, e, n) {
|
|
1771
1771
|
const r = n.filter(([s, i, o, a, c]) => {
|
|
1772
1772
|
if (s !== "add-triple" && s !== "deep-merge-triple")
|
|
1773
1773
|
return !0;
|
|
@@ -1778,7 +1778,7 @@ function vs(t, e, n) {
|
|
|
1778
1778
|
const f = e.getAttr(o);
|
|
1779
1779
|
if (f) {
|
|
1780
1780
|
const h = tr(e, f["forward-identity"][1]);
|
|
1781
|
-
l = !!
|
|
1781
|
+
l = !!vs(t, e, [
|
|
1782
1782
|
i,
|
|
1783
1783
|
h == null ? void 0 : h.id,
|
|
1784
1784
|
i
|
|
@@ -1788,7 +1788,7 @@ function vs(t, e, n) {
|
|
|
1788
1788
|
});
|
|
1789
1789
|
return Ze({ store: t, attrsStore: e }, (s) => {
|
|
1790
1790
|
r.forEach((i) => {
|
|
1791
|
-
|
|
1791
|
+
ws(s.store, s.attrsStore, i);
|
|
1792
1792
|
});
|
|
1793
1793
|
}, {
|
|
1794
1794
|
mark: (s) => {
|
|
@@ -1797,10 +1797,10 @@ function vs(t, e, n) {
|
|
|
1797
1797
|
}
|
|
1798
1798
|
});
|
|
1799
1799
|
}
|
|
1800
|
-
function
|
|
1800
|
+
function Os(t) {
|
|
1801
1801
|
return typeof t == "string" && t.startsWith("?");
|
|
1802
1802
|
}
|
|
1803
|
-
function
|
|
1803
|
+
function ks(t, e, n) {
|
|
1804
1804
|
if (n.hasOwnProperty(t)) {
|
|
1805
1805
|
const r = n[t];
|
|
1806
1806
|
return nr(r, e, n);
|
|
@@ -1810,15 +1810,15 @@ function Os(t, e, n) {
|
|
|
1810
1810
|
function un(t, e, n) {
|
|
1811
1811
|
return t === e ? n : null;
|
|
1812
1812
|
}
|
|
1813
|
-
function
|
|
1813
|
+
function Is(t) {
|
|
1814
1814
|
switch (typeof t) {
|
|
1815
1815
|
case "string":
|
|
1816
|
-
return t.startsWith("?") ?
|
|
1816
|
+
return t.startsWith("?") ? ks : un;
|
|
1817
1817
|
default:
|
|
1818
1818
|
return un;
|
|
1819
1819
|
}
|
|
1820
1820
|
}
|
|
1821
|
-
const
|
|
1821
|
+
const Es = [
|
|
1822
1822
|
"in",
|
|
1823
1823
|
"$in",
|
|
1824
1824
|
"$not",
|
|
@@ -1826,69 +1826,69 @@ const Is = [
|
|
|
1826
1826
|
"$comparator"
|
|
1827
1827
|
// covers all of $gt, $lt, etc.
|
|
1828
1828
|
];
|
|
1829
|
-
function
|
|
1830
|
-
for (const e of
|
|
1829
|
+
function Cs(t) {
|
|
1830
|
+
for (const e of Es)
|
|
1831
1831
|
if (t.hasOwnProperty(e))
|
|
1832
1832
|
return !0;
|
|
1833
1833
|
return !1;
|
|
1834
1834
|
}
|
|
1835
1835
|
function nr(t, e, n) {
|
|
1836
|
-
return n ? typeof t == "object" ?
|
|
1836
|
+
return n ? typeof t == "object" ? Cs(t) ? n : null : Is(t)(t, e, n) : null;
|
|
1837
1837
|
}
|
|
1838
|
-
function
|
|
1838
|
+
function Ps(t, e, n) {
|
|
1839
1839
|
return t.reduce((r, s, i) => {
|
|
1840
1840
|
const o = e[i];
|
|
1841
1841
|
return nr(s, o, r);
|
|
1842
1842
|
}, n);
|
|
1843
1843
|
}
|
|
1844
|
-
function Ps(t, e, n) {
|
|
1845
|
-
return Ds(t, e, n).map((r) => Cs(e, r, n)).filter((r) => r);
|
|
1846
|
-
}
|
|
1847
1844
|
function Ms(t, e, n) {
|
|
1848
|
-
return
|
|
1845
|
+
return $s(t, e, n).map((r) => Ps(e, r, n)).filter((r) => r);
|
|
1846
|
+
}
|
|
1847
|
+
function js(t, e, n) {
|
|
1848
|
+
return e.or ? e.or.patterns.flatMap((r) => Pt(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => Pt(t, s, r), n) : n.flatMap((r) => Ms(t, e, r));
|
|
1849
1849
|
}
|
|
1850
1850
|
function Pt(t, e, n = [{}]) {
|
|
1851
|
-
return e.reduce((r, s) =>
|
|
1851
|
+
return e.reduce((r, s) => js(t, s, r), n);
|
|
1852
1852
|
}
|
|
1853
1853
|
function Jt(t, e) {
|
|
1854
|
-
return Array.isArray(e) ? e.map((n) => Jt(t, n)) :
|
|
1854
|
+
return Array.isArray(e) ? e.map((n) => Jt(t, n)) : Os(e) ? t[e] : e;
|
|
1855
1855
|
}
|
|
1856
|
-
function
|
|
1856
|
+
function Ds(t, { find: e, where: n }) {
|
|
1857
1857
|
return Pt(t, n).map((s) => Jt(s, e));
|
|
1858
1858
|
}
|
|
1859
|
-
function
|
|
1860
|
-
return
|
|
1859
|
+
function $s(t, e, n) {
|
|
1860
|
+
return ms(t, Jt(n, e));
|
|
1861
1861
|
}
|
|
1862
|
-
const
|
|
1862
|
+
const Rs = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
1863
1863
|
function Ae(t) {
|
|
1864
|
-
return typeof t == "string" &&
|
|
1864
|
+
return typeof t == "string" && Rs.test(t);
|
|
1865
1865
|
}
|
|
1866
1866
|
const $ = [];
|
|
1867
1867
|
for (let t = 0; t < 256; ++t)
|
|
1868
1868
|
$.push((t + 256).toString(16).slice(1));
|
|
1869
|
-
function
|
|
1869
|
+
function xs(t, e = 0) {
|
|
1870
1870
|
return ($[t[e + 0]] + $[t[e + 1]] + $[t[e + 2]] + $[t[e + 3]] + "-" + $[t[e + 4]] + $[t[e + 5]] + "-" + $[t[e + 6]] + $[t[e + 7]] + "-" + $[t[e + 8]] + $[t[e + 9]] + "-" + $[t[e + 10]] + $[t[e + 11]] + $[t[e + 12]] + $[t[e + 13]] + $[t[e + 14]] + $[t[e + 15]]).toLowerCase();
|
|
1871
1871
|
}
|
|
1872
1872
|
let bt;
|
|
1873
|
-
const
|
|
1874
|
-
function
|
|
1873
|
+
const Us = new Uint8Array(16);
|
|
1874
|
+
function Ls() {
|
|
1875
1875
|
if (!bt) {
|
|
1876
1876
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1877
1877
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1878
1878
|
bt = crypto.getRandomValues.bind(crypto);
|
|
1879
1879
|
}
|
|
1880
|
-
return bt(
|
|
1880
|
+
return bt(Us);
|
|
1881
1881
|
}
|
|
1882
|
-
const
|
|
1883
|
-
function
|
|
1882
|
+
const Fs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ln = { randomUUID: Fs };
|
|
1883
|
+
function Ns(t, e, n) {
|
|
1884
1884
|
var s;
|
|
1885
1885
|
if (ln.randomUUID && !t)
|
|
1886
1886
|
return ln.randomUUID();
|
|
1887
1887
|
t = t || {};
|
|
1888
|
-
const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ??
|
|
1888
|
+
const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? Ls();
|
|
1889
1889
|
if (r.length < 16)
|
|
1890
1890
|
throw new Error("Random bytes length must be >= 16");
|
|
1891
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
1891
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, xs(r);
|
|
1892
1892
|
}
|
|
1893
1893
|
function fn(t) {
|
|
1894
1894
|
const e = t.replace(/-/g, ""), n = [];
|
|
@@ -1896,7 +1896,7 @@ function fn(t) {
|
|
|
1896
1896
|
n.push(parseInt(e.substring(r, r + 2), 16));
|
|
1897
1897
|
return n;
|
|
1898
1898
|
}
|
|
1899
|
-
function
|
|
1899
|
+
function Ks(t, e) {
|
|
1900
1900
|
for (let n = 0; n < t.length; n++) {
|
|
1901
1901
|
if (t[n] < e[n])
|
|
1902
1902
|
return -1;
|
|
@@ -1905,17 +1905,17 @@ function Ns(t, e) {
|
|
|
1905
1905
|
}
|
|
1906
1906
|
return 0;
|
|
1907
1907
|
}
|
|
1908
|
-
function
|
|
1909
|
-
return
|
|
1908
|
+
function qs(t, e) {
|
|
1909
|
+
return Ks(fn(t), fn(e));
|
|
1910
1910
|
}
|
|
1911
1911
|
function P() {
|
|
1912
|
-
return
|
|
1912
|
+
return Ns();
|
|
1913
1913
|
}
|
|
1914
|
-
function
|
|
1914
|
+
function zs(t, e) {
|
|
1915
1915
|
return t.localeCompare(e);
|
|
1916
1916
|
}
|
|
1917
|
-
function
|
|
1918
|
-
let t =
|
|
1917
|
+
function Ws() {
|
|
1918
|
+
let t = zs;
|
|
1919
1919
|
if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
|
|
1920
1920
|
try {
|
|
1921
1921
|
t = Intl.Collator("en-US").compare;
|
|
@@ -1923,10 +1923,10 @@ function zs() {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
return t;
|
|
1925
1925
|
}
|
|
1926
|
-
const
|
|
1927
|
-
let
|
|
1926
|
+
const Vs = Ws();
|
|
1927
|
+
let Qs = !0, Bs = 0;
|
|
1928
1928
|
function $e(t) {
|
|
1929
|
-
return at(`_${t}`,
|
|
1929
|
+
return at(`_${t}`, Bs++);
|
|
1930
1930
|
}
|
|
1931
1931
|
function at(t, e) {
|
|
1932
1932
|
return `?${t}-${e}`;
|
|
@@ -1936,28 +1936,28 @@ class Oe extends Error {
|
|
|
1936
1936
|
super(e), this.name = "AttrNotFoundError";
|
|
1937
1937
|
}
|
|
1938
1938
|
}
|
|
1939
|
-
function
|
|
1939
|
+
function Gs(t, e) {
|
|
1940
1940
|
const n = tr(t, e);
|
|
1941
1941
|
if (!n)
|
|
1942
1942
|
throw new Oe(`Could not find id attr for ${e}`);
|
|
1943
1943
|
return n;
|
|
1944
1944
|
}
|
|
1945
1945
|
function dn(t, e, n, r) {
|
|
1946
|
-
return [
|
|
1946
|
+
return [Hs(t, e, n, r)];
|
|
1947
1947
|
}
|
|
1948
|
-
function
|
|
1948
|
+
function Hs(t, e, n, r) {
|
|
1949
1949
|
return [
|
|
1950
1950
|
t(n, r),
|
|
1951
|
-
|
|
1951
|
+
Gs(e, n).id,
|
|
1952
1952
|
t(n, r),
|
|
1953
1953
|
t("time", r)
|
|
1954
1954
|
];
|
|
1955
1955
|
}
|
|
1956
|
-
function
|
|
1956
|
+
function Js(t, e, n) {
|
|
1957
1957
|
return t.map((r) => r === e ? n : r);
|
|
1958
1958
|
}
|
|
1959
1959
|
function rr(t, e, n, r, s) {
|
|
1960
|
-
const i =
|
|
1960
|
+
const i = j(e, n, s), o = _e(e, n, s), a = i || o;
|
|
1961
1961
|
if (!a)
|
|
1962
1962
|
throw new Oe(`Could not find attr for ${[n, s]}`);
|
|
1963
1963
|
if (a["value-type"] !== "ref")
|
|
@@ -1985,7 +1985,7 @@ function hn(t, e) {
|
|
|
1985
1985
|
return typeof o != "string" ? !1 : s.test(o);
|
|
1986
1986
|
};
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1988
|
+
function Ys(t, e) {
|
|
1989
1989
|
if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
|
|
1990
1990
|
return e;
|
|
1991
1991
|
const n = t["checked-data-type"] === "date";
|
|
@@ -2045,12 +2045,12 @@ function Js(t, e) {
|
|
|
2045
2045
|
}
|
|
2046
2046
|
return e;
|
|
2047
2047
|
}
|
|
2048
|
-
function
|
|
2049
|
-
const o =
|
|
2048
|
+
function Zs(t, e, n, r, s, i) {
|
|
2049
|
+
const o = j(e, n, s), a = _e(e, n, s), c = o || a;
|
|
2050
2050
|
if (!c)
|
|
2051
2051
|
throw new Oe(`No attr for etype = ${n} label = ${s}`);
|
|
2052
2052
|
if (i != null && i.hasOwnProperty("$isNull")) {
|
|
2053
|
-
const u =
|
|
2053
|
+
const u = j(e, n, "id");
|
|
2054
2054
|
if (!u)
|
|
2055
2055
|
throw new Oe(`No attr for etype = ${n} label = id`);
|
|
2056
2056
|
return [
|
|
@@ -2063,31 +2063,31 @@ function Ys(t, e, n, r, s, i) {
|
|
|
2063
2063
|
return o ? [
|
|
2064
2064
|
t(n, r),
|
|
2065
2065
|
c.id,
|
|
2066
|
-
|
|
2066
|
+
Ys(c, i),
|
|
2067
2067
|
$e("time")
|
|
2068
2068
|
] : [i, c.id, t(n, r), $e("time")];
|
|
2069
2069
|
}
|
|
2070
|
-
function
|
|
2070
|
+
function Xs(t, e, n, r, s) {
|
|
2071
2071
|
const [i, o, a] = s.reduce((c, u) => {
|
|
2072
|
-
const [l, f, h] = c, [p, y,
|
|
2073
|
-
return [p, y, [...h,
|
|
2072
|
+
const [l, f, h] = c, [p, y, g] = rr(t, e, l, f, u);
|
|
2073
|
+
return [p, y, [...h, g]];
|
|
2074
2074
|
}, [n, r, []]);
|
|
2075
2075
|
return [i, o, a];
|
|
2076
2076
|
}
|
|
2077
2077
|
function Mt(t, e, n, r, s, i) {
|
|
2078
|
-
const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] =
|
|
2078
|
+
const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = Xs(t, e, n, r, o), f = Zs(t, e, c, u, a, i);
|
|
2079
2079
|
return l.concat([f]);
|
|
2080
2080
|
}
|
|
2081
|
-
function
|
|
2081
|
+
function ei(t, e) {
|
|
2082
2082
|
return e ? [e].concat(t) : t;
|
|
2083
2083
|
}
|
|
2084
|
-
function
|
|
2084
|
+
function ti([t, e]) {
|
|
2085
2085
|
return t === "or" && Array.isArray(e);
|
|
2086
2086
|
}
|
|
2087
|
-
function
|
|
2087
|
+
function ni([t, e]) {
|
|
2088
2088
|
return t === "and" && Array.isArray(e);
|
|
2089
2089
|
}
|
|
2090
|
-
function
|
|
2090
|
+
function ri(t, e, n) {
|
|
2091
2091
|
return (r, s) => {
|
|
2092
2092
|
const i = t(r, s);
|
|
2093
2093
|
return e == i ? i : `${i}-${n}`;
|
|
@@ -2095,27 +2095,27 @@ function ni(t, e, n) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
function pn(t, e, n, r, s, i) {
|
|
2097
2097
|
const o = t(r, s), a = i.map((c, u) => {
|
|
2098
|
-
const l =
|
|
2098
|
+
const l = ri(t, o, u);
|
|
2099
2099
|
return sr(l, n, r, s, c);
|
|
2100
2100
|
});
|
|
2101
2101
|
return { [e]: { patterns: a, joinSym: o } };
|
|
2102
2102
|
}
|
|
2103
|
-
function
|
|
2103
|
+
function si(t) {
|
|
2104
2104
|
const e = [];
|
|
2105
2105
|
for (let n = 1; n <= t.length; n++)
|
|
2106
2106
|
e.push(t.slice(0, n));
|
|
2107
2107
|
return e;
|
|
2108
2108
|
}
|
|
2109
2109
|
function yn(t, e, n, r, s) {
|
|
2110
|
-
return
|
|
2110
|
+
return si(s).map((i) => Mt(t, e, n, r, i, {
|
|
2111
2111
|
$isNull: !0
|
|
2112
2112
|
}));
|
|
2113
2113
|
}
|
|
2114
2114
|
function sr(t, e, n, r, s) {
|
|
2115
2115
|
return Object.entries(s).flatMap(([i, o]) => {
|
|
2116
|
-
if (ei([i, o]))
|
|
2117
|
-
return pn(t, "or", e, n, r, o);
|
|
2118
2116
|
if (ti([i, o]))
|
|
2117
|
+
return pn(t, "or", e, n, r, o);
|
|
2118
|
+
if (ni([i, o]))
|
|
2119
2119
|
return pn(t, "and", e, n, r, o);
|
|
2120
2120
|
if (i === "$entityIdStartsWith")
|
|
2121
2121
|
return [];
|
|
@@ -2141,46 +2141,46 @@ function sr(t, e, n, r, s) {
|
|
|
2141
2141
|
] : Mt(t, e, n, r, a, o);
|
|
2142
2142
|
});
|
|
2143
2143
|
}
|
|
2144
|
-
function
|
|
2144
|
+
function ii(t, e, n, r) {
|
|
2145
2145
|
const s = at;
|
|
2146
2146
|
return r ? sr(s, t, e, n, r).concat(dn(s, t, e, n)) : dn(s, t, e, n);
|
|
2147
2147
|
}
|
|
2148
|
-
function
|
|
2148
|
+
function oi(t, e, n) {
|
|
2149
2149
|
return [t(e, n), t("time", n)];
|
|
2150
2150
|
}
|
|
2151
|
-
function
|
|
2152
|
-
const [o, a, c, u, l] = rr(t, e, n, r, s), f =
|
|
2151
|
+
function ai(t, e, n, r, s, i) {
|
|
2152
|
+
const [o, a, c, u, l] = rr(t, e, n, r, s), f = Js(c, t(n, r), i);
|
|
2153
2153
|
return [o, a, f, u, l];
|
|
2154
2154
|
}
|
|
2155
|
-
function
|
|
2155
|
+
function ci(t, e, n, { etype: r, level: s, form: i }, o) {
|
|
2156
2156
|
const a = Object.keys(i).filter((c) => c !== "$");
|
|
2157
2157
|
return a.length ? Object.entries(o).map(function([u, l]) {
|
|
2158
2158
|
return a.map(function(p) {
|
|
2159
|
-
var
|
|
2160
|
-
const y = !!(e.cardinalityInference && ((_ = (w = (
|
|
2159
|
+
var g, w, _;
|
|
2160
|
+
const y = !!(e.cardinalityInference && ((_ = (w = (g = n.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : w[p]) != null && _.isSingular));
|
|
2161
2161
|
try {
|
|
2162
|
-
const [
|
|
2163
|
-
etype:
|
|
2162
|
+
const [b, m, A] = ai(t, n, r, s, p, u), T = or(e, n, {
|
|
2163
|
+
etype: b,
|
|
2164
2164
|
level: m,
|
|
2165
2165
|
form: i[p],
|
|
2166
2166
|
join: A
|
|
2167
|
-
}),
|
|
2168
|
-
return { [p]:
|
|
2169
|
-
} catch (
|
|
2170
|
-
if (
|
|
2167
|
+
}), v = y ? T[0] : T;
|
|
2168
|
+
return { [p]: v };
|
|
2169
|
+
} catch (b) {
|
|
2170
|
+
if (b instanceof Oe)
|
|
2171
2171
|
return { [p]: y ? void 0 : [] };
|
|
2172
|
-
throw
|
|
2172
|
+
throw b;
|
|
2173
2173
|
}
|
|
2174
2174
|
}).reduce(function(p, y) {
|
|
2175
2175
|
return { ...p, ...y };
|
|
2176
2176
|
}, l);
|
|
2177
2177
|
}) : Object.values(o);
|
|
2178
2178
|
}
|
|
2179
|
-
function
|
|
2180
|
-
return n === "string" ?
|
|
2179
|
+
function ui(t, e, n) {
|
|
2180
|
+
return n === "string" ? Vs(t, e) : t > e ? 1 : -1;
|
|
2181
2181
|
}
|
|
2182
2182
|
function Me(t, e, n, r, s) {
|
|
2183
|
-
return e === r || e == null && r == null ?
|
|
2183
|
+
return e === r || e == null && r == null ? qs(t, n) : r == null ? 1 : e == null ? -1 : ui(e, r, s);
|
|
2184
2184
|
}
|
|
2185
2185
|
function Xe([t, e], [n, r], s) {
|
|
2186
2186
|
return Me(t, e, n, r, s);
|
|
@@ -2188,7 +2188,7 @@ function Xe([t, e], [n, r], s) {
|
|
|
2188
2188
|
function jt(t) {
|
|
2189
2189
|
return t == null ? t : new Date(t).getTime();
|
|
2190
2190
|
}
|
|
2191
|
-
function
|
|
2191
|
+
function li(t, e, n, r) {
|
|
2192
2192
|
var y;
|
|
2193
2193
|
const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
|
|
2194
2194
|
if (((y = e["forward-identity"]) == null ? void 0 : y[2]) === "id")
|
|
@@ -2196,65 +2196,65 @@ function ui(t, e, n, r) {
|
|
|
2196
2196
|
const [u, l] = r, f = e["checked-data-type"], h = f === "date" ? jt(l) : l, p = f === "date" ? jt(o) : o;
|
|
2197
2197
|
return Xe([u, h], [s, p], f) === c;
|
|
2198
2198
|
}
|
|
2199
|
-
function
|
|
2199
|
+
function fi(t, e) {
|
|
2200
2200
|
const n = e[1];
|
|
2201
2201
|
return t.getAttr(n);
|
|
2202
2202
|
}
|
|
2203
|
-
function
|
|
2203
|
+
function di(t, e, n) {
|
|
2204
2204
|
const r = Object.keys(n)[0];
|
|
2205
|
-
return
|
|
2205
|
+
return j(t, e, r);
|
|
2206
2206
|
}
|
|
2207
|
-
function
|
|
2207
|
+
function hi(t, e, n, r) {
|
|
2208
2208
|
if (n)
|
|
2209
|
-
return
|
|
2209
|
+
return fi(t, n);
|
|
2210
2210
|
if (r)
|
|
2211
|
-
return
|
|
2211
|
+
return di(t, e, r);
|
|
2212
2212
|
}
|
|
2213
|
-
function
|
|
2213
|
+
function pi(t, e, n) {
|
|
2214
2214
|
var s, i;
|
|
2215
2215
|
if (!Array.isArray(n.fields))
|
|
2216
|
-
return
|
|
2216
|
+
return Ss(t, e);
|
|
2217
2217
|
const r = /* @__PURE__ */ new Map();
|
|
2218
2218
|
for (const o of n.fields) {
|
|
2219
|
-
const a =
|
|
2219
|
+
const a = j(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
|
|
2220
2220
|
c && Ht(a) && r.set(c, a);
|
|
2221
2221
|
}
|
|
2222
2222
|
if (!r.has("id")) {
|
|
2223
|
-
const o =
|
|
2223
|
+
const o = j(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
|
|
2224
2224
|
a && r.set(a, o);
|
|
2225
2225
|
}
|
|
2226
2226
|
return r;
|
|
2227
2227
|
}
|
|
2228
|
-
function
|
|
2229
|
-
var y,
|
|
2230
|
-
const o = (y = i == null ? void 0 : i.$) == null ? void 0 : y.order, a = ir(i), c =
|
|
2231
|
-
let u =
|
|
2232
|
-
const l = r == null ? void 0 : r["start-cursor"], f =
|
|
2233
|
-
if (f && ((
|
|
2228
|
+
function yi(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
|
|
2229
|
+
var y, g;
|
|
2230
|
+
const o = (y = i == null ? void 0 : i.$) == null ? void 0 : y.order, a = ir(i), c = bi(i);
|
|
2231
|
+
let u = Ds(t, s);
|
|
2232
|
+
const l = r == null ? void 0 : r["start-cursor"], f = hi(e, n, l, o);
|
|
2233
|
+
if (f && ((g = f == null ? void 0 : f["forward-identity"]) == null ? void 0 : g[2]) !== "id") {
|
|
2234
2234
|
const w = f["checked-data-type"] === "date", _ = f.id;
|
|
2235
|
-
u = u.map(([
|
|
2236
|
-
var A, T,
|
|
2237
|
-
let m = (C = (I = (
|
|
2238
|
-
return w && (m = jt(m)), [
|
|
2235
|
+
u = u.map(([b]) => {
|
|
2236
|
+
var A, T, v, I, C;
|
|
2237
|
+
let m = (C = (I = (v = (T = (A = t.eav.get(b)) == null ? void 0 : A.get(_)) == null ? void 0 : T.values()) == null ? void 0 : v.next()) == null ? void 0 : I.value) == null ? void 0 : C[2];
|
|
2238
|
+
return w && (m = jt(m)), [b, m];
|
|
2239
2239
|
});
|
|
2240
2240
|
}
|
|
2241
|
-
u.sort(c === "asc" ? function(_,
|
|
2242
|
-
return Xe(_,
|
|
2243
|
-
} : function(_,
|
|
2244
|
-
return Xe(
|
|
2241
|
+
u.sort(c === "asc" ? function(_, b) {
|
|
2242
|
+
return Xe(_, b, f == null ? void 0 : f["checked-data-type"]);
|
|
2243
|
+
} : function(_, b) {
|
|
2244
|
+
return Xe(b, _, f == null ? void 0 : f["checked-data-type"]);
|
|
2245
2245
|
});
|
|
2246
2246
|
let h = {};
|
|
2247
|
-
const p =
|
|
2247
|
+
const p = pi(e, n, s);
|
|
2248
2248
|
for (const w of u) {
|
|
2249
2249
|
const [_] = w;
|
|
2250
|
-
if (h[_] || !a && l && f &&
|
|
2250
|
+
if (h[_] || !a && l && f && li(l, f, c, w))
|
|
2251
2251
|
continue;
|
|
2252
|
-
const
|
|
2253
|
-
|
|
2252
|
+
const b = Ts(t, p, _);
|
|
2253
|
+
b && (h[_] = b);
|
|
2254
2254
|
}
|
|
2255
2255
|
return h;
|
|
2256
2256
|
}
|
|
2257
|
-
function
|
|
2257
|
+
function bi(t) {
|
|
2258
2258
|
var n;
|
|
2259
2259
|
const e = (n = t.$) == null ? void 0 : n.order;
|
|
2260
2260
|
return e && e[Object.keys(e)[0]] || "asc";
|
|
@@ -2264,26 +2264,26 @@ function ir(t) {
|
|
|
2264
2264
|
const e = (s = t.$) == null ? void 0 : s.offset, n = (i = t.$) == null ? void 0 : i.before, r = (o = t.$) == null ? void 0 : o.after;
|
|
2265
2265
|
return !e && !n && !r;
|
|
2266
2266
|
}
|
|
2267
|
-
function
|
|
2268
|
-
var h, p, y,
|
|
2267
|
+
function gi(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
|
|
2268
|
+
var h, p, y, g, w;
|
|
2269
2269
|
if (!ir(s) && (!o || !o["start-cursor"]))
|
|
2270
2270
|
return [];
|
|
2271
|
-
const a =
|
|
2271
|
+
const a = ei(ii(e, n, r, (h = s.$) == null ? void 0 : h.where), i), c = oi(at, n, r), u = (p = s.$) == null ? void 0 : p.fields, l = yi(t, e, {
|
|
2272
2272
|
etype: n,
|
|
2273
2273
|
pageInfo: o,
|
|
2274
2274
|
form: s,
|
|
2275
2275
|
dq: { where: a, find: c, fields: u }
|
|
2276
|
-
}), f = ((y = s.$) == null ? void 0 : y.limit) || ((
|
|
2276
|
+
}), f = ((y = s.$) == null ? void 0 : y.limit) || ((g = s.$) == null ? void 0 : g.first) || ((w = s.$) == null ? void 0 : w.last);
|
|
2277
2277
|
if (f != null) {
|
|
2278
|
-
r > 0 &&
|
|
2278
|
+
r > 0 && Qs && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
|
|
2279
2279
|
const _ = Object.entries(l);
|
|
2280
2280
|
return _.length <= f ? l : Object.fromEntries(_.slice(0, f));
|
|
2281
2281
|
}
|
|
2282
2282
|
return l;
|
|
2283
2283
|
}
|
|
2284
|
-
function
|
|
2284
|
+
function wi(t, e, n) {
|
|
2285
2285
|
try {
|
|
2286
|
-
return
|
|
2286
|
+
return gi(t, e, n);
|
|
2287
2287
|
} catch (r) {
|
|
2288
2288
|
if (r instanceof Oe)
|
|
2289
2289
|
return {};
|
|
@@ -2291,10 +2291,10 @@ function gi(t, e, n) {
|
|
|
2291
2291
|
}
|
|
2292
2292
|
}
|
|
2293
2293
|
function or(t, e, n) {
|
|
2294
|
-
const r =
|
|
2295
|
-
return
|
|
2294
|
+
const r = wi(t, e, n);
|
|
2295
|
+
return ci(at, t, e, n, r);
|
|
2296
2296
|
}
|
|
2297
|
-
function
|
|
2297
|
+
function _i(t) {
|
|
2298
2298
|
const e = {};
|
|
2299
2299
|
for (const [n, r] of Object.entries(t))
|
|
2300
2300
|
e[n] = {
|
|
@@ -2314,9 +2314,9 @@ function ar({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, s) {
|
|
|
2314
2314
|
pageInfo: n == null ? void 0 : n[u]
|
|
2315
2315
|
})), c;
|
|
2316
2316
|
}, {}) };
|
|
2317
|
-
return n && (o.pageInfo =
|
|
2317
|
+
return n && (o.pageInfo = _i(n)), r && (o.aggregate = r), o;
|
|
2318
2318
|
}
|
|
2319
|
-
function
|
|
2319
|
+
function mi() {
|
|
2320
2320
|
const e = {
|
|
2321
2321
|
__etype: 1,
|
|
2322
2322
|
__ops: 1,
|
|
@@ -2330,7 +2330,7 @@ function _i() {
|
|
|
2330
2330
|
};
|
|
2331
2331
|
return new Set(Object.keys(e));
|
|
2332
2332
|
}
|
|
2333
|
-
const
|
|
2333
|
+
const Ti = mi();
|
|
2334
2334
|
function He(t, e, n) {
|
|
2335
2335
|
const r = {
|
|
2336
2336
|
__etype: t,
|
|
@@ -2342,7 +2342,7 @@ function He(t, e, n) {
|
|
|
2342
2342
|
return n;
|
|
2343
2343
|
if (i === "__etype")
|
|
2344
2344
|
return t;
|
|
2345
|
-
if (
|
|
2345
|
+
if (Ti.has(i))
|
|
2346
2346
|
return (o, a) => He(t, e, [
|
|
2347
2347
|
...n,
|
|
2348
2348
|
a ? [i, t, e, o, a] : [i, t, e, o]
|
|
@@ -2350,7 +2350,7 @@ function He(t, e, n) {
|
|
|
2350
2350
|
}
|
|
2351
2351
|
});
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2353
|
+
function Si(t, e) {
|
|
2354
2354
|
return `lookup__${t}__${JSON.stringify(e)}`;
|
|
2355
2355
|
}
|
|
2356
2356
|
function et(t) {
|
|
@@ -2360,13 +2360,13 @@ function Dt(t) {
|
|
|
2360
2360
|
const [e, n, ...r] = t.split("__");
|
|
2361
2361
|
return [n, JSON.parse(r.join("__"))];
|
|
2362
2362
|
}
|
|
2363
|
-
function
|
|
2363
|
+
function vi(t) {
|
|
2364
2364
|
return new Proxy({
|
|
2365
2365
|
__etype: t
|
|
2366
2366
|
}, {
|
|
2367
2367
|
get(e, n) {
|
|
2368
2368
|
if (n === "lookup")
|
|
2369
|
-
return (s, i) => He(t, Dt(
|
|
2369
|
+
return (s, i) => He(t, Dt(Si(s, i)), []);
|
|
2370
2370
|
if (n === "__etype")
|
|
2371
2371
|
return t;
|
|
2372
2372
|
const r = n;
|
|
@@ -2377,15 +2377,15 @@ function Si(t) {
|
|
|
2377
2377
|
function Yt() {
|
|
2378
2378
|
return new Proxy({}, {
|
|
2379
2379
|
get(t, e) {
|
|
2380
|
-
return
|
|
2380
|
+
return vi(e);
|
|
2381
2381
|
}
|
|
2382
2382
|
});
|
|
2383
2383
|
}
|
|
2384
|
-
const
|
|
2385
|
-
function
|
|
2384
|
+
const Ga = Yt();
|
|
2385
|
+
function Ai(t) {
|
|
2386
2386
|
return t.__ops;
|
|
2387
2387
|
}
|
|
2388
|
-
function
|
|
2388
|
+
function Oi(t, e) {
|
|
2389
2389
|
const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
|
|
2390
2390
|
for (const o of e) {
|
|
2391
2391
|
const a = n[o];
|
|
@@ -2404,7 +2404,7 @@ function Ai(t, e) {
|
|
|
2404
2404
|
}
|
|
2405
2405
|
return s;
|
|
2406
2406
|
}
|
|
2407
|
-
function
|
|
2407
|
+
function ki(t) {
|
|
2408
2408
|
if (Array.isArray(t))
|
|
2409
2409
|
return t;
|
|
2410
2410
|
const e = Object.entries(t);
|
|
@@ -2412,10 +2412,10 @@ function Oi(t) {
|
|
|
2412
2412
|
throw new Error("lookup must be an object with a single unique attr and value.");
|
|
2413
2413
|
return e[0];
|
|
2414
2414
|
}
|
|
2415
|
-
function
|
|
2415
|
+
function Ii(t, e, n) {
|
|
2416
2416
|
return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2417
2417
|
// before assuming it's a ref lookup.
|
|
2418
|
-
!
|
|
2418
|
+
!j(t, e, n);
|
|
2419
2419
|
}
|
|
2420
2420
|
function $t(t) {
|
|
2421
2421
|
const [e, n, ...r] = t.split(".");
|
|
@@ -2423,22 +2423,22 @@ function $t(t) {
|
|
|
2423
2423
|
throw new Error(`${t} is not a valid lookup attribute.`);
|
|
2424
2424
|
return e;
|
|
2425
2425
|
}
|
|
2426
|
-
function
|
|
2427
|
-
if (!
|
|
2428
|
-
return
|
|
2429
|
-
const r = $t(n), s =
|
|
2426
|
+
function Ei(t, e, n) {
|
|
2427
|
+
if (!Ii(t, e, n))
|
|
2428
|
+
return j(t, e, n);
|
|
2429
|
+
const r = $t(n), s = j(t, e, r) || _e(t, e, r);
|
|
2430
2430
|
if (s && s["value-type"] !== "ref")
|
|
2431
2431
|
throw new Error(`${n} does not reference a valid link attribute.`);
|
|
2432
2432
|
return s;
|
|
2433
2433
|
}
|
|
2434
2434
|
function Rt(t) {
|
|
2435
|
-
return typeof t == "string" && !et(t) ? null : typeof t == "string" && et(t) ? Dt(t) :
|
|
2435
|
+
return typeof t == "string" && !et(t) ? null : typeof t == "string" && et(t) ? Dt(t) : ki(t);
|
|
2436
2436
|
}
|
|
2437
2437
|
function B(t, e, n) {
|
|
2438
2438
|
const r = Rt(n);
|
|
2439
2439
|
if (r === null)
|
|
2440
2440
|
return n;
|
|
2441
|
-
const [s, i] = r, o =
|
|
2441
|
+
const [s, i] = r, o = Ei(t, e, s);
|
|
2442
2442
|
if (!o || !o["unique?"])
|
|
2443
2443
|
throw new Error(`${s} is not a unique attribute.`);
|
|
2444
2444
|
return [o.id, i];
|
|
@@ -2449,13 +2449,13 @@ function cr(t, e, n, r) {
|
|
|
2449
2449
|
return Array.isArray(s) ? [[
|
|
2450
2450
|
"add-triple",
|
|
2451
2451
|
s,
|
|
2452
|
-
(o =
|
|
2452
|
+
(o = j(t, e, "id")) == null ? void 0 : o.id,
|
|
2453
2453
|
s
|
|
2454
2454
|
]].concat(r) : r;
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2456
|
+
function Ci({ attrsStore: t }, [e, n, r]) {
|
|
2457
2457
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2458
|
-
const a = Array.isArray(o) ? o : [o], c =
|
|
2458
|
+
const a = Array.isArray(o) ? o : [o], c = j(t, e, i), u = _e(t, e, i);
|
|
2459
2459
|
return a.map((l) => c ? [
|
|
2460
2460
|
"add-triple",
|
|
2461
2461
|
B(t, e, n),
|
|
@@ -2474,9 +2474,9 @@ function Ei({ attrsStore: t }, [e, n, r]) {
|
|
|
2474
2474
|
});
|
|
2475
2475
|
return cr(t, e, n, s);
|
|
2476
2476
|
}
|
|
2477
|
-
function
|
|
2477
|
+
function Pi({ attrsStore: t }, [e, n, r]) {
|
|
2478
2478
|
const s = Object.entries(r).flatMap(([i, o]) => {
|
|
2479
|
-
const a = Array.isArray(o) ? o : [o], c =
|
|
2479
|
+
const a = Array.isArray(o) ? o : [o], c = j(t, e, i), u = _e(t, e, i);
|
|
2480
2480
|
return a.map((l) => c ? [
|
|
2481
2481
|
"retract-triple",
|
|
2482
2482
|
B(t, e, n),
|
|
@@ -2495,7 +2495,7 @@ function Ci({ attrsStore: t }, [e, n, r]) {
|
|
|
2495
2495
|
});
|
|
2496
2496
|
return cr(t, e, n, s);
|
|
2497
2497
|
}
|
|
2498
|
-
function
|
|
2498
|
+
function Mi(t, e, n, r) {
|
|
2499
2499
|
var s;
|
|
2500
2500
|
if (Array.isArray(r)) {
|
|
2501
2501
|
const [i, o] = r;
|
|
@@ -2519,19 +2519,19 @@ function Pi(t, e, n, r) {
|
|
|
2519
2519
|
return !1;
|
|
2520
2520
|
}
|
|
2521
2521
|
function ur({ stores: t, attrsStore: e }, [n, r, s, i]) {
|
|
2522
|
-
return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null :
|
|
2522
|
+
return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Mi(t, e, n, r) ? { mode: "update" } : null;
|
|
2523
2523
|
}
|
|
2524
|
-
function
|
|
2524
|
+
function ji(t, e) {
|
|
2525
2525
|
const { attrsStore: n } = t, [r, s, i, o] = e, a = Bt(i), c = B(n, r, s);
|
|
2526
2526
|
return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
|
|
2527
|
-
const h =
|
|
2527
|
+
const h = j(n, r, l);
|
|
2528
2528
|
return h["checked-data-type"] === "date" && t.useDateObjects && (f = ot(f)), ["add-triple", c, h.id, f, { mode: "create" }];
|
|
2529
2529
|
});
|
|
2530
2530
|
}
|
|
2531
|
-
function
|
|
2531
|
+
function Di(t, e) {
|
|
2532
2532
|
const { attrsStore: n } = t, [r, s, i, o] = e, a = Bt(i), c = B(n, r, s), u = ur(t, [r, c, i, o]);
|
|
2533
2533
|
return [["id", c]].concat(Object.entries(a)).map(([f, h]) => {
|
|
2534
|
-
const p =
|
|
2534
|
+
const p = j(n, r, f);
|
|
2535
2535
|
return p["checked-data-type"] === "date" && t.useDateObjects && (h = ot(h)), [
|
|
2536
2536
|
"add-triple",
|
|
2537
2537
|
c,
|
|
@@ -2541,12 +2541,12 @@ function ji(t, e) {
|
|
|
2541
2541
|
];
|
|
2542
2542
|
});
|
|
2543
2543
|
}
|
|
2544
|
-
function
|
|
2544
|
+
function $i({ attrsStore: t }, [e, n]) {
|
|
2545
2545
|
return [["delete-entity", B(t, e, n), e]];
|
|
2546
2546
|
}
|
|
2547
|
-
function
|
|
2547
|
+
function Ri(t, e) {
|
|
2548
2548
|
const { attrsStore: n } = t, [r, s, i, o] = e, a = Bt(i), c = B(n, r, s), u = ur(t, [r, c, i, o]), l = Object.entries(a).map(([h, p]) => {
|
|
2549
|
-
const y =
|
|
2549
|
+
const y = j(n, r, h);
|
|
2550
2550
|
return [
|
|
2551
2551
|
"deep-merge-triple",
|
|
2552
2552
|
c,
|
|
@@ -2558,43 +2558,43 @@ function $i(t, e) {
|
|
|
2558
2558
|
return [[
|
|
2559
2559
|
"add-triple",
|
|
2560
2560
|
c,
|
|
2561
|
-
|
|
2561
|
+
j(n, r, "id").id,
|
|
2562
2562
|
c,
|
|
2563
2563
|
...u ? [u] : []
|
|
2564
2564
|
]].concat(l);
|
|
2565
2565
|
}
|
|
2566
|
-
function
|
|
2566
|
+
function xi({ attrsStore: t }, [e, n, r]) {
|
|
2567
2567
|
return [["rule-params", B(t, e, n), e, r]];
|
|
2568
2568
|
}
|
|
2569
|
-
function
|
|
2569
|
+
function Ui(t) {
|
|
2570
2570
|
const [e, n, r, s, i] = t;
|
|
2571
2571
|
if (!s)
|
|
2572
2572
|
return t;
|
|
2573
2573
|
const o = { ...s };
|
|
2574
2574
|
return delete o.id, [e, n, r, o, ...i ? [i] : []];
|
|
2575
2575
|
}
|
|
2576
|
-
function
|
|
2577
|
-
const [n, ...r] =
|
|
2576
|
+
function Li(t, e) {
|
|
2577
|
+
const [n, ...r] = Ui(e);
|
|
2578
2578
|
switch (n) {
|
|
2579
2579
|
case "merge":
|
|
2580
|
-
return
|
|
2580
|
+
return Ri(t, r);
|
|
2581
2581
|
case "create":
|
|
2582
|
-
return Mi(t, r);
|
|
2583
|
-
case "update":
|
|
2584
2582
|
return ji(t, r);
|
|
2583
|
+
case "update":
|
|
2584
|
+
return Di(t, r);
|
|
2585
2585
|
case "link":
|
|
2586
|
-
return Ei(t, r);
|
|
2587
|
-
case "unlink":
|
|
2588
2586
|
return Ci(t, r);
|
|
2587
|
+
case "unlink":
|
|
2588
|
+
return Pi(t, r);
|
|
2589
2589
|
case "delete":
|
|
2590
|
-
return
|
|
2590
|
+
return $i(t, r);
|
|
2591
2591
|
case "ruleParams":
|
|
2592
|
-
return
|
|
2592
|
+
return xi(t, r);
|
|
2593
2593
|
default:
|
|
2594
2594
|
throw new Error(`unsupported action ${n}`);
|
|
2595
2595
|
}
|
|
2596
2596
|
}
|
|
2597
|
-
function
|
|
2597
|
+
function Fi(t) {
|
|
2598
2598
|
switch (t) {
|
|
2599
2599
|
case "string":
|
|
2600
2600
|
case "date":
|
|
@@ -2605,14 +2605,14 @@ function Li(t) {
|
|
|
2605
2605
|
return;
|
|
2606
2606
|
}
|
|
2607
2607
|
}
|
|
2608
|
-
function
|
|
2608
|
+
function Ni(t, e, n) {
|
|
2609
2609
|
var a, c;
|
|
2610
2610
|
const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
|
|
2611
2611
|
if (n === "id")
|
|
2612
2612
|
return null;
|
|
2613
2613
|
if (!r)
|
|
2614
2614
|
throw new Error(`${e}.${n} does not exist in your schema`);
|
|
2615
|
-
const { unique: s, indexed: i } = r == null ? void 0 : r.config, o =
|
|
2615
|
+
const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Fi(r == null ? void 0 : r.valueType);
|
|
2616
2616
|
return {
|
|
2617
2617
|
"index?": i,
|
|
2618
2618
|
"unique?": s,
|
|
@@ -2620,7 +2620,7 @@ function Fi(t, e, n) {
|
|
|
2620
2620
|
};
|
|
2621
2621
|
}
|
|
2622
2622
|
function qe(t, e, n, r) {
|
|
2623
|
-
const s = t ?
|
|
2623
|
+
const s = t ? Ni(t, e, n) : null, i = P(), a = [P(), e, n];
|
|
2624
2624
|
return {
|
|
2625
2625
|
id: i,
|
|
2626
2626
|
"forward-identity": a,
|
|
@@ -2633,11 +2633,11 @@ function qe(t, e, n, r) {
|
|
|
2633
2633
|
...r || {}
|
|
2634
2634
|
};
|
|
2635
2635
|
}
|
|
2636
|
-
function
|
|
2636
|
+
function Ki(t, e, n) {
|
|
2637
2637
|
return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
|
|
2638
2638
|
}
|
|
2639
|
-
function
|
|
2640
|
-
const r =
|
|
2639
|
+
function qi(t, e, n) {
|
|
2640
|
+
const r = Ki(t, e, n);
|
|
2641
2641
|
if (!r)
|
|
2642
2642
|
throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
|
|
2643
2643
|
const { forward: s, reverse: i } = r;
|
|
@@ -2651,7 +2651,7 @@ function Ki(t, e, n) {
|
|
|
2651
2651
|
};
|
|
2652
2652
|
}
|
|
2653
2653
|
function bn(t, e, n, r) {
|
|
2654
|
-
const s = t ?
|
|
2654
|
+
const s = t ? qi(t, e, n) : null, i = P(), o = [P(), e, n], a = [P(), n, e];
|
|
2655
2655
|
return {
|
|
2656
2656
|
id: i,
|
|
2657
2657
|
// @ts-ignore: ts thinks it's any[]
|
|
@@ -2668,7 +2668,7 @@ function bn(t, e, n, r) {
|
|
|
2668
2668
|
...r || {}
|
|
2669
2669
|
};
|
|
2670
2670
|
}
|
|
2671
|
-
const
|
|
2671
|
+
const zi = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Wi = /* @__PURE__ */ new Set(["link", "unlink"]), Vi = /* @__PURE__ */ new Set(["create", "update", "merge"]), Qi = /* @__PURE__ */ new Set([
|
|
2672
2672
|
"link",
|
|
2673
2673
|
"unlink",
|
|
2674
2674
|
"create",
|
|
@@ -2676,13 +2676,13 @@ const qi = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
|
|
|
2676
2676
|
"merge",
|
|
2677
2677
|
"delete",
|
|
2678
2678
|
"ruleParams"
|
|
2679
|
-
]), xt = { "unique?": !0, "index?": !0 },
|
|
2679
|
+
]), xt = { "unique?": !0, "index?": !0 }, Bi = {
|
|
2680
2680
|
...xt,
|
|
2681
2681
|
cardinality: "one"
|
|
2682
2682
|
};
|
|
2683
|
-
function
|
|
2683
|
+
function Gi(t) {
|
|
2684
2684
|
const e = [], [n, r, s, i] = t;
|
|
2685
|
-
if (!
|
|
2685
|
+
if (!Qi.has(n))
|
|
2686
2686
|
return e;
|
|
2687
2687
|
const o = Rt(s);
|
|
2688
2688
|
if (o && e.push({ etype: r, lookupPair: o }), n === "link")
|
|
@@ -2699,16 +2699,16 @@ function Bi(t) {
|
|
|
2699
2699
|
}
|
|
2700
2700
|
return e;
|
|
2701
2701
|
}
|
|
2702
|
-
function
|
|
2702
|
+
function Hi({ attrsStore: t, schema: e }, n) {
|
|
2703
2703
|
var h, p;
|
|
2704
2704
|
const r = /* @__PURE__ */ new Set(), s = [], i = [];
|
|
2705
|
-
function o(y,
|
|
2706
|
-
return
|
|
2705
|
+
function o(y, g) {
|
|
2706
|
+
return j(t, y, g) || s.find((w) => w["forward-identity"][1] === y && w["forward-identity"][2] === g);
|
|
2707
2707
|
}
|
|
2708
|
-
function a(y,
|
|
2709
|
-
return _e(t, y,
|
|
2710
|
-
var _,
|
|
2711
|
-
return ((_ = w["reverse-identity"]) == null ? void 0 : _[1]) === y && ((
|
|
2708
|
+
function a(y, g) {
|
|
2709
|
+
return _e(t, y, g) || s.find((w) => {
|
|
2710
|
+
var _, b;
|
|
2711
|
+
return ((_ = w["reverse-identity"]) == null ? void 0 : _[1]) === y && ((b = w["reverse-identity"]) == null ? void 0 : b[2]) === g;
|
|
2712
2712
|
});
|
|
2713
2713
|
}
|
|
2714
2714
|
function c(y) {
|
|
@@ -2717,67 +2717,67 @@ function Gi({ attrsStore: t, schema: e }, n) {
|
|
|
2717
2717
|
function u(y) {
|
|
2718
2718
|
y && "isUnsynced" in y && y.isUnsynced && !r.has(y.id) && (s.push(y), i.push(["add-attr", y]), r.add(y.id));
|
|
2719
2719
|
}
|
|
2720
|
-
function l(y,
|
|
2721
|
-
return
|
|
2720
|
+
function l(y, g) {
|
|
2721
|
+
return g.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
|
|
2722
2722
|
// before assuming it's a ref lookup.
|
|
2723
|
-
!o(y,
|
|
2723
|
+
!o(y, g);
|
|
2724
2724
|
}
|
|
2725
|
-
function f(y,
|
|
2726
|
-
const w = o(y,
|
|
2727
|
-
u(w), u(_), !w && !_ && c(bn(e, y,
|
|
2725
|
+
function f(y, g) {
|
|
2726
|
+
const w = o(y, g), _ = a(y, g);
|
|
2727
|
+
u(w), u(_), !w && !_ && c(bn(e, y, g, Bi));
|
|
2728
2728
|
}
|
|
2729
2729
|
for (const y of n)
|
|
2730
|
-
for (const { etype:
|
|
2731
|
-
const
|
|
2730
|
+
for (const { etype: g, lookupPair: w, linkLabel: _ } of Gi(y)) {
|
|
2731
|
+
const b = w[0];
|
|
2732
2732
|
if (_) {
|
|
2733
|
-
f(
|
|
2734
|
-
const m = o(
|
|
2733
|
+
f(g, _);
|
|
2734
|
+
const m = o(g, _), A = a(g, _);
|
|
2735
2735
|
u(m), u(A);
|
|
2736
2736
|
const T = ((h = m == null ? void 0 : m["reverse-identity"]) == null ? void 0 : h[1]) || ((p = A == null ? void 0 : A["forward-identity"]) == null ? void 0 : p[1]) || _;
|
|
2737
|
-
if (l(T,
|
|
2738
|
-
f(T, $t(
|
|
2737
|
+
if (l(T, b))
|
|
2738
|
+
f(T, $t(b));
|
|
2739
2739
|
else {
|
|
2740
|
-
const
|
|
2741
|
-
|
|
2740
|
+
const v = o(T, b);
|
|
2741
|
+
v || c(qe(e, T, b, xt)), u(v);
|
|
2742
2742
|
}
|
|
2743
|
-
} else if (l(
|
|
2744
|
-
f(
|
|
2743
|
+
} else if (l(g, b))
|
|
2744
|
+
f(g, $t(b));
|
|
2745
2745
|
else {
|
|
2746
|
-
const m = o(
|
|
2747
|
-
m || c(qe(e,
|
|
2746
|
+
const m = o(g, b);
|
|
2747
|
+
m || c(qe(e, g, b, xt)), u(m);
|
|
2748
2748
|
}
|
|
2749
2749
|
}
|
|
2750
2750
|
for (const y of n) {
|
|
2751
|
-
const [
|
|
2752
|
-
if (
|
|
2751
|
+
const [g, w, _, b] = y;
|
|
2752
|
+
if (zi.has(g)) {
|
|
2753
2753
|
const m = o(w, "id");
|
|
2754
2754
|
u(m), m || c(qe(e, w, "id", { "unique?": !0 }));
|
|
2755
|
-
for (const A of Object.keys(
|
|
2755
|
+
for (const A of Object.keys(b)) {
|
|
2756
2756
|
const T = o(w, A);
|
|
2757
|
-
if (u(T),
|
|
2758
|
-
const
|
|
2759
|
-
!T && !
|
|
2757
|
+
if (u(T), Vi.has(g) && (T || c(qe(e, w, A, A === "id" ? { "unique?": !0 } : null))), Wi.has(g)) {
|
|
2758
|
+
const v = a(w, A);
|
|
2759
|
+
!T && !v && c(bn(e, w, A)), u(v);
|
|
2760
2760
|
}
|
|
2761
2761
|
}
|
|
2762
2762
|
}
|
|
2763
2763
|
}
|
|
2764
2764
|
if (s.length) {
|
|
2765
2765
|
const y = { ...t.attrs };
|
|
2766
|
-
for (const
|
|
2767
|
-
y[
|
|
2766
|
+
for (const g of s)
|
|
2767
|
+
y[g.id] = g;
|
|
2768
2768
|
return [new be(y, t.linkIndex), i];
|
|
2769
2769
|
}
|
|
2770
2770
|
return [t, i];
|
|
2771
2771
|
}
|
|
2772
|
-
function
|
|
2773
|
-
const r = (Array.isArray(e) ? e : [e]).flatMap((c) =>
|
|
2772
|
+
function Ji(t, e) {
|
|
2773
|
+
const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Ai(c)), [s, i] = Hi(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Li(o, c));
|
|
2774
2774
|
return [...i, ...a];
|
|
2775
2775
|
}
|
|
2776
2776
|
function gn(t, e) {
|
|
2777
2777
|
typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
|
|
2778
2778
|
}
|
|
2779
2779
|
const Re = "__meta";
|
|
2780
|
-
class
|
|
2780
|
+
class Yi {
|
|
2781
2781
|
constructor(e, n) {
|
|
2782
2782
|
}
|
|
2783
2783
|
}
|
|
@@ -2953,13 +2953,13 @@ class Ut {
|
|
|
2953
2953
|
for (const [h, p] of Object.entries(r.objects))
|
|
2954
2954
|
!n.has(h) && p.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedOldCount++);
|
|
2955
2955
|
const a = Object.entries(r.objects);
|
|
2956
|
-
a.sort(([h, p], [y,
|
|
2956
|
+
a.sort(([h, p], [y, g]) => p.updatedAt - g.updatedAt);
|
|
2957
2957
|
const c = a.filter(([h]) => !n.has(h));
|
|
2958
2958
|
if (a.length > this._gcOpts.maxEntries)
|
|
2959
2959
|
for (const [h] of c.slice(0, a.length - this._gcOpts.maxEntries))
|
|
2960
2960
|
s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedThresholdCount++;
|
|
2961
2961
|
const u = Object.entries(r.objects);
|
|
2962
|
-
u.sort(([h, p], [y,
|
|
2962
|
+
u.sort(([h, p], [y, g]) => p.updatedAt - g.updatedAt);
|
|
2963
2963
|
const l = u.filter(([h]) => !n.has(h));
|
|
2964
2964
|
let f = u.reduce((h, [p, y]) => h + y.size, 0);
|
|
2965
2965
|
for (; f > 0 && f > this._gcOpts.maxSize && l.length; ) {
|
|
@@ -3021,13 +3021,13 @@ class Ut {
|
|
|
3021
3021
|
};
|
|
3022
3022
|
}
|
|
3023
3023
|
}
|
|
3024
|
-
const
|
|
3025
|
-
function
|
|
3024
|
+
const Zi = 6, Xi = ["kv", "querySubs", "syncSubs"];
|
|
3025
|
+
function eo(t) {
|
|
3026
3026
|
return function(n) {
|
|
3027
3027
|
console.error("Error in IndexedDB event", { source: t, event: n });
|
|
3028
3028
|
};
|
|
3029
3029
|
}
|
|
3030
|
-
async function
|
|
3030
|
+
async function to(t) {
|
|
3031
3031
|
return new Promise((e) => {
|
|
3032
3032
|
const n = indexedDB.open(t);
|
|
3033
3033
|
n.onerror = (r) => {
|
|
@@ -3041,7 +3041,7 @@ async function eo(t) {
|
|
|
3041
3041
|
};
|
|
3042
3042
|
});
|
|
3043
3043
|
}
|
|
3044
|
-
async function
|
|
3044
|
+
async function no(t, e, n) {
|
|
3045
3045
|
const r = (
|
|
3046
3046
|
// Backwards compatibility for older versions where we JSON.stringified before storing
|
|
3047
3047
|
typeof e == "string" ? JSON.parse(e) : e
|
|
@@ -3053,16 +3053,16 @@ async function to(t, e, n) {
|
|
|
3053
3053
|
var l, f, h;
|
|
3054
3054
|
const a = {};
|
|
3055
3055
|
for (const [p, y] of Object.entries(r)) {
|
|
3056
|
-
const
|
|
3057
|
-
if (
|
|
3056
|
+
const g = typeof y == "string" ? JSON.parse(y) : y;
|
|
3057
|
+
if (g.lastAccessed) {
|
|
3058
3058
|
const _ = {
|
|
3059
|
-
createdAt:
|
|
3060
|
-
updatedAt:
|
|
3061
|
-
size: ((h = (f = (l =
|
|
3059
|
+
createdAt: g.lastAccessed,
|
|
3060
|
+
updatedAt: g.lastAccessed,
|
|
3061
|
+
size: ((h = (f = (l = g.result) == null ? void 0 : l.store) == null ? void 0 : f.triples) == null ? void 0 : h.length) ?? 0
|
|
3062
3062
|
};
|
|
3063
3063
|
a[p] = _;
|
|
3064
3064
|
}
|
|
3065
|
-
const w = n.put(
|
|
3065
|
+
const w = n.put(g, p);
|
|
3066
3066
|
s.add(w);
|
|
3067
3067
|
}
|
|
3068
3068
|
const c = { objects: a }, u = n.put(c, Re);
|
|
@@ -3081,8 +3081,8 @@ async function wn(t, e, n) {
|
|
|
3081
3081
|
r.onsuccess = () => s(), r.onerror = (o) => i(o);
|
|
3082
3082
|
});
|
|
3083
3083
|
}
|
|
3084
|
-
async function
|
|
3085
|
-
const n = await
|
|
3084
|
+
async function ro(t, e) {
|
|
3085
|
+
const n = await to(`instant_${t}_5`);
|
|
3086
3086
|
if (!n)
|
|
3087
3087
|
return;
|
|
3088
3088
|
const r = await new Promise((l, f) => {
|
|
@@ -3090,14 +3090,14 @@ async function no(t, e) {
|
|
|
3090
3090
|
y.onerror = (w) => {
|
|
3091
3091
|
f(w);
|
|
3092
3092
|
};
|
|
3093
|
-
const
|
|
3093
|
+
const g = [];
|
|
3094
3094
|
y.onsuccess = () => {
|
|
3095
3095
|
const w = y.result;
|
|
3096
3096
|
if (w) {
|
|
3097
|
-
const _ = w.key,
|
|
3098
|
-
|
|
3097
|
+
const _ = w.key, b = w.value;
|
|
3098
|
+
g.push([_, b]), w.continue();
|
|
3099
3099
|
} else
|
|
3100
|
-
l(
|
|
3100
|
+
l(g);
|
|
3101
3101
|
}, y.onerror = (w) => {
|
|
3102
3102
|
f(w);
|
|
3103
3103
|
};
|
|
@@ -3105,7 +3105,7 @@ async function no(t, e) {
|
|
|
3105
3105
|
for (const [l, f] of r)
|
|
3106
3106
|
switch (l) {
|
|
3107
3107
|
case "querySubs": {
|
|
3108
|
-
const h =
|
|
3108
|
+
const h = no(l, f, o);
|
|
3109
3109
|
a.push(h);
|
|
3110
3110
|
break;
|
|
3111
3111
|
}
|
|
@@ -3127,7 +3127,7 @@ async function no(t, e) {
|
|
|
3127
3127
|
});
|
|
3128
3128
|
}
|
|
3129
3129
|
const _n = /* @__PURE__ */ new Map();
|
|
3130
|
-
class lr extends
|
|
3130
|
+
class lr extends Yi {
|
|
3131
3131
|
constructor(n, r) {
|
|
3132
3132
|
super(n, r);
|
|
3133
3133
|
d(this, "dbName");
|
|
@@ -3135,7 +3135,7 @@ class lr extends Ji {
|
|
|
3135
3135
|
d(this, "_appId");
|
|
3136
3136
|
d(this, "_prefix");
|
|
3137
3137
|
d(this, "_dbPromise");
|
|
3138
|
-
this.dbName = `instant_${n}_${
|
|
3138
|
+
this.dbName = `instant_${n}_${Zi}`, this._storeName = r, this._appId = n, this._dbPromise = this._init();
|
|
3139
3139
|
}
|
|
3140
3140
|
_init() {
|
|
3141
3141
|
return new Promise((n, r) => {
|
|
@@ -3146,8 +3146,8 @@ class lr extends Ji {
|
|
|
3146
3146
|
}, i.onsuccess = (o) => {
|
|
3147
3147
|
const c = o.target.result;
|
|
3148
3148
|
if (s) {
|
|
3149
|
-
const u =
|
|
3150
|
-
|
|
3149
|
+
const u = ro(this._appId, c).catch((l) => {
|
|
3150
|
+
eo("Error upgrading store from version 5 to 6.")(l);
|
|
3151
3151
|
});
|
|
3152
3152
|
_n.set(this.dbName, u), u.then(() => n(c)).catch(() => n(c));
|
|
3153
3153
|
} else {
|
|
@@ -3161,7 +3161,7 @@ class lr extends Ji {
|
|
|
3161
3161
|
}
|
|
3162
3162
|
_upgradeStore(n) {
|
|
3163
3163
|
const s = n.target.result;
|
|
3164
|
-
for (const i of
|
|
3164
|
+
for (const i of Xi)
|
|
3165
3165
|
s.objectStoreNames.contains(i) || s.createObjectStore(i);
|
|
3166
3166
|
}
|
|
3167
3167
|
async getItem(n) {
|
|
@@ -3267,19 +3267,19 @@ class ct extends q {
|
|
|
3267
3267
|
return "InstantAPIError";
|
|
3268
3268
|
}
|
|
3269
3269
|
}
|
|
3270
|
-
async function
|
|
3270
|
+
async function ne(t, e) {
|
|
3271
3271
|
const n = await fetch(t, e), r = await n.json();
|
|
3272
3272
|
return n.status === 200 ? Promise.resolve(r) : Promise.reject(new ct({ status: n.status, body: r }));
|
|
3273
3273
|
}
|
|
3274
|
-
function
|
|
3275
|
-
return
|
|
3274
|
+
function so({ apiURI: t, appId: e, email: n }) {
|
|
3275
|
+
return ne(`${t}/runtime/auth/send_magic_code`, {
|
|
3276
3276
|
method: "POST",
|
|
3277
3277
|
headers: { "content-type": "application/json" },
|
|
3278
3278
|
body: JSON.stringify({ "app-id": e, email: n })
|
|
3279
3279
|
});
|
|
3280
3280
|
}
|
|
3281
|
-
async function
|
|
3282
|
-
return await
|
|
3281
|
+
async function io({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
|
|
3282
|
+
return await ne(`${t}/runtime/auth/verify_magic_code`, {
|
|
3283
3283
|
method: "POST",
|
|
3284
3284
|
headers: { "content-type": "application/json" },
|
|
3285
3285
|
body: JSON.stringify({
|
|
@@ -3290,8 +3290,8 @@ async function so({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
|
|
|
3290
3290
|
})
|
|
3291
3291
|
});
|
|
3292
3292
|
}
|
|
3293
|
-
async function
|
|
3294
|
-
return await
|
|
3293
|
+
async function oo({ apiURI: t, appId: e, refreshToken: n }) {
|
|
3294
|
+
return await ne(`${t}/runtime/auth/verify_refresh_token`, {
|
|
3295
3295
|
method: "POST",
|
|
3296
3296
|
headers: { "content-type": "application/json" },
|
|
3297
3297
|
body: JSON.stringify({
|
|
@@ -3300,8 +3300,8 @@ async function io({ apiURI: t, appId: e, refreshToken: n }) {
|
|
|
3300
3300
|
})
|
|
3301
3301
|
});
|
|
3302
3302
|
}
|
|
3303
|
-
async function
|
|
3304
|
-
return await
|
|
3303
|
+
async function ao({ apiURI: t, appId: e }) {
|
|
3304
|
+
return await ne(`${t}/runtime/auth/sign_in_guest`, {
|
|
3305
3305
|
method: "POST",
|
|
3306
3306
|
headers: { "content-type": "application/json" },
|
|
3307
3307
|
body: JSON.stringify({
|
|
@@ -3310,7 +3310,7 @@ async function oo({ apiURI: t, appId: e }) {
|
|
|
3310
3310
|
});
|
|
3311
3311
|
}
|
|
3312
3312
|
async function mn({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken: s }) {
|
|
3313
|
-
return await
|
|
3313
|
+
return await ne(`${t}/runtime/oauth/token`, {
|
|
3314
3314
|
method: "POST",
|
|
3315
3315
|
headers: { "content-type": "application/json" },
|
|
3316
3316
|
body: JSON.stringify({
|
|
@@ -3321,8 +3321,8 @@ async function mn({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken:
|
|
|
3321
3321
|
})
|
|
3322
3322
|
});
|
|
3323
3323
|
}
|
|
3324
|
-
async function
|
|
3325
|
-
return await
|
|
3324
|
+
async function co({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, refreshToken: i }) {
|
|
3325
|
+
return await ne(`${t}/runtime/oauth/id_token`, {
|
|
3326
3326
|
method: "POST",
|
|
3327
3327
|
headers: { "content-type": "application/json" },
|
|
3328
3328
|
body: JSON.stringify({
|
|
@@ -3334,8 +3334,8 @@ async function ao({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, re
|
|
|
3334
3334
|
})
|
|
3335
3335
|
});
|
|
3336
3336
|
}
|
|
3337
|
-
async function
|
|
3338
|
-
return await
|
|
3337
|
+
async function uo({ apiURI: t, appId: e, refreshToken: n }) {
|
|
3338
|
+
return await ne(`${t}/runtime/signout`, {
|
|
3339
3339
|
method: "POST",
|
|
3340
3340
|
headers: {
|
|
3341
3341
|
"content-type": "application/json"
|
|
@@ -3346,21 +3346,21 @@ async function co({ apiURI: t, appId: e, refreshToken: n }) {
|
|
|
3346
3346
|
})
|
|
3347
3347
|
});
|
|
3348
3348
|
}
|
|
3349
|
-
async function
|
|
3349
|
+
async function lo({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
|
|
3350
3350
|
const a = {
|
|
3351
3351
|
app_id: e,
|
|
3352
3352
|
path: n,
|
|
3353
3353
|
authorization: `Bearer ${s}`,
|
|
3354
3354
|
"content-type": i || r.type
|
|
3355
3355
|
};
|
|
3356
|
-
return o && (a["content-disposition"] = o), await
|
|
3356
|
+
return o && (a["content-disposition"] = o), await ne(`${t}/storage/upload`, {
|
|
3357
3357
|
method: "PUT",
|
|
3358
3358
|
headers: a,
|
|
3359
3359
|
body: r
|
|
3360
3360
|
});
|
|
3361
3361
|
}
|
|
3362
|
-
async function
|
|
3363
|
-
const { data: s } = await
|
|
3362
|
+
async function fo({ apiURI: t, appId: e, path: n, refreshToken: r }) {
|
|
3363
|
+
const { data: s } = await ne(`${t}/storage/files?app_id=${e}&filename=${encodeURIComponent(n)}`, {
|
|
3364
3364
|
method: "DELETE",
|
|
3365
3365
|
headers: {
|
|
3366
3366
|
"content-type": "application/json",
|
|
@@ -3369,8 +3369,8 @@ async function lo({ apiURI: t, appId: e, path: n, refreshToken: r }) {
|
|
|
3369
3369
|
});
|
|
3370
3370
|
return s;
|
|
3371
3371
|
}
|
|
3372
|
-
async function
|
|
3373
|
-
const { data: i } = await
|
|
3372
|
+
async function ho({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata: s = {} }) {
|
|
3373
|
+
const { data: i } = await ne(`${t}/storage/signed-upload-url`, {
|
|
3374
3374
|
method: "POST",
|
|
3375
3375
|
headers: {
|
|
3376
3376
|
"content-type": "application/json",
|
|
@@ -3383,7 +3383,7 @@ async function fo({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata:
|
|
|
3383
3383
|
});
|
|
3384
3384
|
return i;
|
|
3385
3385
|
}
|
|
3386
|
-
async function
|
|
3386
|
+
async function po(t, e) {
|
|
3387
3387
|
return (await fetch(t, {
|
|
3388
3388
|
method: "PUT",
|
|
3389
3389
|
body: e,
|
|
@@ -3392,8 +3392,8 @@ async function ho(t, e) {
|
|
|
3392
3392
|
}
|
|
3393
3393
|
})).ok;
|
|
3394
3394
|
}
|
|
3395
|
-
async function
|
|
3396
|
-
const { data: s } = await
|
|
3395
|
+
async function yo({ apiURI: t, appId: e, path: n, refreshToken: r }) {
|
|
3396
|
+
const { data: s } = await ne(`${t}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(n)}`, {
|
|
3397
3397
|
method: "GET",
|
|
3398
3398
|
headers: {
|
|
3399
3399
|
"content-type": "application/json",
|
|
@@ -3412,7 +3412,7 @@ function Tn(t, e) {
|
|
|
3412
3412
|
n[r] = t[r];
|
|
3413
3413
|
}), n;
|
|
3414
3414
|
}
|
|
3415
|
-
function
|
|
3415
|
+
function bo(t, e, n) {
|
|
3416
3416
|
const r = {
|
|
3417
3417
|
peers: {}
|
|
3418
3418
|
};
|
|
@@ -3429,7 +3429,7 @@ function yo(t, e, n) {
|
|
|
3429
3429
|
}
|
|
3430
3430
|
return r;
|
|
3431
3431
|
}
|
|
3432
|
-
function
|
|
3432
|
+
function go(t, e) {
|
|
3433
3433
|
if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !on(t.user, e.user)) || !zn(t.peers, e.peers))
|
|
3434
3434
|
return !0;
|
|
3435
3435
|
for (const r of Object.keys(t.peers))
|
|
@@ -3480,8 +3480,8 @@ function An(t) {
|
|
|
3480
3480
|
}, e;
|
|
3481
3481
|
}, {});
|
|
3482
3482
|
}
|
|
3483
|
-
const Xt = "v0.22.
|
|
3484
|
-
function
|
|
3483
|
+
const Xt = "v0.22.150";
|
|
3484
|
+
function wo(t, e) {
|
|
3485
3485
|
return {
|
|
3486
3486
|
info: t ? (...n) => console.info(...n, e()) : () => {
|
|
3487
3487
|
},
|
|
@@ -3581,7 +3581,7 @@ const On = [
|
|
|
3581
3581
|
"before",
|
|
3582
3582
|
"fields",
|
|
3583
3583
|
"aggregate"
|
|
3584
|
-
],
|
|
3584
|
+
], _o = (t) => t.valueType || "unknown", yr = (t, e, n = !1) => {
|
|
3585
3585
|
if (n || t == null)
|
|
3586
3586
|
return !0;
|
|
3587
3587
|
switch (e) {
|
|
@@ -3596,7 +3596,7 @@ const On = [
|
|
|
3596
3596
|
default:
|
|
3597
3597
|
return !0;
|
|
3598
3598
|
}
|
|
3599
|
-
},
|
|
3599
|
+
}, mo = (t, e, n, r, s, i, o) => {
|
|
3600
3600
|
const a = i.valueType === "json", c = (u, l, f) => {
|
|
3601
3601
|
if (!yr(f, l, a))
|
|
3602
3602
|
throw new E(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
|
|
@@ -3629,16 +3629,16 @@ const On = [
|
|
|
3629
3629
|
throw new E(`Unknown operator '${t}' for attribute '${r}' in entity '${s}'`, o);
|
|
3630
3630
|
}
|
|
3631
3631
|
}, ve = (t, e, n, r, s) => {
|
|
3632
|
-
const i =
|
|
3632
|
+
const i = _o(n), o = n.valueType === "json";
|
|
3633
3633
|
if (typeof t == "object" && t !== null && !Array.isArray(t)) {
|
|
3634
3634
|
if (o)
|
|
3635
3635
|
return;
|
|
3636
3636
|
const c = t;
|
|
3637
3637
|
for (const [u, l] of Object.entries(c))
|
|
3638
|
-
|
|
3638
|
+
mo(u, l, i, e, r, n, `${s}.${u}`);
|
|
3639
3639
|
} else if (!yr(t, i, o))
|
|
3640
3640
|
throw new E(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`, s);
|
|
3641
|
-
},
|
|
3641
|
+
}, To = (t, e, n, r, s) => {
|
|
3642
3642
|
const i = t.split(".");
|
|
3643
3643
|
if (i.length < 2)
|
|
3644
3644
|
throw new E(`Invalid dot notation path '${t}'. Must contain at least one dot.`, s);
|
|
@@ -3688,7 +3688,7 @@ const On = [
|
|
|
3688
3688
|
continue;
|
|
3689
3689
|
}
|
|
3690
3690
|
if (s.includes(".")) {
|
|
3691
|
-
|
|
3691
|
+
To(s, i, e, n, `${r}.${s}`);
|
|
3692
3692
|
continue;
|
|
3693
3693
|
}
|
|
3694
3694
|
const o = n.entities[e];
|
|
@@ -3708,7 +3708,7 @@ const On = [
|
|
|
3708
3708
|
ve(i, s, u, e, `${r}.${s}`);
|
|
3709
3709
|
}
|
|
3710
3710
|
}
|
|
3711
|
-
},
|
|
3711
|
+
}, So = (t, e, n, r, s = 0) => {
|
|
3712
3712
|
for (const o of Object.keys(t))
|
|
3713
3713
|
if (!On.includes(o))
|
|
3714
3714
|
throw new E(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${On.join(", ")}. Found: ${o}`, r);
|
|
@@ -3747,7 +3747,7 @@ const On = [
|
|
|
3747
3747
|
const a = t[o];
|
|
3748
3748
|
if (typeof a != "object" || a === null)
|
|
3749
3749
|
throw new E(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
|
|
3750
|
-
|
|
3750
|
+
So(a, e, n, `${r}.$`, s);
|
|
3751
3751
|
}
|
|
3752
3752
|
}, kn = (t, e) => {
|
|
3753
3753
|
if (typeof t != "object" || t === null)
|
|
@@ -3769,55 +3769,55 @@ const On = [
|
|
|
3769
3769
|
}
|
|
3770
3770
|
}
|
|
3771
3771
|
}, In = (t) => typeof t != "string" ? !1 : et(t) ? !0 : Ae(t);
|
|
3772
|
-
class
|
|
3772
|
+
class Z extends Error {
|
|
3773
3773
|
constructor(e) {
|
|
3774
3774
|
super(e), this.name = "TransactionValidationError";
|
|
3775
3775
|
}
|
|
3776
3776
|
}
|
|
3777
|
-
const wr = (t) => t.length > 0 ? t.join(", ") : "none",
|
|
3777
|
+
const wr = (t) => t.length > 0 ? t.join(", ") : "none", vo = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${wr(e)}`), gt = {
|
|
3778
3778
|
string: (t) => typeof t == "string",
|
|
3779
3779
|
number: (t) => typeof t == "number" && !isNaN(t),
|
|
3780
3780
|
boolean: (t) => typeof t == "boolean",
|
|
3781
3781
|
date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
|
|
3782
3782
|
json: () => !0
|
|
3783
|
-
},
|
|
3783
|
+
}, Ao = (t, e) => {
|
|
3784
3784
|
var n;
|
|
3785
3785
|
return t == null ? !0 : ((n = gt[e.valueType]) == null ? void 0 : n.call(gt, t)) ?? !1;
|
|
3786
3786
|
}, _r = (t, e) => {
|
|
3787
3787
|
const n = e.entities[t];
|
|
3788
3788
|
if (!n)
|
|
3789
|
-
throw
|
|
3789
|
+
throw vo(t, Object.keys(e.entities));
|
|
3790
3790
|
return n;
|
|
3791
3791
|
}, wt = (t, e, n) => {
|
|
3792
3792
|
const r = _r(t, n);
|
|
3793
3793
|
if (typeof e != "object" || e === null)
|
|
3794
|
-
throw new
|
|
3794
|
+
throw new Z(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
|
|
3795
3795
|
for (const [s, i] of Object.entries(e)) {
|
|
3796
3796
|
if (s === "id")
|
|
3797
3797
|
continue;
|
|
3798
3798
|
const o = r.attrs[s];
|
|
3799
|
-
if (o && !
|
|
3800
|
-
throw new
|
|
3799
|
+
if (o && !Ao(i, o))
|
|
3800
|
+
throw new Z(`Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`);
|
|
3801
3801
|
}
|
|
3802
3802
|
}, En = (t, e, n) => {
|
|
3803
3803
|
const r = _r(t, n);
|
|
3804
3804
|
if (typeof e != "object" || e === null)
|
|
3805
|
-
throw new
|
|
3805
|
+
throw new Z(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
|
|
3806
3806
|
for (const [s, i] of Object.entries(e)) {
|
|
3807
3807
|
if (!r.links[s]) {
|
|
3808
3808
|
const a = Object.keys(r.links);
|
|
3809
|
-
throw new
|
|
3809
|
+
throw new Z(`Link '${s}' does not exist on entity '${t}'. Available links: ${wr(a)}`);
|
|
3810
3810
|
}
|
|
3811
3811
|
if (i != null) {
|
|
3812
3812
|
if (Array.isArray(i)) {
|
|
3813
3813
|
for (const a of i)
|
|
3814
3814
|
if (!In(a))
|
|
3815
|
-
throw new
|
|
3815
|
+
throw new Z(`Invalid entity ID in link '${s}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
|
|
3816
3816
|
} else if (!In(i))
|
|
3817
|
-
throw new
|
|
3817
|
+
throw new Z(`Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`);
|
|
3818
3818
|
}
|
|
3819
3819
|
}
|
|
3820
|
-
},
|
|
3820
|
+
}, Oo = {
|
|
3821
3821
|
create: wt,
|
|
3822
3822
|
update: wt,
|
|
3823
3823
|
merge: wt,
|
|
@@ -3825,27 +3825,27 @@ const wr = (t) => t.length > 0 ? t.join(", ") : "none", So = (t, e) => new J(`En
|
|
|
3825
3825
|
unlink: En,
|
|
3826
3826
|
delete: () => {
|
|
3827
3827
|
}
|
|
3828
|
-
},
|
|
3828
|
+
}, ko = (t, e) => {
|
|
3829
3829
|
if (!e)
|
|
3830
3830
|
return;
|
|
3831
3831
|
const [n, r, s, i] = t;
|
|
3832
3832
|
if (!Array.isArray(s) && !Ae(s))
|
|
3833
|
-
throw new
|
|
3833
|
+
throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
|
|
3834
3834
|
if (typeof r != "string")
|
|
3835
|
-
throw new
|
|
3836
|
-
const o =
|
|
3835
|
+
throw new Z(`Entity name must be a string, but received: ${typeof r}`);
|
|
3836
|
+
const o = Oo[n];
|
|
3837
3837
|
o && i !== void 0 && o(r, i, e);
|
|
3838
|
-
},
|
|
3838
|
+
}, Io = (t, e) => {
|
|
3839
3839
|
const n = Array.isArray(t) ? t : [t];
|
|
3840
3840
|
for (const r of n) {
|
|
3841
3841
|
if (!r || typeof r != "object")
|
|
3842
|
-
throw new
|
|
3842
|
+
throw new Z(`Transaction chunk must be an object, but received: ${typeof r}`);
|
|
3843
3843
|
if (!Array.isArray(r.__ops))
|
|
3844
|
-
throw new
|
|
3844
|
+
throw new Z(`Transaction chunk must have __ops array, but received: ${typeof r.__ops}`);
|
|
3845
3845
|
for (const s of r.__ops) {
|
|
3846
3846
|
if (!Array.isArray(s))
|
|
3847
|
-
throw new
|
|
3848
|
-
|
|
3847
|
+
throw new Z(`Transaction operation must be an array, but received: ${typeof s}`);
|
|
3848
|
+
ko(s, e);
|
|
3849
3849
|
}
|
|
3850
3850
|
}
|
|
3851
3851
|
};
|
|
@@ -3885,7 +3885,7 @@ class Cn {
|
|
|
3885
3885
|
return this.conn.send(JSON.stringify(e));
|
|
3886
3886
|
}
|
|
3887
3887
|
}
|
|
3888
|
-
class
|
|
3888
|
+
class Eo {
|
|
3889
3889
|
constructor(e, n, r) {
|
|
3890
3890
|
d(this, "type", "sse");
|
|
3891
3891
|
d(this, "initParams", null);
|
|
@@ -3982,7 +3982,7 @@ class Io {
|
|
|
3982
3982
|
this.handleClose();
|
|
3983
3983
|
}
|
|
3984
3984
|
}
|
|
3985
|
-
function
|
|
3985
|
+
function Co(t, e) {
|
|
3986
3986
|
const n = t.values;
|
|
3987
3987
|
if (n) {
|
|
3988
3988
|
const r = Hn(n.attrsStore, null);
|
|
@@ -3994,7 +3994,7 @@ function Eo(t, e) {
|
|
|
3994
3994
|
}
|
|
3995
3995
|
return t;
|
|
3996
3996
|
}
|
|
3997
|
-
function
|
|
3997
|
+
function Po(t, e) {
|
|
3998
3998
|
var n;
|
|
3999
3999
|
if (e.values) {
|
|
4000
4000
|
const r = [];
|
|
@@ -4009,7 +4009,7 @@ function Co(t, e) {
|
|
|
4009
4009
|
} else
|
|
4010
4010
|
return e;
|
|
4011
4011
|
}
|
|
4012
|
-
function
|
|
4012
|
+
function Mo(t, e, n) {
|
|
4013
4013
|
var i, o;
|
|
4014
4014
|
const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = n == null ? void 0 : n.state) == null ? void 0 : o.txId;
|
|
4015
4015
|
return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
|
|
@@ -4019,7 +4019,7 @@ function _t(t, e, n) {
|
|
|
4019
4019
|
}
|
|
4020
4020
|
function Pn(t, e, n, r) {
|
|
4021
4021
|
var o;
|
|
4022
|
-
const s = (o =
|
|
4022
|
+
const s = (o = j(n, t.table, "id")) == null ? void 0 : o.id;
|
|
4023
4023
|
if (!s)
|
|
4024
4024
|
return -1;
|
|
4025
4025
|
const i = ke(e.eav, [r, s, r]);
|
|
@@ -4036,7 +4036,7 @@ function Mn(t, e, n) {
|
|
|
4036
4036
|
break;
|
|
4037
4037
|
}
|
|
4038
4038
|
}
|
|
4039
|
-
function
|
|
4039
|
+
function jo(t, e, n) {
|
|
4040
4040
|
var s, i;
|
|
4041
4041
|
const r = {};
|
|
4042
4042
|
for (const { action: o, triple: a } of n) {
|
|
@@ -4064,14 +4064,14 @@ function Mo(t, e, n) {
|
|
|
4064
4064
|
function ze(t, e) {
|
|
4065
4065
|
return { [t.table]: e.map((n) => n.entity) };
|
|
4066
4066
|
}
|
|
4067
|
-
function
|
|
4067
|
+
function Do(t, e) {
|
|
4068
4068
|
var r;
|
|
4069
4069
|
if (t.orderFieldType)
|
|
4070
4070
|
return t.orderFieldType;
|
|
4071
|
-
const n = t.orderField === "serverCreatedAt" ? "number" : (r =
|
|
4071
|
+
const n = t.orderField === "serverCreatedAt" ? "number" : (r = j(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
|
|
4072
4072
|
return t.orderFieldType = n, n;
|
|
4073
4073
|
}
|
|
4074
|
-
function
|
|
4074
|
+
function $o(t, e, n) {
|
|
4075
4075
|
const r = e;
|
|
4076
4076
|
if (t.orderField === "serverCreatedAt") {
|
|
4077
4077
|
n.sort(t.orderDirection === "asc" ? function(o, a) {
|
|
@@ -4092,7 +4092,7 @@ var pe;
|
|
|
4092
4092
|
(function(t) {
|
|
4093
4093
|
t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
|
|
4094
4094
|
})(pe || (pe = {}));
|
|
4095
|
-
class
|
|
4095
|
+
class Ro {
|
|
4096
4096
|
constructor(e, n, r, s, i, o) {
|
|
4097
4097
|
d(this, "trySend");
|
|
4098
4098
|
d(this, "subs");
|
|
@@ -4105,9 +4105,9 @@ class $o {
|
|
|
4105
4105
|
d(this, "getAttrs");
|
|
4106
4106
|
this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new Ut({
|
|
4107
4107
|
persister: n,
|
|
4108
|
-
merge:
|
|
4109
|
-
serialize:
|
|
4110
|
-
parse: (a, c) =>
|
|
4108
|
+
merge: Mo,
|
|
4109
|
+
serialize: Po,
|
|
4110
|
+
parse: (a, c) => Co(c, this.config.useDateObjects),
|
|
4111
4111
|
objectSize: (a) => {
|
|
4112
4112
|
var c;
|
|
4113
4113
|
return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
|
|
@@ -4300,43 +4300,43 @@ class $o {
|
|
|
4300
4300
|
s.values = l;
|
|
4301
4301
|
const h = [];
|
|
4302
4302
|
e: for (const [w, _] of Object.entries(u))
|
|
4303
|
-
for (let
|
|
4304
|
-
const m = f[
|
|
4305
|
-
if (
|
|
4303
|
+
for (let b = 0; b < f.length; b++) {
|
|
4304
|
+
const m = f[b];
|
|
4305
|
+
if (ds(m.store, w)) {
|
|
4306
4306
|
Mn(m.store, l.attrsStore, _);
|
|
4307
|
-
const A = _t(s, m.store, l.attrsStore), T =
|
|
4307
|
+
const A = _t(s, m.store, l.attrsStore), T = jo(m.store, l.attrsStore, _)[w];
|
|
4308
4308
|
A ? (h.push({
|
|
4309
4309
|
oldEntity: m.entity,
|
|
4310
4310
|
newEntity: A,
|
|
4311
4311
|
changedFields: T || {}
|
|
4312
|
-
}), m.entity = A) : c.push(
|
|
4312
|
+
}), m.entity = A) : c.push(b), delete u[w];
|
|
4313
4313
|
continue e;
|
|
4314
4314
|
}
|
|
4315
4315
|
}
|
|
4316
4316
|
const p = [];
|
|
4317
4317
|
for (const [w, _] of Object.entries(u)) {
|
|
4318
|
-
const
|
|
4319
|
-
Mn(
|
|
4320
|
-
const m = _t(s,
|
|
4318
|
+
const b = this.createStore([]);
|
|
4319
|
+
Mn(b, l.attrsStore, _);
|
|
4320
|
+
const m = _t(s, b, l.attrsStore);
|
|
4321
4321
|
if (!m) {
|
|
4322
4322
|
this.log.error("No entity found after applying change", {
|
|
4323
4323
|
sub: s,
|
|
4324
4324
|
changes: _,
|
|
4325
|
-
store:
|
|
4325
|
+
store: b
|
|
4326
4326
|
});
|
|
4327
4327
|
continue;
|
|
4328
4328
|
}
|
|
4329
4329
|
f.push({
|
|
4330
|
-
store:
|
|
4330
|
+
store: b,
|
|
4331
4331
|
entity: m,
|
|
4332
|
-
serverCreatedAt: Pn(s,
|
|
4332
|
+
serverCreatedAt: Pn(s, b, l.attrsStore, m.id)
|
|
4333
4333
|
}), p.push(m);
|
|
4334
4334
|
}
|
|
4335
4335
|
const y = [];
|
|
4336
4336
|
for (const w of c.sort().reverse())
|
|
4337
4337
|
y.push(f[w].entity), f.splice(w, 1);
|
|
4338
|
-
const
|
|
4339
|
-
|
|
4338
|
+
const g = Do(s, this.getAttrs);
|
|
4339
|
+
$o(s, g, f), this.notifyCbs(r, {
|
|
4340
4340
|
type: pe.SyncTransaction,
|
|
4341
4341
|
data: ze(s, (o = s.values) == null ? void 0 : o.entities),
|
|
4342
4342
|
added: p,
|
|
@@ -4377,206 +4377,206 @@ class $o {
|
|
|
4377
4377
|
r && this.initSubscription(r.query, r.hash);
|
|
4378
4378
|
}
|
|
4379
4379
|
}
|
|
4380
|
-
function
|
|
4380
|
+
function xo({ WStream: t, opts: e, startStream: n, appendStream: r, registerStream: s }) {
|
|
4381
4381
|
const i = e.clientId;
|
|
4382
|
-
let o = null, a = null;
|
|
4383
|
-
const
|
|
4384
|
-
let
|
|
4385
|
-
const
|
|
4386
|
-
let
|
|
4387
|
-
const
|
|
4388
|
-
function
|
|
4389
|
-
|
|
4390
|
-
for (const
|
|
4391
|
-
|
|
4392
|
-
}
|
|
4393
|
-
function
|
|
4394
|
-
return
|
|
4395
|
-
const k =
|
|
4396
|
-
k !== -1 &&
|
|
4382
|
+
let o = null, a = null, c = null;
|
|
4383
|
+
const u = P();
|
|
4384
|
+
let l = !1, f = !1;
|
|
4385
|
+
const h = [], p = [], y = [];
|
|
4386
|
+
let g = !1, w = 0, _ = 0;
|
|
4387
|
+
const b = [], m = new TextEncoder();
|
|
4388
|
+
function A() {
|
|
4389
|
+
f = !0;
|
|
4390
|
+
for (const S of h)
|
|
4391
|
+
S(a ?? void 0);
|
|
4392
|
+
}
|
|
4393
|
+
function T(S) {
|
|
4394
|
+
return h.push(S), f && S(a ?? void 0), () => {
|
|
4395
|
+
const k = h.indexOf(S);
|
|
4396
|
+
k !== -1 && h.splice(k, 1);
|
|
4397
4397
|
};
|
|
4398
4398
|
}
|
|
4399
|
-
function
|
|
4400
|
-
return
|
|
4401
|
-
const k =
|
|
4402
|
-
k !== -1 &&
|
|
4399
|
+
function v(S) {
|
|
4400
|
+
return y.push(S), () => {
|
|
4401
|
+
const k = y.indexOf(S);
|
|
4402
|
+
k !== -1 && y.splice(k, 1);
|
|
4403
4403
|
};
|
|
4404
4404
|
}
|
|
4405
|
-
e.waitUntil && e.waitUntil(new Promise((
|
|
4406
|
-
|
|
4405
|
+
e.waitUntil && e.waitUntil(new Promise((S) => {
|
|
4406
|
+
y.push(S);
|
|
4407
4407
|
}));
|
|
4408
|
-
function
|
|
4409
|
-
for (const
|
|
4408
|
+
function I() {
|
|
4409
|
+
for (const S of y)
|
|
4410
4410
|
try {
|
|
4411
|
-
|
|
4411
|
+
S();
|
|
4412
4412
|
} catch {
|
|
4413
4413
|
}
|
|
4414
4414
|
}
|
|
4415
|
-
function
|
|
4416
|
-
return
|
|
4417
|
-
const k =
|
|
4418
|
-
k !== -1 &&
|
|
4415
|
+
function C(S) {
|
|
4416
|
+
return p.push(S), o && S(o), () => {
|
|
4417
|
+
const k = p.indexOf(S);
|
|
4418
|
+
k !== -1 && p.splice(k, 1);
|
|
4419
4419
|
};
|
|
4420
4420
|
}
|
|
4421
|
-
function
|
|
4422
|
-
o =
|
|
4423
|
-
for (const k of
|
|
4421
|
+
function D(S) {
|
|
4422
|
+
o = S;
|
|
4423
|
+
for (const k of p)
|
|
4424
4424
|
k(o);
|
|
4425
4425
|
}
|
|
4426
|
-
function
|
|
4427
|
-
|
|
4426
|
+
function ie() {
|
|
4427
|
+
g = !0;
|
|
4428
4428
|
}
|
|
4429
|
-
function
|
|
4430
|
-
let k =
|
|
4431
|
-
for (const { byteLen:
|
|
4432
|
-
const oe = k +
|
|
4433
|
-
if (oe >
|
|
4429
|
+
function Ie(S) {
|
|
4430
|
+
let k = w, N = 0, W = 0;
|
|
4431
|
+
for (const { byteLen: X } of b) {
|
|
4432
|
+
const oe = k + X;
|
|
4433
|
+
if (oe > S)
|
|
4434
4434
|
break;
|
|
4435
|
-
k = oe, N++, W +=
|
|
4435
|
+
k = oe, N++, W += X;
|
|
4436
4436
|
}
|
|
4437
|
-
N > 0 && (
|
|
4437
|
+
N > 0 && (w += W, _ -= W, b.splice(0, N));
|
|
4438
4438
|
}
|
|
4439
|
-
function
|
|
4440
|
-
|
|
4439
|
+
function G(S, k) {
|
|
4440
|
+
a = k, A(), S.error(k), I();
|
|
4441
4441
|
}
|
|
4442
|
-
async function
|
|
4443
|
-
const
|
|
4442
|
+
async function Y() {
|
|
4443
|
+
const S = await n({
|
|
4444
4444
|
clientId: i,
|
|
4445
|
-
reconnectToken:
|
|
4445
|
+
reconnectToken: u,
|
|
4446
4446
|
ruleParams: e.ruleParams
|
|
4447
4447
|
});
|
|
4448
|
-
switch (
|
|
4448
|
+
switch (S.type) {
|
|
4449
4449
|
case "ok": {
|
|
4450
|
-
const { streamId: k, offset: N } =
|
|
4451
|
-
o = k,
|
|
4450
|
+
const { streamId: k, offset: N } = S;
|
|
4451
|
+
o = k, Ie(N), b.length && r({
|
|
4452
4452
|
streamId: k,
|
|
4453
|
-
chunks:
|
|
4454
|
-
offset:
|
|
4455
|
-
}),
|
|
4453
|
+
chunks: b.map((W) => W.chunk),
|
|
4454
|
+
offset: w
|
|
4455
|
+
}), g = !1;
|
|
4456
4456
|
break;
|
|
4457
4457
|
}
|
|
4458
4458
|
case "disconnect": {
|
|
4459
|
-
|
|
4459
|
+
ie();
|
|
4460
4460
|
break;
|
|
4461
4461
|
}
|
|
4462
4462
|
case "error": {
|
|
4463
|
-
|
|
4463
|
+
c && G(c, S.error);
|
|
4464
4464
|
break;
|
|
4465
4465
|
}
|
|
4466
4466
|
}
|
|
4467
4467
|
}
|
|
4468
|
-
function
|
|
4469
|
-
|
|
4468
|
+
function U() {
|
|
4469
|
+
ie(), Y();
|
|
4470
4470
|
}
|
|
4471
|
-
function
|
|
4472
|
-
|
|
4471
|
+
function de({ offset: S, done: k }) {
|
|
4472
|
+
Ie(S), k && (l = !0, I());
|
|
4473
4473
|
}
|
|
4474
|
-
function
|
|
4475
|
-
return
|
|
4474
|
+
function Fe(S) {
|
|
4475
|
+
return l ? (G(S, new q("Stream has been closed.")), null) : o || (G(S, new q("Stream has not been initialized.")), null);
|
|
4476
4476
|
}
|
|
4477
|
-
async function
|
|
4478
|
-
|
|
4477
|
+
async function Ne(S) {
|
|
4478
|
+
c = S;
|
|
4479
4479
|
let k = !0, N = 0;
|
|
4480
4480
|
for (; k; ) {
|
|
4481
4481
|
let W = Date.now() + Math.min(15e3, 500 * (N - 1));
|
|
4482
4482
|
k = !1;
|
|
4483
|
-
const
|
|
4483
|
+
const X = await n({
|
|
4484
4484
|
clientId: e.clientId,
|
|
4485
|
-
reconnectToken:
|
|
4485
|
+
reconnectToken: u,
|
|
4486
4486
|
ruleParams: e.ruleParams
|
|
4487
4487
|
});
|
|
4488
|
-
switch (
|
|
4488
|
+
switch (X.type) {
|
|
4489
4489
|
case "ok": {
|
|
4490
|
-
const { streamId: oe, offset: pt } =
|
|
4490
|
+
const { streamId: oe, offset: pt } = X;
|
|
4491
4491
|
if (pt !== 0) {
|
|
4492
|
-
const
|
|
4493
|
-
|
|
4492
|
+
const he = new q("Write stream is corrupted");
|
|
4493
|
+
G(S, he);
|
|
4494
4494
|
return;
|
|
4495
4495
|
}
|
|
4496
|
-
|
|
4497
|
-
onDisconnect:
|
|
4498
|
-
onFlush:
|
|
4499
|
-
onConnectionReconnect:
|
|
4500
|
-
onAppendFailed:
|
|
4501
|
-
}),
|
|
4496
|
+
D(oe), s(oe, {
|
|
4497
|
+
onDisconnect: ie,
|
|
4498
|
+
onFlush: de,
|
|
4499
|
+
onConnectionReconnect: Y,
|
|
4500
|
+
onAppendFailed: U
|
|
4501
|
+
}), g = !1;
|
|
4502
4502
|
return;
|
|
4503
4503
|
}
|
|
4504
4504
|
case "disconnect": {
|
|
4505
|
-
k = !0,
|
|
4505
|
+
k = !0, ie(), N++, await new Promise((oe) => {
|
|
4506
4506
|
setTimeout(oe, Math.max(0, W - Date.now()));
|
|
4507
4507
|
});
|
|
4508
4508
|
break;
|
|
4509
4509
|
}
|
|
4510
4510
|
case "error": {
|
|
4511
|
-
|
|
4511
|
+
G(S, X.error);
|
|
4512
4512
|
return;
|
|
4513
4513
|
}
|
|
4514
4514
|
}
|
|
4515
4515
|
}
|
|
4516
4516
|
}
|
|
4517
|
-
class
|
|
4517
|
+
class Pr extends t {
|
|
4518
4518
|
constructor(k, N) {
|
|
4519
4519
|
super(k, N);
|
|
4520
4520
|
}
|
|
4521
4521
|
async streamId() {
|
|
4522
4522
|
return o || new Promise((k, N) => {
|
|
4523
|
-
const W = [],
|
|
4524
|
-
for (const
|
|
4525
|
-
|
|
4526
|
-
}, oe = (
|
|
4527
|
-
k(
|
|
4528
|
-
}, pt = () => {
|
|
4529
|
-
N(new q("Stream is closed.")),
|
|
4523
|
+
const W = [], X = () => {
|
|
4524
|
+
for (const he of W)
|
|
4525
|
+
he();
|
|
4526
|
+
}, oe = (he) => {
|
|
4527
|
+
k(he), X();
|
|
4528
|
+
}, pt = (he) => {
|
|
4529
|
+
N(he || new q("Stream is closed.")), X();
|
|
4530
4530
|
};
|
|
4531
|
-
W.push(
|
|
4531
|
+
W.push(C(oe)), W.push(T(pt));
|
|
4532
4532
|
});
|
|
4533
4533
|
}
|
|
4534
4534
|
}
|
|
4535
4535
|
return {
|
|
4536
|
-
stream: new
|
|
4536
|
+
stream: new Pr({
|
|
4537
4537
|
// TODO(dww): accept a storage so that write streams can survive across
|
|
4538
4538
|
// browser restarts
|
|
4539
|
-
async start(
|
|
4539
|
+
async start(S) {
|
|
4540
4540
|
try {
|
|
4541
|
-
await
|
|
4541
|
+
await Ne(S);
|
|
4542
4542
|
} catch (k) {
|
|
4543
|
-
|
|
4543
|
+
G(S, k);
|
|
4544
4544
|
}
|
|
4545
4545
|
},
|
|
4546
|
-
write(
|
|
4547
|
-
const N =
|
|
4546
|
+
write(S, k) {
|
|
4547
|
+
const N = Fe(k);
|
|
4548
4548
|
if (N) {
|
|
4549
|
-
const W =
|
|
4550
|
-
|
|
4551
|
-
const
|
|
4552
|
-
|
|
4549
|
+
const W = m.encode(S).length;
|
|
4550
|
+
b.push({ chunk: S, byteLen: W });
|
|
4551
|
+
const X = w + _;
|
|
4552
|
+
_ += W, g || r({ streamId: N, chunks: [S], offset: X });
|
|
4553
4553
|
}
|
|
4554
4554
|
},
|
|
4555
4555
|
close() {
|
|
4556
4556
|
o ? r({
|
|
4557
4557
|
streamId: o,
|
|
4558
4558
|
chunks: [],
|
|
4559
|
-
offset:
|
|
4559
|
+
offset: w + _,
|
|
4560
4560
|
isDone: !0
|
|
4561
|
-
}) :
|
|
4561
|
+
}) : I(), A();
|
|
4562
4562
|
},
|
|
4563
|
-
abort(
|
|
4563
|
+
abort(S) {
|
|
4564
4564
|
o ? r({
|
|
4565
4565
|
streamId: o,
|
|
4566
4566
|
chunks: [],
|
|
4567
|
-
offset:
|
|
4567
|
+
offset: w + _,
|
|
4568
4568
|
isDone: !0,
|
|
4569
|
-
abortReason:
|
|
4570
|
-
}) :
|
|
4569
|
+
abortReason: S
|
|
4570
|
+
}) : I(), A();
|
|
4571
4571
|
}
|
|
4572
4572
|
}),
|
|
4573
|
-
addCompleteCb:
|
|
4573
|
+
addCompleteCb: v,
|
|
4574
4574
|
closed() {
|
|
4575
|
-
return
|
|
4575
|
+
return f;
|
|
4576
4576
|
}
|
|
4577
4577
|
};
|
|
4578
4578
|
}
|
|
4579
|
-
class
|
|
4579
|
+
class Uo {
|
|
4580
4580
|
constructor() {
|
|
4581
4581
|
d(this, "items", []);
|
|
4582
4582
|
d(this, "resolvers", []);
|
|
@@ -4610,29 +4610,29 @@ class xo {
|
|
|
4610
4610
|
}
|
|
4611
4611
|
}
|
|
4612
4612
|
}
|
|
4613
|
-
function
|
|
4613
|
+
function Lo({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
4614
4614
|
let s = e.byteOffset || 0, i = !1;
|
|
4615
4615
|
const o = new TextDecoder("utf-8"), a = new TextEncoder();
|
|
4616
4616
|
let c, u = !1;
|
|
4617
4617
|
const l = [];
|
|
4618
4618
|
function f() {
|
|
4619
4619
|
u = !0;
|
|
4620
|
-
for (const
|
|
4621
|
-
|
|
4620
|
+
for (const b of l)
|
|
4621
|
+
b();
|
|
4622
4622
|
}
|
|
4623
|
-
function h(
|
|
4624
|
-
return l.push(
|
|
4625
|
-
const m = l.indexOf(
|
|
4623
|
+
function h(b) {
|
|
4624
|
+
return l.push(b), () => {
|
|
4625
|
+
const m = l.indexOf(b);
|
|
4626
4626
|
m !== -1 && l.splice(m, 1);
|
|
4627
4627
|
};
|
|
4628
4628
|
}
|
|
4629
|
-
function p(
|
|
4630
|
-
|
|
4629
|
+
function p(b, m) {
|
|
4630
|
+
b.error(m), f();
|
|
4631
4631
|
}
|
|
4632
4632
|
let y = 0;
|
|
4633
|
-
async function b
|
|
4633
|
+
async function g(b, m) {
|
|
4634
4634
|
c = P();
|
|
4635
|
-
const A = { ...
|
|
4635
|
+
const A = { ...b || {}, eventId: c };
|
|
4636
4636
|
for await (const T of n(A)) {
|
|
4637
4637
|
if (i)
|
|
4638
4638
|
return;
|
|
@@ -4646,42 +4646,42 @@ function Uo({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
|
4646
4646
|
p(m, new q("Stream is corrupted.")), i = !0;
|
|
4647
4647
|
return;
|
|
4648
4648
|
}
|
|
4649
|
-
let
|
|
4649
|
+
let v = s - T.offset;
|
|
4650
4650
|
if (T.files && T.files.length) {
|
|
4651
4651
|
const I = new AbortController();
|
|
4652
4652
|
let C = fetch(T.files[0].url, {
|
|
4653
4653
|
signal: I.signal
|
|
4654
4654
|
});
|
|
4655
|
-
for (let
|
|
4656
|
-
const
|
|
4657
|
-
if (
|
|
4655
|
+
for (let D = 0; D < T.files.length; D++) {
|
|
4656
|
+
const ie = T.files[D + 1], G = await C;
|
|
4657
|
+
if (ie && (C = fetch(ie.url, { signal: I.signal })), !G.ok) {
|
|
4658
4658
|
if (y++, y > 10) {
|
|
4659
4659
|
p(m, new q("Unable to process stream."));
|
|
4660
4660
|
return;
|
|
4661
4661
|
}
|
|
4662
4662
|
return { retry: !0 };
|
|
4663
4663
|
}
|
|
4664
|
-
if (
|
|
4665
|
-
for await (const Y of
|
|
4664
|
+
if (G.body)
|
|
4665
|
+
for await (const Y of G.body) {
|
|
4666
4666
|
if (i) {
|
|
4667
4667
|
I.abort();
|
|
4668
4668
|
return;
|
|
4669
4669
|
}
|
|
4670
4670
|
let U = Y;
|
|
4671
|
-
if (
|
|
4671
|
+
if (v > 0 && (U = Y.subarray(v), v -= Y.length - U.length), !U.length)
|
|
4672
4672
|
continue;
|
|
4673
4673
|
s += U.length;
|
|
4674
4674
|
const de = o.decode(U);
|
|
4675
4675
|
m.enqueue(de);
|
|
4676
4676
|
}
|
|
4677
4677
|
else {
|
|
4678
|
-
const Y = await
|
|
4678
|
+
const Y = await G.arrayBuffer();
|
|
4679
4679
|
let U = Y;
|
|
4680
4680
|
if (i) {
|
|
4681
4681
|
I.abort();
|
|
4682
4682
|
return;
|
|
4683
4683
|
}
|
|
4684
|
-
if (
|
|
4684
|
+
if (v > 0 && (U = new Uint8Array(Y).subarray(v), v -= Y.byteLength - U.length), !U.byteLength)
|
|
4685
4685
|
continue;
|
|
4686
4686
|
s += U.byteLength;
|
|
4687
4687
|
const de = o.decode(U);
|
|
@@ -4691,34 +4691,34 @@ function Uo({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
|
4691
4691
|
}
|
|
4692
4692
|
if (y = 0, T.content) {
|
|
4693
4693
|
let I = T.content, C = a.encode(T.content);
|
|
4694
|
-
if (
|
|
4695
|
-
const
|
|
4696
|
-
if (
|
|
4694
|
+
if (v > 0) {
|
|
4695
|
+
const D = C.subarray(v);
|
|
4696
|
+
if (v -= C.length - D.length, !D.length)
|
|
4697
4697
|
continue;
|
|
4698
|
-
C =
|
|
4698
|
+
C = D, I = o.decode(D);
|
|
4699
4699
|
}
|
|
4700
4700
|
s += C.length, m.enqueue(I);
|
|
4701
4701
|
}
|
|
4702
4702
|
}
|
|
4703
4703
|
}
|
|
4704
|
-
async function w(
|
|
4704
|
+
async function w(b) {
|
|
4705
4705
|
let m = !0, A = 0;
|
|
4706
4706
|
for (; m; ) {
|
|
4707
4707
|
m = !1;
|
|
4708
4708
|
let T = Date.now() + Math.min(15e3, 500 * (A - 1));
|
|
4709
|
-
const
|
|
4710
|
-
|
|
4709
|
+
const v = await g({ ...e, offset: s }, b);
|
|
4710
|
+
v != null && v.retry && (m = !0, A++, T < Date.now() - 3e5 && (A = 0), await new Promise((I) => {
|
|
4711
4711
|
setTimeout(I, Math.max(0, T - Date.now()));
|
|
4712
4712
|
}));
|
|
4713
4713
|
}
|
|
4714
|
-
!i && !u && (
|
|
4714
|
+
!i && !u && (b.close(), f());
|
|
4715
4715
|
}
|
|
4716
4716
|
return {
|
|
4717
4717
|
stream: new t({
|
|
4718
|
-
start(
|
|
4719
|
-
w(
|
|
4718
|
+
start(b) {
|
|
4719
|
+
w(b);
|
|
4720
4720
|
},
|
|
4721
|
-
cancel(
|
|
4721
|
+
cancel(b) {
|
|
4722
4722
|
i = !0, c && r({ eventId: c }), f();
|
|
4723
4723
|
}
|
|
4724
4724
|
}),
|
|
@@ -4728,7 +4728,7 @@ function Uo({ RStream: t, opts: e, startStream: n, cancelStream: r }) {
|
|
|
4728
4728
|
}
|
|
4729
4729
|
};
|
|
4730
4730
|
}
|
|
4731
|
-
class
|
|
4731
|
+
class Fo {
|
|
4732
4732
|
constructor({ WStream: e, RStream: n, trySend: r, log: s }) {
|
|
4733
4733
|
d(this, "trySend");
|
|
4734
4734
|
d(this, "WStream");
|
|
@@ -4741,7 +4741,7 @@ class Lo {
|
|
|
4741
4741
|
this.WStream = e, this.RStream = n, this.trySend = r, this.log = s;
|
|
4742
4742
|
}
|
|
4743
4743
|
createWriteStream(e) {
|
|
4744
|
-
const { stream: n, addCompleteCb: r } =
|
|
4744
|
+
const { stream: n, addCompleteCb: r } = xo({
|
|
4745
4745
|
WStream: this.WStream,
|
|
4746
4746
|
startStream: this.startWriteStream.bind(this),
|
|
4747
4747
|
appendStream: this.appendStream.bind(this),
|
|
@@ -4753,7 +4753,7 @@ class Lo {
|
|
|
4753
4753
|
}), n;
|
|
4754
4754
|
}
|
|
4755
4755
|
createReadStream(e) {
|
|
4756
|
-
const { stream: n, addCloseCb: r } =
|
|
4756
|
+
const { stream: n, addCloseCb: r } = Lo({
|
|
4757
4757
|
RStream: this.RStream,
|
|
4758
4758
|
opts: e,
|
|
4759
4759
|
startStream: this.startReadStream.bind(this),
|
|
@@ -4815,7 +4815,7 @@ class Lo {
|
|
|
4815
4815
|
if (!r && !n)
|
|
4816
4816
|
throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");
|
|
4817
4817
|
r && (o["stream-id"] = r), n && (o["client-id"] = n), s && (o.offset = s), i && (o["rule-params"] = i);
|
|
4818
|
-
const a = new
|
|
4818
|
+
const a = new Uo();
|
|
4819
4819
|
return this.readStreamIterators[e] = a, this.trySend(e, o), a;
|
|
4820
4820
|
}
|
|
4821
4821
|
cancelReadStream({ eventId: e }) {
|
|
@@ -4849,7 +4849,7 @@ class Lo {
|
|
|
4849
4849
|
onConnectionStatusChange(e) {
|
|
4850
4850
|
for (const n of Object.values(this.startWriteStreamCbs))
|
|
4851
4851
|
n({ type: "disconnect" });
|
|
4852
|
-
if (this.startWriteStreamCbs = {}, e !==
|
|
4852
|
+
if (this.startWriteStreamCbs = {}, e !== re.AUTHENTICATED)
|
|
4853
4853
|
for (const { onDisconnect: n } of Object.values(this.writeStreams))
|
|
4854
4854
|
n();
|
|
4855
4855
|
else {
|
|
@@ -4890,29 +4890,29 @@ class Lo {
|
|
|
4890
4890
|
return this.activeStreams.size > 0;
|
|
4891
4891
|
}
|
|
4892
4892
|
}
|
|
4893
|
-
const
|
|
4893
|
+
const re = {
|
|
4894
4894
|
CONNECTING: "connecting",
|
|
4895
4895
|
OPENED: "opened",
|
|
4896
4896
|
AUTHENTICATED: "authenticated",
|
|
4897
4897
|
CLOSED: "closed",
|
|
4898
4898
|
ERRORED: "errored"
|
|
4899
|
-
},
|
|
4899
|
+
}, No = 3e4, Ko = 3e4, qo = 200, zo = 1e3 * 60, Wo = {
|
|
4900
4900
|
apiURI: "https://api.instantdb.com",
|
|
4901
4901
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
4902
4902
|
}, mt = "_instant_oauth_redirect", Te = "currentUser";
|
|
4903
|
-
function
|
|
4903
|
+
function Vo({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
|
|
4904
4904
|
if (!s)
|
|
4905
4905
|
return new Cn(`${r}?app_id=${e}`);
|
|
4906
4906
|
switch (t) {
|
|
4907
4907
|
case "ws":
|
|
4908
4908
|
return new Cn(`${r}?app_id=${e}`);
|
|
4909
4909
|
case "sse":
|
|
4910
|
-
return new
|
|
4910
|
+
return new Eo(s, `${n}/runtime/sse?app_id=${e}`);
|
|
4911
4911
|
default:
|
|
4912
4912
|
throw new Error("Unknown transport type " + t);
|
|
4913
4913
|
}
|
|
4914
4914
|
}
|
|
4915
|
-
function
|
|
4915
|
+
function Qo() {
|
|
4916
4916
|
return typeof window < "u" || typeof chrome < "u";
|
|
4917
4917
|
}
|
|
4918
4918
|
const jn = {
|
|
@@ -4921,7 +4921,7 @@ const jn = {
|
|
|
4921
4921
|
"refresh-presence": !0,
|
|
4922
4922
|
"patch-presence": !0
|
|
4923
4923
|
};
|
|
4924
|
-
function
|
|
4924
|
+
function Bo(t, e) {
|
|
4925
4925
|
var r;
|
|
4926
4926
|
const n = typeof t == "string" ? JSON.parse(t) : t;
|
|
4927
4927
|
if ((r = n == null ? void 0 : n.result) != null && r.store) {
|
|
@@ -4936,7 +4936,7 @@ function Qo(t, e) {
|
|
|
4936
4936
|
}
|
|
4937
4937
|
return n;
|
|
4938
4938
|
}
|
|
4939
|
-
function
|
|
4939
|
+
function Go(t, e) {
|
|
4940
4940
|
const { result: n, ...r } = e, s = (
|
|
4941
4941
|
/** @type {import('./reactorTypes.ts').QuerySubInStorage} */
|
|
4942
4942
|
r
|
|
@@ -4951,7 +4951,7 @@ function Bo(t, e) {
|
|
|
4951
4951
|
}
|
|
4952
4952
|
return s;
|
|
4953
4953
|
}
|
|
4954
|
-
function
|
|
4954
|
+
function Ho(t, e) {
|
|
4955
4955
|
switch (t) {
|
|
4956
4956
|
case "pendingMutations":
|
|
4957
4957
|
return new Map(typeof e == "string" ? JSON.parse(e) : e);
|
|
@@ -4959,7 +4959,7 @@ function Go(t, e) {
|
|
|
4959
4959
|
return e;
|
|
4960
4960
|
}
|
|
4961
4961
|
}
|
|
4962
|
-
function
|
|
4962
|
+
function Jo(t, e) {
|
|
4963
4963
|
switch (t) {
|
|
4964
4964
|
case "pendingMutations":
|
|
4965
4965
|
return [...e.entries()];
|
|
@@ -4967,7 +4967,7 @@ function Ho(t, e) {
|
|
|
4967
4967
|
return e;
|
|
4968
4968
|
}
|
|
4969
4969
|
}
|
|
4970
|
-
function
|
|
4970
|
+
function Yo(t, e, n) {
|
|
4971
4971
|
const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
|
|
4972
4972
|
return r && !s && n && (n.result = r), n || e;
|
|
4973
4973
|
}
|
|
@@ -4977,13 +4977,13 @@ function Tt(t) {
|
|
|
4977
4977
|
return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
|
|
4978
4978
|
});
|
|
4979
4979
|
}
|
|
4980
|
-
class
|
|
4980
|
+
class Zo {
|
|
4981
4981
|
constructor(e, n = lr, r = fr, s, i) {
|
|
4982
4982
|
/** @type {s.AttrsStore | undefined} */
|
|
4983
4983
|
d(this, "attrs");
|
|
4984
4984
|
d(this, "_isOnline", !0);
|
|
4985
4985
|
d(this, "_isShutdown", !1);
|
|
4986
|
-
d(this, "status",
|
|
4986
|
+
d(this, "status", re.CONNECTING);
|
|
4987
4987
|
/** @type {PersistedObject<string, QuerySub, QuerySubInStorage>} */
|
|
4988
4988
|
d(this, "querySubs");
|
|
4989
4989
|
/** @type {PersistedObject} */
|
|
@@ -5074,9 +5074,9 @@ class Yo {
|
|
|
5074
5074
|
});
|
|
5075
5075
|
/** Applies transactions locally and sends transact message to server */
|
|
5076
5076
|
d(this, "pushTx", (e) => {
|
|
5077
|
-
this.config.disableValidation ||
|
|
5077
|
+
this.config.disableValidation || Io(e, this.config.schema);
|
|
5078
5078
|
try {
|
|
5079
|
-
const n =
|
|
5079
|
+
const n = Ji({
|
|
5080
5080
|
attrsStore: this.optimisticAttrs(),
|
|
5081
5081
|
schema: this.config.schema,
|
|
5082
5082
|
stores: Object.values(this.querySubs.currentValue).map((r) => {
|
|
@@ -5115,7 +5115,7 @@ class Yo {
|
|
|
5115
5115
|
this._log.info("[socket][open]", n.id, "skip; this is no longer the current transport");
|
|
5116
5116
|
return;
|
|
5117
5117
|
}
|
|
5118
|
-
this._log.info("[socket][open]", this._transport.id), this._setStatus(
|
|
5118
|
+
this._log.info("[socket][open]", this._transport.id), this._setStatus(re.OPENED), this.getCurrentUser().then((r) => {
|
|
5119
5119
|
var s;
|
|
5120
5120
|
this._trySend(P(), {
|
|
5121
5121
|
op: "init",
|
|
@@ -5168,7 +5168,7 @@ class Yo {
|
|
|
5168
5168
|
this._log.info("[socket][close]", n.id, "skip; this is no longer the current transport");
|
|
5169
5169
|
return;
|
|
5170
5170
|
}
|
|
5171
|
-
this._setStatus(
|
|
5171
|
+
this._setStatus(re.CLOSED);
|
|
5172
5172
|
for (const r of Object.values(this._rooms))
|
|
5173
5173
|
r.isConnected = !1;
|
|
5174
5174
|
if (this._isShutdown) {
|
|
@@ -5177,7 +5177,7 @@ class Yo {
|
|
|
5177
5177
|
}
|
|
5178
5178
|
this._log.info("[socket][close]", n.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
|
|
5179
5179
|
});
|
|
5180
|
-
if (this._EventSource = i, this.config = { ...
|
|
5180
|
+
if (this._EventSource = i, this.config = { ...Wo, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ko, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? qo, this._log = wo(e.verbose || Zt || dr, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": Xt }, this.config.schema && (this._linkIndex = An(this.config.schema)), !!Qo()) {
|
|
5181
5181
|
if (!e.appId)
|
|
5182
5182
|
throw new Error("Instant must be initialized with an appId.");
|
|
5183
5183
|
if (!Ae(e.appId))
|
|
@@ -5196,9 +5196,9 @@ class Yo {
|
|
|
5196
5196
|
} catch (c) {
|
|
5197
5197
|
this._log.error("[error] handle broadcast channel", c);
|
|
5198
5198
|
}
|
|
5199
|
-
})), this._initStorage(n), this._syncTable = new
|
|
5199
|
+
})), this._initStorage(n), this._syncTable = new Ro(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
|
|
5200
5200
|
useDateObjects: this.config.useDateObjects
|
|
5201
|
-
}, this._log, (o) => Pe(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new
|
|
5201
|
+
}, this._log, (o) => Pe(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new Fo({
|
|
5202
5202
|
WStream: this.config.WritableStream || WritableStream,
|
|
5203
5203
|
RStream: this.config.ReadableStream || ReadableStream,
|
|
5204
5204
|
trySend: this._trySendAuthed.bind(this),
|
|
@@ -5208,9 +5208,9 @@ class Yo {
|
|
|
5208
5208
|
}), setInterval(async () => {
|
|
5209
5209
|
const o = await this.getCurrentUser();
|
|
5210
5210
|
this.syncUserToEndpoint(o.user);
|
|
5211
|
-
},
|
|
5211
|
+
}, zo), r.getIsOnline().then((o) => {
|
|
5212
5212
|
this._isOnline = o, this._startSocket(), r.listen((a) => {
|
|
5213
|
-
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",
|
|
5213
|
+
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", re.CLOSED), this._setStatus(re.CLOSED)));
|
|
5214
5214
|
});
|
|
5215
5215
|
}), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
|
|
5216
5216
|
}
|
|
@@ -5240,9 +5240,9 @@ class Yo {
|
|
|
5240
5240
|
_initStorage(e) {
|
|
5241
5241
|
this.querySubs = new Ut({
|
|
5242
5242
|
persister: new e(this.config.appId, "querySubs"),
|
|
5243
|
-
merge:
|
|
5244
|
-
serialize:
|
|
5245
|
-
parse: (n, r) =>
|
|
5243
|
+
merge: Yo,
|
|
5244
|
+
serialize: Go,
|
|
5245
|
+
parse: (n, r) => Bo(r, this.config.useDateObjects),
|
|
5246
5246
|
// objectSize
|
|
5247
5247
|
objectSize: (n) => {
|
|
5248
5248
|
var r, s, i;
|
|
@@ -5261,8 +5261,8 @@ class Yo {
|
|
|
5261
5261
|
}), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Ut({
|
|
5262
5262
|
persister: new e(this.config.appId, "kv"),
|
|
5263
5263
|
merge: this._onMergeKv,
|
|
5264
|
-
serialize:
|
|
5265
|
-
parse:
|
|
5264
|
+
serialize: Jo,
|
|
5265
|
+
parse: Ho,
|
|
5266
5266
|
objectSize: () => 0,
|
|
5267
5267
|
logger: this._log,
|
|
5268
5268
|
saveThrottleMs: 100,
|
|
@@ -5343,10 +5343,10 @@ class Yo {
|
|
|
5343
5343
|
const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
|
|
5344
5344
|
switch (jn[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
|
|
5345
5345
|
case "init-ok": {
|
|
5346
|
-
this._setStatus(
|
|
5346
|
+
this._setStatus(re.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
|
|
5347
5347
|
for (const p of Object.keys(this._rooms)) {
|
|
5348
|
-
const y = (i = (s = this._presence[p]) == null ? void 0 : s.result) == null ? void 0 : i.user,
|
|
5349
|
-
this._tryJoinRoom(
|
|
5348
|
+
const y = (i = (s = this._presence[p]) == null ? void 0 : s.result) == null ? void 0 : i.user, g = (o = this._rooms[p]) == null ? void 0 : o.roomType;
|
|
5349
|
+
this._tryJoinRoom(g, p, y);
|
|
5350
5350
|
}
|
|
5351
5351
|
break;
|
|
5352
5352
|
}
|
|
@@ -5355,23 +5355,23 @@ class Yo {
|
|
|
5355
5355
|
break;
|
|
5356
5356
|
}
|
|
5357
5357
|
case "add-query-ok": {
|
|
5358
|
-
const { q: p, result: y } = n,
|
|
5359
|
-
if (!this._hasQueryListeners() && !this.querySubs.currentValue[
|
|
5358
|
+
const { q: p, result: y } = n, g = x(p);
|
|
5359
|
+
if (!this._hasQueryListeners() && !this.querySubs.currentValue[g])
|
|
5360
5360
|
break;
|
|
5361
|
-
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,
|
|
5361
|
+
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, b = vn(y), m = this.ensureAttrs(), A = Pe(m, b, r, this.config.useDateObjects);
|
|
5362
5362
|
this.querySubs.updateInPlace((T) => {
|
|
5363
|
-
if (!T[
|
|
5364
|
-
this._log.info("Missing value in querySubs", { hash:
|
|
5363
|
+
if (!T[g]) {
|
|
5364
|
+
this._log.info("Missing value in querySubs", { hash: g, q: p });
|
|
5365
5365
|
return;
|
|
5366
5366
|
}
|
|
5367
|
-
T[
|
|
5367
|
+
T[g].result = {
|
|
5368
5368
|
store: A,
|
|
5369
5369
|
attrsStore: m,
|
|
5370
5370
|
pageInfo: w,
|
|
5371
5371
|
aggregate: _,
|
|
5372
5372
|
processedTxId: n["processed-tx-id"]
|
|
5373
5373
|
};
|
|
5374
|
-
}), this._cleanupPendingMutationsQueries(), this.notifyOne(
|
|
5374
|
+
}), this._cleanupPendingMutationsQueries(), this.notifyOne(g), this.notifyOneQueryOnce(g), this._cleanupPendingMutationsTimeout();
|
|
5375
5375
|
break;
|
|
5376
5376
|
}
|
|
5377
5377
|
case "start-sync-ok": {
|
|
@@ -5407,39 +5407,39 @@ class Yo {
|
|
|
5407
5407
|
break;
|
|
5408
5408
|
}
|
|
5409
5409
|
case "refresh-ok": {
|
|
5410
|
-
const { computations: p, attrs: y } = n,
|
|
5410
|
+
const { computations: p, attrs: y } = n, g = n["processed-tx-id"];
|
|
5411
5411
|
y && this._setAttrs(y), this._cleanupPendingMutationsTimeout();
|
|
5412
|
-
const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(),
|
|
5412
|
+
const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), g);
|
|
5413
5413
|
w !== this._pendingMutations() && this.kv.updateInPlace((m) => {
|
|
5414
5414
|
m.pendingMutations = w;
|
|
5415
5415
|
});
|
|
5416
|
-
const _ = Tt(w.entries()),
|
|
5416
|
+
const _ = Tt(w.entries()), b = p.map((m) => {
|
|
5417
5417
|
var U, de, Fe, Ne;
|
|
5418
|
-
const A = m["instaql-query"], T = m["instaql-result"],
|
|
5418
|
+
const A = m["instaql-query"], T = m["instaql-result"], v = x(A), I = vn(T), C = this.ensureAttrs(), D = Pe(C, I, r, this.config.useDateObjects), { store: ie, attrsStore: Ie } = this._applyOptimisticUpdates(D, C, _, g), G = (de = (U = T == null ? void 0 : T[0]) == null ? void 0 : U.data) == null ? void 0 : de["page-info"], Y = (Ne = (Fe = T == null ? void 0 : T[0]) == null ? void 0 : Fe.data) == null ? void 0 : Ne.aggregate;
|
|
5419
5419
|
return {
|
|
5420
5420
|
q: A,
|
|
5421
|
-
hash:
|
|
5422
|
-
store:
|
|
5423
|
-
attrsStore:
|
|
5424
|
-
pageInfo:
|
|
5421
|
+
hash: v,
|
|
5422
|
+
store: ie,
|
|
5423
|
+
attrsStore: Ie,
|
|
5424
|
+
pageInfo: G,
|
|
5425
5425
|
aggregate: Y
|
|
5426
5426
|
};
|
|
5427
5427
|
});
|
|
5428
|
-
|
|
5429
|
-
this.querySubs.updateInPlace((
|
|
5430
|
-
if (!
|
|
5428
|
+
b.forEach(({ hash: m, q: A, store: T, attrsStore: v, pageInfo: I, aggregate: C }) => {
|
|
5429
|
+
this.querySubs.updateInPlace((D) => {
|
|
5430
|
+
if (!D[m]) {
|
|
5431
5431
|
this._log.error("Missing value in querySubs", { hash: m, q: A });
|
|
5432
5432
|
return;
|
|
5433
5433
|
}
|
|
5434
|
-
|
|
5434
|
+
D[m].result = {
|
|
5435
5435
|
store: T,
|
|
5436
|
-
attrsStore:
|
|
5436
|
+
attrsStore: v,
|
|
5437
5437
|
pageInfo: I,
|
|
5438
5438
|
aggregate: C,
|
|
5439
|
-
processedTxId:
|
|
5439
|
+
processedTxId: g
|
|
5440
5440
|
};
|
|
5441
5441
|
});
|
|
5442
|
-
}), this._cleanupPendingMutationsQueries(),
|
|
5442
|
+
}), this._cleanupPendingMutationsQueries(), b.forEach(({ hash: m }) => {
|
|
5443
5443
|
this.notifyOne(m);
|
|
5444
5444
|
});
|
|
5445
5445
|
break;
|
|
@@ -5450,22 +5450,22 @@ class Yo {
|
|
|
5450
5450
|
const w = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(p);
|
|
5451
5451
|
if (!w)
|
|
5452
5452
|
break;
|
|
5453
|
-
this._updatePendingMutations((
|
|
5454
|
-
|
|
5455
|
-
...
|
|
5453
|
+
this._updatePendingMutations((b) => {
|
|
5454
|
+
b.set(p, {
|
|
5455
|
+
...b.get(p),
|
|
5456
5456
|
"tx-id": y,
|
|
5457
5457
|
confirmed: Date.now()
|
|
5458
5458
|
});
|
|
5459
5459
|
});
|
|
5460
5460
|
const _ = [];
|
|
5461
|
-
for (const
|
|
5462
|
-
if (
|
|
5463
|
-
const m =
|
|
5461
|
+
for (const b of w["tx-steps"])
|
|
5462
|
+
if (b[0] === "add-attr") {
|
|
5463
|
+
const m = b[1];
|
|
5464
5464
|
_.push(m);
|
|
5465
5465
|
}
|
|
5466
5466
|
if (_.length) {
|
|
5467
|
-
const
|
|
5468
|
-
this._setAttrs([...
|
|
5467
|
+
const b = Object.values(this.ensureAttrs().attrs);
|
|
5468
|
+
this._setAttrs([...b, ..._]);
|
|
5469
5469
|
}
|
|
5470
5470
|
this._finishTransaction("synced", p), this._cleanupPendingMutationsTimeout();
|
|
5471
5471
|
break;
|
|
@@ -5564,7 +5564,7 @@ class Yo {
|
|
|
5564
5564
|
this.changeCurrentUser(null);
|
|
5565
5565
|
return;
|
|
5566
5566
|
}
|
|
5567
|
-
this._setStatus(
|
|
5567
|
+
this._setStatus(re.ERRORED, s), this.notifyAll();
|
|
5568
5568
|
return;
|
|
5569
5569
|
}
|
|
5570
5570
|
switch ((h = e["original-event"]) == null ? void 0 : h.op) {
|
|
@@ -5630,7 +5630,7 @@ class Yo {
|
|
|
5630
5630
|
if (!this.querySubs)
|
|
5631
5631
|
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;
|
|
5632
5632
|
const s = x(e), i = this._startQuerySub(e, s);
|
|
5633
|
-
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")),
|
|
5633
|
+
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")), No), r.promise;
|
|
5634
5634
|
}
|
|
5635
5635
|
_completeQueryOnce(e, n, r) {
|
|
5636
5636
|
this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((s) => s.dfd !== r), this._cleanupQuery(e, n));
|
|
@@ -5669,7 +5669,7 @@ class Yo {
|
|
|
5669
5669
|
return /* @__PURE__ */ new Map();
|
|
5670
5670
|
const s = (l) => {
|
|
5671
5671
|
const [f, h, p] = l["forward-identity"];
|
|
5672
|
-
return
|
|
5672
|
+
return j(e, h, p);
|
|
5673
5673
|
}, i = (l) => {
|
|
5674
5674
|
const [f, h, p] = l["forward-identity"];
|
|
5675
5675
|
return _e(e, h, p);
|
|
@@ -5680,9 +5680,9 @@ class Yo {
|
|
|
5680
5680
|
for (const p of l) {
|
|
5681
5681
|
const [y] = p;
|
|
5682
5682
|
if (y === "add-attr") {
|
|
5683
|
-
const [w, _] = p,
|
|
5684
|
-
if (
|
|
5685
|
-
o.attrIdMap[_.id] =
|
|
5683
|
+
const [w, _] = p, b = s(_);
|
|
5684
|
+
if (b && _.id !== b.id) {
|
|
5685
|
+
o.attrIdMap[_.id] = b.id, a = !0;
|
|
5686
5686
|
continue;
|
|
5687
5687
|
}
|
|
5688
5688
|
if (_["value-type"] === "ref") {
|
|
@@ -5697,8 +5697,8 @@ class Yo {
|
|
|
5697
5697
|
a = !0;
|
|
5698
5698
|
continue;
|
|
5699
5699
|
}
|
|
5700
|
-
const
|
|
5701
|
-
h.push(
|
|
5700
|
+
const g = a ? Oi(o, p) : p;
|
|
5701
|
+
h.push(g);
|
|
5702
5702
|
}
|
|
5703
5703
|
return a ? h : l;
|
|
5704
5704
|
}, u = /* @__PURE__ */ new Map();
|
|
@@ -5750,17 +5750,17 @@ class Yo {
|
|
|
5750
5750
|
if (l && s === l.querySubVersion && o === l.pendingMutationsVersion)
|
|
5751
5751
|
return l;
|
|
5752
5752
|
let f = u.store, h = u.attrsStore;
|
|
5753
|
-
const { pageInfo: p, aggregate: y, processedTxId:
|
|
5753
|
+
const { pageInfo: p, aggregate: y, processedTxId: g } = u, w = this._rewriteMutationsSorted(h, a);
|
|
5754
5754
|
if (n) {
|
|
5755
|
-
const
|
|
5756
|
-
f =
|
|
5755
|
+
const b = this._applyOptimisticUpdates(f, h, w, g);
|
|
5756
|
+
f = b.store, h = b.attrsStore;
|
|
5757
5757
|
}
|
|
5758
5758
|
return { data: ar({ store: f, attrsStore: h, pageInfo: p, aggregate: y }, c), querySubVersion: s, pendingMutationsVersion: o };
|
|
5759
5759
|
}
|
|
5760
5760
|
_applyOptimisticUpdates(e, n, r, s) {
|
|
5761
5761
|
for (const [i, o] of r)
|
|
5762
5762
|
if (!o["tx-id"] || s && o["tx-id"] > s) {
|
|
5763
|
-
const a =
|
|
5763
|
+
const a = As(e, n, o["tx-steps"]);
|
|
5764
5764
|
e = a.store, n = a.attrsStore;
|
|
5765
5765
|
}
|
|
5766
5766
|
return { store: e, attrsStore: n };
|
|
@@ -5792,7 +5792,7 @@ class Yo {
|
|
|
5792
5792
|
});
|
|
5793
5793
|
return;
|
|
5794
5794
|
}
|
|
5795
|
-
if (this.status !==
|
|
5795
|
+
if (this.status !== re.AUTHENTICATED) {
|
|
5796
5796
|
this._finishTransaction("enqueued", e);
|
|
5797
5797
|
return;
|
|
5798
5798
|
}
|
|
@@ -5850,7 +5850,7 @@ class Yo {
|
|
|
5850
5850
|
});
|
|
5851
5851
|
}
|
|
5852
5852
|
_trySendAuthed(...e) {
|
|
5853
|
-
this.status ===
|
|
5853
|
+
this.status === re.AUTHENTICATED && this._trySend(...e);
|
|
5854
5854
|
}
|
|
5855
5855
|
_trySend(e, n, r) {
|
|
5856
5856
|
if (this._transport.isOpen()) {
|
|
@@ -5878,7 +5878,7 @@ class Yo {
|
|
|
5878
5878
|
return;
|
|
5879
5879
|
}
|
|
5880
5880
|
const e = this._transport;
|
|
5881
|
-
this._transport =
|
|
5881
|
+
this._transport = Vo({
|
|
5882
5882
|
transportType: this._transportType,
|
|
5883
5883
|
appId: this.config.appId,
|
|
5884
5884
|
apiURI: this.config.apiURI,
|
|
@@ -6098,7 +6098,7 @@ class Yo {
|
|
|
6098
6098
|
}), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
|
|
6099
6099
|
}
|
|
6100
6100
|
sendMagicCode({ email: e }) {
|
|
6101
|
-
return
|
|
6101
|
+
return so({
|
|
6102
6102
|
apiURI: this.config.apiURI,
|
|
6103
6103
|
appId: this.config.appId,
|
|
6104
6104
|
email: e
|
|
@@ -6106,7 +6106,7 @@ class Yo {
|
|
|
6106
6106
|
}
|
|
6107
6107
|
async signInWithMagicCode({ email: e, code: n }) {
|
|
6108
6108
|
var o, a;
|
|
6109
|
-
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await
|
|
6109
|
+
const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await io({
|
|
6110
6110
|
apiURI: this.config.apiURI,
|
|
6111
6111
|
appId: this.config.appId,
|
|
6112
6112
|
email: e,
|
|
@@ -6116,7 +6116,7 @@ class Yo {
|
|
|
6116
6116
|
return await this.changeCurrentUser(i.user), i;
|
|
6117
6117
|
}
|
|
6118
6118
|
async signInWithCustomToken(e) {
|
|
6119
|
-
const n = await
|
|
6119
|
+
const n = await oo({
|
|
6120
6120
|
apiURI: this.config.apiURI,
|
|
6121
6121
|
appId: this.config.appId,
|
|
6122
6122
|
refreshToken: e
|
|
@@ -6124,7 +6124,7 @@ class Yo {
|
|
|
6124
6124
|
return await this.changeCurrentUser(n.user), n;
|
|
6125
6125
|
}
|
|
6126
6126
|
async signInAsGuest() {
|
|
6127
|
-
const e = await
|
|
6127
|
+
const e = await ao({
|
|
6128
6128
|
apiURI: this.config.apiURI,
|
|
6129
6129
|
appId: this.config.appId
|
|
6130
6130
|
});
|
|
@@ -6139,7 +6139,7 @@ class Yo {
|
|
|
6139
6139
|
this._log.info("[auth-invalidate] skipped invalidateToken");
|
|
6140
6140
|
return;
|
|
6141
6141
|
}
|
|
6142
|
-
|
|
6142
|
+
uo({
|
|
6143
6143
|
apiURI: this.config.apiURI,
|
|
6144
6144
|
appId: this.config.appId,
|
|
6145
6145
|
refreshToken: r
|
|
@@ -6192,7 +6192,7 @@ class Yo {
|
|
|
6192
6192
|
*/
|
|
6193
6193
|
async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
|
|
6194
6194
|
var a;
|
|
6195
|
-
const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await
|
|
6195
|
+
const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await co({
|
|
6196
6196
|
apiURI: this.config.apiURI,
|
|
6197
6197
|
appId: this.config.appId,
|
|
6198
6198
|
idToken: e,
|
|
@@ -6235,7 +6235,7 @@ class Yo {
|
|
|
6235
6235
|
getPresence(e, n, r = {}) {
|
|
6236
6236
|
const s = this._rooms[n], i = this._presence[n];
|
|
6237
6237
|
return !s || !i || !i.result ? null : {
|
|
6238
|
-
...
|
|
6238
|
+
...bo(i.result, r, this._sessionId),
|
|
6239
6239
|
isLoading: !s.isConnected,
|
|
6240
6240
|
error: s.error
|
|
6241
6241
|
};
|
|
@@ -6297,7 +6297,7 @@ class Yo {
|
|
|
6297
6297
|
}
|
|
6298
6298
|
_notifyPresenceSub(e, n) {
|
|
6299
6299
|
const r = this.getPresence("", e, n);
|
|
6300
|
-
r && (n.prev && !
|
|
6300
|
+
r && (n.prev && !go(r, n.prev) || (n.prev = r, n.cb(r)));
|
|
6301
6301
|
}
|
|
6302
6302
|
_patchPresencePeers(e, n) {
|
|
6303
6303
|
var o, a, c;
|
|
@@ -6308,7 +6308,7 @@ class Yo {
|
|
|
6308
6308
|
for (let [l, f, h] of n)
|
|
6309
6309
|
switch (f) {
|
|
6310
6310
|
case "+":
|
|
6311
|
-
|
|
6311
|
+
Qr(u, l, h);
|
|
6312
6312
|
break;
|
|
6313
6313
|
case "r":
|
|
6314
6314
|
an(u, l, h);
|
|
@@ -6359,8 +6359,8 @@ class Yo {
|
|
|
6359
6359
|
_notifyBroadcastSubs(e, n, r) {
|
|
6360
6360
|
var s, i, o;
|
|
6361
6361
|
(o = (i = (s = this._broadcastSubs) == null ? void 0 : s[e]) == null ? void 0 : i[n]) == null || o.forEach((a) => {
|
|
6362
|
-
var l, f, h, p, y,
|
|
6363
|
-
const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (h = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : h.user : (
|
|
6362
|
+
var l, f, h, p, y, g;
|
|
6363
|
+
const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (h = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : h.user : (g = (y = (p = this._presence[e]) == null ? void 0 : p.result) == null ? void 0 : y.peers) == null ? void 0 : g[r.data["peer-id"]];
|
|
6364
6364
|
return a(c, u);
|
|
6365
6365
|
});
|
|
6366
6366
|
}
|
|
@@ -6369,7 +6369,7 @@ class Yo {
|
|
|
6369
6369
|
async uploadFile(e, n, r) {
|
|
6370
6370
|
var o;
|
|
6371
6371
|
const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
|
|
6372
|
-
return
|
|
6372
|
+
return lo({
|
|
6373
6373
|
...r,
|
|
6374
6374
|
apiURI: this.config.apiURI,
|
|
6375
6375
|
appId: this.config.appId,
|
|
@@ -6381,7 +6381,7 @@ class Yo {
|
|
|
6381
6381
|
async deleteFile(e) {
|
|
6382
6382
|
var i;
|
|
6383
6383
|
const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
|
|
6384
|
-
return await
|
|
6384
|
+
return await fo({
|
|
6385
6385
|
apiURI: this.config.apiURI,
|
|
6386
6386
|
appId: this.config.appId,
|
|
6387
6387
|
path: e,
|
|
@@ -6392,18 +6392,18 @@ class Yo {
|
|
|
6392
6392
|
// ---------------------------------
|
|
6393
6393
|
async upload(e, n) {
|
|
6394
6394
|
var c;
|
|
6395
|
-
const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await
|
|
6395
|
+
const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await ho({
|
|
6396
6396
|
apiURI: this.config.apiURI,
|
|
6397
6397
|
appId: this.config.appId,
|
|
6398
6398
|
fileName: i,
|
|
6399
6399
|
refreshToken: s
|
|
6400
6400
|
});
|
|
6401
|
-
return await
|
|
6401
|
+
return await po(o, n);
|
|
6402
6402
|
}
|
|
6403
6403
|
async getDownloadUrl(e) {
|
|
6404
6404
|
var i;
|
|
6405
6405
|
const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
|
|
6406
|
-
return await
|
|
6406
|
+
return await yo({
|
|
6407
6407
|
apiURI: this.config.apiURI,
|
|
6408
6408
|
appId: this.config.appId,
|
|
6409
6409
|
path: e,
|
|
@@ -6411,7 +6411,7 @@ class Yo {
|
|
|
6411
6411
|
});
|
|
6412
6412
|
}
|
|
6413
6413
|
}
|
|
6414
|
-
function
|
|
6414
|
+
function Xo(t, e) {
|
|
6415
6415
|
return new lt(
|
|
6416
6416
|
Tr(t, e),
|
|
6417
6417
|
// (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
|
|
@@ -6423,25 +6423,25 @@ function Zo(t, e) {
|
|
|
6423
6423
|
void 0
|
|
6424
6424
|
);
|
|
6425
6425
|
}
|
|
6426
|
-
function
|
|
6426
|
+
function ea(t) {
|
|
6427
6427
|
return new ut(t, {});
|
|
6428
6428
|
}
|
|
6429
|
-
function
|
|
6429
|
+
function ta() {
|
|
6430
6430
|
return new z("string", !0, !1);
|
|
6431
6431
|
}
|
|
6432
|
-
function
|
|
6432
|
+
function na() {
|
|
6433
6433
|
return new z("number", !0, !1);
|
|
6434
6434
|
}
|
|
6435
|
-
function
|
|
6435
|
+
function ra() {
|
|
6436
6436
|
return new z("boolean", !0, !1);
|
|
6437
6437
|
}
|
|
6438
|
-
function
|
|
6438
|
+
function sa() {
|
|
6439
6439
|
return new z("date", !0, !1);
|
|
6440
6440
|
}
|
|
6441
|
-
function
|
|
6441
|
+
function ia() {
|
|
6442
6442
|
return new z("json", !0, !1);
|
|
6443
6443
|
}
|
|
6444
|
-
function
|
|
6444
|
+
function oa() {
|
|
6445
6445
|
return new z("json", !0, !1);
|
|
6446
6446
|
}
|
|
6447
6447
|
function Tr(t, e) {
|
|
@@ -6463,7 +6463,7 @@ function Tr(t, e) {
|
|
|
6463
6463
|
})
|
|
6464
6464
|
]));
|
|
6465
6465
|
}
|
|
6466
|
-
function
|
|
6466
|
+
function aa({ entities: t, links: e, rooms: n }) {
|
|
6467
6467
|
const r = e ?? {}, s = n ?? {};
|
|
6468
6468
|
return new lt(
|
|
6469
6469
|
Tr(t, r),
|
|
@@ -6476,23 +6476,23 @@ function oa({ entities: t, links: e, rooms: n }) {
|
|
|
6476
6476
|
s
|
|
6477
6477
|
);
|
|
6478
6478
|
}
|
|
6479
|
-
const
|
|
6479
|
+
const Ha = {
|
|
6480
6480
|
// constructs
|
|
6481
|
-
graph:
|
|
6482
|
-
schema:
|
|
6483
|
-
entity:
|
|
6481
|
+
graph: Xo,
|
|
6482
|
+
schema: aa,
|
|
6483
|
+
entity: ea,
|
|
6484
6484
|
// value types
|
|
6485
|
-
string:
|
|
6486
|
-
number:
|
|
6487
|
-
boolean:
|
|
6488
|
-
date:
|
|
6489
|
-
json:
|
|
6490
|
-
any:
|
|
6485
|
+
string: ta,
|
|
6486
|
+
number: na,
|
|
6487
|
+
boolean: ra,
|
|
6488
|
+
date: sa,
|
|
6489
|
+
json: ia,
|
|
6490
|
+
any: oa
|
|
6491
6491
|
};
|
|
6492
6492
|
let We;
|
|
6493
|
-
function
|
|
6493
|
+
function ca(t, e) {
|
|
6494
6494
|
We == null || We.dispose();
|
|
6495
|
-
const n =
|
|
6495
|
+
const n = pa(e), r = fa(e, a), s = la(ua(t));
|
|
6496
6496
|
function i(l) {
|
|
6497
6497
|
var f;
|
|
6498
6498
|
l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
|
|
@@ -6514,10 +6514,10 @@ function aa(t, e) {
|
|
|
6514
6514
|
}
|
|
6515
6515
|
return u();
|
|
6516
6516
|
}
|
|
6517
|
-
function
|
|
6517
|
+
function ua(t) {
|
|
6518
6518
|
return `${Zt || hr ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
|
|
6519
6519
|
}
|
|
6520
|
-
function
|
|
6520
|
+
function la(t) {
|
|
6521
6521
|
const e = document.createElement("iframe");
|
|
6522
6522
|
return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
|
|
6523
6523
|
width: "100%",
|
|
@@ -6526,7 +6526,7 @@ function ua(t) {
|
|
|
6526
6526
|
border: "none"
|
|
6527
6527
|
}), { element: e };
|
|
6528
6528
|
}
|
|
6529
|
-
function
|
|
6529
|
+
function fa(t, e) {
|
|
6530
6530
|
const n = `
|
|
6531
6531
|
<svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6532
6532
|
<rect width="512" height="512" fill="black"/>
|
|
@@ -6536,7 +6536,7 @@ function la(t, e) {
|
|
|
6536
6536
|
return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
|
|
6537
6537
|
// pos
|
|
6538
6538
|
position: "fixed",
|
|
6539
|
-
...
|
|
6539
|
+
...da(t.position),
|
|
6540
6540
|
height: "32px",
|
|
6541
6541
|
width: "32px",
|
|
6542
6542
|
// layout
|
|
@@ -6551,7 +6551,7 @@ function la(t, e) {
|
|
|
6551
6551
|
cursor: "pointer"
|
|
6552
6552
|
}), r.addEventListener("click", e), { element: r };
|
|
6553
6553
|
}
|
|
6554
|
-
function
|
|
6554
|
+
function da(t) {
|
|
6555
6555
|
switch (t) {
|
|
6556
6556
|
case "bottom-left":
|
|
6557
6557
|
return { bottom: "24px", left: "24px" };
|
|
@@ -6563,7 +6563,7 @@ function fa(t) {
|
|
|
6563
6563
|
return { top: "24px", left: "24px" };
|
|
6564
6564
|
}
|
|
6565
6565
|
}
|
|
6566
|
-
function
|
|
6566
|
+
function ha(t) {
|
|
6567
6567
|
switch (t) {
|
|
6568
6568
|
case "bottom-left":
|
|
6569
6569
|
return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
|
|
@@ -6575,11 +6575,11 @@ function da(t) {
|
|
|
6575
6575
|
return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
|
|
6576
6576
|
}
|
|
6577
6577
|
}
|
|
6578
|
-
function
|
|
6578
|
+
function pa(t) {
|
|
6579
6579
|
const e = document.createElement("div");
|
|
6580
6580
|
Object.assign(e.style, {
|
|
6581
6581
|
position: "fixed",
|
|
6582
|
-
...
|
|
6582
|
+
...ha(t.position),
|
|
6583
6583
|
display: "block",
|
|
6584
6584
|
borderRadius: "4px",
|
|
6585
6585
|
border: "1px #ccc solid",
|
|
@@ -6592,7 +6592,7 @@ function ha(t) {
|
|
|
6592
6592
|
}
|
|
6593
6593
|
return { element: e, isVisible: n };
|
|
6594
6594
|
}
|
|
6595
|
-
function
|
|
6595
|
+
function ya(t, e) {
|
|
6596
6596
|
return e && e.refresh_token ? new Response(JSON.stringify({ ok: !0 }), {
|
|
6597
6597
|
headers: {
|
|
6598
6598
|
"Content-Type": "application/json",
|
|
@@ -6613,7 +6613,7 @@ function Ve(t, e) {
|
|
|
6613
6613
|
headers: { "Content-Type": "application/json" }
|
|
6614
6614
|
});
|
|
6615
6615
|
}
|
|
6616
|
-
const
|
|
6616
|
+
const Ja = (t) => ({
|
|
6617
6617
|
POST: async (e) => {
|
|
6618
6618
|
let n;
|
|
6619
6619
|
try {
|
|
@@ -6627,27 +6627,27 @@ const Ha = (t) => ({
|
|
|
6627
6627
|
return Ve(403, "App ID mismatch");
|
|
6628
6628
|
switch (n.type) {
|
|
6629
6629
|
case "sync-user":
|
|
6630
|
-
return
|
|
6630
|
+
return ya(t, n.user ?? null);
|
|
6631
6631
|
default:
|
|
6632
6632
|
return Ve(400, `Unknown type: ${n.type}`);
|
|
6633
6633
|
}
|
|
6634
6634
|
}
|
|
6635
|
-
}),
|
|
6635
|
+
}), ba = {
|
|
6636
6636
|
apiURI: "https://api.instantdb.com",
|
|
6637
6637
|
websocketURI: "wss://api.instantdb.com/runtime/session"
|
|
6638
6638
|
};
|
|
6639
|
-
function
|
|
6639
|
+
function ga() {
|
|
6640
6640
|
return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
|
|
6641
6641
|
}
|
|
6642
|
-
function
|
|
6642
|
+
function wa() {
|
|
6643
6643
|
return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
|
|
6644
6644
|
}
|
|
6645
6645
|
function Lt(t) {
|
|
6646
6646
|
const e = t.__adminToken;
|
|
6647
6647
|
return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
|
|
6648
6648
|
}
|
|
6649
|
-
const Ft =
|
|
6650
|
-
class
|
|
6649
|
+
const Ft = wa(), Dn = ga();
|
|
6650
|
+
class _a {
|
|
6651
6651
|
constructor(e) {
|
|
6652
6652
|
d(this, "db");
|
|
6653
6653
|
/**
|
|
@@ -6764,7 +6764,7 @@ class wa {
|
|
|
6764
6764
|
this.db = e;
|
|
6765
6765
|
}
|
|
6766
6766
|
}
|
|
6767
|
-
class
|
|
6767
|
+
class ma {
|
|
6768
6768
|
constructor(e) {
|
|
6769
6769
|
d(this, "db");
|
|
6770
6770
|
/**
|
|
@@ -6822,7 +6822,7 @@ class _a {
|
|
|
6822
6822
|
this.db = e;
|
|
6823
6823
|
}
|
|
6824
6824
|
}
|
|
6825
|
-
class
|
|
6825
|
+
class Ta {
|
|
6826
6826
|
constructor(e) {
|
|
6827
6827
|
d(this, "db");
|
|
6828
6828
|
/**
|
|
@@ -6848,17 +6848,17 @@ class ma {
|
|
|
6848
6848
|
this.db = e;
|
|
6849
6849
|
}
|
|
6850
6850
|
}
|
|
6851
|
-
function
|
|
6851
|
+
function Sa(t) {
|
|
6852
6852
|
return JSON.parse(JSON.stringify(t));
|
|
6853
6853
|
}
|
|
6854
|
-
class
|
|
6854
|
+
class va {
|
|
6855
6855
|
constructor(e) {
|
|
6856
6856
|
d(this, "_reactor");
|
|
6857
6857
|
d(this, "auth");
|
|
6858
6858
|
d(this, "storage");
|
|
6859
6859
|
d(this, "streams");
|
|
6860
6860
|
d(this, "tx", Yt());
|
|
6861
|
-
this._reactor = e, this.auth = new
|
|
6861
|
+
this._reactor = e, this.auth = new _a(this._reactor), this.storage = new ma(this._reactor), this.streams = new Ta(this._reactor);
|
|
6862
6862
|
}
|
|
6863
6863
|
/**
|
|
6864
6864
|
* Use this to write data! You can create, update, delete, and link objects
|
|
@@ -7041,10 +7041,10 @@ function $n(t) {
|
|
|
7041
7041
|
const n = x(t);
|
|
7042
7042
|
return Dn.set(t, n), n;
|
|
7043
7043
|
}
|
|
7044
|
-
function
|
|
7044
|
+
function Aa(t, e) {
|
|
7045
7045
|
return $n(t._reactor.config.schema) !== $n(e);
|
|
7046
7046
|
}
|
|
7047
|
-
function
|
|
7047
|
+
function Oa(t, e, n, r, s) {
|
|
7048
7048
|
var u;
|
|
7049
7049
|
const i = {
|
|
7050
7050
|
...t,
|
|
@@ -7052,15 +7052,15 @@ function Aa(t, e, n, r, s) {
|
|
|
7052
7052
|
useDateObjects: t.useDateObjects ?? !1
|
|
7053
7053
|
}, o = Ft[Lt(i)];
|
|
7054
7054
|
if (o)
|
|
7055
|
-
return
|
|
7056
|
-
const a = new
|
|
7057
|
-
...
|
|
7055
|
+
return Aa(o, i.schema) && o._reactor.updateSchema(i.schema), o;
|
|
7056
|
+
const a = new Zo({
|
|
7057
|
+
...ba,
|
|
7058
7058
|
...i,
|
|
7059
7059
|
cardinalityInference: !!i.schema
|
|
7060
|
-
}, e || lr, n || fr, { ...r || {}, "@instantdb/core": Xt }, s), c = new
|
|
7061
|
-
return Ft[Lt(i)] = c,
|
|
7060
|
+
}, e || lr, n || fr, { ...r || {}, "@instantdb/core": Xt }, s), c = new va(a);
|
|
7061
|
+
return Ft[Lt(i)] = c, ka(i.appId, i.devtool), c;
|
|
7062
7062
|
}
|
|
7063
|
-
function
|
|
7063
|
+
function ka(t, e) {
|
|
7064
7064
|
if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
|
|
7065
7065
|
return;
|
|
7066
7066
|
const n = {
|
|
@@ -7068,15 +7068,15 @@ function Oa(t, e) {
|
|
|
7068
7068
|
allowedHosts: ["localhost"],
|
|
7069
7069
|
...typeof e == "object" ? e : {}
|
|
7070
7070
|
};
|
|
7071
|
-
n.allowedHosts.includes(window.location.hostname) &&
|
|
7071
|
+
n.allowedHosts.includes(window.location.hostname) && ca(t, n);
|
|
7072
7072
|
}
|
|
7073
|
-
const
|
|
7074
|
-
equals:
|
|
7073
|
+
const Ia = !1, Ea = (t, e) => t === e, tt = {
|
|
7074
|
+
equals: Ea
|
|
7075
7075
|
};
|
|
7076
7076
|
let Sr = kr;
|
|
7077
|
-
const me = 1, nt = 2,
|
|
7077
|
+
const me = 1, nt = 2, Ca = {};
|
|
7078
7078
|
var L = null;
|
|
7079
|
-
let St = null,
|
|
7079
|
+
let St = null, Pa = null, R = null, F = null, le = null, ft = 0;
|
|
7080
7080
|
function je(t, e) {
|
|
7081
7081
|
e = e ? Object.assign({}, tt, e) : tt;
|
|
7082
7082
|
const n = {
|
|
@@ -7088,7 +7088,7 @@ function je(t, e) {
|
|
|
7088
7088
|
return [vr.bind(n), r];
|
|
7089
7089
|
}
|
|
7090
7090
|
function ae(t, e, n) {
|
|
7091
|
-
Sr =
|
|
7091
|
+
Sr = $a;
|
|
7092
7092
|
const r = Or(t, e, !1, me);
|
|
7093
7093
|
r.user = !0, le ? le.push(r) : dt(r);
|
|
7094
7094
|
}
|
|
@@ -7097,7 +7097,7 @@ function en(t, e, n) {
|
|
|
7097
7097
|
const r = Or(t, e, !0, 0);
|
|
7098
7098
|
return r.observers = null, r.observerSlots = null, r.comparator = n.equals || void 0, dt(r), vr.bind(r);
|
|
7099
7099
|
}
|
|
7100
|
-
function
|
|
7100
|
+
function Ma(t) {
|
|
7101
7101
|
if (R === null) return t();
|
|
7102
7102
|
const e = R;
|
|
7103
7103
|
R = null;
|
|
@@ -7138,9 +7138,9 @@ function dt(t) {
|
|
|
7138
7138
|
if (!t.fn) return;
|
|
7139
7139
|
it(t);
|
|
7140
7140
|
const e = ft;
|
|
7141
|
-
|
|
7141
|
+
ja(t, t.value, e);
|
|
7142
7142
|
}
|
|
7143
|
-
function
|
|
7143
|
+
function ja(t, e, n) {
|
|
7144
7144
|
let r;
|
|
7145
7145
|
const s = L, i = R;
|
|
7146
7146
|
R = L = t;
|
|
@@ -7167,12 +7167,12 @@ function Or(t, e, n, r = me, s) {
|
|
|
7167
7167
|
context: L ? L.context : null,
|
|
7168
7168
|
pure: n
|
|
7169
7169
|
};
|
|
7170
|
-
return L === null || L !==
|
|
7170
|
+
return L === null || L !== Ca && (L.owned ? L.owned.push(i) : L.owned = [i]), i;
|
|
7171
7171
|
}
|
|
7172
7172
|
function rt(t) {
|
|
7173
7173
|
if (t.state === 0) return;
|
|
7174
7174
|
if (t.state === nt) return st(t);
|
|
7175
|
-
if (t.suspense &&
|
|
7175
|
+
if (t.suspense && Ma(t.suspense.inFallback)) return t.suspense.effects.push(t);
|
|
7176
7176
|
const e = [t];
|
|
7177
7177
|
for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < ft); )
|
|
7178
7178
|
t.state && e.push(t);
|
|
@@ -7190,12 +7190,12 @@ function ht(t, e) {
|
|
|
7190
7190
|
F = [], le ? n = !0 : le = [], ft++;
|
|
7191
7191
|
try {
|
|
7192
7192
|
const r = t();
|
|
7193
|
-
return
|
|
7193
|
+
return Da(n), r;
|
|
7194
7194
|
} catch (r) {
|
|
7195
7195
|
n || (le = null), F = null, Er(r);
|
|
7196
7196
|
}
|
|
7197
7197
|
}
|
|
7198
|
-
function
|
|
7198
|
+
function Da(t) {
|
|
7199
7199
|
if (F && (kr(F), F = null), t) return;
|
|
7200
7200
|
const e = le;
|
|
7201
7201
|
le = null, e.length && ht(() => Sr(e));
|
|
@@ -7203,7 +7203,7 @@ function ja(t) {
|
|
|
7203
7203
|
function kr(t) {
|
|
7204
7204
|
for (let e = 0; e < t.length; e++) rt(t[e]);
|
|
7205
7205
|
}
|
|
7206
|
-
function
|
|
7206
|
+
function $a(t) {
|
|
7207
7207
|
let e, n = 0;
|
|
7208
7208
|
for (e = 0; e < t.length; e++) {
|
|
7209
7209
|
const r = t[e];
|
|
@@ -7251,16 +7251,16 @@ function it(t) {
|
|
|
7251
7251
|
}
|
|
7252
7252
|
t.state = 0;
|
|
7253
7253
|
}
|
|
7254
|
-
function
|
|
7254
|
+
function Ra(t) {
|
|
7255
7255
|
return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", {
|
|
7256
7256
|
cause: t
|
|
7257
7257
|
});
|
|
7258
7258
|
}
|
|
7259
7259
|
function Er(t, e = L) {
|
|
7260
|
-
throw
|
|
7260
|
+
throw Ra(t);
|
|
7261
7261
|
}
|
|
7262
|
-
const
|
|
7263
|
-
function
|
|
7262
|
+
const xa = 1e3;
|
|
7263
|
+
function Ua(t, e, n) {
|
|
7264
7264
|
ae(() => {
|
|
7265
7265
|
const r = t.core._reactor.subscribeTopic(
|
|
7266
7266
|
t.type,
|
|
@@ -7273,7 +7273,7 @@ function xa(t, e, n) {
|
|
|
7273
7273
|
ce(r);
|
|
7274
7274
|
});
|
|
7275
7275
|
}
|
|
7276
|
-
function
|
|
7276
|
+
function La(t, e) {
|
|
7277
7277
|
return ae(() => {
|
|
7278
7278
|
const n = t.core._reactor.joinRoom(t.type, t.id);
|
|
7279
7279
|
ce(n);
|
|
@@ -7286,7 +7286,7 @@ function Ua(t, e) {
|
|
|
7286
7286
|
});
|
|
7287
7287
|
};
|
|
7288
7288
|
}
|
|
7289
|
-
function
|
|
7289
|
+
function Fa(t, e = {}) {
|
|
7290
7290
|
const [n, r] = je(
|
|
7291
7291
|
t.core._reactor.getPresence(t.type, t.id, e) ?? {
|
|
7292
7292
|
peers: {},
|
|
@@ -7312,7 +7312,7 @@ function La(t, e = {}) {
|
|
|
7312
7312
|
publishPresence: s
|
|
7313
7313
|
}));
|
|
7314
7314
|
}
|
|
7315
|
-
function
|
|
7315
|
+
function Na(t, e, n) {
|
|
7316
7316
|
ae(() => {
|
|
7317
7317
|
const r = t.core._reactor.joinRoom(
|
|
7318
7318
|
t.type,
|
|
@@ -7324,7 +7324,7 @@ function Fa(t, e, n) {
|
|
|
7324
7324
|
n ? n.forEach((r) => typeof r == "function" ? r() : r) : JSON.stringify(e), t.core._reactor.publishPresence(t.type, t.id, e);
|
|
7325
7325
|
});
|
|
7326
7326
|
}
|
|
7327
|
-
function
|
|
7327
|
+
function Ka(t, e, n = {}) {
|
|
7328
7328
|
let r = null;
|
|
7329
7329
|
const s = Cr.usePresence(t, {
|
|
7330
7330
|
keys: [e]
|
|
@@ -7342,7 +7342,7 @@ function Na(t, e, n = {}) {
|
|
|
7342
7342
|
t.core._reactor.publishPresence(t.type, t.id, {
|
|
7343
7343
|
[e]: null
|
|
7344
7344
|
});
|
|
7345
|
-
}, (n == null ? void 0 : n.timeout) ??
|
|
7345
|
+
}, (n == null ? void 0 : n.timeout) ?? xa)));
|
|
7346
7346
|
};
|
|
7347
7347
|
return ce(() => {
|
|
7348
7348
|
r && (clearTimeout(r), r = null), o(!1);
|
|
@@ -7358,13 +7358,13 @@ function Na(t, e, n = {}) {
|
|
|
7358
7358
|
};
|
|
7359
7359
|
}
|
|
7360
7360
|
const Cr = {
|
|
7361
|
-
useTopicEffect:
|
|
7362
|
-
usePublishTopic:
|
|
7363
|
-
usePresence:
|
|
7364
|
-
useSyncPresence:
|
|
7365
|
-
useTypingIndicator:
|
|
7361
|
+
useTopicEffect: Ua,
|
|
7362
|
+
usePublishTopic: La,
|
|
7363
|
+
usePresence: Fa,
|
|
7364
|
+
useSyncPresence: Na,
|
|
7365
|
+
useTypingIndicator: Ka
|
|
7366
7366
|
};
|
|
7367
|
-
class
|
|
7367
|
+
class qa {
|
|
7368
7368
|
constructor(e, n, r) {
|
|
7369
7369
|
d(this, "core");
|
|
7370
7370
|
d(this, "type");
|
|
@@ -7377,12 +7377,12 @@ const Rn = {
|
|
|
7377
7377
|
data: void 0,
|
|
7378
7378
|
pageInfo: void 0,
|
|
7379
7379
|
error: void 0
|
|
7380
|
-
},
|
|
7380
|
+
}, za = {
|
|
7381
7381
|
isLoading: !0,
|
|
7382
7382
|
user: void 0,
|
|
7383
7383
|
error: void 0
|
|
7384
7384
|
};
|
|
7385
|
-
function
|
|
7385
|
+
function Wa(t) {
|
|
7386
7386
|
return {
|
|
7387
7387
|
isLoading: !t,
|
|
7388
7388
|
data: void 0,
|
|
@@ -7391,7 +7391,7 @@ function za(t) {
|
|
|
7391
7391
|
...t || {}
|
|
7392
7392
|
};
|
|
7393
7393
|
}
|
|
7394
|
-
class
|
|
7394
|
+
class Va {
|
|
7395
7395
|
constructor(e) {
|
|
7396
7396
|
d(this, "tx", Yt());
|
|
7397
7397
|
d(this, "auth");
|
|
@@ -7449,9 +7449,9 @@ class Wa {
|
|
|
7449
7449
|
}
|
|
7450
7450
|
let o = i;
|
|
7451
7451
|
n && "ruleParams" in n && (o = { $$ruleParams: n.ruleParams, ...o });
|
|
7452
|
-
const a =
|
|
7452
|
+
const a = Sa(o), c = this.core._reactor.getPreviousResult(a);
|
|
7453
7453
|
c && s(
|
|
7454
|
-
() =>
|
|
7454
|
+
() => Wa(c)
|
|
7455
7455
|
);
|
|
7456
7456
|
const u = this.core.subscribeQuery(a, (l) => {
|
|
7457
7457
|
s(
|
|
@@ -7482,7 +7482,7 @@ class Wa {
|
|
|
7482
7482
|
*/
|
|
7483
7483
|
d(this, "useAuth", () => {
|
|
7484
7484
|
const [e, n] = je(
|
|
7485
|
-
this.core._reactor._currentUserCached ??
|
|
7485
|
+
this.core._reactor._currentUserCached ?? za
|
|
7486
7486
|
);
|
|
7487
7487
|
return ae(() => {
|
|
7488
7488
|
const r = this.core.subscribeAuth((s) => {
|
|
@@ -7589,25 +7589,25 @@ class Wa {
|
|
|
7589
7589
|
* const presence = db.rooms.usePresence(room);
|
|
7590
7590
|
*/
|
|
7591
7591
|
room(e = "_defaultRoomType", n = "_defaultRoomId") {
|
|
7592
|
-
return new
|
|
7592
|
+
return new qa(this.core, e, n);
|
|
7593
7593
|
}
|
|
7594
7594
|
}
|
|
7595
|
-
function
|
|
7596
|
-
const e =
|
|
7595
|
+
function Ya(t) {
|
|
7596
|
+
const e = Oa(t, void 0, void 0, {
|
|
7597
7597
|
"@instantdb/solidjs": Xt
|
|
7598
7598
|
});
|
|
7599
|
-
return new
|
|
7599
|
+
return new Va(e);
|
|
7600
7600
|
}
|
|
7601
7601
|
export {
|
|
7602
7602
|
ct as InstantAPIError,
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7603
|
+
Va as InstantSolidDatabase,
|
|
7604
|
+
qa as InstantSolidRoom,
|
|
7605
|
+
Yi as StoreInterface,
|
|
7606
7606
|
pe as SyncTableCallbackEventType,
|
|
7607
|
-
|
|
7608
|
-
|
|
7607
|
+
Ja as createInstantRouteHandler,
|
|
7608
|
+
Ha as i,
|
|
7609
7609
|
P as id,
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7610
|
+
Ya as init,
|
|
7611
|
+
Si as lookup,
|
|
7612
|
+
Ga as tx
|
|
7613
7613
|
};
|