fetchium 0.0.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 +250 -0
- package/README.md +287 -0
- 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 +2 -0
- package/dist/cjs/development/index.js.map +1 -0
- 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/package.json +3 -0
- package/dist/cjs/development/react/index.js +2 -0
- package/dist/cjs/development/react/index.js.map +1 -0
- package/dist/cjs/development/rest/index.js +2 -0
- package/dist/cjs/development/rest/index.js.map +1 -0
- package/dist/cjs/development/shared-Ct5zKrt4.js +2 -0
- package/dist/cjs/development/shared-Ct5zKrt4.js.map +1 -0
- package/dist/cjs/development/stores/async.js +2 -0
- package/dist/cjs/development/stores/async.js.map +1 -0
- package/dist/cjs/development/stores/sync.js +2 -0
- package/dist/cjs/development/stores/sync.js.map +1 -0
- package/dist/cjs/development/subscriptions/polling.js +2 -0
- package/dist/cjs/development/subscriptions/polling.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 +2 -0
- package/dist/cjs/production/index.js.map +1 -0
- 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/package.json +3 -0
- package/dist/cjs/production/react/index.js +2 -0
- package/dist/cjs/production/react/index.js.map +1 -0
- package/dist/cjs/production/rest/index.js +2 -0
- package/dist/cjs/production/rest/index.js.map +1 -0
- package/dist/cjs/production/shared-Ct5zKrt4.js +2 -0
- package/dist/cjs/production/shared-Ct5zKrt4.js.map +1 -0
- package/dist/cjs/production/stores/async.js +2 -0
- package/dist/cjs/production/stores/async.js.map +1 -0
- package/dist/cjs/production/stores/sync.js +2 -0
- package/dist/cjs/production/stores/sync.js.map +1 -0
- package/dist/cjs/production/subscriptions/polling.js +2 -0
- package/dist/cjs/production/subscriptions/polling.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/ConstraintMatcher.d.ts +42 -0
- package/dist/esm/ConstraintMatcher.d.ts.map +1 -0
- package/dist/esm/EntityInstance.d.ts +38 -0
- package/dist/esm/EntityInstance.d.ts.map +1 -0
- package/dist/esm/EntityStore.d.ts +14 -0
- package/dist/esm/EntityStore.d.ts.map +1 -0
- package/dist/esm/GcManager.d.ts +38 -0
- package/dist/esm/GcManager.d.ts.map +1 -0
- package/dist/esm/LiveCollection.d.ts +86 -0
- package/dist/esm/LiveCollection.d.ts.map +1 -0
- package/dist/esm/MutationResult.d.ts +22 -0
- package/dist/esm/MutationResult.d.ts.map +1 -0
- package/dist/esm/NetworkManager.d.ts +62 -0
- package/dist/esm/NetworkManager.d.ts.map +1 -0
- package/dist/esm/QueryClient.d.ts +98 -0
- package/dist/esm/QueryClient.d.ts.map +1 -0
- package/dist/esm/QueryController.d.ts +49 -0
- package/dist/esm/QueryController.d.ts.map +1 -0
- package/dist/esm/QueryResult.d.ts +67 -0
- package/dist/esm/QueryResult.d.ts.map +1 -0
- package/dist/esm/applyEntities.d.ts +12 -0
- package/dist/esm/applyEntities.d.ts.map +1 -0
- 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 +32 -0
- package/dist/esm/development/index.js.map +1 -0
- 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 +40 -0
- package/dist/esm/development/react/index.js.map +1 -0
- package/dist/esm/development/rest/index.js +142 -0
- package/dist/esm/development/rest/index.js.map +1 -0
- package/dist/esm/development/shared-DcuVH8Pf.js +15 -0
- package/dist/esm/development/shared-DcuVH8Pf.js.map +1 -0
- package/dist/esm/development/stores/async.js +214 -0
- package/dist/esm/development/stores/async.js.map +1 -0
- package/dist/esm/development/stores/sync.js +149 -0
- package/dist/esm/development/stores/sync.js.map +1 -0
- package/dist/esm/development/subscriptions/polling.js +25 -0
- package/dist/esm/development/subscriptions/polling.js.map +1 -0
- package/dist/esm/development/topic/index.js +86 -0
- package/dist/esm/development/topic/index.js.map +1 -0
- package/dist/esm/errors.d.ts +4 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/fieldRef.d.ts +15 -0
- package/dist/esm/fieldRef.d.ts.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/mutation.d.ts +34 -0
- package/dist/esm/mutation.d.ts.map +1 -0
- package/dist/esm/parseEntities.d.ts +44 -0
- package/dist/esm/parseEntities.d.ts.map +1 -0
- package/dist/esm/production/QueryClient-YqnBxFy1.js +2457 -0
- 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 +32 -0
- package/dist/esm/production/index.js.map +1 -0
- 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 +40 -0
- package/dist/esm/production/react/index.js.map +1 -0
- package/dist/esm/production/rest/index.js +142 -0
- package/dist/esm/production/rest/index.js.map +1 -0
- package/dist/esm/production/shared-DcuVH8Pf.js +15 -0
- package/dist/esm/production/shared-DcuVH8Pf.js.map +1 -0
- package/dist/esm/production/stores/async.js +214 -0
- package/dist/esm/production/stores/async.js.map +1 -0
- package/dist/esm/production/stores/sync.js +149 -0
- package/dist/esm/production/stores/sync.js.map +1 -0
- package/dist/esm/production/subscriptions/polling.js +25 -0
- package/dist/esm/production/subscriptions/polling.js.map +1 -0
- package/dist/esm/production/topic/index.js +86 -0
- package/dist/esm/production/topic/index.js.map +1 -0
- package/dist/esm/proxy.d.ts +20 -0
- package/dist/esm/proxy.d.ts.map +1 -0
- package/dist/esm/proxyId.d.ts +8 -0
- package/dist/esm/proxyId.d.ts.map +1 -0
- package/dist/esm/query-types.d.ts +60 -0
- package/dist/esm/query-types.d.ts.map +1 -0
- package/dist/esm/query.d.ts +64 -0
- package/dist/esm/query.d.ts.map +1 -0
- package/dist/esm/react/index.d.ts +2 -0
- package/dist/esm/react/index.d.ts.map +1 -0
- package/dist/esm/react/use-query.d.ts +5 -0
- package/dist/esm/react/use-query.d.ts.map +1 -0
- 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/retry.d.ts +4 -0
- package/dist/esm/retry.d.ts.map +1 -0
- package/dist/esm/stores/async.d.ts +80 -0
- package/dist/esm/stores/async.d.ts.map +1 -0
- package/dist/esm/stores/shared.d.ts +12 -0
- package/dist/esm/stores/shared.d.ts.map +1 -0
- package/dist/esm/stores/sync.d.ts +41 -0
- package/dist/esm/stores/sync.d.ts.map +1 -0
- package/dist/esm/subscriptions/polling.d.ts +6 -0
- package/dist/esm/subscriptions/polling.d.ts.map +1 -0
- 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/type-utils.d.ts +16 -0
- package/dist/esm/type-utils.d.ts.map +1 -0
- package/dist/esm/typeDefs.d.ts +86 -0
- package/dist/esm/typeDefs.d.ts.map +1 -0
- package/dist/esm/types.d.ts +277 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/utils.d.ts +38 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/index.d.ts +1 -0
- package/package.json +181 -5
- 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/stores/async.d.ts +1 -0
- package/stores/async.js +15 -0
- package/stores/sync.d.ts +1 -0
- package/stores/sync.js +15 -0
- package/index.js +0 -1
|
@@ -0,0 +1,2457 @@
|
|
|
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 {
|
|
9
|
+
type;
|
|
10
|
+
entityDefs;
|
|
11
|
+
constraintFieldRefs;
|
|
12
|
+
sort;
|
|
13
|
+
valueType;
|
|
14
|
+
onCreate;
|
|
15
|
+
onUpdate;
|
|
16
|
+
onDelete;
|
|
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;
|
|
19
|
+
}
|
|
20
|
+
static array(t, e, i) {
|
|
21
|
+
return new j(
|
|
22
|
+
0,
|
|
23
|
+
t,
|
|
24
|
+
e,
|
|
25
|
+
i,
|
|
26
|
+
void 0,
|
|
27
|
+
void 0,
|
|
28
|
+
void 0,
|
|
29
|
+
void 0
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
static value(t, e, i, s, r, o) {
|
|
33
|
+
return new j(
|
|
34
|
+
1,
|
|
35
|
+
t,
|
|
36
|
+
e,
|
|
37
|
+
void 0,
|
|
38
|
+
i,
|
|
39
|
+
s,
|
|
40
|
+
r,
|
|
41
|
+
o
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function k(n) {
|
|
47
|
+
return x.get(n);
|
|
48
|
+
}
|
|
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);
|
|
53
|
+
}
|
|
54
|
+
_currentFlush = /* @__PURE__ */ new Map();
|
|
55
|
+
_nextFlush = /* @__PURE__ */ new Map();
|
|
56
|
+
_intervalId;
|
|
57
|
+
schedule(t, e) {
|
|
58
|
+
this._nextFlush.set(t, e);
|
|
59
|
+
}
|
|
60
|
+
cancel(t) {
|
|
61
|
+
this._currentFlush.delete(t), this._nextFlush.delete(t);
|
|
62
|
+
}
|
|
63
|
+
_tick = () => {
|
|
64
|
+
const { _currentFlush: t, _nextFlush: e, _onEvict: i } = this;
|
|
65
|
+
for (const [s, r] of t)
|
|
66
|
+
i(s, r);
|
|
67
|
+
this._currentFlush = e, this._nextFlush = /* @__PURE__ */ new Map();
|
|
68
|
+
};
|
|
69
|
+
destroy() {
|
|
70
|
+
clearInterval(this._intervalId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class Oe {
|
|
74
|
+
_buckets = /* @__PURE__ */ new Map();
|
|
75
|
+
_nextTickEntries = /* @__PURE__ */ new Map();
|
|
76
|
+
_nextTickScheduled = !1;
|
|
77
|
+
_onEvict;
|
|
78
|
+
_multiplier;
|
|
79
|
+
constructor(t, e = 1) {
|
|
80
|
+
this._onEvict = t, this._multiplier = e;
|
|
81
|
+
}
|
|
82
|
+
schedule(t, e, i) {
|
|
83
|
+
if (e === 1 / 0) return;
|
|
84
|
+
if (e === 0) {
|
|
85
|
+
const { _nextTickEntries: o } = this;
|
|
86
|
+
o.set(t, i), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const { _buckets: s } = this;
|
|
90
|
+
let r = s.get(e);
|
|
91
|
+
r || (r = new xe(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t, i);
|
|
92
|
+
}
|
|
93
|
+
cancel(t, e) {
|
|
94
|
+
if (e !== 1 / 0) {
|
|
95
|
+
if (e === 0) {
|
|
96
|
+
this._nextTickEntries.delete(t);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this._buckets.get(e)?.cancel(t);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_flushNextTick = () => {
|
|
103
|
+
const { _nextTickEntries: t, _onEvict: e } = this;
|
|
104
|
+
this._nextTickScheduled = !1;
|
|
105
|
+
for (const [i, s] of t)
|
|
106
|
+
e(i, s);
|
|
107
|
+
t.clear();
|
|
108
|
+
};
|
|
109
|
+
destroy() {
|
|
110
|
+
const { _buckets: t, _nextTickEntries: e } = this;
|
|
111
|
+
for (const i of t.values())
|
|
112
|
+
i.destroy();
|
|
113
|
+
t.clear(), e.clear();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
class Re {
|
|
117
|
+
schedule(t, e, i) {
|
|
118
|
+
}
|
|
119
|
+
cancel(t, e) {
|
|
120
|
+
}
|
|
121
|
+
destroy() {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
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) {
|
|
126
|
+
const t = {
|
|
127
|
+
[Y]: !0,
|
|
128
|
+
[N]: n
|
|
129
|
+
};
|
|
130
|
+
return new Proxy(t, Ae);
|
|
131
|
+
}
|
|
132
|
+
const Ae = {
|
|
133
|
+
get(n, t) {
|
|
134
|
+
if (t === Y) return !0;
|
|
135
|
+
if (t === N) return n[N];
|
|
136
|
+
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
|
|
137
|
+
const i = n[N];
|
|
138
|
+
return () => `[${i.join(".")}]`;
|
|
139
|
+
}
|
|
140
|
+
if (typeof t == "symbol") return;
|
|
141
|
+
const e = n[N];
|
|
142
|
+
return Tt([...e, t]);
|
|
143
|
+
},
|
|
144
|
+
has(n, t) {
|
|
145
|
+
return t === Y || t === N;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function Pt(n) {
|
|
149
|
+
return typeof n == "object" && n !== null && n[Y] === !0;
|
|
150
|
+
}
|
|
151
|
+
function Lt(n) {
|
|
152
|
+
return n[N];
|
|
153
|
+
}
|
|
154
|
+
function jt(n) {
|
|
155
|
+
return new Proxy(n, {
|
|
156
|
+
set(t, e, i) {
|
|
157
|
+
return t[e] = i, !0;
|
|
158
|
+
},
|
|
159
|
+
get(t, e) {
|
|
160
|
+
return e === ft ? t : e === G ? () => {
|
|
161
|
+
} : typeof e == "symbol" ? t[e] : Tt([e]);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function De(n) {
|
|
166
|
+
const t = n[ft];
|
|
167
|
+
n[G]();
|
|
168
|
+
const e = {};
|
|
169
|
+
for (const r of Object.getOwnPropertyNames(t))
|
|
170
|
+
e[r] = t[r];
|
|
171
|
+
const i = {};
|
|
172
|
+
let s = Object.getPrototypeOf(t);
|
|
173
|
+
for (; s && s !== Object.prototype; ) {
|
|
174
|
+
for (const r of Object.getOwnPropertyNames(s)) {
|
|
175
|
+
if (r === "constructor") continue;
|
|
176
|
+
const o = Object.getOwnPropertyDescriptor(s, r);
|
|
177
|
+
typeof o.value == "function" && !(r in i) && (i[r] = o.value);
|
|
178
|
+
}
|
|
179
|
+
s = Object.getPrototypeOf(s);
|
|
180
|
+
}
|
|
181
|
+
return { fields: e, methods: i };
|
|
182
|
+
}
|
|
183
|
+
function ut(n, t) {
|
|
184
|
+
let e = t;
|
|
185
|
+
for (const i of n) {
|
|
186
|
+
if (e == null) return;
|
|
187
|
+
e = e[i];
|
|
188
|
+
}
|
|
189
|
+
return e;
|
|
190
|
+
}
|
|
191
|
+
function Ie(n, t) {
|
|
192
|
+
return n.replace(Se, (e, i) => {
|
|
193
|
+
const s = i.split("."), r = ut(s, t);
|
|
194
|
+
return r != null ? encodeURIComponent(String(r)) : "";
|
|
195
|
+
});
|
|
196
|
+
}
|
|
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) {
|
|
205
|
+
const e = {};
|
|
206
|
+
for (const i of Object.keys(n))
|
|
207
|
+
e[i] = W(n[i], t);
|
|
208
|
+
return e;
|
|
209
|
+
}
|
|
210
|
+
return n;
|
|
211
|
+
}
|
|
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);
|
|
216
|
+
o.params = t, o.context = e;
|
|
217
|
+
for (const [a, c] of Object.entries(s))
|
|
218
|
+
o[a] = c.bind(o);
|
|
219
|
+
return o;
|
|
220
|
+
}
|
|
221
|
+
class qt {
|
|
222
|
+
static cache;
|
|
223
|
+
constructor() {
|
|
224
|
+
return jt(this);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
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;
|
|
230
|
+
}
|
|
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;
|
|
233
|
+
}
|
|
234
|
+
function Vt(n, t, e) {
|
|
235
|
+
const i = /* @__PURE__ */ new Set();
|
|
236
|
+
for (const r of n)
|
|
237
|
+
if (r !== void 0)
|
|
238
|
+
for (const o of Object.keys(r))
|
|
239
|
+
i.add(o);
|
|
240
|
+
const s = {};
|
|
241
|
+
for (const r of i) {
|
|
242
|
+
let o = 0, a;
|
|
243
|
+
const c = [];
|
|
244
|
+
let f = !0;
|
|
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));
|
|
248
|
+
}
|
|
249
|
+
if (f && o > 0) {
|
|
250
|
+
const d = Vt(c, t), u = new _(l.OBJECT, d);
|
|
251
|
+
s[r] = o < t ? wt(u) : u;
|
|
252
|
+
} else
|
|
253
|
+
s[r] = o < t ? wt(a) : a;
|
|
254
|
+
}
|
|
255
|
+
return s;
|
|
256
|
+
}
|
|
257
|
+
class _ {
|
|
258
|
+
mask;
|
|
259
|
+
shape;
|
|
260
|
+
typenameField = void 0;
|
|
261
|
+
typenameValue = void 0;
|
|
262
|
+
idField = void 0;
|
|
263
|
+
values = void 0;
|
|
264
|
+
/**
|
|
265
|
+
* Methods object for entity definitions.
|
|
266
|
+
* Shared across all proxies, but each proxy binds its own reactive method wrappers.
|
|
267
|
+
*/
|
|
268
|
+
_methods = void 0;
|
|
269
|
+
/**
|
|
270
|
+
* Entity configuration including stream options.
|
|
271
|
+
*/
|
|
272
|
+
_entityConfig = void 0;
|
|
273
|
+
/**
|
|
274
|
+
* The original Entity class for this definition.
|
|
275
|
+
* Used by createEntityProxy to set the proxy prototype so `instanceof` works.
|
|
276
|
+
*/
|
|
277
|
+
_entityClass = void 0;
|
|
278
|
+
/**
|
|
279
|
+
* Entity cache options (e.g. gcTime for in-memory eviction).
|
|
280
|
+
*/
|
|
281
|
+
_entityCache = void 0;
|
|
282
|
+
/**
|
|
283
|
+
* Live data configuration (shared by LiveArray and LiveValue).
|
|
284
|
+
*/
|
|
285
|
+
_liveConfig = void 0;
|
|
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;
|
|
288
|
+
}
|
|
289
|
+
static merge(t) {
|
|
290
|
+
if (t.length === 1) return t[0];
|
|
291
|
+
const e = t.length, i = t.map((c) => c.shape);
|
|
292
|
+
t[0].typenameValue;
|
|
293
|
+
const s = Vt(i, e);
|
|
294
|
+
let r, o, a;
|
|
295
|
+
for (const c of t) {
|
|
296
|
+
if (r === void 0 && c.idField !== void 0)
|
|
297
|
+
r = c.idField;
|
|
298
|
+
else if (r !== void 0 && c.idField !== void 0 && c.idField !== r)
|
|
299
|
+
throw new Error(
|
|
300
|
+
`[fetchium] Entity typename '${c.typenameValue}' has conflicting id fields: '${String(r)}' vs '${String(c.idField)}'`
|
|
301
|
+
);
|
|
302
|
+
o === void 0 && (o = c.typenameField), a === void 0 && (a = c.typenameValue);
|
|
303
|
+
}
|
|
304
|
+
return new _(
|
|
305
|
+
l.ENTITY | l.OBJECT,
|
|
306
|
+
s,
|
|
307
|
+
void 0,
|
|
308
|
+
o,
|
|
309
|
+
a,
|
|
310
|
+
r
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
static cloneWith(t, e) {
|
|
314
|
+
const i = new _(
|
|
315
|
+
e | t.mask,
|
|
316
|
+
t.shape,
|
|
317
|
+
t.values,
|
|
318
|
+
t.typenameField,
|
|
319
|
+
t.typenameValue,
|
|
320
|
+
t.idField
|
|
321
|
+
);
|
|
322
|
+
return i._methods = t._methods, i._entityConfig = t._entityConfig, i._entityClass = t._entityClass, i._entityCache = t._entityCache, i._liveConfig = t._liveConfig, i;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
class H extends Set {
|
|
326
|
+
lowercaseMap;
|
|
327
|
+
// lowercase -> canonical (strings only)
|
|
328
|
+
constructor(t) {
|
|
329
|
+
super(t), this.lowercaseMap = /* @__PURE__ */ new Map();
|
|
330
|
+
for (const e of t)
|
|
331
|
+
if (typeof e == "string") {
|
|
332
|
+
const i = e.toLowerCase(), s = this.lowercaseMap.get(i);
|
|
333
|
+
if (s !== void 0)
|
|
334
|
+
throw new Error(
|
|
335
|
+
`Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${i}'`
|
|
336
|
+
);
|
|
337
|
+
this.lowercaseMap.set(i, e);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Check if a value exists in the set (case-insensitively for strings).
|
|
342
|
+
* Used for backwards compatibility with Set-based checks.
|
|
343
|
+
*/
|
|
344
|
+
has(t) {
|
|
345
|
+
return this.get(t) !== void 0;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Get the canonical value for a given input.
|
|
349
|
+
* For strings, performs case-insensitive lookup and returns the canonical casing.
|
|
350
|
+
* For numbers/booleans, performs exact match.
|
|
351
|
+
* Returns undefined if no match is found.
|
|
352
|
+
*/
|
|
353
|
+
get(t) {
|
|
354
|
+
if (typeof t == "string")
|
|
355
|
+
return this.lowercaseMap.get(t.toLowerCase());
|
|
356
|
+
if (super.has(t))
|
|
357
|
+
return t;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const Me = 1128875347;
|
|
361
|
+
Ee(H, (n) => {
|
|
362
|
+
let t = Me;
|
|
363
|
+
for (const e of n)
|
|
364
|
+
t += D(e);
|
|
365
|
+
return t >>> 0;
|
|
366
|
+
});
|
|
367
|
+
function lt(n, t) {
|
|
368
|
+
return new _(n, t);
|
|
369
|
+
}
|
|
370
|
+
function ke(n) {
|
|
371
|
+
return lt(l.ARRAY, n);
|
|
372
|
+
}
|
|
373
|
+
function Fe(n) {
|
|
374
|
+
return lt(l.RECORD | l.OBJECT, n);
|
|
375
|
+
}
|
|
376
|
+
function Te(n) {
|
|
377
|
+
return lt(l.PARSE_RESULT, n);
|
|
378
|
+
}
|
|
379
|
+
function Kt(n, t) {
|
|
380
|
+
let e = n, i, s, r;
|
|
381
|
+
for (const [o, a] of Ut(t))
|
|
382
|
+
switch (typeof a) {
|
|
383
|
+
case "number":
|
|
384
|
+
if ((a & l.ID) !== 0) {
|
|
385
|
+
if (i !== void 0)
|
|
386
|
+
throw new Error(`Duplicate id field: ${o}`);
|
|
387
|
+
i = o;
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
case "string":
|
|
391
|
+
if (s !== void 0 && s !== o)
|
|
392
|
+
throw new Error(`Duplicate typename field: ${o}`);
|
|
393
|
+
s = o, r = a;
|
|
394
|
+
break;
|
|
395
|
+
case "object":
|
|
396
|
+
if (a instanceof H || a instanceof Set)
|
|
397
|
+
break;
|
|
398
|
+
a.mask & l.LIVE && (e |= l.LIVE);
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
return new _(e, t, void 0, s, r, i);
|
|
402
|
+
}
|
|
403
|
+
function Pe(n) {
|
|
404
|
+
return Kt(l.OBJECT, n);
|
|
405
|
+
}
|
|
406
|
+
function Et(n, t, e) {
|
|
407
|
+
const i = n.mask;
|
|
408
|
+
if ((i & l.UNION) !== 0) {
|
|
409
|
+
const s = n;
|
|
410
|
+
if (s.typenameField !== void 0) {
|
|
411
|
+
if (e !== void 0 && e !== s.typenameField)
|
|
412
|
+
throw new Error(
|
|
413
|
+
`Union typename field conflict: Cannot merge unions with different typename fields ('${e}' vs '${s.typenameField}')`
|
|
414
|
+
);
|
|
415
|
+
e = s.typenameField;
|
|
416
|
+
}
|
|
417
|
+
const r = s.shape;
|
|
418
|
+
if (r !== void 0)
|
|
419
|
+
for (const o of [...nt(r), Q, B]) {
|
|
420
|
+
const a = r[o];
|
|
421
|
+
if (t[o] !== void 0 && t[o] !== a)
|
|
422
|
+
throw new Error(
|
|
423
|
+
`Union merge conflict: Duplicate typename value '${String(o)}' found when merging nested unions (${String(t[o])} vs ${String(a)})`
|
|
424
|
+
);
|
|
425
|
+
t[o] = a;
|
|
426
|
+
}
|
|
427
|
+
} else if ((i & l.ARRAY) !== 0) {
|
|
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)
|
|
433
|
+
throw new Error("Record shape already defined");
|
|
434
|
+
t[B] = n.shape;
|
|
435
|
+
} else {
|
|
436
|
+
const s = n.typenameField, r = n.typenameValue;
|
|
437
|
+
if (r === void 0)
|
|
438
|
+
throw new Error(
|
|
439
|
+
"Object definitions must have a typename to be in a union with other objects, records, or arrays"
|
|
440
|
+
);
|
|
441
|
+
if (e !== void 0 && s !== e)
|
|
442
|
+
throw new Error("Object definitions must have the same typename field to be in the same union");
|
|
443
|
+
e = s, t[r] = n;
|
|
444
|
+
}
|
|
445
|
+
return e;
|
|
446
|
+
}
|
|
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;
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (d instanceof Set) {
|
|
456
|
+
if (r === void 0)
|
|
457
|
+
r = new Set(d);
|
|
458
|
+
else
|
|
459
|
+
for (const u of d)
|
|
460
|
+
r.add(u);
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (i++, c |= d.mask, i === 1) {
|
|
464
|
+
s = d;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Et(s, o, a)), a = Et(d, o, a);
|
|
468
|
+
}
|
|
469
|
+
if (i === 0)
|
|
470
|
+
return r === void 0 ? e : e === 0 ? r : new _(e | l.UNION, void 0, r);
|
|
471
|
+
if (i === 1)
|
|
472
|
+
return _.cloneWith(s, e);
|
|
473
|
+
const f = e | c | l.UNION;
|
|
474
|
+
return new _(f, o, r, a);
|
|
475
|
+
}
|
|
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;
|
|
484
|
+
}
|
|
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);
|
|
488
|
+
}
|
|
489
|
+
function Ve(n) {
|
|
490
|
+
return ht(n, l.UNDEFINED, Le);
|
|
491
|
+
}
|
|
492
|
+
function Ke(n) {
|
|
493
|
+
return ht(n, l.NULL, je);
|
|
494
|
+
}
|
|
495
|
+
function $e(n) {
|
|
496
|
+
return n;
|
|
497
|
+
}
|
|
498
|
+
function Qe(n) {
|
|
499
|
+
return /* @__PURE__ */ new Set([n]);
|
|
500
|
+
}
|
|
501
|
+
const $t = ((...n) => new Set(n));
|
|
502
|
+
$t.caseInsensitive = (...n) => new H(n);
|
|
503
|
+
const Qt = 16;
|
|
504
|
+
let Be = 0;
|
|
505
|
+
const it = [], Bt = [], Yt = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new WeakSet();
|
|
506
|
+
class q {
|
|
507
|
+
_raw;
|
|
508
|
+
_formatted;
|
|
509
|
+
_parsed;
|
|
510
|
+
_formatId;
|
|
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);
|
|
513
|
+
}
|
|
514
|
+
getValue() {
|
|
515
|
+
return this._parsed || (this._formatted = it[this._formatId](this._raw), this._parsed = !0), this._formatted;
|
|
516
|
+
}
|
|
517
|
+
toJSON() {
|
|
518
|
+
return this._parsed ? Bt[this._formatId](this._formatted) : this._raw;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function Ye(n) {
|
|
522
|
+
const t = Yt.get(n);
|
|
523
|
+
if (t === void 0)
|
|
524
|
+
throw new Error(`Format ${n} not registered`);
|
|
525
|
+
return t;
|
|
526
|
+
}
|
|
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);
|
|
532
|
+
}
|
|
533
|
+
Gt(
|
|
534
|
+
"date",
|
|
535
|
+
l.STRING,
|
|
536
|
+
(n) => {
|
|
537
|
+
const t = n.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
538
|
+
if (!t)
|
|
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)));
|
|
541
|
+
if (isNaN(r.getTime()))
|
|
542
|
+
throw new Error(`Invalid date string: ${n}`);
|
|
543
|
+
return r;
|
|
544
|
+
},
|
|
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}`;
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
Gt(
|
|
551
|
+
"date-time",
|
|
552
|
+
l.STRING,
|
|
553
|
+
(n) => {
|
|
554
|
+
const t = new Date(n);
|
|
555
|
+
if (isNaN(t.getTime()))
|
|
556
|
+
throw new Error(`Invalid date-time string: ${n}`);
|
|
557
|
+
return t;
|
|
558
|
+
},
|
|
559
|
+
(n) => n.toISOString()
|
|
560
|
+
);
|
|
561
|
+
const Ct = /* @__PURE__ */ new WeakMap();
|
|
562
|
+
function T(n) {
|
|
563
|
+
let t = Ct.get(n);
|
|
564
|
+
if (t === void 0) {
|
|
565
|
+
const e = new n(), i = e[ft] ?? e;
|
|
566
|
+
e[G] && e[G]();
|
|
567
|
+
const s = {};
|
|
568
|
+
for (const [f, d] of Ut(i))
|
|
569
|
+
s[f] = d;
|
|
570
|
+
const r = Object.getPrototypeOf(n.prototype);
|
|
571
|
+
if (r != null) {
|
|
572
|
+
const f = r.constructor;
|
|
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])
|
|
577
|
+
throw new Error(`Cannot extend: field '${y}' already exists in type definition`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const o = {}, a = n.prototype;
|
|
581
|
+
for (const f of Object.getOwnPropertyNames(a))
|
|
582
|
+
f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
|
|
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);
|
|
586
|
+
}
|
|
587
|
+
return t;
|
|
588
|
+
}
|
|
589
|
+
function Ge(n) {
|
|
590
|
+
return T(n);
|
|
591
|
+
}
|
|
592
|
+
function Wt(n, t) {
|
|
593
|
+
if (t == null) return;
|
|
594
|
+
const e = /* @__PURE__ */ new Map();
|
|
595
|
+
if (Array.isArray(t))
|
|
596
|
+
for (const i of t) {
|
|
597
|
+
const [s, r] = i, a = T(s).typenameValue;
|
|
598
|
+
if (a === void 0) continue;
|
|
599
|
+
const c = [];
|
|
600
|
+
for (const [f, d] of Object.entries(r))
|
|
601
|
+
c.push([f, d]);
|
|
602
|
+
c.length > 0 && e.set(a, c);
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
const s = Object.entries(t);
|
|
606
|
+
if (s.length === 0) return;
|
|
607
|
+
const r = s.map(([o, a]) => [o, a]);
|
|
608
|
+
for (const o of n) {
|
|
609
|
+
const a = o.typenameValue;
|
|
610
|
+
a !== void 0 && e.set(a, r);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return e.size > 0 ? e : void 0;
|
|
614
|
+
}
|
|
615
|
+
function zt(n) {
|
|
616
|
+
return Array.isArray(n) ? n.map((t) => T(t)) : [T(n)];
|
|
617
|
+
}
|
|
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(
|
|
621
|
+
e,
|
|
622
|
+
Wt(e, t?.constraints),
|
|
623
|
+
t?.sort
|
|
624
|
+
), r;
|
|
625
|
+
}
|
|
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),
|
|
631
|
+
s,
|
|
632
|
+
e.onCreate,
|
|
633
|
+
e.onUpdate,
|
|
634
|
+
e.onDelete
|
|
635
|
+
), o;
|
|
636
|
+
}
|
|
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,
|
|
655
|
+
result: Te,
|
|
656
|
+
entity: Ge,
|
|
657
|
+
liveArray: We,
|
|
658
|
+
liveValue: ze
|
|
659
|
+
};
|
|
660
|
+
function P(n, t, e) {
|
|
661
|
+
return new TypeError(`Validation error at ${n}`);
|
|
662
|
+
}
|
|
663
|
+
const Ht = Array.isArray;
|
|
664
|
+
function bt(n) {
|
|
665
|
+
if (n === null) return l.NULL;
|
|
666
|
+
switch (typeof n) {
|
|
667
|
+
case "number":
|
|
668
|
+
return l.NUMBER;
|
|
669
|
+
case "string":
|
|
670
|
+
return l.STRING;
|
|
671
|
+
case "boolean":
|
|
672
|
+
return l.BOOLEAN;
|
|
673
|
+
case "undefined":
|
|
674
|
+
return l.UNDEFINED;
|
|
675
|
+
case "object":
|
|
676
|
+
return Ht(n) ? l.ARRAY : l.OBJECT;
|
|
677
|
+
default:
|
|
678
|
+
throw new Error(`Invalid type: ${typeof n}`);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function Dn(n) {
|
|
682
|
+
return F(n);
|
|
683
|
+
}
|
|
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) {
|
|
692
|
+
const e = /* @__PURE__ */ new Map();
|
|
693
|
+
for (const [i, s] of n)
|
|
694
|
+
e.set(F(i), F(s));
|
|
695
|
+
return e;
|
|
696
|
+
}
|
|
697
|
+
if (n instanceof Set) {
|
|
698
|
+
const e = /* @__PURE__ */ new Set();
|
|
699
|
+
for (const i of n)
|
|
700
|
+
e.add(F(i));
|
|
701
|
+
return e;
|
|
702
|
+
}
|
|
703
|
+
const t = {};
|
|
704
|
+
for (const e of Object.keys(n))
|
|
705
|
+
t[e] = F(n[e]);
|
|
706
|
+
return t;
|
|
707
|
+
}
|
|
708
|
+
const yt = Object.entries, Je = () => {
|
|
709
|
+
};
|
|
710
|
+
class st {
|
|
711
|
+
queryClient = void 0;
|
|
712
|
+
preloadedEntities = void 0;
|
|
713
|
+
warn = Je;
|
|
714
|
+
/** When true, missing optional fields on existing entities are set to
|
|
715
|
+
* undefined. False for mutation events (truly partial payloads). */
|
|
716
|
+
isPartialEvent = !1;
|
|
717
|
+
seen = void 0;
|
|
718
|
+
seenByKey = void 0;
|
|
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()));
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
function Jt(n, t, e) {
|
|
724
|
+
return M(n, t, e, "");
|
|
725
|
+
}
|
|
726
|
+
function Xe(n, t, e) {
|
|
727
|
+
return pt(n, t, e);
|
|
728
|
+
}
|
|
729
|
+
function xt(n, t, e, i) {
|
|
730
|
+
const s = n >> Qt;
|
|
731
|
+
if ((n & l.IS_EAGER_FORMAT) !== 0)
|
|
732
|
+
try {
|
|
733
|
+
return new q(t, s, !0);
|
|
734
|
+
} catch (o) {
|
|
735
|
+
if ((n & l.UNDEFINED) !== 0) {
|
|
736
|
+
e.warn("Invalid formatted value for optional type, defaulting to undefined", {
|
|
737
|
+
value: t,
|
|
738
|
+
path: i,
|
|
739
|
+
error: o instanceof Error ? o.message : String(o)
|
|
740
|
+
});
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
throw o;
|
|
744
|
+
}
|
|
745
|
+
return new q(t, s, !1);
|
|
746
|
+
}
|
|
747
|
+
function M(n, t, e, i) {
|
|
748
|
+
const s = t;
|
|
749
|
+
if (s instanceof H) {
|
|
750
|
+
const c = s.get(n);
|
|
751
|
+
if (c === void 0) throw P(i);
|
|
752
|
+
return c;
|
|
753
|
+
}
|
|
754
|
+
if (s instanceof Set) {
|
|
755
|
+
if (!s.has(n)) throw P(i);
|
|
756
|
+
return n;
|
|
757
|
+
}
|
|
758
|
+
if (typeof s == "string") {
|
|
759
|
+
if (n == null) return s;
|
|
760
|
+
if (n !== s) throw P(i);
|
|
761
|
+
return n;
|
|
762
|
+
}
|
|
763
|
+
if (typeof s == "number") {
|
|
764
|
+
const c = bt(n);
|
|
765
|
+
if ((s & c) === 0) {
|
|
766
|
+
if ((s & l.UNDEFINED) !== 0) {
|
|
767
|
+
e.warn("Invalid value for optional type, defaulting to undefined", { value: n, path: i });
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
throw P(i);
|
|
771
|
+
}
|
|
772
|
+
return (s & l.HAS_FORMAT) !== 0 && n !== null && n !== void 0 ? xt(s, n, e, i) : n;
|
|
773
|
+
}
|
|
774
|
+
const r = s.mask, o = s._liveConfig;
|
|
775
|
+
if (o !== void 0 && o.type === ct.Value)
|
|
776
|
+
return o.valueType !== void 0 ? M(n, o.valueType, e, i) : n;
|
|
777
|
+
if ((r & l.PARSE_RESULT) !== 0)
|
|
778
|
+
try {
|
|
779
|
+
return { success: !0, value: M(n, s.shape, e, i) };
|
|
780
|
+
} catch (c) {
|
|
781
|
+
return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
|
|
782
|
+
}
|
|
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 });
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
throw P(i);
|
|
790
|
+
}
|
|
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);
|
|
792
|
+
}
|
|
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);
|
|
797
|
+
} else {
|
|
798
|
+
const r = e.typenameField, o = r ? t[r] : void 0;
|
|
799
|
+
if (o === void 0 || typeof o != "string") {
|
|
800
|
+
const c = e.shape[B];
|
|
801
|
+
if (c === void 0)
|
|
802
|
+
throw new Error(
|
|
803
|
+
`Typename field '${r}' is required for union discrimination but was not found in the data`
|
|
804
|
+
);
|
|
805
|
+
return Zt(t, c, i, s);
|
|
806
|
+
}
|
|
807
|
+
const a = e.shape[o];
|
|
808
|
+
if (a === void 0 || typeof a == "number")
|
|
809
|
+
throw new Error(`Unknown typename '${o}' in union`);
|
|
810
|
+
return a.mask & l.ENTITY && i.queryClient !== void 0 ? pt(t, a, i) : te(t, a, i, s);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
function Xt(n, t, e, i) {
|
|
814
|
+
const s = [];
|
|
815
|
+
for (let r = 0; r < n.length; r++)
|
|
816
|
+
try {
|
|
817
|
+
s.push(M(n[r], t, e, `${i}[${r}]`));
|
|
818
|
+
} catch (o) {
|
|
819
|
+
e.warn("Failed to parse array item, filtering out", {
|
|
820
|
+
index: r,
|
|
821
|
+
value: n[r],
|
|
822
|
+
error: o instanceof Error ? o.message : String(o)
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
return s;
|
|
826
|
+
}
|
|
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;
|
|
831
|
+
}
|
|
832
|
+
function te(n, t, e, i) {
|
|
833
|
+
if (x.has(n))
|
|
834
|
+
return n;
|
|
835
|
+
const s = t.shape;
|
|
836
|
+
for (const [r, o] of yt(s))
|
|
837
|
+
n[r] = M(n[r], o, e, `${i}.${r}`);
|
|
838
|
+
return n;
|
|
839
|
+
}
|
|
840
|
+
function pt(n, t, e) {
|
|
841
|
+
const i = e.queryClient, s = e.preloadedEntities;
|
|
842
|
+
let r, o;
|
|
843
|
+
if (s !== void 0)
|
|
844
|
+
r = n.__entityRef, o = r;
|
|
845
|
+
else {
|
|
846
|
+
const p = n[t.idField];
|
|
847
|
+
if (p == null || typeof p != "string" && typeof p != "number")
|
|
848
|
+
throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
|
|
849
|
+
o = p, r = D([t.typenameValue, o]);
|
|
850
|
+
}
|
|
851
|
+
const a = e.seenByKey.get(r);
|
|
852
|
+
if (a !== void 0)
|
|
853
|
+
return a.data;
|
|
854
|
+
if (s !== void 0) {
|
|
855
|
+
const g = i.entityMap.getEntity(r)?.data ?? s.get(r);
|
|
856
|
+
if (g === void 0)
|
|
857
|
+
throw new Error(`Cached entity ${r} not found in preloaded map`);
|
|
858
|
+
n = g;
|
|
859
|
+
}
|
|
860
|
+
const c = {};
|
|
861
|
+
typeof t.idField == "symbol" && (c[t.idField] = o);
|
|
862
|
+
const f = i.entityMap.getEntity(r), d = e.isPartialEvent && f !== void 0, u = {
|
|
863
|
+
key: r,
|
|
864
|
+
shape: t,
|
|
865
|
+
data: c,
|
|
866
|
+
rawKeys: d ? new Set(Object.keys(n)) : void 0
|
|
867
|
+
};
|
|
868
|
+
e.seen.set(c, u), e.seenByKey.set(r, u);
|
|
869
|
+
const y = `[[${t.typenameValue}:${o}]]`, v = t.shape;
|
|
870
|
+
for (const [p, g] of yt(v))
|
|
871
|
+
d && !(p in n) || (c[p] = M(n[p], g, e, `${y}.${p}`));
|
|
872
|
+
return c;
|
|
873
|
+
}
|
|
874
|
+
function tn(n, t) {
|
|
875
|
+
return en(n, t.shape, t.typenameField);
|
|
876
|
+
}
|
|
877
|
+
function en(n, t, e) {
|
|
878
|
+
if (t === void 0) return !0;
|
|
879
|
+
for (const i of Object.keys(t)) {
|
|
880
|
+
if (i === e) continue;
|
|
881
|
+
const s = t[i];
|
|
882
|
+
if (s instanceof _) {
|
|
883
|
+
if ((s.mask & l.UNDEFINED) !== 0) continue;
|
|
884
|
+
if (!(i in n) || n[i] === void 0) return !1;
|
|
885
|
+
} else if (typeof s == "number") {
|
|
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;
|
|
889
|
+
}
|
|
890
|
+
return !0;
|
|
891
|
+
}
|
|
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;
|
|
900
|
+
}
|
|
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;
|
|
904
|
+
}
|
|
905
|
+
return n;
|
|
906
|
+
}
|
|
907
|
+
const sn = {
|
|
908
|
+
get(n, t, e) {
|
|
909
|
+
if (typeof t == "string") {
|
|
910
|
+
const i = Number(t);
|
|
911
|
+
if (Number.isInteger(i) && i >= 0 && i < n.length)
|
|
912
|
+
return A(n[i]);
|
|
913
|
+
}
|
|
914
|
+
return Reflect.get(n, t, e);
|
|
915
|
+
},
|
|
916
|
+
set() {
|
|
917
|
+
return !1;
|
|
918
|
+
},
|
|
919
|
+
deleteProperty() {
|
|
920
|
+
return !1;
|
|
921
|
+
}
|
|
922
|
+
}, rn = {
|
|
923
|
+
get(n, t, e) {
|
|
924
|
+
return typeof t == "string" ? A(n[t]) : Reflect.get(n, t, e);
|
|
925
|
+
},
|
|
926
|
+
set() {
|
|
927
|
+
return !1;
|
|
928
|
+
},
|
|
929
|
+
deleteProperty() {
|
|
930
|
+
return !1;
|
|
931
|
+
},
|
|
932
|
+
has(n, t) {
|
|
933
|
+
return t in n;
|
|
934
|
+
},
|
|
935
|
+
ownKeys(n) {
|
|
936
|
+
return Reflect.ownKeys(n);
|
|
937
|
+
},
|
|
938
|
+
getOwnPropertyDescriptor(n, t) {
|
|
939
|
+
return Object.getOwnPropertyDescriptor(n, t);
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
class on {
|
|
943
|
+
_notifier;
|
|
944
|
+
_queryClient;
|
|
945
|
+
_proxies = /* @__PURE__ */ new Map();
|
|
946
|
+
key;
|
|
947
|
+
typename;
|
|
948
|
+
id;
|
|
949
|
+
idField;
|
|
950
|
+
data;
|
|
951
|
+
refCount = 0;
|
|
952
|
+
entityRefs;
|
|
953
|
+
liveCollections = [];
|
|
954
|
+
satisfiedDefs = /* @__PURE__ */ new WeakSet();
|
|
955
|
+
parseId = -1;
|
|
956
|
+
_entityCache;
|
|
957
|
+
_extraMethods;
|
|
958
|
+
_extraGetters;
|
|
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;
|
|
961
|
+
}
|
|
962
|
+
retain() {
|
|
963
|
+
this.refCount++;
|
|
964
|
+
const t = this._entityCache?.gcTime;
|
|
965
|
+
t !== void 0 && this._queryClient.gcManager.cancel(this.key, t);
|
|
966
|
+
}
|
|
967
|
+
release() {
|
|
968
|
+
if (--this.refCount > 0 || this.refCount < 0)
|
|
969
|
+
return;
|
|
970
|
+
const t = this._entityCache?.gcTime;
|
|
971
|
+
t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, z.Entity) : this.evict();
|
|
972
|
+
}
|
|
973
|
+
evict() {
|
|
974
|
+
const t = this.liveCollections.slice();
|
|
975
|
+
this.liveCollections.length = 0;
|
|
976
|
+
for (const i of t) i.destroy();
|
|
977
|
+
this._queryClient.entityMap.remove(this.key);
|
|
978
|
+
const e = this.entityRefs;
|
|
979
|
+
if (this.entityRefs = void 0, e)
|
|
980
|
+
for (const i of e.keys()) i.release();
|
|
981
|
+
}
|
|
982
|
+
setChildRefs(t, e) {
|
|
983
|
+
const i = this.entityRefs;
|
|
984
|
+
if (t !== void 0 && t.size > 0)
|
|
985
|
+
for (const s of t.keys())
|
|
986
|
+
(i === void 0 || !i.has(s)) && s.retain();
|
|
987
|
+
if (i !== void 0 && i.size > 0)
|
|
988
|
+
for (const s of i.keys())
|
|
989
|
+
(t === void 0 || !t.has(s)) && s.release();
|
|
990
|
+
this.entityRefs = t, e && this.save();
|
|
991
|
+
}
|
|
992
|
+
addChildRef(t) {
|
|
993
|
+
this.entityRefs === void 0 && (this.entityRefs = /* @__PURE__ */ new Map());
|
|
994
|
+
const e = this.entityRefs.get(t) ?? 0;
|
|
995
|
+
this.entityRefs.set(t, e + 1), e === 0 && t.retain(), this.save();
|
|
996
|
+
}
|
|
997
|
+
removeChildRef(t) {
|
|
998
|
+
if (this.entityRefs === void 0) return;
|
|
999
|
+
const e = this.entityRefs.get(t);
|
|
1000
|
+
e !== void 0 && (e <= 1 ? (this.entityRefs.delete(t), t.release()) : this.entityRefs.set(t, e - 1), this.save());
|
|
1001
|
+
}
|
|
1002
|
+
getProxy(t) {
|
|
1003
|
+
const e = t;
|
|
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;
|
|
1006
|
+
}
|
|
1007
|
+
get proxy() {
|
|
1008
|
+
return this._proxies.values().next().value;
|
|
1009
|
+
}
|
|
1010
|
+
satisfiesDef(t) {
|
|
1011
|
+
return this.satisfiedDefs.has(t) ? !0 : tn(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
|
|
1012
|
+
}
|
|
1013
|
+
save() {
|
|
1014
|
+
this._queryClient.entityMap.save(this);
|
|
1015
|
+
}
|
|
1016
|
+
notify() {
|
|
1017
|
+
this._notifier.notify();
|
|
1018
|
+
}
|
|
1019
|
+
consume() {
|
|
1020
|
+
this._notifier.consume();
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function an(n, t, e) {
|
|
1024
|
+
const i = [];
|
|
1025
|
+
for (const s of n) {
|
|
1026
|
+
if (typeof s != "object" || s === null) continue;
|
|
1027
|
+
const r = x.get(s);
|
|
1028
|
+
if (r === void 0) continue;
|
|
1029
|
+
const o = e.entityMap.getEntity(r);
|
|
1030
|
+
o !== void 0 && o.satisfiesDef(t) && i.push(s);
|
|
1031
|
+
}
|
|
1032
|
+
return i;
|
|
1033
|
+
}
|
|
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;
|
|
1036
|
+
e.typenameField;
|
|
1037
|
+
const u = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
|
|
1038
|
+
let p;
|
|
1039
|
+
f?.hasSubscribe && a && "__subscribe" in a && (p = It((E) => {
|
|
1040
|
+
const h = (C) => {
|
|
1041
|
+
C.__eventSource = t, s.applyMutationEvent(C);
|
|
1042
|
+
}, m = a.__subscribe.call(g, h);
|
|
1043
|
+
return E.value = g, m;
|
|
1044
|
+
}));
|
|
1045
|
+
let g;
|
|
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;
|
|
1058
|
+
if (h !== void 0)
|
|
1059
|
+
for (const m of Object.keys(h))
|
|
1060
|
+
O.includes(m) || O.push(m);
|
|
1061
|
+
}
|
|
1062
|
+
return O;
|
|
1063
|
+
}
|
|
1064
|
+
const R = {
|
|
1065
|
+
getPrototypeOf() {
|
|
1066
|
+
return d;
|
|
1067
|
+
},
|
|
1068
|
+
get(E, h) {
|
|
1069
|
+
if (typeof h == "symbol") return;
|
|
1070
|
+
if (h === "toJSON") return v;
|
|
1071
|
+
if (h === "__context") return s.getContext();
|
|
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;
|
|
1081
|
+
}
|
|
1082
|
+
if (a && h in a) {
|
|
1083
|
+
let b = u.get(h);
|
|
1084
|
+
return b || (b = pe(g, a[h].bind(g)), u.set(h, b)), b;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
const m = n.data[h];
|
|
1088
|
+
if (typeof m == "object" && m !== null && J.has(m))
|
|
1089
|
+
return A(m.getValue());
|
|
1090
|
+
if (Array.isArray(m) && typeof h == "string") {
|
|
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);
|
|
1098
|
+
if (_t !== void 0 && _t.length > 1) {
|
|
1099
|
+
const X = y.get(h);
|
|
1100
|
+
if (X !== void 0 && X.source === m)
|
|
1101
|
+
return A(X.filtered);
|
|
1102
|
+
const mt = an(m, S, s);
|
|
1103
|
+
return y.set(h, { source: m, filtered: mt }), A(mt);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return A(m);
|
|
1109
|
+
}
|
|
1110
|
+
return A(m);
|
|
1111
|
+
},
|
|
1112
|
+
set() {
|
|
1113
|
+
return !1;
|
|
1114
|
+
},
|
|
1115
|
+
has(E, h) {
|
|
1116
|
+
if (h === "__typename") return !0;
|
|
1117
|
+
if (typeof h == "string") {
|
|
1118
|
+
const m = n._extraGetters;
|
|
1119
|
+
if (m && h in m) return !0;
|
|
1120
|
+
const C = n._extraMethods;
|
|
1121
|
+
if (C && h in C || a && h in a) return !0;
|
|
1122
|
+
}
|
|
1123
|
+
return h in r;
|
|
1124
|
+
},
|
|
1125
|
+
ownKeys() {
|
|
1126
|
+
return K();
|
|
1127
|
+
},
|
|
1128
|
+
getOwnPropertyDescriptor(E, h) {
|
|
1129
|
+
if (h === "__typename")
|
|
1130
|
+
return { enumerable: !0, configurable: !0, value: n.typename, writable: !1 };
|
|
1131
|
+
if (h in r)
|
|
1132
|
+
return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1133
|
+
if (typeof h == "string") {
|
|
1134
|
+
const m = n._extraGetters;
|
|
1135
|
+
if (m && h in m)
|
|
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 };
|
|
1140
|
+
if (a && h in a)
|
|
1141
|
+
return { enumerable: !1, configurable: !0, value: R.get(E, h, g), writable: !1 };
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
return g = new Proxy({}, R), x.set(g, t), ye(g, s), g;
|
|
1146
|
+
}
|
|
1147
|
+
class fn {
|
|
1148
|
+
instances = /* @__PURE__ */ new Map();
|
|
1149
|
+
persistEntity;
|
|
1150
|
+
constructor(t) {
|
|
1151
|
+
this.persistEntity = t;
|
|
1152
|
+
}
|
|
1153
|
+
hasEntity(t) {
|
|
1154
|
+
return this.instances.has(t);
|
|
1155
|
+
}
|
|
1156
|
+
getEntity(t) {
|
|
1157
|
+
return this.instances.get(t);
|
|
1158
|
+
}
|
|
1159
|
+
getOrCreateEntity(t, e, i, s) {
|
|
1160
|
+
let r = this.instances.get(t);
|
|
1161
|
+
if (r === void 0) {
|
|
1162
|
+
const o = i.idField;
|
|
1163
|
+
if (o === void 0)
|
|
1164
|
+
throw new Error(`Entity id field is required ${i.typenameValue}`);
|
|
1165
|
+
const a = e[o];
|
|
1166
|
+
if (typeof a != "string" && typeof a != "number")
|
|
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);
|
|
1170
|
+
}
|
|
1171
|
+
return r.parseId = s.currentParseId, r;
|
|
1172
|
+
}
|
|
1173
|
+
remove(t) {
|
|
1174
|
+
this.instances.delete(t);
|
|
1175
|
+
}
|
|
1176
|
+
save(t) {
|
|
1177
|
+
let e;
|
|
1178
|
+
if (t.entityRefs) {
|
|
1179
|
+
e = /* @__PURE__ */ new Set();
|
|
1180
|
+
for (const i of t.entityRefs.keys()) e.add(i.key);
|
|
1181
|
+
}
|
|
1182
|
+
this.persistEntity(t.key, t.data, e);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
class ee {
|
|
1186
|
+
onlineSignal;
|
|
1187
|
+
manualOverride = void 0;
|
|
1188
|
+
eventListenersAttached = !1;
|
|
1189
|
+
constructor(t) {
|
|
1190
|
+
const e = t ?? this.detectOnlineStatus();
|
|
1191
|
+
this.onlineSignal = Nt(e), this.canAttachListeners() && this.attachEventListeners();
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Returns true if the network is currently online
|
|
1195
|
+
*/
|
|
1196
|
+
get isOnline() {
|
|
1197
|
+
return this.manualOverride !== void 0 ? this.manualOverride : this.onlineSignal.value;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Manually set the network status (useful for testing)
|
|
1201
|
+
*/
|
|
1202
|
+
setNetworkStatus(t) {
|
|
1203
|
+
this.manualOverride = t, this.onlineSignal.value = t;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Clear manual override and return to automatic detection
|
|
1207
|
+
*/
|
|
1208
|
+
clearManualOverride() {
|
|
1209
|
+
this.manualOverride = void 0, this.onlineSignal.value = this.detectOnlineStatus();
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Get the reactive signal for online status
|
|
1213
|
+
* This allows reactive functions to depend on network status
|
|
1214
|
+
*/
|
|
1215
|
+
getOnlineSignal() {
|
|
1216
|
+
return this.onlineSignal;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Detect current online status from the environment
|
|
1220
|
+
*/
|
|
1221
|
+
detectOnlineStatus() {
|
|
1222
|
+
return typeof navigator < "u" && "onLine" in navigator ? navigator.onLine : !0;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Check if we can attach event listeners (browser or React Native)
|
|
1226
|
+
*/
|
|
1227
|
+
canAttachListeners() {
|
|
1228
|
+
return typeof window < "u" && typeof window.addEventListener == "function";
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Remove event listeners and clean up resources.
|
|
1232
|
+
*/
|
|
1233
|
+
destroy() {
|
|
1234
|
+
this.eventListenersAttached && this.handleOnline && this.handleOffline && (window.removeEventListener("online", this.handleOnline), window.removeEventListener("offline", this.handleOffline), this.eventListenersAttached = !1);
|
|
1235
|
+
}
|
|
1236
|
+
handleOnline = void 0;
|
|
1237
|
+
handleOffline = void 0;
|
|
1238
|
+
/**
|
|
1239
|
+
* Attach event listeners for online/offline events
|
|
1240
|
+
*/
|
|
1241
|
+
attachEventListeners() {
|
|
1242
|
+
this.eventListenersAttached || (this.handleOnline = () => {
|
|
1243
|
+
this.manualOverride === void 0 && (this.onlineSignal.value = !0);
|
|
1244
|
+
}, this.handleOffline = () => {
|
|
1245
|
+
this.manualOverride === void 0 && (this.onlineSignal.value = !1);
|
|
1246
|
+
}, window.addEventListener("online", this.handleOnline), window.addEventListener("offline", this.handleOffline), this.eventListenersAttached = !0);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
class ne {
|
|
1250
|
+
static onlineSignal = Nt(!0);
|
|
1251
|
+
get isOnline() {
|
|
1252
|
+
return !0;
|
|
1253
|
+
}
|
|
1254
|
+
setNetworkStatus(t) {
|
|
1255
|
+
}
|
|
1256
|
+
clearManualOverride() {
|
|
1257
|
+
}
|
|
1258
|
+
getOnlineSignal() {
|
|
1259
|
+
return ne.onlineSignal;
|
|
1260
|
+
}
|
|
1261
|
+
destroy() {
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
const un = new ee(), In = Mt(un);
|
|
1265
|
+
function gt(n, t = typeof window > "u") {
|
|
1266
|
+
let e;
|
|
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 };
|
|
1270
|
+
}
|
|
1271
|
+
class Nn {
|
|
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;
|
|
1278
|
+
params;
|
|
1279
|
+
config;
|
|
1280
|
+
constructor() {
|
|
1281
|
+
return jt(this);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
const Ot = /* @__PURE__ */ new WeakMap();
|
|
1285
|
+
class V {
|
|
1286
|
+
constructor(t, e) {
|
|
1287
|
+
this.captured = e, this.statics = t;
|
|
1288
|
+
}
|
|
1289
|
+
statics;
|
|
1290
|
+
createExecutionContext(t, e) {
|
|
1291
|
+
return et(this.captured, t, e);
|
|
1292
|
+
}
|
|
1293
|
+
resolveOptions(t) {
|
|
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 };
|
|
1296
|
+
}
|
|
1297
|
+
static for(t) {
|
|
1298
|
+
let e = Ot.get(t);
|
|
1299
|
+
if (e !== void 0)
|
|
1300
|
+
return e;
|
|
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,
|
|
1308
|
+
a.shape,
|
|
1309
|
+
void 0,
|
|
1310
|
+
void 0,
|
|
1311
|
+
r,
|
|
1312
|
+
// typenameValue — unique per query class
|
|
1313
|
+
Ft
|
|
1314
|
+
// idField — symbol, injected onto payload before parse
|
|
1315
|
+
);
|
|
1316
|
+
return e = new V(
|
|
1317
|
+
{ id: r, shape: v, cache: f, rawFetchNext: d, hasSendNext: y, isEntityResult: c, controllerClass: u },
|
|
1318
|
+
s
|
|
1319
|
+
), Ot.set(t, e), e;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
const Mn = (n, t) => {
|
|
1323
|
+
const e = V.for(n);
|
|
1324
|
+
return vt(e, t);
|
|
1325
|
+
};
|
|
1326
|
+
function kn(n, ...t) {
|
|
1327
|
+
const e = V.for(n), i = ge(bn);
|
|
1328
|
+
if (i === void 0)
|
|
1329
|
+
throw new Error("QueryClient not found");
|
|
1330
|
+
const s = t[0];
|
|
1331
|
+
return i.getQuery(e, s);
|
|
1332
|
+
}
|
|
1333
|
+
function ie(n, t) {
|
|
1334
|
+
return new Promise((e, i) => {
|
|
1335
|
+
if (t?.aborted) {
|
|
1336
|
+
i(t.reason);
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
const s = setTimeout(e, n);
|
|
1340
|
+
t?.addEventListener(
|
|
1341
|
+
"abort",
|
|
1342
|
+
() => {
|
|
1343
|
+
clearTimeout(s), i(t.reason);
|
|
1344
|
+
},
|
|
1345
|
+
{ once: !0 }
|
|
1346
|
+
);
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
async function rt(n, t, e) {
|
|
1350
|
+
const i = Math.max(0, t.retries);
|
|
1351
|
+
let s;
|
|
1352
|
+
for (let r = 0; r <= i; r++) {
|
|
1353
|
+
e?.throwIfAborted();
|
|
1354
|
+
try {
|
|
1355
|
+
return await n();
|
|
1356
|
+
} catch (o) {
|
|
1357
|
+
if (s = o, r >= i) throw o;
|
|
1358
|
+
await ie(t.retryDelay(r), e);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
throw s;
|
|
1362
|
+
}
|
|
1363
|
+
class ln {
|
|
1364
|
+
def;
|
|
1365
|
+
queryKey;
|
|
1366
|
+
storageKey = -1;
|
|
1367
|
+
/** The public-facing ReactivePromise returned to consumers. */
|
|
1368
|
+
relay;
|
|
1369
|
+
queryClient;
|
|
1370
|
+
initialized = !1;
|
|
1371
|
+
updatedAt = void 0;
|
|
1372
|
+
params = void 0;
|
|
1373
|
+
unsubscribe = void 0;
|
|
1374
|
+
_relayState = void 0;
|
|
1375
|
+
wasPaused = !1;
|
|
1376
|
+
currentParams = void 0;
|
|
1377
|
+
debounceTimer = void 0;
|
|
1378
|
+
/** Resolved per-instance options (depend on actual params). */
|
|
1379
|
+
config = void 0;
|
|
1380
|
+
retryConfig = gt(void 0);
|
|
1381
|
+
/** Controller for aborting in-flight fetches and retry waits. */
|
|
1382
|
+
_abortController = void 0;
|
|
1383
|
+
/** Cached execution context, recreated only when storageKey (params) changes. */
|
|
1384
|
+
_executionCtx = void 0;
|
|
1385
|
+
_executionCtxKey = -1;
|
|
1386
|
+
/** Root entity that holds parsed data, proxy, child refs, and bindings.
|
|
1387
|
+
* For entity results, this is undefined until the first apply discovers it. */
|
|
1388
|
+
rootEntity;
|
|
1389
|
+
/** Extra methods (__refetch, __fetchNext) attached to the root entity proxy. */
|
|
1390
|
+
_extraMethods = {};
|
|
1391
|
+
/** Query id injected as QUERY_ID on non-entity payloads. */
|
|
1392
|
+
_queryId = 0;
|
|
1393
|
+
get key() {
|
|
1394
|
+
return this.queryKey;
|
|
1395
|
+
}
|
|
1396
|
+
get relayState() {
|
|
1397
|
+
return this._relayState;
|
|
1398
|
+
}
|
|
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(
|
|
1403
|
+
(o) => {
|
|
1404
|
+
this._relayState = o;
|
|
1405
|
+
const a = () => {
|
|
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);
|
|
1409
|
+
}, c = (f = !1) => {
|
|
1410
|
+
const { wasPaused: d, isPaused: u, initialized: y } = this;
|
|
1411
|
+
if (this.wasPaused = u, u && !d && y) {
|
|
1412
|
+
a();
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
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());
|
|
1417
|
+
};
|
|
1418
|
+
return c(!0), {
|
|
1419
|
+
update: c,
|
|
1420
|
+
deactivate: a
|
|
1421
|
+
};
|
|
1422
|
+
},
|
|
1423
|
+
{ desc: `Query(${t.statics.id})` }
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
/** Apply raw data (fresh or cached) to the root entity and return the proxy. */
|
|
1427
|
+
applyData(t, e, i = !1, s) {
|
|
1428
|
+
const r = this.def;
|
|
1429
|
+
return this.rootEntity = this.queryClient.parseAndApplyRootEntity(
|
|
1430
|
+
t,
|
|
1431
|
+
this._queryId,
|
|
1432
|
+
r.statics.shape,
|
|
1433
|
+
e,
|
|
1434
|
+
i,
|
|
1435
|
+
s
|
|
1436
|
+
), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
|
|
1437
|
+
__hasNext: () => this.hasNext,
|
|
1438
|
+
__isFetchingNext: () => this._fetchNextPromise !== void 0
|
|
1439
|
+
}), this.rootEntity.getProxy(r.statics.shape);
|
|
1440
|
+
}
|
|
1441
|
+
/** Save query metadata (the __entityRef pointer, updatedAt, ref set). */
|
|
1442
|
+
saveQueryMetadata() {
|
|
1443
|
+
if (this.rootEntity === void 0 || this.updatedAt === void 0) return;
|
|
1444
|
+
const t = new Map(this.rootEntity.entityRefs ?? []);
|
|
1445
|
+
t.set(this.rootEntity, 1), this.queryClient.saveQueryData(
|
|
1446
|
+
this.def,
|
|
1447
|
+
this.storageKey,
|
|
1448
|
+
{ __entityRef: this.rootEntity.key },
|
|
1449
|
+
this.updatedAt,
|
|
1450
|
+
t
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
async initialize() {
|
|
1454
|
+
const t = this.queryClient, e = this.relayState;
|
|
1455
|
+
this.initialized = !0;
|
|
1456
|
+
let i;
|
|
1457
|
+
try {
|
|
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));
|
|
1459
|
+
} catch (s) {
|
|
1460
|
+
t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid", s);
|
|
1461
|
+
}
|
|
1462
|
+
if (!this.isPaused)
|
|
1463
|
+
try {
|
|
1464
|
+
if (i !== void 0 && this.setupSubscription(), i === void 0 || this.isStale) {
|
|
1465
|
+
if (await ie(0), this.isPaused) return;
|
|
1466
|
+
this.runQueryImmediately();
|
|
1467
|
+
}
|
|
1468
|
+
} catch (s) {
|
|
1469
|
+
e.setError(s);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
setupSubscription() {
|
|
1473
|
+
this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1474
|
+
const t = this.config?.subscribe;
|
|
1475
|
+
if (!t) return;
|
|
1476
|
+
const e = this._executionCtx;
|
|
1477
|
+
this.unsubscribe = t.call(e, (i) => {
|
|
1478
|
+
i.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(i);
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
getOrCreateExecutionContext() {
|
|
1482
|
+
return (this._executionCtx === void 0 || this._executionCtxKey !== this.storageKey) && (this._executionCtxKey = this.storageKey, this._executionCtx = this.def.createExecutionContext(
|
|
1483
|
+
this.currentParams ?? {},
|
|
1484
|
+
this.queryClient.getContext()
|
|
1485
|
+
), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext), this.resolveAndApplyOptions(), this._executionCtx;
|
|
1486
|
+
}
|
|
1487
|
+
resolveAndApplyOptions() {
|
|
1488
|
+
const t = this.def.resolveOptions(this._executionCtx);
|
|
1489
|
+
this.config = t.config, this.retryConfig = t.retryConfig;
|
|
1490
|
+
}
|
|
1491
|
+
async runQuery() {
|
|
1492
|
+
const t = this.def;
|
|
1493
|
+
if (this.isPaused)
|
|
1494
|
+
throw new Error("Query is paused due to network status");
|
|
1495
|
+
const e = this.getOrCreateExecutionContext(), i = this.queryClient.getController(t.statics.controllerClass), s = this._abortController?.signal ?? new AbortController().signal;
|
|
1496
|
+
return rt(
|
|
1497
|
+
async () => {
|
|
1498
|
+
const r = await i.send(e, s);
|
|
1499
|
+
this.updatedAt = Date.now();
|
|
1500
|
+
const o = this.applyData(r, !0);
|
|
1501
|
+
return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
|
|
1502
|
+
},
|
|
1503
|
+
this.retryConfig,
|
|
1504
|
+
s
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
runQueryImmediately() {
|
|
1508
|
+
this._abortController?.abort(), this._abortController = new AbortController(), this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.relayState.setPromise(this.runQuery());
|
|
1509
|
+
}
|
|
1510
|
+
runDebounced() {
|
|
1511
|
+
if (this.relayState.isPending) return;
|
|
1512
|
+
const t = this.config?.debounce ?? 0;
|
|
1513
|
+
clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(() => {
|
|
1514
|
+
this.debounceTimer = void 0, this.runQueryImmediately();
|
|
1515
|
+
}, t);
|
|
1516
|
+
}
|
|
1517
|
+
// ======================================================
|
|
1518
|
+
// Public methods
|
|
1519
|
+
// ======================================================
|
|
1520
|
+
refetch = () => this.relayState.isPending ? this.relay : (this.runQueryImmediately(), this.relay);
|
|
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 = () => {
|
|
1532
|
+
if (this.updatedAt === void 0)
|
|
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),
|
|
1536
|
+
(t) => {
|
|
1537
|
+
throw this._fetchNextPromise = void 0, this.rootEntity?.notify(), t;
|
|
1538
|
+
}
|
|
1539
|
+
), this._fetchNextPromise);
|
|
1540
|
+
};
|
|
1541
|
+
get hasNext() {
|
|
1542
|
+
if (this.rootEntity === void 0 || !this._executionCtx) return !1;
|
|
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;
|
|
1545
|
+
}
|
|
1546
|
+
async runFetchNext() {
|
|
1547
|
+
const t = this.def;
|
|
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);
|
|
1552
|
+
return rt(
|
|
1553
|
+
async () => {
|
|
1554
|
+
const r = await s.sendNext(i, e);
|
|
1555
|
+
this.updatedAt = Date.now();
|
|
1556
|
+
const o = this.applyData(r, !0, !0);
|
|
1557
|
+
return this.saveQueryMetadata(), o;
|
|
1558
|
+
},
|
|
1559
|
+
this.retryConfig,
|
|
1560
|
+
e
|
|
1561
|
+
);
|
|
1562
|
+
}
|
|
1563
|
+
// ======================================================
|
|
1564
|
+
// Internal computed properties
|
|
1565
|
+
// ======================================================
|
|
1566
|
+
get isStale() {
|
|
1567
|
+
if (this.updatedAt === void 0)
|
|
1568
|
+
return !0;
|
|
1569
|
+
const t = this.config?.staleTime ?? 0;
|
|
1570
|
+
return Date.now() - this.updatedAt >= t;
|
|
1571
|
+
}
|
|
1572
|
+
get isPaused() {
|
|
1573
|
+
const t = this.config?.networkMode ?? L.Online;
|
|
1574
|
+
if (t === L.Always)
|
|
1575
|
+
return !1;
|
|
1576
|
+
const e = this.queryClient.networkManager.getOnlineSignal().value;
|
|
1577
|
+
switch (t) {
|
|
1578
|
+
case L.Online:
|
|
1579
|
+
return !e;
|
|
1580
|
+
case L.OfflineFirst:
|
|
1581
|
+
return !e && this.updatedAt === void 0;
|
|
1582
|
+
default:
|
|
1583
|
+
return !1;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
class dn {
|
|
1588
|
+
def;
|
|
1589
|
+
queryClient;
|
|
1590
|
+
_inFlight = !1;
|
|
1591
|
+
task;
|
|
1592
|
+
constructor(t, e) {
|
|
1593
|
+
this.def = t, this.queryClient = e, this.task = this.createTask();
|
|
1594
|
+
}
|
|
1595
|
+
createTask() {
|
|
1596
|
+
return ve(
|
|
1597
|
+
async (t) => {
|
|
1598
|
+
if (this._inFlight)
|
|
1599
|
+
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
1600
|
+
this._inFlight = !0;
|
|
1601
|
+
try {
|
|
1602
|
+
const e = await this.executeWithRetry(t), i = this.validateResponse(e);
|
|
1603
|
+
return this.processEffects(t, i), i;
|
|
1604
|
+
} finally {
|
|
1605
|
+
this._inFlight = !1;
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
{ desc: `Mutation(${this.def.id})` }
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
validateResponse(t) {
|
|
1612
|
+
const e = this.def.responseShape;
|
|
1613
|
+
if (!(e instanceof _))
|
|
1614
|
+
return t;
|
|
1615
|
+
const i = this.queryClient.getContext().log?.warn ?? (() => {
|
|
1616
|
+
}), s = new st();
|
|
1617
|
+
return s.reset(void 0, void 0, i), Jt(t, e, s);
|
|
1618
|
+
}
|
|
1619
|
+
// ======================================================
|
|
1620
|
+
// Effects processing
|
|
1621
|
+
// ======================================================
|
|
1622
|
+
processEffects(t, e) {
|
|
1623
|
+
let i;
|
|
1624
|
+
if (this.def.hasGetEffects) {
|
|
1625
|
+
const r = et(
|
|
1626
|
+
this.def.captured,
|
|
1627
|
+
t ?? {},
|
|
1628
|
+
this.queryClient.getContext()
|
|
1629
|
+
);
|
|
1630
|
+
r.result = e, i = r.getEffects();
|
|
1631
|
+
} else if (this.def.effects !== void 0) {
|
|
1632
|
+
const r = { params: t, result: e };
|
|
1633
|
+
i = W(this.def.effects, r);
|
|
1634
|
+
}
|
|
1635
|
+
if (i === void 0) return;
|
|
1636
|
+
const s = this.queryClient;
|
|
1637
|
+
Z(i.creates, "create", s), Z(i.updates, "update", s), Z(i.deletes, "delete", s), i.invalidates && s.invalidateQueries(i.invalidates);
|
|
1638
|
+
}
|
|
1639
|
+
// ======================================================
|
|
1640
|
+
// Retry logic
|
|
1641
|
+
// ======================================================
|
|
1642
|
+
executeWithRetry(t) {
|
|
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
|
+
);
|
|
1648
|
+
return rt(async () => {
|
|
1649
|
+
const s = new AbortController(), r = et(
|
|
1650
|
+
this.def.captured,
|
|
1651
|
+
t ?? {},
|
|
1652
|
+
this.queryClient.getContext()
|
|
1653
|
+
);
|
|
1654
|
+
return await i.sendMutation(r, s.signal);
|
|
1655
|
+
}, e);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function hn(n) {
|
|
1659
|
+
return typeof n == "string" ? n : T(n).typenameValue;
|
|
1660
|
+
}
|
|
1661
|
+
function Z(n, t, e) {
|
|
1662
|
+
if (n)
|
|
1663
|
+
for (const [i, s] of n) {
|
|
1664
|
+
const r = hn(i);
|
|
1665
|
+
r !== void 0 && e.applyMutationEvent({ type: t, typename: r, data: s });
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
const se = "__eventSource";
|
|
1669
|
+
function re(n) {
|
|
1670
|
+
return { field: n, segments: n.indexOf(".") !== -1 ? n.split(".") : void 0 };
|
|
1671
|
+
}
|
|
1672
|
+
function yn(n) {
|
|
1673
|
+
return n.map(re);
|
|
1674
|
+
}
|
|
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) {
|
|
1679
|
+
if (e == null) return;
|
|
1680
|
+
e = e[i];
|
|
1681
|
+
}
|
|
1682
|
+
return e;
|
|
1683
|
+
}
|
|
1684
|
+
function oe(n, t) {
|
|
1685
|
+
const e = [];
|
|
1686
|
+
for (let i = 0; i < t.length; i++) {
|
|
1687
|
+
const s = t[i], r = pn(n, s);
|
|
1688
|
+
if (r === void 0) return;
|
|
1689
|
+
e.push(s.field, r);
|
|
1690
|
+
}
|
|
1691
|
+
return D(e);
|
|
1692
|
+
}
|
|
1693
|
+
function gn(n, t) {
|
|
1694
|
+
if (n === void 0) return;
|
|
1695
|
+
const e = /* @__PURE__ */ new Map();
|
|
1696
|
+
for (const [i, s] of n) {
|
|
1697
|
+
const r = s.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
|
|
1698
|
+
let a = !0;
|
|
1699
|
+
for (const [c, f] of r) {
|
|
1700
|
+
let d;
|
|
1701
|
+
if (Pt(f)) {
|
|
1702
|
+
const u = Lt(f);
|
|
1703
|
+
d = ut(u, t);
|
|
1704
|
+
} else
|
|
1705
|
+
d = f;
|
|
1706
|
+
if (d === void 0) {
|
|
1707
|
+
a = !1;
|
|
1708
|
+
break;
|
|
1709
|
+
}
|
|
1710
|
+
o.push(c, d);
|
|
1711
|
+
}
|
|
1712
|
+
a && e.set(i, D(o));
|
|
1713
|
+
}
|
|
1714
|
+
return e.size > 0 ? e : void 0;
|
|
1715
|
+
}
|
|
1716
|
+
function Rt(n, t) {
|
|
1717
|
+
const e = n.get(t);
|
|
1718
|
+
if (e !== void 0)
|
|
1719
|
+
return e.map(([i]) => i).sort();
|
|
1720
|
+
}
|
|
1721
|
+
class vn {
|
|
1722
|
+
fields;
|
|
1723
|
+
fieldPaths;
|
|
1724
|
+
_bindings = /* @__PURE__ */ new Map();
|
|
1725
|
+
constructor(t) {
|
|
1726
|
+
this.fields = t, this.fieldPaths = t.map(re);
|
|
1727
|
+
}
|
|
1728
|
+
register(t, e) {
|
|
1729
|
+
let i = this._bindings.get(t);
|
|
1730
|
+
i === void 0 && (i = /* @__PURE__ */ new Set(), this._bindings.set(t, i)), i.add(e);
|
|
1731
|
+
}
|
|
1732
|
+
unregister(t, e) {
|
|
1733
|
+
const i = this._bindings.get(t);
|
|
1734
|
+
i !== void 0 && (i.delete(e), i.size === 0 && this._bindings.delete(t));
|
|
1735
|
+
}
|
|
1736
|
+
getMatching(t) {
|
|
1737
|
+
return this._bindings.get(t);
|
|
1738
|
+
}
|
|
1739
|
+
get isEmpty() {
|
|
1740
|
+
return this._bindings.size === 0;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
function St(n) {
|
|
1744
|
+
return D(n);
|
|
1745
|
+
}
|
|
1746
|
+
class _n {
|
|
1747
|
+
_groups = /* @__PURE__ */ new Map();
|
|
1748
|
+
getOrCreateGroup(t) {
|
|
1749
|
+
const e = St(t);
|
|
1750
|
+
let i = this._groups.get(e);
|
|
1751
|
+
return i === void 0 && (i = new vn(t), this._groups.set(e, i)), i;
|
|
1752
|
+
}
|
|
1753
|
+
register(t, e, i) {
|
|
1754
|
+
this.getOrCreateGroup(e).register(t, i);
|
|
1755
|
+
}
|
|
1756
|
+
unregister(t, e, i) {
|
|
1757
|
+
const s = St(e), r = this._groups.get(s);
|
|
1758
|
+
r !== void 0 && (r.unregister(t, i), r.isEmpty && this._groups.delete(s));
|
|
1759
|
+
}
|
|
1760
|
+
registerBinding(t, e) {
|
|
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);
|
|
1765
|
+
}
|
|
1766
|
+
unregisterBinding(t, e) {
|
|
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);
|
|
1771
|
+
}
|
|
1772
|
+
routeEvent(t, e, i, s, r, o) {
|
|
1773
|
+
for (const a of this._groups.values()) {
|
|
1774
|
+
const c = oe(e, a.fieldPaths);
|
|
1775
|
+
if (c === void 0) continue;
|
|
1776
|
+
const f = a.getMatching(c);
|
|
1777
|
+
if (f !== void 0)
|
|
1778
|
+
for (const d of f)
|
|
1779
|
+
d.onEvent(t, i, s, r, o);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
function At(n) {
|
|
1784
|
+
const t = /* @__PURE__ */ new Set();
|
|
1785
|
+
for (const e of n)
|
|
1786
|
+
if (typeof e == "object" && e !== null) {
|
|
1787
|
+
const i = k(e);
|
|
1788
|
+
i !== void 0 && t.add(i);
|
|
1789
|
+
}
|
|
1790
|
+
return t;
|
|
1791
|
+
}
|
|
1792
|
+
class ae {
|
|
1793
|
+
_queryClient;
|
|
1794
|
+
_parent;
|
|
1795
|
+
_constraintHashes;
|
|
1796
|
+
_entityDefsByTypename;
|
|
1797
|
+
_constraintFieldRefs;
|
|
1798
|
+
instance;
|
|
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();
|
|
1801
|
+
for (const a of t)
|
|
1802
|
+
a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
|
|
1803
|
+
J.add(this);
|
|
1804
|
+
}
|
|
1805
|
+
getValue() {
|
|
1806
|
+
return this.instance.getValue();
|
|
1807
|
+
}
|
|
1808
|
+
toJSON() {
|
|
1809
|
+
return this.instance.getRawValue();
|
|
1810
|
+
}
|
|
1811
|
+
reset(t) {
|
|
1812
|
+
this.instance.reset(t);
|
|
1813
|
+
}
|
|
1814
|
+
append(t) {
|
|
1815
|
+
this.instance.append(t);
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Handle an entity event. The entity has already been created/updated at the
|
|
1819
|
+
* root level by applyMutationEvent. The binding just checks if the entity's
|
|
1820
|
+
* current data satisfies this binding's shape and forwards to the instance.
|
|
1821
|
+
*/
|
|
1822
|
+
onEvent(t, e, i, s, r) {
|
|
1823
|
+
const o = this._entityDefsByTypename.get(t);
|
|
1824
|
+
if (o === void 0) return;
|
|
1825
|
+
const a = this._queryClient.entityMap.getEntity(e);
|
|
1826
|
+
if (i === "delete") {
|
|
1827
|
+
const f = a !== void 0 ? a.getProxy(o) : r;
|
|
1828
|
+
f !== void 0 && (this.instance.onEvent(e, f, r ?? a?.data ?? {}, "delete"), s?.());
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
if (a === void 0 || !a.satisfiesDef(o)) return;
|
|
1832
|
+
s?.();
|
|
1833
|
+
const c = a.getProxy(o);
|
|
1834
|
+
this.instance.onEvent(e, c, a.data, i);
|
|
1835
|
+
}
|
|
1836
|
+
destroy() {
|
|
1837
|
+
this._queryClient.unregisterLiveCollection(this);
|
|
1838
|
+
const t = this._parent.liveCollections, e = t.indexOf(this);
|
|
1839
|
+
e !== -1 && t.splice(e, 1);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
class mn {
|
|
1843
|
+
_notifier;
|
|
1844
|
+
_items;
|
|
1845
|
+
_keys;
|
|
1846
|
+
_outputSignal;
|
|
1847
|
+
_queryClient;
|
|
1848
|
+
_parent;
|
|
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;
|
|
1851
|
+
const a = s !== void 0 && r !== void 0, c = o !== void 0;
|
|
1852
|
+
(a || c) && (this._outputSignal = _e(() => {
|
|
1853
|
+
this._notifier.consume();
|
|
1854
|
+
let f = this._items;
|
|
1855
|
+
if (a) {
|
|
1856
|
+
const d = [];
|
|
1857
|
+
for (const u of f) {
|
|
1858
|
+
if (typeof u != "object" || u === null) {
|
|
1859
|
+
d.push(u);
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
const y = k(u);
|
|
1863
|
+
if (y === void 0) {
|
|
1864
|
+
d.push(u);
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1867
|
+
const v = t.entityMap.getEntity(y);
|
|
1868
|
+
if (v === void 0) {
|
|
1869
|
+
d.push(u);
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
v.consume(), oe(v.data, s) === r && d.push(u);
|
|
1873
|
+
}
|
|
1874
|
+
f = d;
|
|
1875
|
+
}
|
|
1876
|
+
return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
|
|
1877
|
+
}));
|
|
1878
|
+
}
|
|
1879
|
+
onEvent(t, e, i, s) {
|
|
1880
|
+
switch (s) {
|
|
1881
|
+
case "create":
|
|
1882
|
+
this.add(t, e);
|
|
1883
|
+
break;
|
|
1884
|
+
case "update":
|
|
1885
|
+
!this.has(t) && e !== void 0 && this.add(t, e);
|
|
1886
|
+
break;
|
|
1887
|
+
case "delete":
|
|
1888
|
+
this.remove(t);
|
|
1889
|
+
break;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
getValue() {
|
|
1893
|
+
return this._outputSignal !== void 0 ? this._outputSignal.value : (this._notifier.consume(), this._items);
|
|
1894
|
+
}
|
|
1895
|
+
getRawValue() {
|
|
1896
|
+
return this._items;
|
|
1897
|
+
}
|
|
1898
|
+
add(t, e) {
|
|
1899
|
+
if (this._keys.has(t)) return !1;
|
|
1900
|
+
this._keys.add(t), this._items.push(e);
|
|
1901
|
+
const i = this._queryClient.entityMap.getEntity(t);
|
|
1902
|
+
return i !== void 0 && (this._parent.addChildRef(i), i.save()), this._notifier.notify(), !0;
|
|
1903
|
+
}
|
|
1904
|
+
remove(t) {
|
|
1905
|
+
if (!this._keys.has(t)) return !1;
|
|
1906
|
+
this._keys.delete(t);
|
|
1907
|
+
const e = this._findIndex(t);
|
|
1908
|
+
e !== -1 && this._items.splice(e, 1);
|
|
1909
|
+
const i = this._queryClient.entityMap.getEntity(t);
|
|
1910
|
+
return i !== void 0 && this._parent.removeChildRef(i), this._notifier.notify(), !0;
|
|
1911
|
+
}
|
|
1912
|
+
has(t) {
|
|
1913
|
+
return this._keys.has(t);
|
|
1914
|
+
}
|
|
1915
|
+
reset(t) {
|
|
1916
|
+
const e = this._items, i = Array.isArray(t) ? t : [];
|
|
1917
|
+
this._items = i, this._keys = At(i);
|
|
1918
|
+
for (const s of i)
|
|
1919
|
+
if (typeof s == "object" && s !== null) {
|
|
1920
|
+
const r = k(s);
|
|
1921
|
+
if (r !== void 0) {
|
|
1922
|
+
const o = this._queryClient.entityMap.getEntity(r);
|
|
1923
|
+
o !== void 0 && this._parent.addChildRef(o);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
for (const s of e)
|
|
1927
|
+
if (typeof s == "object" && s !== null) {
|
|
1928
|
+
const r = k(s);
|
|
1929
|
+
if (r !== void 0) {
|
|
1930
|
+
const o = this._queryClient.entityMap.getEntity(r);
|
|
1931
|
+
o !== void 0 && this._parent.removeChildRef(o);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
this._notifier.notify();
|
|
1935
|
+
}
|
|
1936
|
+
append(t) {
|
|
1937
|
+
if (Array.isArray(t))
|
|
1938
|
+
for (const e of t) {
|
|
1939
|
+
if (typeof e != "object" || e === null) continue;
|
|
1940
|
+
const i = k(e);
|
|
1941
|
+
i !== void 0 && this.add(i, e);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
_findIndex(t) {
|
|
1945
|
+
for (let e = 0; e < this._items.length; e++) {
|
|
1946
|
+
const i = this._items[e];
|
|
1947
|
+
if (typeof i == "object" && i !== null && k(i) === t)
|
|
1948
|
+
return e;
|
|
1949
|
+
}
|
|
1950
|
+
return -1;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
class wn {
|
|
1954
|
+
_notifier;
|
|
1955
|
+
_value;
|
|
1956
|
+
_createdKeys;
|
|
1957
|
+
_deletedKeys;
|
|
1958
|
+
_queryClient;
|
|
1959
|
+
_parent;
|
|
1960
|
+
_onCreate;
|
|
1961
|
+
_onUpdate;
|
|
1962
|
+
_onDelete;
|
|
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;
|
|
1965
|
+
}
|
|
1966
|
+
onEvent(t, e, i, s) {
|
|
1967
|
+
switch (s) {
|
|
1968
|
+
case "create":
|
|
1969
|
+
if (this._createdKeys.has(t)) return;
|
|
1970
|
+
this._createdKeys.add(t), this._value = this._onCreate(this._value, e);
|
|
1971
|
+
break;
|
|
1972
|
+
case "update":
|
|
1973
|
+
this._value = this._onUpdate(this._value, e ?? i);
|
|
1974
|
+
break;
|
|
1975
|
+
case "delete":
|
|
1976
|
+
if (this._deletedKeys.has(t)) return;
|
|
1977
|
+
this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ?? i);
|
|
1978
|
+
break;
|
|
1979
|
+
}
|
|
1980
|
+
this._notifier.notify();
|
|
1981
|
+
}
|
|
1982
|
+
getValue() {
|
|
1983
|
+
return this._notifier.consume(), this._value;
|
|
1984
|
+
}
|
|
1985
|
+
getRawValue() {
|
|
1986
|
+
return this._value;
|
|
1987
|
+
}
|
|
1988
|
+
reset(t) {
|
|
1989
|
+
this._value = t, this._createdKeys.clear(), this._deletedKeys.clear(), this._notifier.notify();
|
|
1990
|
+
}
|
|
1991
|
+
append(t) {
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
function ce(n, t, e, i, s) {
|
|
1995
|
+
let r = n.constraintFieldRefs;
|
|
1996
|
+
if (r === void 0) {
|
|
1997
|
+
r = /* @__PURE__ */ new Map();
|
|
1998
|
+
for (const f of n.entityDefs) {
|
|
1999
|
+
const d = f.typenameValue;
|
|
2000
|
+
d !== void 0 && r.set(d, [[se, e.key]]);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
const o = gn(r, i) ?? /* @__PURE__ */ new Map();
|
|
2004
|
+
let a;
|
|
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);
|
|
2010
|
+
if (y !== void 0) {
|
|
2011
|
+
d = y;
|
|
2012
|
+
const v = n.constraintFieldRefs.get(u);
|
|
2013
|
+
v !== void 0 && (f = yn(v.map(([p]) => p)));
|
|
2014
|
+
break;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
a = new mn(
|
|
2018
|
+
s,
|
|
2019
|
+
e,
|
|
2020
|
+
Array.isArray(t) ? t : [],
|
|
2021
|
+
f,
|
|
2022
|
+
d,
|
|
2023
|
+
n.sort
|
|
2024
|
+
);
|
|
2025
|
+
} else
|
|
2026
|
+
a = new wn(
|
|
2027
|
+
s,
|
|
2028
|
+
e,
|
|
2029
|
+
t,
|
|
2030
|
+
n.onCreate,
|
|
2031
|
+
n.onUpdate,
|
|
2032
|
+
n.onDelete
|
|
2033
|
+
);
|
|
2034
|
+
const c = new ae(
|
|
2035
|
+
n.entityDefs,
|
|
2036
|
+
r,
|
|
2037
|
+
s,
|
|
2038
|
+
e,
|
|
2039
|
+
o,
|
|
2040
|
+
a
|
|
2041
|
+
);
|
|
2042
|
+
return e.liveCollections.push(c), s.registerLiveCollection(c), c;
|
|
2043
|
+
}
|
|
2044
|
+
const fe = Object.entries, ue = Object.prototype;
|
|
2045
|
+
function tt(n, t, e, i = !1) {
|
|
2046
|
+
const s = n.queryClient;
|
|
2047
|
+
s.currentParseId++;
|
|
2048
|
+
const r = n.seen, o = /* @__PURE__ */ new Map();
|
|
2049
|
+
return { data: U(t, r, s, e, o, i), entityRefs: o };
|
|
2050
|
+
}
|
|
2051
|
+
function U(n, t, e, i, s, r) {
|
|
2052
|
+
if (typeof n != "object" || n === null) return n;
|
|
2053
|
+
const o = t.get(n);
|
|
2054
|
+
if (o !== void 0)
|
|
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));
|
|
2060
|
+
}
|
|
2061
|
+
return n;
|
|
2062
|
+
}
|
|
2063
|
+
if (Object.getPrototypeOf(n) === ue && !x.has(n)) {
|
|
2064
|
+
const a = n;
|
|
2065
|
+
for (const c of Object.keys(a)) {
|
|
2066
|
+
const f = a[c];
|
|
2067
|
+
typeof f == "object" && f !== null && !(f instanceof q) && !x.has(f) && (a[c] = U(f, t, e, i, s, r));
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
return n;
|
|
2071
|
+
}
|
|
2072
|
+
function le(n) {
|
|
2073
|
+
return typeof n == "object" && n !== null && !(n instanceof q) && !x.has(n);
|
|
2074
|
+
}
|
|
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,
|
|
2079
|
+
a,
|
|
2080
|
+
y,
|
|
2081
|
+
f,
|
|
2082
|
+
u,
|
|
2083
|
+
y,
|
|
2084
|
+
t,
|
|
2085
|
+
e,
|
|
2086
|
+
i,
|
|
2087
|
+
p,
|
|
2088
|
+
r
|
|
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);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
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(
|
|
2111
|
+
y._liveConfig,
|
|
2112
|
+
t[u],
|
|
2113
|
+
s,
|
|
2114
|
+
r,
|
|
2115
|
+
a
|
|
2116
|
+
);
|
|
2117
|
+
} else {
|
|
2118
|
+
const v = t[u], p = e[u];
|
|
2119
|
+
if (ot(v) && ot(p)) {
|
|
2120
|
+
const g = y instanceof _ && y.shape !== void 0 ? y.shape : void 0;
|
|
2121
|
+
if (g !== void 0)
|
|
2122
|
+
de(
|
|
2123
|
+
g,
|
|
2124
|
+
v,
|
|
2125
|
+
p,
|
|
2126
|
+
void 0,
|
|
2127
|
+
s,
|
|
2128
|
+
r,
|
|
2129
|
+
o,
|
|
2130
|
+
a,
|
|
2131
|
+
c,
|
|
2132
|
+
f,
|
|
2133
|
+
d
|
|
2134
|
+
);
|
|
2135
|
+
else
|
|
2136
|
+
for (const w of Object.keys(v))
|
|
2137
|
+
p[w] = v[w];
|
|
2138
|
+
e[u] = p;
|
|
2139
|
+
} else
|
|
2140
|
+
e[u] = v;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
function he(n, t, e, i, s, r, o, a, c) {
|
|
2144
|
+
for (const [f, d] of fe(n))
|
|
2145
|
+
if (f in t)
|
|
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,
|
|
2149
|
+
t[f],
|
|
2150
|
+
e,
|
|
2151
|
+
i,
|
|
2152
|
+
r
|
|
2153
|
+
);
|
|
2154
|
+
else {
|
|
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);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
function ot(n) {
|
|
2163
|
+
return typeof n == "object" && n !== null && !Array.isArray(n) && Object.getPrototypeOf(n) === ue && !x.has(n);
|
|
2164
|
+
}
|
|
2165
|
+
function Fn(n) {
|
|
2166
|
+
if (n !== void 0)
|
|
2167
|
+
return typeof n == "string" ? n : typeof n == "function" ? n() : n.value;
|
|
2168
|
+
}
|
|
2169
|
+
function Cn(n) {
|
|
2170
|
+
return me(n);
|
|
2171
|
+
}
|
|
2172
|
+
function Dt(n) {
|
|
2173
|
+
if (n === void 0)
|
|
2174
|
+
return;
|
|
2175
|
+
const t = {};
|
|
2176
|
+
for (const [e, i] of Object.entries(n))
|
|
2177
|
+
Cn(i) ? t[e] = i.value : t[e] = i;
|
|
2178
|
+
return t;
|
|
2179
|
+
}
|
|
2180
|
+
const vt = (n, t) => D([n.statics.id, t]);
|
|
2181
|
+
class Tn {
|
|
2182
|
+
entityMap;
|
|
2183
|
+
queryInstances = /* @__PURE__ */ new Map();
|
|
2184
|
+
mutationInstances = /* @__PURE__ */ new Map();
|
|
2185
|
+
gcManager;
|
|
2186
|
+
networkManager;
|
|
2187
|
+
isServer;
|
|
2188
|
+
store;
|
|
2189
|
+
currentParseId = 0;
|
|
2190
|
+
context;
|
|
2191
|
+
typenameRegistry = /* @__PURE__ */ new Map();
|
|
2192
|
+
constraintRegistry = /* @__PURE__ */ new Map();
|
|
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
|
+
}
|
|
2237
|
+
getContext() {
|
|
2238
|
+
return this.context;
|
|
2239
|
+
}
|
|
2240
|
+
// ======================================================
|
|
2241
|
+
// Typename Registry (per-client)
|
|
2242
|
+
// ======================================================
|
|
2243
|
+
registerEntityDef(t) {
|
|
2244
|
+
const e = t.typenameValue;
|
|
2245
|
+
if (e === void 0 || t._entityClass === void 0) return;
|
|
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);
|
|
2250
|
+
} else
|
|
2251
|
+
this.typenameRegistry.set(e, [t]);
|
|
2252
|
+
}
|
|
2253
|
+
getEntityDefsForTypename(t) {
|
|
2254
|
+
return this.typenameRegistry.get(t);
|
|
2255
|
+
}
|
|
2256
|
+
getMergedDef(t) {
|
|
2257
|
+
let e = this.mergedDefCache.get(t);
|
|
2258
|
+
if (e !== void 0) return e;
|
|
2259
|
+
const i = this.typenameRegistry.get(t);
|
|
2260
|
+
if (i !== void 0)
|
|
2261
|
+
return e = _.merge(i), this.mergedDefCache.set(t, e), e;
|
|
2262
|
+
}
|
|
2263
|
+
saveQueryData(t, e, i, s, r) {
|
|
2264
|
+
const o = r !== void 0 && r.size > 0 ? new Set([...r.keys()].map((a) => a.key)) : void 0;
|
|
2265
|
+
this.store.saveQuery(t, e, i, s, o);
|
|
2266
|
+
}
|
|
2267
|
+
activateQuery(t) {
|
|
2268
|
+
const { def: e, queryKey: i, storageKey: s, config: r } = t;
|
|
2269
|
+
this.store.activateQuery(e, s);
|
|
2270
|
+
const o = r?.gcTime ?? kt;
|
|
2271
|
+
this.gcManager.cancel(i, o);
|
|
2272
|
+
}
|
|
2273
|
+
loadCachedQuery(t, e) {
|
|
2274
|
+
return this.store.loadQuery(t, e);
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Loads a query from the document store and returns a QueryResult
|
|
2278
|
+
* that triggers fetches and prepopulates with cached data
|
|
2279
|
+
*/
|
|
2280
|
+
getQuery(t, e) {
|
|
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;
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Gets or creates a MutationResult for the given mutation definition.
|
|
2287
|
+
* Mutations are cached by their definition ID.
|
|
2288
|
+
*/
|
|
2289
|
+
getMutation(t) {
|
|
2290
|
+
const e = t.id;
|
|
2291
|
+
let i = this.mutationInstances.get(e);
|
|
2292
|
+
return i === void 0 && (i = new dn(t, this), this.mutationInstances.set(e, i)), i.task;
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Parse data: validates, formats, produces parsed entity data objects.
|
|
2296
|
+
* Does NOT touch the entity store. Call applyRefs() after to commit entities.
|
|
2297
|
+
*/
|
|
2298
|
+
parseData(t, e, i) {
|
|
2299
|
+
const s = this.context.log?.warn ?? (() => {
|
|
2300
|
+
}), r = new st();
|
|
2301
|
+
return r.reset(this, i, s), { data: Jt(t, e, r), ctx: r };
|
|
2302
|
+
}
|
|
2303
|
+
/**
|
|
2304
|
+
* Apply entities from parseData() via a single depth-first walk: creates/
|
|
2305
|
+
* updates EntityInstances, replaces parsed data with proxies, counts child
|
|
2306
|
+
* refs. Returns the reified data and root-level entity refs.
|
|
2307
|
+
*/
|
|
2308
|
+
applyRefs(t, e = !0, i = !1) {
|
|
2309
|
+
return tt(t.ctx, t.data, e, i);
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Parse and apply data as a root entity. For non-entity results, injects
|
|
2313
|
+
* QUERY_ID onto the payload. Returns the root EntityInstance (created or
|
|
2314
|
+
* found in the store by the standard entity pipeline).
|
|
2315
|
+
*/
|
|
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);
|
|
2319
|
+
return this.entityMap.getEntity(f);
|
|
2320
|
+
}
|
|
2321
|
+
prepareEntity(t, e, i) {
|
|
2322
|
+
return this.registerEntityDef(i), this.entityMap.getOrCreateEntity(t, e, i, this);
|
|
2323
|
+
}
|
|
2324
|
+
// ======================================================
|
|
2325
|
+
// Mutation Events
|
|
2326
|
+
// ======================================================
|
|
2327
|
+
applyMutationEvent(t) {
|
|
2328
|
+
const { type: e, typename: i } = t, s = this.getMergedDef(i);
|
|
2329
|
+
if (s === void 0) return;
|
|
2330
|
+
const r = s.idField;
|
|
2331
|
+
if (r === void 0 || typeof r == "symbol") return;
|
|
2332
|
+
const o = t.data, a = t.id !== void 0 ? t.id : e === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[r];
|
|
2333
|
+
if (a === void 0) return;
|
|
2334
|
+
const c = D([i, a]), f = t.__eventSource, d = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
|
|
2335
|
+
if (e === "delete") {
|
|
2336
|
+
const g = u !== void 0 ? u.data : d;
|
|
2337
|
+
this.routeEvent(i, g, c, e, f, void 0, g);
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
try {
|
|
2341
|
+
const g = this.context.log?.warn ?? (() => {
|
|
2342
|
+
}), w = new st();
|
|
2343
|
+
w.reset(
|
|
2344
|
+
this,
|
|
2345
|
+
void 0,
|
|
2346
|
+
g,
|
|
2347
|
+
/* isPartialEvent */
|
|
2348
|
+
!0
|
|
2349
|
+
);
|
|
2350
|
+
const I = Xe(d, s, w);
|
|
2351
|
+
tt(w, I, !0);
|
|
2352
|
+
} catch (g) {
|
|
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();
|
|
2356
|
+
}
|
|
2357
|
+
return;
|
|
2358
|
+
}
|
|
2359
|
+
const y = this.entityMap.getEntity(c);
|
|
2360
|
+
if (y === void 0) return;
|
|
2361
|
+
this.entityMap.save(y);
|
|
2362
|
+
const v = u === void 0;
|
|
2363
|
+
let p = !1;
|
|
2364
|
+
this.routeEvent(i, y.data, c, e, f, () => {
|
|
2365
|
+
p = !0;
|
|
2366
|
+
}), v && !p && y.evict();
|
|
2367
|
+
}
|
|
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
|
+
// ======================================================
|
|
2379
|
+
// In-Memory GC
|
|
2380
|
+
// ======================================================
|
|
2381
|
+
handleEviction = (t, e) => {
|
|
2382
|
+
if (e === z.Query) {
|
|
2383
|
+
const s = this.queryInstances.get(t);
|
|
2384
|
+
if (s === void 0) return;
|
|
2385
|
+
s.rootEntity?.evict(), this.queryInstances.delete(t);
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
const i = this.entityMap.getEntity(t);
|
|
2389
|
+
i !== void 0 && i.evict();
|
|
2390
|
+
};
|
|
2391
|
+
// ======================================================
|
|
2392
|
+
// Constraint Registry (Live Data)
|
|
2393
|
+
// ======================================================
|
|
2394
|
+
getOrCreateMatcher(t) {
|
|
2395
|
+
let e = this.constraintRegistry.get(t);
|
|
2396
|
+
return e === void 0 && (e = new _n(), this.constraintRegistry.set(t, e)), e;
|
|
2397
|
+
}
|
|
2398
|
+
registerLiveCollection(t) {
|
|
2399
|
+
for (const [e, i] of t._entityDefsByTypename)
|
|
2400
|
+
this.registerEntityDef(i), this.getOrCreateMatcher(e).registerBinding(t, e);
|
|
2401
|
+
}
|
|
2402
|
+
unregisterLiveCollection(t) {
|
|
2403
|
+
for (const e of t._entityDefsByTypename.keys()) {
|
|
2404
|
+
const i = this.constraintRegistry.get(e);
|
|
2405
|
+
i !== void 0 && i.unregisterBinding(t, e);
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
routeEvent(t, e, i, s, r, o, a) {
|
|
2409
|
+
const c = this.constraintRegistry.get(t);
|
|
2410
|
+
if (c === void 0) return;
|
|
2411
|
+
const f = r !== void 0 ? { ...e, [se]: r } : e;
|
|
2412
|
+
c.routeEvent(t, f, i, s, o, a);
|
|
2413
|
+
}
|
|
2414
|
+
destroy() {
|
|
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();
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
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
|
+
}
|
|
2428
|
+
export {
|
|
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,
|
|
2437
|
+
_ as V,
|
|
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
|
|
2456
|
+
};
|
|
2457
|
+
//# sourceMappingURL=QueryClient-YqnBxFy1.js.map
|