fetchium 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/development/QueryClient-D_e76rYS.js +2 -0
- package/dist/cjs/development/QueryClient-D_e76rYS.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-CjSajlTU.js → development/mutation-bq06T6Wg.js} +2 -2
- package/dist/cjs/{production/mutation-CjSajlTU.js.map → development/mutation-bq06T6Wg.js.map} +1 -1
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/rest/index.js.map +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/production/QueryClient-BPdrfgtE.js +2 -0
- package/dist/cjs/production/QueryClient-BPdrfgtE.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-OJNwoJcf.js → production/mutation-BVVlcTsK.js} +2 -2
- package/dist/cjs/{development/mutation-OJNwoJcf.js.map → production/mutation-BVVlcTsK.js.map} +1 -1
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/rest/index.js.map +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/esm/QueryResult.d.ts +5 -5
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/{QueryClient-DfxP7pt2.js → QueryClient-CkO_s9Uh.js} +347 -338
- package/dist/esm/development/QueryClient-CkO_s9Uh.js.map +1 -0
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-DZAq7Pbu.js → mutation-SZTEGudR.js} +2 -2
- package/dist/esm/development/{mutation-DZAq7Pbu.js.map → mutation-SZTEGudR.js.map} +1 -1
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +8 -8
- package/dist/esm/development/rest/index.js.map +1 -1
- package/dist/esm/development/topic/index.js +1 -1
- package/dist/esm/fieldRef.d.ts.map +1 -1
- package/dist/esm/production/{QueryClient-DrWSXg0y.js → QueryClient--PrsE8Kj.js} +286 -277
- package/dist/esm/production/QueryClient--PrsE8Kj.js.map +1 -0
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-B8dmX5lz.js → mutation-20F2qe90.js} +2 -2
- package/dist/esm/production/{mutation-B8dmX5lz.js.map → mutation-20F2qe90.js.map} +1 -1
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +8 -8
- package/dist/esm/production/rest/index.js.map +1 -1
- package/dist/esm/production/topic/index.js +1 -1
- package/dist/esm/rest/RESTQuery.d.ts +2 -0
- package/dist/esm/rest/RESTQuery.d.ts.map +1 -1
- package/dist/esm/rest/RESTQueryAdapter.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/docs/api/fetchium.md +16 -15
- package/plugin/docs/core/queries.md +10 -3
- package/plugin/docs/reference/rest-queries.md +1 -1
- package/dist/cjs/development/QueryClient-BefSCMoE.js +0 -2
- package/dist/cjs/development/QueryClient-BefSCMoE.js.map +0 -1
- package/dist/cjs/production/QueryClient-rbPYznie.js +0 -2
- package/dist/cjs/production/QueryClient-rbPYznie.js.map +0 -1
- package/dist/esm/development/QueryClient-DfxP7pt2.js.map +0 -1
- package/dist/esm/production/QueryClient-DrWSXg0y.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { notifier as
|
|
1
|
+
import { notifier as Z, relay as Lt, setScopeOwner as Ce, reactiveMethod as Se, signal as Ut, context as qt, getContext as Oe, reactiveSignal as st, task as Re, isSignal as xe, watcher as Ae } from "signalium";
|
|
2
2
|
import { registerCustomHash as Ne, hashValue as N, registerCustomSnapshot as De } from "signalium/utils";
|
|
3
|
-
import { d as
|
|
4
|
-
import { SyncQueryStore as Ie, MemoryPersistentStore as
|
|
3
|
+
import { d as Vt } from "./shared-DcuVH8Pf.js";
|
|
4
|
+
import { SyncQueryStore as Ie, MemoryPersistentStore as Fe } from "./stores/sync.js";
|
|
5
5
|
var K = /* @__PURE__ */ ((e) => (e.Always = "always", e.Online = "online", e.OfflineFirst = "offlineFirst", e))(K || {}), d = /* @__PURE__ */ ((e) => (e[e.UNDEFINED = 1] = "UNDEFINED", e[e.NULL = 2] = "NULL", e[e.NUMBER = 4] = "NUMBER", e[e.STRING = 8] = "STRING", e[e.BOOLEAN = 16] = "BOOLEAN", e[e.OBJECT = 32] = "OBJECT", e[e.ARRAY = 64] = "ARRAY", e[e.ID = 128] = "ID", e[e.RECORD = 256] = "RECORD", e[e.UNION = 512] = "UNION", e[e.ENTITY = 1024] = "ENTITY", e[e.HAS_FORMAT = 4096] = "HAS_FORMAT", e[e.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", e[e.PARSE_RESULT = 16384] = "PARSE_RESULT", e[e.LIVE = 32768] = "LIVE", e))(d || {});
|
|
6
|
-
const
|
|
7
|
-
var
|
|
6
|
+
const F = /* @__PURE__ */ Symbol("array"), k = /* @__PURE__ */ Symbol("record"), Kt = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
|
+
var ht = /* @__PURE__ */ ((e) => (e[e.Array = 0] = "Array", e[e.Value = 1] = "Value", e))(ht || {});
|
|
8
8
|
class Q {
|
|
9
9
|
type;
|
|
10
10
|
entityDefs;
|
|
@@ -42,12 +42,12 @@ class Q {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const S = /* @__PURE__ */ new WeakMap();
|
|
46
46
|
function P(e) {
|
|
47
|
-
return
|
|
47
|
+
return S.get(e);
|
|
48
48
|
}
|
|
49
|
-
var
|
|
50
|
-
class
|
|
49
|
+
var tt = /* @__PURE__ */ ((e) => (e[e.Query = 0] = "Query", e[e.Entity = 1] = "Entity", e))(tt || {});
|
|
50
|
+
class ke {
|
|
51
51
|
constructor(t, n, i) {
|
|
52
52
|
this._onEvict = n, this._intervalId = setInterval(this._tick, t * 6e4 * i);
|
|
53
53
|
}
|
|
@@ -88,7 +88,7 @@ class Me {
|
|
|
88
88
|
}
|
|
89
89
|
const { _buckets: r } = this;
|
|
90
90
|
let s = r.get(n);
|
|
91
|
-
s || (s = new
|
|
91
|
+
s || (s = new ke(n, this._onEvict, this._multiplier), r.set(n, s)), s.schedule(t, i);
|
|
92
92
|
}
|
|
93
93
|
cancel(t, n) {
|
|
94
94
|
if (n !== 1 / 0) {
|
|
@@ -121,8 +121,8 @@ class Te {
|
|
|
121
121
|
destroy() {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const z = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"),
|
|
125
|
-
function
|
|
124
|
+
const z = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"), yt = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), J = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Pe = /\[([^\]]+)\]/g;
|
|
125
|
+
function Bt(e) {
|
|
126
126
|
const t = {
|
|
127
127
|
[z]: !0,
|
|
128
128
|
[I]: e
|
|
@@ -139,19 +139,19 @@ const je = {
|
|
|
139
139
|
}
|
|
140
140
|
if (typeof t == "symbol") return;
|
|
141
141
|
const n = e[I];
|
|
142
|
-
return
|
|
142
|
+
return Bt([...n, t]);
|
|
143
143
|
},
|
|
144
144
|
has(e, t) {
|
|
145
145
|
return t === z || t === I;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
function
|
|
148
|
+
function Qt(e) {
|
|
149
149
|
return typeof e == "object" && e !== null && e[z] === !0;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Yt(e) {
|
|
152
152
|
return e[I];
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Gt(e) {
|
|
155
155
|
let t = !1;
|
|
156
156
|
return new Proxy(e, {
|
|
157
157
|
set(n, i, r) {
|
|
@@ -160,14 +160,14 @@ function Yt(e) {
|
|
|
160
160
|
get(n, i) {
|
|
161
161
|
if (t)
|
|
162
162
|
throw new Error("Definition proxy accessed after extraction. Avoid arrow functions that capture `this`.");
|
|
163
|
-
return i ===
|
|
163
|
+
return i === yt ? n : i === J ? () => {
|
|
164
164
|
t = !0;
|
|
165
|
-
} : typeof i == "symbol" ? n[i] :
|
|
165
|
+
} : typeof i == "symbol" ? n[i] : Bt([i]);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
function $e(e) {
|
|
170
|
-
const t = e[
|
|
170
|
+
const t = e[yt];
|
|
171
171
|
e[J]();
|
|
172
172
|
const n = {};
|
|
173
173
|
for (const s of Object.getOwnPropertyNames(t))
|
|
@@ -184,7 +184,7 @@ function $e(e) {
|
|
|
184
184
|
}
|
|
185
185
|
return { fields: n, methods: i };
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function pt(e, t) {
|
|
188
188
|
let n = t;
|
|
189
189
|
for (const i of e) {
|
|
190
190
|
if (n == null) return;
|
|
@@ -194,13 +194,13 @@ function yt(e, t) {
|
|
|
194
194
|
}
|
|
195
195
|
function Le(e, t) {
|
|
196
196
|
return e.replace(Pe, (n, i) => {
|
|
197
|
-
const r = i.split("."), s =
|
|
197
|
+
const r = i.split("."), s = pt(r, t);
|
|
198
198
|
return s != null ? encodeURIComponent(String(s)) : "";
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
function X(e, t) {
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
202
|
+
if (Qt(e))
|
|
203
|
+
return pt(Yt(e), t);
|
|
204
204
|
if (typeof e == "string")
|
|
205
205
|
return Le(e, t);
|
|
206
206
|
if (Array.isArray(e))
|
|
@@ -213,23 +213,23 @@ function X(e, t) {
|
|
|
213
213
|
}
|
|
214
214
|
return e;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function ot(e, t, n) {
|
|
217
217
|
const i = e.fields, r = e.methods, s = { params: t }, o = {};
|
|
218
218
|
for (const [a, c] of Object.entries(i))
|
|
219
219
|
o[a] = X(c, s);
|
|
220
|
-
o.params = t, o.context = n;
|
|
220
|
+
o.params = t, o.context = n, o.responseNotifier = Z();
|
|
221
221
|
for (const [a, c] of Object.entries(r))
|
|
222
222
|
o[a] = c.bind(o);
|
|
223
223
|
return o;
|
|
224
224
|
}
|
|
225
|
-
class
|
|
225
|
+
class gt {
|
|
226
226
|
static cache;
|
|
227
227
|
constructor() {
|
|
228
|
-
return
|
|
228
|
+
return Gt(this);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
let
|
|
231
|
+
const Ht = Object.entries, at = Object.keys;
|
|
232
|
+
let Wt = () => {
|
|
233
233
|
};
|
|
234
234
|
{
|
|
235
235
|
const t = (i, r) => {
|
|
@@ -249,7 +249,7 @@ let Ht = () => {
|
|
|
249
249
|
if (typeof i == "string") return i === r;
|
|
250
250
|
if (i instanceof Set && r instanceof Set)
|
|
251
251
|
return t(i, r);
|
|
252
|
-
if (i instanceof
|
|
252
|
+
if (i instanceof v && r instanceof v) {
|
|
253
253
|
const s = i.mask, o = r.mask;
|
|
254
254
|
if ((s & 65535) !== (o & 65535)) return !1;
|
|
255
255
|
const a = s >> 16, c = o >> 16;
|
|
@@ -266,20 +266,20 @@ let Ht = () => {
|
|
|
266
266
|
}
|
|
267
267
|
return !1;
|
|
268
268
|
};
|
|
269
|
-
|
|
269
|
+
Wt = (i, r, s, o) => {
|
|
270
270
|
if (!n(s, o))
|
|
271
271
|
throw new Error(
|
|
272
272
|
`[fetchium] Entity typename '${i}' has incompatible type for field '${r}' across different entity definitions`
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
return typeof e == "number" ? e | d.UNDEFINED : e instanceof
|
|
276
|
+
function xt(e) {
|
|
277
|
+
return typeof e == "number" ? e | d.UNDEFINED : e instanceof v ? (e.mask & d.UNDEFINED) !== 0 ? e : v.cloneWith(e, d.UNDEFINED) : e;
|
|
278
278
|
}
|
|
279
279
|
function At(e) {
|
|
280
|
-
return e instanceof
|
|
280
|
+
return e instanceof v && (e.mask & d.OBJECT) !== 0 && (e.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function zt(e, t, n) {
|
|
283
283
|
const i = /* @__PURE__ */ new Set();
|
|
284
284
|
for (const s of e)
|
|
285
285
|
if (s !== void 0)
|
|
@@ -292,17 +292,17 @@ function Wt(e, t, n) {
|
|
|
292
292
|
let f = !0;
|
|
293
293
|
for (const l of e) {
|
|
294
294
|
const u = l?.[s];
|
|
295
|
-
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !At(u) &&
|
|
295
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !At(u) && Wt(n, s, a, u), At(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
296
296
|
}
|
|
297
297
|
if (f && o > 0) {
|
|
298
|
-
const l =
|
|
299
|
-
r[s] = o < t ?
|
|
298
|
+
const l = zt(c, t, n), u = new v(d.OBJECT, l);
|
|
299
|
+
r[s] = o < t ? xt(u) : u;
|
|
300
300
|
} else
|
|
301
|
-
r[s] = o < t ?
|
|
301
|
+
r[s] = o < t ? xt(a) : a;
|
|
302
302
|
}
|
|
303
303
|
return r;
|
|
304
304
|
}
|
|
305
|
-
class
|
|
305
|
+
class v {
|
|
306
306
|
mask;
|
|
307
307
|
shape;
|
|
308
308
|
typenameField = void 0;
|
|
@@ -336,7 +336,7 @@ class m {
|
|
|
336
336
|
}
|
|
337
337
|
static merge(t) {
|
|
338
338
|
if (t.length === 1) return t[0];
|
|
339
|
-
const n = t.length, i = t.map((f) => f.shape), r = t[0].typenameValue ?? "(unknown)", s =
|
|
339
|
+
const n = t.length, i = t.map((f) => f.shape), r = t[0].typenameValue ?? "(unknown)", s = zt(i, n, r);
|
|
340
340
|
let o, a, c;
|
|
341
341
|
for (const f of t) {
|
|
342
342
|
if (o === void 0 && f.idField !== void 0)
|
|
@@ -347,7 +347,7 @@ class m {
|
|
|
347
347
|
);
|
|
348
348
|
a === void 0 && (a = f.typenameField), c === void 0 && (c = f.typenameValue);
|
|
349
349
|
}
|
|
350
|
-
return new
|
|
350
|
+
return new v(
|
|
351
351
|
d.ENTITY | d.OBJECT,
|
|
352
352
|
s,
|
|
353
353
|
void 0,
|
|
@@ -357,7 +357,7 @@ class m {
|
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
359
|
static cloneWith(t, n) {
|
|
360
|
-
const i = new
|
|
360
|
+
const i = new v(
|
|
361
361
|
n | t.mask,
|
|
362
362
|
t.shape,
|
|
363
363
|
t.values,
|
|
@@ -410,21 +410,21 @@ Ne(L, (e) => {
|
|
|
410
410
|
t += N(n);
|
|
411
411
|
return t >>> 0;
|
|
412
412
|
});
|
|
413
|
-
function
|
|
414
|
-
return new
|
|
413
|
+
function vt(e, t) {
|
|
414
|
+
return new v(e, t);
|
|
415
415
|
}
|
|
416
416
|
function qe(e) {
|
|
417
|
-
return
|
|
417
|
+
return vt(d.ARRAY, e);
|
|
418
418
|
}
|
|
419
419
|
function Ve(e) {
|
|
420
|
-
return
|
|
420
|
+
return vt(d.RECORD | d.OBJECT, e);
|
|
421
421
|
}
|
|
422
422
|
function Ke(e) {
|
|
423
|
-
return
|
|
423
|
+
return vt(d.PARSE_RESULT, e);
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function Jt(e, t) {
|
|
426
426
|
let n = e, i, r, s;
|
|
427
|
-
for (const [o, a] of
|
|
427
|
+
for (const [o, a] of Ht(t))
|
|
428
428
|
switch (typeof a) {
|
|
429
429
|
case "number":
|
|
430
430
|
if ((a & d.ID) !== 0) {
|
|
@@ -444,12 +444,12 @@ function zt(e, t) {
|
|
|
444
444
|
a.mask & d.LIVE && (n |= d.LIVE);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
|
-
return new
|
|
447
|
+
return new v(n, t, void 0, r, s, i);
|
|
448
448
|
}
|
|
449
449
|
function Be(e) {
|
|
450
|
-
return
|
|
450
|
+
return Jt(d.OBJECT, e);
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function Nt(e, t, n) {
|
|
453
453
|
const i = e.mask;
|
|
454
454
|
if ((i & d.UNION) !== 0) {
|
|
455
455
|
const r = e;
|
|
@@ -462,7 +462,7 @@ function xt(e, t, n) {
|
|
|
462
462
|
}
|
|
463
463
|
const s = r.shape;
|
|
464
464
|
if (s !== void 0)
|
|
465
|
-
for (const o of [...
|
|
465
|
+
for (const o of [...at(s), F, k]) {
|
|
466
466
|
const a = s[o];
|
|
467
467
|
if (t[o] !== void 0 && t[o] !== a)
|
|
468
468
|
throw new Error(
|
|
@@ -471,13 +471,13 @@ function xt(e, t, n) {
|
|
|
471
471
|
t[o] = a;
|
|
472
472
|
}
|
|
473
473
|
} else if ((i & d.ARRAY) !== 0) {
|
|
474
|
-
if (t[
|
|
474
|
+
if (t[F] !== void 0)
|
|
475
475
|
throw new Error("Array shape already defined");
|
|
476
|
-
t[
|
|
476
|
+
t[F] = e.shape;
|
|
477
477
|
} else if ((i & d.RECORD) !== 0) {
|
|
478
|
-
if (t[
|
|
478
|
+
if (t[k] !== void 0)
|
|
479
479
|
throw new Error("Record shape already defined");
|
|
480
|
-
t[
|
|
480
|
+
t[k] = e.shape;
|
|
481
481
|
} else {
|
|
482
482
|
const r = e.typenameField, s = e.typenameValue;
|
|
483
483
|
if (s === void 0)
|
|
@@ -510,33 +510,33 @@ function mt(...e) {
|
|
|
510
510
|
r = l;
|
|
511
511
|
continue;
|
|
512
512
|
}
|
|
513
|
-
i === 2 && (o = /* @__PURE__ */ Object.create(null), a =
|
|
513
|
+
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Nt(r, o, a)), a = Nt(l, o, a);
|
|
514
514
|
}
|
|
515
515
|
if (i === 0)
|
|
516
|
-
return s === void 0 ? n : n === 0 ? s : new
|
|
516
|
+
return s === void 0 ? n : n === 0 ? s : new v(n | d.UNION, void 0, s);
|
|
517
517
|
if (i === 1)
|
|
518
|
-
return
|
|
518
|
+
return v.cloneWith(r, n);
|
|
519
519
|
const f = n | c | d.UNION;
|
|
520
|
-
return new
|
|
520
|
+
return new v(f, o, s, a);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function _t(e, t, n) {
|
|
523
523
|
const i = e;
|
|
524
524
|
if (typeof i == "number")
|
|
525
525
|
return i | t;
|
|
526
526
|
if (i instanceof Set)
|
|
527
527
|
return mt(e, t);
|
|
528
528
|
let r = n.get(i);
|
|
529
|
-
return r === void 0 && (r =
|
|
529
|
+
return r === void 0 && (r = v.cloneWith(i, t), n.set(i, r)), r;
|
|
530
530
|
}
|
|
531
531
|
const Qe = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), Ge = /* @__PURE__ */ new WeakMap();
|
|
532
532
|
function He(e) {
|
|
533
|
-
return
|
|
533
|
+
return _t(e, d.UNDEFINED | d.NULL, Ge);
|
|
534
534
|
}
|
|
535
535
|
function We(e) {
|
|
536
|
-
return
|
|
536
|
+
return _t(e, d.UNDEFINED, Qe);
|
|
537
537
|
}
|
|
538
538
|
function ze(e) {
|
|
539
|
-
return
|
|
539
|
+
return _t(e, d.NULL, Ye);
|
|
540
540
|
}
|
|
541
541
|
function Je(e) {
|
|
542
542
|
return e;
|
|
@@ -544,43 +544,43 @@ function Je(e) {
|
|
|
544
544
|
function Xe(e) {
|
|
545
545
|
return /* @__PURE__ */ new Set([e]);
|
|
546
546
|
}
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
const
|
|
547
|
+
const Xt = ((...e) => new Set(e));
|
|
548
|
+
Xt.caseInsensitive = (...e) => new L(e);
|
|
549
|
+
const wt = 16;
|
|
550
550
|
let Ze = 0;
|
|
551
|
-
const
|
|
551
|
+
const ct = [], Zt = [], te = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map(), et = /* @__PURE__ */ new WeakSet();
|
|
552
552
|
class Y {
|
|
553
553
|
_raw;
|
|
554
554
|
_formatted;
|
|
555
555
|
_parsed;
|
|
556
556
|
_formatId;
|
|
557
557
|
constructor(t, n, i) {
|
|
558
|
-
this._raw = t, this._formatId = n, i ? (this._formatted =
|
|
558
|
+
this._raw = t, this._formatId = n, i ? (this._formatted = ct[n](t), this._parsed = !0) : this._parsed = !1, et.add(this);
|
|
559
559
|
}
|
|
560
560
|
getValue() {
|
|
561
|
-
return this._parsed || (this._formatted =
|
|
561
|
+
return this._parsed || (this._formatted = ct[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
562
562
|
}
|
|
563
563
|
toJSON() {
|
|
564
|
-
return this._parsed ?
|
|
564
|
+
return this._parsed ? Zt[this._formatId](this._formatted) : this._raw;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
function tn(e) {
|
|
568
|
-
const t =
|
|
568
|
+
const t = te.get(e);
|
|
569
569
|
if (t === void 0)
|
|
570
570
|
throw new Error(`Format ${e} not registered`);
|
|
571
571
|
return t;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
const t = e >>
|
|
575
|
-
return
|
|
573
|
+
function Dt(e) {
|
|
574
|
+
const t = e >> wt;
|
|
575
|
+
return ee.get(t);
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function ne(e, t, n, i, r) {
|
|
578
578
|
const s = Ze++;
|
|
579
|
-
|
|
580
|
-
const o = r?.eager ?? !0, c = s <<
|
|
581
|
-
|
|
579
|
+
ct[s] = n, Zt[s] = i, ee.set(s, e);
|
|
580
|
+
const o = r?.eager ?? !0, c = s << wt | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
581
|
+
te.set(e, c);
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
ne(
|
|
584
584
|
"date",
|
|
585
585
|
d.STRING,
|
|
586
586
|
(e) => {
|
|
@@ -597,7 +597,7 @@ ee(
|
|
|
597
597
|
return `${t}-${n}-${i}`;
|
|
598
598
|
}
|
|
599
599
|
);
|
|
600
|
-
|
|
600
|
+
ne(
|
|
601
601
|
"date-time",
|
|
602
602
|
d.STRING,
|
|
603
603
|
(e) => {
|
|
@@ -608,15 +608,15 @@ ee(
|
|
|
608
608
|
},
|
|
609
609
|
(e) => e.toISOString()
|
|
610
610
|
);
|
|
611
|
-
const
|
|
611
|
+
const It = /* @__PURE__ */ new WeakMap();
|
|
612
612
|
function $(e) {
|
|
613
|
-
let t =
|
|
613
|
+
let t = It.get(e);
|
|
614
614
|
if (t === void 0) {
|
|
615
|
-
const n = new e(), i = n[
|
|
615
|
+
const n = new e(), i = n[yt] ?? n;
|
|
616
616
|
n[J] && n[J]();
|
|
617
617
|
const r = {};
|
|
618
|
-
for (const [f, l] of
|
|
619
|
-
if (!(typeof l == "number" || typeof l == "string" || l instanceof Set || l instanceof
|
|
618
|
+
for (const [f, l] of Ht(i)) {
|
|
619
|
+
if (!(typeof l == "number" || typeof l == "string" || l instanceof Set || l instanceof v || l instanceof L))
|
|
620
620
|
throw new Error(
|
|
621
621
|
`[fetchium] Entity '${e.name}' field '${f}' has an invalid type definition. All entity fields must be type definitions (e.g. t.string, t.number, t.entity(...), etc). Got: ${typeof l == "object" ? l?.constructor?.name ?? typeof l : typeof l}`
|
|
622
622
|
);
|
|
@@ -625,9 +625,9 @@ function $(e) {
|
|
|
625
625
|
const s = Object.getPrototypeOf(e.prototype);
|
|
626
626
|
if (s != null) {
|
|
627
627
|
const f = s.constructor;
|
|
628
|
-
if (f !==
|
|
628
|
+
if (f !== gt && typeof f == "function") {
|
|
629
629
|
const u = $(f).shape;
|
|
630
|
-
for (const h of
|
|
630
|
+
for (const h of at(u))
|
|
631
631
|
if (h in r && r[h] !== u[h])
|
|
632
632
|
throw new Error(`Cannot extend: field '${h}' already exists in type definition`);
|
|
633
633
|
}
|
|
@@ -635,16 +635,16 @@ function $(e) {
|
|
|
635
635
|
const o = {}, a = e.prototype;
|
|
636
636
|
for (const f of Object.getOwnPropertyNames(a))
|
|
637
637
|
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
638
|
-
t =
|
|
638
|
+
t = Jt(d.ENTITY | d.OBJECT, r), t._entityClass = e, at(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
639
639
|
const c = e;
|
|
640
|
-
c.cache && (t._entityCache = c.cache),
|
|
640
|
+
c.cache && (t._entityCache = c.cache), It.set(e, t);
|
|
641
641
|
}
|
|
642
642
|
return t;
|
|
643
643
|
}
|
|
644
644
|
function en(e) {
|
|
645
645
|
return $(e);
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function ie(e, t) {
|
|
648
648
|
if (t == null) return;
|
|
649
649
|
const n = /* @__PURE__ */ new Map();
|
|
650
650
|
if (Array.isArray(t))
|
|
@@ -667,22 +667,22 @@ function ne(e, t) {
|
|
|
667
667
|
}
|
|
668
668
|
return n.size > 0 ? n : void 0;
|
|
669
669
|
}
|
|
670
|
-
function
|
|
670
|
+
function re(e) {
|
|
671
671
|
return Array.isArray(e) ? e.map((t) => $(t)) : [$(e)];
|
|
672
672
|
}
|
|
673
673
|
function nn(e, t) {
|
|
674
|
-
const n =
|
|
674
|
+
const n = re(e), i = n.length === 1 ? n[0] : mt(...n.map((o) => o)), r = d.ARRAY | d.LIVE, s = new v(r, i);
|
|
675
675
|
return s._liveConfig = Q.array(
|
|
676
676
|
n,
|
|
677
|
-
|
|
677
|
+
ie(n, t?.constraints),
|
|
678
678
|
t?.sort
|
|
679
679
|
), s;
|
|
680
680
|
}
|
|
681
681
|
function rn(e, t, n) {
|
|
682
|
-
const i =
|
|
682
|
+
const i = re(t), r = e, s = d.LIVE, o = new v(s, void 0);
|
|
683
683
|
return o._liveConfig = Q.value(
|
|
684
684
|
i,
|
|
685
|
-
|
|
685
|
+
ie(i, n?.constraints),
|
|
686
686
|
r,
|
|
687
687
|
n.onCreate,
|
|
688
688
|
n.onUpdate,
|
|
@@ -693,7 +693,7 @@ const sn = {
|
|
|
693
693
|
format: tn,
|
|
694
694
|
typename: Je,
|
|
695
695
|
const: Xe,
|
|
696
|
-
enum:
|
|
696
|
+
enum: Xt,
|
|
697
697
|
id: d.ID | d.STRING | d.NUMBER,
|
|
698
698
|
string: d.STRING,
|
|
699
699
|
number: d.NUMBER,
|
|
@@ -723,7 +723,7 @@ function B(e) {
|
|
|
723
723
|
return String(e);
|
|
724
724
|
if (typeof e == "number") {
|
|
725
725
|
if ((e & d.HAS_FORMAT) !== 0) {
|
|
726
|
-
const r =
|
|
726
|
+
const r = Dt(e);
|
|
727
727
|
if (r)
|
|
728
728
|
return `"${r}"`;
|
|
729
729
|
}
|
|
@@ -739,12 +739,12 @@ function B(e) {
|
|
|
739
739
|
i.push(o);
|
|
740
740
|
}
|
|
741
741
|
if (n.shape !== void 0) {
|
|
742
|
-
n.shape[
|
|
742
|
+
n.shape[F] !== void 0 && i.push(`Array<${B(n.shape[F])}>`), n.shape[k] !== void 0 && i.push(`Record<string, ${B(n.shape[k])}>`);
|
|
743
743
|
for (const [s, o] of Object.entries(n.shape))
|
|
744
|
-
s !==
|
|
744
|
+
s !== F && s !== k && i.push(s);
|
|
745
745
|
}
|
|
746
746
|
if (t = n.mask, (t & d.HAS_FORMAT) !== 0) {
|
|
747
|
-
const s =
|
|
747
|
+
const s = Dt(t);
|
|
748
748
|
s && i.push(`"${s}"`);
|
|
749
749
|
}
|
|
750
750
|
return t & d.UNDEFINED && i.push("undefined"), t & d.NULL && i.push("null"), t & d.NUMBER && i.push("number"), t & d.STRING && i.push("string"), t & d.BOOLEAN && i.push("boolean"), i.length === 0 ? "union" : i.join(" | ");
|
|
@@ -770,8 +770,8 @@ function V(e, t, n) {
|
|
|
770
770
|
`Validation error at ${e}: expected ${B(t)}, got ${typeof n == "object" ? n === null ? "null" : Array.isArray(n) ? "array" : "object" : typeof n}`
|
|
771
771
|
);
|
|
772
772
|
}
|
|
773
|
-
const
|
|
774
|
-
function
|
|
773
|
+
const se = Array.isArray;
|
|
774
|
+
function Ft(e) {
|
|
775
775
|
if (e === null) return d.NULL;
|
|
776
776
|
switch (typeof e) {
|
|
777
777
|
case "number":
|
|
@@ -783,7 +783,7 @@ function It(e) {
|
|
|
783
783
|
case "undefined":
|
|
784
784
|
return d.UNDEFINED;
|
|
785
785
|
case "object":
|
|
786
|
-
return
|
|
786
|
+
return se(e) ? d.ARRAY : d.OBJECT;
|
|
787
787
|
default:
|
|
788
788
|
throw new Error(`Invalid type: ${typeof e}`);
|
|
789
789
|
}
|
|
@@ -794,7 +794,7 @@ function $n(e) {
|
|
|
794
794
|
function j(e) {
|
|
795
795
|
if (e === null || typeof e != "object")
|
|
796
796
|
return e;
|
|
797
|
-
if (
|
|
797
|
+
if (se(e))
|
|
798
798
|
return e.map((n) => j(n));
|
|
799
799
|
if (e instanceof Date)
|
|
800
800
|
return new Date(e.getTime());
|
|
@@ -815,9 +815,9 @@ function j(e) {
|
|
|
815
815
|
t[n] = j(e[n]);
|
|
816
816
|
return t;
|
|
817
817
|
}
|
|
818
|
-
const
|
|
818
|
+
const Et = Object.entries, on = () => {
|
|
819
819
|
};
|
|
820
|
-
class
|
|
820
|
+
class ft {
|
|
821
821
|
queryClient = void 0;
|
|
822
822
|
preloadedEntities = void 0;
|
|
823
823
|
warn = on;
|
|
@@ -830,14 +830,14 @@ class at {
|
|
|
830
830
|
this.queryClient = t, this.preloadedEntities = n, this.warn = i, this.isPartialEvent = r, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
function
|
|
833
|
+
function oe(e, t, n) {
|
|
834
834
|
return M(e, t, n, "");
|
|
835
835
|
}
|
|
836
836
|
function an(e, t, n) {
|
|
837
|
-
return
|
|
837
|
+
return bt(e, t, n);
|
|
838
838
|
}
|
|
839
839
|
function kt(e, t, n, i) {
|
|
840
|
-
const r = e >>
|
|
840
|
+
const r = e >> wt;
|
|
841
841
|
if ((e & d.IS_EAGER_FORMAT) !== 0)
|
|
842
842
|
try {
|
|
843
843
|
return new Y(t, r, !0);
|
|
@@ -871,7 +871,7 @@ function M(e, t, n, i) {
|
|
|
871
871
|
return e;
|
|
872
872
|
}
|
|
873
873
|
if (typeof r == "number") {
|
|
874
|
-
const c =
|
|
874
|
+
const c = Ft(e);
|
|
875
875
|
if ((r & c) === 0) {
|
|
876
876
|
if ((r & d.UNDEFINED) !== 0) {
|
|
877
877
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
@@ -882,7 +882,7 @@ function M(e, t, n, i) {
|
|
|
882
882
|
return (r & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? kt(r, e, n, i) : e;
|
|
883
883
|
}
|
|
884
884
|
const s = r.mask, o = r._liveConfig;
|
|
885
|
-
if (o !== void 0 && o.type ===
|
|
885
|
+
if (o !== void 0 && o.type === ht.Value)
|
|
886
886
|
return o.valueType !== void 0 ? M(e, o.valueType, n, i) : e;
|
|
887
887
|
if ((s & d.PARSE_RESULT) !== 0)
|
|
888
888
|
try {
|
|
@@ -890,7 +890,7 @@ function M(e, t, n, i) {
|
|
|
890
890
|
} catch (c) {
|
|
891
891
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
892
892
|
}
|
|
893
|
-
const a =
|
|
893
|
+
const a = Ft(e);
|
|
894
894
|
if ((s & a) === 0 && !r.values?.has(e)) {
|
|
895
895
|
if ((s & d.UNDEFINED) !== 0) {
|
|
896
896
|
n.warn("Invalid value for optional type, defaulting to undefined", { value: e, path: i });
|
|
@@ -898,29 +898,29 @@ function M(e, t, n, i) {
|
|
|
898
898
|
}
|
|
899
899
|
throw V(i, s, e);
|
|
900
900
|
}
|
|
901
|
-
return a < d.OBJECT ? (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? kt(s, e, n, i) : e : (s & d.UNION) !== 0 ? cn(a, e, r, n, i) : a === d.ARRAY ?
|
|
901
|
+
return a < d.OBJECT ? (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ? kt(s, e, n, i) : e : (s & d.UNION) !== 0 ? cn(a, e, r, n, i) : a === d.ARRAY ? ae(e, r.shape, n, i) : (s & d.RECORD) !== 0 ? ce(e, r.shape, n, i) : (s & d.ENTITY) !== 0 && n.queryClient !== void 0 ? bt(e, r, n) : fe(e, r, n, i);
|
|
902
902
|
}
|
|
903
903
|
function cn(e, t, n, i, r) {
|
|
904
904
|
if (e === d.ARRAY) {
|
|
905
|
-
const s = n.shape[
|
|
906
|
-
return s === void 0 || typeof s == "number" ? t :
|
|
905
|
+
const s = n.shape[F];
|
|
906
|
+
return s === void 0 || typeof s == "number" ? t : ae(t, s, i, r);
|
|
907
907
|
} else {
|
|
908
908
|
const s = n.typenameField, o = s ? t[s] : void 0;
|
|
909
909
|
if (o === void 0 || typeof o != "string") {
|
|
910
|
-
const c = n.shape[
|
|
910
|
+
const c = n.shape[k];
|
|
911
911
|
if (c === void 0)
|
|
912
912
|
throw new Error(
|
|
913
913
|
`Typename field '${s}' is required for union discrimination but was not found in the data`
|
|
914
914
|
);
|
|
915
|
-
return
|
|
915
|
+
return ce(t, c, i, r);
|
|
916
916
|
}
|
|
917
917
|
const a = n.shape[o];
|
|
918
918
|
if (a === void 0 || typeof a == "number")
|
|
919
919
|
throw new Error(`Unknown typename '${o}' in union`);
|
|
920
|
-
return a.mask & d.ENTITY && i.queryClient !== void 0 ?
|
|
920
|
+
return a.mask & d.ENTITY && i.queryClient !== void 0 ? bt(t, a, i) : fe(t, a, i, r);
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function ae(e, t, n, i) {
|
|
924
924
|
const r = [];
|
|
925
925
|
for (let s = 0; s < e.length; s++)
|
|
926
926
|
try {
|
|
@@ -934,20 +934,20 @@ function oe(e, t, n, i) {
|
|
|
934
934
|
}
|
|
935
935
|
return r;
|
|
936
936
|
}
|
|
937
|
-
function
|
|
938
|
-
for (const [r, s] of
|
|
937
|
+
function ce(e, t, n, i) {
|
|
938
|
+
for (const [r, s] of Et(e))
|
|
939
939
|
e[r] = M(s, t, n, `${i}["${r}"]`);
|
|
940
940
|
return e;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
if (
|
|
942
|
+
function fe(e, t, n, i) {
|
|
943
|
+
if (S.has(e))
|
|
944
944
|
return e;
|
|
945
945
|
const r = t.shape;
|
|
946
|
-
for (const [s, o] of
|
|
946
|
+
for (const [s, o] of Et(r))
|
|
947
947
|
e[s] = M(e[s], o, n, `${i}.${s}`);
|
|
948
948
|
return e;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function bt(e, t, n) {
|
|
951
951
|
const i = n.queryClient, r = n.preloadedEntities;
|
|
952
952
|
let s, o;
|
|
953
953
|
if (r !== void 0)
|
|
@@ -977,7 +977,7 @@ function Et(e, t, n) {
|
|
|
977
977
|
};
|
|
978
978
|
n.seen.set(c, u), n.seenByKey.set(s, u);
|
|
979
979
|
const h = `[[${t.typenameValue}:${o}]]`, g = t.shape;
|
|
980
|
-
for (const [p, _] of
|
|
980
|
+
for (const [p, _] of Et(g))
|
|
981
981
|
l && !(p in e) || (c[p] = M(e[p], _, n, `${h}.${p}`));
|
|
982
982
|
return c;
|
|
983
983
|
}
|
|
@@ -989,7 +989,7 @@ function un(e, t, n) {
|
|
|
989
989
|
for (const i of Object.keys(t)) {
|
|
990
990
|
if (i === n) continue;
|
|
991
991
|
const r = t[i];
|
|
992
|
-
if (r instanceof
|
|
992
|
+
if (r instanceof v) {
|
|
993
993
|
if ((r.mask & d.UNDEFINED) !== 0) continue;
|
|
994
994
|
if (!(i in e) || e[i] === void 0) return !1;
|
|
995
995
|
} else if (typeof r == "number") {
|
|
@@ -1000,10 +1000,10 @@ function un(e, t, n) {
|
|
|
1000
1000
|
return !0;
|
|
1001
1001
|
}
|
|
1002
1002
|
const dn = Object.prototype, W = /* @__PURE__ */ new WeakMap();
|
|
1003
|
-
function
|
|
1003
|
+
function A(e) {
|
|
1004
1004
|
if (typeof e != "object" || e === null) return e;
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1005
|
+
if (et.has(e)) return A(e.getValue());
|
|
1006
|
+
if (S.has(e)) return e;
|
|
1007
1007
|
if (Array.isArray(e)) {
|
|
1008
1008
|
let t = W.get(e);
|
|
1009
1009
|
return t === void 0 && (t = new Proxy(e, ln), W.set(e, t)), t;
|
|
@@ -1019,7 +1019,7 @@ const ln = {
|
|
|
1019
1019
|
if (typeof t == "string") {
|
|
1020
1020
|
const i = Number(t);
|
|
1021
1021
|
if (Number.isInteger(i) && i >= 0 && i < e.length)
|
|
1022
|
-
return
|
|
1022
|
+
return A(e[i]);
|
|
1023
1023
|
}
|
|
1024
1024
|
return Reflect.get(e, t, n);
|
|
1025
1025
|
},
|
|
@@ -1031,7 +1031,7 @@ const ln = {
|
|
|
1031
1031
|
}
|
|
1032
1032
|
}, hn = {
|
|
1033
1033
|
get(e, t, n) {
|
|
1034
|
-
return typeof t == "string" ?
|
|
1034
|
+
return typeof t == "string" ? A(e[t]) : Reflect.get(e, t, n);
|
|
1035
1035
|
},
|
|
1036
1036
|
set() {
|
|
1037
1037
|
throw new Error("Cannot mutate a read-only object");
|
|
@@ -1060,7 +1060,7 @@ const ln = {
|
|
|
1060
1060
|
return o ? a : s;
|
|
1061
1061
|
};
|
|
1062
1062
|
De(
|
|
1063
|
-
|
|
1063
|
+
gt,
|
|
1064
1064
|
yn
|
|
1065
1065
|
);
|
|
1066
1066
|
class pn {
|
|
@@ -1081,7 +1081,7 @@ class pn {
|
|
|
1081
1081
|
_extraMethods;
|
|
1082
1082
|
_extraGetters;
|
|
1083
1083
|
constructor(t, n, i, r, s, o) {
|
|
1084
|
-
this._notifier =
|
|
1084
|
+
this._notifier = Z(), this._queryClient = o, this.key = t, this.typename = n, this.id = i, this.idField = r, this.data = s, this.entityRefs = void 0;
|
|
1085
1085
|
}
|
|
1086
1086
|
retain() {
|
|
1087
1087
|
this.refCount++;
|
|
@@ -1093,7 +1093,7 @@ class pn {
|
|
|
1093
1093
|
if (this.refCount < 0)
|
|
1094
1094
|
throw new Error(`Entity ${this.typename}:${this.id} released more times than retained`);
|
|
1095
1095
|
const t = this._entityCache?.gcTime;
|
|
1096
|
-
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t,
|
|
1096
|
+
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, tt.Entity) : this.evict();
|
|
1097
1097
|
}
|
|
1098
1098
|
evict() {
|
|
1099
1099
|
const t = this.liveCollections.slice();
|
|
@@ -1127,7 +1127,7 @@ class pn {
|
|
|
1127
1127
|
getProxy(t) {
|
|
1128
1128
|
const n = t;
|
|
1129
1129
|
let i = this._proxies.get(n);
|
|
1130
|
-
return i === void 0 && (i =
|
|
1130
|
+
return i === void 0 && (i = vn(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(n, i)), i;
|
|
1131
1131
|
}
|
|
1132
1132
|
get proxy() {
|
|
1133
1133
|
return this._proxies.values().next().value;
|
|
@@ -1149,34 +1149,34 @@ function gn(e, t, n) {
|
|
|
1149
1149
|
const i = [];
|
|
1150
1150
|
for (const r of e) {
|
|
1151
1151
|
if (typeof r != "object" || r === null) continue;
|
|
1152
|
-
const s =
|
|
1152
|
+
const s = S.get(r);
|
|
1153
1153
|
if (s === void 0) continue;
|
|
1154
1154
|
const o = n.entityMap.getEntity(s);
|
|
1155
1155
|
o !== void 0 && o.satisfiesDef(t) && i.push(r);
|
|
1156
1156
|
}
|
|
1157
1157
|
return i;
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1160
|
-
const s = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype :
|
|
1159
|
+
function vn(e, t, n, i, r) {
|
|
1160
|
+
const s = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype : gt.prototype, u = n.typenameField, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = () => ({ __entityRef: t });
|
|
1161
1161
|
let _;
|
|
1162
|
-
f?.hasSubscribe && a && "__subscribe" in a && (_ =
|
|
1162
|
+
f?.hasSubscribe && a && "__subscribe" in a && (_ = Lt((E) => {
|
|
1163
1163
|
const y = (w) => {
|
|
1164
1164
|
w.__eventSource = t, r.applyMutationEvent(w);
|
|
1165
|
-
}, b = a.__subscribe.call(
|
|
1166
|
-
return E.value =
|
|
1165
|
+
}, b = a.__subscribe.call(m, y);
|
|
1166
|
+
return E.value = m, b;
|
|
1167
1167
|
}));
|
|
1168
|
-
let
|
|
1168
|
+
let m;
|
|
1169
1169
|
if (u && !(u in s))
|
|
1170
1170
|
throw new Error(`typenameField "${u}" must be declared in the entity shape`);
|
|
1171
|
-
const
|
|
1172
|
-
if (
|
|
1171
|
+
const O = Object.keys(s);
|
|
1172
|
+
if (O.includes("__typename") || O.push("__typename"), a)
|
|
1173
1173
|
for (const E of Object.keys(a))
|
|
1174
|
-
|
|
1175
|
-
let T, R =
|
|
1174
|
+
O.includes(E) || O.push(E);
|
|
1175
|
+
let T, R = O;
|
|
1176
1176
|
function U() {
|
|
1177
1177
|
const E = e._extraMethods;
|
|
1178
1178
|
if (E !== T) {
|
|
1179
|
-
if (T = E, R =
|
|
1179
|
+
if (T = E, R = O.slice(), E !== void 0)
|
|
1180
1180
|
for (const b of Object.keys(E))
|
|
1181
1181
|
R.includes(b) || R.push(b);
|
|
1182
1182
|
const y = e._extraGetters;
|
|
@@ -1199,40 +1199,40 @@ function mn(e, t, n, i, r) {
|
|
|
1199
1199
|
const D = e._extraGetters;
|
|
1200
1200
|
if (D !== void 0 && y in D)
|
|
1201
1201
|
return D[y]();
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1202
|
+
const x = e._extraMethods;
|
|
1203
|
+
if (x !== void 0 && y in x) {
|
|
1204
1204
|
let C = h.get(y);
|
|
1205
|
-
return C || (C =
|
|
1205
|
+
return C || (C = x[y].bind(m), h.set(y, C)), C;
|
|
1206
1206
|
}
|
|
1207
1207
|
if (a && y in a) {
|
|
1208
1208
|
let C = h.get(y);
|
|
1209
|
-
return C || (C =
|
|
1209
|
+
return C || (C = Se(m, a[y].bind(m)), h.set(y, C)), C;
|
|
1210
1210
|
}
|
|
1211
1211
|
}
|
|
1212
1212
|
const w = e.data[y];
|
|
1213
|
-
if (typeof w == "object" && w !== null &&
|
|
1214
|
-
return
|
|
1213
|
+
if (typeof w == "object" && w !== null && et.has(w))
|
|
1214
|
+
return A(w.getValue());
|
|
1215
1215
|
if (Array.isArray(w) && typeof y == "string") {
|
|
1216
1216
|
const D = s[y];
|
|
1217
|
-
if (D instanceof
|
|
1218
|
-
const
|
|
1219
|
-
if (
|
|
1220
|
-
const C =
|
|
1217
|
+
if (D instanceof v && (D.mask & d.ARRAY) !== 0) {
|
|
1218
|
+
const x = D.shape;
|
|
1219
|
+
if (x instanceof v && (x.mask & d.ENTITY) !== 0) {
|
|
1220
|
+
const C = x.typenameValue;
|
|
1221
1221
|
if (C !== void 0) {
|
|
1222
1222
|
const Ot = r.getEntityDefsForTypename(C);
|
|
1223
1223
|
if (Ot !== void 0 && Ot.length > 1) {
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
return
|
|
1227
|
-
const
|
|
1228
|
-
return g.set(y, { source: w, filtered:
|
|
1224
|
+
const nt = g.get(y);
|
|
1225
|
+
if (nt !== void 0 && nt.source === w)
|
|
1226
|
+
return A(nt.filtered);
|
|
1227
|
+
const Rt = gn(w, x, r);
|
|
1228
|
+
return g.set(y, { source: w, filtered: Rt }), A(Rt);
|
|
1229
1229
|
}
|
|
1230
1230
|
}
|
|
1231
1231
|
}
|
|
1232
1232
|
}
|
|
1233
|
-
return
|
|
1233
|
+
return A(w);
|
|
1234
1234
|
}
|
|
1235
|
-
return
|
|
1235
|
+
return A(w);
|
|
1236
1236
|
},
|
|
1237
1237
|
set() {
|
|
1238
1238
|
throw new Error("Entity properties are read-only");
|
|
@@ -1254,22 +1254,22 @@ function mn(e, t, n, i, r) {
|
|
|
1254
1254
|
if (y === "__typename")
|
|
1255
1255
|
return { enumerable: !0, configurable: !0, value: e.typename, writable: !1 };
|
|
1256
1256
|
if (y in s)
|
|
1257
|
-
return { enumerable: !0, configurable: !0, value: q.get(E, y,
|
|
1257
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1258
1258
|
if (typeof y == "string") {
|
|
1259
1259
|
const b = e._extraGetters;
|
|
1260
1260
|
if (b && y in b)
|
|
1261
|
-
return { enumerable: !0, configurable: !0, value: q.get(E, y,
|
|
1261
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1262
1262
|
const w = e._extraMethods;
|
|
1263
1263
|
if (w && y in w)
|
|
1264
|
-
return { enumerable: !0, configurable: !0, value: q.get(E, y,
|
|
1264
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1265
1265
|
if (a && y in a)
|
|
1266
|
-
return { enumerable: !1, configurable: !0, value: q.get(E, y,
|
|
1266
|
+
return { enumerable: !1, configurable: !0, value: q.get(E, y, m), writable: !1 };
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
|
-
return
|
|
1270
|
+
return m = new Proxy({}, q), S.set(m, t), Ce(m, r), m;
|
|
1271
1271
|
}
|
|
1272
|
-
class
|
|
1272
|
+
class mn {
|
|
1273
1273
|
instances = /* @__PURE__ */ new Map();
|
|
1274
1274
|
persistEntity;
|
|
1275
1275
|
constructor(t) {
|
|
@@ -1307,13 +1307,13 @@ class vn {
|
|
|
1307
1307
|
this.persistEntity(t.key, t.data, n);
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
class
|
|
1310
|
+
class ue {
|
|
1311
1311
|
onlineSignal;
|
|
1312
1312
|
manualOverride = void 0;
|
|
1313
1313
|
eventListenersAttached = !1;
|
|
1314
1314
|
constructor(t) {
|
|
1315
1315
|
const n = t ?? this.detectOnlineStatus();
|
|
1316
|
-
this.onlineSignal =
|
|
1316
|
+
this.onlineSignal = Ut(n), this.canAttachListeners() && this.attachEventListeners();
|
|
1317
1317
|
}
|
|
1318
1318
|
/**
|
|
1319
1319
|
* Returns true if the network is currently online
|
|
@@ -1371,8 +1371,8 @@ class fe {
|
|
|
1371
1371
|
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
class
|
|
1375
|
-
static onlineSignal =
|
|
1374
|
+
class de {
|
|
1375
|
+
static onlineSignal = Ut(!0);
|
|
1376
1376
|
get isOnline() {
|
|
1377
1377
|
return !0;
|
|
1378
1378
|
}
|
|
@@ -1381,13 +1381,13 @@ class ue {
|
|
|
1381
1381
|
clearManualOverride() {
|
|
1382
1382
|
}
|
|
1383
1383
|
getOnlineSignal() {
|
|
1384
|
-
return
|
|
1384
|
+
return de.onlineSignal;
|
|
1385
1385
|
}
|
|
1386
1386
|
destroy() {
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
|
-
const _n = new
|
|
1390
|
-
function
|
|
1389
|
+
const _n = new ue(), Ln = qt(_n);
|
|
1390
|
+
function Ct(e, t = typeof window > "u") {
|
|
1391
1391
|
let n;
|
|
1392
1392
|
e === !1 ? n = 0 : e === void 0 || e === !0 ? n = t ? 0 : 3 : typeof e == "number" ? n = e : n = e.retries;
|
|
1393
1393
|
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (r) => 1e3 * Math.pow(2, r);
|
|
@@ -1403,94 +1403,94 @@ class Un {
|
|
|
1403
1403
|
params;
|
|
1404
1404
|
config;
|
|
1405
1405
|
constructor() {
|
|
1406
|
-
return
|
|
1406
|
+
return Gt(this);
|
|
1407
1407
|
}
|
|
1408
1408
|
}
|
|
1409
|
-
const
|
|
1409
|
+
const Mt = /* @__PURE__ */ new WeakMap();
|
|
1410
1410
|
class H {
|
|
1411
1411
|
constructor(t, n) {
|
|
1412
1412
|
this.captured = n, this.statics = t;
|
|
1413
1413
|
}
|
|
1414
1414
|
statics;
|
|
1415
1415
|
createExecutionContext(t, n) {
|
|
1416
|
-
return
|
|
1416
|
+
return ot(this.captured, t, n);
|
|
1417
1417
|
}
|
|
1418
1418
|
resolveOptions(t) {
|
|
1419
|
-
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config, r =
|
|
1419
|
+
const { methods: n } = this.captured, i = n.getConfig ? n.getConfig.call(t) : t.config, r = Ct(i?.retry);
|
|
1420
1420
|
return { config: i, retryConfig: r };
|
|
1421
1421
|
}
|
|
1422
1422
|
static for(t) {
|
|
1423
|
-
let n =
|
|
1423
|
+
let n = Mt.get(t);
|
|
1424
1424
|
if (n !== void 0)
|
|
1425
1425
|
return n;
|
|
1426
|
-
const i = new t(), r = $e(i), s = String(r.methods.getIdentityKey.call(r.fields)), o = r.fields.result, a = o instanceof
|
|
1426
|
+
const i = new t(), r = $e(i), s = String(r.methods.getIdentityKey.call(r.fields)), o = r.fields.result, a = o instanceof v ? o : sn.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = r.fields.fetchNext, u = t.adapter;
|
|
1427
1427
|
if (!u)
|
|
1428
1428
|
throw new Error(
|
|
1429
1429
|
`Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
|
|
1430
1430
|
);
|
|
1431
|
-
const h = typeof u.prototype.sendNext == "function", g = c ? a : new
|
|
1431
|
+
const h = typeof u.prototype.sendNext == "function", g = c ? a : new v(
|
|
1432
1432
|
d.ENTITY | d.OBJECT,
|
|
1433
1433
|
a.shape,
|
|
1434
1434
|
void 0,
|
|
1435
1435
|
void 0,
|
|
1436
1436
|
s,
|
|
1437
1437
|
// typenameValue — unique per query class
|
|
1438
|
-
|
|
1438
|
+
Kt
|
|
1439
1439
|
// idField — symbol, injected onto payload before parse
|
|
1440
1440
|
);
|
|
1441
1441
|
return n = new H(
|
|
1442
1442
|
{ id: s, shape: g, cache: f, rawFetchNext: l, hasSendNext: h, isEntityResult: c, adapterClass: u },
|
|
1443
1443
|
r
|
|
1444
|
-
),
|
|
1444
|
+
), Mt.set(t, n), n;
|
|
1445
1445
|
}
|
|
1446
1446
|
}
|
|
1447
1447
|
const qn = (e, t) => {
|
|
1448
1448
|
const n = H.for(e);
|
|
1449
|
-
return
|
|
1449
|
+
return St(n, t);
|
|
1450
1450
|
};
|
|
1451
1451
|
function Vn(e, ...t) {
|
|
1452
|
-
const n = H.for(e), i = Oe(
|
|
1452
|
+
const n = H.for(e), i = Oe(Fn);
|
|
1453
1453
|
if (i === void 0)
|
|
1454
1454
|
throw new Error("QueryClient not found");
|
|
1455
1455
|
const r = t[0];
|
|
1456
1456
|
return i.getQuery(n, r);
|
|
1457
1457
|
}
|
|
1458
|
-
function
|
|
1458
|
+
function ut(e) {
|
|
1459
1459
|
if (e.reason !== void 0) return e.reason;
|
|
1460
1460
|
if (typeof DOMException < "u")
|
|
1461
1461
|
return new DOMException("The operation was aborted", "AbortError");
|
|
1462
1462
|
const t = new Error("The operation was aborted");
|
|
1463
1463
|
return t.name = "AbortError", t;
|
|
1464
1464
|
}
|
|
1465
|
-
function
|
|
1465
|
+
function le(e, t) {
|
|
1466
1466
|
return new Promise((n, i) => {
|
|
1467
1467
|
if (t?.aborted) {
|
|
1468
|
-
i(
|
|
1468
|
+
i(ut(t));
|
|
1469
1469
|
return;
|
|
1470
1470
|
}
|
|
1471
1471
|
const r = setTimeout(n, e);
|
|
1472
1472
|
t?.addEventListener(
|
|
1473
1473
|
"abort",
|
|
1474
1474
|
() => {
|
|
1475
|
-
clearTimeout(r), i(
|
|
1475
|
+
clearTimeout(r), i(ut(t));
|
|
1476
1476
|
},
|
|
1477
1477
|
{ once: !0 }
|
|
1478
1478
|
);
|
|
1479
1479
|
});
|
|
1480
1480
|
}
|
|
1481
|
-
async function
|
|
1481
|
+
async function dt(e, t, n) {
|
|
1482
1482
|
if (t.retries < 0)
|
|
1483
1483
|
throw new Error("retries must be non-negative");
|
|
1484
1484
|
const i = Math.max(0, t.retries);
|
|
1485
1485
|
let r;
|
|
1486
1486
|
for (let s = 0; s <= i; s++) {
|
|
1487
1487
|
if (n?.aborted)
|
|
1488
|
-
throw
|
|
1488
|
+
throw ut(n);
|
|
1489
1489
|
try {
|
|
1490
1490
|
return await e();
|
|
1491
1491
|
} catch (o) {
|
|
1492
1492
|
if (r = o, s >= i) throw o;
|
|
1493
|
-
await
|
|
1493
|
+
await le(t.retryDelay(s), n);
|
|
1494
1494
|
}
|
|
1495
1495
|
}
|
|
1496
1496
|
throw r;
|
|
@@ -1506,14 +1506,24 @@ class wn {
|
|
|
1506
1506
|
updatedAt = void 0;
|
|
1507
1507
|
params = void 0;
|
|
1508
1508
|
unsubscribe = void 0;
|
|
1509
|
+
lastSubscribeFn = void 0;
|
|
1509
1510
|
_relayState = void 0;
|
|
1510
1511
|
_isActive = !1;
|
|
1511
1512
|
wasPaused = !1;
|
|
1512
1513
|
currentParams = void 0;
|
|
1513
1514
|
debounceTimer = void 0;
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1515
|
+
// Invalidates on any signal consumed by getConfig() (such as
|
|
1516
|
+
// responseNotifier, fired by the adapter after each fetch). Param
|
|
1517
|
+
// changes are handled separately: getOrCreateExecutionContext
|
|
1518
|
+
// replaces this wholesale to force recomputation against the new ctx.
|
|
1519
|
+
_resolvedOptions = st(() => this.def.resolveOptions(this._executionCtx));
|
|
1520
|
+
get config() {
|
|
1521
|
+
if (this._executionCtx !== void 0)
|
|
1522
|
+
return this._resolvedOptions.value.config;
|
|
1523
|
+
}
|
|
1524
|
+
get retryConfig() {
|
|
1525
|
+
return this._executionCtx === void 0 ? Ct(void 0) : this._resolvedOptions.value.retryConfig;
|
|
1526
|
+
}
|
|
1517
1527
|
/** Cancels in-flight fetches and retry waits. */
|
|
1518
1528
|
_abortController = void 0;
|
|
1519
1529
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
@@ -1536,14 +1546,14 @@ class wn {
|
|
|
1536
1546
|
}
|
|
1537
1547
|
constructor(t, n, i, r) {
|
|
1538
1548
|
this.def = t, this.queryClient = n, this.queryKey = i, this.params = r, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1539
|
-
const s =
|
|
1540
|
-
this._queryId = s !== void 0 ? N(s) : 0, this.relay =
|
|
1549
|
+
const s = $t(r);
|
|
1550
|
+
this._queryId = s !== void 0 ? N(s) : 0, this.relay = Lt(
|
|
1541
1551
|
(o) => {
|
|
1542
1552
|
this._relayState = o;
|
|
1543
1553
|
const a = () => {
|
|
1544
|
-
this._isActive = !1, clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1545
|
-
const f = this.config?.gcTime ??
|
|
1546
|
-
this.queryClient.gcManager.schedule(this.queryKey, f,
|
|
1554
|
+
this._isActive = !1, clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0, this.lastSubscribeFn = void 0;
|
|
1555
|
+
const f = this.config?.gcTime ?? Vt;
|
|
1556
|
+
this.queryClient.gcManager.schedule(this.queryKey, f, tt.Query);
|
|
1547
1557
|
}, c = (f = !1) => {
|
|
1548
1558
|
const { wasPaused: l, isPaused: u, initialized: h } = this;
|
|
1549
1559
|
if (this.wasPaused = u, u && !l && h) {
|
|
@@ -1551,8 +1561,8 @@ class wn {
|
|
|
1551
1561
|
return;
|
|
1552
1562
|
}
|
|
1553
1563
|
this._isActive = !0;
|
|
1554
|
-
const g =
|
|
1555
|
-
_ && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.
|
|
1564
|
+
const g = $t(this.params), p = St(this.def, g), _ = p !== this.storageKey;
|
|
1565
|
+
_ && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.reconcileSubscription(), this.relayState.isPending && this._abortController === void 0 ? this.runQueryImmediately() : (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : _ && (this.lastSubscribeFn = void 0, this.reconcileSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1556
1566
|
};
|
|
1557
1567
|
return c(!0), {
|
|
1558
1568
|
update: c,
|
|
@@ -1600,18 +1610,17 @@ class wn {
|
|
|
1600
1610
|
}
|
|
1601
1611
|
if (!this.isPaused)
|
|
1602
1612
|
try {
|
|
1603
|
-
if (i !== void 0 && this.
|
|
1604
|
-
if (await
|
|
1613
|
+
if (i !== void 0 && this.reconcileSubscription(), i === void 0 || this.isStale) {
|
|
1614
|
+
if (await le(0), this.isPaused) return;
|
|
1605
1615
|
this.runQueryImmediately();
|
|
1606
1616
|
}
|
|
1607
1617
|
} catch (r) {
|
|
1608
1618
|
n.setError(r);
|
|
1609
1619
|
}
|
|
1610
1620
|
}
|
|
1611
|
-
|
|
1612
|
-
this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1621
|
+
reconcileSubscription() {
|
|
1613
1622
|
const t = this.config?.subscribe;
|
|
1614
|
-
if (!t) return;
|
|
1623
|
+
if (t === this.lastSubscribeFn || (this.unsubscribe?.(), this.unsubscribe = void 0, this.lastSubscribeFn = t, !t)) return;
|
|
1615
1624
|
const n = this._executionCtx;
|
|
1616
1625
|
this.unsubscribe = t.call(n, (i) => {
|
|
1617
1626
|
i.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(i);
|
|
@@ -1621,23 +1630,23 @@ class wn {
|
|
|
1621
1630
|
return (this._executionCtx === void 0 || this._executionCtxKey !== this.storageKey) && (this._executionCtxKey = this.storageKey, this._executionCtx = this.def.createExecutionContext(
|
|
1622
1631
|
this.currentParams ?? {},
|
|
1623
1632
|
this.queryClient.getContext()
|
|
1624
|
-
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext
|
|
1625
|
-
}
|
|
1626
|
-
resolveAndApplyOptions() {
|
|
1627
|
-
const t = this.def.resolveOptions(this._executionCtx);
|
|
1628
|
-
this.config = t.config, this.retryConfig = t.retryConfig;
|
|
1633
|
+
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext, this._resolvedOptions = st(() => this.def.resolveOptions(this._executionCtx))), this._executionCtx;
|
|
1629
1634
|
}
|
|
1630
1635
|
async runQuery() {
|
|
1631
1636
|
const t = this.def;
|
|
1632
1637
|
if (this.isPaused)
|
|
1633
1638
|
throw new Error("Query is paused due to network status");
|
|
1634
1639
|
const n = this.getOrCreateExecutionContext(), i = this.queryClient.getAdapter(t.statics.adapterClass), r = this._abortController?.signal ?? new AbortController().signal;
|
|
1635
|
-
return
|
|
1640
|
+
return dt(
|
|
1636
1641
|
async () => {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1642
|
+
try {
|
|
1643
|
+
const s = await i.send(n, r);
|
|
1644
|
+
this.updatedAt = Date.now();
|
|
1645
|
+
const o = this.applyData(s, !0);
|
|
1646
|
+
return this.saveQueryMetadata(), o;
|
|
1647
|
+
} finally {
|
|
1648
|
+
this.reconcileSubscription();
|
|
1649
|
+
}
|
|
1641
1650
|
},
|
|
1642
1651
|
this.retryConfig,
|
|
1643
1652
|
r
|
|
@@ -1688,7 +1697,7 @@ class wn {
|
|
|
1688
1697
|
const n = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
|
|
1689
1698
|
i.resultData = this.rootEntity.data;
|
|
1690
1699
|
const r = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1691
|
-
return
|
|
1700
|
+
return dt(
|
|
1692
1701
|
async () => {
|
|
1693
1702
|
const s = await r.sendNext(i, n);
|
|
1694
1703
|
this.updatedAt = Date.now();
|
|
@@ -1732,7 +1741,7 @@ class En {
|
|
|
1732
1741
|
this.def = t, this.queryClient = n, this.task = this.createTask();
|
|
1733
1742
|
}
|
|
1734
1743
|
createTask() {
|
|
1735
|
-
return
|
|
1744
|
+
return Re(
|
|
1736
1745
|
async (t) => {
|
|
1737
1746
|
if (this._inFlight)
|
|
1738
1747
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
@@ -1749,11 +1758,11 @@ class En {
|
|
|
1749
1758
|
}
|
|
1750
1759
|
validateResponse(t) {
|
|
1751
1760
|
const n = this.def.responseShape;
|
|
1752
|
-
if (!(n instanceof
|
|
1761
|
+
if (!(n instanceof v))
|
|
1753
1762
|
return t;
|
|
1754
1763
|
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1755
|
-
}), r = new
|
|
1756
|
-
return r.reset(void 0, void 0, i),
|
|
1764
|
+
}), r = new ft();
|
|
1765
|
+
return r.reset(void 0, void 0, i), oe(t, n, r);
|
|
1757
1766
|
}
|
|
1758
1767
|
// ======================================================
|
|
1759
1768
|
// Effects processing
|
|
@@ -1761,7 +1770,7 @@ class En {
|
|
|
1761
1770
|
processEffects(t, n) {
|
|
1762
1771
|
let i;
|
|
1763
1772
|
if (this.def.hasGetEffects) {
|
|
1764
|
-
const s =
|
|
1773
|
+
const s = ot(
|
|
1765
1774
|
this.def.captured,
|
|
1766
1775
|
t ?? {},
|
|
1767
1776
|
this.queryClient.getContext()
|
|
@@ -1773,19 +1782,19 @@ class En {
|
|
|
1773
1782
|
}
|
|
1774
1783
|
if (i === void 0) return;
|
|
1775
1784
|
const r = this.queryClient;
|
|
1776
|
-
|
|
1785
|
+
it(i.creates, "create", r), it(i.updates, "update", r), it(i.deletes, "delete", r), i.invalidates && r.invalidateQueries(i.invalidates);
|
|
1777
1786
|
}
|
|
1778
1787
|
// ======================================================
|
|
1779
1788
|
// Retry logic
|
|
1780
1789
|
// ======================================================
|
|
1781
1790
|
executeWithRetry(t) {
|
|
1782
|
-
const n =
|
|
1791
|
+
const n = Ct(this.def.config?.retry, !0), i = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1783
1792
|
if (!i.sendMutation)
|
|
1784
1793
|
throw new Error(
|
|
1785
1794
|
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1786
1795
|
);
|
|
1787
|
-
return
|
|
1788
|
-
const r = new AbortController(), s =
|
|
1796
|
+
return dt(async () => {
|
|
1797
|
+
const r = new AbortController(), s = ot(
|
|
1789
1798
|
this.def.captured,
|
|
1790
1799
|
t ?? {},
|
|
1791
1800
|
this.queryClient.getContext()
|
|
@@ -1797,21 +1806,21 @@ class En {
|
|
|
1797
1806
|
function bn(e) {
|
|
1798
1807
|
return typeof e == "string" ? e : $(e).typenameValue;
|
|
1799
1808
|
}
|
|
1800
|
-
function
|
|
1809
|
+
function it(e, t, n) {
|
|
1801
1810
|
if (e)
|
|
1802
1811
|
for (const [i, r] of e) {
|
|
1803
1812
|
const s = bn(i);
|
|
1804
1813
|
s !== void 0 && n.applyMutationEvent({ type: t, typename: s, data: r });
|
|
1805
1814
|
}
|
|
1806
1815
|
}
|
|
1807
|
-
const
|
|
1808
|
-
function
|
|
1816
|
+
const he = "__eventSource";
|
|
1817
|
+
function ye(e) {
|
|
1809
1818
|
return { field: e, segments: e.indexOf(".") !== -1 ? e.split(".") : void 0 };
|
|
1810
1819
|
}
|
|
1811
1820
|
function Cn(e) {
|
|
1812
|
-
return e.map(
|
|
1821
|
+
return e.map(ye);
|
|
1813
1822
|
}
|
|
1814
|
-
function
|
|
1823
|
+
function Sn(e, t) {
|
|
1815
1824
|
if (t.segments === void 0) return e[t.field];
|
|
1816
1825
|
let n = e;
|
|
1817
1826
|
for (const i of t.segments) {
|
|
@@ -1820,16 +1829,16 @@ function On(e, t) {
|
|
|
1820
1829
|
}
|
|
1821
1830
|
return n;
|
|
1822
1831
|
}
|
|
1823
|
-
function
|
|
1832
|
+
function pe(e, t) {
|
|
1824
1833
|
const n = [];
|
|
1825
1834
|
for (let i = 0; i < t.length; i++) {
|
|
1826
|
-
const r = t[i], s =
|
|
1835
|
+
const r = t[i], s = Sn(e, r);
|
|
1827
1836
|
if (s === void 0) return;
|
|
1828
1837
|
n.push(r.field, s);
|
|
1829
1838
|
}
|
|
1830
1839
|
return N(n);
|
|
1831
1840
|
}
|
|
1832
|
-
function
|
|
1841
|
+
function On(e, t) {
|
|
1833
1842
|
if (e === void 0) return;
|
|
1834
1843
|
const n = /* @__PURE__ */ new Map();
|
|
1835
1844
|
for (const [i, r] of e) {
|
|
@@ -1837,9 +1846,9 @@ function Sn(e, t) {
|
|
|
1837
1846
|
let a = !0;
|
|
1838
1847
|
for (const [c, f] of s) {
|
|
1839
1848
|
let l;
|
|
1840
|
-
if (
|
|
1841
|
-
const u =
|
|
1842
|
-
l =
|
|
1849
|
+
if (Qt(f)) {
|
|
1850
|
+
const u = Yt(f);
|
|
1851
|
+
l = pt(u, t);
|
|
1843
1852
|
} else
|
|
1844
1853
|
l = f;
|
|
1845
1854
|
if (l === void 0) {
|
|
@@ -1852,7 +1861,7 @@ function Sn(e, t) {
|
|
|
1852
1861
|
}
|
|
1853
1862
|
return n.size > 0 ? n : void 0;
|
|
1854
1863
|
}
|
|
1855
|
-
function
|
|
1864
|
+
function Tt(e, t) {
|
|
1856
1865
|
const n = e.get(t);
|
|
1857
1866
|
if (n !== void 0)
|
|
1858
1867
|
return n.map(([i]) => i).sort();
|
|
@@ -1862,7 +1871,7 @@ class Rn {
|
|
|
1862
1871
|
fieldPaths;
|
|
1863
1872
|
_bindings = /* @__PURE__ */ new Map();
|
|
1864
1873
|
constructor(t) {
|
|
1865
|
-
this.fields = t, this.fieldPaths = t.map(
|
|
1874
|
+
this.fields = t, this.fieldPaths = t.map(ye);
|
|
1866
1875
|
}
|
|
1867
1876
|
register(t, n) {
|
|
1868
1877
|
let i = this._bindings.get(t);
|
|
@@ -1879,13 +1888,13 @@ class Rn {
|
|
|
1879
1888
|
return this._bindings.size === 0;
|
|
1880
1889
|
}
|
|
1881
1890
|
}
|
|
1882
|
-
function
|
|
1891
|
+
function Pt(e) {
|
|
1883
1892
|
return N(e);
|
|
1884
1893
|
}
|
|
1885
|
-
class
|
|
1894
|
+
class xn {
|
|
1886
1895
|
_groups = /* @__PURE__ */ new Map();
|
|
1887
1896
|
getOrCreateGroup(t) {
|
|
1888
|
-
const n =
|
|
1897
|
+
const n = Pt(t);
|
|
1889
1898
|
let i = this._groups.get(n);
|
|
1890
1899
|
return i === void 0 && (i = new Rn(t), this._groups.set(n, i)), i;
|
|
1891
1900
|
}
|
|
@@ -1893,24 +1902,24 @@ class An {
|
|
|
1893
1902
|
this.getOrCreateGroup(n).register(t, i);
|
|
1894
1903
|
}
|
|
1895
1904
|
unregister(t, n, i) {
|
|
1896
|
-
const r =
|
|
1905
|
+
const r = Pt(n), s = this._groups.get(r);
|
|
1897
1906
|
s !== void 0 && (s.unregister(t, i), s.isEmpty && this._groups.delete(r));
|
|
1898
1907
|
}
|
|
1899
1908
|
registerBinding(t, n) {
|
|
1900
1909
|
const i = t._constraintHashes.get(n);
|
|
1901
1910
|
if (i === void 0) return;
|
|
1902
|
-
const r =
|
|
1911
|
+
const r = Tt(t._constraintFieldRefs, n);
|
|
1903
1912
|
r !== void 0 && this.register(i, r, t);
|
|
1904
1913
|
}
|
|
1905
1914
|
unregisterBinding(t, n) {
|
|
1906
1915
|
const i = t._constraintHashes.get(n);
|
|
1907
1916
|
if (i === void 0) return;
|
|
1908
|
-
const r =
|
|
1917
|
+
const r = Tt(t._constraintFieldRefs, n);
|
|
1909
1918
|
r !== void 0 && this.unregister(i, r, t);
|
|
1910
1919
|
}
|
|
1911
1920
|
routeEvent(t, n, i, r, s, o) {
|
|
1912
1921
|
for (const a of this._groups.values()) {
|
|
1913
|
-
const c =
|
|
1922
|
+
const c = pe(n, a.fieldPaths);
|
|
1914
1923
|
if (c === void 0) continue;
|
|
1915
1924
|
const f = a.getMatching(c);
|
|
1916
1925
|
if (f !== void 0)
|
|
@@ -1919,7 +1928,7 @@ class An {
|
|
|
1919
1928
|
}
|
|
1920
1929
|
}
|
|
1921
1930
|
}
|
|
1922
|
-
function
|
|
1931
|
+
function jt(e) {
|
|
1923
1932
|
const t = /* @__PURE__ */ new Set();
|
|
1924
1933
|
for (const n of e)
|
|
1925
1934
|
if (typeof n == "object" && n !== null) {
|
|
@@ -1928,7 +1937,7 @@ function Pt(e) {
|
|
|
1928
1937
|
}
|
|
1929
1938
|
return t;
|
|
1930
1939
|
}
|
|
1931
|
-
class
|
|
1940
|
+
class ge {
|
|
1932
1941
|
_queryClient;
|
|
1933
1942
|
_parent;
|
|
1934
1943
|
_constraintHashes;
|
|
@@ -1939,7 +1948,7 @@ class pe {
|
|
|
1939
1948
|
this._queryClient = i, this._parent = r, this._constraintHashes = s, this._constraintFieldRefs = n, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1940
1949
|
for (const a of t)
|
|
1941
1950
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1942
|
-
|
|
1951
|
+
et.add(this);
|
|
1943
1952
|
}
|
|
1944
1953
|
getValue() {
|
|
1945
1954
|
return this.instance.getValue();
|
|
@@ -1978,7 +1987,7 @@ class pe {
|
|
|
1978
1987
|
n !== -1 && t.splice(n, 1);
|
|
1979
1988
|
}
|
|
1980
1989
|
}
|
|
1981
|
-
class
|
|
1990
|
+
class An {
|
|
1982
1991
|
_notifier;
|
|
1983
1992
|
_items;
|
|
1984
1993
|
_keys;
|
|
@@ -1986,9 +1995,9 @@ class xn {
|
|
|
1986
1995
|
_queryClient;
|
|
1987
1996
|
_parent;
|
|
1988
1997
|
constructor(t, n, i, r, s, o) {
|
|
1989
|
-
this._notifier =
|
|
1998
|
+
this._notifier = Z(), this._items = i, this._keys = jt(i), this._queryClient = t, this._parent = n;
|
|
1990
1999
|
const a = r !== void 0 && s !== void 0, c = o !== void 0;
|
|
1991
|
-
(a || c) && (this._outputSignal =
|
|
2000
|
+
(a || c) && (this._outputSignal = st(() => {
|
|
1992
2001
|
this._notifier.consume();
|
|
1993
2002
|
let f = this._items;
|
|
1994
2003
|
if (a) {
|
|
@@ -2008,7 +2017,7 @@ class xn {
|
|
|
2008
2017
|
l.push(u);
|
|
2009
2018
|
continue;
|
|
2010
2019
|
}
|
|
2011
|
-
g.consume(),
|
|
2020
|
+
g.consume(), pe(g.data, r) === s && l.push(u);
|
|
2012
2021
|
}
|
|
2013
2022
|
f = l;
|
|
2014
2023
|
}
|
|
@@ -2053,7 +2062,7 @@ class xn {
|
|
|
2053
2062
|
}
|
|
2054
2063
|
reset(t) {
|
|
2055
2064
|
const n = this._items, i = Array.isArray(t) ? t : [];
|
|
2056
|
-
this._items = i, this._keys =
|
|
2065
|
+
this._items = i, this._keys = jt(i);
|
|
2057
2066
|
for (const r of i)
|
|
2058
2067
|
if (typeof r == "object" && r !== null) {
|
|
2059
2068
|
const s = P(r);
|
|
@@ -2100,7 +2109,7 @@ class Nn {
|
|
|
2100
2109
|
_onUpdate;
|
|
2101
2110
|
_onDelete;
|
|
2102
2111
|
constructor(t, n, i, r, s, o) {
|
|
2103
|
-
this._notifier =
|
|
2112
|
+
this._notifier = Z(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = n, this._onCreate = r, this._onUpdate = s, this._onDelete = o;
|
|
2104
2113
|
}
|
|
2105
2114
|
onEvent(t, n, i, r) {
|
|
2106
2115
|
switch (r) {
|
|
@@ -2130,18 +2139,18 @@ class Nn {
|
|
|
2130
2139
|
append(t) {
|
|
2131
2140
|
}
|
|
2132
2141
|
}
|
|
2133
|
-
function
|
|
2142
|
+
function ve(e, t, n, i, r) {
|
|
2134
2143
|
let s = e.constraintFieldRefs;
|
|
2135
2144
|
if (s === void 0) {
|
|
2136
2145
|
s = /* @__PURE__ */ new Map();
|
|
2137
2146
|
for (const f of e.entityDefs) {
|
|
2138
2147
|
const l = f.typenameValue;
|
|
2139
|
-
l !== void 0 && s.set(l, [[
|
|
2148
|
+
l !== void 0 && s.set(l, [[he, n.key]]);
|
|
2140
2149
|
}
|
|
2141
2150
|
}
|
|
2142
|
-
const o =
|
|
2151
|
+
const o = On(s, i) ?? /* @__PURE__ */ new Map();
|
|
2143
2152
|
let a;
|
|
2144
|
-
if (e.type ===
|
|
2153
|
+
if (e.type === ht.Array) {
|
|
2145
2154
|
let f, l;
|
|
2146
2155
|
if (e.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2147
2156
|
for (const [u] of e.constraintFieldRefs) {
|
|
@@ -2153,7 +2162,7 @@ function ge(e, t, n, i, r) {
|
|
|
2153
2162
|
break;
|
|
2154
2163
|
}
|
|
2155
2164
|
}
|
|
2156
|
-
a = new
|
|
2165
|
+
a = new An(
|
|
2157
2166
|
r,
|
|
2158
2167
|
n,
|
|
2159
2168
|
Array.isArray(t) ? t : [],
|
|
@@ -2170,7 +2179,7 @@ function ge(e, t, n, i, r) {
|
|
|
2170
2179
|
e.onUpdate,
|
|
2171
2180
|
e.onDelete
|
|
2172
2181
|
);
|
|
2173
|
-
const c = new
|
|
2182
|
+
const c = new ge(
|
|
2174
2183
|
e.entityDefs,
|
|
2175
2184
|
s,
|
|
2176
2185
|
r,
|
|
@@ -2180,8 +2189,8 @@ function ge(e, t, n, i, r) {
|
|
|
2180
2189
|
);
|
|
2181
2190
|
return n.liveCollections.push(c), r.registerLiveCollection(c), c;
|
|
2182
2191
|
}
|
|
2183
|
-
const me = Object.entries,
|
|
2184
|
-
function
|
|
2192
|
+
const me = Object.entries, _e = Object.prototype;
|
|
2193
|
+
function rt(e, t, n, i = !1) {
|
|
2185
2194
|
const r = e.queryClient;
|
|
2186
2195
|
r.currentParseId++;
|
|
2187
2196
|
const s = e.seen, o = /* @__PURE__ */ new Map();
|
|
@@ -2195,25 +2204,25 @@ function G(e, t, n, i, r, s) {
|
|
|
2195
2204
|
if (Array.isArray(e)) {
|
|
2196
2205
|
for (let a = 0; a < e.length; a++) {
|
|
2197
2206
|
const c = e[a];
|
|
2198
|
-
typeof c == "object" && c !== null && !(c instanceof Y) && !
|
|
2207
|
+
typeof c == "object" && c !== null && !(c instanceof Y) && !S.has(c) && (e[a] = G(c, t, n, i, r, s));
|
|
2199
2208
|
}
|
|
2200
2209
|
return e;
|
|
2201
2210
|
}
|
|
2202
|
-
if (Object.getPrototypeOf(e) ===
|
|
2211
|
+
if (Object.getPrototypeOf(e) === _e && !S.has(e)) {
|
|
2203
2212
|
const a = e;
|
|
2204
2213
|
for (const c of Object.keys(a)) {
|
|
2205
2214
|
const f = a[c];
|
|
2206
|
-
typeof f == "object" && f !== null && !(f instanceof Y) && !
|
|
2215
|
+
typeof f == "object" && f !== null && !(f instanceof Y) && !S.has(f) && (a[c] = G(f, t, n, i, r, s));
|
|
2207
2216
|
}
|
|
2208
2217
|
}
|
|
2209
2218
|
return e;
|
|
2210
2219
|
}
|
|
2211
|
-
function
|
|
2212
|
-
return typeof e == "object" && e !== null && !(e instanceof Y) && !
|
|
2220
|
+
function we(e) {
|
|
2221
|
+
return typeof e == "object" && e !== null && !(e instanceof Y) && !S.has(e);
|
|
2213
2222
|
}
|
|
2214
2223
|
function Dn(e, t, n, i, r, s) {
|
|
2215
2224
|
const { key: o, data: a, shape: c, rawKeys: f } = e, l = c.shape, u = n.prepareEntity(o, a, c), h = u.data, g = h !== a, p = g && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2216
|
-
if (g ? (
|
|
2225
|
+
if (g ? (Ee(
|
|
2217
2226
|
l,
|
|
2218
2227
|
a,
|
|
2219
2228
|
h,
|
|
@@ -2225,13 +2234,13 @@ function Dn(e, t, n, i, r, s) {
|
|
|
2225
2234
|
i,
|
|
2226
2235
|
p,
|
|
2227
2236
|
s
|
|
2228
|
-
), u.notify()) :
|
|
2229
|
-
for (const
|
|
2230
|
-
const
|
|
2231
|
-
if (Array.isArray(
|
|
2232
|
-
for (const T of
|
|
2237
|
+
), u.notify()) : be(l, a, u, a, t, n, i, p, s), s && u.liveCollections.length > 0)
|
|
2238
|
+
for (const m of u.liveCollections) {
|
|
2239
|
+
const O = m.instance.getRawValue();
|
|
2240
|
+
if (Array.isArray(O))
|
|
2241
|
+
for (const T of O) {
|
|
2233
2242
|
if (typeof T != "object" || T === null) continue;
|
|
2234
|
-
const R =
|
|
2243
|
+
const R = S.get(T);
|
|
2235
2244
|
if (R === void 0) continue;
|
|
2236
2245
|
const U = n.entityMap.getEntity(R);
|
|
2237
2246
|
U !== void 0 && p.set(U, (p.get(U) ?? 0) + 1);
|
|
@@ -2241,12 +2250,12 @@ function Dn(e, t, n, i, r, s) {
|
|
|
2241
2250
|
const _ = u.getProxy(c);
|
|
2242
2251
|
return r.set(u, (r.get(u) ?? 0) + 1), _;
|
|
2243
2252
|
}
|
|
2244
|
-
function
|
|
2253
|
+
function Ee(e, t, n, i, r, s, o, a, c, f, l) {
|
|
2245
2254
|
for (const [u, h] of me(e))
|
|
2246
2255
|
if (!(i !== void 0 && !i.has(u)))
|
|
2247
|
-
if (
|
|
2256
|
+
if (we(t[u]) && (t[u] = G(t[u], o, a, c, f, l)), h instanceof v && h._liveConfig !== void 0) {
|
|
2248
2257
|
const g = n[u];
|
|
2249
|
-
g instanceof
|
|
2258
|
+
g instanceof ge ? l ? g.append(t[u]) : g.reset(t[u]) : n[u] = ve(
|
|
2250
2259
|
h._liveConfig,
|
|
2251
2260
|
t[u],
|
|
2252
2261
|
r,
|
|
@@ -2255,10 +2264,10 @@ function we(e, t, n, i, r, s, o, a, c, f, l) {
|
|
|
2255
2264
|
);
|
|
2256
2265
|
} else {
|
|
2257
2266
|
const g = t[u], p = n[u];
|
|
2258
|
-
if (
|
|
2259
|
-
const _ = h instanceof
|
|
2267
|
+
if (lt(g) && lt(p)) {
|
|
2268
|
+
const _ = h instanceof v && h.shape !== void 0 ? h.shape : void 0;
|
|
2260
2269
|
if (_ !== void 0)
|
|
2261
|
-
|
|
2270
|
+
Ee(
|
|
2262
2271
|
_,
|
|
2263
2272
|
g,
|
|
2264
2273
|
p,
|
|
@@ -2272,18 +2281,18 @@ function we(e, t, n, i, r, s, o, a, c, f, l) {
|
|
|
2272
2281
|
l
|
|
2273
2282
|
);
|
|
2274
2283
|
else
|
|
2275
|
-
for (const
|
|
2276
|
-
p[
|
|
2284
|
+
for (const m of Object.keys(g))
|
|
2285
|
+
p[m] = g[m];
|
|
2277
2286
|
n[u] = p;
|
|
2278
2287
|
} else
|
|
2279
2288
|
n[u] = g;
|
|
2280
2289
|
}
|
|
2281
2290
|
}
|
|
2282
|
-
function
|
|
2291
|
+
function be(e, t, n, i, r, s, o, a, c) {
|
|
2283
2292
|
for (const [f, l] of me(e))
|
|
2284
2293
|
if (f in t)
|
|
2285
|
-
if (
|
|
2286
|
-
t[f] =
|
|
2294
|
+
if (we(t[f]) && (t[f] = G(t[f], r, s, o, a, c)), l instanceof v && l._liveConfig !== void 0)
|
|
2295
|
+
t[f] = ve(
|
|
2287
2296
|
l._liveConfig,
|
|
2288
2297
|
t[f],
|
|
2289
2298
|
n,
|
|
@@ -2292,23 +2301,23 @@ function Ee(e, t, n, i, r, s, o, a, c) {
|
|
|
2292
2301
|
);
|
|
2293
2302
|
else {
|
|
2294
2303
|
const u = t[f];
|
|
2295
|
-
if (
|
|
2296
|
-
const h = l instanceof
|
|
2297
|
-
h !== void 0 &&
|
|
2304
|
+
if (lt(u)) {
|
|
2305
|
+
const h = l instanceof v && l.shape !== void 0 ? l.shape : void 0;
|
|
2306
|
+
h !== void 0 && be(h, u, n, i, r, s, o, a, c);
|
|
2298
2307
|
}
|
|
2299
2308
|
}
|
|
2300
2309
|
}
|
|
2301
|
-
function
|
|
2302
|
-
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) ===
|
|
2310
|
+
function lt(e) {
|
|
2311
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) === _e && !S.has(e);
|
|
2303
2312
|
}
|
|
2304
2313
|
function Kn(e) {
|
|
2305
2314
|
if (e !== void 0)
|
|
2306
2315
|
return typeof e == "string" ? e : typeof e == "function" ? e() : e.value;
|
|
2307
2316
|
}
|
|
2308
2317
|
function In(e) {
|
|
2309
|
-
return
|
|
2318
|
+
return xe(e);
|
|
2310
2319
|
}
|
|
2311
|
-
function
|
|
2320
|
+
function $t(e) {
|
|
2312
2321
|
if (e === void 0)
|
|
2313
2322
|
return;
|
|
2314
2323
|
const t = {};
|
|
@@ -2316,7 +2325,7 @@ function jt(e) {
|
|
|
2316
2325
|
In(i) ? t[n] = i.value : t[n] = i;
|
|
2317
2326
|
return t;
|
|
2318
2327
|
}
|
|
2319
|
-
const
|
|
2328
|
+
const St = (e, t) => N([e.statics.id, t]);
|
|
2320
2329
|
class Bn {
|
|
2321
2330
|
entityMap;
|
|
2322
2331
|
queryInstances = /* @__PURE__ */ new Map();
|
|
@@ -2334,7 +2343,7 @@ class Bn {
|
|
|
2334
2343
|
networkUnsubscribe;
|
|
2335
2344
|
constructor(t = {}) {
|
|
2336
2345
|
const {
|
|
2337
|
-
store: n = new Ie(new
|
|
2346
|
+
store: n = new Ie(new Fe()),
|
|
2338
2347
|
log: i,
|
|
2339
2348
|
evictionMultiplier: r,
|
|
2340
2349
|
adapters: s,
|
|
@@ -2342,10 +2351,10 @@ class Bn {
|
|
|
2342
2351
|
gcManager: a,
|
|
2343
2352
|
...c
|
|
2344
2353
|
} = t;
|
|
2345
|
-
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: r }, this.gcManager = t.gcManager ?? (this.isServer ? new Te() : new Me(this.handleEviction, r)), this.networkManager = t.networkManager ?? new
|
|
2354
|
+
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: r }, this.gcManager = t.gcManager ?? (this.isServer ? new Te() : new Me(this.handleEviction, r)), this.networkManager = t.networkManager ?? new ue(), this.entityMap = new mn((u, h, g) => this.store.saveEntity(u, h, g));
|
|
2346
2355
|
for (const u of t.adapters ?? [])
|
|
2347
2356
|
this.adapters.set(u.constructor, u), u.register(this);
|
|
2348
|
-
const f = this.networkManager.getOnlineSignal(), l =
|
|
2357
|
+
const f = this.networkManager.getOnlineSignal(), l = Ae(() => f.value);
|
|
2349
2358
|
this.networkUnsubscribe = l.addListener(
|
|
2350
2359
|
() => {
|
|
2351
2360
|
const u = f.value;
|
|
@@ -2421,7 +2430,7 @@ class Bn {
|
|
|
2421
2430
|
if (n !== void 0) return n;
|
|
2422
2431
|
const i = this.typenameRegistry.get(t);
|
|
2423
2432
|
if (i !== void 0)
|
|
2424
|
-
return n =
|
|
2433
|
+
return n = v.merge(i), this.mergedDefCache.set(t, n), n;
|
|
2425
2434
|
}
|
|
2426
2435
|
saveQueryData(t, n, i, r, s) {
|
|
2427
2436
|
const o = s !== void 0 && s.size > 0 ? new Set([...s.keys()].map((a) => a.key)) : void 0;
|
|
@@ -2430,7 +2439,7 @@ class Bn {
|
|
|
2430
2439
|
activateQuery(t) {
|
|
2431
2440
|
const { def: n, queryKey: i, storageKey: r, config: s } = t;
|
|
2432
2441
|
this.store.activateQuery(n, r);
|
|
2433
|
-
const o = s?.gcTime ??
|
|
2442
|
+
const o = s?.gcTime ?? Vt;
|
|
2434
2443
|
this.gcManager.cancel(i, o);
|
|
2435
2444
|
}
|
|
2436
2445
|
loadCachedQuery(t, n) {
|
|
@@ -2441,7 +2450,7 @@ class Bn {
|
|
|
2441
2450
|
* that triggers fetches and prepopulates with cached data
|
|
2442
2451
|
*/
|
|
2443
2452
|
getQuery(t, n) {
|
|
2444
|
-
const i =
|
|
2453
|
+
const i = St(t, n);
|
|
2445
2454
|
let r = this.queryInstances.get(i);
|
|
2446
2455
|
return r === void 0 && (r = new wn(t, this, i, n), this.queryInstances.set(i, r)), r.relay;
|
|
2447
2456
|
}
|
|
@@ -2460,8 +2469,8 @@ class Bn {
|
|
|
2460
2469
|
*/
|
|
2461
2470
|
parseData(t, n, i) {
|
|
2462
2471
|
const r = this.context.log?.warn ?? (() => {
|
|
2463
|
-
}), s = new
|
|
2464
|
-
return s.reset(this, i, r), { data:
|
|
2472
|
+
}), s = new ft();
|
|
2473
|
+
return s.reset(this, i, r), { data: oe(t, n, s), ctx: s };
|
|
2465
2474
|
}
|
|
2466
2475
|
/**
|
|
2467
2476
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
@@ -2469,7 +2478,7 @@ class Bn {
|
|
|
2469
2478
|
* refs. Returns the reified data and root-level entity refs.
|
|
2470
2479
|
*/
|
|
2471
2480
|
applyRefs(t, n = !0, i = !1) {
|
|
2472
|
-
return
|
|
2481
|
+
return rt(t.ctx, t.data, n, i);
|
|
2473
2482
|
}
|
|
2474
2483
|
/**
|
|
2475
2484
|
* Parse and apply data as a root entity. For non-entity results, injects
|
|
@@ -2477,8 +2486,8 @@ class Bn {
|
|
|
2477
2486
|
* found in the store by the standard entity pipeline).
|
|
2478
2487
|
*/
|
|
2479
2488
|
parseAndApplyRootEntity(t, n, i, r, s = !1, o) {
|
|
2480
|
-
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[
|
|
2481
|
-
const a = this.parseData(t, i, o), c =
|
|
2489
|
+
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Kt] = n);
|
|
2490
|
+
const a = this.parseData(t, i, o), c = rt(a.ctx, a.data, r, s), f = S.get(c.data);
|
|
2482
2491
|
return this.entityMap.getEntity(f);
|
|
2483
2492
|
}
|
|
2484
2493
|
prepareEntity(t, n, i) {
|
|
@@ -2502,20 +2511,20 @@ class Bn {
|
|
|
2502
2511
|
}
|
|
2503
2512
|
try {
|
|
2504
2513
|
const _ = this.context.log?.warn ?? (() => {
|
|
2505
|
-
}),
|
|
2506
|
-
|
|
2514
|
+
}), m = new ft();
|
|
2515
|
+
m.reset(
|
|
2507
2516
|
this,
|
|
2508
2517
|
void 0,
|
|
2509
2518
|
_,
|
|
2510
2519
|
/* isPartialEvent */
|
|
2511
2520
|
!0
|
|
2512
2521
|
);
|
|
2513
|
-
const
|
|
2514
|
-
|
|
2522
|
+
const O = an(l, r, m);
|
|
2523
|
+
rt(m, O, !0);
|
|
2515
2524
|
} catch (_) {
|
|
2516
2525
|
if (this.context.log?.warn?.("Failed to apply mutation event", _), u === void 0) {
|
|
2517
|
-
const
|
|
2518
|
-
|
|
2526
|
+
const m = this.entityMap.getEntity(c);
|
|
2527
|
+
m !== void 0 && m.evict();
|
|
2519
2528
|
}
|
|
2520
2529
|
return;
|
|
2521
2530
|
}
|
|
@@ -2535,14 +2544,14 @@ class Bn {
|
|
|
2535
2544
|
for (const n of t) {
|
|
2536
2545
|
const i = Array.isArray(n), r = i ? n[0] : n, s = i ? n[1] : void 0, a = H.for(r).statics.id;
|
|
2537
2546
|
for (const [, c] of this.queryInstances)
|
|
2538
|
-
c.def.statics.id === a && (s === void 0 ||
|
|
2547
|
+
c.def.statics.id === a && (s === void 0 || kn(c.resolvedParams, s)) && c.markStale();
|
|
2539
2548
|
}
|
|
2540
2549
|
}
|
|
2541
2550
|
// ======================================================
|
|
2542
2551
|
// In-Memory GC
|
|
2543
2552
|
// ======================================================
|
|
2544
2553
|
handleEviction = (t, n) => {
|
|
2545
|
-
if (n ===
|
|
2554
|
+
if (n === tt.Query) {
|
|
2546
2555
|
const r = this.queryInstances.get(t);
|
|
2547
2556
|
if (r === void 0) return;
|
|
2548
2557
|
r.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
@@ -2556,7 +2565,7 @@ class Bn {
|
|
|
2556
2565
|
// ======================================================
|
|
2557
2566
|
getOrCreateMatcher(t) {
|
|
2558
2567
|
let n = this.constraintRegistry.get(t);
|
|
2559
|
-
return n === void 0 && (n = new
|
|
2568
|
+
return n === void 0 && (n = new xn(), this.constraintRegistry.set(t, n)), n;
|
|
2560
2569
|
}
|
|
2561
2570
|
registerLiveCollection(t) {
|
|
2562
2571
|
for (const [n, i] of t._entityDefsByTypename)
|
|
@@ -2571,7 +2580,7 @@ class Bn {
|
|
|
2571
2580
|
routeEvent(t, n, i, r, s, o, a) {
|
|
2572
2581
|
const c = this.constraintRegistry.get(t);
|
|
2573
2582
|
if (c === void 0) return;
|
|
2574
|
-
const f = s !== void 0 ? { ...n, [
|
|
2583
|
+
const f = s !== void 0 ? { ...n, [he]: s } : n;
|
|
2575
2584
|
c.routeEvent(t, f, i, r, o, a);
|
|
2576
2585
|
}
|
|
2577
2586
|
destroy() {
|
|
@@ -2581,40 +2590,40 @@ class Bn {
|
|
|
2581
2590
|
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2582
2591
|
}
|
|
2583
2592
|
}
|
|
2584
|
-
const
|
|
2585
|
-
function
|
|
2593
|
+
const Fn = qt(void 0);
|
|
2594
|
+
function kn(e, t) {
|
|
2586
2595
|
if (e === void 0) return !1;
|
|
2587
2596
|
for (const n in t)
|
|
2588
2597
|
if (e[n] !== t[n]) return !1;
|
|
2589
2598
|
return !0;
|
|
2590
2599
|
}
|
|
2591
2600
|
export {
|
|
2592
|
-
|
|
2593
|
-
|
|
2601
|
+
F as A,
|
|
2602
|
+
gt as E,
|
|
2594
2603
|
Me as G,
|
|
2595
2604
|
Q as L,
|
|
2596
2605
|
d as M,
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2606
|
+
ue as N,
|
|
2607
|
+
Kt as Q,
|
|
2608
|
+
k as R,
|
|
2609
|
+
v as V,
|
|
2610
|
+
ht as a,
|
|
2602
2611
|
Ln as b,
|
|
2603
2612
|
K as c,
|
|
2604
2613
|
Te as d,
|
|
2605
|
-
|
|
2614
|
+
de as e,
|
|
2606
2615
|
Un as f,
|
|
2607
2616
|
Bn as g,
|
|
2608
|
-
|
|
2617
|
+
Fn as h,
|
|
2609
2618
|
_n as i,
|
|
2610
2619
|
$n as j,
|
|
2611
2620
|
Vn as k,
|
|
2612
|
-
|
|
2621
|
+
Gt as l,
|
|
2613
2622
|
$e as m,
|
|
2614
2623
|
X as n,
|
|
2615
2624
|
Kn as o,
|
|
2616
2625
|
qn as q,
|
|
2617
|
-
|
|
2626
|
+
ne as r,
|
|
2618
2627
|
sn as t
|
|
2619
2628
|
};
|
|
2620
|
-
//# sourceMappingURL=QueryClient-
|
|
2629
|
+
//# sourceMappingURL=QueryClient-CkO_s9Uh.js.map
|