fetchium 0.2.4 → 0.3.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 +25 -0
- package/dist/cjs/development/QueryClient-BefSCMoE.js +2 -0
- package/dist/cjs/development/QueryClient-BefSCMoE.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-LrsiDsl7.js → development/mutation-OJNwoJcf.js} +2 -2
- package/dist/cjs/{production/mutation-LrsiDsl7.js.map → development/mutation-OJNwoJcf.js.map} +1 -1
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/react/index.js.map +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/production/QueryClient-rbPYznie.js +2 -0
- package/dist/cjs/production/QueryClient-rbPYznie.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-CUV5TC93.js → production/mutation-CjSajlTU.js} +2 -2
- package/dist/cjs/{development/mutation-CUV5TC93.js.map → production/mutation-CjSajlTU.js.map} +1 -1
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/react/index.js.map +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/esm/EntityInstance.d.ts.map +1 -1
- package/dist/esm/QueryResult.d.ts +3 -3
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/{QueryClient-WObL5AFz.js → QueryClient-DfxP7pt2.js} +584 -570
- package/dist/esm/development/QueryClient-DfxP7pt2.js.map +1 -0
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-C3e7FM9D.js → mutation-DZAq7Pbu.js} +2 -2
- package/dist/esm/development/{mutation-C3e7FM9D.js.map → mutation-DZAq7Pbu.js.map} +1 -1
- package/dist/esm/development/react/index.js +5 -36
- package/dist/esm/development/react/index.js.map +1 -1
- package/dist/esm/development/rest/index.js +2 -2
- package/dist/esm/development/topic/index.js +1 -1
- package/dist/esm/production/{QueryClient-DqHBCvA1.js → QueryClient-DrWSXg0y.js} +482 -468
- package/dist/esm/production/QueryClient-DrWSXg0y.js.map +1 -0
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-BOc53DJi.js → mutation-B8dmX5lz.js} +2 -2
- package/dist/esm/production/{mutation-BOc53DJi.js.map → mutation-B8dmX5lz.js.map} +1 -1
- package/dist/esm/production/react/index.js +5 -36
- package/dist/esm/production/react/index.js.map +1 -1
- package/dist/esm/production/rest/index.js +2 -2
- package/dist/esm/production/topic/index.js +1 -1
- package/dist/esm/react/use-query.d.ts +8 -0
- package/dist/esm/react/use-query.d.ts.map +1 -1
- package/dist/esm/types.d.ts +3 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/plugin/docs/api/fetchium-react.md +5 -4
- package/plugin/docs/api/fetchium.md +2 -2
- package/dist/cjs/development/QueryClient-DjKxdY2y.js +0 -2
- package/dist/cjs/development/QueryClient-DjKxdY2y.js.map +0 -1
- package/dist/cjs/production/QueryClient-YzaJT_2g.js +0 -2
- package/dist/cjs/production/QueryClient-YzaJT_2g.js.map +0 -1
- package/dist/esm/development/QueryClient-WObL5AFz.js.map +0 -1
- package/dist/esm/production/QueryClient-DqHBCvA1.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { notifier as
|
|
2
|
-
import { registerCustomHash as
|
|
3
|
-
import { d as
|
|
4
|
-
import { SyncQueryStore as
|
|
5
|
-
var
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
class
|
|
1
|
+
import { notifier as dt, relay as $t, setScopeOwner as be, reactiveMethod as Ce, signal as Lt, context as Ut, getContext as Oe, task as Se, reactiveSignal as Re, isSignal as Ae, watcher as xe } from "signalium";
|
|
2
|
+
import { registerCustomHash as Ne, hashValue as N, registerCustomSnapshot as De } from "signalium/utils";
|
|
3
|
+
import { d as qt } from "./shared-DcuVH8Pf.js";
|
|
4
|
+
import { SyncQueryStore as Ie, MemoryPersistentStore as ke } from "./stores/sync.js";
|
|
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 k = /* @__PURE__ */ Symbol("array"), F = /* @__PURE__ */ Symbol("record"), Vt = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
|
+
var lt = /* @__PURE__ */ ((e) => (e[e.Array = 0] = "Array", e[e.Value = 1] = "Value", e))(lt || {});
|
|
8
|
+
class Q {
|
|
9
9
|
type;
|
|
10
10
|
entityDefs;
|
|
11
11
|
constraintFieldRefs;
|
|
@@ -18,7 +18,7 @@ class B {
|
|
|
18
18
|
this.type = t, this.entityDefs = n, this.constraintFieldRefs = i, this.sort = r, this.valueType = s, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
|
|
19
19
|
}
|
|
20
20
|
static array(t, n, i) {
|
|
21
|
-
return new
|
|
21
|
+
return new Q(
|
|
22
22
|
0,
|
|
23
23
|
t,
|
|
24
24
|
n,
|
|
@@ -30,7 +30,7 @@ class B {
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
static value(t, n, i, r, s, o) {
|
|
33
|
-
return new
|
|
33
|
+
return new Q(
|
|
34
34
|
1,
|
|
35
35
|
t,
|
|
36
36
|
n,
|
|
@@ -42,12 +42,12 @@ class B {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
47
|
-
return
|
|
45
|
+
const O = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function P(e) {
|
|
47
|
+
return O.get(e);
|
|
48
48
|
}
|
|
49
|
-
var
|
|
50
|
-
class
|
|
49
|
+
var Z = /* @__PURE__ */ ((e) => (e[e.Query = 0] = "Query", e[e.Entity = 1] = "Entity", e))(Z || {});
|
|
50
|
+
class Fe {
|
|
51
51
|
constructor(t, n, i) {
|
|
52
52
|
this._onEvict = n, this._intervalId = setInterval(this._tick, t * 6e4 * i);
|
|
53
53
|
}
|
|
@@ -70,7 +70,7 @@ class Ie {
|
|
|
70
70
|
clearInterval(this._intervalId);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
class
|
|
73
|
+
class Me {
|
|
74
74
|
_buckets = /* @__PURE__ */ new Map();
|
|
75
75
|
_nextTickEntries = /* @__PURE__ */ new Map();
|
|
76
76
|
_nextTickScheduled = !1;
|
|
@@ -88,7 +88,7 @@ class Fe {
|
|
|
88
88
|
}
|
|
89
89
|
const { _buckets: r } = this;
|
|
90
90
|
let s = r.get(n);
|
|
91
|
-
s || (s = new
|
|
91
|
+
s || (s = new Fe(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) {
|
|
@@ -113,7 +113,7 @@ class Fe {
|
|
|
113
113
|
t.clear(), n.clear();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
class
|
|
116
|
+
class Te {
|
|
117
117
|
schedule(t, n, i) {
|
|
118
118
|
}
|
|
119
119
|
cancel(t, n) {
|
|
@@ -121,37 +121,37 @@ class Me {
|
|
|
121
121
|
destroy() {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
function
|
|
124
|
+
const z = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"), ht = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), J = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Pe = /\[([^\]]+)\]/g;
|
|
125
|
+
function Kt(e) {
|
|
126
126
|
const t = {
|
|
127
|
-
[
|
|
128
|
-
[
|
|
127
|
+
[z]: !0,
|
|
128
|
+
[I]: e
|
|
129
129
|
};
|
|
130
|
-
return new Proxy(t,
|
|
130
|
+
return new Proxy(t, je);
|
|
131
131
|
}
|
|
132
|
-
const
|
|
132
|
+
const je = {
|
|
133
133
|
get(e, t) {
|
|
134
|
-
if (t ===
|
|
135
|
-
if (t ===
|
|
134
|
+
if (t === z) return !0;
|
|
135
|
+
if (t === I) return e[I];
|
|
136
136
|
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
|
|
137
|
-
const i = e[
|
|
137
|
+
const i = e[I];
|
|
138
138
|
return () => `[${i.join(".")}]`;
|
|
139
139
|
}
|
|
140
140
|
if (typeof t == "symbol") return;
|
|
141
|
-
const n = e[
|
|
142
|
-
return
|
|
141
|
+
const n = e[I];
|
|
142
|
+
return Kt([...n, t]);
|
|
143
143
|
},
|
|
144
144
|
has(e, t) {
|
|
145
|
-
return t ===
|
|
145
|
+
return t === z || t === I;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
function
|
|
149
|
-
return typeof e == "object" && e !== null && e[
|
|
148
|
+
function Bt(e) {
|
|
149
|
+
return typeof e == "object" && e !== null && e[z] === !0;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
return e[
|
|
151
|
+
function Qt(e) {
|
|
152
|
+
return e[I];
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Yt(e) {
|
|
155
155
|
let t = !1;
|
|
156
156
|
return new Proxy(e, {
|
|
157
157
|
set(n, i, r) {
|
|
@@ -160,15 +160,15 @@ function Bt(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 === ht ? n : i ===
|
|
163
|
+
return i === ht ? n : i === J ? () => {
|
|
164
164
|
t = !0;
|
|
165
|
-
} : typeof i == "symbol" ? n[i] :
|
|
165
|
+
} : typeof i == "symbol" ? n[i] : Kt([i]);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function $e(e) {
|
|
170
170
|
const t = e[ht];
|
|
171
|
-
e[
|
|
171
|
+
e[J]();
|
|
172
172
|
const n = {};
|
|
173
173
|
for (const s of Object.getOwnPropertyNames(t))
|
|
174
174
|
n[s] = t[s];
|
|
@@ -184,7 +184,7 @@ function Pe(e) {
|
|
|
184
184
|
}
|
|
185
185
|
return { fields: n, methods: i };
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function yt(e, t) {
|
|
188
188
|
let n = t;
|
|
189
189
|
for (const i of e) {
|
|
190
190
|
if (n == null) return;
|
|
@@ -192,44 +192,44 @@ function lt(e, t) {
|
|
|
192
192
|
}
|
|
193
193
|
return n;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
return e.replace(
|
|
197
|
-
const r = i.split("."), s =
|
|
195
|
+
function Le(e, t) {
|
|
196
|
+
return e.replace(Pe, (n, i) => {
|
|
197
|
+
const r = i.split("."), s = yt(r, t);
|
|
198
198
|
return s != null ? encodeURIComponent(String(s)) : "";
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
201
|
+
function X(e, t) {
|
|
202
|
+
if (Bt(e))
|
|
203
|
+
return yt(Qt(e), t);
|
|
204
204
|
if (typeof e == "string")
|
|
205
|
-
return
|
|
205
|
+
return Le(e, t);
|
|
206
206
|
if (Array.isArray(e))
|
|
207
|
-
return e.map((n) =>
|
|
207
|
+
return e.map((n) => X(n, t));
|
|
208
208
|
if (typeof e == "object" && e !== null && Object.getPrototypeOf(e) === Object.prototype) {
|
|
209
209
|
const n = {};
|
|
210
210
|
for (const i of Object.keys(e))
|
|
211
|
-
n[i] =
|
|
211
|
+
n[i] = X(e[i], t);
|
|
212
212
|
return n;
|
|
213
213
|
}
|
|
214
214
|
return e;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function rt(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
|
-
o[a] =
|
|
219
|
+
o[a] = X(c, s);
|
|
220
220
|
o.params = t, o.context = n;
|
|
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 pt {
|
|
226
226
|
static cache;
|
|
227
227
|
constructor() {
|
|
228
|
-
return
|
|
228
|
+
return Yt(this);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
let
|
|
231
|
+
const Gt = Object.entries, st = Object.keys;
|
|
232
|
+
let Ht = () => {
|
|
233
233
|
};
|
|
234
234
|
{
|
|
235
235
|
const t = (i, r) => {
|
|
@@ -256,30 +256,30 @@ let Gt = () => {
|
|
|
256
256
|
if (a !== 0 && c !== 0 && a !== c) return !1;
|
|
257
257
|
if (i.shape === r.shape) return !0;
|
|
258
258
|
if (i.shape !== void 0 && r.shape !== void 0 && typeof i.shape == "object" && typeof r.shape == "object") {
|
|
259
|
-
const f = i.shape,
|
|
259
|
+
const f = i.shape, l = r.shape;
|
|
260
260
|
for (const u of Object.keys(f))
|
|
261
|
-
if (u in
|
|
262
|
-
for (const u of Object.keys(
|
|
263
|
-
if (u in f && !n(f[u],
|
|
261
|
+
if (u in l && !n(f[u], l[u])) return !1;
|
|
262
|
+
for (const u of Object.keys(l))
|
|
263
|
+
if (u in f && !n(f[u], l[u])) return !1;
|
|
264
264
|
}
|
|
265
265
|
return !0;
|
|
266
266
|
}
|
|
267
267
|
return !1;
|
|
268
268
|
};
|
|
269
|
-
|
|
269
|
+
Ht = (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
|
|
276
|
+
function Rt(e) {
|
|
277
277
|
return typeof e == "number" ? e | d.UNDEFINED : e instanceof m ? (e.mask & d.UNDEFINED) !== 0 ? e : m.cloneWith(e, d.UNDEFINED) : e;
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function At(e) {
|
|
280
280
|
return e instanceof m && (e.mask & d.OBJECT) !== 0 && (e.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function Wt(e, t, n) {
|
|
283
283
|
const i = /* @__PURE__ */ new Set();
|
|
284
284
|
for (const s of e)
|
|
285
285
|
if (s !== void 0)
|
|
@@ -290,15 +290,15 @@ function Ht(e, t, n) {
|
|
|
290
290
|
let o = 0, a;
|
|
291
291
|
const c = [];
|
|
292
292
|
let f = !0;
|
|
293
|
-
for (const
|
|
294
|
-
const u =
|
|
295
|
-
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !
|
|
293
|
+
for (const l of e) {
|
|
294
|
+
const u = l?.[s];
|
|
295
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !At(u) && Ht(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
|
|
299
|
-
r[s] = o < t ?
|
|
298
|
+
const l = Wt(c, t, n), u = new m(d.OBJECT, l);
|
|
299
|
+
r[s] = o < t ? Rt(u) : u;
|
|
300
300
|
} else
|
|
301
|
-
r[s] = o < t ?
|
|
301
|
+
r[s] = o < t ? Rt(a) : a;
|
|
302
302
|
}
|
|
303
303
|
return r;
|
|
304
304
|
}
|
|
@@ -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 = Wt(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)
|
|
@@ -368,7 +368,7 @@ class m {
|
|
|
368
368
|
return i._methods = t._methods, i._entityConfig = t._entityConfig, i._entityClass = t._entityClass, i._entityCache = t._entityCache, i._liveConfig = t._liveConfig, i;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
class
|
|
371
|
+
class L extends Set {
|
|
372
372
|
lowercaseMap;
|
|
373
373
|
// lowercase -> canonical (strings only)
|
|
374
374
|
constructor(t) {
|
|
@@ -403,28 +403,28 @@ class $ extends Set {
|
|
|
403
403
|
return t;
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
let t =
|
|
406
|
+
const Ue = 1128875347;
|
|
407
|
+
Ne(L, (e) => {
|
|
408
|
+
let t = Ue;
|
|
409
409
|
for (const n of e)
|
|
410
410
|
t += N(n);
|
|
411
411
|
return t >>> 0;
|
|
412
412
|
});
|
|
413
|
-
function
|
|
413
|
+
function gt(e, t) {
|
|
414
414
|
return new m(e, t);
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
return
|
|
416
|
+
function qe(e) {
|
|
417
|
+
return gt(d.ARRAY, e);
|
|
418
418
|
}
|
|
419
|
-
function
|
|
420
|
-
return
|
|
419
|
+
function Ve(e) {
|
|
420
|
+
return gt(d.RECORD | d.OBJECT, e);
|
|
421
421
|
}
|
|
422
|
-
function
|
|
423
|
-
return
|
|
422
|
+
function Ke(e) {
|
|
423
|
+
return gt(d.PARSE_RESULT, e);
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function zt(e, t) {
|
|
426
426
|
let n = e, i, r, s;
|
|
427
|
-
for (const [o, a] of
|
|
427
|
+
for (const [o, a] of Gt(t))
|
|
428
428
|
switch (typeof a) {
|
|
429
429
|
case "number":
|
|
430
430
|
if ((a & d.ID) !== 0) {
|
|
@@ -439,17 +439,17 @@ function Wt(e, t) {
|
|
|
439
439
|
r = o, s = a;
|
|
440
440
|
break;
|
|
441
441
|
case "object":
|
|
442
|
-
if (a instanceof
|
|
442
|
+
if (a instanceof L || a instanceof Set)
|
|
443
443
|
break;
|
|
444
444
|
a.mask & d.LIVE && (n |= d.LIVE);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
447
|
return new m(n, t, void 0, r, s, i);
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return
|
|
449
|
+
function Be(e) {
|
|
450
|
+
return zt(d.OBJECT, e);
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function xt(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 Rt(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 [...st(s), k, F]) {
|
|
466
466
|
const a = s[o];
|
|
467
467
|
if (t[o] !== void 0 && t[o] !== a)
|
|
468
468
|
throw new Error(
|
|
@@ -471,9 +471,9 @@ function Rt(e, t, n) {
|
|
|
471
471
|
t[o] = a;
|
|
472
472
|
}
|
|
473
473
|
} else if ((i & d.ARRAY) !== 0) {
|
|
474
|
-
if (t[
|
|
474
|
+
if (t[k] !== void 0)
|
|
475
475
|
throw new Error("Array shape already defined");
|
|
476
|
-
t[
|
|
476
|
+
t[k] = e.shape;
|
|
477
477
|
} else if ((i & d.RECORD) !== 0) {
|
|
478
478
|
if (t[F] !== void 0)
|
|
479
479
|
throw new Error("Record shape already defined");
|
|
@@ -490,27 +490,27 @@ function Rt(e, t, n) {
|
|
|
490
490
|
}
|
|
491
491
|
return n;
|
|
492
492
|
}
|
|
493
|
-
function
|
|
493
|
+
function mt(...e) {
|
|
494
494
|
const t = e;
|
|
495
495
|
let n = 0, i = 0, r, s, o, a, c = 0;
|
|
496
|
-
for (const
|
|
497
|
-
if (typeof
|
|
498
|
-
n |=
|
|
496
|
+
for (const l of t) {
|
|
497
|
+
if (typeof l == "number") {
|
|
498
|
+
n |= l;
|
|
499
499
|
continue;
|
|
500
500
|
}
|
|
501
|
-
if (
|
|
501
|
+
if (l instanceof Set) {
|
|
502
502
|
if (s === void 0)
|
|
503
|
-
s = new Set(
|
|
503
|
+
s = new Set(l);
|
|
504
504
|
else
|
|
505
|
-
for (const u of
|
|
505
|
+
for (const u of l)
|
|
506
506
|
s.add(u);
|
|
507
507
|
continue;
|
|
508
508
|
}
|
|
509
|
-
if (i++, c |=
|
|
510
|
-
r =
|
|
509
|
+
if (i++, c |= l.mask, i === 1) {
|
|
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 = xt(r, o, a)), a = xt(l, o, a);
|
|
514
514
|
}
|
|
515
515
|
if (i === 0)
|
|
516
516
|
return s === void 0 ? n : n === 0 ? s : new m(n | d.UNION, void 0, s);
|
|
@@ -519,68 +519,68 @@ function pt(...e) {
|
|
|
519
519
|
const f = n | c | d.UNION;
|
|
520
520
|
return new m(f, o, s, a);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function vt(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
|
-
return
|
|
527
|
+
return mt(e, t);
|
|
528
528
|
let r = n.get(i);
|
|
529
529
|
return r === void 0 && (r = m.cloneWith(i, t), n.set(i, r)), r;
|
|
530
530
|
}
|
|
531
|
-
const
|
|
532
|
-
function Ye(e) {
|
|
533
|
-
return gt(e, d.UNDEFINED | d.NULL, Qe);
|
|
534
|
-
}
|
|
535
|
-
function Ge(e) {
|
|
536
|
-
return gt(e, d.UNDEFINED, Ke);
|
|
537
|
-
}
|
|
531
|
+
const Qe = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), Ge = /* @__PURE__ */ new WeakMap();
|
|
538
532
|
function He(e) {
|
|
539
|
-
return
|
|
533
|
+
return vt(e, d.UNDEFINED | d.NULL, Ge);
|
|
540
534
|
}
|
|
541
535
|
function We(e) {
|
|
542
|
-
return e;
|
|
536
|
+
return vt(e, d.UNDEFINED, Qe);
|
|
543
537
|
}
|
|
544
538
|
function ze(e) {
|
|
539
|
+
return vt(e, d.NULL, Ye);
|
|
540
|
+
}
|
|
541
|
+
function Je(e) {
|
|
542
|
+
return e;
|
|
543
|
+
}
|
|
544
|
+
function Xe(e) {
|
|
545
545
|
return /* @__PURE__ */ new Set([e]);
|
|
546
546
|
}
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
const
|
|
550
|
-
let
|
|
551
|
-
const
|
|
552
|
-
class
|
|
547
|
+
const Jt = ((...e) => new Set(e));
|
|
548
|
+
Jt.caseInsensitive = (...e) => new L(e);
|
|
549
|
+
const _t = 16;
|
|
550
|
+
let Ze = 0;
|
|
551
|
+
const ot = [], Xt = [], Zt = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map(), tt = /* @__PURE__ */ new WeakSet();
|
|
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 = ot[n](t), this._parsed = !0) : this._parsed = !1, tt.add(this);
|
|
559
559
|
}
|
|
560
560
|
getValue() {
|
|
561
|
-
return this._parsed || (this._formatted =
|
|
561
|
+
return this._parsed || (this._formatted = ot[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
562
562
|
}
|
|
563
563
|
toJSON() {
|
|
564
|
-
return this._parsed ?
|
|
564
|
+
return this._parsed ? Xt[this._formatId](this._formatted) : this._raw;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
const t =
|
|
567
|
+
function tn(e) {
|
|
568
|
+
const t = Zt.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 Nt(e) {
|
|
574
|
+
const t = e >> _t;
|
|
575
|
+
return te.get(t);
|
|
576
576
|
}
|
|
577
|
-
function
|
|
578
|
-
const s =
|
|
579
|
-
|
|
580
|
-
const o = r?.eager ?? !0, c = s <<
|
|
581
|
-
|
|
577
|
+
function ee(e, t, n, i, r) {
|
|
578
|
+
const s = Ze++;
|
|
579
|
+
ot[s] = n, Xt[s] = i, te.set(s, e);
|
|
580
|
+
const o = r?.eager ?? !0, c = s << _t | t | d.HAS_FORMAT | (o ? d.IS_EAGER_FORMAT : 0);
|
|
581
|
+
Zt.set(e, c);
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
ee(
|
|
584
584
|
"date",
|
|
585
585
|
d.STRING,
|
|
586
586
|
(e) => {
|
|
@@ -597,7 +597,7 @@ te(
|
|
|
597
597
|
return `${t}-${n}-${i}`;
|
|
598
598
|
}
|
|
599
599
|
);
|
|
600
|
-
|
|
600
|
+
ee(
|
|
601
601
|
"date-time",
|
|
602
602
|
d.STRING,
|
|
603
603
|
(e) => {
|
|
@@ -608,52 +608,52 @@ te(
|
|
|
608
608
|
},
|
|
609
609
|
(e) => e.toISOString()
|
|
610
610
|
);
|
|
611
|
-
const
|
|
612
|
-
function
|
|
613
|
-
let t =
|
|
611
|
+
const Dt = /* @__PURE__ */ new WeakMap();
|
|
612
|
+
function $(e) {
|
|
613
|
+
let t = Dt.get(e);
|
|
614
614
|
if (t === void 0) {
|
|
615
615
|
const n = new e(), i = n[ht] ?? n;
|
|
616
|
-
n[
|
|
616
|
+
n[J] && n[J]();
|
|
617
617
|
const r = {};
|
|
618
|
-
for (const [f,
|
|
619
|
-
if (!(typeof
|
|
618
|
+
for (const [f, l] of Gt(i)) {
|
|
619
|
+
if (!(typeof l == "number" || typeof l == "string" || l instanceof Set || l instanceof m || l instanceof L))
|
|
620
620
|
throw new Error(
|
|
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
|
|
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
|
);
|
|
623
|
-
r[f] =
|
|
623
|
+
r[f] = l;
|
|
624
624
|
}
|
|
625
625
|
const s = Object.getPrototypeOf(e.prototype);
|
|
626
626
|
if (s != null) {
|
|
627
627
|
const f = s.constructor;
|
|
628
|
-
if (f !==
|
|
629
|
-
const u =
|
|
630
|
-
for (const
|
|
631
|
-
if (
|
|
632
|
-
throw new Error(`Cannot extend: field '${
|
|
628
|
+
if (f !== pt && typeof f == "function") {
|
|
629
|
+
const u = $(f).shape;
|
|
630
|
+
for (const h of st(u))
|
|
631
|
+
if (h in r && r[h] !== u[h])
|
|
632
|
+
throw new Error(`Cannot extend: field '${h}' already exists in type definition`);
|
|
633
633
|
}
|
|
634
634
|
}
|
|
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 = zt(d.ENTITY | d.OBJECT, r), t._entityClass = e, st(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), Dt.set(e, t);
|
|
641
641
|
}
|
|
642
642
|
return t;
|
|
643
643
|
}
|
|
644
|
-
function
|
|
645
|
-
return
|
|
644
|
+
function en(e) {
|
|
645
|
+
return $(e);
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function ne(e, t) {
|
|
648
648
|
if (t == null) return;
|
|
649
649
|
const n = /* @__PURE__ */ new Map();
|
|
650
650
|
if (Array.isArray(t))
|
|
651
651
|
for (const i of t) {
|
|
652
|
-
const [r, s] = i, a =
|
|
652
|
+
const [r, s] = i, a = $(r).typenameValue;
|
|
653
653
|
if (a === void 0) continue;
|
|
654
654
|
const c = [];
|
|
655
|
-
for (const [f,
|
|
656
|
-
c.push([f,
|
|
655
|
+
for (const [f, l] of Object.entries(s))
|
|
656
|
+
c.push([f, l]);
|
|
657
657
|
c.length > 0 && n.set(a, c);
|
|
658
658
|
}
|
|
659
659
|
else {
|
|
@@ -667,53 +667,53 @@ function ee(e, t) {
|
|
|
667
667
|
}
|
|
668
668
|
return n.size > 0 ? n : void 0;
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
return Array.isArray(e) ? e.map((t) =>
|
|
670
|
+
function ie(e) {
|
|
671
|
+
return Array.isArray(e) ? e.map((t) => $(t)) : [$(e)];
|
|
672
672
|
}
|
|
673
|
-
function
|
|
674
|
-
const n =
|
|
675
|
-
return s._liveConfig =
|
|
673
|
+
function nn(e, t) {
|
|
674
|
+
const n = ie(e), i = n.length === 1 ? n[0] : mt(...n.map((o) => o)), r = d.ARRAY | d.LIVE, s = new m(r, i);
|
|
675
|
+
return s._liveConfig = Q.array(
|
|
676
676
|
n,
|
|
677
|
-
|
|
677
|
+
ne(n, t?.constraints),
|
|
678
678
|
t?.sort
|
|
679
679
|
), s;
|
|
680
680
|
}
|
|
681
|
-
function
|
|
682
|
-
const i =
|
|
683
|
-
return o._liveConfig =
|
|
681
|
+
function rn(e, t, n) {
|
|
682
|
+
const i = ie(t), r = e, s = d.LIVE, o = new m(s, void 0);
|
|
683
|
+
return o._liveConfig = Q.value(
|
|
684
684
|
i,
|
|
685
|
-
|
|
685
|
+
ne(i, n?.constraints),
|
|
686
686
|
r,
|
|
687
687
|
n.onCreate,
|
|
688
688
|
n.onUpdate,
|
|
689
689
|
n.onDelete
|
|
690
690
|
), o;
|
|
691
691
|
}
|
|
692
|
-
const
|
|
693
|
-
format:
|
|
694
|
-
typename:
|
|
695
|
-
const:
|
|
696
|
-
enum:
|
|
692
|
+
const sn = {
|
|
693
|
+
format: tn,
|
|
694
|
+
typename: Je,
|
|
695
|
+
const: Xe,
|
|
696
|
+
enum: Jt,
|
|
697
697
|
id: d.ID | d.STRING | d.NUMBER,
|
|
698
698
|
string: d.STRING,
|
|
699
699
|
number: d.NUMBER,
|
|
700
700
|
boolean: d.BOOLEAN,
|
|
701
701
|
null: d.NULL,
|
|
702
702
|
undefined: d.UNDEFINED,
|
|
703
|
-
array:
|
|
704
|
-
object:
|
|
705
|
-
record:
|
|
706
|
-
union:
|
|
707
|
-
nullish:
|
|
708
|
-
optional:
|
|
709
|
-
nullable:
|
|
710
|
-
result:
|
|
711
|
-
entity:
|
|
712
|
-
liveArray:
|
|
713
|
-
liveValue:
|
|
703
|
+
array: qe,
|
|
704
|
+
object: Be,
|
|
705
|
+
record: Ve,
|
|
706
|
+
union: mt,
|
|
707
|
+
nullish: He,
|
|
708
|
+
optional: We,
|
|
709
|
+
nullable: ze,
|
|
710
|
+
result: Ke,
|
|
711
|
+
entity: en,
|
|
712
|
+
liveArray: nn,
|
|
713
|
+
liveValue: rn
|
|
714
714
|
};
|
|
715
|
-
function
|
|
716
|
-
if (e instanceof
|
|
715
|
+
function B(e) {
|
|
716
|
+
if (e instanceof L)
|
|
717
717
|
return Array.from(e).map((i) => typeof i == "string" ? `"${i}"` : String(i)).join(" | ");
|
|
718
718
|
if (e instanceof Set)
|
|
719
719
|
return Array.from(e).map((i) => typeof i == "string" ? `"${i}"` : String(i)).join(" | ");
|
|
@@ -723,7 +723,7 @@ function K(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 = Nt(e);
|
|
727
727
|
if (r)
|
|
728
728
|
return `"${r}"`;
|
|
729
729
|
}
|
|
@@ -739,12 +739,12 @@ function K(e) {
|
|
|
739
739
|
i.push(o);
|
|
740
740
|
}
|
|
741
741
|
if (n.shape !== void 0) {
|
|
742
|
-
n.shape[
|
|
742
|
+
n.shape[k] !== void 0 && i.push(`Array<${B(n.shape[k])}>`), n.shape[F] !== void 0 && i.push(`Record<string, ${B(n.shape[F])}>`);
|
|
743
743
|
for (const [s, o] of Object.entries(n.shape))
|
|
744
|
-
s !==
|
|
744
|
+
s !== k && s !== F && i.push(s);
|
|
745
745
|
}
|
|
746
746
|
if (t = n.mask, (t & d.HAS_FORMAT) !== 0) {
|
|
747
|
-
const s =
|
|
747
|
+
const s = Nt(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(" | ");
|
|
@@ -753,11 +753,11 @@ function K(e) {
|
|
|
753
753
|
return `Entity<${e.typenameValue}>`;
|
|
754
754
|
if (t & d.ARRAY) {
|
|
755
755
|
const n = e.shape;
|
|
756
|
-
return `Array<${
|
|
756
|
+
return `Array<${B(n)}>`;
|
|
757
757
|
}
|
|
758
758
|
if (t & d.RECORD) {
|
|
759
759
|
const n = e.shape;
|
|
760
|
-
return `Record<string, ${
|
|
760
|
+
return `Record<string, ${B(n)}>`;
|
|
761
761
|
}
|
|
762
762
|
if (t & d.OBJECT) {
|
|
763
763
|
const n = e.typenameValue;
|
|
@@ -765,13 +765,13 @@ function K(e) {
|
|
|
765
765
|
}
|
|
766
766
|
return "unknown";
|
|
767
767
|
}
|
|
768
|
-
function
|
|
768
|
+
function V(e, t, n) {
|
|
769
769
|
return new TypeError(
|
|
770
|
-
`Validation error at ${e}: expected ${
|
|
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 re = Array.isArray;
|
|
774
|
+
function It(e) {
|
|
775
775
|
if (e === null) return d.NULL;
|
|
776
776
|
switch (typeof e) {
|
|
777
777
|
case "number":
|
|
@@ -783,44 +783,44 @@ function Nt(e) {
|
|
|
783
783
|
case "undefined":
|
|
784
784
|
return d.UNDEFINED;
|
|
785
785
|
case "object":
|
|
786
|
-
return
|
|
786
|
+
return re(e) ? d.ARRAY : d.OBJECT;
|
|
787
787
|
default:
|
|
788
788
|
throw new Error(`Invalid type: ${typeof e}`);
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
|
-
function
|
|
792
|
-
return
|
|
791
|
+
function $n(e) {
|
|
792
|
+
return j(e);
|
|
793
793
|
}
|
|
794
|
-
function
|
|
794
|
+
function j(e) {
|
|
795
795
|
if (e === null || typeof e != "object")
|
|
796
796
|
return e;
|
|
797
|
-
if (
|
|
798
|
-
return e.map((n) =>
|
|
797
|
+
if (re(e))
|
|
798
|
+
return e.map((n) => j(n));
|
|
799
799
|
if (e instanceof Date)
|
|
800
800
|
return new Date(e.getTime());
|
|
801
801
|
if (e instanceof Map) {
|
|
802
802
|
const n = /* @__PURE__ */ new Map();
|
|
803
803
|
for (const [i, r] of e)
|
|
804
|
-
n.set(
|
|
804
|
+
n.set(j(i), j(r));
|
|
805
805
|
return n;
|
|
806
806
|
}
|
|
807
807
|
if (e instanceof Set) {
|
|
808
808
|
const n = /* @__PURE__ */ new Set();
|
|
809
809
|
for (const i of e)
|
|
810
|
-
n.add(
|
|
810
|
+
n.add(j(i));
|
|
811
811
|
return n;
|
|
812
812
|
}
|
|
813
813
|
const t = {};
|
|
814
814
|
for (const n of Object.keys(e))
|
|
815
|
-
t[n] =
|
|
815
|
+
t[n] = j(e[n]);
|
|
816
816
|
return t;
|
|
817
817
|
}
|
|
818
|
-
const
|
|
818
|
+
const wt = Object.entries, on = () => {
|
|
819
819
|
};
|
|
820
|
-
class
|
|
820
|
+
class at {
|
|
821
821
|
queryClient = void 0;
|
|
822
822
|
preloadedEntities = void 0;
|
|
823
|
-
warn =
|
|
823
|
+
warn = on;
|
|
824
824
|
/** When true, missing optional fields on existing entities are set to
|
|
825
825
|
* undefined. False for mutation events (truly partial payloads). */
|
|
826
826
|
isPartialEvent = !1;
|
|
@@ -830,17 +830,17 @@ class ot {
|
|
|
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 se(e, t, n) {
|
|
834
834
|
return M(e, t, n, "");
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
return
|
|
836
|
+
function an(e, t, n) {
|
|
837
|
+
return Et(e, t, n);
|
|
838
838
|
}
|
|
839
|
-
function
|
|
840
|
-
const r = e >>
|
|
839
|
+
function kt(e, t, n, i) {
|
|
840
|
+
const r = e >> _t;
|
|
841
841
|
if ((e & d.IS_EAGER_FORMAT) !== 0)
|
|
842
842
|
try {
|
|
843
|
-
return new
|
|
843
|
+
return new Y(t, r, !0);
|
|
844
844
|
} catch (o) {
|
|
845
845
|
if ((e & d.UNDEFINED) !== 0) {
|
|
846
846
|
n.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
@@ -852,37 +852,37 @@ function Dt(e, t, n, i) {
|
|
|
852
852
|
}
|
|
853
853
|
throw o;
|
|
854
854
|
}
|
|
855
|
-
return new
|
|
855
|
+
return new Y(t, r, !1);
|
|
856
856
|
}
|
|
857
857
|
function M(e, t, n, i) {
|
|
858
858
|
const r = t;
|
|
859
|
-
if (r instanceof
|
|
859
|
+
if (r instanceof L) {
|
|
860
860
|
const c = r.get(e);
|
|
861
|
-
if (c === void 0) throw
|
|
861
|
+
if (c === void 0) throw V(i, r, e);
|
|
862
862
|
return c;
|
|
863
863
|
}
|
|
864
864
|
if (r instanceof Set) {
|
|
865
|
-
if (!r.has(e)) throw
|
|
865
|
+
if (!r.has(e)) throw V(i, r, e);
|
|
866
866
|
return e;
|
|
867
867
|
}
|
|
868
868
|
if (typeof r == "string") {
|
|
869
869
|
if (e == null) return r;
|
|
870
|
-
if (e !== r) throw
|
|
870
|
+
if (e !== r) throw V(i, r, e);
|
|
871
871
|
return e;
|
|
872
872
|
}
|
|
873
873
|
if (typeof r == "number") {
|
|
874
|
-
const c =
|
|
874
|
+
const c = It(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 });
|
|
878
878
|
return;
|
|
879
879
|
}
|
|
880
|
-
throw
|
|
880
|
+
throw V(i, r, e);
|
|
881
881
|
}
|
|
882
|
-
return (r & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ?
|
|
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 === lt.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,20 +890,20 @@ 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 = It(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 });
|
|
897
897
|
return;
|
|
898
898
|
}
|
|
899
|
-
throw
|
|
899
|
+
throw V(i, s, e);
|
|
900
900
|
}
|
|
901
|
-
return a < d.OBJECT ? (s & d.HAS_FORMAT) !== 0 && e !== null && e !== void 0 ?
|
|
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 ? oe(e, r.shape, n, i) : (s & d.RECORD) !== 0 ? ae(e, r.shape, n, i) : (s & d.ENTITY) !== 0 && n.queryClient !== void 0 ? Et(e, r, n) : ce(e, r, n, i);
|
|
902
902
|
}
|
|
903
|
-
function
|
|
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[k];
|
|
906
|
+
return s === void 0 || typeof s == "number" ? t : oe(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") {
|
|
@@ -912,15 +912,15 @@ function on(e, t, n, i, r) {
|
|
|
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 ae(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 ? Et(t, a, i) : ce(t, a, i, r);
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function oe(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 se(e, t, n, i) {
|
|
|
934
934
|
}
|
|
935
935
|
return r;
|
|
936
936
|
}
|
|
937
|
-
function
|
|
938
|
-
for (const [r, s] of
|
|
937
|
+
function ae(e, t, n, i) {
|
|
938
|
+
for (const [r, s] of wt(e))
|
|
939
939
|
e[r] = M(s, t, n, `${i}["${r}"]`);
|
|
940
940
|
return e;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
if (
|
|
942
|
+
function ce(e, t, n, i) {
|
|
943
|
+
if (O.has(e))
|
|
944
944
|
return e;
|
|
945
945
|
const r = t.shape;
|
|
946
|
-
for (const [s, o] of
|
|
946
|
+
for (const [s, o] of wt(r))
|
|
947
947
|
e[s] = M(e[s], o, n, `${i}.${s}`);
|
|
948
948
|
return e;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function Et(e, t, n) {
|
|
951
951
|
const i = n.queryClient, r = n.preloadedEntities;
|
|
952
952
|
let s, o;
|
|
953
953
|
if (r !== void 0)
|
|
@@ -962,29 +962,29 @@ function _t(e, t, n) {
|
|
|
962
962
|
if (a !== void 0)
|
|
963
963
|
return a.data;
|
|
964
964
|
if (r !== void 0) {
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
965
|
+
const _ = i.entityMap.getEntity(s)?.data ?? r.get(s);
|
|
966
|
+
if (_ === void 0)
|
|
967
967
|
throw new Error(`Cached entity ${s} not found in preloaded map`);
|
|
968
|
-
e =
|
|
968
|
+
e = _;
|
|
969
969
|
}
|
|
970
970
|
const c = {};
|
|
971
971
|
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
972
|
-
const f = i.entityMap.getEntity(s),
|
|
972
|
+
const f = i.entityMap.getEntity(s), l = n.isPartialEvent && f !== void 0, u = {
|
|
973
973
|
key: s,
|
|
974
974
|
shape: t,
|
|
975
975
|
data: c,
|
|
976
|
-
rawKeys:
|
|
976
|
+
rawKeys: l ? new Set(Object.keys(e)) : void 0
|
|
977
977
|
};
|
|
978
978
|
n.seen.set(c, u), n.seenByKey.set(s, u);
|
|
979
|
-
const
|
|
980
|
-
for (const [p,
|
|
981
|
-
|
|
979
|
+
const h = `[[${t.typenameValue}:${o}]]`, g = t.shape;
|
|
980
|
+
for (const [p, _] of wt(g))
|
|
981
|
+
l && !(p in e) || (c[p] = M(e[p], _, n, `${h}.${p}`));
|
|
982
982
|
return c;
|
|
983
983
|
}
|
|
984
|
-
function
|
|
985
|
-
return
|
|
984
|
+
function fn(e, t) {
|
|
985
|
+
return un(e, t.shape, t.typenameField);
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function un(e, t, n) {
|
|
988
988
|
if (t === void 0) return !0;
|
|
989
989
|
for (const i of Object.keys(t)) {
|
|
990
990
|
if (i === n) continue;
|
|
@@ -999,27 +999,27 @@ function cn(e, t, n) {
|
|
|
999
999
|
}
|
|
1000
1000
|
return !0;
|
|
1001
1001
|
}
|
|
1002
|
-
const
|
|
1003
|
-
function
|
|
1002
|
+
const dn = Object.prototype, W = /* @__PURE__ */ new WeakMap();
|
|
1003
|
+
function x(e) {
|
|
1004
1004
|
if (typeof e != "object" || e === null) return e;
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1005
|
+
if (tt.has(e)) return x(e.getValue());
|
|
1006
|
+
if (O.has(e)) return e;
|
|
1007
1007
|
if (Array.isArray(e)) {
|
|
1008
|
-
let t =
|
|
1009
|
-
return t === void 0 && (t = new Proxy(e,
|
|
1008
|
+
let t = W.get(e);
|
|
1009
|
+
return t === void 0 && (t = new Proxy(e, ln), W.set(e, t)), t;
|
|
1010
1010
|
}
|
|
1011
|
-
if (Object.getPrototypeOf(e) ===
|
|
1012
|
-
let t =
|
|
1013
|
-
return t === void 0 && (t = new Proxy(e,
|
|
1011
|
+
if (Object.getPrototypeOf(e) === dn) {
|
|
1012
|
+
let t = W.get(e);
|
|
1013
|
+
return t === void 0 && (t = new Proxy(e, hn), W.set(e, t)), t;
|
|
1014
1014
|
}
|
|
1015
1015
|
return e;
|
|
1016
1016
|
}
|
|
1017
|
-
const
|
|
1017
|
+
const ln = {
|
|
1018
1018
|
get(e, t, n) {
|
|
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 x(e[i]);
|
|
1023
1023
|
}
|
|
1024
1024
|
return Reflect.get(e, t, n);
|
|
1025
1025
|
},
|
|
@@ -1029,9 +1029,9 @@ const un = {
|
|
|
1029
1029
|
deleteProperty() {
|
|
1030
1030
|
throw new Error("Cannot mutate a read-only array");
|
|
1031
1031
|
}
|
|
1032
|
-
},
|
|
1032
|
+
}, hn = {
|
|
1033
1033
|
get(e, t, n) {
|
|
1034
|
-
return typeof t == "string" ?
|
|
1034
|
+
return typeof t == "string" ? x(e[t]) : Reflect.get(e, t, n);
|
|
1035
1035
|
},
|
|
1036
1036
|
set() {
|
|
1037
1037
|
throw new Error("Cannot mutate a read-only object");
|
|
@@ -1048,8 +1048,22 @@ const un = {
|
|
|
1048
1048
|
getOwnPropertyDescriptor(e, t) {
|
|
1049
1049
|
return Object.getOwnPropertyDescriptor(e, t);
|
|
1050
1050
|
}
|
|
1051
|
+
}, yn = (e, t, n) => {
|
|
1052
|
+
const i = e, r = Object.keys(i), s = t !== null && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
1053
|
+
let o = !s || Object.keys(s).length !== r.length;
|
|
1054
|
+
const a = {};
|
|
1055
|
+
for (let c = 0; c < r.length; c++) {
|
|
1056
|
+
const f = r[c], l = i[f];
|
|
1057
|
+
let u;
|
|
1058
|
+
typeof l == "function" ? u = l : u = n(l, s?.[f]), a[f] = u, !o && u !== s?.[f] && (o = !0);
|
|
1059
|
+
}
|
|
1060
|
+
return o ? a : s;
|
|
1051
1061
|
};
|
|
1052
|
-
|
|
1062
|
+
De(
|
|
1063
|
+
pt,
|
|
1064
|
+
yn
|
|
1065
|
+
);
|
|
1066
|
+
class pn {
|
|
1053
1067
|
_notifier;
|
|
1054
1068
|
_queryClient;
|
|
1055
1069
|
_proxies = /* @__PURE__ */ new Map();
|
|
@@ -1067,7 +1081,7 @@ class hn {
|
|
|
1067
1081
|
_extraMethods;
|
|
1068
1082
|
_extraGetters;
|
|
1069
1083
|
constructor(t, n, i, r, s, o) {
|
|
1070
|
-
this._notifier =
|
|
1084
|
+
this._notifier = dt(), this._queryClient = o, this.key = t, this.typename = n, this.id = i, this.idField = r, this.data = s, this.entityRefs = void 0;
|
|
1071
1085
|
}
|
|
1072
1086
|
retain() {
|
|
1073
1087
|
this.refCount++;
|
|
@@ -1079,7 +1093,7 @@ class hn {
|
|
|
1079
1093
|
if (this.refCount < 0)
|
|
1080
1094
|
throw new Error(`Entity ${this.typename}:${this.id} released more times than retained`);
|
|
1081
1095
|
const t = this._entityCache?.gcTime;
|
|
1082
|
-
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t,
|
|
1096
|
+
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, Z.Entity) : this.evict();
|
|
1083
1097
|
}
|
|
1084
1098
|
evict() {
|
|
1085
1099
|
const t = this.liveCollections.slice();
|
|
@@ -1113,13 +1127,13 @@ class hn {
|
|
|
1113
1127
|
getProxy(t) {
|
|
1114
1128
|
const n = t;
|
|
1115
1129
|
let i = this._proxies.get(n);
|
|
1116
|
-
return i === void 0 && (i =
|
|
1130
|
+
return i === void 0 && (i = mn(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(n, i)), i;
|
|
1117
1131
|
}
|
|
1118
1132
|
get proxy() {
|
|
1119
1133
|
return this._proxies.values().next().value;
|
|
1120
1134
|
}
|
|
1121
1135
|
satisfiesDef(t) {
|
|
1122
|
-
return this.satisfiedDefs.has(t) ? !0 :
|
|
1136
|
+
return this.satisfiedDefs.has(t) ? !0 : fn(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
|
|
1123
1137
|
}
|
|
1124
1138
|
save() {
|
|
1125
1139
|
this._queryClient.entityMap.save(this);
|
|
@@ -1131,94 +1145,94 @@ class hn {
|
|
|
1131
1145
|
this._notifier.consume();
|
|
1132
1146
|
}
|
|
1133
1147
|
}
|
|
1134
|
-
function
|
|
1148
|
+
function gn(e, t, n) {
|
|
1135
1149
|
const i = [];
|
|
1136
1150
|
for (const r of e) {
|
|
1137
1151
|
if (typeof r != "object" || r === null) continue;
|
|
1138
|
-
const s =
|
|
1152
|
+
const s = O.get(r);
|
|
1139
1153
|
if (s === void 0) continue;
|
|
1140
1154
|
const o = n.entityMap.getEntity(s);
|
|
1141
1155
|
o !== void 0 && o.satisfiesDef(t) && i.push(r);
|
|
1142
1156
|
}
|
|
1143
1157
|
return i;
|
|
1144
1158
|
}
|
|
1145
|
-
function
|
|
1146
|
-
const s = n.shape ?? {}, o = n, a = o._methods, c = o._entityClass, f = o._entityConfig,
|
|
1147
|
-
let
|
|
1148
|
-
f?.hasSubscribe && a && "__subscribe" in a && (
|
|
1149
|
-
const y = (
|
|
1150
|
-
|
|
1151
|
-
},
|
|
1152
|
-
return E.value = v,
|
|
1159
|
+
function mn(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 : pt.prototype, u = n.typenameField, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = () => ({ __entityRef: t });
|
|
1161
|
+
let _;
|
|
1162
|
+
f?.hasSubscribe && a && "__subscribe" in a && (_ = $t((E) => {
|
|
1163
|
+
const y = (w) => {
|
|
1164
|
+
w.__eventSource = t, r.applyMutationEvent(w);
|
|
1165
|
+
}, b = a.__subscribe.call(v, y);
|
|
1166
|
+
return E.value = v, b;
|
|
1153
1167
|
}));
|
|
1154
1168
|
let v;
|
|
1155
1169
|
if (u && !(u in s))
|
|
1156
1170
|
throw new Error(`typenameField "${u}" must be declared in the entity shape`);
|
|
1157
|
-
const
|
|
1158
|
-
if (
|
|
1171
|
+
const S = Object.keys(s);
|
|
1172
|
+
if (S.includes("__typename") || S.push("__typename"), a)
|
|
1159
1173
|
for (const E of Object.keys(a))
|
|
1160
|
-
|
|
1161
|
-
let
|
|
1162
|
-
function
|
|
1174
|
+
S.includes(E) || S.push(E);
|
|
1175
|
+
let T, R = S;
|
|
1176
|
+
function U() {
|
|
1163
1177
|
const E = e._extraMethods;
|
|
1164
|
-
if (E !==
|
|
1165
|
-
if (
|
|
1166
|
-
for (const
|
|
1167
|
-
R.includes(
|
|
1178
|
+
if (E !== T) {
|
|
1179
|
+
if (T = E, R = S.slice(), E !== void 0)
|
|
1180
|
+
for (const b of Object.keys(E))
|
|
1181
|
+
R.includes(b) || R.push(b);
|
|
1168
1182
|
const y = e._extraGetters;
|
|
1169
1183
|
if (y !== void 0)
|
|
1170
|
-
for (const
|
|
1171
|
-
R.includes(
|
|
1184
|
+
for (const b of Object.keys(y))
|
|
1185
|
+
R.includes(b) || R.push(b);
|
|
1172
1186
|
}
|
|
1173
1187
|
return R;
|
|
1174
1188
|
}
|
|
1175
|
-
const
|
|
1189
|
+
const q = {
|
|
1176
1190
|
getPrototypeOf() {
|
|
1177
|
-
return
|
|
1191
|
+
return l;
|
|
1178
1192
|
},
|
|
1179
|
-
get(E, y) {
|
|
1180
|
-
if (typeof y == "symbol") return;
|
|
1193
|
+
get(E, y, b) {
|
|
1194
|
+
if (typeof y == "symbol") return Reflect.get(l, y, b);
|
|
1181
1195
|
if (y === "toJSON") return p;
|
|
1182
1196
|
if (y === "__context") return r.getContext();
|
|
1183
1197
|
if (y === "__typename") return e.typename;
|
|
1184
|
-
if (
|
|
1185
|
-
const
|
|
1186
|
-
if (
|
|
1187
|
-
return
|
|
1188
|
-
const
|
|
1189
|
-
if (
|
|
1190
|
-
let C =
|
|
1191
|
-
return C || (C =
|
|
1198
|
+
if (_?.value, i.consume(), typeof y == "string") {
|
|
1199
|
+
const D = e._extraGetters;
|
|
1200
|
+
if (D !== void 0 && y in D)
|
|
1201
|
+
return D[y]();
|
|
1202
|
+
const A = e._extraMethods;
|
|
1203
|
+
if (A !== void 0 && y in A) {
|
|
1204
|
+
let C = h.get(y);
|
|
1205
|
+
return C || (C = A[y].bind(v), h.set(y, C)), C;
|
|
1192
1206
|
}
|
|
1193
1207
|
if (a && y in a) {
|
|
1194
|
-
let C =
|
|
1195
|
-
return C || (C =
|
|
1208
|
+
let C = h.get(y);
|
|
1209
|
+
return C || (C = Ce(v, a[y].bind(v)), h.set(y, C)), C;
|
|
1196
1210
|
}
|
|
1197
1211
|
}
|
|
1198
|
-
const
|
|
1199
|
-
if (typeof
|
|
1200
|
-
return
|
|
1201
|
-
if (Array.isArray(
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1204
|
-
const
|
|
1205
|
-
if (
|
|
1206
|
-
const C =
|
|
1212
|
+
const w = e.data[y];
|
|
1213
|
+
if (typeof w == "object" && w !== null && tt.has(w))
|
|
1214
|
+
return x(w.getValue());
|
|
1215
|
+
if (Array.isArray(w) && typeof y == "string") {
|
|
1216
|
+
const D = s[y];
|
|
1217
|
+
if (D instanceof m && (D.mask & d.ARRAY) !== 0) {
|
|
1218
|
+
const A = D.shape;
|
|
1219
|
+
if (A instanceof m && (A.mask & d.ENTITY) !== 0) {
|
|
1220
|
+
const C = A.typenameValue;
|
|
1207
1221
|
if (C !== void 0) {
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1210
|
-
const
|
|
1211
|
-
if (
|
|
1212
|
-
return
|
|
1213
|
-
const
|
|
1214
|
-
return g.set(y, { source:
|
|
1222
|
+
const Ot = r.getEntityDefsForTypename(C);
|
|
1223
|
+
if (Ot !== void 0 && Ot.length > 1) {
|
|
1224
|
+
const et = g.get(y);
|
|
1225
|
+
if (et !== void 0 && et.source === w)
|
|
1226
|
+
return x(et.filtered);
|
|
1227
|
+
const St = gn(w, A, r);
|
|
1228
|
+
return g.set(y, { source: w, filtered: St }), x(St);
|
|
1215
1229
|
}
|
|
1216
1230
|
}
|
|
1217
1231
|
}
|
|
1218
1232
|
}
|
|
1219
|
-
return
|
|
1233
|
+
return x(w);
|
|
1220
1234
|
}
|
|
1221
|
-
return
|
|
1235
|
+
return x(w);
|
|
1222
1236
|
},
|
|
1223
1237
|
set() {
|
|
1224
1238
|
throw new Error("Entity properties are read-only");
|
|
@@ -1226,36 +1240,36 @@ function yn(e, t, n, i, r) {
|
|
|
1226
1240
|
has(E, y) {
|
|
1227
1241
|
if (y === "__typename") return !0;
|
|
1228
1242
|
if (typeof y == "string") {
|
|
1229
|
-
const
|
|
1230
|
-
if (
|
|
1231
|
-
const
|
|
1232
|
-
if (
|
|
1243
|
+
const b = e._extraGetters;
|
|
1244
|
+
if (b && y in b) return !0;
|
|
1245
|
+
const w = e._extraMethods;
|
|
1246
|
+
if (w && y in w || a && y in a) return !0;
|
|
1233
1247
|
}
|
|
1234
1248
|
return y in s;
|
|
1235
1249
|
},
|
|
1236
1250
|
ownKeys() {
|
|
1237
|
-
return
|
|
1251
|
+
return U();
|
|
1238
1252
|
},
|
|
1239
1253
|
getOwnPropertyDescriptor(E, y) {
|
|
1240
1254
|
if (y === "__typename")
|
|
1241
1255
|
return { enumerable: !0, configurable: !0, value: e.typename, writable: !1 };
|
|
1242
1256
|
if (y in s)
|
|
1243
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1257
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, v), writable: !1 };
|
|
1244
1258
|
if (typeof y == "string") {
|
|
1245
|
-
const
|
|
1246
|
-
if (_ && y in _)
|
|
1247
|
-
return { enumerable: !0, configurable: !0, value: U.get(E, y, v), writable: !1 };
|
|
1248
|
-
const b = e._extraMethods;
|
|
1259
|
+
const b = e._extraGetters;
|
|
1249
1260
|
if (b && y in b)
|
|
1250
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1261
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, v), writable: !1 };
|
|
1262
|
+
const w = e._extraMethods;
|
|
1263
|
+
if (w && y in w)
|
|
1264
|
+
return { enumerable: !0, configurable: !0, value: q.get(E, y, v), writable: !1 };
|
|
1251
1265
|
if (a && y in a)
|
|
1252
|
-
return { enumerable: !1, configurable: !0, value:
|
|
1266
|
+
return { enumerable: !1, configurable: !0, value: q.get(E, y, v), writable: !1 };
|
|
1253
1267
|
}
|
|
1254
1268
|
}
|
|
1255
1269
|
};
|
|
1256
|
-
return v = new Proxy({},
|
|
1270
|
+
return v = new Proxy({}, q), O.set(v, t), be(v, r), v;
|
|
1257
1271
|
}
|
|
1258
|
-
class
|
|
1272
|
+
class vn {
|
|
1259
1273
|
instances = /* @__PURE__ */ new Map();
|
|
1260
1274
|
persistEntity;
|
|
1261
1275
|
constructor(t) {
|
|
@@ -1277,7 +1291,7 @@ class pn {
|
|
|
1277
1291
|
if (typeof a != "string" && typeof a != "number")
|
|
1278
1292
|
throw new Error(`Entity id must be string or number: ${i.typenameValue}`);
|
|
1279
1293
|
const c = i;
|
|
1280
|
-
s = new
|
|
1294
|
+
s = new pn(t, i.typenameValue, a, o, n, r), s._entityCache = c._entityCache, this.instances.set(t, s);
|
|
1281
1295
|
}
|
|
1282
1296
|
return s.parseId = r.currentParseId, s;
|
|
1283
1297
|
}
|
|
@@ -1293,13 +1307,13 @@ class pn {
|
|
|
1293
1307
|
this.persistEntity(t.key, t.data, n);
|
|
1294
1308
|
}
|
|
1295
1309
|
}
|
|
1296
|
-
class
|
|
1310
|
+
class fe {
|
|
1297
1311
|
onlineSignal;
|
|
1298
1312
|
manualOverride = void 0;
|
|
1299
1313
|
eventListenersAttached = !1;
|
|
1300
1314
|
constructor(t) {
|
|
1301
1315
|
const n = t ?? this.detectOnlineStatus();
|
|
1302
|
-
this.onlineSignal =
|
|
1316
|
+
this.onlineSignal = Lt(n), this.canAttachListeners() && this.attachEventListeners();
|
|
1303
1317
|
}
|
|
1304
1318
|
/**
|
|
1305
1319
|
* Returns true if the network is currently online
|
|
@@ -1357,8 +1371,8 @@ class ce {
|
|
|
1357
1371
|
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1358
1372
|
}
|
|
1359
1373
|
}
|
|
1360
|
-
class
|
|
1361
|
-
static onlineSignal =
|
|
1374
|
+
class ue {
|
|
1375
|
+
static onlineSignal = Lt(!0);
|
|
1362
1376
|
get isOnline() {
|
|
1363
1377
|
return !0;
|
|
1364
1378
|
}
|
|
@@ -1367,19 +1381,19 @@ class fe {
|
|
|
1367
1381
|
clearManualOverride() {
|
|
1368
1382
|
}
|
|
1369
1383
|
getOnlineSignal() {
|
|
1370
|
-
return
|
|
1384
|
+
return ue.onlineSignal;
|
|
1371
1385
|
}
|
|
1372
1386
|
destroy() {
|
|
1373
1387
|
}
|
|
1374
1388
|
}
|
|
1375
|
-
const
|
|
1376
|
-
function
|
|
1389
|
+
const _n = new fe(), Ln = Ut(_n);
|
|
1390
|
+
function bt(e, t = typeof window > "u") {
|
|
1377
1391
|
let n;
|
|
1378
1392
|
e === !1 ? n = 0 : e === void 0 || e === !0 ? n = t ? 0 : 3 : typeof e == "number" ? n = e : n = e.retries;
|
|
1379
1393
|
const i = typeof e == "object" && e.retryDelay ? e.retryDelay : (r) => 1e3 * Math.pow(2, r);
|
|
1380
1394
|
return { retries: n, retryDelay: i };
|
|
1381
1395
|
}
|
|
1382
|
-
class
|
|
1396
|
+
class Un {
|
|
1383
1397
|
static cache;
|
|
1384
1398
|
/**
|
|
1385
1399
|
* The adapter class responsible for sending requests for this query type.
|
|
@@ -1389,99 +1403,99 @@ class jn {
|
|
|
1389
1403
|
params;
|
|
1390
1404
|
config;
|
|
1391
1405
|
constructor() {
|
|
1392
|
-
return
|
|
1406
|
+
return Yt(this);
|
|
1393
1407
|
}
|
|
1394
1408
|
}
|
|
1395
|
-
const
|
|
1396
|
-
class
|
|
1409
|
+
const Ft = /* @__PURE__ */ new WeakMap();
|
|
1410
|
+
class H {
|
|
1397
1411
|
constructor(t, n) {
|
|
1398
1412
|
this.captured = n, this.statics = t;
|
|
1399
1413
|
}
|
|
1400
1414
|
statics;
|
|
1401
1415
|
createExecutionContext(t, n) {
|
|
1402
|
-
return
|
|
1416
|
+
return rt(this.captured, t, n);
|
|
1403
1417
|
}
|
|
1404
1418
|
resolveOptions(t) {
|
|
1405
|
-
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 = bt(i?.retry);
|
|
1406
1420
|
return { config: i, retryConfig: r };
|
|
1407
1421
|
}
|
|
1408
1422
|
static for(t) {
|
|
1409
|
-
let n =
|
|
1423
|
+
let n = Ft.get(t);
|
|
1410
1424
|
if (n !== void 0)
|
|
1411
1425
|
return n;
|
|
1412
|
-
const i = new t(), r =
|
|
1426
|
+
const i = new t(), r = $e(i), s = String(r.methods.getIdentityKey.call(r.fields)), o = r.fields.result, a = o instanceof m ? o : sn.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = r.fields.fetchNext, u = t.adapter;
|
|
1413
1427
|
if (!u)
|
|
1414
1428
|
throw new Error(
|
|
1415
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.`
|
|
1416
1430
|
);
|
|
1417
|
-
const
|
|
1431
|
+
const h = typeof u.prototype.sendNext == "function", g = c ? a : new m(
|
|
1418
1432
|
d.ENTITY | d.OBJECT,
|
|
1419
1433
|
a.shape,
|
|
1420
1434
|
void 0,
|
|
1421
1435
|
void 0,
|
|
1422
1436
|
s,
|
|
1423
1437
|
// typenameValue — unique per query class
|
|
1424
|
-
|
|
1438
|
+
Vt
|
|
1425
1439
|
// idField — symbol, injected onto payload before parse
|
|
1426
1440
|
);
|
|
1427
|
-
return n = new
|
|
1428
|
-
{ id: s, shape: g, cache: f, rawFetchNext:
|
|
1441
|
+
return n = new H(
|
|
1442
|
+
{ id: s, shape: g, cache: f, rawFetchNext: l, hasSendNext: h, isEntityResult: c, adapterClass: u },
|
|
1429
1443
|
r
|
|
1430
|
-
),
|
|
1444
|
+
), Ft.set(t, n), n;
|
|
1431
1445
|
}
|
|
1432
1446
|
}
|
|
1433
|
-
const
|
|
1434
|
-
const n =
|
|
1435
|
-
return
|
|
1447
|
+
const qn = (e, t) => {
|
|
1448
|
+
const n = H.for(e);
|
|
1449
|
+
return Ct(n, t);
|
|
1436
1450
|
};
|
|
1437
|
-
function
|
|
1438
|
-
const n =
|
|
1451
|
+
function Vn(e, ...t) {
|
|
1452
|
+
const n = H.for(e), i = Oe(kn);
|
|
1439
1453
|
if (i === void 0)
|
|
1440
1454
|
throw new Error("QueryClient not found");
|
|
1441
1455
|
const r = t[0];
|
|
1442
1456
|
return i.getQuery(n, r);
|
|
1443
1457
|
}
|
|
1444
|
-
function
|
|
1458
|
+
function ct(e) {
|
|
1445
1459
|
if (e.reason !== void 0) return e.reason;
|
|
1446
1460
|
if (typeof DOMException < "u")
|
|
1447
1461
|
return new DOMException("The operation was aborted", "AbortError");
|
|
1448
1462
|
const t = new Error("The operation was aborted");
|
|
1449
1463
|
return t.name = "AbortError", t;
|
|
1450
1464
|
}
|
|
1451
|
-
function
|
|
1465
|
+
function de(e, t) {
|
|
1452
1466
|
return new Promise((n, i) => {
|
|
1453
1467
|
if (t?.aborted) {
|
|
1454
|
-
i(
|
|
1468
|
+
i(ct(t));
|
|
1455
1469
|
return;
|
|
1456
1470
|
}
|
|
1457
1471
|
const r = setTimeout(n, e);
|
|
1458
1472
|
t?.addEventListener(
|
|
1459
1473
|
"abort",
|
|
1460
1474
|
() => {
|
|
1461
|
-
clearTimeout(r), i(
|
|
1475
|
+
clearTimeout(r), i(ct(t));
|
|
1462
1476
|
},
|
|
1463
1477
|
{ once: !0 }
|
|
1464
1478
|
);
|
|
1465
1479
|
});
|
|
1466
1480
|
}
|
|
1467
|
-
async function
|
|
1481
|
+
async function ft(e, t, n) {
|
|
1468
1482
|
if (t.retries < 0)
|
|
1469
1483
|
throw new Error("retries must be non-negative");
|
|
1470
1484
|
const i = Math.max(0, t.retries);
|
|
1471
1485
|
let r;
|
|
1472
1486
|
for (let s = 0; s <= i; s++) {
|
|
1473
1487
|
if (n?.aborted)
|
|
1474
|
-
throw
|
|
1488
|
+
throw ct(n);
|
|
1475
1489
|
try {
|
|
1476
1490
|
return await e();
|
|
1477
1491
|
} catch (o) {
|
|
1478
1492
|
if (r = o, s >= i) throw o;
|
|
1479
|
-
await
|
|
1493
|
+
await de(t.retryDelay(s), n);
|
|
1480
1494
|
}
|
|
1481
1495
|
}
|
|
1482
1496
|
throw r;
|
|
1483
1497
|
}
|
|
1484
|
-
class
|
|
1498
|
+
class wn {
|
|
1485
1499
|
def;
|
|
1486
1500
|
queryKey;
|
|
1487
1501
|
storageKey = -1;
|
|
@@ -1499,7 +1513,7 @@ class mn {
|
|
|
1499
1513
|
debounceTimer = void 0;
|
|
1500
1514
|
/** Resolved per-instance options (depend on actual params). */
|
|
1501
1515
|
config = void 0;
|
|
1502
|
-
retryConfig =
|
|
1516
|
+
retryConfig = bt(void 0);
|
|
1503
1517
|
/** Cancels in-flight fetches and retry waits. */
|
|
1504
1518
|
_abortController = void 0;
|
|
1505
1519
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
@@ -1522,23 +1536,23 @@ class mn {
|
|
|
1522
1536
|
}
|
|
1523
1537
|
constructor(t, n, i, r) {
|
|
1524
1538
|
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);
|
|
1525
|
-
const s =
|
|
1526
|
-
this._queryId = s !== void 0 ? N(s) : 0, this.relay =
|
|
1539
|
+
const s = jt(r);
|
|
1540
|
+
this._queryId = s !== void 0 ? N(s) : 0, this.relay = $t(
|
|
1527
1541
|
(o) => {
|
|
1528
1542
|
this._relayState = o;
|
|
1529
1543
|
const a = () => {
|
|
1530
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;
|
|
1531
|
-
const f = this.config?.gcTime ??
|
|
1532
|
-
this.queryClient.gcManager.schedule(this.queryKey, f,
|
|
1545
|
+
const f = this.config?.gcTime ?? qt;
|
|
1546
|
+
this.queryClient.gcManager.schedule(this.queryKey, f, Z.Query);
|
|
1533
1547
|
}, c = (f = !1) => {
|
|
1534
|
-
const { wasPaused:
|
|
1535
|
-
if (this.wasPaused = u, u && !
|
|
1548
|
+
const { wasPaused: l, isPaused: u, initialized: h } = this;
|
|
1549
|
+
if (this.wasPaused = u, u && !l && h) {
|
|
1536
1550
|
a();
|
|
1537
1551
|
return;
|
|
1538
1552
|
}
|
|
1539
1553
|
this._isActive = !0;
|
|
1540
|
-
const g =
|
|
1541
|
-
|
|
1554
|
+
const g = jt(this.params), p = Ct(this.def, g), _ = p !== this.storageKey;
|
|
1555
|
+
_ && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), this.relayState.isPending && this._abortController === void 0 ? this.runQueryImmediately() : (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : _ && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1542
1556
|
};
|
|
1543
1557
|
return c(!0), {
|
|
1544
1558
|
update: c,
|
|
@@ -1587,7 +1601,7 @@ class mn {
|
|
|
1587
1601
|
if (!this.isPaused)
|
|
1588
1602
|
try {
|
|
1589
1603
|
if (i !== void 0 && this.setupSubscription(), i === void 0 || this.isStale) {
|
|
1590
|
-
if (await
|
|
1604
|
+
if (await de(0), this.isPaused) return;
|
|
1591
1605
|
this.runQueryImmediately();
|
|
1592
1606
|
}
|
|
1593
1607
|
} catch (r) {
|
|
@@ -1618,7 +1632,7 @@ class mn {
|
|
|
1618
1632
|
if (this.isPaused)
|
|
1619
1633
|
throw new Error("Query is paused due to network status");
|
|
1620
1634
|
const n = this.getOrCreateExecutionContext(), i = this.queryClient.getAdapter(t.statics.adapterClass), r = this._abortController?.signal ?? new AbortController().signal;
|
|
1621
|
-
return
|
|
1635
|
+
return ft(
|
|
1622
1636
|
async () => {
|
|
1623
1637
|
const s = await i.send(n, r);
|
|
1624
1638
|
this.updatedAt = Date.now();
|
|
@@ -1674,7 +1688,7 @@ class mn {
|
|
|
1674
1688
|
const n = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
|
|
1675
1689
|
i.resultData = this.rootEntity.data;
|
|
1676
1690
|
const r = this.queryClient.getAdapter(t.statics.adapterClass);
|
|
1677
|
-
return
|
|
1691
|
+
return ft(
|
|
1678
1692
|
async () => {
|
|
1679
1693
|
const s = await r.sendNext(i, n);
|
|
1680
1694
|
this.updatedAt = Date.now();
|
|
@@ -1695,21 +1709,21 @@ class mn {
|
|
|
1695
1709
|
return Date.now() - this.updatedAt >= t;
|
|
1696
1710
|
}
|
|
1697
1711
|
get isPaused() {
|
|
1698
|
-
const t = this.config?.networkMode ??
|
|
1699
|
-
if (t ===
|
|
1712
|
+
const t = this.config?.networkMode ?? K.Online;
|
|
1713
|
+
if (t === K.Always)
|
|
1700
1714
|
return !1;
|
|
1701
1715
|
const n = this.queryClient.networkManager.getOnlineSignal().value;
|
|
1702
1716
|
switch (t) {
|
|
1703
|
-
case
|
|
1717
|
+
case K.Online:
|
|
1704
1718
|
return !n;
|
|
1705
|
-
case
|
|
1719
|
+
case K.OfflineFirst:
|
|
1706
1720
|
return !n && this.updatedAt === void 0;
|
|
1707
1721
|
default:
|
|
1708
1722
|
return !1;
|
|
1709
1723
|
}
|
|
1710
1724
|
}
|
|
1711
1725
|
}
|
|
1712
|
-
class
|
|
1726
|
+
class En {
|
|
1713
1727
|
def;
|
|
1714
1728
|
queryClient;
|
|
1715
1729
|
_inFlight = !1;
|
|
@@ -1738,8 +1752,8 @@ class vn {
|
|
|
1738
1752
|
if (!(n instanceof m))
|
|
1739
1753
|
return t;
|
|
1740
1754
|
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1741
|
-
}), r = new
|
|
1742
|
-
return r.reset(void 0, void 0, i),
|
|
1755
|
+
}), r = new at();
|
|
1756
|
+
return r.reset(void 0, void 0, i), se(t, n, r);
|
|
1743
1757
|
}
|
|
1744
1758
|
// ======================================================
|
|
1745
1759
|
// Effects processing
|
|
@@ -1747,7 +1761,7 @@ class vn {
|
|
|
1747
1761
|
processEffects(t, n) {
|
|
1748
1762
|
let i;
|
|
1749
1763
|
if (this.def.hasGetEffects) {
|
|
1750
|
-
const s =
|
|
1764
|
+
const s = rt(
|
|
1751
1765
|
this.def.captured,
|
|
1752
1766
|
t ?? {},
|
|
1753
1767
|
this.queryClient.getContext()
|
|
@@ -1755,23 +1769,23 @@ class vn {
|
|
|
1755
1769
|
s.result = n, i = s.getEffects();
|
|
1756
1770
|
} else if (this.def.effects !== void 0) {
|
|
1757
1771
|
const s = { params: t, result: n };
|
|
1758
|
-
i =
|
|
1772
|
+
i = X(this.def.effects, s);
|
|
1759
1773
|
}
|
|
1760
1774
|
if (i === void 0) return;
|
|
1761
1775
|
const r = this.queryClient;
|
|
1762
|
-
|
|
1776
|
+
nt(i.creates, "create", r), nt(i.updates, "update", r), nt(i.deletes, "delete", r), i.invalidates && r.invalidateQueries(i.invalidates);
|
|
1763
1777
|
}
|
|
1764
1778
|
// ======================================================
|
|
1765
1779
|
// Retry logic
|
|
1766
1780
|
// ======================================================
|
|
1767
1781
|
executeWithRetry(t) {
|
|
1768
|
-
const n =
|
|
1782
|
+
const n = bt(this.def.config?.retry, !0), i = this.queryClient.getAdapter(this.def.adapterClass);
|
|
1769
1783
|
if (!i.sendMutation)
|
|
1770
1784
|
throw new Error(
|
|
1771
1785
|
`Adapter "${this.def.adapterClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1772
1786
|
);
|
|
1773
|
-
return
|
|
1774
|
-
const r = new AbortController(), s =
|
|
1787
|
+
return ft(async () => {
|
|
1788
|
+
const r = new AbortController(), s = rt(
|
|
1775
1789
|
this.def.captured,
|
|
1776
1790
|
t ?? {},
|
|
1777
1791
|
this.queryClient.getContext()
|
|
@@ -1780,24 +1794,24 @@ class vn {
|
|
|
1780
1794
|
}, n);
|
|
1781
1795
|
}
|
|
1782
1796
|
}
|
|
1783
|
-
function
|
|
1784
|
-
return typeof e == "string" ? e :
|
|
1797
|
+
function bn(e) {
|
|
1798
|
+
return typeof e == "string" ? e : $(e).typenameValue;
|
|
1785
1799
|
}
|
|
1786
|
-
function
|
|
1800
|
+
function nt(e, t, n) {
|
|
1787
1801
|
if (e)
|
|
1788
1802
|
for (const [i, r] of e) {
|
|
1789
|
-
const s =
|
|
1803
|
+
const s = bn(i);
|
|
1790
1804
|
s !== void 0 && n.applyMutationEvent({ type: t, typename: s, data: r });
|
|
1791
1805
|
}
|
|
1792
1806
|
}
|
|
1793
|
-
const
|
|
1807
|
+
const le = "__eventSource";
|
|
1794
1808
|
function he(e) {
|
|
1795
1809
|
return { field: e, segments: e.indexOf(".") !== -1 ? e.split(".") : void 0 };
|
|
1796
1810
|
}
|
|
1797
|
-
function
|
|
1811
|
+
function Cn(e) {
|
|
1798
1812
|
return e.map(he);
|
|
1799
1813
|
}
|
|
1800
|
-
function
|
|
1814
|
+
function On(e, t) {
|
|
1801
1815
|
if (t.segments === void 0) return e[t.field];
|
|
1802
1816
|
let n = e;
|
|
1803
1817
|
for (const i of t.segments) {
|
|
@@ -1806,44 +1820,44 @@ function En(e, t) {
|
|
|
1806
1820
|
}
|
|
1807
1821
|
return n;
|
|
1808
1822
|
}
|
|
1809
|
-
function
|
|
1823
|
+
function ye(e, t) {
|
|
1810
1824
|
const n = [];
|
|
1811
1825
|
for (let i = 0; i < t.length; i++) {
|
|
1812
|
-
const r = t[i], s =
|
|
1826
|
+
const r = t[i], s = On(e, r);
|
|
1813
1827
|
if (s === void 0) return;
|
|
1814
1828
|
n.push(r.field, s);
|
|
1815
1829
|
}
|
|
1816
1830
|
return N(n);
|
|
1817
1831
|
}
|
|
1818
|
-
function
|
|
1832
|
+
function Sn(e, t) {
|
|
1819
1833
|
if (e === void 0) return;
|
|
1820
1834
|
const n = /* @__PURE__ */ new Map();
|
|
1821
1835
|
for (const [i, r] of e) {
|
|
1822
1836
|
const s = r.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
|
|
1823
1837
|
let a = !0;
|
|
1824
1838
|
for (const [c, f] of s) {
|
|
1825
|
-
let
|
|
1826
|
-
if (
|
|
1827
|
-
const u =
|
|
1828
|
-
|
|
1839
|
+
let l;
|
|
1840
|
+
if (Bt(f)) {
|
|
1841
|
+
const u = Qt(f);
|
|
1842
|
+
l = yt(u, t);
|
|
1829
1843
|
} else
|
|
1830
|
-
|
|
1831
|
-
if (
|
|
1844
|
+
l = f;
|
|
1845
|
+
if (l === void 0) {
|
|
1832
1846
|
a = !1;
|
|
1833
1847
|
break;
|
|
1834
1848
|
}
|
|
1835
|
-
o.push(c,
|
|
1849
|
+
o.push(c, l);
|
|
1836
1850
|
}
|
|
1837
1851
|
a && n.set(i, N(o));
|
|
1838
1852
|
}
|
|
1839
1853
|
return n.size > 0 ? n : void 0;
|
|
1840
1854
|
}
|
|
1841
|
-
function
|
|
1855
|
+
function Mt(e, t) {
|
|
1842
1856
|
const n = e.get(t);
|
|
1843
1857
|
if (n !== void 0)
|
|
1844
1858
|
return n.map(([i]) => i).sort();
|
|
1845
1859
|
}
|
|
1846
|
-
class
|
|
1860
|
+
class Rn {
|
|
1847
1861
|
fields;
|
|
1848
1862
|
fieldPaths;
|
|
1849
1863
|
_bindings = /* @__PURE__ */ new Map();
|
|
@@ -1865,56 +1879,56 @@ class Cn {
|
|
|
1865
1879
|
return this._bindings.size === 0;
|
|
1866
1880
|
}
|
|
1867
1881
|
}
|
|
1868
|
-
function
|
|
1882
|
+
function Tt(e) {
|
|
1869
1883
|
return N(e);
|
|
1870
1884
|
}
|
|
1871
|
-
class
|
|
1885
|
+
class An {
|
|
1872
1886
|
_groups = /* @__PURE__ */ new Map();
|
|
1873
1887
|
getOrCreateGroup(t) {
|
|
1874
|
-
const n =
|
|
1888
|
+
const n = Tt(t);
|
|
1875
1889
|
let i = this._groups.get(n);
|
|
1876
|
-
return i === void 0 && (i = new
|
|
1890
|
+
return i === void 0 && (i = new Rn(t), this._groups.set(n, i)), i;
|
|
1877
1891
|
}
|
|
1878
1892
|
register(t, n, i) {
|
|
1879
1893
|
this.getOrCreateGroup(n).register(t, i);
|
|
1880
1894
|
}
|
|
1881
1895
|
unregister(t, n, i) {
|
|
1882
|
-
const r =
|
|
1896
|
+
const r = Tt(n), s = this._groups.get(r);
|
|
1883
1897
|
s !== void 0 && (s.unregister(t, i), s.isEmpty && this._groups.delete(r));
|
|
1884
1898
|
}
|
|
1885
1899
|
registerBinding(t, n) {
|
|
1886
1900
|
const i = t._constraintHashes.get(n);
|
|
1887
1901
|
if (i === void 0) return;
|
|
1888
|
-
const r =
|
|
1902
|
+
const r = Mt(t._constraintFieldRefs, n);
|
|
1889
1903
|
r !== void 0 && this.register(i, r, t);
|
|
1890
1904
|
}
|
|
1891
1905
|
unregisterBinding(t, n) {
|
|
1892
1906
|
const i = t._constraintHashes.get(n);
|
|
1893
1907
|
if (i === void 0) return;
|
|
1894
|
-
const r =
|
|
1908
|
+
const r = Mt(t._constraintFieldRefs, n);
|
|
1895
1909
|
r !== void 0 && this.unregister(i, r, t);
|
|
1896
1910
|
}
|
|
1897
1911
|
routeEvent(t, n, i, r, s, o) {
|
|
1898
1912
|
for (const a of this._groups.values()) {
|
|
1899
|
-
const c =
|
|
1913
|
+
const c = ye(n, a.fieldPaths);
|
|
1900
1914
|
if (c === void 0) continue;
|
|
1901
1915
|
const f = a.getMatching(c);
|
|
1902
1916
|
if (f !== void 0)
|
|
1903
|
-
for (const
|
|
1904
|
-
|
|
1917
|
+
for (const l of f)
|
|
1918
|
+
l.onEvent(t, i, r, s, o);
|
|
1905
1919
|
}
|
|
1906
1920
|
}
|
|
1907
1921
|
}
|
|
1908
|
-
function
|
|
1922
|
+
function Pt(e) {
|
|
1909
1923
|
const t = /* @__PURE__ */ new Set();
|
|
1910
1924
|
for (const n of e)
|
|
1911
1925
|
if (typeof n == "object" && n !== null) {
|
|
1912
|
-
const i =
|
|
1926
|
+
const i = P(n);
|
|
1913
1927
|
i !== void 0 && t.add(i);
|
|
1914
1928
|
}
|
|
1915
1929
|
return t;
|
|
1916
1930
|
}
|
|
1917
|
-
class
|
|
1931
|
+
class pe {
|
|
1918
1932
|
_queryClient;
|
|
1919
1933
|
_parent;
|
|
1920
1934
|
_constraintHashes;
|
|
@@ -1925,7 +1939,7 @@ class ye {
|
|
|
1925
1939
|
this._queryClient = i, this._parent = r, this._constraintHashes = s, this._constraintFieldRefs = n, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1926
1940
|
for (const a of t)
|
|
1927
1941
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1928
|
-
|
|
1942
|
+
tt.add(this);
|
|
1929
1943
|
}
|
|
1930
1944
|
getValue() {
|
|
1931
1945
|
return this.instance.getValue();
|
|
@@ -1964,7 +1978,7 @@ class ye {
|
|
|
1964
1978
|
n !== -1 && t.splice(n, 1);
|
|
1965
1979
|
}
|
|
1966
1980
|
}
|
|
1967
|
-
class
|
|
1981
|
+
class xn {
|
|
1968
1982
|
_notifier;
|
|
1969
1983
|
_items;
|
|
1970
1984
|
_keys;
|
|
@@ -1972,31 +1986,31 @@ class On {
|
|
|
1972
1986
|
_queryClient;
|
|
1973
1987
|
_parent;
|
|
1974
1988
|
constructor(t, n, i, r, s, o) {
|
|
1975
|
-
this._notifier =
|
|
1989
|
+
this._notifier = dt(), this._items = i, this._keys = Pt(i), this._queryClient = t, this._parent = n;
|
|
1976
1990
|
const a = r !== void 0 && s !== void 0, c = o !== void 0;
|
|
1977
|
-
(a || c) && (this._outputSignal =
|
|
1991
|
+
(a || c) && (this._outputSignal = Re(() => {
|
|
1978
1992
|
this._notifier.consume();
|
|
1979
1993
|
let f = this._items;
|
|
1980
1994
|
if (a) {
|
|
1981
|
-
const
|
|
1995
|
+
const l = [];
|
|
1982
1996
|
for (const u of f) {
|
|
1983
1997
|
if (typeof u != "object" || u === null) {
|
|
1984
|
-
|
|
1998
|
+
l.push(u);
|
|
1985
1999
|
continue;
|
|
1986
2000
|
}
|
|
1987
|
-
const
|
|
1988
|
-
if (
|
|
1989
|
-
|
|
2001
|
+
const h = P(u);
|
|
2002
|
+
if (h === void 0) {
|
|
2003
|
+
l.push(u);
|
|
1990
2004
|
continue;
|
|
1991
2005
|
}
|
|
1992
|
-
const g = t.entityMap.getEntity(
|
|
2006
|
+
const g = t.entityMap.getEntity(h);
|
|
1993
2007
|
if (g === void 0) {
|
|
1994
|
-
|
|
2008
|
+
l.push(u);
|
|
1995
2009
|
continue;
|
|
1996
2010
|
}
|
|
1997
|
-
g.consume(),
|
|
2011
|
+
g.consume(), ye(g.data, r) === s && l.push(u);
|
|
1998
2012
|
}
|
|
1999
|
-
f =
|
|
2013
|
+
f = l;
|
|
2000
2014
|
}
|
|
2001
2015
|
return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
|
|
2002
2016
|
}));
|
|
@@ -2039,10 +2053,10 @@ class On {
|
|
|
2039
2053
|
}
|
|
2040
2054
|
reset(t) {
|
|
2041
2055
|
const n = this._items, i = Array.isArray(t) ? t : [];
|
|
2042
|
-
this._items = i, this._keys =
|
|
2056
|
+
this._items = i, this._keys = Pt(i);
|
|
2043
2057
|
for (const r of i)
|
|
2044
2058
|
if (typeof r == "object" && r !== null) {
|
|
2045
|
-
const s =
|
|
2059
|
+
const s = P(r);
|
|
2046
2060
|
if (s !== void 0) {
|
|
2047
2061
|
const o = this._queryClient.entityMap.getEntity(s);
|
|
2048
2062
|
o !== void 0 && this._parent.addChildRef(o);
|
|
@@ -2050,7 +2064,7 @@ class On {
|
|
|
2050
2064
|
}
|
|
2051
2065
|
for (const r of n)
|
|
2052
2066
|
if (typeof r == "object" && r !== null) {
|
|
2053
|
-
const s =
|
|
2067
|
+
const s = P(r);
|
|
2054
2068
|
if (s !== void 0) {
|
|
2055
2069
|
const o = this._queryClient.entityMap.getEntity(s);
|
|
2056
2070
|
o !== void 0 && this._parent.removeChildRef(o);
|
|
@@ -2062,20 +2076,20 @@ class On {
|
|
|
2062
2076
|
if (Array.isArray(t))
|
|
2063
2077
|
for (const n of t) {
|
|
2064
2078
|
if (typeof n != "object" || n === null) continue;
|
|
2065
|
-
const i =
|
|
2079
|
+
const i = P(n);
|
|
2066
2080
|
i !== void 0 && this.add(i, n);
|
|
2067
2081
|
}
|
|
2068
2082
|
}
|
|
2069
2083
|
_findIndex(t) {
|
|
2070
2084
|
for (let n = 0; n < this._items.length; n++) {
|
|
2071
2085
|
const i = this._items[n];
|
|
2072
|
-
if (typeof i == "object" && i !== null &&
|
|
2086
|
+
if (typeof i == "object" && i !== null && P(i) === t)
|
|
2073
2087
|
return n;
|
|
2074
2088
|
}
|
|
2075
2089
|
return -1;
|
|
2076
2090
|
}
|
|
2077
2091
|
}
|
|
2078
|
-
class
|
|
2092
|
+
class Nn {
|
|
2079
2093
|
_notifier;
|
|
2080
2094
|
_value;
|
|
2081
2095
|
_createdKeys;
|
|
@@ -2086,7 +2100,7 @@ class Rn {
|
|
|
2086
2100
|
_onUpdate;
|
|
2087
2101
|
_onDelete;
|
|
2088
2102
|
constructor(t, n, i, r, s, o) {
|
|
2089
|
-
this._notifier =
|
|
2103
|
+
this._notifier = dt(), 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;
|
|
2090
2104
|
}
|
|
2091
2105
|
onEvent(t, n, i, r) {
|
|
2092
2106
|
switch (r) {
|
|
@@ -2116,39 +2130,39 @@ class Rn {
|
|
|
2116
2130
|
append(t) {
|
|
2117
2131
|
}
|
|
2118
2132
|
}
|
|
2119
|
-
function
|
|
2133
|
+
function ge(e, t, n, i, r) {
|
|
2120
2134
|
let s = e.constraintFieldRefs;
|
|
2121
2135
|
if (s === void 0) {
|
|
2122
2136
|
s = /* @__PURE__ */ new Map();
|
|
2123
2137
|
for (const f of e.entityDefs) {
|
|
2124
|
-
const
|
|
2125
|
-
|
|
2138
|
+
const l = f.typenameValue;
|
|
2139
|
+
l !== void 0 && s.set(l, [[le, n.key]]);
|
|
2126
2140
|
}
|
|
2127
2141
|
}
|
|
2128
|
-
const o =
|
|
2142
|
+
const o = Sn(s, i) ?? /* @__PURE__ */ new Map();
|
|
2129
2143
|
let a;
|
|
2130
|
-
if (e.type ===
|
|
2131
|
-
let f,
|
|
2144
|
+
if (e.type === lt.Array) {
|
|
2145
|
+
let f, l;
|
|
2132
2146
|
if (e.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2133
2147
|
for (const [u] of e.constraintFieldRefs) {
|
|
2134
|
-
const
|
|
2135
|
-
if (
|
|
2136
|
-
|
|
2148
|
+
const h = o.get(u);
|
|
2149
|
+
if (h !== void 0) {
|
|
2150
|
+
l = h;
|
|
2137
2151
|
const g = e.constraintFieldRefs.get(u);
|
|
2138
|
-
g !== void 0 && (f =
|
|
2152
|
+
g !== void 0 && (f = Cn(g.map(([p]) => p)));
|
|
2139
2153
|
break;
|
|
2140
2154
|
}
|
|
2141
2155
|
}
|
|
2142
|
-
a = new
|
|
2156
|
+
a = new xn(
|
|
2143
2157
|
r,
|
|
2144
2158
|
n,
|
|
2145
2159
|
Array.isArray(t) ? t : [],
|
|
2146
2160
|
f,
|
|
2147
|
-
|
|
2161
|
+
l,
|
|
2148
2162
|
e.sort
|
|
2149
2163
|
);
|
|
2150
2164
|
} else
|
|
2151
|
-
a = new
|
|
2165
|
+
a = new Nn(
|
|
2152
2166
|
r,
|
|
2153
2167
|
n,
|
|
2154
2168
|
t,
|
|
@@ -2156,7 +2170,7 @@ function pe(e, t, n, i, r) {
|
|
|
2156
2170
|
e.onUpdate,
|
|
2157
2171
|
e.onDelete
|
|
2158
2172
|
);
|
|
2159
|
-
const c = new
|
|
2173
|
+
const c = new pe(
|
|
2160
2174
|
e.entityDefs,
|
|
2161
2175
|
s,
|
|
2162
2176
|
r,
|
|
@@ -2166,74 +2180,74 @@ function pe(e, t, n, i, r) {
|
|
|
2166
2180
|
);
|
|
2167
2181
|
return n.liveCollections.push(c), r.registerLiveCollection(c), c;
|
|
2168
2182
|
}
|
|
2169
|
-
const
|
|
2170
|
-
function
|
|
2183
|
+
const me = Object.entries, ve = Object.prototype;
|
|
2184
|
+
function it(e, t, n, i = !1) {
|
|
2171
2185
|
const r = e.queryClient;
|
|
2172
2186
|
r.currentParseId++;
|
|
2173
2187
|
const s = e.seen, o = /* @__PURE__ */ new Map();
|
|
2174
|
-
return { data:
|
|
2188
|
+
return { data: G(t, s, r, n, o, i), entityRefs: o };
|
|
2175
2189
|
}
|
|
2176
|
-
function
|
|
2190
|
+
function G(e, t, n, i, r, s) {
|
|
2177
2191
|
if (typeof e != "object" || e === null) return e;
|
|
2178
2192
|
const o = t.get(e);
|
|
2179
2193
|
if (o !== void 0)
|
|
2180
|
-
return
|
|
2194
|
+
return Dn(o, t, n, i, r, s);
|
|
2181
2195
|
if (Array.isArray(e)) {
|
|
2182
2196
|
for (let a = 0; a < e.length; a++) {
|
|
2183
2197
|
const c = e[a];
|
|
2184
|
-
typeof c == "object" && c !== null && !(c instanceof
|
|
2198
|
+
typeof c == "object" && c !== null && !(c instanceof Y) && !O.has(c) && (e[a] = G(c, t, n, i, r, s));
|
|
2185
2199
|
}
|
|
2186
2200
|
return e;
|
|
2187
2201
|
}
|
|
2188
|
-
if (Object.getPrototypeOf(e) ===
|
|
2202
|
+
if (Object.getPrototypeOf(e) === ve && !O.has(e)) {
|
|
2189
2203
|
const a = e;
|
|
2190
2204
|
for (const c of Object.keys(a)) {
|
|
2191
2205
|
const f = a[c];
|
|
2192
|
-
typeof f == "object" && f !== null && !(f instanceof
|
|
2206
|
+
typeof f == "object" && f !== null && !(f instanceof Y) && !O.has(f) && (a[c] = G(f, t, n, i, r, s));
|
|
2193
2207
|
}
|
|
2194
2208
|
}
|
|
2195
2209
|
return e;
|
|
2196
2210
|
}
|
|
2197
|
-
function
|
|
2198
|
-
return typeof e == "object" && e !== null && !(e instanceof
|
|
2211
|
+
function _e(e) {
|
|
2212
|
+
return typeof e == "object" && e !== null && !(e instanceof Y) && !O.has(e);
|
|
2199
2213
|
}
|
|
2200
|
-
function
|
|
2201
|
-
const { key: o, data: a, shape: c, rawKeys: f } = e,
|
|
2202
|
-
if (g ? (
|
|
2203
|
-
h,
|
|
2204
|
-
a,
|
|
2214
|
+
function Dn(e, t, n, i, r, s) {
|
|
2215
|
+
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 ? (we(
|
|
2205
2217
|
l,
|
|
2218
|
+
a,
|
|
2219
|
+
h,
|
|
2206
2220
|
f,
|
|
2207
2221
|
u,
|
|
2208
|
-
|
|
2222
|
+
h,
|
|
2209
2223
|
t,
|
|
2210
2224
|
n,
|
|
2211
2225
|
i,
|
|
2212
2226
|
p,
|
|
2213
2227
|
s
|
|
2214
|
-
), u.notify()) :
|
|
2228
|
+
), u.notify()) : Ee(l, a, u, a, t, n, i, p, s), s && u.liveCollections.length > 0)
|
|
2215
2229
|
for (const v of u.liveCollections) {
|
|
2216
|
-
const
|
|
2217
|
-
if (Array.isArray(
|
|
2218
|
-
for (const
|
|
2219
|
-
if (typeof
|
|
2220
|
-
const R =
|
|
2230
|
+
const S = v.instance.getRawValue();
|
|
2231
|
+
if (Array.isArray(S))
|
|
2232
|
+
for (const T of S) {
|
|
2233
|
+
if (typeof T != "object" || T === null) continue;
|
|
2234
|
+
const R = O.get(T);
|
|
2221
2235
|
if (R === void 0) continue;
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2236
|
+
const U = n.entityMap.getEntity(R);
|
|
2237
|
+
U !== void 0 && p.set(U, (p.get(U) ?? 0) + 1);
|
|
2224
2238
|
}
|
|
2225
2239
|
}
|
|
2226
2240
|
u.setChildRefs(p.size > 0 ? p : void 0, i);
|
|
2227
|
-
const
|
|
2228
|
-
return r.set(u, (r.get(u) ?? 0) + 1),
|
|
2241
|
+
const _ = u.getProxy(c);
|
|
2242
|
+
return r.set(u, (r.get(u) ?? 0) + 1), _;
|
|
2229
2243
|
}
|
|
2230
|
-
function
|
|
2231
|
-
for (const [u,
|
|
2244
|
+
function we(e, t, n, i, r, s, o, a, c, f, l) {
|
|
2245
|
+
for (const [u, h] of me(e))
|
|
2232
2246
|
if (!(i !== void 0 && !i.has(u)))
|
|
2233
|
-
if (
|
|
2247
|
+
if (_e(t[u]) && (t[u] = G(t[u], o, a, c, f, l)), h instanceof m && h._liveConfig !== void 0) {
|
|
2234
2248
|
const g = n[u];
|
|
2235
|
-
g instanceof
|
|
2236
|
-
|
|
2249
|
+
g instanceof pe ? l ? g.append(t[u]) : g.reset(t[u]) : n[u] = ge(
|
|
2250
|
+
h._liveConfig,
|
|
2237
2251
|
t[u],
|
|
2238
2252
|
r,
|
|
2239
2253
|
s,
|
|
@@ -2241,11 +2255,11 @@ function _e(e, t, n, i, r, s, o, a, c, f, h) {
|
|
|
2241
2255
|
);
|
|
2242
2256
|
} else {
|
|
2243
2257
|
const g = t[u], p = n[u];
|
|
2244
|
-
if (
|
|
2245
|
-
const
|
|
2246
|
-
if (
|
|
2247
|
-
|
|
2248
|
-
|
|
2258
|
+
if (ut(g) && ut(p)) {
|
|
2259
|
+
const _ = h instanceof m && h.shape !== void 0 ? h.shape : void 0;
|
|
2260
|
+
if (_ !== void 0)
|
|
2261
|
+
we(
|
|
2262
|
+
_,
|
|
2249
2263
|
g,
|
|
2250
2264
|
p,
|
|
2251
2265
|
void 0,
|
|
@@ -2255,7 +2269,7 @@ function _e(e, t, n, i, r, s, o, a, c, f, h) {
|
|
|
2255
2269
|
a,
|
|
2256
2270
|
c,
|
|
2257
2271
|
f,
|
|
2258
|
-
|
|
2272
|
+
l
|
|
2259
2273
|
);
|
|
2260
2274
|
else
|
|
2261
2275
|
for (const v of Object.keys(g))
|
|
@@ -2265,12 +2279,12 @@ function _e(e, t, n, i, r, s, o, a, c, f, h) {
|
|
|
2265
2279
|
n[u] = g;
|
|
2266
2280
|
}
|
|
2267
2281
|
}
|
|
2268
|
-
function
|
|
2269
|
-
for (const [f,
|
|
2282
|
+
function Ee(e, t, n, i, r, s, o, a, c) {
|
|
2283
|
+
for (const [f, l] of me(e))
|
|
2270
2284
|
if (f in t)
|
|
2271
|
-
if (
|
|
2272
|
-
t[f] =
|
|
2273
|
-
|
|
2285
|
+
if (_e(t[f]) && (t[f] = G(t[f], r, s, o, a, c)), l instanceof m && l._liveConfig !== void 0)
|
|
2286
|
+
t[f] = ge(
|
|
2287
|
+
l._liveConfig,
|
|
2274
2288
|
t[f],
|
|
2275
2289
|
n,
|
|
2276
2290
|
i,
|
|
@@ -2278,32 +2292,32 @@ function we(e, t, n, i, r, s, o, a, c) {
|
|
|
2278
2292
|
);
|
|
2279
2293
|
else {
|
|
2280
2294
|
const u = t[f];
|
|
2281
|
-
if (
|
|
2282
|
-
const
|
|
2283
|
-
|
|
2295
|
+
if (ut(u)) {
|
|
2296
|
+
const h = l instanceof m && l.shape !== void 0 ? l.shape : void 0;
|
|
2297
|
+
h !== void 0 && Ee(h, u, n, i, r, s, o, a, c);
|
|
2284
2298
|
}
|
|
2285
2299
|
}
|
|
2286
2300
|
}
|
|
2287
|
-
function
|
|
2288
|
-
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) ===
|
|
2301
|
+
function ut(e) {
|
|
2302
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) === ve && !O.has(e);
|
|
2289
2303
|
}
|
|
2290
|
-
function
|
|
2304
|
+
function Kn(e) {
|
|
2291
2305
|
if (e !== void 0)
|
|
2292
2306
|
return typeof e == "string" ? e : typeof e == "function" ? e() : e.value;
|
|
2293
2307
|
}
|
|
2294
|
-
function
|
|
2295
|
-
return
|
|
2308
|
+
function In(e) {
|
|
2309
|
+
return Ae(e);
|
|
2296
2310
|
}
|
|
2297
|
-
function
|
|
2311
|
+
function jt(e) {
|
|
2298
2312
|
if (e === void 0)
|
|
2299
2313
|
return;
|
|
2300
2314
|
const t = {};
|
|
2301
2315
|
for (const [n, i] of Object.entries(e))
|
|
2302
|
-
|
|
2316
|
+
In(i) ? t[n] = i.value : t[n] = i;
|
|
2303
2317
|
return t;
|
|
2304
2318
|
}
|
|
2305
|
-
const
|
|
2306
|
-
class
|
|
2319
|
+
const Ct = (e, t) => N([e.statics.id, t]);
|
|
2320
|
+
class Bn {
|
|
2307
2321
|
entityMap;
|
|
2308
2322
|
queryInstances = /* @__PURE__ */ new Map();
|
|
2309
2323
|
mutationInstances = /* @__PURE__ */ new Map();
|
|
@@ -2320,7 +2334,7 @@ class qn {
|
|
|
2320
2334
|
networkUnsubscribe;
|
|
2321
2335
|
constructor(t = {}) {
|
|
2322
2336
|
const {
|
|
2323
|
-
store: n = new
|
|
2337
|
+
store: n = new Ie(new ke()),
|
|
2324
2338
|
log: i,
|
|
2325
2339
|
evictionMultiplier: r,
|
|
2326
2340
|
adapters: s,
|
|
@@ -2328,15 +2342,15 @@ class qn {
|
|
|
2328
2342
|
gcManager: a,
|
|
2329
2343
|
...c
|
|
2330
2344
|
} = t;
|
|
2331
|
-
this.isServer = typeof window > "u", this.store = n, this.context = { ...c, log: i ?? console, evictionMultiplier: r }, this.gcManager = t.gcManager ?? (this.isServer ? new
|
|
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 fe(), this.entityMap = new vn((u, h, g) => this.store.saveEntity(u, h, g));
|
|
2332
2346
|
for (const u of t.adapters ?? [])
|
|
2333
2347
|
this.adapters.set(u.constructor, u), u.register(this);
|
|
2334
|
-
const f = this.networkManager.getOnlineSignal(),
|
|
2335
|
-
this.networkUnsubscribe =
|
|
2348
|
+
const f = this.networkManager.getOnlineSignal(), l = xe(() => f.value);
|
|
2349
|
+
this.networkUnsubscribe = l.addListener(
|
|
2336
2350
|
() => {
|
|
2337
2351
|
const u = f.value;
|
|
2338
|
-
for (const
|
|
2339
|
-
|
|
2352
|
+
for (const h of this.adapters.values())
|
|
2353
|
+
h.onNetworkStatusChange?.(u);
|
|
2340
2354
|
},
|
|
2341
2355
|
{ skipInitial: !0 }
|
|
2342
2356
|
), this.store.purgeStaleQueries?.();
|
|
@@ -2416,7 +2430,7 @@ class qn {
|
|
|
2416
2430
|
activateQuery(t) {
|
|
2417
2431
|
const { def: n, queryKey: i, storageKey: r, config: s } = t;
|
|
2418
2432
|
this.store.activateQuery(n, r);
|
|
2419
|
-
const o = s?.gcTime ??
|
|
2433
|
+
const o = s?.gcTime ?? qt;
|
|
2420
2434
|
this.gcManager.cancel(i, o);
|
|
2421
2435
|
}
|
|
2422
2436
|
loadCachedQuery(t, n) {
|
|
@@ -2427,9 +2441,9 @@ class qn {
|
|
|
2427
2441
|
* that triggers fetches and prepopulates with cached data
|
|
2428
2442
|
*/
|
|
2429
2443
|
getQuery(t, n) {
|
|
2430
|
-
const i =
|
|
2444
|
+
const i = Ct(t, n);
|
|
2431
2445
|
let r = this.queryInstances.get(i);
|
|
2432
|
-
return r === void 0 && (r = new
|
|
2446
|
+
return r === void 0 && (r = new wn(t, this, i, n), this.queryInstances.set(i, r)), r.relay;
|
|
2433
2447
|
}
|
|
2434
2448
|
/**
|
|
2435
2449
|
* Gets or creates a MutationResult for the given mutation definition.
|
|
@@ -2438,7 +2452,7 @@ class qn {
|
|
|
2438
2452
|
getMutation(t) {
|
|
2439
2453
|
const n = t.id;
|
|
2440
2454
|
let i = this.mutationInstances.get(n);
|
|
2441
|
-
return i === void 0 && (i = new
|
|
2455
|
+
return i === void 0 && (i = new En(t, this), this.mutationInstances.set(n, i)), i.task;
|
|
2442
2456
|
}
|
|
2443
2457
|
/**
|
|
2444
2458
|
* Parse data: validates, formats, produces parsed entity data objects.
|
|
@@ -2446,8 +2460,8 @@ class qn {
|
|
|
2446
2460
|
*/
|
|
2447
2461
|
parseData(t, n, i) {
|
|
2448
2462
|
const r = this.context.log?.warn ?? (() => {
|
|
2449
|
-
}), s = new
|
|
2450
|
-
return s.reset(this, i, r), { data:
|
|
2463
|
+
}), s = new at();
|
|
2464
|
+
return s.reset(this, i, r), { data: se(t, n, s), ctx: s };
|
|
2451
2465
|
}
|
|
2452
2466
|
/**
|
|
2453
2467
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
@@ -2455,7 +2469,7 @@ class qn {
|
|
|
2455
2469
|
* refs. Returns the reified data and root-level entity refs.
|
|
2456
2470
|
*/
|
|
2457
2471
|
applyRefs(t, n = !0, i = !1) {
|
|
2458
|
-
return
|
|
2472
|
+
return it(t.ctx, t.data, n, i);
|
|
2459
2473
|
}
|
|
2460
2474
|
/**
|
|
2461
2475
|
* Parse and apply data as a root entity. For non-entity results, injects
|
|
@@ -2463,8 +2477,8 @@ class qn {
|
|
|
2463
2477
|
* found in the store by the standard entity pipeline).
|
|
2464
2478
|
*/
|
|
2465
2479
|
parseAndApplyRootEntity(t, n, i, r, s = !1, o) {
|
|
2466
|
-
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[
|
|
2467
|
-
const a = this.parseData(t, i, o), c =
|
|
2480
|
+
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Vt] = n);
|
|
2481
|
+
const a = this.parseData(t, i, o), c = it(a.ctx, a.data, r, s), f = O.get(c.data);
|
|
2468
2482
|
return this.entityMap.getEntity(f);
|
|
2469
2483
|
}
|
|
2470
2484
|
prepareEntity(t, n, i) {
|
|
@@ -2480,55 +2494,55 @@ class qn {
|
|
|
2480
2494
|
if (s === void 0 || typeof s == "symbol") return;
|
|
2481
2495
|
const o = t.data, a = t.id !== void 0 ? t.id : n === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[s];
|
|
2482
2496
|
if (a === void 0) return;
|
|
2483
|
-
const c = N([i, a]), f = t.__eventSource,
|
|
2497
|
+
const c = N([i, a]), f = t.__eventSource, l = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2484
2498
|
if (n === "delete") {
|
|
2485
|
-
const
|
|
2486
|
-
this.routeEvent(i,
|
|
2499
|
+
const _ = u !== void 0 ? u.data : l;
|
|
2500
|
+
this.routeEvent(i, _, c, n, f, void 0, _);
|
|
2487
2501
|
return;
|
|
2488
2502
|
}
|
|
2489
2503
|
try {
|
|
2490
|
-
const
|
|
2491
|
-
}), v = new
|
|
2504
|
+
const _ = this.context.log?.warn ?? (() => {
|
|
2505
|
+
}), v = new at();
|
|
2492
2506
|
v.reset(
|
|
2493
2507
|
this,
|
|
2494
2508
|
void 0,
|
|
2495
|
-
|
|
2509
|
+
_,
|
|
2496
2510
|
/* isPartialEvent */
|
|
2497
2511
|
!0
|
|
2498
2512
|
);
|
|
2499
|
-
const
|
|
2500
|
-
|
|
2501
|
-
} catch (
|
|
2502
|
-
if (this.context.log?.warn?.("Failed to apply mutation event",
|
|
2513
|
+
const S = an(l, r, v);
|
|
2514
|
+
it(v, S, !0);
|
|
2515
|
+
} catch (_) {
|
|
2516
|
+
if (this.context.log?.warn?.("Failed to apply mutation event", _), u === void 0) {
|
|
2503
2517
|
const v = this.entityMap.getEntity(c);
|
|
2504
2518
|
v !== void 0 && v.evict();
|
|
2505
2519
|
}
|
|
2506
2520
|
return;
|
|
2507
2521
|
}
|
|
2508
|
-
const
|
|
2509
|
-
if (
|
|
2510
|
-
this.entityMap.save(
|
|
2522
|
+
const h = this.entityMap.getEntity(c);
|
|
2523
|
+
if (h === void 0) return;
|
|
2524
|
+
this.entityMap.save(h);
|
|
2511
2525
|
const g = u === void 0;
|
|
2512
2526
|
let p = !1;
|
|
2513
|
-
this.routeEvent(i,
|
|
2527
|
+
this.routeEvent(i, h.data, c, n, f, () => {
|
|
2514
2528
|
p = !0;
|
|
2515
|
-
}), g && !p &&
|
|
2529
|
+
}), g && !p && h.evict();
|
|
2516
2530
|
}
|
|
2517
2531
|
// ======================================================
|
|
2518
2532
|
// Query Invalidation
|
|
2519
2533
|
// ======================================================
|
|
2520
2534
|
invalidateQueries(t) {
|
|
2521
2535
|
for (const n of t) {
|
|
2522
|
-
const i = Array.isArray(n), r = i ? n[0] : n, s = i ? n[1] : void 0, a =
|
|
2536
|
+
const i = Array.isArray(n), r = i ? n[0] : n, s = i ? n[1] : void 0, a = H.for(r).statics.id;
|
|
2523
2537
|
for (const [, c] of this.queryInstances)
|
|
2524
|
-
c.def.statics.id === a && (s === void 0 ||
|
|
2538
|
+
c.def.statics.id === a && (s === void 0 || Fn(c.resolvedParams, s)) && c.markStale();
|
|
2525
2539
|
}
|
|
2526
2540
|
}
|
|
2527
2541
|
// ======================================================
|
|
2528
2542
|
// In-Memory GC
|
|
2529
2543
|
// ======================================================
|
|
2530
2544
|
handleEviction = (t, n) => {
|
|
2531
|
-
if (n ===
|
|
2545
|
+
if (n === Z.Query) {
|
|
2532
2546
|
const r = this.queryInstances.get(t);
|
|
2533
2547
|
if (r === void 0) return;
|
|
2534
2548
|
r.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
@@ -2542,7 +2556,7 @@ class qn {
|
|
|
2542
2556
|
// ======================================================
|
|
2543
2557
|
getOrCreateMatcher(t) {
|
|
2544
2558
|
let n = this.constraintRegistry.get(t);
|
|
2545
|
-
return n === void 0 && (n = new
|
|
2559
|
+
return n === void 0 && (n = new An(), this.constraintRegistry.set(t, n)), n;
|
|
2546
2560
|
}
|
|
2547
2561
|
registerLiveCollection(t) {
|
|
2548
2562
|
for (const [n, i] of t._entityDefsByTypename)
|
|
@@ -2557,7 +2571,7 @@ class qn {
|
|
|
2557
2571
|
routeEvent(t, n, i, r, s, o, a) {
|
|
2558
2572
|
const c = this.constraintRegistry.get(t);
|
|
2559
2573
|
if (c === void 0) return;
|
|
2560
|
-
const f = s !== void 0 ? { ...n, [
|
|
2574
|
+
const f = s !== void 0 ? { ...n, [le]: s } : n;
|
|
2561
2575
|
c.routeEvent(t, f, i, r, o, a);
|
|
2562
2576
|
}
|
|
2563
2577
|
destroy() {
|
|
@@ -2567,40 +2581,40 @@ class qn {
|
|
|
2567
2581
|
this.adapters.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2568
2582
|
}
|
|
2569
2583
|
}
|
|
2570
|
-
const
|
|
2571
|
-
function
|
|
2584
|
+
const kn = Ut(void 0);
|
|
2585
|
+
function Fn(e, t) {
|
|
2572
2586
|
if (e === void 0) return !1;
|
|
2573
2587
|
for (const n in t)
|
|
2574
2588
|
if (e[n] !== t[n]) return !1;
|
|
2575
2589
|
return !0;
|
|
2576
2590
|
}
|
|
2577
2591
|
export {
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2592
|
+
k as A,
|
|
2593
|
+
pt as E,
|
|
2594
|
+
Me as G,
|
|
2595
|
+
Q as L,
|
|
2582
2596
|
d as M,
|
|
2583
|
-
|
|
2584
|
-
|
|
2597
|
+
fe as N,
|
|
2598
|
+
Vt as Q,
|
|
2585
2599
|
F as R,
|
|
2586
2600
|
m as V,
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2601
|
+
lt as a,
|
|
2602
|
+
Ln as b,
|
|
2603
|
+
K as c,
|
|
2604
|
+
Te as d,
|
|
2605
|
+
ue as e,
|
|
2606
|
+
Un as f,
|
|
2607
|
+
Bn as g,
|
|
2608
|
+
kn as h,
|
|
2609
|
+
_n as i,
|
|
2610
|
+
$n as j,
|
|
2611
|
+
Vn as k,
|
|
2612
|
+
Yt as l,
|
|
2613
|
+
$e as m,
|
|
2614
|
+
X as n,
|
|
2615
|
+
Kn as o,
|
|
2616
|
+
qn as q,
|
|
2617
|
+
ee as r,
|
|
2618
|
+
sn as t
|
|
2605
2619
|
};
|
|
2606
|
-
//# sourceMappingURL=QueryClient-
|
|
2620
|
+
//# sourceMappingURL=QueryClient-DfxP7pt2.js.map
|