fetchium 0.1.0 → 0.1.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 +6 -5
- package/dist/cjs/development/QueryClient-CLi3ONNM.js +2 -0
- package/dist/cjs/development/QueryClient-CLi3ONNM.js.map +1 -0
- package/dist/cjs/development/QueryController-BQA49OYU.js +2 -0
- package/dist/cjs/development/QueryController-BQA49OYU.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/development/index.js.map +1 -1
- package/dist/cjs/development/mutation-CikIl_6k.js +2 -0
- package/dist/cjs/development/mutation-CikIl_6k.js.map +1 -0
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +2 -0
- package/dist/cjs/development/rest/index.js.map +1 -0
- package/dist/cjs/development/topic/index.js +2 -0
- package/dist/cjs/development/topic/index.js.map +1 -0
- package/dist/cjs/production/QueryClient-N0MJmuHW.js +2 -0
- package/dist/cjs/production/QueryClient-N0MJmuHW.js.map +1 -0
- package/dist/cjs/production/QueryController-BQA49OYU.js +2 -0
- package/dist/cjs/production/QueryController-BQA49OYU.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/production/index.js.map +1 -1
- package/dist/cjs/production/mutation-P_Yb4LI9.js +2 -0
- package/dist/cjs/production/mutation-P_Yb4LI9.js.map +1 -0
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +2 -0
- package/dist/cjs/production/rest/index.js.map +1 -0
- package/dist/cjs/production/topic/index.js +2 -0
- package/dist/cjs/production/topic/index.js.map +1 -0
- package/dist/esm/MutationResult.d.ts +0 -1
- package/dist/esm/MutationResult.d.ts.map +1 -1
- package/dist/esm/QueryClient.d.ts +26 -4
- package/dist/esm/QueryClient.d.ts.map +1 -1
- package/dist/esm/QueryController.d.ts +49 -0
- package/dist/esm/QueryController.d.ts.map +1 -0
- package/dist/esm/QueryResult.d.ts +10 -10
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/QueryClient-Dtde3pss.js +2572 -0
- package/dist/esm/development/QueryClient-Dtde3pss.js.map +1 -0
- package/dist/esm/development/QueryController-Ch_ncxiI.js +14 -0
- package/dist/esm/development/QueryController-Ch_ncxiI.js.map +1 -0
- package/dist/esm/development/index.js +29 -100
- package/dist/esm/development/index.js.map +1 -1
- package/dist/esm/development/mutation-UZshUQAf.js +58 -0
- package/dist/esm/development/mutation-UZshUQAf.js.map +1 -0
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +142 -0
- package/dist/esm/development/rest/index.js.map +1 -0
- package/dist/esm/development/{shared-Dq2yW78d.js → shared-DcuVH8Pf.js} +5 -5
- package/dist/esm/development/{shared-Dq2yW78d.js.map → shared-DcuVH8Pf.js.map} +1 -1
- package/dist/esm/development/stores/async.js +6 -6
- package/dist/esm/development/stores/sync.js +5 -5
- package/dist/esm/development/topic/index.js +86 -0
- package/dist/esm/development/topic/index.js.map +1 -0
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/mutation.d.ts +6 -19
- package/dist/esm/mutation.d.ts.map +1 -1
- package/dist/esm/production/{QueryClient-BP0Z1rQV.js → QueryClient-YqnBxFy1.js} +972 -968
- package/dist/esm/production/QueryClient-YqnBxFy1.js.map +1 -0
- package/dist/esm/production/QueryController-Ch_ncxiI.js +14 -0
- package/dist/esm/production/QueryController-Ch_ncxiI.js.map +1 -0
- package/dist/esm/production/index.js +29 -100
- package/dist/esm/production/index.js.map +1 -1
- package/dist/esm/production/mutation-pgFl1uIY.js +58 -0
- package/dist/esm/production/mutation-pgFl1uIY.js.map +1 -0
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +142 -0
- package/dist/esm/production/rest/index.js.map +1 -0
- package/dist/esm/production/{shared-Dq2yW78d.js → shared-DcuVH8Pf.js} +5 -5
- package/dist/esm/production/{shared-Dq2yW78d.js.map → shared-DcuVH8Pf.js.map} +1 -1
- package/dist/esm/production/stores/async.js +6 -6
- package/dist/esm/production/stores/sync.js +5 -5
- package/dist/esm/production/topic/index.js +86 -0
- package/dist/esm/production/topic/index.js.map +1 -0
- package/dist/esm/query-types.d.ts +2 -4
- package/dist/esm/query-types.d.ts.map +1 -1
- package/dist/esm/query.d.ts +17 -39
- package/dist/esm/query.d.ts.map +1 -1
- package/dist/esm/rest/RESTMutation.d.ts +18 -0
- package/dist/esm/rest/RESTMutation.d.ts.map +1 -0
- package/dist/esm/rest/RESTQuery.d.ts +24 -0
- package/dist/esm/rest/RESTQuery.d.ts.map +1 -0
- package/dist/esm/rest/RESTQueryController.d.ts +34 -0
- package/dist/esm/rest/RESTQueryController.d.ts.map +1 -0
- package/dist/esm/rest/index.d.ts +5 -0
- package/dist/esm/rest/index.d.ts.map +1 -0
- package/dist/esm/stores/shared.d.ts.map +1 -1
- package/dist/esm/testing/MockClient.d.ts +64 -0
- package/dist/esm/testing/MockClient.d.ts.map +1 -0
- package/dist/esm/testing/auto-generate.d.ts +20 -0
- package/dist/esm/testing/auto-generate.d.ts.map +1 -0
- package/dist/esm/testing/entity-factory.d.ts +13 -0
- package/dist/esm/testing/entity-factory.d.ts.map +1 -0
- package/dist/esm/testing/index.d.ts +6 -0
- package/dist/esm/testing/index.d.ts.map +1 -0
- package/dist/esm/testing/types.d.ts +37 -0
- package/dist/esm/testing/types.d.ts.map +1 -0
- package/dist/esm/topic/TopicQuery.d.ts +10 -0
- package/dist/esm/topic/TopicQuery.d.ts.map +1 -0
- package/dist/esm/topic/TopicQueryController.d.ts +43 -0
- package/dist/esm/topic/TopicQueryController.d.ts.map +1 -0
- package/dist/esm/topic/index.d.ts +3 -0
- package/dist/esm/topic/index.d.ts.map +1 -0
- package/dist/esm/typeDefs.d.ts +1 -1
- package/dist/esm/types.d.ts +9 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +51 -4
- package/plugin/.claude-plugin/plugin.json +10 -0
- package/plugin/agents/fetchium.md +168 -0
- package/plugin/docs/api/fetchium-react.md +135 -0
- package/plugin/docs/api/fetchium.md +674 -0
- package/plugin/docs/api/stores-async.md +219 -0
- package/plugin/docs/api/stores-sync.md +133 -0
- package/plugin/docs/core/entities.md +351 -0
- package/plugin/docs/core/queries.md +600 -0
- package/plugin/docs/core/streaming.md +550 -0
- package/plugin/docs/core/types.md +374 -0
- package/plugin/docs/data/caching.md +298 -0
- package/plugin/docs/data/live-data.md +435 -0
- package/plugin/docs/data/mutations.md +465 -0
- package/plugin/docs/guides/auth.md +318 -0
- package/plugin/docs/guides/error-handling.md +351 -0
- package/plugin/docs/guides/offline.md +270 -0
- package/plugin/docs/guides/testing.md +301 -0
- package/plugin/docs/quickstart.md +170 -0
- package/plugin/docs/reference/pagination.md +519 -0
- package/plugin/docs/reference/rest-queries.md +107 -0
- package/plugin/docs/reference/why-signalium.md +364 -0
- package/plugin/docs/setup/project-setup.md +319 -0
- package/plugin/install.mjs +88 -0
- package/plugin/skills/design/SKILL.md +140 -0
- package/plugin/skills/teach/SKILL.md +105 -0
- package/dist/cjs/development/QueryClient-CpmwggOn.js +0 -2
- package/dist/cjs/development/QueryClient-CpmwggOn.js.map +0 -1
- package/dist/cjs/production/QueryClient-qi3bR0eD.js +0 -2
- package/dist/cjs/production/QueryClient-qi3bR0eD.js.map +0 -1
- package/dist/esm/development/QueryClient-DRZtPKFD.js +0 -2568
- package/dist/esm/development/QueryClient-DRZtPKFD.js.map +0 -1
- package/dist/esm/production/QueryClient-BP0Z1rQV.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { notifier as at, relay as It, setScopeOwner as
|
|
2
|
-
import { registerCustomHash as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { notifier as at, relay as It, setScopeOwner as ye, reactiveMethod as pe, signal as Nt, context as Mt, getContext as ge, task as ve, reactiveSignal as _e, isSignal as me, watcher as we } from "signalium";
|
|
2
|
+
import { registerCustomHash as Ee, hashValue as D } from "signalium/utils";
|
|
3
|
+
import { d as kt } from "./shared-DcuVH8Pf.js";
|
|
4
|
+
import { SyncQueryStore as Ce, MemoryPersistentStore as be } from "./stores/sync.js";
|
|
5
|
+
var L = /* @__PURE__ */ ((n) => (n.Always = "always", n.Online = "online", n.OfflineFirst = "offlineFirst", n))(L || {}), l = /* @__PURE__ */ ((n) => (n[n.UNDEFINED = 1] = "UNDEFINED", n[n.NULL = 2] = "NULL", n[n.NUMBER = 4] = "NUMBER", n[n.STRING = 8] = "STRING", n[n.BOOLEAN = 16] = "BOOLEAN", n[n.OBJECT = 32] = "OBJECT", n[n.ARRAY = 64] = "ARRAY", n[n.ID = 128] = "ID", n[n.RECORD = 256] = "RECORD", n[n.UNION = 512] = "UNION", n[n.ENTITY = 1024] = "ENTITY", n[n.HAS_FORMAT = 4096] = "HAS_FORMAT", n[n.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", n[n.PARSE_RESULT = 16384] = "PARSE_RESULT", n[n.LIVE = 32768] = "LIVE", n))(l || {});
|
|
6
|
+
const Q = /* @__PURE__ */ Symbol("array"), B = /* @__PURE__ */ Symbol("record"), Ft = /* @__PURE__ */ Symbol("QUERY_ID");
|
|
7
|
+
var ct = /* @__PURE__ */ ((n) => (n[n.Array = 0] = "Array", n[n.Value = 1] = "Value", n))(ct || {});
|
|
8
|
+
class j {
|
|
8
9
|
type;
|
|
9
10
|
entityDefs;
|
|
10
11
|
constraintFieldRefs;
|
|
@@ -13,42 +14,42 @@ class U {
|
|
|
13
14
|
onCreate;
|
|
14
15
|
onUpdate;
|
|
15
16
|
onDelete;
|
|
16
|
-
constructor(t, e,
|
|
17
|
-
this.type = t, this.entityDefs = e, this.constraintFieldRefs =
|
|
17
|
+
constructor(t, e, i, s, r, o, a, c) {
|
|
18
|
+
this.type = t, this.entityDefs = e, this.constraintFieldRefs = i, this.sort = s, this.valueType = r, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
|
|
18
19
|
}
|
|
19
|
-
static array(t, e,
|
|
20
|
-
return new
|
|
20
|
+
static array(t, e, i) {
|
|
21
|
+
return new j(
|
|
21
22
|
0,
|
|
22
23
|
t,
|
|
23
24
|
e,
|
|
24
|
-
|
|
25
|
+
i,
|
|
25
26
|
void 0,
|
|
26
27
|
void 0,
|
|
27
28
|
void 0,
|
|
28
29
|
void 0
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
|
-
static value(t, e,
|
|
32
|
-
return new
|
|
32
|
+
static value(t, e, i, s, r, o) {
|
|
33
|
+
return new j(
|
|
33
34
|
1,
|
|
34
35
|
t,
|
|
35
36
|
e,
|
|
36
37
|
void 0,
|
|
37
|
-
|
|
38
|
+
i,
|
|
38
39
|
s,
|
|
39
40
|
r,
|
|
40
41
|
o
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
const
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function k(n) {
|
|
47
|
+
return x.get(n);
|
|
47
48
|
}
|
|
48
|
-
var
|
|
49
|
-
class
|
|
50
|
-
constructor(t, e,
|
|
51
|
-
this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 *
|
|
49
|
+
var z = /* @__PURE__ */ ((n) => (n[n.Query = 0] = "Query", n[n.Entity = 1] = "Entity", n))(z || {});
|
|
50
|
+
class xe {
|
|
51
|
+
constructor(t, e, i) {
|
|
52
|
+
this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 * i);
|
|
52
53
|
}
|
|
53
54
|
_currentFlush = /* @__PURE__ */ new Map();
|
|
54
55
|
_nextFlush = /* @__PURE__ */ new Map();
|
|
@@ -60,16 +61,16 @@ class be {
|
|
|
60
61
|
this._currentFlush.delete(t), this._nextFlush.delete(t);
|
|
61
62
|
}
|
|
62
63
|
_tick = () => {
|
|
63
|
-
const { _currentFlush: t, _nextFlush: e, _onEvict:
|
|
64
|
+
const { _currentFlush: t, _nextFlush: e, _onEvict: i } = this;
|
|
64
65
|
for (const [s, r] of t)
|
|
65
|
-
|
|
66
|
+
i(s, r);
|
|
66
67
|
this._currentFlush = e, this._nextFlush = /* @__PURE__ */ new Map();
|
|
67
68
|
};
|
|
68
69
|
destroy() {
|
|
69
70
|
clearInterval(this._intervalId);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
class
|
|
73
|
+
class Oe {
|
|
73
74
|
_buckets = /* @__PURE__ */ new Map();
|
|
74
75
|
_nextTickEntries = /* @__PURE__ */ new Map();
|
|
75
76
|
_nextTickScheduled = !1;
|
|
@@ -78,16 +79,16 @@ class Ce {
|
|
|
78
79
|
constructor(t, e = 1) {
|
|
79
80
|
this._onEvict = t, this._multiplier = e;
|
|
80
81
|
}
|
|
81
|
-
schedule(t, e,
|
|
82
|
+
schedule(t, e, i) {
|
|
82
83
|
if (e === 1 / 0) return;
|
|
83
84
|
if (e === 0) {
|
|
84
85
|
const { _nextTickEntries: o } = this;
|
|
85
|
-
o.set(t,
|
|
86
|
+
o.set(t, i), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
89
|
const { _buckets: s } = this;
|
|
89
90
|
let r = s.get(e);
|
|
90
|
-
r || (r = new
|
|
91
|
+
r || (r = new xe(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t, i);
|
|
91
92
|
}
|
|
92
93
|
cancel(t, e) {
|
|
93
94
|
if (e !== 1 / 0) {
|
|
@@ -101,155 +102,155 @@ class Ce {
|
|
|
101
102
|
_flushNextTick = () => {
|
|
102
103
|
const { _nextTickEntries: t, _onEvict: e } = this;
|
|
103
104
|
this._nextTickScheduled = !1;
|
|
104
|
-
for (const [
|
|
105
|
-
e(
|
|
105
|
+
for (const [i, s] of t)
|
|
106
|
+
e(i, s);
|
|
106
107
|
t.clear();
|
|
107
108
|
};
|
|
108
109
|
destroy() {
|
|
109
110
|
const { _buckets: t, _nextTickEntries: e } = this;
|
|
110
|
-
for (const
|
|
111
|
-
|
|
111
|
+
for (const i of t.values())
|
|
112
|
+
i.destroy();
|
|
112
113
|
t.clear(), e.clear();
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
class
|
|
116
|
-
schedule(t, e,
|
|
116
|
+
class Re {
|
|
117
|
+
schedule(t, e, i) {
|
|
117
118
|
}
|
|
118
119
|
cancel(t, e) {
|
|
119
120
|
}
|
|
120
121
|
destroy() {
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
const Y = /* @__PURE__ */ Symbol("fieldRef"),
|
|
124
|
-
function
|
|
124
|
+
const Y = /* @__PURE__ */ Symbol("fieldRef"), N = /* @__PURE__ */ Symbol("fieldRefPath"), ft = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Se = /\[([^\]]+)\]/g;
|
|
125
|
+
function Tt(n) {
|
|
125
126
|
const t = {
|
|
126
127
|
[Y]: !0,
|
|
127
|
-
[
|
|
128
|
+
[N]: n
|
|
128
129
|
};
|
|
129
|
-
return new Proxy(t,
|
|
130
|
+
return new Proxy(t, Ae);
|
|
130
131
|
}
|
|
131
|
-
const
|
|
132
|
-
get(
|
|
132
|
+
const Ae = {
|
|
133
|
+
get(n, t) {
|
|
133
134
|
if (t === Y) return !0;
|
|
134
|
-
if (t ===
|
|
135
|
+
if (t === N) return n[N];
|
|
135
136
|
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
|
|
136
|
-
const
|
|
137
|
-
return () => `[${
|
|
137
|
+
const i = n[N];
|
|
138
|
+
return () => `[${i.join(".")}]`;
|
|
138
139
|
}
|
|
139
140
|
if (typeof t == "symbol") return;
|
|
140
|
-
const e =
|
|
141
|
-
return
|
|
141
|
+
const e = n[N];
|
|
142
|
+
return Tt([...e, t]);
|
|
142
143
|
},
|
|
143
|
-
has(
|
|
144
|
-
return t === Y || t ===
|
|
144
|
+
has(n, t) {
|
|
145
|
+
return t === Y || t === N;
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
|
-
function
|
|
148
|
-
return typeof
|
|
148
|
+
function Pt(n) {
|
|
149
|
+
return typeof n == "object" && n !== null && n[Y] === !0;
|
|
149
150
|
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
151
|
+
function Lt(n) {
|
|
152
|
+
return n[N];
|
|
152
153
|
}
|
|
153
|
-
function
|
|
154
|
-
return new Proxy(
|
|
155
|
-
set(t, e,
|
|
156
|
-
return t[e] =
|
|
154
|
+
function jt(n) {
|
|
155
|
+
return new Proxy(n, {
|
|
156
|
+
set(t, e, i) {
|
|
157
|
+
return t[e] = i, !0;
|
|
157
158
|
},
|
|
158
159
|
get(t, e) {
|
|
159
160
|
return e === ft ? t : e === G ? () => {
|
|
160
|
-
} : typeof e == "symbol" ? t[e] :
|
|
161
|
+
} : typeof e == "symbol" ? t[e] : Tt([e]);
|
|
161
162
|
}
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
-
const t =
|
|
166
|
-
|
|
165
|
+
function De(n) {
|
|
166
|
+
const t = n[ft];
|
|
167
|
+
n[G]();
|
|
167
168
|
const e = {};
|
|
168
169
|
for (const r of Object.getOwnPropertyNames(t))
|
|
169
170
|
e[r] = t[r];
|
|
170
|
-
const
|
|
171
|
+
const i = {};
|
|
171
172
|
let s = Object.getPrototypeOf(t);
|
|
172
173
|
for (; s && s !== Object.prototype; ) {
|
|
173
174
|
for (const r of Object.getOwnPropertyNames(s)) {
|
|
174
175
|
if (r === "constructor") continue;
|
|
175
176
|
const o = Object.getOwnPropertyDescriptor(s, r);
|
|
176
|
-
typeof o.value == "function" && !(r in
|
|
177
|
+
typeof o.value == "function" && !(r in i) && (i[r] = o.value);
|
|
177
178
|
}
|
|
178
179
|
s = Object.getPrototypeOf(s);
|
|
179
180
|
}
|
|
180
|
-
return { fields: e, methods:
|
|
181
|
+
return { fields: e, methods: i };
|
|
181
182
|
}
|
|
182
|
-
function ut(
|
|
183
|
+
function ut(n, t) {
|
|
183
184
|
let e = t;
|
|
184
|
-
for (const
|
|
185
|
+
for (const i of n) {
|
|
185
186
|
if (e == null) return;
|
|
186
|
-
e = e[
|
|
187
|
+
e = e[i];
|
|
187
188
|
}
|
|
188
189
|
return e;
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
-
return
|
|
192
|
-
const s =
|
|
191
|
+
function Ie(n, t) {
|
|
192
|
+
return n.replace(Se, (e, i) => {
|
|
193
|
+
const s = i.split("."), r = ut(s, t);
|
|
193
194
|
return r != null ? encodeURIComponent(String(r)) : "";
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
-
if (
|
|
198
|
-
return ut(
|
|
199
|
-
if (typeof
|
|
200
|
-
return
|
|
201
|
-
if (Array.isArray(
|
|
202
|
-
return
|
|
203
|
-
if (typeof
|
|
197
|
+
function W(n, t) {
|
|
198
|
+
if (Pt(n))
|
|
199
|
+
return ut(Lt(n), t);
|
|
200
|
+
if (typeof n == "string")
|
|
201
|
+
return Ie(n, t);
|
|
202
|
+
if (Array.isArray(n))
|
|
203
|
+
return n.map((e) => W(e, t));
|
|
204
|
+
if (typeof n == "object" && n !== null && Object.getPrototypeOf(n) === Object.prototype) {
|
|
204
205
|
const e = {};
|
|
205
|
-
for (const
|
|
206
|
-
e[
|
|
206
|
+
for (const i of Object.keys(n))
|
|
207
|
+
e[i] = W(n[i], t);
|
|
207
208
|
return e;
|
|
208
209
|
}
|
|
209
|
-
return
|
|
210
|
+
return n;
|
|
210
211
|
}
|
|
211
|
-
function et(
|
|
212
|
-
const
|
|
213
|
-
for (const [a, c] of Object.entries(
|
|
214
|
-
o[a] =
|
|
212
|
+
function et(n, t, e) {
|
|
213
|
+
const i = n.fields, s = n.methods, r = { params: t }, o = {};
|
|
214
|
+
for (const [a, c] of Object.entries(i))
|
|
215
|
+
o[a] = W(c, r);
|
|
215
216
|
o.params = t, o.context = e;
|
|
216
217
|
for (const [a, c] of Object.entries(s))
|
|
217
218
|
o[a] = c.bind(o);
|
|
218
219
|
return o;
|
|
219
220
|
}
|
|
220
|
-
class
|
|
221
|
+
class qt {
|
|
221
222
|
static cache;
|
|
222
223
|
constructor() {
|
|
223
|
-
return
|
|
224
|
+
return jt(this);
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
return typeof
|
|
227
|
+
const Ut = Object.entries, nt = Object.keys;
|
|
228
|
+
function wt(n) {
|
|
229
|
+
return typeof n == "number" ? n | l.UNDEFINED : n instanceof _ ? (n.mask & l.UNDEFINED) !== 0 ? n : _.cloneWith(n, l.UNDEFINED) : n;
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
-
return
|
|
231
|
+
function Ne(n) {
|
|
232
|
+
return n instanceof _ && (n.mask & l.OBJECT) !== 0 && (n.mask & (l.ENTITY | l.ARRAY | l.UNION | l.RECORD | l.LIVE)) === 0;
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
for (const r of
|
|
234
|
+
function Vt(n, t, e) {
|
|
235
|
+
const i = /* @__PURE__ */ new Set();
|
|
236
|
+
for (const r of n)
|
|
236
237
|
if (r !== void 0)
|
|
237
238
|
for (const o of Object.keys(r))
|
|
238
|
-
|
|
239
|
+
i.add(o);
|
|
239
240
|
const s = {};
|
|
240
|
-
for (const r of
|
|
241
|
+
for (const r of i) {
|
|
241
242
|
let o = 0, a;
|
|
242
243
|
const c = [];
|
|
243
244
|
let f = !0;
|
|
244
|
-
for (const
|
|
245
|
-
const
|
|
246
|
-
|
|
245
|
+
for (const d of n) {
|
|
246
|
+
const u = d?.[r];
|
|
247
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), Ne(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
247
248
|
}
|
|
248
249
|
if (f && o > 0) {
|
|
249
|
-
const
|
|
250
|
-
s[r] = o < t ?
|
|
250
|
+
const d = Vt(c, t), u = new _(l.OBJECT, d);
|
|
251
|
+
s[r] = o < t ? wt(u) : u;
|
|
251
252
|
} else
|
|
252
|
-
s[r] = o < t ?
|
|
253
|
+
s[r] = o < t ? wt(a) : a;
|
|
253
254
|
}
|
|
254
255
|
return s;
|
|
255
256
|
}
|
|
@@ -279,17 +280,17 @@ class _ {
|
|
|
279
280
|
*/
|
|
280
281
|
_entityCache = void 0;
|
|
281
282
|
/**
|
|
282
|
-
* Live
|
|
283
|
+
* Live data configuration (shared by LiveArray and LiveValue).
|
|
283
284
|
*/
|
|
284
285
|
_liveConfig = void 0;
|
|
285
|
-
constructor(t, e,
|
|
286
|
-
this.mask = t, this.shape = e, this.values =
|
|
286
|
+
constructor(t, e, i, s, r, o) {
|
|
287
|
+
this.mask = t, this.shape = e, this.values = i, this.typenameField = s, this.typenameValue = r, this.idField = o;
|
|
287
288
|
}
|
|
288
289
|
static merge(t) {
|
|
289
290
|
if (t.length === 1) return t[0];
|
|
290
|
-
const e = t.length,
|
|
291
|
+
const e = t.length, i = t.map((c) => c.shape);
|
|
291
292
|
t[0].typenameValue;
|
|
292
|
-
const s =
|
|
293
|
+
const s = Vt(i, e);
|
|
293
294
|
let r, o, a;
|
|
294
295
|
for (const c of t) {
|
|
295
296
|
if (r === void 0 && c.idField !== void 0)
|
|
@@ -301,7 +302,7 @@ class _ {
|
|
|
301
302
|
o === void 0 && (o = c.typenameField), a === void 0 && (a = c.typenameValue);
|
|
302
303
|
}
|
|
303
304
|
return new _(
|
|
304
|
-
|
|
305
|
+
l.ENTITY | l.OBJECT,
|
|
305
306
|
s,
|
|
306
307
|
void 0,
|
|
307
308
|
o,
|
|
@@ -310,7 +311,7 @@ class _ {
|
|
|
310
311
|
);
|
|
311
312
|
}
|
|
312
313
|
static cloneWith(t, e) {
|
|
313
|
-
const
|
|
314
|
+
const i = new _(
|
|
314
315
|
e | t.mask,
|
|
315
316
|
t.shape,
|
|
316
317
|
t.values,
|
|
@@ -318,7 +319,7 @@ class _ {
|
|
|
318
319
|
t.typenameValue,
|
|
319
320
|
t.idField
|
|
320
321
|
);
|
|
321
|
-
return
|
|
322
|
+
return i._methods = t._methods, i._entityConfig = t._entityConfig, i._entityClass = t._entityClass, i._entityCache = t._entityCache, i._liveConfig = t._liveConfig, i;
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
class H extends Set {
|
|
@@ -328,12 +329,12 @@ class H extends Set {
|
|
|
328
329
|
super(t), this.lowercaseMap = /* @__PURE__ */ new Map();
|
|
329
330
|
for (const e of t)
|
|
330
331
|
if (typeof e == "string") {
|
|
331
|
-
const
|
|
332
|
+
const i = e.toLowerCase(), s = this.lowercaseMap.get(i);
|
|
332
333
|
if (s !== void 0)
|
|
333
334
|
throw new Error(
|
|
334
|
-
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${
|
|
335
|
+
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${i}'`
|
|
335
336
|
);
|
|
336
|
-
this.lowercaseMap.set(
|
|
337
|
+
this.lowercaseMap.set(i, e);
|
|
337
338
|
}
|
|
338
339
|
}
|
|
339
340
|
/**
|
|
@@ -356,34 +357,34 @@ class H extends Set {
|
|
|
356
357
|
return t;
|
|
357
358
|
}
|
|
358
359
|
}
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
let t =
|
|
362
|
-
for (const e of
|
|
363
|
-
t +=
|
|
360
|
+
const Me = 1128875347;
|
|
361
|
+
Ee(H, (n) => {
|
|
362
|
+
let t = Me;
|
|
363
|
+
for (const e of n)
|
|
364
|
+
t += D(e);
|
|
364
365
|
return t >>> 0;
|
|
365
366
|
});
|
|
366
|
-
function
|
|
367
|
-
return new _(
|
|
367
|
+
function lt(n, t) {
|
|
368
|
+
return new _(n, t);
|
|
368
369
|
}
|
|
369
|
-
function
|
|
370
|
-
return
|
|
370
|
+
function ke(n) {
|
|
371
|
+
return lt(l.ARRAY, n);
|
|
371
372
|
}
|
|
372
|
-
function
|
|
373
|
-
return
|
|
373
|
+
function Fe(n) {
|
|
374
|
+
return lt(l.RECORD | l.OBJECT, n);
|
|
374
375
|
}
|
|
375
|
-
function Te(
|
|
376
|
-
return
|
|
376
|
+
function Te(n) {
|
|
377
|
+
return lt(l.PARSE_RESULT, n);
|
|
377
378
|
}
|
|
378
|
-
function
|
|
379
|
-
let e =
|
|
380
|
-
for (const [o, a] of
|
|
379
|
+
function Kt(n, t) {
|
|
380
|
+
let e = n, i, s, r;
|
|
381
|
+
for (const [o, a] of Ut(t))
|
|
381
382
|
switch (typeof a) {
|
|
382
383
|
case "number":
|
|
383
|
-
if ((a &
|
|
384
|
-
if (
|
|
384
|
+
if ((a & l.ID) !== 0) {
|
|
385
|
+
if (i !== void 0)
|
|
385
386
|
throw new Error(`Duplicate id field: ${o}`);
|
|
386
|
-
|
|
387
|
+
i = o;
|
|
387
388
|
}
|
|
388
389
|
break;
|
|
389
390
|
case "string":
|
|
@@ -394,18 +395,18 @@ function $t(i, t) {
|
|
|
394
395
|
case "object":
|
|
395
396
|
if (a instanceof H || a instanceof Set)
|
|
396
397
|
break;
|
|
397
|
-
a.mask &
|
|
398
|
+
a.mask & l.LIVE && (e |= l.LIVE);
|
|
398
399
|
break;
|
|
399
400
|
}
|
|
400
|
-
return new _(e, t, void 0, s, r,
|
|
401
|
+
return new _(e, t, void 0, s, r, i);
|
|
401
402
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
403
|
+
function Pe(n) {
|
|
404
|
+
return Kt(l.OBJECT, n);
|
|
404
405
|
}
|
|
405
|
-
function
|
|
406
|
-
const
|
|
407
|
-
if ((
|
|
408
|
-
const s =
|
|
406
|
+
function Et(n, t, e) {
|
|
407
|
+
const i = n.mask;
|
|
408
|
+
if ((i & l.UNION) !== 0) {
|
|
409
|
+
const s = n;
|
|
409
410
|
if (s.typenameField !== void 0) {
|
|
410
411
|
if (e !== void 0 && e !== s.typenameField)
|
|
411
412
|
throw new Error(
|
|
@@ -415,7 +416,7 @@ function wt(i, t, e) {
|
|
|
415
416
|
}
|
|
416
417
|
const r = s.shape;
|
|
417
418
|
if (r !== void 0)
|
|
418
|
-
for (const o of [...
|
|
419
|
+
for (const o of [...nt(r), Q, B]) {
|
|
419
420
|
const a = r[o];
|
|
420
421
|
if (t[o] !== void 0 && t[o] !== a)
|
|
421
422
|
throw new Error(
|
|
@@ -423,494 +424,494 @@ function wt(i, t, e) {
|
|
|
423
424
|
);
|
|
424
425
|
t[o] = a;
|
|
425
426
|
}
|
|
426
|
-
} else if ((
|
|
427
|
-
if (t[B] !== void 0)
|
|
428
|
-
throw new Error("Array shape already defined");
|
|
429
|
-
t[B] = i.shape;
|
|
430
|
-
} else if ((n & u.RECORD) !== 0) {
|
|
427
|
+
} else if ((i & l.ARRAY) !== 0) {
|
|
431
428
|
if (t[Q] !== void 0)
|
|
429
|
+
throw new Error("Array shape already defined");
|
|
430
|
+
t[Q] = n.shape;
|
|
431
|
+
} else if ((i & l.RECORD) !== 0) {
|
|
432
|
+
if (t[B] !== void 0)
|
|
432
433
|
throw new Error("Record shape already defined");
|
|
433
|
-
t[
|
|
434
|
+
t[B] = n.shape;
|
|
434
435
|
} else {
|
|
435
|
-
const s =
|
|
436
|
+
const s = n.typenameField, r = n.typenameValue;
|
|
436
437
|
if (r === void 0)
|
|
437
438
|
throw new Error(
|
|
438
439
|
"Object definitions must have a typename to be in a union with other objects, records, or arrays"
|
|
439
440
|
);
|
|
440
441
|
if (e !== void 0 && s !== e)
|
|
441
442
|
throw new Error("Object definitions must have the same typename field to be in the same union");
|
|
442
|
-
e = s, t[r] =
|
|
443
|
+
e = s, t[r] = n;
|
|
443
444
|
}
|
|
444
445
|
return e;
|
|
445
446
|
}
|
|
446
|
-
function
|
|
447
|
-
const t =
|
|
448
|
-
let e = 0,
|
|
449
|
-
for (const
|
|
450
|
-
if (typeof
|
|
451
|
-
e |=
|
|
447
|
+
function dt(...n) {
|
|
448
|
+
const t = n;
|
|
449
|
+
let e = 0, i = 0, s, r, o, a, c = 0;
|
|
450
|
+
for (const d of t) {
|
|
451
|
+
if (typeof d == "number") {
|
|
452
|
+
e |= d;
|
|
452
453
|
continue;
|
|
453
454
|
}
|
|
454
|
-
if (
|
|
455
|
+
if (d instanceof Set) {
|
|
455
456
|
if (r === void 0)
|
|
456
|
-
r = new Set(
|
|
457
|
+
r = new Set(d);
|
|
457
458
|
else
|
|
458
|
-
for (const
|
|
459
|
-
r.add(
|
|
459
|
+
for (const u of d)
|
|
460
|
+
r.add(u);
|
|
460
461
|
continue;
|
|
461
462
|
}
|
|
462
|
-
if (
|
|
463
|
-
s =
|
|
463
|
+
if (i++, c |= d.mask, i === 1) {
|
|
464
|
+
s = d;
|
|
464
465
|
continue;
|
|
465
466
|
}
|
|
466
|
-
|
|
467
|
+
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Et(s, o, a)), a = Et(d, o, a);
|
|
467
468
|
}
|
|
468
|
-
if (
|
|
469
|
-
return r === void 0 ? e : e === 0 ? r : new _(e |
|
|
470
|
-
if (
|
|
469
|
+
if (i === 0)
|
|
470
|
+
return r === void 0 ? e : e === 0 ? r : new _(e | l.UNION, void 0, r);
|
|
471
|
+
if (i === 1)
|
|
471
472
|
return _.cloneWith(s, e);
|
|
472
|
-
const f = e | c |
|
|
473
|
+
const f = e | c | l.UNION;
|
|
473
474
|
return new _(f, o, r, a);
|
|
474
475
|
}
|
|
475
|
-
function ht(
|
|
476
|
-
const
|
|
477
|
-
if (typeof
|
|
478
|
-
return
|
|
479
|
-
if (
|
|
480
|
-
return
|
|
481
|
-
let s = e.get(
|
|
482
|
-
return s === void 0 && (s = _.cloneWith(
|
|
476
|
+
function ht(n, t, e) {
|
|
477
|
+
const i = n;
|
|
478
|
+
if (typeof i == "number")
|
|
479
|
+
return i | t;
|
|
480
|
+
if (i instanceof Set)
|
|
481
|
+
return dt(n, t);
|
|
482
|
+
let s = e.get(i);
|
|
483
|
+
return s === void 0 && (s = _.cloneWith(i, t), e.set(i, s)), s;
|
|
483
484
|
}
|
|
484
|
-
const
|
|
485
|
-
function
|
|
486
|
-
return ht(
|
|
485
|
+
const Le = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap();
|
|
486
|
+
function Ue(n) {
|
|
487
|
+
return ht(n, l.UNDEFINED | l.NULL, qe);
|
|
487
488
|
}
|
|
488
|
-
function
|
|
489
|
-
return ht(
|
|
489
|
+
function Ve(n) {
|
|
490
|
+
return ht(n, l.UNDEFINED, Le);
|
|
490
491
|
}
|
|
491
|
-
function
|
|
492
|
-
return ht(
|
|
492
|
+
function Ke(n) {
|
|
493
|
+
return ht(n, l.NULL, je);
|
|
493
494
|
}
|
|
494
|
-
function
|
|
495
|
-
return
|
|
495
|
+
function $e(n) {
|
|
496
|
+
return n;
|
|
496
497
|
}
|
|
497
|
-
function
|
|
498
|
-
return /* @__PURE__ */ new Set([
|
|
498
|
+
function Qe(n) {
|
|
499
|
+
return /* @__PURE__ */ new Set([n]);
|
|
499
500
|
}
|
|
500
|
-
const
|
|
501
|
-
|
|
501
|
+
const $t = ((...n) => new Set(n));
|
|
502
|
+
$t.caseInsensitive = (...n) => new H(n);
|
|
502
503
|
const Qt = 16;
|
|
503
|
-
let
|
|
504
|
-
const
|
|
505
|
-
class
|
|
504
|
+
let Be = 0;
|
|
505
|
+
const it = [], Bt = [], Yt = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new WeakSet();
|
|
506
|
+
class q {
|
|
506
507
|
_raw;
|
|
507
508
|
_formatted;
|
|
508
509
|
_parsed;
|
|
509
510
|
_formatId;
|
|
510
|
-
constructor(t, e,
|
|
511
|
-
this._raw = t, this._formatId = e,
|
|
511
|
+
constructor(t, e, i) {
|
|
512
|
+
this._raw = t, this._formatId = e, i ? (this._formatted = it[e](t), this._parsed = !0) : this._parsed = !1, J.add(this);
|
|
512
513
|
}
|
|
513
514
|
getValue() {
|
|
514
|
-
return this._parsed || (this._formatted =
|
|
515
|
+
return this._parsed || (this._formatted = it[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
515
516
|
}
|
|
516
517
|
toJSON() {
|
|
517
|
-
return this._parsed ?
|
|
518
|
+
return this._parsed ? Bt[this._formatId](this._formatted) : this._raw;
|
|
518
519
|
}
|
|
519
520
|
}
|
|
520
|
-
function
|
|
521
|
-
const t =
|
|
521
|
+
function Ye(n) {
|
|
522
|
+
const t = Yt.get(n);
|
|
522
523
|
if (t === void 0)
|
|
523
|
-
throw new Error(`Format ${
|
|
524
|
+
throw new Error(`Format ${n} not registered`);
|
|
524
525
|
return t;
|
|
525
526
|
}
|
|
526
|
-
function
|
|
527
|
-
const r =
|
|
528
|
-
|
|
529
|
-
const o = s?.eager ?? !0, c = r << Qt | t |
|
|
530
|
-
|
|
527
|
+
function Gt(n, t, e, i, s) {
|
|
528
|
+
const r = Be++;
|
|
529
|
+
it[r] = e, Bt[r] = i;
|
|
530
|
+
const o = s?.eager ?? !0, c = r << Qt | t | l.HAS_FORMAT | (o ? l.IS_EAGER_FORMAT : 0);
|
|
531
|
+
Yt.set(n, c);
|
|
531
532
|
}
|
|
532
|
-
|
|
533
|
+
Gt(
|
|
533
534
|
"date",
|
|
534
|
-
|
|
535
|
-
(
|
|
536
|
-
const t =
|
|
535
|
+
l.STRING,
|
|
536
|
+
(n) => {
|
|
537
|
+
const t = n.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
537
538
|
if (!t)
|
|
538
|
-
throw new Error(`Invalid date string: ${
|
|
539
|
-
const [, e,
|
|
539
|
+
throw new Error(`Invalid date string: ${n}. Expected YYYY-MM-DD format.`);
|
|
540
|
+
const [, e, i, s] = t, r = new Date(Date.UTC(parseInt(e, 10), parseInt(i, 10) - 1, parseInt(s, 10)));
|
|
540
541
|
if (isNaN(r.getTime()))
|
|
541
|
-
throw new Error(`Invalid date string: ${
|
|
542
|
+
throw new Error(`Invalid date string: ${n}`);
|
|
542
543
|
return r;
|
|
543
544
|
},
|
|
544
|
-
(
|
|
545
|
-
const t =
|
|
546
|
-
return `${t}-${e}-${
|
|
545
|
+
(n) => {
|
|
546
|
+
const t = n.getUTCFullYear(), e = String(n.getUTCMonth() + 1).padStart(2, "0"), i = String(n.getUTCDate()).padStart(2, "0");
|
|
547
|
+
return `${t}-${e}-${i}`;
|
|
547
548
|
}
|
|
548
549
|
);
|
|
549
|
-
|
|
550
|
+
Gt(
|
|
550
551
|
"date-time",
|
|
551
|
-
|
|
552
|
-
(
|
|
553
|
-
const t = new Date(
|
|
552
|
+
l.STRING,
|
|
553
|
+
(n) => {
|
|
554
|
+
const t = new Date(n);
|
|
554
555
|
if (isNaN(t.getTime()))
|
|
555
|
-
throw new Error(`Invalid date-time string: ${
|
|
556
|
+
throw new Error(`Invalid date-time string: ${n}`);
|
|
556
557
|
return t;
|
|
557
558
|
},
|
|
558
|
-
(
|
|
559
|
+
(n) => n.toISOString()
|
|
559
560
|
);
|
|
560
|
-
const
|
|
561
|
-
function
|
|
562
|
-
let t =
|
|
561
|
+
const Ct = /* @__PURE__ */ new WeakMap();
|
|
562
|
+
function T(n) {
|
|
563
|
+
let t = Ct.get(n);
|
|
563
564
|
if (t === void 0) {
|
|
564
|
-
const e = new
|
|
565
|
+
const e = new n(), i = e[ft] ?? e;
|
|
565
566
|
e[G] && e[G]();
|
|
566
567
|
const s = {};
|
|
567
|
-
for (const [f,
|
|
568
|
-
s[f] =
|
|
569
|
-
const r = Object.getPrototypeOf(
|
|
568
|
+
for (const [f, d] of Ut(i))
|
|
569
|
+
s[f] = d;
|
|
570
|
+
const r = Object.getPrototypeOf(n.prototype);
|
|
570
571
|
if (r != null) {
|
|
571
572
|
const f = r.constructor;
|
|
572
|
-
if (f !==
|
|
573
|
-
const
|
|
574
|
-
for (const y of
|
|
575
|
-
if (y in s && s[y] !==
|
|
573
|
+
if (f !== qt && typeof f == "function") {
|
|
574
|
+
const u = T(f).shape;
|
|
575
|
+
for (const y of nt(u))
|
|
576
|
+
if (y in s && s[y] !== u[y])
|
|
576
577
|
throw new Error(`Cannot extend: field '${y}' already exists in type definition`);
|
|
577
578
|
}
|
|
578
579
|
}
|
|
579
|
-
const o = {}, a =
|
|
580
|
+
const o = {}, a = n.prototype;
|
|
580
581
|
for (const f of Object.getOwnPropertyNames(a))
|
|
581
582
|
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
582
|
-
t =
|
|
583
|
-
const c =
|
|
584
|
-
c.cache && (t._entityCache = c.cache),
|
|
583
|
+
t = Kt(l.ENTITY | l.OBJECT, s), t._entityClass = n, nt(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
|
|
584
|
+
const c = n;
|
|
585
|
+
c.cache && (t._entityCache = c.cache), Ct.set(n, t);
|
|
585
586
|
}
|
|
586
587
|
return t;
|
|
587
588
|
}
|
|
588
|
-
function
|
|
589
|
-
return
|
|
589
|
+
function Ge(n) {
|
|
590
|
+
return T(n);
|
|
590
591
|
}
|
|
591
|
-
function
|
|
592
|
+
function Wt(n, t) {
|
|
592
593
|
if (t == null) return;
|
|
593
594
|
const e = /* @__PURE__ */ new Map();
|
|
594
595
|
if (Array.isArray(t))
|
|
595
|
-
for (const
|
|
596
|
-
const [s, r] =
|
|
596
|
+
for (const i of t) {
|
|
597
|
+
const [s, r] = i, a = T(s).typenameValue;
|
|
597
598
|
if (a === void 0) continue;
|
|
598
599
|
const c = [];
|
|
599
|
-
for (const [f,
|
|
600
|
-
c.push([f,
|
|
600
|
+
for (const [f, d] of Object.entries(r))
|
|
601
|
+
c.push([f, d]);
|
|
601
602
|
c.length > 0 && e.set(a, c);
|
|
602
603
|
}
|
|
603
604
|
else {
|
|
604
605
|
const s = Object.entries(t);
|
|
605
606
|
if (s.length === 0) return;
|
|
606
607
|
const r = s.map(([o, a]) => [o, a]);
|
|
607
|
-
for (const o of
|
|
608
|
+
for (const o of n) {
|
|
608
609
|
const a = o.typenameValue;
|
|
609
610
|
a !== void 0 && e.set(a, r);
|
|
610
611
|
}
|
|
611
612
|
}
|
|
612
613
|
return e.size > 0 ? e : void 0;
|
|
613
614
|
}
|
|
614
|
-
function zt(
|
|
615
|
-
return Array.isArray(
|
|
615
|
+
function zt(n) {
|
|
616
|
+
return Array.isArray(n) ? n.map((t) => T(t)) : [T(n)];
|
|
616
617
|
}
|
|
617
|
-
function
|
|
618
|
-
const e = zt(
|
|
619
|
-
return r._liveConfig =
|
|
618
|
+
function We(n, t) {
|
|
619
|
+
const e = zt(n), i = e.length === 1 ? e[0] : dt(...e.map((o) => o)), s = l.ARRAY | l.LIVE, r = new _(s, i);
|
|
620
|
+
return r._liveConfig = j.array(
|
|
620
621
|
e,
|
|
621
|
-
|
|
622
|
+
Wt(e, t?.constraints),
|
|
622
623
|
t?.sort
|
|
623
624
|
), r;
|
|
624
625
|
}
|
|
625
|
-
function
|
|
626
|
-
const
|
|
627
|
-
return o._liveConfig =
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
function ze(n, t, e) {
|
|
627
|
+
const i = zt(t), s = n, r = l.LIVE, o = new _(r, void 0);
|
|
628
|
+
return o._liveConfig = j.value(
|
|
629
|
+
i,
|
|
630
|
+
Wt(i, e?.constraints),
|
|
630
631
|
s,
|
|
631
632
|
e.onCreate,
|
|
632
633
|
e.onUpdate,
|
|
633
634
|
e.onDelete
|
|
634
635
|
), o;
|
|
635
636
|
}
|
|
636
|
-
const
|
|
637
|
-
format:
|
|
638
|
-
typename:
|
|
639
|
-
const:
|
|
640
|
-
enum:
|
|
641
|
-
id:
|
|
642
|
-
string:
|
|
643
|
-
number:
|
|
644
|
-
boolean:
|
|
645
|
-
null:
|
|
646
|
-
undefined:
|
|
647
|
-
array:
|
|
648
|
-
object:
|
|
649
|
-
record:
|
|
650
|
-
union:
|
|
651
|
-
nullish:
|
|
652
|
-
optional:
|
|
653
|
-
nullable:
|
|
637
|
+
const He = {
|
|
638
|
+
format: Ye,
|
|
639
|
+
typename: $e,
|
|
640
|
+
const: Qe,
|
|
641
|
+
enum: $t,
|
|
642
|
+
id: l.ID | l.STRING | l.NUMBER,
|
|
643
|
+
string: l.STRING,
|
|
644
|
+
number: l.NUMBER,
|
|
645
|
+
boolean: l.BOOLEAN,
|
|
646
|
+
null: l.NULL,
|
|
647
|
+
undefined: l.UNDEFINED,
|
|
648
|
+
array: ke,
|
|
649
|
+
object: Pe,
|
|
650
|
+
record: Fe,
|
|
651
|
+
union: dt,
|
|
652
|
+
nullish: Ue,
|
|
653
|
+
optional: Ve,
|
|
654
|
+
nullable: Ke,
|
|
654
655
|
result: Te,
|
|
655
|
-
entity:
|
|
656
|
-
liveArray:
|
|
657
|
-
liveValue:
|
|
656
|
+
entity: Ge,
|
|
657
|
+
liveArray: We,
|
|
658
|
+
liveValue: ze
|
|
658
659
|
};
|
|
659
|
-
function
|
|
660
|
-
return new TypeError(`Validation error at ${
|
|
660
|
+
function P(n, t, e) {
|
|
661
|
+
return new TypeError(`Validation error at ${n}`);
|
|
661
662
|
}
|
|
662
|
-
const
|
|
663
|
-
function
|
|
664
|
-
if (
|
|
665
|
-
switch (typeof
|
|
663
|
+
const Ht = Array.isArray;
|
|
664
|
+
function bt(n) {
|
|
665
|
+
if (n === null) return l.NULL;
|
|
666
|
+
switch (typeof n) {
|
|
666
667
|
case "number":
|
|
667
|
-
return
|
|
668
|
+
return l.NUMBER;
|
|
668
669
|
case "string":
|
|
669
|
-
return
|
|
670
|
+
return l.STRING;
|
|
670
671
|
case "boolean":
|
|
671
|
-
return
|
|
672
|
+
return l.BOOLEAN;
|
|
672
673
|
case "undefined":
|
|
673
|
-
return
|
|
674
|
+
return l.UNDEFINED;
|
|
674
675
|
case "object":
|
|
675
|
-
return
|
|
676
|
+
return Ht(n) ? l.ARRAY : l.OBJECT;
|
|
676
677
|
default:
|
|
677
|
-
throw new Error(`Invalid type: ${typeof
|
|
678
|
+
throw new Error(`Invalid type: ${typeof n}`);
|
|
678
679
|
}
|
|
679
680
|
}
|
|
680
|
-
function
|
|
681
|
-
return
|
|
681
|
+
function Dn(n) {
|
|
682
|
+
return F(n);
|
|
682
683
|
}
|
|
683
|
-
function
|
|
684
|
-
if (
|
|
685
|
-
return
|
|
686
|
-
if (
|
|
687
|
-
return
|
|
688
|
-
if (
|
|
689
|
-
return new Date(
|
|
690
|
-
if (
|
|
684
|
+
function F(n) {
|
|
685
|
+
if (n === null || typeof n != "object")
|
|
686
|
+
return n;
|
|
687
|
+
if (Ht(n))
|
|
688
|
+
return n.map((e) => F(e));
|
|
689
|
+
if (n instanceof Date)
|
|
690
|
+
return new Date(n.getTime());
|
|
691
|
+
if (n instanceof Map) {
|
|
691
692
|
const e = /* @__PURE__ */ new Map();
|
|
692
|
-
for (const [
|
|
693
|
-
e.set(
|
|
693
|
+
for (const [i, s] of n)
|
|
694
|
+
e.set(F(i), F(s));
|
|
694
695
|
return e;
|
|
695
696
|
}
|
|
696
|
-
if (
|
|
697
|
+
if (n instanceof Set) {
|
|
697
698
|
const e = /* @__PURE__ */ new Set();
|
|
698
|
-
for (const
|
|
699
|
-
e.add(
|
|
699
|
+
for (const i of n)
|
|
700
|
+
e.add(F(i));
|
|
700
701
|
return e;
|
|
701
702
|
}
|
|
702
703
|
const t = {};
|
|
703
|
-
for (const e of Object.keys(
|
|
704
|
-
t[e] =
|
|
704
|
+
for (const e of Object.keys(n))
|
|
705
|
+
t[e] = F(n[e]);
|
|
705
706
|
return t;
|
|
706
707
|
}
|
|
707
|
-
const yt = Object.entries,
|
|
708
|
+
const yt = Object.entries, Je = () => {
|
|
708
709
|
};
|
|
709
710
|
class st {
|
|
710
711
|
queryClient = void 0;
|
|
711
712
|
preloadedEntities = void 0;
|
|
712
|
-
warn =
|
|
713
|
+
warn = Je;
|
|
713
714
|
/** When true, missing optional fields on existing entities are set to
|
|
714
715
|
* undefined. False for mutation events (truly partial payloads). */
|
|
715
716
|
isPartialEvent = !1;
|
|
716
717
|
seen = void 0;
|
|
717
718
|
seenByKey = void 0;
|
|
718
|
-
reset(t, e,
|
|
719
|
-
this.queryClient = t, this.preloadedEntities = e, this.warn =
|
|
719
|
+
reset(t, e, i, s = !1) {
|
|
720
|
+
this.queryClient = t, this.preloadedEntities = e, this.warn = i, this.isPartialEvent = s, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
|
|
720
721
|
}
|
|
721
722
|
}
|
|
722
|
-
function
|
|
723
|
-
return
|
|
723
|
+
function Jt(n, t, e) {
|
|
724
|
+
return M(n, t, e, "");
|
|
724
725
|
}
|
|
725
|
-
function
|
|
726
|
-
return pt(
|
|
726
|
+
function Xe(n, t, e) {
|
|
727
|
+
return pt(n, t, e);
|
|
727
728
|
}
|
|
728
|
-
function xt(
|
|
729
|
-
const s =
|
|
730
|
-
if ((
|
|
729
|
+
function xt(n, t, e, i) {
|
|
730
|
+
const s = n >> Qt;
|
|
731
|
+
if ((n & l.IS_EAGER_FORMAT) !== 0)
|
|
731
732
|
try {
|
|
732
|
-
return new
|
|
733
|
+
return new q(t, s, !0);
|
|
733
734
|
} catch (o) {
|
|
734
|
-
if ((
|
|
735
|
+
if ((n & l.UNDEFINED) !== 0) {
|
|
735
736
|
e.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
736
737
|
value: t,
|
|
737
|
-
path:
|
|
738
|
+
path: i,
|
|
738
739
|
error: o instanceof Error ? o.message : String(o)
|
|
739
740
|
});
|
|
740
741
|
return;
|
|
741
742
|
}
|
|
742
743
|
throw o;
|
|
743
744
|
}
|
|
744
|
-
return new
|
|
745
|
+
return new q(t, s, !1);
|
|
745
746
|
}
|
|
746
|
-
function
|
|
747
|
+
function M(n, t, e, i) {
|
|
747
748
|
const s = t;
|
|
748
749
|
if (s instanceof H) {
|
|
749
|
-
const c = s.get(
|
|
750
|
-
if (c === void 0) throw
|
|
750
|
+
const c = s.get(n);
|
|
751
|
+
if (c === void 0) throw P(i);
|
|
751
752
|
return c;
|
|
752
753
|
}
|
|
753
754
|
if (s instanceof Set) {
|
|
754
|
-
if (!s.has(
|
|
755
|
-
return
|
|
755
|
+
if (!s.has(n)) throw P(i);
|
|
756
|
+
return n;
|
|
756
757
|
}
|
|
757
758
|
if (typeof s == "string") {
|
|
758
|
-
if (
|
|
759
|
-
if (
|
|
760
|
-
return
|
|
759
|
+
if (n == null) return s;
|
|
760
|
+
if (n !== s) throw P(i);
|
|
761
|
+
return n;
|
|
761
762
|
}
|
|
762
763
|
if (typeof s == "number") {
|
|
763
|
-
const c =
|
|
764
|
+
const c = bt(n);
|
|
764
765
|
if ((s & c) === 0) {
|
|
765
|
-
if ((s &
|
|
766
|
-
e.warn("Invalid value for optional type, defaulting to undefined", { value:
|
|
766
|
+
if ((s & l.UNDEFINED) !== 0) {
|
|
767
|
+
e.warn("Invalid value for optional type, defaulting to undefined", { value: n, path: i });
|
|
767
768
|
return;
|
|
768
769
|
}
|
|
769
|
-
throw
|
|
770
|
+
throw P(i);
|
|
770
771
|
}
|
|
771
|
-
return (s &
|
|
772
|
+
return (s & l.HAS_FORMAT) !== 0 && n !== null && n !== void 0 ? xt(s, n, e, i) : n;
|
|
772
773
|
}
|
|
773
774
|
const r = s.mask, o = s._liveConfig;
|
|
774
775
|
if (o !== void 0 && o.type === ct.Value)
|
|
775
|
-
return o.valueType !== void 0 ?
|
|
776
|
-
if ((r &
|
|
776
|
+
return o.valueType !== void 0 ? M(n, o.valueType, e, i) : n;
|
|
777
|
+
if ((r & l.PARSE_RESULT) !== 0)
|
|
777
778
|
try {
|
|
778
|
-
return { success: !0, value:
|
|
779
|
+
return { success: !0, value: M(n, s.shape, e, i) };
|
|
779
780
|
} catch (c) {
|
|
780
781
|
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
781
782
|
}
|
|
782
|
-
const a =
|
|
783
|
-
if ((r & a) === 0 && !s.values?.has(
|
|
784
|
-
if ((r &
|
|
785
|
-
e.warn("Invalid value for optional type, defaulting to undefined", { value:
|
|
783
|
+
const a = bt(n);
|
|
784
|
+
if ((r & a) === 0 && !s.values?.has(n)) {
|
|
785
|
+
if ((r & l.UNDEFINED) !== 0) {
|
|
786
|
+
e.warn("Invalid value for optional type, defaulting to undefined", { value: n, path: i });
|
|
786
787
|
return;
|
|
787
788
|
}
|
|
788
|
-
throw
|
|
789
|
+
throw P(i);
|
|
789
790
|
}
|
|
790
|
-
return a <
|
|
791
|
+
return a < l.OBJECT ? (r & l.HAS_FORMAT) !== 0 && n !== null && n !== void 0 ? xt(r, n, e, i) : n : (r & l.UNION) !== 0 ? Ze(a, n, s, e, i) : a === l.ARRAY ? Xt(n, s.shape, e, i) : (r & l.RECORD) !== 0 ? Zt(n, s.shape, e, i) : (r & l.ENTITY) !== 0 && e.queryClient !== void 0 ? pt(n, s, e) : te(n, s, e, i);
|
|
791
792
|
}
|
|
792
|
-
function
|
|
793
|
-
if (
|
|
794
|
-
const r = e.shape[
|
|
795
|
-
return r === void 0 || typeof r == "number" ? t :
|
|
793
|
+
function Ze(n, t, e, i, s) {
|
|
794
|
+
if (n === l.ARRAY) {
|
|
795
|
+
const r = e.shape[Q];
|
|
796
|
+
return r === void 0 || typeof r == "number" ? t : Xt(t, r, i, s);
|
|
796
797
|
} else {
|
|
797
798
|
const r = e.typenameField, o = r ? t[r] : void 0;
|
|
798
799
|
if (o === void 0 || typeof o != "string") {
|
|
799
|
-
const c = e.shape[
|
|
800
|
+
const c = e.shape[B];
|
|
800
801
|
if (c === void 0)
|
|
801
802
|
throw new Error(
|
|
802
803
|
`Typename field '${r}' is required for union discrimination but was not found in the data`
|
|
803
804
|
);
|
|
804
|
-
return
|
|
805
|
+
return Zt(t, c, i, s);
|
|
805
806
|
}
|
|
806
807
|
const a = e.shape[o];
|
|
807
808
|
if (a === void 0 || typeof a == "number")
|
|
808
809
|
throw new Error(`Unknown typename '${o}' in union`);
|
|
809
|
-
return a.mask &
|
|
810
|
+
return a.mask & l.ENTITY && i.queryClient !== void 0 ? pt(t, a, i) : te(t, a, i, s);
|
|
810
811
|
}
|
|
811
812
|
}
|
|
812
|
-
function
|
|
813
|
+
function Xt(n, t, e, i) {
|
|
813
814
|
const s = [];
|
|
814
|
-
for (let r = 0; r <
|
|
815
|
+
for (let r = 0; r < n.length; r++)
|
|
815
816
|
try {
|
|
816
|
-
s.push(
|
|
817
|
+
s.push(M(n[r], t, e, `${i}[${r}]`));
|
|
817
818
|
} catch (o) {
|
|
818
819
|
e.warn("Failed to parse array item, filtering out", {
|
|
819
820
|
index: r,
|
|
820
|
-
value:
|
|
821
|
+
value: n[r],
|
|
821
822
|
error: o instanceof Error ? o.message : String(o)
|
|
822
823
|
});
|
|
823
824
|
}
|
|
824
825
|
return s;
|
|
825
826
|
}
|
|
826
|
-
function
|
|
827
|
-
for (const [s, r] of yt(
|
|
828
|
-
|
|
829
|
-
return
|
|
827
|
+
function Zt(n, t, e, i) {
|
|
828
|
+
for (const [s, r] of yt(n))
|
|
829
|
+
n[s] = M(r, t, e, `${i}["${s}"]`);
|
|
830
|
+
return n;
|
|
830
831
|
}
|
|
831
|
-
function
|
|
832
|
-
if (
|
|
833
|
-
return
|
|
832
|
+
function te(n, t, e, i) {
|
|
833
|
+
if (x.has(n))
|
|
834
|
+
return n;
|
|
834
835
|
const s = t.shape;
|
|
835
836
|
for (const [r, o] of yt(s))
|
|
836
|
-
|
|
837
|
-
return
|
|
837
|
+
n[r] = M(n[r], o, e, `${i}.${r}`);
|
|
838
|
+
return n;
|
|
838
839
|
}
|
|
839
|
-
function pt(
|
|
840
|
-
const
|
|
840
|
+
function pt(n, t, e) {
|
|
841
|
+
const i = e.queryClient, s = e.preloadedEntities;
|
|
841
842
|
let r, o;
|
|
842
843
|
if (s !== void 0)
|
|
843
|
-
r =
|
|
844
|
+
r = n.__entityRef, o = r;
|
|
844
845
|
else {
|
|
845
|
-
const p =
|
|
846
|
+
const p = n[t.idField];
|
|
846
847
|
if (p == null || typeof p != "string" && typeof p != "number")
|
|
847
848
|
throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
|
|
848
|
-
o = p, r =
|
|
849
|
+
o = p, r = D([t.typenameValue, o]);
|
|
849
850
|
}
|
|
850
851
|
const a = e.seenByKey.get(r);
|
|
851
852
|
if (a !== void 0)
|
|
852
853
|
return a.data;
|
|
853
854
|
if (s !== void 0) {
|
|
854
|
-
const g =
|
|
855
|
+
const g = i.entityMap.getEntity(r)?.data ?? s.get(r);
|
|
855
856
|
if (g === void 0)
|
|
856
857
|
throw new Error(`Cached entity ${r} not found in preloaded map`);
|
|
857
|
-
|
|
858
|
+
n = g;
|
|
858
859
|
}
|
|
859
860
|
const c = {};
|
|
860
861
|
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
861
|
-
const f =
|
|
862
|
+
const f = i.entityMap.getEntity(r), d = e.isPartialEvent && f !== void 0, u = {
|
|
862
863
|
key: r,
|
|
863
864
|
shape: t,
|
|
864
865
|
data: c,
|
|
865
|
-
rawKeys:
|
|
866
|
+
rawKeys: d ? new Set(Object.keys(n)) : void 0
|
|
866
867
|
};
|
|
867
|
-
e.seen.set(c,
|
|
868
|
+
e.seen.set(c, u), e.seenByKey.set(r, u);
|
|
868
869
|
const y = `[[${t.typenameValue}:${o}]]`, v = t.shape;
|
|
869
870
|
for (const [p, g] of yt(v))
|
|
870
|
-
|
|
871
|
+
d && !(p in n) || (c[p] = M(n[p], g, e, `${y}.${p}`));
|
|
871
872
|
return c;
|
|
872
873
|
}
|
|
873
|
-
function
|
|
874
|
-
return
|
|
874
|
+
function tn(n, t) {
|
|
875
|
+
return en(n, t.shape, t.typenameField);
|
|
875
876
|
}
|
|
876
|
-
function
|
|
877
|
+
function en(n, t, e) {
|
|
877
878
|
if (t === void 0) return !0;
|
|
878
|
-
for (const
|
|
879
|
-
if (
|
|
880
|
-
const s = t[
|
|
879
|
+
for (const i of Object.keys(t)) {
|
|
880
|
+
if (i === e) continue;
|
|
881
|
+
const s = t[i];
|
|
881
882
|
if (s instanceof _) {
|
|
882
|
-
if ((s.mask &
|
|
883
|
-
if (!(
|
|
883
|
+
if ((s.mask & l.UNDEFINED) !== 0) continue;
|
|
884
|
+
if (!(i in n) || n[i] === void 0) return !1;
|
|
884
885
|
} else if (typeof s == "number") {
|
|
885
|
-
if ((s &
|
|
886
|
-
if (!(
|
|
887
|
-
} else if (!(
|
|
886
|
+
if ((s & l.UNDEFINED) !== 0) continue;
|
|
887
|
+
if (!(i in n) || n[i] === void 0) return !1;
|
|
888
|
+
} else if (!(i in n) || n[i] === void 0) return !1;
|
|
888
889
|
}
|
|
889
890
|
return !0;
|
|
890
891
|
}
|
|
891
|
-
const
|
|
892
|
-
function
|
|
893
|
-
if (typeof
|
|
894
|
-
if (
|
|
895
|
-
if (
|
|
896
|
-
if (Array.isArray(
|
|
897
|
-
let t = $.get(
|
|
898
|
-
return t === void 0 && (t = new Proxy(
|
|
892
|
+
const nn = Object.prototype, $ = /* @__PURE__ */ new WeakMap();
|
|
893
|
+
function A(n) {
|
|
894
|
+
if (typeof n != "object" || n === null) return n;
|
|
895
|
+
if (J.has(n)) return A(n.getValue());
|
|
896
|
+
if (x.has(n)) return n;
|
|
897
|
+
if (Array.isArray(n)) {
|
|
898
|
+
let t = $.get(n);
|
|
899
|
+
return t === void 0 && (t = new Proxy(n, sn), $.set(n, t)), t;
|
|
899
900
|
}
|
|
900
|
-
if (Object.getPrototypeOf(
|
|
901
|
-
let t = $.get(
|
|
902
|
-
return t === void 0 && (t = new Proxy(
|
|
901
|
+
if (Object.getPrototypeOf(n) === nn) {
|
|
902
|
+
let t = $.get(n);
|
|
903
|
+
return t === void 0 && (t = new Proxy(n, rn), $.set(n, t)), t;
|
|
903
904
|
}
|
|
904
|
-
return
|
|
905
|
+
return n;
|
|
905
906
|
}
|
|
906
|
-
const
|
|
907
|
-
get(
|
|
907
|
+
const sn = {
|
|
908
|
+
get(n, t, e) {
|
|
908
909
|
if (typeof t == "string") {
|
|
909
|
-
const
|
|
910
|
-
if (Number.isInteger(
|
|
911
|
-
return
|
|
910
|
+
const i = Number(t);
|
|
911
|
+
if (Number.isInteger(i) && i >= 0 && i < n.length)
|
|
912
|
+
return A(n[i]);
|
|
912
913
|
}
|
|
913
|
-
return Reflect.get(
|
|
914
|
+
return Reflect.get(n, t, e);
|
|
914
915
|
},
|
|
915
916
|
set() {
|
|
916
917
|
return !1;
|
|
@@ -918,9 +919,9 @@ const ei = {
|
|
|
918
919
|
deleteProperty() {
|
|
919
920
|
return !1;
|
|
920
921
|
}
|
|
921
|
-
},
|
|
922
|
-
get(
|
|
923
|
-
return typeof t == "string" ?
|
|
922
|
+
}, rn = {
|
|
923
|
+
get(n, t, e) {
|
|
924
|
+
return typeof t == "string" ? A(n[t]) : Reflect.get(n, t, e);
|
|
924
925
|
},
|
|
925
926
|
set() {
|
|
926
927
|
return !1;
|
|
@@ -928,17 +929,17 @@ const ei = {
|
|
|
928
929
|
deleteProperty() {
|
|
929
930
|
return !1;
|
|
930
931
|
},
|
|
931
|
-
has(
|
|
932
|
-
return t in
|
|
932
|
+
has(n, t) {
|
|
933
|
+
return t in n;
|
|
933
934
|
},
|
|
934
|
-
ownKeys(
|
|
935
|
-
return Reflect.ownKeys(
|
|
935
|
+
ownKeys(n) {
|
|
936
|
+
return Reflect.ownKeys(n);
|
|
936
937
|
},
|
|
937
|
-
getOwnPropertyDescriptor(
|
|
938
|
-
return Object.getOwnPropertyDescriptor(
|
|
938
|
+
getOwnPropertyDescriptor(n, t) {
|
|
939
|
+
return Object.getOwnPropertyDescriptor(n, t);
|
|
939
940
|
}
|
|
940
941
|
};
|
|
941
|
-
class
|
|
942
|
+
class on {
|
|
942
943
|
_notifier;
|
|
943
944
|
_queryClient;
|
|
944
945
|
_proxies = /* @__PURE__ */ new Map();
|
|
@@ -955,8 +956,8 @@ class ni {
|
|
|
955
956
|
_entityCache;
|
|
956
957
|
_extraMethods;
|
|
957
958
|
_extraGetters;
|
|
958
|
-
constructor(t, e,
|
|
959
|
-
this._notifier = at(), this._queryClient = o, this.key = t, this.typename = e, this.id =
|
|
959
|
+
constructor(t, e, i, s, r, o) {
|
|
960
|
+
this._notifier = at(), this._queryClient = o, this.key = t, this.typename = e, this.id = i, this.idField = s, this.data = r, this.entityRefs = void 0;
|
|
960
961
|
}
|
|
961
962
|
retain() {
|
|
962
963
|
this.refCount++;
|
|
@@ -967,24 +968,24 @@ class ni {
|
|
|
967
968
|
if (--this.refCount > 0 || this.refCount < 0)
|
|
968
969
|
return;
|
|
969
970
|
const t = this._entityCache?.gcTime;
|
|
970
|
-
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t,
|
|
971
|
+
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, z.Entity) : this.evict();
|
|
971
972
|
}
|
|
972
973
|
evict() {
|
|
973
974
|
const t = this.liveCollections.slice();
|
|
974
975
|
this.liveCollections.length = 0;
|
|
975
|
-
for (const
|
|
976
|
+
for (const i of t) i.destroy();
|
|
976
977
|
this._queryClient.entityMap.remove(this.key);
|
|
977
978
|
const e = this.entityRefs;
|
|
978
979
|
if (this.entityRefs = void 0, e)
|
|
979
|
-
for (const
|
|
980
|
+
for (const i of e.keys()) i.release();
|
|
980
981
|
}
|
|
981
982
|
setChildRefs(t, e) {
|
|
982
|
-
const
|
|
983
|
+
const i = this.entityRefs;
|
|
983
984
|
if (t !== void 0 && t.size > 0)
|
|
984
985
|
for (const s of t.keys())
|
|
985
|
-
(
|
|
986
|
-
if (
|
|
987
|
-
for (const s of
|
|
986
|
+
(i === void 0 || !i.has(s)) && s.retain();
|
|
987
|
+
if (i !== void 0 && i.size > 0)
|
|
988
|
+
for (const s of i.keys())
|
|
988
989
|
(t === void 0 || !t.has(s)) && s.release();
|
|
989
990
|
this.entityRefs = t, e && this.save();
|
|
990
991
|
}
|
|
@@ -1000,14 +1001,14 @@ class ni {
|
|
|
1000
1001
|
}
|
|
1001
1002
|
getProxy(t) {
|
|
1002
1003
|
const e = t;
|
|
1003
|
-
let
|
|
1004
|
-
return
|
|
1004
|
+
let i = this._proxies.get(e);
|
|
1005
|
+
return i === void 0 && (i = cn(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(e, i)), i;
|
|
1005
1006
|
}
|
|
1006
1007
|
get proxy() {
|
|
1007
1008
|
return this._proxies.values().next().value;
|
|
1008
1009
|
}
|
|
1009
1010
|
satisfiesDef(t) {
|
|
1010
|
-
return this.satisfiedDefs.has(t) ? !0 :
|
|
1011
|
+
return this.satisfiedDefs.has(t) ? !0 : tn(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
|
|
1011
1012
|
}
|
|
1012
1013
|
save() {
|
|
1013
1014
|
this._queryClient.entityMap.save(this);
|
|
@@ -1019,131 +1020,131 @@ class ni {
|
|
|
1019
1020
|
this._notifier.consume();
|
|
1020
1021
|
}
|
|
1021
1022
|
}
|
|
1022
|
-
function
|
|
1023
|
-
const
|
|
1024
|
-
for (const s of
|
|
1023
|
+
function an(n, t, e) {
|
|
1024
|
+
const i = [];
|
|
1025
|
+
for (const s of n) {
|
|
1025
1026
|
if (typeof s != "object" || s === null) continue;
|
|
1026
|
-
const r =
|
|
1027
|
+
const r = x.get(s);
|
|
1027
1028
|
if (r === void 0) continue;
|
|
1028
1029
|
const o = e.entityMap.getEntity(r);
|
|
1029
|
-
o !== void 0 && o.satisfiesDef(t) &&
|
|
1030
|
+
o !== void 0 && o.satisfiesDef(t) && i.push(s);
|
|
1030
1031
|
}
|
|
1031
|
-
return
|
|
1032
|
+
return i;
|
|
1032
1033
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig,
|
|
1034
|
+
function cn(n, t, e, i, s) {
|
|
1035
|
+
const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig, d = c ? c.prototype : qt.prototype;
|
|
1035
1036
|
e.typenameField;
|
|
1036
|
-
const
|
|
1037
|
+
const u = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
|
|
1037
1038
|
let p;
|
|
1038
|
-
f?.hasSubscribe && a && "__subscribe" in a && (p = It((
|
|
1039
|
-
const h = (
|
|
1040
|
-
|
|
1039
|
+
f?.hasSubscribe && a && "__subscribe" in a && (p = It((E) => {
|
|
1040
|
+
const h = (C) => {
|
|
1041
|
+
C.__eventSource = t, s.applyMutationEvent(C);
|
|
1041
1042
|
}, m = a.__subscribe.call(g, h);
|
|
1042
|
-
return
|
|
1043
|
+
return E.value = g, m;
|
|
1043
1044
|
}));
|
|
1044
1045
|
let g;
|
|
1045
|
-
const
|
|
1046
|
-
if (
|
|
1047
|
-
for (const
|
|
1048
|
-
|
|
1049
|
-
let
|
|
1050
|
-
function
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
if (
|
|
1054
|
-
for (const m of Object.keys(
|
|
1055
|
-
|
|
1056
|
-
const h =
|
|
1046
|
+
const w = Object.keys(r);
|
|
1047
|
+
if (w.includes("__typename") || w.push("__typename"), a)
|
|
1048
|
+
for (const E of Object.keys(a))
|
|
1049
|
+
w.includes(E) || w.push(E);
|
|
1050
|
+
let I, O = w;
|
|
1051
|
+
function K() {
|
|
1052
|
+
const E = n._extraMethods;
|
|
1053
|
+
if (E !== I) {
|
|
1054
|
+
if (I = E, O = w.slice(), E !== void 0)
|
|
1055
|
+
for (const m of Object.keys(E))
|
|
1056
|
+
O.includes(m) || O.push(m);
|
|
1057
|
+
const h = n._extraGetters;
|
|
1057
1058
|
if (h !== void 0)
|
|
1058
1059
|
for (const m of Object.keys(h))
|
|
1059
|
-
|
|
1060
|
+
O.includes(m) || O.push(m);
|
|
1060
1061
|
}
|
|
1061
|
-
return
|
|
1062
|
+
return O;
|
|
1062
1063
|
}
|
|
1063
|
-
const
|
|
1064
|
+
const R = {
|
|
1064
1065
|
getPrototypeOf() {
|
|
1065
|
-
return
|
|
1066
|
+
return d;
|
|
1066
1067
|
},
|
|
1067
|
-
get(
|
|
1068
|
+
get(E, h) {
|
|
1068
1069
|
if (typeof h == "symbol") return;
|
|
1069
1070
|
if (h === "toJSON") return v;
|
|
1070
1071
|
if (h === "__context") return s.getContext();
|
|
1071
|
-
if (h === "__typename") return
|
|
1072
|
-
if (p?.value,
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1075
|
-
return
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
let
|
|
1079
|
-
return
|
|
1072
|
+
if (h === "__typename") return n.typename;
|
|
1073
|
+
if (p?.value, i.consume(), typeof h == "string") {
|
|
1074
|
+
const C = n._extraGetters;
|
|
1075
|
+
if (C !== void 0 && h in C)
|
|
1076
|
+
return C[h]();
|
|
1077
|
+
const S = n._extraMethods;
|
|
1078
|
+
if (S !== void 0 && h in S) {
|
|
1079
|
+
let b = u.get(h);
|
|
1080
|
+
return b || (b = S[h].bind(g), u.set(h, b)), b;
|
|
1080
1081
|
}
|
|
1081
1082
|
if (a && h in a) {
|
|
1082
|
-
let
|
|
1083
|
-
return
|
|
1083
|
+
let b = u.get(h);
|
|
1084
|
+
return b || (b = pe(g, a[h].bind(g)), u.set(h, b)), b;
|
|
1084
1085
|
}
|
|
1085
1086
|
}
|
|
1086
|
-
const m =
|
|
1087
|
-
if (typeof m == "object" && m !== null &&
|
|
1088
|
-
return
|
|
1087
|
+
const m = n.data[h];
|
|
1088
|
+
if (typeof m == "object" && m !== null && J.has(m))
|
|
1089
|
+
return A(m.getValue());
|
|
1089
1090
|
if (Array.isArray(m) && typeof h == "string") {
|
|
1090
|
-
const
|
|
1091
|
-
if (
|
|
1092
|
-
const
|
|
1093
|
-
if (
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
const _t = s.getEntityDefsForTypename(
|
|
1091
|
+
const C = r[h];
|
|
1092
|
+
if (C instanceof _ && (C.mask & l.ARRAY) !== 0) {
|
|
1093
|
+
const S = C.shape;
|
|
1094
|
+
if (S instanceof _ && (S.mask & l.ENTITY) !== 0) {
|
|
1095
|
+
const b = S.typenameValue;
|
|
1096
|
+
if (b !== void 0) {
|
|
1097
|
+
const _t = s.getEntityDefsForTypename(b);
|
|
1097
1098
|
if (_t !== void 0 && _t.length > 1) {
|
|
1098
1099
|
const X = y.get(h);
|
|
1099
1100
|
if (X !== void 0 && X.source === m)
|
|
1100
|
-
return
|
|
1101
|
-
const mt =
|
|
1102
|
-
return y.set(h, { source: m, filtered: mt }),
|
|
1101
|
+
return A(X.filtered);
|
|
1102
|
+
const mt = an(m, S, s);
|
|
1103
|
+
return y.set(h, { source: m, filtered: mt }), A(mt);
|
|
1103
1104
|
}
|
|
1104
1105
|
}
|
|
1105
1106
|
}
|
|
1106
1107
|
}
|
|
1107
|
-
return
|
|
1108
|
+
return A(m);
|
|
1108
1109
|
}
|
|
1109
|
-
return
|
|
1110
|
+
return A(m);
|
|
1110
1111
|
},
|
|
1111
1112
|
set() {
|
|
1112
1113
|
return !1;
|
|
1113
1114
|
},
|
|
1114
|
-
has(
|
|
1115
|
+
has(E, h) {
|
|
1115
1116
|
if (h === "__typename") return !0;
|
|
1116
1117
|
if (typeof h == "string") {
|
|
1117
|
-
const m =
|
|
1118
|
+
const m = n._extraGetters;
|
|
1118
1119
|
if (m && h in m) return !0;
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1120
|
+
const C = n._extraMethods;
|
|
1121
|
+
if (C && h in C || a && h in a) return !0;
|
|
1121
1122
|
}
|
|
1122
1123
|
return h in r;
|
|
1123
1124
|
},
|
|
1124
1125
|
ownKeys() {
|
|
1125
|
-
return
|
|
1126
|
+
return K();
|
|
1126
1127
|
},
|
|
1127
|
-
getOwnPropertyDescriptor(
|
|
1128
|
+
getOwnPropertyDescriptor(E, h) {
|
|
1128
1129
|
if (h === "__typename")
|
|
1129
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1130
|
+
return { enumerable: !0, configurable: !0, value: n.typename, writable: !1 };
|
|
1130
1131
|
if (h in r)
|
|
1131
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1132
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1132
1133
|
if (typeof h == "string") {
|
|
1133
|
-
const m =
|
|
1134
|
+
const m = n._extraGetters;
|
|
1134
1135
|
if (m && h in m)
|
|
1135
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1136
|
-
const
|
|
1137
|
-
if (
|
|
1138
|
-
return { enumerable: !0, configurable: !0, value:
|
|
1136
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1137
|
+
const C = n._extraMethods;
|
|
1138
|
+
if (C && h in C)
|
|
1139
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1139
1140
|
if (a && h in a)
|
|
1140
|
-
return { enumerable: !1, configurable: !0, value:
|
|
1141
|
+
return { enumerable: !1, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1141
1142
|
}
|
|
1142
1143
|
}
|
|
1143
1144
|
};
|
|
1144
|
-
return g = new Proxy({},
|
|
1145
|
+
return g = new Proxy({}, R), x.set(g, t), ye(g, s), g;
|
|
1145
1146
|
}
|
|
1146
|
-
class
|
|
1147
|
+
class fn {
|
|
1147
1148
|
instances = /* @__PURE__ */ new Map();
|
|
1148
1149
|
persistEntity;
|
|
1149
1150
|
constructor(t) {
|
|
@@ -1155,17 +1156,17 @@ class oi {
|
|
|
1155
1156
|
getEntity(t) {
|
|
1156
1157
|
return this.instances.get(t);
|
|
1157
1158
|
}
|
|
1158
|
-
getOrCreateEntity(t, e,
|
|
1159
|
+
getOrCreateEntity(t, e, i, s) {
|
|
1159
1160
|
let r = this.instances.get(t);
|
|
1160
1161
|
if (r === void 0) {
|
|
1161
|
-
const o =
|
|
1162
|
+
const o = i.idField;
|
|
1162
1163
|
if (o === void 0)
|
|
1163
|
-
throw new Error(`Entity id field is required ${
|
|
1164
|
+
throw new Error(`Entity id field is required ${i.typenameValue}`);
|
|
1164
1165
|
const a = e[o];
|
|
1165
1166
|
if (typeof a != "string" && typeof a != "number")
|
|
1166
|
-
throw new Error(`Entity id must be string or number: ${
|
|
1167
|
-
const c =
|
|
1168
|
-
r = new
|
|
1167
|
+
throw new Error(`Entity id must be string or number: ${i.typenameValue}`);
|
|
1168
|
+
const c = i;
|
|
1169
|
+
r = new on(t, i.typenameValue, a, o, e, s), r._entityCache = c._entityCache, this.instances.set(t, r);
|
|
1169
1170
|
}
|
|
1170
1171
|
return r.parseId = s.currentParseId, r;
|
|
1171
1172
|
}
|
|
@@ -1176,18 +1177,18 @@ class oi {
|
|
|
1176
1177
|
let e;
|
|
1177
1178
|
if (t.entityRefs) {
|
|
1178
1179
|
e = /* @__PURE__ */ new Set();
|
|
1179
|
-
for (const
|
|
1180
|
+
for (const i of t.entityRefs.keys()) e.add(i.key);
|
|
1180
1181
|
}
|
|
1181
1182
|
this.persistEntity(t.key, t.data, e);
|
|
1182
1183
|
}
|
|
1183
1184
|
}
|
|
1184
|
-
class
|
|
1185
|
+
class ee {
|
|
1185
1186
|
onlineSignal;
|
|
1186
1187
|
manualOverride = void 0;
|
|
1187
1188
|
eventListenersAttached = !1;
|
|
1188
1189
|
constructor(t) {
|
|
1189
1190
|
const e = t ?? this.detectOnlineStatus();
|
|
1190
|
-
this.onlineSignal =
|
|
1191
|
+
this.onlineSignal = Nt(e), this.canAttachListeners() && this.attachEventListeners();
|
|
1191
1192
|
}
|
|
1192
1193
|
/**
|
|
1193
1194
|
* Returns true if the network is currently online
|
|
@@ -1246,7 +1247,7 @@ class ie {
|
|
|
1246
1247
|
}
|
|
1247
1248
|
}
|
|
1248
1249
|
class ne {
|
|
1249
|
-
static onlineSignal =
|
|
1250
|
+
static onlineSignal = Nt(!0);
|
|
1250
1251
|
get isOnline() {
|
|
1251
1252
|
return !0;
|
|
1252
1253
|
}
|
|
@@ -1260,97 +1261,28 @@ class ne {
|
|
|
1260
1261
|
destroy() {
|
|
1261
1262
|
}
|
|
1262
1263
|
}
|
|
1263
|
-
const
|
|
1264
|
-
function gt(
|
|
1264
|
+
const un = new ee(), In = Mt(un);
|
|
1265
|
+
function gt(n, t = typeof window > "u") {
|
|
1265
1266
|
let e;
|
|
1266
|
-
|
|
1267
|
-
const
|
|
1268
|
-
return { retries: e, retryDelay:
|
|
1267
|
+
n === !1 ? e = 0 : n === void 0 || n === !0 ? e = t ? 0 : 3 : typeof n == "number" ? e = n : e = n.retries;
|
|
1268
|
+
const i = typeof n == "object" && n.retryDelay ? n.retryDelay : (s) => 1e3 * Math.pow(2, s);
|
|
1269
|
+
return { retries: e, retryDelay: i };
|
|
1269
1270
|
}
|
|
1270
|
-
class
|
|
1271
|
+
class Nn {
|
|
1271
1272
|
static cache;
|
|
1273
|
+
/**
|
|
1274
|
+
* The controller class responsible for sending requests for this query type.
|
|
1275
|
+
* Must be set on each concrete Query subclass (or inherited from a base like RESTQuery).
|
|
1276
|
+
*/
|
|
1277
|
+
static controller;
|
|
1272
1278
|
params;
|
|
1273
1279
|
config;
|
|
1274
1280
|
constructor() {
|
|
1275
|
-
return
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
class Si extends ci {
|
|
1279
|
-
method = "GET";
|
|
1280
|
-
path;
|
|
1281
|
-
searchParams;
|
|
1282
|
-
body;
|
|
1283
|
-
headers;
|
|
1284
|
-
requestOptions;
|
|
1285
|
-
loadNext;
|
|
1286
|
-
getStorageKey() {
|
|
1287
|
-
return `${this.method ?? "GET"}:${this.path ?? ""}`;
|
|
1288
|
-
}
|
|
1289
|
-
async send() {
|
|
1290
|
-
return this.executeRequest();
|
|
1291
|
-
}
|
|
1292
|
-
resolveLoadNext() {
|
|
1293
|
-
const e = (this.getLoadNext ? this.getLoadNext() : void 0) ?? this.rawLoadNext;
|
|
1294
|
-
if (e === void 0) return;
|
|
1295
|
-
const n = {
|
|
1296
|
-
params: this.params ?? {},
|
|
1297
|
-
result: this.resultData
|
|
1298
|
-
};
|
|
1299
|
-
return {
|
|
1300
|
-
url: e.url !== void 0 ? P(e.url, n) : void 0,
|
|
1301
|
-
searchParams: e.searchParams !== void 0 ? P(e.searchParams, n) : void 0
|
|
1302
|
-
};
|
|
1303
|
-
}
|
|
1304
|
-
hasNext() {
|
|
1305
|
-
const t = this.resolveLoadNext();
|
|
1306
|
-
if (t === void 0) return !1;
|
|
1307
|
-
if (t.url !== void 0 && t.url !== null)
|
|
1308
|
-
return !0;
|
|
1309
|
-
if (t.searchParams !== void 0) {
|
|
1310
|
-
const e = Object.keys(t.searchParams);
|
|
1311
|
-
if (e.length === 0) return !1;
|
|
1312
|
-
for (const n of e)
|
|
1313
|
-
if (t.searchParams[n] === void 0 || t.searchParams[n] === null)
|
|
1314
|
-
return !1;
|
|
1315
|
-
return !0;
|
|
1316
|
-
}
|
|
1317
|
-
return !1;
|
|
1318
|
-
}
|
|
1319
|
-
async sendNext() {
|
|
1320
|
-
const t = this.resolveLoadNext();
|
|
1321
|
-
if (t === void 0)
|
|
1322
|
-
throw new Error("loadNext is not configured for this query");
|
|
1323
|
-
return this.executeRequest(t);
|
|
1324
|
-
}
|
|
1325
|
-
async executeRequest(t) {
|
|
1326
|
-
const e = t?.url ?? (this.getPath ? this.getPath() : this.path), n = this.getMethod ? this.getMethod() : this.method, s = this.getSearchParams ? this.getSearchParams() : this.searchParams, r = t?.searchParams ? { ...s, ...t.searchParams } : s, o = this.getBody ? this.getBody() : this.body, a = this.getRequestOptions ? this.getRequestOptions() : this.requestOptions;
|
|
1327
|
-
if (!e)
|
|
1328
|
-
throw new Error("RESTQuery requires a path. Define `path` as a field or override `getPath()`.");
|
|
1329
|
-
let c = e;
|
|
1330
|
-
if (r) {
|
|
1331
|
-
const S = new URLSearchParams();
|
|
1332
|
-
for (const I in r) {
|
|
1333
|
-
const x = r[I];
|
|
1334
|
-
x != null && S.append(I, String(x));
|
|
1335
|
-
}
|
|
1336
|
-
const C = S.toString();
|
|
1337
|
-
C && (c += "?" + C);
|
|
1338
|
-
}
|
|
1339
|
-
const f = Dt(a?.baseUrl) ?? Dt(this.context.baseUrl), l = f ? `${f}${c}` : c, { baseUrl: d, signal: y, ...v } = a ?? {}, g = o || this.headers ? {
|
|
1340
|
-
...o ? { "Content-Type": "application/json" } : void 0,
|
|
1341
|
-
...this.headers
|
|
1342
|
-
} : void 0, E = await this.context.fetch(l, {
|
|
1343
|
-
method: n,
|
|
1344
|
-
headers: g,
|
|
1345
|
-
body: o ? JSON.stringify(o) : void 0,
|
|
1346
|
-
signal: this.signal,
|
|
1347
|
-
...v
|
|
1348
|
-
});
|
|
1349
|
-
return this.response = E, E.json();
|
|
1281
|
+
return jt(this);
|
|
1350
1282
|
}
|
|
1351
1283
|
}
|
|
1352
|
-
const
|
|
1353
|
-
class
|
|
1284
|
+
const Ot = /* @__PURE__ */ new WeakMap();
|
|
1285
|
+
class V {
|
|
1354
1286
|
constructor(t, e) {
|
|
1355
1287
|
this.captured = e, this.statics = t;
|
|
1356
1288
|
}
|
|
@@ -1359,71 +1291,76 @@ class J {
|
|
|
1359
1291
|
return et(this.captured, t, e);
|
|
1360
1292
|
}
|
|
1361
1293
|
resolveOptions(t) {
|
|
1362
|
-
const { methods: e } = this.captured,
|
|
1363
|
-
return { config:
|
|
1294
|
+
const { methods: e } = this.captured, i = e.getConfig ? e.getConfig.call(t) : t.config, s = gt(i?.retry);
|
|
1295
|
+
return { config: i, retryConfig: s };
|
|
1364
1296
|
}
|
|
1365
1297
|
static for(t) {
|
|
1366
|
-
let e =
|
|
1298
|
+
let e = Ot.get(t);
|
|
1367
1299
|
if (e !== void 0)
|
|
1368
1300
|
return e;
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1301
|
+
const i = new t(), s = De(i), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : He.object(o), c = (a.mask & l.ENTITY) !== 0, f = t.cache, d = s.fields.fetchNext, u = t.controller;
|
|
1302
|
+
if (!u)
|
|
1303
|
+
throw new Error(
|
|
1304
|
+
`Query class "${t.name}" must define a static \`controller\` property. Extend RESTQuery (from fetchium/rest) or set \`static controller = MyController\` on your query class.`
|
|
1305
|
+
);
|
|
1306
|
+
const y = typeof u.prototype.sendNext == "function", v = c ? a : new _(
|
|
1307
|
+
l.ENTITY | l.OBJECT,
|
|
1371
1308
|
a.shape,
|
|
1372
1309
|
void 0,
|
|
1373
1310
|
void 0,
|
|
1374
1311
|
r,
|
|
1375
1312
|
// typenameValue — unique per query class
|
|
1376
|
-
|
|
1313
|
+
Ft
|
|
1377
1314
|
// idField — symbol, injected onto payload before parse
|
|
1378
1315
|
);
|
|
1379
|
-
return e = new
|
|
1380
|
-
{ id: r, shape:
|
|
1316
|
+
return e = new V(
|
|
1317
|
+
{ id: r, shape: v, cache: f, rawFetchNext: d, hasSendNext: y, isEntityResult: c, controllerClass: u },
|
|
1381
1318
|
s
|
|
1382
|
-
),
|
|
1319
|
+
), Ot.set(t, e), e;
|
|
1383
1320
|
}
|
|
1384
1321
|
}
|
|
1385
|
-
const
|
|
1386
|
-
const e =
|
|
1322
|
+
const Mn = (n, t) => {
|
|
1323
|
+
const e = V.for(n);
|
|
1387
1324
|
return vt(e, t);
|
|
1388
1325
|
};
|
|
1389
|
-
function
|
|
1390
|
-
const e =
|
|
1391
|
-
if (
|
|
1326
|
+
function kn(n, ...t) {
|
|
1327
|
+
const e = V.for(n), i = ge(bn);
|
|
1328
|
+
if (i === void 0)
|
|
1392
1329
|
throw new Error("QueryClient not found");
|
|
1393
1330
|
const s = t[0];
|
|
1394
|
-
return
|
|
1331
|
+
return i.getQuery(e, s);
|
|
1395
1332
|
}
|
|
1396
|
-
function
|
|
1397
|
-
return new Promise((e,
|
|
1333
|
+
function ie(n, t) {
|
|
1334
|
+
return new Promise((e, i) => {
|
|
1398
1335
|
if (t?.aborted) {
|
|
1399
|
-
|
|
1336
|
+
i(t.reason);
|
|
1400
1337
|
return;
|
|
1401
1338
|
}
|
|
1402
|
-
const s = setTimeout(e,
|
|
1339
|
+
const s = setTimeout(e, n);
|
|
1403
1340
|
t?.addEventListener(
|
|
1404
1341
|
"abort",
|
|
1405
1342
|
() => {
|
|
1406
|
-
clearTimeout(s),
|
|
1343
|
+
clearTimeout(s), i(t.reason);
|
|
1407
1344
|
},
|
|
1408
1345
|
{ once: !0 }
|
|
1409
1346
|
);
|
|
1410
1347
|
});
|
|
1411
1348
|
}
|
|
1412
|
-
async function rt(
|
|
1413
|
-
const
|
|
1349
|
+
async function rt(n, t, e) {
|
|
1350
|
+
const i = Math.max(0, t.retries);
|
|
1414
1351
|
let s;
|
|
1415
|
-
for (let r = 0; r <=
|
|
1352
|
+
for (let r = 0; r <= i; r++) {
|
|
1416
1353
|
e?.throwIfAborted();
|
|
1417
1354
|
try {
|
|
1418
|
-
return await
|
|
1355
|
+
return await n();
|
|
1419
1356
|
} catch (o) {
|
|
1420
|
-
if (s = o, r >=
|
|
1421
|
-
await
|
|
1357
|
+
if (s = o, r >= i) throw o;
|
|
1358
|
+
await ie(t.retryDelay(r), e);
|
|
1422
1359
|
}
|
|
1423
1360
|
}
|
|
1424
1361
|
throw s;
|
|
1425
1362
|
}
|
|
1426
|
-
class
|
|
1363
|
+
class ln {
|
|
1427
1364
|
def;
|
|
1428
1365
|
queryKey;
|
|
1429
1366
|
storageKey = -1;
|
|
@@ -1441,8 +1378,6 @@ class fi {
|
|
|
1441
1378
|
/** Resolved per-instance options (depend on actual params). */
|
|
1442
1379
|
config = void 0;
|
|
1443
1380
|
retryConfig = gt(void 0);
|
|
1444
|
-
/** The raw fetch Response from the most recent successful fetch. */
|
|
1445
|
-
_lastResponse = void 0;
|
|
1446
1381
|
/** Controller for aborting in-flight fetches and retry waits. */
|
|
1447
1382
|
_abortController = void 0;
|
|
1448
1383
|
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
@@ -1451,7 +1386,7 @@ class fi {
|
|
|
1451
1386
|
/** Root entity that holds parsed data, proxy, child refs, and bindings.
|
|
1452
1387
|
* For entity results, this is undefined until the first apply discovers it. */
|
|
1453
1388
|
rootEntity;
|
|
1454
|
-
/** Extra methods (__refetch,
|
|
1389
|
+
/** Extra methods (__refetch, __fetchNext) attached to the root entity proxy. */
|
|
1455
1390
|
_extraMethods = {};
|
|
1456
1391
|
/** Query id injected as QUERY_ID on non-entity payloads. */
|
|
1457
1392
|
_queryId = 0;
|
|
@@ -1461,24 +1396,24 @@ class fi {
|
|
|
1461
1396
|
get relayState() {
|
|
1462
1397
|
return this._relayState;
|
|
1463
1398
|
}
|
|
1464
|
-
constructor(t, e,
|
|
1465
|
-
this.def = t, this.queryClient = e, this.queryKey =
|
|
1466
|
-
const r =
|
|
1467
|
-
this._queryId = r !== void 0 ?
|
|
1399
|
+
constructor(t, e, i, s) {
|
|
1400
|
+
this.def = t, this.queryClient = e, this.queryKey = i, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
|
|
1401
|
+
const r = Dt(s);
|
|
1402
|
+
this._queryId = r !== void 0 ? D(r) : 0, this.relay = It(
|
|
1468
1403
|
(o) => {
|
|
1469
1404
|
this._relayState = o;
|
|
1470
1405
|
const a = () => {
|
|
1471
|
-
clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this.
|
|
1472
|
-
const f = this.config?.gcTime ??
|
|
1473
|
-
this.queryClient.gcManager.schedule(this.queryKey, f,
|
|
1406
|
+
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;
|
|
1407
|
+
const f = this.config?.gcTime ?? kt;
|
|
1408
|
+
this.queryClient.gcManager.schedule(this.queryKey, f, z.Query);
|
|
1474
1409
|
}, c = (f = !1) => {
|
|
1475
|
-
const { wasPaused:
|
|
1476
|
-
if (this.wasPaused =
|
|
1410
|
+
const { wasPaused: d, isPaused: u, initialized: y } = this;
|
|
1411
|
+
if (this.wasPaused = u, u && !d && y) {
|
|
1477
1412
|
a();
|
|
1478
1413
|
return;
|
|
1479
1414
|
}
|
|
1480
|
-
const v =
|
|
1481
|
-
g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ?
|
|
1415
|
+
const v = Dt(this.params), p = vt(this.def, v), g = p !== this.storageKey;
|
|
1416
|
+
g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? d || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1482
1417
|
};
|
|
1483
1418
|
return c(!0), {
|
|
1484
1419
|
update: c,
|
|
@@ -1489,18 +1424,18 @@ class fi {
|
|
|
1489
1424
|
);
|
|
1490
1425
|
}
|
|
1491
1426
|
/** Apply raw data (fresh or cached) to the root entity and return the proxy. */
|
|
1492
|
-
applyData(t, e,
|
|
1427
|
+
applyData(t, e, i = !1, s) {
|
|
1493
1428
|
const r = this.def;
|
|
1494
1429
|
return this.rootEntity = this.queryClient.parseAndApplyRootEntity(
|
|
1495
1430
|
t,
|
|
1496
1431
|
this._queryId,
|
|
1497
1432
|
r.statics.shape,
|
|
1498
1433
|
e,
|
|
1499
|
-
|
|
1434
|
+
i,
|
|
1500
1435
|
s
|
|
1501
1436
|
), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
|
|
1502
1437
|
__hasNext: () => this.hasNext,
|
|
1503
|
-
|
|
1438
|
+
__isFetchingNext: () => this._fetchNextPromise !== void 0
|
|
1504
1439
|
}), this.rootEntity.getProxy(r.statics.shape);
|
|
1505
1440
|
}
|
|
1506
1441
|
/** Save query metadata (the __entityRef pointer, updatedAt, ref set). */
|
|
@@ -1518,16 +1453,16 @@ class fi {
|
|
|
1518
1453
|
async initialize() {
|
|
1519
1454
|
const t = this.queryClient, e = this.relayState;
|
|
1520
1455
|
this.initialized = !0;
|
|
1521
|
-
let
|
|
1456
|
+
let i;
|
|
1522
1457
|
try {
|
|
1523
|
-
|
|
1458
|
+
i = await t.loadCachedQuery(this.def, this.storageKey), i !== void 0 && (this.updatedAt = i.updatedAt, e.value = this.applyData(i.value, !1, !1, i.preloadedEntities));
|
|
1524
1459
|
} catch (s) {
|
|
1525
1460
|
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid", s);
|
|
1526
1461
|
}
|
|
1527
1462
|
if (!this.isPaused)
|
|
1528
1463
|
try {
|
|
1529
|
-
if (
|
|
1530
|
-
if (await
|
|
1464
|
+
if (i !== void 0 && this.setupSubscription(), i === void 0 || this.isStale) {
|
|
1465
|
+
if (await ie(0), this.isPaused) return;
|
|
1531
1466
|
this.runQueryImmediately();
|
|
1532
1467
|
}
|
|
1533
1468
|
} catch (s) {
|
|
@@ -1539,15 +1474,15 @@ class fi {
|
|
|
1539
1474
|
const t = this.config?.subscribe;
|
|
1540
1475
|
if (!t) return;
|
|
1541
1476
|
const e = this._executionCtx;
|
|
1542
|
-
this.unsubscribe = t.call(e, (
|
|
1543
|
-
|
|
1477
|
+
this.unsubscribe = t.call(e, (i) => {
|
|
1478
|
+
i.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(i);
|
|
1544
1479
|
});
|
|
1545
1480
|
}
|
|
1546
1481
|
getOrCreateExecutionContext() {
|
|
1547
1482
|
return (this._executionCtx === void 0 || this._executionCtxKey !== this.storageKey) && (this._executionCtxKey = this.storageKey, this._executionCtx = this.def.createExecutionContext(
|
|
1548
1483
|
this.currentParams ?? {},
|
|
1549
1484
|
this.queryClient.getContext()
|
|
1550
|
-
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.
|
|
1485
|
+
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext), this.resolveAndApplyOptions(), this._executionCtx;
|
|
1551
1486
|
}
|
|
1552
1487
|
resolveAndApplyOptions() {
|
|
1553
1488
|
const t = this.def.resolveOptions(this._executionCtx);
|
|
@@ -1557,11 +1492,11 @@ class fi {
|
|
|
1557
1492
|
const t = this.def;
|
|
1558
1493
|
if (this.isPaused)
|
|
1559
1494
|
throw new Error("Query is paused due to network status");
|
|
1560
|
-
const e = this.getOrCreateExecutionContext(),
|
|
1561
|
-
return
|
|
1495
|
+
const e = this.getOrCreateExecutionContext(), i = this.queryClient.getController(t.statics.controllerClass), s = this._abortController?.signal ?? new AbortController().signal;
|
|
1496
|
+
return rt(
|
|
1562
1497
|
async () => {
|
|
1563
|
-
const r = await
|
|
1564
|
-
this.
|
|
1498
|
+
const r = await i.send(e, s);
|
|
1499
|
+
this.updatedAt = Date.now();
|
|
1565
1500
|
const o = this.applyData(r, !0);
|
|
1566
1501
|
return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
|
|
1567
1502
|
},
|
|
@@ -1570,7 +1505,7 @@ class fi {
|
|
|
1570
1505
|
);
|
|
1571
1506
|
}
|
|
1572
1507
|
runQueryImmediately() {
|
|
1573
|
-
this._abortController?.abort(), this._abortController = new AbortController(), this.
|
|
1508
|
+
this._abortController?.abort(), this._abortController = new AbortController(), this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.relayState.setPromise(this.runQuery());
|
|
1574
1509
|
}
|
|
1575
1510
|
runDebounced() {
|
|
1576
1511
|
if (this.relayState.isPending) return;
|
|
@@ -1583,35 +1518,41 @@ class fi {
|
|
|
1583
1518
|
// Public methods
|
|
1584
1519
|
// ======================================================
|
|
1585
1520
|
refetch = () => this.relayState.isPending ? this.relay : (this.runQueryImmediately(), this.relay);
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1521
|
+
markStale() {
|
|
1522
|
+
this.updatedAt = 0;
|
|
1523
|
+
}
|
|
1524
|
+
get resolvedParams() {
|
|
1525
|
+
return this.currentParams;
|
|
1526
|
+
}
|
|
1527
|
+
/** In-flight fetchNext promise for deduplication. */
|
|
1528
|
+
_fetchNextPromise = void 0;
|
|
1529
|
+
/** Controller for aborting in-flight fetchNext requests. */
|
|
1530
|
+
_fetchNextAbort = void 0;
|
|
1531
|
+
fetchNext = () => {
|
|
1591
1532
|
if (this.updatedAt === void 0)
|
|
1592
|
-
throw new Error("Cannot call
|
|
1593
|
-
return this.
|
|
1594
|
-
(t) => (this.
|
|
1533
|
+
throw new Error("Cannot call __fetchNext before initial data has loaded");
|
|
1534
|
+
return this._fetchNextPromise !== void 0 ? this._fetchNextPromise : (queueMicrotask(() => this.rootEntity?.notify()), this._fetchNextPromise = this.runFetchNext().then(
|
|
1535
|
+
(t) => (this._fetchNextPromise = void 0, this.rootEntity?.notify(), t),
|
|
1595
1536
|
(t) => {
|
|
1596
|
-
throw this.
|
|
1537
|
+
throw this._fetchNextPromise = void 0, this.rootEntity?.notify(), t;
|
|
1597
1538
|
}
|
|
1598
|
-
), this.
|
|
1539
|
+
), this._fetchNextPromise);
|
|
1599
1540
|
};
|
|
1600
1541
|
get hasNext() {
|
|
1601
1542
|
if (this.rootEntity === void 0 || !this._executionCtx) return !1;
|
|
1602
|
-
const t = this.def.
|
|
1603
|
-
return t ? (this._executionCtx.resultData = this.rootEntity.data, t.
|
|
1543
|
+
const t = this.queryClient.getController(this.def.statics.controllerClass);
|
|
1544
|
+
return t.hasNext ? (this._executionCtx.resultData = this.rootEntity.data, t.hasNext(this._executionCtx)) : !1;
|
|
1604
1545
|
}
|
|
1605
|
-
async
|
|
1546
|
+
async runFetchNext() {
|
|
1606
1547
|
const t = this.def;
|
|
1607
|
-
this.
|
|
1608
|
-
const e = this.
|
|
1609
|
-
|
|
1610
|
-
const s = t.
|
|
1548
|
+
this._fetchNextAbort = new AbortController();
|
|
1549
|
+
const e = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
|
|
1550
|
+
i.resultData = this.rootEntity.data;
|
|
1551
|
+
const s = this.queryClient.getController(t.statics.controllerClass);
|
|
1611
1552
|
return rt(
|
|
1612
1553
|
async () => {
|
|
1613
|
-
const r = await s.
|
|
1614
|
-
this.
|
|
1554
|
+
const r = await s.sendNext(i, e);
|
|
1555
|
+
this.updatedAt = Date.now();
|
|
1615
1556
|
const o = this.applyData(r, !0, !0);
|
|
1616
1557
|
return this.saveQueryMetadata(), o;
|
|
1617
1558
|
},
|
|
@@ -1629,38 +1570,37 @@ class fi {
|
|
|
1629
1570
|
return Date.now() - this.updatedAt >= t;
|
|
1630
1571
|
}
|
|
1631
1572
|
get isPaused() {
|
|
1632
|
-
const t = this.config?.networkMode ??
|
|
1633
|
-
if (t ===
|
|
1573
|
+
const t = this.config?.networkMode ?? L.Online;
|
|
1574
|
+
if (t === L.Always)
|
|
1634
1575
|
return !1;
|
|
1635
1576
|
const e = this.queryClient.networkManager.getOnlineSignal().value;
|
|
1636
1577
|
switch (t) {
|
|
1637
|
-
case
|
|
1578
|
+
case L.Online:
|
|
1638
1579
|
return !e;
|
|
1639
|
-
case
|
|
1580
|
+
case L.OfflineFirst:
|
|
1640
1581
|
return !e && this.updatedAt === void 0;
|
|
1641
1582
|
default:
|
|
1642
1583
|
return !1;
|
|
1643
1584
|
}
|
|
1644
1585
|
}
|
|
1645
1586
|
}
|
|
1646
|
-
class
|
|
1587
|
+
class dn {
|
|
1647
1588
|
def;
|
|
1648
1589
|
queryClient;
|
|
1649
|
-
_lastResponse;
|
|
1650
1590
|
_inFlight = !1;
|
|
1651
1591
|
task;
|
|
1652
1592
|
constructor(t, e) {
|
|
1653
1593
|
this.def = t, this.queryClient = e, this.task = this.createTask();
|
|
1654
1594
|
}
|
|
1655
1595
|
createTask() {
|
|
1656
|
-
return
|
|
1596
|
+
return ve(
|
|
1657
1597
|
async (t) => {
|
|
1658
1598
|
if (this._inFlight)
|
|
1659
1599
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
1660
1600
|
this._inFlight = !0;
|
|
1661
1601
|
try {
|
|
1662
|
-
const e = await this.executeWithRetry(t),
|
|
1663
|
-
return this.processEffects(t,
|
|
1602
|
+
const e = await this.executeWithRetry(t), i = this.validateResponse(e);
|
|
1603
|
+
return this.processEffects(t, i), i;
|
|
1664
1604
|
} finally {
|
|
1665
1605
|
this._inFlight = !1;
|
|
1666
1606
|
}
|
|
@@ -1672,122 +1612,126 @@ class ui {
|
|
|
1672
1612
|
const e = this.def.responseShape;
|
|
1673
1613
|
if (!(e instanceof _))
|
|
1674
1614
|
return t;
|
|
1675
|
-
const
|
|
1615
|
+
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1676
1616
|
}), s = new st();
|
|
1677
|
-
return s.reset(void 0, void 0,
|
|
1617
|
+
return s.reset(void 0, void 0, i), Jt(t, e, s);
|
|
1678
1618
|
}
|
|
1679
1619
|
// ======================================================
|
|
1680
1620
|
// Effects processing
|
|
1681
1621
|
// ======================================================
|
|
1682
1622
|
processEffects(t, e) {
|
|
1683
|
-
let
|
|
1623
|
+
let i;
|
|
1684
1624
|
if (this.def.hasGetEffects) {
|
|
1685
1625
|
const r = et(
|
|
1686
1626
|
this.def.captured,
|
|
1687
1627
|
t ?? {},
|
|
1688
1628
|
this.queryClient.getContext()
|
|
1689
1629
|
);
|
|
1690
|
-
r.result = e,
|
|
1630
|
+
r.result = e, i = r.getEffects();
|
|
1691
1631
|
} else if (this.def.effects !== void 0) {
|
|
1692
1632
|
const r = { params: t, result: e };
|
|
1693
|
-
|
|
1633
|
+
i = W(this.def.effects, r);
|
|
1694
1634
|
}
|
|
1695
|
-
if (
|
|
1635
|
+
if (i === void 0) return;
|
|
1696
1636
|
const s = this.queryClient;
|
|
1697
|
-
Z(
|
|
1637
|
+
Z(i.creates, "create", s), Z(i.updates, "update", s), Z(i.deletes, "delete", s), i.invalidates && s.invalidateQueries(i.invalidates);
|
|
1698
1638
|
}
|
|
1699
1639
|
// ======================================================
|
|
1700
1640
|
// Retry logic
|
|
1701
1641
|
// ======================================================
|
|
1702
1642
|
executeWithRetry(t) {
|
|
1703
|
-
const e = gt(this.def.config?.retry, !0);
|
|
1643
|
+
const e = gt(this.def.config?.retry, !0), i = this.queryClient.getController(this.def.controllerClass);
|
|
1644
|
+
if (!i.sendMutation)
|
|
1645
|
+
throw new Error(
|
|
1646
|
+
`Controller "${this.def.controllerClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
|
|
1647
|
+
);
|
|
1704
1648
|
return rt(async () => {
|
|
1705
|
-
const
|
|
1649
|
+
const s = new AbortController(), r = et(
|
|
1706
1650
|
this.def.captured,
|
|
1707
1651
|
t ?? {},
|
|
1708
1652
|
this.queryClient.getContext()
|
|
1709
|
-
)
|
|
1710
|
-
return
|
|
1653
|
+
);
|
|
1654
|
+
return await i.sendMutation(r, s.signal);
|
|
1711
1655
|
}, e);
|
|
1712
1656
|
}
|
|
1713
1657
|
}
|
|
1714
|
-
function
|
|
1715
|
-
return typeof
|
|
1658
|
+
function hn(n) {
|
|
1659
|
+
return typeof n == "string" ? n : T(n).typenameValue;
|
|
1716
1660
|
}
|
|
1717
|
-
function Z(
|
|
1718
|
-
if (
|
|
1719
|
-
for (const [
|
|
1720
|
-
const r =
|
|
1661
|
+
function Z(n, t, e) {
|
|
1662
|
+
if (n)
|
|
1663
|
+
for (const [i, s] of n) {
|
|
1664
|
+
const r = hn(i);
|
|
1721
1665
|
r !== void 0 && e.applyMutationEvent({ type: t, typename: r, data: s });
|
|
1722
1666
|
}
|
|
1723
1667
|
}
|
|
1724
|
-
const
|
|
1725
|
-
function
|
|
1726
|
-
return { field:
|
|
1668
|
+
const se = "__eventSource";
|
|
1669
|
+
function re(n) {
|
|
1670
|
+
return { field: n, segments: n.indexOf(".") !== -1 ? n.split(".") : void 0 };
|
|
1727
1671
|
}
|
|
1728
|
-
function
|
|
1729
|
-
return
|
|
1672
|
+
function yn(n) {
|
|
1673
|
+
return n.map(re);
|
|
1730
1674
|
}
|
|
1731
|
-
function
|
|
1732
|
-
if (t.segments === void 0) return
|
|
1733
|
-
let e =
|
|
1734
|
-
for (const
|
|
1675
|
+
function pn(n, t) {
|
|
1676
|
+
if (t.segments === void 0) return n[t.field];
|
|
1677
|
+
let e = n;
|
|
1678
|
+
for (const i of t.segments) {
|
|
1735
1679
|
if (e == null) return;
|
|
1736
|
-
e = e[
|
|
1680
|
+
e = e[i];
|
|
1737
1681
|
}
|
|
1738
1682
|
return e;
|
|
1739
1683
|
}
|
|
1740
|
-
function
|
|
1684
|
+
function oe(n, t) {
|
|
1741
1685
|
const e = [];
|
|
1742
|
-
for (let
|
|
1743
|
-
const s = t[
|
|
1686
|
+
for (let i = 0; i < t.length; i++) {
|
|
1687
|
+
const s = t[i], r = pn(n, s);
|
|
1744
1688
|
if (r === void 0) return;
|
|
1745
1689
|
e.push(s.field, r);
|
|
1746
1690
|
}
|
|
1747
|
-
return
|
|
1691
|
+
return D(e);
|
|
1748
1692
|
}
|
|
1749
|
-
function
|
|
1750
|
-
if (
|
|
1693
|
+
function gn(n, t) {
|
|
1694
|
+
if (n === void 0) return;
|
|
1751
1695
|
const e = /* @__PURE__ */ new Map();
|
|
1752
|
-
for (const [
|
|
1696
|
+
for (const [i, s] of n) {
|
|
1753
1697
|
const r = s.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
|
|
1754
1698
|
let a = !0;
|
|
1755
1699
|
for (const [c, f] of r) {
|
|
1756
|
-
let
|
|
1757
|
-
if (
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1700
|
+
let d;
|
|
1701
|
+
if (Pt(f)) {
|
|
1702
|
+
const u = Lt(f);
|
|
1703
|
+
d = ut(u, t);
|
|
1760
1704
|
} else
|
|
1761
|
-
|
|
1762
|
-
if (
|
|
1705
|
+
d = f;
|
|
1706
|
+
if (d === void 0) {
|
|
1763
1707
|
a = !1;
|
|
1764
1708
|
break;
|
|
1765
1709
|
}
|
|
1766
|
-
o.push(c,
|
|
1710
|
+
o.push(c, d);
|
|
1767
1711
|
}
|
|
1768
|
-
a && e.set(
|
|
1712
|
+
a && e.set(i, D(o));
|
|
1769
1713
|
}
|
|
1770
1714
|
return e.size > 0 ? e : void 0;
|
|
1771
1715
|
}
|
|
1772
|
-
function
|
|
1773
|
-
const e =
|
|
1716
|
+
function Rt(n, t) {
|
|
1717
|
+
const e = n.get(t);
|
|
1774
1718
|
if (e !== void 0)
|
|
1775
|
-
return e.map(([
|
|
1719
|
+
return e.map(([i]) => i).sort();
|
|
1776
1720
|
}
|
|
1777
|
-
class
|
|
1721
|
+
class vn {
|
|
1778
1722
|
fields;
|
|
1779
1723
|
fieldPaths;
|
|
1780
1724
|
_bindings = /* @__PURE__ */ new Map();
|
|
1781
1725
|
constructor(t) {
|
|
1782
|
-
this.fields = t, this.fieldPaths = t.map(
|
|
1726
|
+
this.fields = t, this.fieldPaths = t.map(re);
|
|
1783
1727
|
}
|
|
1784
1728
|
register(t, e) {
|
|
1785
|
-
let
|
|
1786
|
-
|
|
1729
|
+
let i = this._bindings.get(t);
|
|
1730
|
+
i === void 0 && (i = /* @__PURE__ */ new Set(), this._bindings.set(t, i)), i.add(e);
|
|
1787
1731
|
}
|
|
1788
1732
|
unregister(t, e) {
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1733
|
+
const i = this._bindings.get(t);
|
|
1734
|
+
i !== void 0 && (i.delete(e), i.size === 0 && this._bindings.delete(t));
|
|
1791
1735
|
}
|
|
1792
1736
|
getMatching(t) {
|
|
1793
1737
|
return this._bindings.get(t);
|
|
@@ -1796,67 +1740,67 @@ class pi {
|
|
|
1796
1740
|
return this._bindings.size === 0;
|
|
1797
1741
|
}
|
|
1798
1742
|
}
|
|
1799
|
-
function St(
|
|
1800
|
-
return
|
|
1743
|
+
function St(n) {
|
|
1744
|
+
return D(n);
|
|
1801
1745
|
}
|
|
1802
|
-
class
|
|
1746
|
+
class _n {
|
|
1803
1747
|
_groups = /* @__PURE__ */ new Map();
|
|
1804
1748
|
getOrCreateGroup(t) {
|
|
1805
1749
|
const e = St(t);
|
|
1806
|
-
let
|
|
1807
|
-
return
|
|
1750
|
+
let i = this._groups.get(e);
|
|
1751
|
+
return i === void 0 && (i = new vn(t), this._groups.set(e, i)), i;
|
|
1808
1752
|
}
|
|
1809
|
-
register(t, e,
|
|
1810
|
-
this.getOrCreateGroup(e).register(t,
|
|
1753
|
+
register(t, e, i) {
|
|
1754
|
+
this.getOrCreateGroup(e).register(t, i);
|
|
1811
1755
|
}
|
|
1812
|
-
unregister(t, e,
|
|
1756
|
+
unregister(t, e, i) {
|
|
1813
1757
|
const s = St(e), r = this._groups.get(s);
|
|
1814
|
-
r !== void 0 && (r.unregister(t,
|
|
1758
|
+
r !== void 0 && (r.unregister(t, i), r.isEmpty && this._groups.delete(s));
|
|
1815
1759
|
}
|
|
1816
1760
|
registerBinding(t, e) {
|
|
1817
|
-
const
|
|
1818
|
-
if (
|
|
1819
|
-
const s =
|
|
1820
|
-
s !== void 0 && this.register(
|
|
1761
|
+
const i = t._constraintHashes.get(e);
|
|
1762
|
+
if (i === void 0) return;
|
|
1763
|
+
const s = Rt(t._constraintFieldRefs, e);
|
|
1764
|
+
s !== void 0 && this.register(i, s, t);
|
|
1821
1765
|
}
|
|
1822
1766
|
unregisterBinding(t, e) {
|
|
1823
|
-
const
|
|
1824
|
-
if (
|
|
1825
|
-
const s =
|
|
1826
|
-
s !== void 0 && this.unregister(
|
|
1767
|
+
const i = t._constraintHashes.get(e);
|
|
1768
|
+
if (i === void 0) return;
|
|
1769
|
+
const s = Rt(t._constraintFieldRefs, e);
|
|
1770
|
+
s !== void 0 && this.unregister(i, s, t);
|
|
1827
1771
|
}
|
|
1828
|
-
routeEvent(t, e,
|
|
1772
|
+
routeEvent(t, e, i, s, r, o) {
|
|
1829
1773
|
for (const a of this._groups.values()) {
|
|
1830
|
-
const c =
|
|
1774
|
+
const c = oe(e, a.fieldPaths);
|
|
1831
1775
|
if (c === void 0) continue;
|
|
1832
1776
|
const f = a.getMatching(c);
|
|
1833
1777
|
if (f !== void 0)
|
|
1834
|
-
for (const
|
|
1835
|
-
|
|
1778
|
+
for (const d of f)
|
|
1779
|
+
d.onEvent(t, i, s, r, o);
|
|
1836
1780
|
}
|
|
1837
1781
|
}
|
|
1838
1782
|
}
|
|
1839
|
-
function
|
|
1783
|
+
function At(n) {
|
|
1840
1784
|
const t = /* @__PURE__ */ new Set();
|
|
1841
|
-
for (const e of
|
|
1785
|
+
for (const e of n)
|
|
1842
1786
|
if (typeof e == "object" && e !== null) {
|
|
1843
|
-
const
|
|
1844
|
-
|
|
1787
|
+
const i = k(e);
|
|
1788
|
+
i !== void 0 && t.add(i);
|
|
1845
1789
|
}
|
|
1846
1790
|
return t;
|
|
1847
1791
|
}
|
|
1848
|
-
class
|
|
1792
|
+
class ae {
|
|
1849
1793
|
_queryClient;
|
|
1850
1794
|
_parent;
|
|
1851
1795
|
_constraintHashes;
|
|
1852
1796
|
_entityDefsByTypename;
|
|
1853
1797
|
_constraintFieldRefs;
|
|
1854
1798
|
instance;
|
|
1855
|
-
constructor(t, e,
|
|
1856
|
-
this._queryClient =
|
|
1799
|
+
constructor(t, e, i, s, r, o) {
|
|
1800
|
+
this._queryClient = i, this._parent = s, this._constraintHashes = r, this._constraintFieldRefs = e, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
|
|
1857
1801
|
for (const a of t)
|
|
1858
1802
|
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1859
|
-
|
|
1803
|
+
J.add(this);
|
|
1860
1804
|
}
|
|
1861
1805
|
getValue() {
|
|
1862
1806
|
return this.instance.getValue();
|
|
@@ -1875,11 +1819,11 @@ class ce {
|
|
|
1875
1819
|
* root level by applyMutationEvent. The binding just checks if the entity's
|
|
1876
1820
|
* current data satisfies this binding's shape and forwards to the instance.
|
|
1877
1821
|
*/
|
|
1878
|
-
onEvent(t, e,
|
|
1822
|
+
onEvent(t, e, i, s, r) {
|
|
1879
1823
|
const o = this._entityDefsByTypename.get(t);
|
|
1880
1824
|
if (o === void 0) return;
|
|
1881
1825
|
const a = this._queryClient.entityMap.getEntity(e);
|
|
1882
|
-
if (
|
|
1826
|
+
if (i === "delete") {
|
|
1883
1827
|
const f = a !== void 0 ? a.getProxy(o) : r;
|
|
1884
1828
|
f !== void 0 && (this.instance.onEvent(e, f, r ?? a?.data ?? {}, "delete"), s?.());
|
|
1885
1829
|
return;
|
|
@@ -1887,7 +1831,7 @@ class ce {
|
|
|
1887
1831
|
if (a === void 0 || !a.satisfiesDef(o)) return;
|
|
1888
1832
|
s?.();
|
|
1889
1833
|
const c = a.getProxy(o);
|
|
1890
|
-
this.instance.onEvent(e, c, a.data,
|
|
1834
|
+
this.instance.onEvent(e, c, a.data, i);
|
|
1891
1835
|
}
|
|
1892
1836
|
destroy() {
|
|
1893
1837
|
this._queryClient.unregisterLiveCollection(this);
|
|
@@ -1895,44 +1839,44 @@ class ce {
|
|
|
1895
1839
|
e !== -1 && t.splice(e, 1);
|
|
1896
1840
|
}
|
|
1897
1841
|
}
|
|
1898
|
-
class
|
|
1842
|
+
class mn {
|
|
1899
1843
|
_notifier;
|
|
1900
1844
|
_items;
|
|
1901
1845
|
_keys;
|
|
1902
1846
|
_outputSignal;
|
|
1903
1847
|
_queryClient;
|
|
1904
1848
|
_parent;
|
|
1905
|
-
constructor(t, e,
|
|
1906
|
-
this._notifier = at(), this._items =
|
|
1849
|
+
constructor(t, e, i, s, r, o) {
|
|
1850
|
+
this._notifier = at(), this._items = i, this._keys = At(i), this._queryClient = t, this._parent = e;
|
|
1907
1851
|
const a = s !== void 0 && r !== void 0, c = o !== void 0;
|
|
1908
|
-
(a || c) && (this._outputSignal =
|
|
1852
|
+
(a || c) && (this._outputSignal = _e(() => {
|
|
1909
1853
|
this._notifier.consume();
|
|
1910
1854
|
let f = this._items;
|
|
1911
1855
|
if (a) {
|
|
1912
|
-
const
|
|
1913
|
-
for (const
|
|
1914
|
-
if (typeof
|
|
1915
|
-
|
|
1856
|
+
const d = [];
|
|
1857
|
+
for (const u of f) {
|
|
1858
|
+
if (typeof u != "object" || u === null) {
|
|
1859
|
+
d.push(u);
|
|
1916
1860
|
continue;
|
|
1917
1861
|
}
|
|
1918
|
-
const y =
|
|
1862
|
+
const y = k(u);
|
|
1919
1863
|
if (y === void 0) {
|
|
1920
|
-
|
|
1864
|
+
d.push(u);
|
|
1921
1865
|
continue;
|
|
1922
1866
|
}
|
|
1923
1867
|
const v = t.entityMap.getEntity(y);
|
|
1924
1868
|
if (v === void 0) {
|
|
1925
|
-
|
|
1869
|
+
d.push(u);
|
|
1926
1870
|
continue;
|
|
1927
1871
|
}
|
|
1928
|
-
v.consume(),
|
|
1872
|
+
v.consume(), oe(v.data, s) === r && d.push(u);
|
|
1929
1873
|
}
|
|
1930
|
-
f =
|
|
1874
|
+
f = d;
|
|
1931
1875
|
}
|
|
1932
1876
|
return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
|
|
1933
1877
|
}));
|
|
1934
1878
|
}
|
|
1935
|
-
onEvent(t, e,
|
|
1879
|
+
onEvent(t, e, i, s) {
|
|
1936
1880
|
switch (s) {
|
|
1937
1881
|
case "create":
|
|
1938
1882
|
this.add(t, e);
|
|
@@ -1954,26 +1898,26 @@ class vi {
|
|
|
1954
1898
|
add(t, e) {
|
|
1955
1899
|
if (this._keys.has(t)) return !1;
|
|
1956
1900
|
this._keys.add(t), this._items.push(e);
|
|
1957
|
-
const
|
|
1958
|
-
return
|
|
1901
|
+
const i = this._queryClient.entityMap.getEntity(t);
|
|
1902
|
+
return i !== void 0 && (this._parent.addChildRef(i), i.save()), this._notifier.notify(), !0;
|
|
1959
1903
|
}
|
|
1960
1904
|
remove(t) {
|
|
1961
1905
|
if (!this._keys.has(t)) return !1;
|
|
1962
1906
|
this._keys.delete(t);
|
|
1963
1907
|
const e = this._findIndex(t);
|
|
1964
1908
|
e !== -1 && this._items.splice(e, 1);
|
|
1965
|
-
const
|
|
1966
|
-
return
|
|
1909
|
+
const i = this._queryClient.entityMap.getEntity(t);
|
|
1910
|
+
return i !== void 0 && this._parent.removeChildRef(i), this._notifier.notify(), !0;
|
|
1967
1911
|
}
|
|
1968
1912
|
has(t) {
|
|
1969
1913
|
return this._keys.has(t);
|
|
1970
1914
|
}
|
|
1971
1915
|
reset(t) {
|
|
1972
|
-
const e = this._items,
|
|
1973
|
-
this._items =
|
|
1974
|
-
for (const s of
|
|
1916
|
+
const e = this._items, i = Array.isArray(t) ? t : [];
|
|
1917
|
+
this._items = i, this._keys = At(i);
|
|
1918
|
+
for (const s of i)
|
|
1975
1919
|
if (typeof s == "object" && s !== null) {
|
|
1976
|
-
const r =
|
|
1920
|
+
const r = k(s);
|
|
1977
1921
|
if (r !== void 0) {
|
|
1978
1922
|
const o = this._queryClient.entityMap.getEntity(r);
|
|
1979
1923
|
o !== void 0 && this._parent.addChildRef(o);
|
|
@@ -1981,7 +1925,7 @@ class vi {
|
|
|
1981
1925
|
}
|
|
1982
1926
|
for (const s of e)
|
|
1983
1927
|
if (typeof s == "object" && s !== null) {
|
|
1984
|
-
const r =
|
|
1928
|
+
const r = k(s);
|
|
1985
1929
|
if (r !== void 0) {
|
|
1986
1930
|
const o = this._queryClient.entityMap.getEntity(r);
|
|
1987
1931
|
o !== void 0 && this._parent.removeChildRef(o);
|
|
@@ -1993,20 +1937,20 @@ class vi {
|
|
|
1993
1937
|
if (Array.isArray(t))
|
|
1994
1938
|
for (const e of t) {
|
|
1995
1939
|
if (typeof e != "object" || e === null) continue;
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1940
|
+
const i = k(e);
|
|
1941
|
+
i !== void 0 && this.add(i, e);
|
|
1998
1942
|
}
|
|
1999
1943
|
}
|
|
2000
1944
|
_findIndex(t) {
|
|
2001
1945
|
for (let e = 0; e < this._items.length; e++) {
|
|
2002
|
-
const
|
|
2003
|
-
if (typeof
|
|
1946
|
+
const i = this._items[e];
|
|
1947
|
+
if (typeof i == "object" && i !== null && k(i) === t)
|
|
2004
1948
|
return e;
|
|
2005
1949
|
}
|
|
2006
1950
|
return -1;
|
|
2007
1951
|
}
|
|
2008
1952
|
}
|
|
2009
|
-
class
|
|
1953
|
+
class wn {
|
|
2010
1954
|
_notifier;
|
|
2011
1955
|
_value;
|
|
2012
1956
|
_createdKeys;
|
|
@@ -2016,21 +1960,21 @@ class _i {
|
|
|
2016
1960
|
_onCreate;
|
|
2017
1961
|
_onUpdate;
|
|
2018
1962
|
_onDelete;
|
|
2019
|
-
constructor(t, e,
|
|
2020
|
-
this._notifier = at(), this._value =
|
|
1963
|
+
constructor(t, e, i, s, r, o) {
|
|
1964
|
+
this._notifier = at(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = e, this._onCreate = s, this._onUpdate = r, this._onDelete = o;
|
|
2021
1965
|
}
|
|
2022
|
-
onEvent(t, e,
|
|
1966
|
+
onEvent(t, e, i, s) {
|
|
2023
1967
|
switch (s) {
|
|
2024
1968
|
case "create":
|
|
2025
1969
|
if (this._createdKeys.has(t)) return;
|
|
2026
1970
|
this._createdKeys.add(t), this._value = this._onCreate(this._value, e);
|
|
2027
1971
|
break;
|
|
2028
1972
|
case "update":
|
|
2029
|
-
this._value = this._onUpdate(this._value, e ??
|
|
1973
|
+
this._value = this._onUpdate(this._value, e ?? i);
|
|
2030
1974
|
break;
|
|
2031
1975
|
case "delete":
|
|
2032
1976
|
if (this._deletedKeys.has(t)) return;
|
|
2033
|
-
this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ??
|
|
1977
|
+
this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ?? i);
|
|
2034
1978
|
break;
|
|
2035
1979
|
}
|
|
2036
1980
|
this._notifier.notify();
|
|
@@ -2047,48 +1991,48 @@ class _i {
|
|
|
2047
1991
|
append(t) {
|
|
2048
1992
|
}
|
|
2049
1993
|
}
|
|
2050
|
-
function
|
|
2051
|
-
let r =
|
|
1994
|
+
function ce(n, t, e, i, s) {
|
|
1995
|
+
let r = n.constraintFieldRefs;
|
|
2052
1996
|
if (r === void 0) {
|
|
2053
1997
|
r = /* @__PURE__ */ new Map();
|
|
2054
|
-
for (const f of
|
|
2055
|
-
const
|
|
2056
|
-
|
|
1998
|
+
for (const f of n.entityDefs) {
|
|
1999
|
+
const d = f.typenameValue;
|
|
2000
|
+
d !== void 0 && r.set(d, [[se, e.key]]);
|
|
2057
2001
|
}
|
|
2058
2002
|
}
|
|
2059
|
-
const o =
|
|
2003
|
+
const o = gn(r, i) ?? /* @__PURE__ */ new Map();
|
|
2060
2004
|
let a;
|
|
2061
|
-
if (
|
|
2062
|
-
let f,
|
|
2063
|
-
if (
|
|
2064
|
-
for (const [
|
|
2065
|
-
const y = o.get(
|
|
2005
|
+
if (n.type === ct.Array) {
|
|
2006
|
+
let f, d;
|
|
2007
|
+
if (n.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
|
|
2008
|
+
for (const [u] of n.constraintFieldRefs) {
|
|
2009
|
+
const y = o.get(u);
|
|
2066
2010
|
if (y !== void 0) {
|
|
2067
|
-
|
|
2068
|
-
const v =
|
|
2069
|
-
v !== void 0 && (f =
|
|
2011
|
+
d = y;
|
|
2012
|
+
const v = n.constraintFieldRefs.get(u);
|
|
2013
|
+
v !== void 0 && (f = yn(v.map(([p]) => p)));
|
|
2070
2014
|
break;
|
|
2071
2015
|
}
|
|
2072
2016
|
}
|
|
2073
|
-
a = new
|
|
2017
|
+
a = new mn(
|
|
2074
2018
|
s,
|
|
2075
2019
|
e,
|
|
2076
2020
|
Array.isArray(t) ? t : [],
|
|
2077
2021
|
f,
|
|
2078
|
-
|
|
2079
|
-
|
|
2022
|
+
d,
|
|
2023
|
+
n.sort
|
|
2080
2024
|
);
|
|
2081
2025
|
} else
|
|
2082
|
-
a = new
|
|
2026
|
+
a = new wn(
|
|
2083
2027
|
s,
|
|
2084
2028
|
e,
|
|
2085
2029
|
t,
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2030
|
+
n.onCreate,
|
|
2031
|
+
n.onUpdate,
|
|
2032
|
+
n.onDelete
|
|
2089
2033
|
);
|
|
2090
|
-
const c = new
|
|
2091
|
-
|
|
2034
|
+
const c = new ae(
|
|
2035
|
+
n.entityDefs,
|
|
2092
2036
|
r,
|
|
2093
2037
|
s,
|
|
2094
2038
|
e,
|
|
@@ -2097,85 +2041,85 @@ function fe(i, t, e, n, s) {
|
|
|
2097
2041
|
);
|
|
2098
2042
|
return e.liveCollections.push(c), s.registerLiveCollection(c), c;
|
|
2099
2043
|
}
|
|
2100
|
-
const
|
|
2101
|
-
function tt(
|
|
2102
|
-
const s =
|
|
2044
|
+
const fe = Object.entries, ue = Object.prototype;
|
|
2045
|
+
function tt(n, t, e, i = !1) {
|
|
2046
|
+
const s = n.queryClient;
|
|
2103
2047
|
s.currentParseId++;
|
|
2104
|
-
const r =
|
|
2105
|
-
return { data:
|
|
2048
|
+
const r = n.seen, o = /* @__PURE__ */ new Map();
|
|
2049
|
+
return { data: U(t, r, s, e, o, i), entityRefs: o };
|
|
2106
2050
|
}
|
|
2107
|
-
function
|
|
2108
|
-
if (typeof
|
|
2109
|
-
const o = t.get(
|
|
2051
|
+
function U(n, t, e, i, s, r) {
|
|
2052
|
+
if (typeof n != "object" || n === null) return n;
|
|
2053
|
+
const o = t.get(n);
|
|
2110
2054
|
if (o !== void 0)
|
|
2111
|
-
return
|
|
2112
|
-
if (Array.isArray(
|
|
2113
|
-
for (let a = 0; a <
|
|
2114
|
-
const c =
|
|
2115
|
-
typeof c == "object" && c !== null && !(c instanceof
|
|
2055
|
+
return En(o, t, e, i, s, r);
|
|
2056
|
+
if (Array.isArray(n)) {
|
|
2057
|
+
for (let a = 0; a < n.length; a++) {
|
|
2058
|
+
const c = n[a];
|
|
2059
|
+
typeof c == "object" && c !== null && !(c instanceof q) && !x.has(c) && (n[a] = U(c, t, e, i, s, r));
|
|
2116
2060
|
}
|
|
2117
|
-
return
|
|
2061
|
+
return n;
|
|
2118
2062
|
}
|
|
2119
|
-
if (Object.getPrototypeOf(
|
|
2120
|
-
const a =
|
|
2063
|
+
if (Object.getPrototypeOf(n) === ue && !x.has(n)) {
|
|
2064
|
+
const a = n;
|
|
2121
2065
|
for (const c of Object.keys(a)) {
|
|
2122
2066
|
const f = a[c];
|
|
2123
|
-
typeof f == "object" && f !== null && !(f instanceof
|
|
2067
|
+
typeof f == "object" && f !== null && !(f instanceof q) && !x.has(f) && (a[c] = U(f, t, e, i, s, r));
|
|
2124
2068
|
}
|
|
2125
2069
|
}
|
|
2126
|
-
return
|
|
2070
|
+
return n;
|
|
2127
2071
|
}
|
|
2128
|
-
function le(
|
|
2129
|
-
return typeof
|
|
2072
|
+
function le(n) {
|
|
2073
|
+
return typeof n == "object" && n !== null && !(n instanceof q) && !x.has(n);
|
|
2130
2074
|
}
|
|
2131
|
-
function
|
|
2132
|
-
const { key: o, data: a, shape: c, rawKeys: f } =
|
|
2133
|
-
if (v ? (
|
|
2134
|
-
|
|
2075
|
+
function En(n, t, e, i, s, r) {
|
|
2076
|
+
const { key: o, data: a, shape: c, rawKeys: f } = n, d = c.shape, u = e.prepareEntity(o, a, c), y = u.data, v = y !== a, p = v && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
2077
|
+
if (v ? (de(
|
|
2078
|
+
d,
|
|
2135
2079
|
a,
|
|
2136
2080
|
y,
|
|
2137
2081
|
f,
|
|
2138
|
-
|
|
2082
|
+
u,
|
|
2139
2083
|
y,
|
|
2140
2084
|
t,
|
|
2141
2085
|
e,
|
|
2142
|
-
|
|
2086
|
+
i,
|
|
2143
2087
|
p,
|
|
2144
2088
|
r
|
|
2145
|
-
),
|
|
2146
|
-
for (const
|
|
2147
|
-
const
|
|
2148
|
-
if (Array.isArray(
|
|
2149
|
-
for (const
|
|
2150
|
-
if (typeof
|
|
2151
|
-
const
|
|
2152
|
-
if (
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2089
|
+
), u.notify()) : he(d, a, u, a, t, e, i, p, r), r && u.liveCollections.length > 0)
|
|
2090
|
+
for (const w of u.liveCollections) {
|
|
2091
|
+
const I = w.instance.getRawValue();
|
|
2092
|
+
if (Array.isArray(I))
|
|
2093
|
+
for (const O of I) {
|
|
2094
|
+
if (typeof O != "object" || O === null) continue;
|
|
2095
|
+
const K = x.get(O);
|
|
2096
|
+
if (K === void 0) continue;
|
|
2097
|
+
const R = e.entityMap.getEntity(K);
|
|
2098
|
+
R !== void 0 && p.set(R, (p.get(R) ?? 0) + 1);
|
|
2155
2099
|
}
|
|
2156
2100
|
}
|
|
2157
|
-
|
|
2158
|
-
const g =
|
|
2159
|
-
return s.set(
|
|
2160
|
-
}
|
|
2161
|
-
function
|
|
2162
|
-
for (const [
|
|
2163
|
-
if (!(
|
|
2164
|
-
if (le(t[
|
|
2165
|
-
const v = e[
|
|
2166
|
-
v instanceof
|
|
2101
|
+
u.setChildRefs(p.size > 0 ? p : void 0, i);
|
|
2102
|
+
const g = u.getProxy(c);
|
|
2103
|
+
return s.set(u, (s.get(u) ?? 0) + 1), g;
|
|
2104
|
+
}
|
|
2105
|
+
function de(n, t, e, i, s, r, o, a, c, f, d) {
|
|
2106
|
+
for (const [u, y] of fe(n))
|
|
2107
|
+
if (!(i !== void 0 && !i.has(u)))
|
|
2108
|
+
if (le(t[u]) && (t[u] = U(t[u], o, a, c, f, d)), y instanceof _ && y._liveConfig !== void 0) {
|
|
2109
|
+
const v = e[u];
|
|
2110
|
+
v instanceof ae ? d ? v.append(t[u]) : v.reset(t[u]) : e[u] = ce(
|
|
2167
2111
|
y._liveConfig,
|
|
2168
|
-
t[
|
|
2112
|
+
t[u],
|
|
2169
2113
|
s,
|
|
2170
2114
|
r,
|
|
2171
2115
|
a
|
|
2172
2116
|
);
|
|
2173
2117
|
} else {
|
|
2174
|
-
const v = t[
|
|
2118
|
+
const v = t[u], p = e[u];
|
|
2175
2119
|
if (ot(v) && ot(p)) {
|
|
2176
2120
|
const g = y instanceof _ && y.shape !== void 0 ? y.shape : void 0;
|
|
2177
2121
|
if (g !== void 0)
|
|
2178
|
-
|
|
2122
|
+
de(
|
|
2179
2123
|
g,
|
|
2180
2124
|
v,
|
|
2181
2125
|
p,
|
|
@@ -2186,58 +2130,55 @@ function he(i, t, e, n, s, r, o, a, c, f, l) {
|
|
|
2186
2130
|
a,
|
|
2187
2131
|
c,
|
|
2188
2132
|
f,
|
|
2189
|
-
|
|
2133
|
+
d
|
|
2190
2134
|
);
|
|
2191
2135
|
else
|
|
2192
|
-
for (const
|
|
2193
|
-
p[
|
|
2194
|
-
e[
|
|
2136
|
+
for (const w of Object.keys(v))
|
|
2137
|
+
p[w] = v[w];
|
|
2138
|
+
e[u] = p;
|
|
2195
2139
|
} else
|
|
2196
|
-
e[
|
|
2140
|
+
e[u] = v;
|
|
2197
2141
|
}
|
|
2198
2142
|
}
|
|
2199
|
-
function
|
|
2200
|
-
for (const [f,
|
|
2143
|
+
function he(n, t, e, i, s, r, o, a, c) {
|
|
2144
|
+
for (const [f, d] of fe(n))
|
|
2201
2145
|
if (f in t)
|
|
2202
|
-
if (le(t[f]) && (t[f] =
|
|
2203
|
-
t[f] =
|
|
2204
|
-
|
|
2146
|
+
if (le(t[f]) && (t[f] = U(t[f], s, r, o, a, c)), d instanceof _ && d._liveConfig !== void 0)
|
|
2147
|
+
t[f] = ce(
|
|
2148
|
+
d._liveConfig,
|
|
2205
2149
|
t[f],
|
|
2206
2150
|
e,
|
|
2207
|
-
|
|
2151
|
+
i,
|
|
2208
2152
|
r
|
|
2209
2153
|
);
|
|
2210
2154
|
else {
|
|
2211
|
-
const
|
|
2212
|
-
if (ot(
|
|
2213
|
-
const y =
|
|
2214
|
-
y !== void 0 &&
|
|
2155
|
+
const u = t[f];
|
|
2156
|
+
if (ot(u)) {
|
|
2157
|
+
const y = d instanceof _ && d.shape !== void 0 ? d.shape : void 0;
|
|
2158
|
+
y !== void 0 && he(y, u, e, i, s, r, o, a, c);
|
|
2215
2159
|
}
|
|
2216
2160
|
}
|
|
2217
2161
|
}
|
|
2218
|
-
function ot(
|
|
2219
|
-
return typeof
|
|
2162
|
+
function ot(n) {
|
|
2163
|
+
return typeof n == "object" && n !== null && !Array.isArray(n) && Object.getPrototypeOf(n) === ue && !x.has(n);
|
|
2220
2164
|
}
|
|
2221
|
-
function
|
|
2222
|
-
if (
|
|
2223
|
-
return typeof
|
|
2165
|
+
function Fn(n) {
|
|
2166
|
+
if (n !== void 0)
|
|
2167
|
+
return typeof n == "string" ? n : typeof n == "function" ? n() : n.value;
|
|
2224
2168
|
}
|
|
2225
|
-
function
|
|
2226
|
-
return
|
|
2169
|
+
function Cn(n) {
|
|
2170
|
+
return me(n);
|
|
2227
2171
|
}
|
|
2228
|
-
function
|
|
2229
|
-
if (
|
|
2172
|
+
function Dt(n) {
|
|
2173
|
+
if (n === void 0)
|
|
2230
2174
|
return;
|
|
2231
2175
|
const t = {};
|
|
2232
|
-
for (const [e,
|
|
2233
|
-
|
|
2176
|
+
for (const [e, i] of Object.entries(n))
|
|
2177
|
+
Cn(i) ? t[e] = i.value : t[e] = i;
|
|
2234
2178
|
return t;
|
|
2235
2179
|
}
|
|
2236
|
-
const vt = (
|
|
2237
|
-
class
|
|
2238
|
-
constructor(t, e = { fetch, log: console }, n, s) {
|
|
2239
|
-
this.context = e, this.isServer = typeof window > "u", this.store = t, this.gcManager = s ?? (this.isServer ? new xe() : new Ce(this.handleEviction, this.context.evictionMultiplier)), this.networkManager = n ?? new ie(), this.entityMap = new oi((r, o, a) => this.store.saveEntity(r, o, a)), this.store.purgeStaleQueries?.();
|
|
2240
|
-
}
|
|
2180
|
+
const vt = (n, t) => D([n.statics.id, t]);
|
|
2181
|
+
class Tn {
|
|
2241
2182
|
entityMap;
|
|
2242
2183
|
queryInstances = /* @__PURE__ */ new Map();
|
|
2243
2184
|
mutationInstances = /* @__PURE__ */ new Map();
|
|
@@ -2246,9 +2187,53 @@ class Ai {
|
|
|
2246
2187
|
isServer;
|
|
2247
2188
|
store;
|
|
2248
2189
|
currentParseId = 0;
|
|
2190
|
+
context;
|
|
2249
2191
|
typenameRegistry = /* @__PURE__ */ new Map();
|
|
2250
2192
|
constraintRegistry = /* @__PURE__ */ new Map();
|
|
2251
2193
|
mergedDefCache = /* @__PURE__ */ new Map();
|
|
2194
|
+
controllers = /* @__PURE__ */ new Map();
|
|
2195
|
+
networkUnsubscribe;
|
|
2196
|
+
constructor(t = {}) {
|
|
2197
|
+
const {
|
|
2198
|
+
store: e = new Ce(new be()),
|
|
2199
|
+
log: i,
|
|
2200
|
+
evictionMultiplier: s,
|
|
2201
|
+
controllers: r,
|
|
2202
|
+
networkManager: o,
|
|
2203
|
+
gcManager: a,
|
|
2204
|
+
...c
|
|
2205
|
+
} = t;
|
|
2206
|
+
this.isServer = typeof window > "u", this.store = e, this.context = { ...c, log: i ?? console, evictionMultiplier: s }, this.gcManager = t.gcManager ?? (this.isServer ? new Re() : new Oe(this.handleEviction, s)), this.networkManager = t.networkManager ?? new ee(), this.entityMap = new fn((u, y, v) => this.store.saveEntity(u, y, v));
|
|
2207
|
+
for (const u of t.controllers ?? [])
|
|
2208
|
+
this.controllers.set(u.constructor, u), u.register(this);
|
|
2209
|
+
const f = this.networkManager.getOnlineSignal(), d = we(() => f.value);
|
|
2210
|
+
this.networkUnsubscribe = d.addListener(
|
|
2211
|
+
() => {
|
|
2212
|
+
const u = f.value;
|
|
2213
|
+
for (const y of this.controllers.values())
|
|
2214
|
+
y.onNetworkStatusChange?.(u);
|
|
2215
|
+
},
|
|
2216
|
+
{ skipInitial: !0 }
|
|
2217
|
+
), this.store.purgeStaleQueries?.();
|
|
2218
|
+
}
|
|
2219
|
+
/**
|
|
2220
|
+
* Returns the registered controller instance for the given controller class.
|
|
2221
|
+
* Throws if no controller of that class has been registered.
|
|
2222
|
+
*/
|
|
2223
|
+
getController(t) {
|
|
2224
|
+
let e = this.controllers.get(t);
|
|
2225
|
+
if (!e) {
|
|
2226
|
+
try {
|
|
2227
|
+
e = new t();
|
|
2228
|
+
} catch {
|
|
2229
|
+
throw new Error(
|
|
2230
|
+
`No controller registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, controllers: [new ${t.name}(...)] })`
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
this.controllers.set(t, e), e.register(this);
|
|
2234
|
+
}
|
|
2235
|
+
return e;
|
|
2236
|
+
}
|
|
2252
2237
|
getContext() {
|
|
2253
2238
|
return this.context;
|
|
2254
2239
|
}
|
|
@@ -2258,10 +2243,10 @@ class Ai {
|
|
|
2258
2243
|
registerEntityDef(t) {
|
|
2259
2244
|
const e = t.typenameValue;
|
|
2260
2245
|
if (e === void 0 || t._entityClass === void 0) return;
|
|
2261
|
-
const
|
|
2262
|
-
if (
|
|
2263
|
-
if (
|
|
2264
|
-
|
|
2246
|
+
const i = this.typenameRegistry.get(e);
|
|
2247
|
+
if (i !== void 0) {
|
|
2248
|
+
if (i.indexOf(t) !== -1) return;
|
|
2249
|
+
i.push(t), this.mergedDefCache.delete(e), this.getMergedDef(e);
|
|
2265
2250
|
} else
|
|
2266
2251
|
this.typenameRegistry.set(e, [t]);
|
|
2267
2252
|
}
|
|
@@ -2271,19 +2256,19 @@ class Ai {
|
|
|
2271
2256
|
getMergedDef(t) {
|
|
2272
2257
|
let e = this.mergedDefCache.get(t);
|
|
2273
2258
|
if (e !== void 0) return e;
|
|
2274
|
-
const
|
|
2275
|
-
if (
|
|
2276
|
-
return e = _.merge(
|
|
2259
|
+
const i = this.typenameRegistry.get(t);
|
|
2260
|
+
if (i !== void 0)
|
|
2261
|
+
return e = _.merge(i), this.mergedDefCache.set(t, e), e;
|
|
2277
2262
|
}
|
|
2278
|
-
saveQueryData(t, e,
|
|
2263
|
+
saveQueryData(t, e, i, s, r) {
|
|
2279
2264
|
const o = r !== void 0 && r.size > 0 ? new Set([...r.keys()].map((a) => a.key)) : void 0;
|
|
2280
|
-
this.store.saveQuery(t, e,
|
|
2265
|
+
this.store.saveQuery(t, e, i, s, o);
|
|
2281
2266
|
}
|
|
2282
2267
|
activateQuery(t) {
|
|
2283
|
-
const { def: e, queryKey:
|
|
2268
|
+
const { def: e, queryKey: i, storageKey: s, config: r } = t;
|
|
2284
2269
|
this.store.activateQuery(e, s);
|
|
2285
|
-
const o = r?.gcTime ??
|
|
2286
|
-
this.gcManager.cancel(
|
|
2270
|
+
const o = r?.gcTime ?? kt;
|
|
2271
|
+
this.gcManager.cancel(i, o);
|
|
2287
2272
|
}
|
|
2288
2273
|
loadCachedQuery(t, e) {
|
|
2289
2274
|
return this.store.loadQuery(t, e);
|
|
@@ -2293,9 +2278,9 @@ class Ai {
|
|
|
2293
2278
|
* that triggers fetches and prepopulates with cached data
|
|
2294
2279
|
*/
|
|
2295
2280
|
getQuery(t, e) {
|
|
2296
|
-
const
|
|
2297
|
-
let s = this.queryInstances.get(
|
|
2298
|
-
return s === void 0 && (s = new
|
|
2281
|
+
const i = vt(t, e);
|
|
2282
|
+
let s = this.queryInstances.get(i);
|
|
2283
|
+
return s === void 0 && (s = new ln(t, this, i, e), this.queryInstances.set(i, s)), s.relay;
|
|
2299
2284
|
}
|
|
2300
2285
|
/**
|
|
2301
2286
|
* Gets or creates a MutationResult for the given mutation definition.
|
|
@@ -2303,151 +2288,170 @@ class Ai {
|
|
|
2303
2288
|
*/
|
|
2304
2289
|
getMutation(t) {
|
|
2305
2290
|
const e = t.id;
|
|
2306
|
-
let
|
|
2307
|
-
return
|
|
2291
|
+
let i = this.mutationInstances.get(e);
|
|
2292
|
+
return i === void 0 && (i = new dn(t, this), this.mutationInstances.set(e, i)), i.task;
|
|
2308
2293
|
}
|
|
2309
2294
|
/**
|
|
2310
2295
|
* Parse data: validates, formats, produces parsed entity data objects.
|
|
2311
2296
|
* Does NOT touch the entity store. Call applyRefs() after to commit entities.
|
|
2312
2297
|
*/
|
|
2313
|
-
parseData(t, e,
|
|
2298
|
+
parseData(t, e, i) {
|
|
2314
2299
|
const s = this.context.log?.warn ?? (() => {
|
|
2315
2300
|
}), r = new st();
|
|
2316
|
-
return r.reset(this,
|
|
2301
|
+
return r.reset(this, i, s), { data: Jt(t, e, r), ctx: r };
|
|
2317
2302
|
}
|
|
2318
2303
|
/**
|
|
2319
2304
|
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
2320
2305
|
* updates EntityInstances, replaces parsed data with proxies, counts child
|
|
2321
2306
|
* refs. Returns the reified data and root-level entity refs.
|
|
2322
2307
|
*/
|
|
2323
|
-
applyRefs(t, e = !0,
|
|
2324
|
-
return tt(t.ctx, t.data, e,
|
|
2308
|
+
applyRefs(t, e = !0, i = !1) {
|
|
2309
|
+
return tt(t.ctx, t.data, e, i);
|
|
2325
2310
|
}
|
|
2326
2311
|
/**
|
|
2327
2312
|
* Parse and apply data as a root entity. For non-entity results, injects
|
|
2328
2313
|
* QUERY_ID onto the payload. Returns the root EntityInstance (created or
|
|
2329
2314
|
* found in the store by the standard entity pipeline).
|
|
2330
2315
|
*/
|
|
2331
|
-
parseAndApplyRootEntity(t, e,
|
|
2332
|
-
typeof
|
|
2333
|
-
const a = this.parseData(t,
|
|
2316
|
+
parseAndApplyRootEntity(t, e, i, s, r = !1, o) {
|
|
2317
|
+
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Ft] = e);
|
|
2318
|
+
const a = this.parseData(t, i, o), c = tt(a.ctx, a.data, s, r), f = x.get(c.data);
|
|
2334
2319
|
return this.entityMap.getEntity(f);
|
|
2335
2320
|
}
|
|
2336
|
-
prepareEntity(t, e,
|
|
2337
|
-
return this.registerEntityDef(
|
|
2321
|
+
prepareEntity(t, e, i) {
|
|
2322
|
+
return this.registerEntityDef(i), this.entityMap.getOrCreateEntity(t, e, i, this);
|
|
2338
2323
|
}
|
|
2339
2324
|
// ======================================================
|
|
2340
2325
|
// Mutation Events
|
|
2341
2326
|
// ======================================================
|
|
2342
2327
|
applyMutationEvent(t) {
|
|
2343
|
-
const { type: e, typename:
|
|
2328
|
+
const { type: e, typename: i } = t, s = this.getMergedDef(i);
|
|
2344
2329
|
if (s === void 0) return;
|
|
2345
2330
|
const r = s.idField;
|
|
2346
2331
|
if (r === void 0 || typeof r == "symbol") return;
|
|
2347
2332
|
const o = t.data, a = t.id !== void 0 ? t.id : e === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[r];
|
|
2348
2333
|
if (a === void 0) return;
|
|
2349
|
-
const c =
|
|
2334
|
+
const c = D([i, a]), f = t.__eventSource, d = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2350
2335
|
if (e === "delete") {
|
|
2351
|
-
const g =
|
|
2352
|
-
this.routeEvent(
|
|
2336
|
+
const g = u !== void 0 ? u.data : d;
|
|
2337
|
+
this.routeEvent(i, g, c, e, f, void 0, g);
|
|
2353
2338
|
return;
|
|
2354
2339
|
}
|
|
2355
2340
|
try {
|
|
2356
2341
|
const g = this.context.log?.warn ?? (() => {
|
|
2357
|
-
}),
|
|
2358
|
-
|
|
2342
|
+
}), w = new st();
|
|
2343
|
+
w.reset(
|
|
2359
2344
|
this,
|
|
2360
2345
|
void 0,
|
|
2361
2346
|
g,
|
|
2362
2347
|
/* isPartialEvent */
|
|
2363
2348
|
!0
|
|
2364
2349
|
);
|
|
2365
|
-
const
|
|
2366
|
-
tt(
|
|
2350
|
+
const I = Xe(d, s, w);
|
|
2351
|
+
tt(w, I, !0);
|
|
2367
2352
|
} catch (g) {
|
|
2368
|
-
if (this.context.log?.warn?.("Failed to apply mutation event", g),
|
|
2369
|
-
const
|
|
2370
|
-
|
|
2353
|
+
if (this.context.log?.warn?.("Failed to apply mutation event", g), u === void 0) {
|
|
2354
|
+
const w = this.entityMap.getEntity(c);
|
|
2355
|
+
w !== void 0 && w.evict();
|
|
2371
2356
|
}
|
|
2372
2357
|
return;
|
|
2373
2358
|
}
|
|
2374
2359
|
const y = this.entityMap.getEntity(c);
|
|
2375
2360
|
if (y === void 0) return;
|
|
2376
2361
|
this.entityMap.save(y);
|
|
2377
|
-
const v =
|
|
2362
|
+
const v = u === void 0;
|
|
2378
2363
|
let p = !1;
|
|
2379
|
-
this.routeEvent(
|
|
2364
|
+
this.routeEvent(i, y.data, c, e, f, () => {
|
|
2380
2365
|
p = !0;
|
|
2381
2366
|
}), v && !p && y.evict();
|
|
2382
2367
|
}
|
|
2383
2368
|
// ======================================================
|
|
2369
|
+
// Query Invalidation
|
|
2370
|
+
// ======================================================
|
|
2371
|
+
invalidateQueries(t) {
|
|
2372
|
+
for (const e of t) {
|
|
2373
|
+
const i = Array.isArray(e), s = i ? e[0] : e, r = i ? e[1] : void 0, a = V.for(s).statics.id;
|
|
2374
|
+
for (const [, c] of this.queryInstances)
|
|
2375
|
+
c.def.statics.id === a && (r === void 0 || xn(c.resolvedParams, r)) && c.markStale();
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
// ======================================================
|
|
2384
2379
|
// In-Memory GC
|
|
2385
2380
|
// ======================================================
|
|
2386
2381
|
handleEviction = (t, e) => {
|
|
2387
|
-
if (e ===
|
|
2382
|
+
if (e === z.Query) {
|
|
2388
2383
|
const s = this.queryInstances.get(t);
|
|
2389
2384
|
if (s === void 0) return;
|
|
2390
2385
|
s.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
2391
2386
|
return;
|
|
2392
2387
|
}
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2388
|
+
const i = this.entityMap.getEntity(t);
|
|
2389
|
+
i !== void 0 && i.evict();
|
|
2395
2390
|
};
|
|
2396
2391
|
// ======================================================
|
|
2397
|
-
// Constraint Registry (Live
|
|
2392
|
+
// Constraint Registry (Live Data)
|
|
2398
2393
|
// ======================================================
|
|
2399
2394
|
getOrCreateMatcher(t) {
|
|
2400
2395
|
let e = this.constraintRegistry.get(t);
|
|
2401
|
-
return e === void 0 && (e = new
|
|
2396
|
+
return e === void 0 && (e = new _n(), this.constraintRegistry.set(t, e)), e;
|
|
2402
2397
|
}
|
|
2403
2398
|
registerLiveCollection(t) {
|
|
2404
|
-
for (const [e,
|
|
2405
|
-
this.registerEntityDef(
|
|
2399
|
+
for (const [e, i] of t._entityDefsByTypename)
|
|
2400
|
+
this.registerEntityDef(i), this.getOrCreateMatcher(e).registerBinding(t, e);
|
|
2406
2401
|
}
|
|
2407
2402
|
unregisterLiveCollection(t) {
|
|
2408
2403
|
for (const e of t._entityDefsByTypename.keys()) {
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2404
|
+
const i = this.constraintRegistry.get(e);
|
|
2405
|
+
i !== void 0 && i.unregisterBinding(t, e);
|
|
2411
2406
|
}
|
|
2412
2407
|
}
|
|
2413
|
-
routeEvent(t, e,
|
|
2408
|
+
routeEvent(t, e, i, s, r, o, a) {
|
|
2414
2409
|
const c = this.constraintRegistry.get(t);
|
|
2415
2410
|
if (c === void 0) return;
|
|
2416
|
-
const f = r !== void 0 ? { ...e, [
|
|
2417
|
-
c.routeEvent(t, f,
|
|
2411
|
+
const f = r !== void 0 ? { ...e, [se]: r } : e;
|
|
2412
|
+
c.routeEvent(t, f, i, s, o, a);
|
|
2418
2413
|
}
|
|
2419
2414
|
destroy() {
|
|
2420
|
-
this.
|
|
2415
|
+
this.networkUnsubscribe?.(), this.gcManager.destroy(), this.networkManager.destroy();
|
|
2416
|
+
for (const t of this.controllers.values())
|
|
2417
|
+
t.destroy?.();
|
|
2418
|
+
this.controllers.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
|
|
2421
2419
|
}
|
|
2422
2420
|
}
|
|
2423
|
-
const
|
|
2421
|
+
const bn = Mt(void 0);
|
|
2422
|
+
function xn(n, t) {
|
|
2423
|
+
if (n === void 0) return !1;
|
|
2424
|
+
for (const e in t)
|
|
2425
|
+
if (n[e] !== t[e]) return !1;
|
|
2426
|
+
return !0;
|
|
2427
|
+
}
|
|
2424
2428
|
export {
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2429
|
+
Q as A,
|
|
2430
|
+
qt as E,
|
|
2431
|
+
Oe as G,
|
|
2432
|
+
j as L,
|
|
2433
|
+
l as M,
|
|
2434
|
+
ee as N,
|
|
2435
|
+
Ft as Q,
|
|
2436
|
+
B as R,
|
|
2433
2437
|
_ as V,
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2438
|
+
ct as a,
|
|
2439
|
+
In as b,
|
|
2440
|
+
L as c,
|
|
2441
|
+
Re as d,
|
|
2442
|
+
ne as e,
|
|
2443
|
+
Nn as f,
|
|
2444
|
+
Tn as g,
|
|
2445
|
+
bn as h,
|
|
2446
|
+
un as i,
|
|
2447
|
+
Dn as j,
|
|
2448
|
+
kn as k,
|
|
2449
|
+
jt as l,
|
|
2450
|
+
De as m,
|
|
2451
|
+
W as n,
|
|
2452
|
+
Fn as o,
|
|
2453
|
+
Mn as q,
|
|
2454
|
+
Gt as r,
|
|
2455
|
+
He as t
|
|
2452
2456
|
};
|
|
2453
|
-
//# sourceMappingURL=QueryClient-
|
|
2457
|
+
//# sourceMappingURL=QueryClient-YqnBxFy1.js.map
|