@hortiview/modulebase 0.0.12333 → 0.0.12550
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/dist/QueryClientProvider-Q_mWQTzQ.js +435 -0
- package/dist/components/ModuleBase.js +509 -10
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +11 -102
- package/dist/hooks/useEntity.d.ts +2 -8
- package/dist/hooks/useEntity.js +1 -1
- package/dist/hooks/useOption.js +1 -1
- package/dist/hooks/useServiceBus.d.ts +15 -0
- package/dist/hooks/useServiceBus.js +17 -0
- package/dist/hooks/useStores.d.ts +2 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +118 -116
- package/dist/mutation-X73nm7Df.js +192 -0
- package/dist/query-CRIVoEP7.js +277 -0
- package/dist/types/BaseProps.d.ts +3 -0
- package/dist/types/ModuleApi.d.ts +75 -4
- package/dist/types/ServiceBus.d.ts +17 -0
- package/dist/types/ServiceBus.js +1 -0
- package/dist/useMutation-3rykrmeD.js +97 -0
- package/dist/{useQuery-DtzakC1A.js → useQuery-CwwWze9O.js} +47 -53
- package/dist/utils-DxRR_XLb.js +9 -0
- package/package.json +1 -1
- package/dist/ModuleBase-brrfWM_W.js +0 -697
- package/dist/QueryClientProvider-QWqHaM3I.js +0 -707
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import * as F from "react";
|
|
2
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
3
|
+
var C = class {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
6
|
+
}
|
|
7
|
+
subscribe(e) {
|
|
8
|
+
return this.listeners.add(e), this.onSubscribe(), () => {
|
|
9
|
+
this.listeners.delete(e), this.onUnsubscribe();
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
hasListeners() {
|
|
13
|
+
return this.listeners.size > 0;
|
|
14
|
+
}
|
|
15
|
+
onSubscribe() {
|
|
16
|
+
}
|
|
17
|
+
onUnsubscribe() {
|
|
18
|
+
}
|
|
19
|
+
}, d = typeof window > "u" || "Deno" in globalThis;
|
|
20
|
+
function J() {
|
|
21
|
+
}
|
|
22
|
+
function _(e, t) {
|
|
23
|
+
return typeof e == "function" ? e(t) : e;
|
|
24
|
+
}
|
|
25
|
+
function Q(e) {
|
|
26
|
+
return typeof e == "number" && e >= 0 && e !== 1 / 0;
|
|
27
|
+
}
|
|
28
|
+
function B(e, t) {
|
|
29
|
+
return Math.max(e + (t || 0) - Date.now(), 0);
|
|
30
|
+
}
|
|
31
|
+
function W(e, t) {
|
|
32
|
+
return typeof e == "function" ? e(t) : e;
|
|
33
|
+
}
|
|
34
|
+
function X(e, t) {
|
|
35
|
+
return typeof e == "function" ? e(t) : e;
|
|
36
|
+
}
|
|
37
|
+
function Y(e, t) {
|
|
38
|
+
const {
|
|
39
|
+
type: n = "all",
|
|
40
|
+
exact: r,
|
|
41
|
+
fetchStatus: s,
|
|
42
|
+
predicate: o,
|
|
43
|
+
queryKey: l,
|
|
44
|
+
stale: i
|
|
45
|
+
} = e;
|
|
46
|
+
if (l) {
|
|
47
|
+
if (r) {
|
|
48
|
+
if (t.queryHash !== K(l, t.options))
|
|
49
|
+
return !1;
|
|
50
|
+
} else if (!S(t.queryKey, l))
|
|
51
|
+
return !1;
|
|
52
|
+
}
|
|
53
|
+
if (n !== "all") {
|
|
54
|
+
const u = t.isActive();
|
|
55
|
+
if (n === "active" && !u || n === "inactive" && u)
|
|
56
|
+
return !1;
|
|
57
|
+
}
|
|
58
|
+
return !(typeof i == "boolean" && t.isStale() !== i || s && s !== t.state.fetchStatus || o && !o(t));
|
|
59
|
+
}
|
|
60
|
+
function Z(e, t) {
|
|
61
|
+
const { exact: n, status: r, predicate: s, mutationKey: o } = e;
|
|
62
|
+
if (o) {
|
|
63
|
+
if (!t.options.mutationKey)
|
|
64
|
+
return !1;
|
|
65
|
+
if (n) {
|
|
66
|
+
if (w(t.options.mutationKey) !== w(o))
|
|
67
|
+
return !1;
|
|
68
|
+
} else if (!S(t.options.mutationKey, o))
|
|
69
|
+
return !1;
|
|
70
|
+
}
|
|
71
|
+
return !(r && t.state.status !== r || s && !s(t));
|
|
72
|
+
}
|
|
73
|
+
function K(e, t) {
|
|
74
|
+
return (t?.queryKeyHashFn || w)(e);
|
|
75
|
+
}
|
|
76
|
+
function w(e) {
|
|
77
|
+
return JSON.stringify(
|
|
78
|
+
e,
|
|
79
|
+
(t, n) => g(n) ? Object.keys(n).sort().reduce((r, s) => (r[s] = n[s], r), {}) : n
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function S(e, t) {
|
|
83
|
+
return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? !Object.keys(t).some((n) => !S(e[n], t[n])) : !1;
|
|
84
|
+
}
|
|
85
|
+
function E(e, t) {
|
|
86
|
+
if (e === t)
|
|
87
|
+
return e;
|
|
88
|
+
const n = j(e) && j(t);
|
|
89
|
+
if (n || g(e) && g(t)) {
|
|
90
|
+
const r = n ? e : Object.keys(e), s = r.length, o = n ? t : Object.keys(t), l = o.length, i = n ? [] : {};
|
|
91
|
+
let u = 0;
|
|
92
|
+
for (let f = 0; f < l; f++) {
|
|
93
|
+
const c = n ? f : o[f];
|
|
94
|
+
(!n && r.includes(c) || n) && e[c] === void 0 && t[c] === void 0 ? (i[c] = void 0, u++) : (i[c] = E(e[c], t[c]), i[c] === e[c] && e[c] !== void 0 && u++);
|
|
95
|
+
}
|
|
96
|
+
return s === l && u === s ? e : i;
|
|
97
|
+
}
|
|
98
|
+
return t;
|
|
99
|
+
}
|
|
100
|
+
function ee(e, t) {
|
|
101
|
+
if (!t || Object.keys(e).length !== Object.keys(t).length)
|
|
102
|
+
return !1;
|
|
103
|
+
for (const n in e)
|
|
104
|
+
if (e[n] !== t[n])
|
|
105
|
+
return !1;
|
|
106
|
+
return !0;
|
|
107
|
+
}
|
|
108
|
+
function j(e) {
|
|
109
|
+
return Array.isArray(e) && e.length === Object.keys(e).length;
|
|
110
|
+
}
|
|
111
|
+
function g(e) {
|
|
112
|
+
if (!T(e))
|
|
113
|
+
return !1;
|
|
114
|
+
const t = e.constructor;
|
|
115
|
+
if (t === void 0)
|
|
116
|
+
return !0;
|
|
117
|
+
const n = t.prototype;
|
|
118
|
+
return !(!T(n) || !n.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
|
|
119
|
+
}
|
|
120
|
+
function T(e) {
|
|
121
|
+
return Object.prototype.toString.call(e) === "[object Object]";
|
|
122
|
+
}
|
|
123
|
+
function z(e) {
|
|
124
|
+
return new Promise((t) => {
|
|
125
|
+
setTimeout(t, e);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function te(e, t, n) {
|
|
129
|
+
if (typeof n.structuralSharing == "function")
|
|
130
|
+
return n.structuralSharing(e, t);
|
|
131
|
+
if (n.structuralSharing !== !1) {
|
|
132
|
+
if (process.env.NODE_ENV !== "production")
|
|
133
|
+
try {
|
|
134
|
+
return E(e, t);
|
|
135
|
+
} catch (r) {
|
|
136
|
+
console.error(
|
|
137
|
+
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
return E(e, t);
|
|
141
|
+
}
|
|
142
|
+
return t;
|
|
143
|
+
}
|
|
144
|
+
function ne(e, t, n = 0) {
|
|
145
|
+
const r = [...e, t];
|
|
146
|
+
return n && r.length > n ? r.slice(1) : r;
|
|
147
|
+
}
|
|
148
|
+
function re(e, t, n = 0) {
|
|
149
|
+
const r = [t, ...e];
|
|
150
|
+
return n && r.length > n ? r.slice(0, -1) : r;
|
|
151
|
+
}
|
|
152
|
+
var P = Symbol();
|
|
153
|
+
function se(e, t) {
|
|
154
|
+
return process.env.NODE_ENV !== "production" && e.queryFn === P && console.error(
|
|
155
|
+
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
|
|
156
|
+
), !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === P ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
|
|
157
|
+
}
|
|
158
|
+
var D = class extends C {
|
|
159
|
+
#e;
|
|
160
|
+
#t;
|
|
161
|
+
#n;
|
|
162
|
+
constructor() {
|
|
163
|
+
super(), this.#n = (e) => {
|
|
164
|
+
if (!d && window.addEventListener) {
|
|
165
|
+
const t = () => e();
|
|
166
|
+
return window.addEventListener("visibilitychange", t, !1), () => {
|
|
167
|
+
window.removeEventListener("visibilitychange", t);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
onSubscribe() {
|
|
173
|
+
this.#t || this.setEventListener(this.#n);
|
|
174
|
+
}
|
|
175
|
+
onUnsubscribe() {
|
|
176
|
+
this.hasListeners() || (this.#t?.(), this.#t = void 0);
|
|
177
|
+
}
|
|
178
|
+
setEventListener(e) {
|
|
179
|
+
this.#n = e, this.#t?.(), this.#t = e((t) => {
|
|
180
|
+
typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
setFocused(e) {
|
|
184
|
+
this.#e !== e && (this.#e = e, this.onFocus());
|
|
185
|
+
}
|
|
186
|
+
onFocus() {
|
|
187
|
+
const e = this.isFocused();
|
|
188
|
+
this.listeners.forEach((t) => {
|
|
189
|
+
t(e);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
isFocused() {
|
|
193
|
+
return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
|
|
194
|
+
}
|
|
195
|
+
}, I = new D(), A = class extends C {
|
|
196
|
+
#e = !0;
|
|
197
|
+
#t;
|
|
198
|
+
#n;
|
|
199
|
+
constructor() {
|
|
200
|
+
super(), this.#n = (e) => {
|
|
201
|
+
if (!d && window.addEventListener) {
|
|
202
|
+
const t = () => e(!0), n = () => e(!1);
|
|
203
|
+
return window.addEventListener("online", t, !1), window.addEventListener("offline", n, !1), () => {
|
|
204
|
+
window.removeEventListener("online", t), window.removeEventListener("offline", n);
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
onSubscribe() {
|
|
210
|
+
this.#t || this.setEventListener(this.#n);
|
|
211
|
+
}
|
|
212
|
+
onUnsubscribe() {
|
|
213
|
+
this.hasListeners() || (this.#t?.(), this.#t = void 0);
|
|
214
|
+
}
|
|
215
|
+
setEventListener(e) {
|
|
216
|
+
this.#n = e, this.#t?.(), this.#t = e(this.setOnline.bind(this));
|
|
217
|
+
}
|
|
218
|
+
setOnline(e) {
|
|
219
|
+
this.#e !== e && (this.#e = e, this.listeners.forEach((n) => {
|
|
220
|
+
n(e);
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
isOnline() {
|
|
224
|
+
return this.#e;
|
|
225
|
+
}
|
|
226
|
+
}, L = new A();
|
|
227
|
+
function U() {
|
|
228
|
+
let e, t;
|
|
229
|
+
const n = new Promise((s, o) => {
|
|
230
|
+
e = s, t = o;
|
|
231
|
+
});
|
|
232
|
+
n.status = "pending", n.catch(() => {
|
|
233
|
+
});
|
|
234
|
+
function r(s) {
|
|
235
|
+
Object.assign(n, s), delete n.resolve, delete n.reject;
|
|
236
|
+
}
|
|
237
|
+
return n.resolve = (s) => {
|
|
238
|
+
r({
|
|
239
|
+
status: "fulfilled",
|
|
240
|
+
value: s
|
|
241
|
+
}), e(s);
|
|
242
|
+
}, n.reject = (s) => {
|
|
243
|
+
r({
|
|
244
|
+
status: "rejected",
|
|
245
|
+
reason: s
|
|
246
|
+
}), t(s);
|
|
247
|
+
}, n;
|
|
248
|
+
}
|
|
249
|
+
function G(e) {
|
|
250
|
+
return Math.min(1e3 * 2 ** e, 3e4);
|
|
251
|
+
}
|
|
252
|
+
function H(e) {
|
|
253
|
+
return (e ?? "online") === "online" ? L.isOnline() : !0;
|
|
254
|
+
}
|
|
255
|
+
var q = class extends Error {
|
|
256
|
+
constructor(e) {
|
|
257
|
+
super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
function ie(e) {
|
|
261
|
+
return e instanceof q;
|
|
262
|
+
}
|
|
263
|
+
function oe(e) {
|
|
264
|
+
let t = !1, n = 0, r = !1, s;
|
|
265
|
+
const o = U(), l = (a) => {
|
|
266
|
+
r || (b(new q(a)), e.abort?.());
|
|
267
|
+
}, i = () => {
|
|
268
|
+
t = !0;
|
|
269
|
+
}, u = () => {
|
|
270
|
+
t = !1;
|
|
271
|
+
}, f = () => I.isFocused() && (e.networkMode === "always" || L.isOnline()) && e.canRun(), c = () => H(e.networkMode) && e.canRun(), M = (a) => {
|
|
272
|
+
r || (r = !0, e.onSuccess?.(a), s?.(), o.resolve(a));
|
|
273
|
+
}, b = (a) => {
|
|
274
|
+
r || (r = !0, e.onError?.(a), s?.(), o.reject(a));
|
|
275
|
+
}, O = () => new Promise((a) => {
|
|
276
|
+
s = (p) => {
|
|
277
|
+
(r || f()) && a(p);
|
|
278
|
+
}, e.onPause?.();
|
|
279
|
+
}).then(() => {
|
|
280
|
+
s = void 0, r || e.onContinue?.();
|
|
281
|
+
}), m = () => {
|
|
282
|
+
if (r)
|
|
283
|
+
return;
|
|
284
|
+
let a;
|
|
285
|
+
const p = n === 0 ? e.initialPromise : void 0;
|
|
286
|
+
try {
|
|
287
|
+
a = p ?? e.fn();
|
|
288
|
+
} catch (h) {
|
|
289
|
+
a = Promise.reject(h);
|
|
290
|
+
}
|
|
291
|
+
Promise.resolve(a).then(M).catch((h) => {
|
|
292
|
+
if (r)
|
|
293
|
+
return;
|
|
294
|
+
const y = e.retry ?? (d ? 0 : 3), v = e.retryDelay ?? G, R = typeof v == "function" ? v(n, h) : v, x = y === !0 || typeof y == "number" && n < y || typeof y == "function" && y(n, h);
|
|
295
|
+
if (t || !x) {
|
|
296
|
+
b(h);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
n++, e.onFail?.(n, h), z(R).then(() => f() ? void 0 : O()).then(() => {
|
|
300
|
+
t ? b(h) : m();
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
return {
|
|
305
|
+
promise: o,
|
|
306
|
+
cancel: l,
|
|
307
|
+
continue: () => (s?.(), o),
|
|
308
|
+
cancelRetry: i,
|
|
309
|
+
continueRetry: u,
|
|
310
|
+
canStart: c,
|
|
311
|
+
start: () => (c() ? m() : O().then(m), o)
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function V() {
|
|
315
|
+
let e = [], t = 0, n = (i) => {
|
|
316
|
+
i();
|
|
317
|
+
}, r = (i) => {
|
|
318
|
+
i();
|
|
319
|
+
}, s = (i) => setTimeout(i, 0);
|
|
320
|
+
const o = (i) => {
|
|
321
|
+
t ? e.push(i) : s(() => {
|
|
322
|
+
n(i);
|
|
323
|
+
});
|
|
324
|
+
}, l = () => {
|
|
325
|
+
const i = e;
|
|
326
|
+
e = [], i.length && s(() => {
|
|
327
|
+
r(() => {
|
|
328
|
+
i.forEach((u) => {
|
|
329
|
+
n(u);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
return {
|
|
335
|
+
batch: (i) => {
|
|
336
|
+
let u;
|
|
337
|
+
t++;
|
|
338
|
+
try {
|
|
339
|
+
u = i();
|
|
340
|
+
} finally {
|
|
341
|
+
t--, t || l();
|
|
342
|
+
}
|
|
343
|
+
return u;
|
|
344
|
+
},
|
|
345
|
+
/**
|
|
346
|
+
* All calls to the wrapped function will be batched.
|
|
347
|
+
*/
|
|
348
|
+
batchCalls: (i) => (...u) => {
|
|
349
|
+
o(() => {
|
|
350
|
+
i(...u);
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
schedule: o,
|
|
354
|
+
/**
|
|
355
|
+
* Use this method to set a custom notify function.
|
|
356
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
357
|
+
*/
|
|
358
|
+
setNotifyFunction: (i) => {
|
|
359
|
+
n = i;
|
|
360
|
+
},
|
|
361
|
+
/**
|
|
362
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
363
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
364
|
+
*/
|
|
365
|
+
setBatchNotifyFunction: (i) => {
|
|
366
|
+
r = i;
|
|
367
|
+
},
|
|
368
|
+
setScheduler: (i) => {
|
|
369
|
+
s = i;
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
var ue = V(), ce = class {
|
|
374
|
+
#e;
|
|
375
|
+
destroy() {
|
|
376
|
+
this.clearGcTimeout();
|
|
377
|
+
}
|
|
378
|
+
scheduleGc() {
|
|
379
|
+
this.clearGcTimeout(), Q(this.gcTime) && (this.#e = setTimeout(() => {
|
|
380
|
+
this.optionalRemove();
|
|
381
|
+
}, this.gcTime));
|
|
382
|
+
}
|
|
383
|
+
updateGcTime(e) {
|
|
384
|
+
this.gcTime = Math.max(
|
|
385
|
+
this.gcTime || 0,
|
|
386
|
+
e ?? (d ? 1 / 0 : 5 * 60 * 1e3)
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
clearGcTimeout() {
|
|
390
|
+
this.#e && (clearTimeout(this.#e), this.#e = void 0);
|
|
391
|
+
}
|
|
392
|
+
}, k = F.createContext(
|
|
393
|
+
void 0
|
|
394
|
+
), ae = (e) => {
|
|
395
|
+
const t = F.useContext(k);
|
|
396
|
+
if (!t)
|
|
397
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
398
|
+
return t;
|
|
399
|
+
}, le = ({
|
|
400
|
+
client: e,
|
|
401
|
+
children: t
|
|
402
|
+
}) => (F.useEffect(() => (e.mount(), () => {
|
|
403
|
+
e.unmount();
|
|
404
|
+
}), [e]), /* @__PURE__ */ N(k.Provider, { value: e, children: t }));
|
|
405
|
+
export {
|
|
406
|
+
le as Q,
|
|
407
|
+
ce as R,
|
|
408
|
+
C as S,
|
|
409
|
+
J as a,
|
|
410
|
+
X as b,
|
|
411
|
+
oe as c,
|
|
412
|
+
H as d,
|
|
413
|
+
se as e,
|
|
414
|
+
ee as f,
|
|
415
|
+
K as g,
|
|
416
|
+
w as h,
|
|
417
|
+
ie as i,
|
|
418
|
+
Z as j,
|
|
419
|
+
re as k,
|
|
420
|
+
ne as l,
|
|
421
|
+
Y as m,
|
|
422
|
+
ue as n,
|
|
423
|
+
I as o,
|
|
424
|
+
L as p,
|
|
425
|
+
W as q,
|
|
426
|
+
te as r,
|
|
427
|
+
P as s,
|
|
428
|
+
B as t,
|
|
429
|
+
ae as u,
|
|
430
|
+
_ as v,
|
|
431
|
+
S as w,
|
|
432
|
+
U as x,
|
|
433
|
+
d as y,
|
|
434
|
+
Q as z
|
|
435
|
+
};
|