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