@bquery/bquery 1.8.2 → 1.9.0
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/README.md +96 -24
- package/dist/{a11y-DVBCy09c.js → a11y-_9X-kt-_.js} +2 -2
- package/dist/{a11y-DVBCy09c.js.map → a11y-_9X-kt-_.js.map} +1 -1
- package/dist/a11y.es.mjs +1 -1
- package/dist/{forms-UcRHsYxC.js → forms-UhAeJEoO.js} +13 -13
- package/dist/{forms-UcRHsYxC.js.map → forms-UhAeJEoO.js.map} +1 -1
- package/dist/forms.es.mjs +1 -1
- package/dist/full.d.ts +4 -4
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +201 -196
- package/dist/full.iife.js +20 -20
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +20 -20
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +214 -209
- package/dist/media/index.d.ts +10 -3
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/observers.d.ts +99 -0
- package/dist/media/observers.d.ts.map +1 -0
- package/dist/media/types.d.ts +125 -0
- package/dist/media/types.d.ts.map +1 -1
- package/dist/media-D4zLj9t-.js +514 -0
- package/dist/media-D4zLj9t-.js.map +1 -0
- package/dist/media.es.mjs +12 -9
- package/dist/mount-B-JvH6Y0.js +449 -0
- package/dist/mount-B-JvH6Y0.js.map +1 -0
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.d.ts.map +1 -1
- package/dist/reactive/signal.d.ts +2 -1
- package/dist/reactive/signal.d.ts.map +1 -1
- package/dist/reactive/watch.d.ts +49 -0
- package/dist/reactive/watch.d.ts.map +1 -1
- package/dist/reactive-BjpLkclt.js +1184 -0
- package/dist/{reactive-DwkhUJfP.js.map → reactive-BjpLkclt.js.map} +1 -1
- package/dist/reactive.es.mjs +35 -33
- package/dist/{router-CQikC9Ed.js → router-BieVwgci.js} +2 -2
- package/dist/{router-CQikC9Ed.js.map → router-BieVwgci.js.map} +1 -1
- package/dist/router.es.mjs +1 -1
- package/dist/{ssr-_dAcGdzu.js → ssr-CrGSJySz.js} +3 -3
- package/dist/{ssr-_dAcGdzu.js.map → ssr-CrGSJySz.js.map} +1 -1
- package/dist/ssr.es.mjs +1 -1
- package/dist/{store-Cb3gPRve.js → store-CY6sjTW3.js} +2 -2
- package/dist/{store-Cb3gPRve.js.map → store-CY6sjTW3.js.map} +1 -1
- package/dist/store.es.mjs +1 -1
- package/dist/{testing-C5Sjfsna.js → testing-UjAtu9aQ.js} +9 -9
- package/dist/{testing-C5Sjfsna.js.map → testing-UjAtu9aQ.js.map} +1 -1
- package/dist/testing.es.mjs +1 -1
- package/dist/view/directives/aria.d.ts +7 -0
- package/dist/view/directives/aria.d.ts.map +1 -0
- package/dist/view/directives/error.d.ts +7 -0
- package/dist/view/directives/error.d.ts.map +1 -0
- package/dist/view/directives/index.d.ts +2 -0
- package/dist/view/directives/index.d.ts.map +1 -1
- package/dist/view/mount.d.ts.map +1 -1
- package/dist/view/process.d.ts +2 -0
- package/dist/view/process.d.ts.map +1 -1
- package/dist/view.es.mjs +2 -2
- package/package.json +5 -5
- package/src/full.ts +12 -0
- package/src/media/index.ts +20 -2
- package/src/media/observers.ts +421 -0
- package/src/media/types.ts +136 -0
- package/src/reactive/index.ts +3 -0
- package/src/reactive/signal.ts +2 -1
- package/src/reactive/watch.ts +137 -0
- package/src/view/directives/aria.ts +72 -0
- package/src/view/directives/error.ts +56 -0
- package/src/view/directives/index.ts +2 -0
- package/src/view/mount.ts +4 -0
- package/src/view/process.ts +6 -0
- package/dist/media-i-fB5WxI.js +0 -340
- package/dist/media-i-fB5WxI.js.map +0 -1
- package/dist/mount-B4Y8bk8Z.js +0 -403
- package/dist/mount-B4Y8bk8Z.js.map +0 -1
- package/dist/reactive-DwkhUJfP.js +0 -1148
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import { a as K, r as pe } from "./object-BCk-1c8T.js";
|
|
2
|
+
import { i as ye, t as ge } from "./function-Cybd57JV.js";
|
|
3
|
+
import { c as Ee, d as we, l as be, n as C, o as Se, r as z, t as Y } from "./core-DdtZHzsS.js";
|
|
4
|
+
import { n as X } from "./config-DhT9auRm.js";
|
|
5
|
+
import { n as Z, r as q, t as V } from "./untrack-D0fnO5k2.js";
|
|
6
|
+
var ot = (e) => {
|
|
7
|
+
be();
|
|
8
|
+
try {
|
|
9
|
+
e();
|
|
10
|
+
} finally {
|
|
11
|
+
we();
|
|
12
|
+
}
|
|
13
|
+
}, Re = (e) => {
|
|
14
|
+
if (e instanceof Error) return e;
|
|
15
|
+
if (typeof e == "string") return new Error(e);
|
|
16
|
+
try {
|
|
17
|
+
return new Error(JSON.stringify(e));
|
|
18
|
+
} catch {
|
|
19
|
+
return new Error(String(e));
|
|
20
|
+
}
|
|
21
|
+
}, Te = (e) => typeof e == "function" ? e() : e.value, ee = (...e) => {
|
|
22
|
+
const t = new Headers();
|
|
23
|
+
for (const n of e)
|
|
24
|
+
n && new Headers(n).forEach((r, o) => {
|
|
25
|
+
t.set(o, r);
|
|
26
|
+
});
|
|
27
|
+
return t;
|
|
28
|
+
}, Oe = (e) => typeof e == "string" || e instanceof Blob || e instanceof FormData || e instanceof URLSearchParams || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer || typeof ReadableStream < "u" && e instanceof ReadableStream ? !0 : typeof e == "object" && e !== null && ArrayBuffer.isView(e), xe = (e, t) => e == null || Oe(e) ? e : (t.has("content-type") || t.set("content-type", "application/json"), JSON.stringify(e)), Ce = (e) => typeof e == "function" ? e() : e, Le = (e, t) => {
|
|
29
|
+
for (const [n, r] of Object.entries(t))
|
|
30
|
+
if (r != null) {
|
|
31
|
+
if (Array.isArray(r)) {
|
|
32
|
+
for (const o of r) o != null && e.searchParams.append(n, String(o));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
e.searchParams.set(n, String(r));
|
|
36
|
+
}
|
|
37
|
+
}, Ae = (e, t) => {
|
|
38
|
+
const n = typeof window < "u" && /^https?:/i.test(window.location.href) ? window.location.href : "http://localhost", r = t ? new URL(t, n).toString() : n;
|
|
39
|
+
return e instanceof URL ? new URL(e.toString(), r) : new URL(e, r);
|
|
40
|
+
}, De = async (e, t) => {
|
|
41
|
+
if (t === "response") return e;
|
|
42
|
+
if (t === "text") return await e.text();
|
|
43
|
+
if (t === "blob") return await e.blob();
|
|
44
|
+
if (t === "arrayBuffer") return await e.arrayBuffer();
|
|
45
|
+
if (t === "formData") return await e.formData();
|
|
46
|
+
const n = await e.text();
|
|
47
|
+
if (n)
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(n);
|
|
50
|
+
} catch (r) {
|
|
51
|
+
const o = e.url ? ` for ${e.url}` : "";
|
|
52
|
+
throw new Error(`Failed to parse JSON response${o} (status ${e.status}): ${r instanceof Error ? r.message : String(r)}`);
|
|
53
|
+
}
|
|
54
|
+
}, W = (e) => {
|
|
55
|
+
const t = e?.trim();
|
|
56
|
+
return t ? t.toUpperCase() : void 0;
|
|
57
|
+
}, ke = (e, t, n) => {
|
|
58
|
+
const r = t instanceof Request ? W(t.method) : void 0;
|
|
59
|
+
return e ?? r ?? (n ? "POST" : void 0);
|
|
60
|
+
}, Pe = (e, t, n) => e || (t instanceof Request ? void 0 : n), Ie = (e) => {
|
|
61
|
+
const t = W(e.method);
|
|
62
|
+
let n;
|
|
63
|
+
if (t !== "GET" && t !== "HEAD" && !e.bodyUsed) try {
|
|
64
|
+
n = e.clone().body ?? void 0;
|
|
65
|
+
} catch {
|
|
66
|
+
n = void 0;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
method: t,
|
|
70
|
+
headers: e.headers,
|
|
71
|
+
body: n,
|
|
72
|
+
cache: e.cache,
|
|
73
|
+
credentials: e.credentials,
|
|
74
|
+
integrity: e.integrity,
|
|
75
|
+
keepalive: e.keepalive,
|
|
76
|
+
mode: e.mode,
|
|
77
|
+
redirect: e.redirect,
|
|
78
|
+
referrer: e.referrer,
|
|
79
|
+
referrerPolicy: e.referrerPolicy,
|
|
80
|
+
signal: e.signal
|
|
81
|
+
};
|
|
82
|
+
}, qe = (e, t = {}) => {
|
|
83
|
+
const n = t.immediate ?? !0, r = C(t.defaultValue), o = C(null), i = C("idle"), a = q(() => i.value === "pending");
|
|
84
|
+
let s = 0, d = !1, c = () => {
|
|
85
|
+
};
|
|
86
|
+
const l = () => {
|
|
87
|
+
s += 1, r.value = t.defaultValue, o.value = null, i.value = "idle";
|
|
88
|
+
}, m = () => {
|
|
89
|
+
d || (d = !0, s += 1, c());
|
|
90
|
+
}, u = async () => {
|
|
91
|
+
if (d) return r.peek();
|
|
92
|
+
const p = ++s;
|
|
93
|
+
i.value = "pending", o.value = null;
|
|
94
|
+
try {
|
|
95
|
+
const y = await e(), w = t.transform ? t.transform(y) : y;
|
|
96
|
+
return d || p !== s ? r.peek() : (r.value = w, i.value = "success", t.onSuccess?.(w), w);
|
|
97
|
+
} catch (y) {
|
|
98
|
+
const w = Re(y);
|
|
99
|
+
return d || p !== s || (o.value = w, i.value = "error", t.onError?.(w)), r.peek();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
if (t.watch?.length) {
|
|
103
|
+
let p = !1;
|
|
104
|
+
c = z(() => {
|
|
105
|
+
for (const y of t.watch ?? []) Te(y);
|
|
106
|
+
if (!p) {
|
|
107
|
+
p = !0, n && V(() => u());
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
V(() => u());
|
|
111
|
+
});
|
|
112
|
+
} else n && u();
|
|
113
|
+
return {
|
|
114
|
+
data: r,
|
|
115
|
+
error: o,
|
|
116
|
+
status: i,
|
|
117
|
+
pending: a,
|
|
118
|
+
execute: u,
|
|
119
|
+
refresh: u,
|
|
120
|
+
abort: () => {
|
|
121
|
+
},
|
|
122
|
+
clear: l,
|
|
123
|
+
dispose: m
|
|
124
|
+
};
|
|
125
|
+
}, Ne = (e) => e >= 200 && e < 300, te = (e, t) => e instanceof DOMException && e.name === t, B = (e) => te(e, "TimeoutError"), re = (e) => te(e, "AbortError"), Ue = (e) => {
|
|
126
|
+
if (re(e) || B(e) || e.code === "ABORT" || e.code === "TIMEOUT") return !1;
|
|
127
|
+
const t = e.status;
|
|
128
|
+
return t === void 0 || t >= 500;
|
|
129
|
+
}, Me = (e) => {
|
|
130
|
+
if (e != null)
|
|
131
|
+
return typeof e == "number" ? { count: e } : e;
|
|
132
|
+
}, $e = (e, t) => e == null ? Math.min(1e3 * 2 ** t, 3e4) : typeof e == "number" ? e : e(t), _e = (e, t) => new Promise((n, r) => {
|
|
133
|
+
if (t?.aborted) {
|
|
134
|
+
r(t.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let o = !1, i;
|
|
138
|
+
const a = () => {
|
|
139
|
+
o || (o = !0, clearTimeout(i), t?.removeEventListener("abort", a), r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError")));
|
|
140
|
+
};
|
|
141
|
+
i = setTimeout(() => {
|
|
142
|
+
o || (o = !0, t?.removeEventListener("abort", a), n());
|
|
143
|
+
}, e), t?.addEventListener("abort", a, { once: !0 });
|
|
144
|
+
}), N = (e, t = {}) => {
|
|
145
|
+
const n = X().fetch, r = t.parseAs ?? n?.parseAs ?? "json", o = t.fetcher ?? fetch, i = t.validateStatus ?? Ne;
|
|
146
|
+
let a = null;
|
|
147
|
+
const s = (c, l) => {
|
|
148
|
+
const m = l || B(c) || B(a?.signal.reason);
|
|
149
|
+
return Object.assign(/* @__PURE__ */ new Error(m ? `Request timeout of ${t.timeout}ms exceeded` : "Request aborted"), { code: m ? "TIMEOUT" : "ABORT" });
|
|
150
|
+
}, d = qe(async () => {
|
|
151
|
+
const c = Ce(e), l = typeof c == "string" || c instanceof URL ? Ae(c, t.baseUrl ?? n?.baseUrl) : c instanceof Request && t.query ? new URL(c.url) : null;
|
|
152
|
+
l && t.query && Le(l, t.query);
|
|
153
|
+
const m = ee(n?.headers, c instanceof Request ? c.headers : void 0, t.headers), u = t.body != null, p = W(t.method), y = ke(p, c, u), w = y === "GET" || y === "HEAD" ? y : null;
|
|
154
|
+
if (u && w) throw new Error(`Cannot send a request body with ${w} requests`);
|
|
155
|
+
const R = Pe(p, c, y), b = Me(t.retry), f = (b?.count ?? 0) + 1, h = new AbortController();
|
|
156
|
+
a = h;
|
|
157
|
+
let v, g = !1, E;
|
|
158
|
+
t.signal && (t.signal.aborted ? h.abort(t.signal.reason) : (E = () => h.abort(t.signal?.reason), t.signal.addEventListener("abort", E, { once: !0 }))), t.timeout && t.timeout > 0 && (v = setTimeout(() => {
|
|
159
|
+
g = !0, h.abort(new DOMException("Request timeout", "TimeoutError"));
|
|
160
|
+
}, t.timeout));
|
|
161
|
+
const S = {
|
|
162
|
+
...t,
|
|
163
|
+
method: R,
|
|
164
|
+
headers: m
|
|
165
|
+
};
|
|
166
|
+
delete S.baseUrl, delete S.query, delete S.parseAs, delete S.fetcher, delete S.defaultValue, delete S.immediate, delete S.watch, delete S.transform, delete S.onSuccess, delete S.onError, delete S.timeout, delete S.retry, delete S.validateStatus;
|
|
167
|
+
let O = l ?? c;
|
|
168
|
+
c instanceof Request && l && l.toString() !== c.url && (O = new Request(l.toString(), Ie(c)));
|
|
169
|
+
const L = () => {
|
|
170
|
+
const x = new Headers(m);
|
|
171
|
+
return {
|
|
172
|
+
...S,
|
|
173
|
+
headers: x,
|
|
174
|
+
body: xe(t.body, x),
|
|
175
|
+
signal: h.signal
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
if (f > 1 && typeof ReadableStream < "u" && t.body instanceof ReadableStream) throw new Error("Cannot retry requests with ReadableStream bodies");
|
|
179
|
+
if (f > 1 && typeof Request < "u" && O instanceof Request && O.body !== null) throw new Error("Cannot retry requests with non-replayable Request bodies");
|
|
180
|
+
let D;
|
|
181
|
+
try {
|
|
182
|
+
for (let x = 0; x < f; x++) try {
|
|
183
|
+
const A = await o(O, L());
|
|
184
|
+
if (!i(A.status)) throw Object.assign(/* @__PURE__ */ new Error(`Request failed with status ${A.status}`), {
|
|
185
|
+
response: A,
|
|
186
|
+
status: A.status,
|
|
187
|
+
statusText: A.statusText
|
|
188
|
+
});
|
|
189
|
+
return await De(A, r);
|
|
190
|
+
} catch (A) {
|
|
191
|
+
const k = A instanceof Error ? A : new Error(String(A));
|
|
192
|
+
if (h.signal.aborted || re(k) || B(k)) throw s(h.signal.aborted ? h.signal.reason : k, g);
|
|
193
|
+
if (D = k, !(b && (b.retryOn ?? Ue)(k, x)) || x >= f - 1) throw k;
|
|
194
|
+
await _e($e(b.delay, x), h.signal);
|
|
195
|
+
}
|
|
196
|
+
throw D;
|
|
197
|
+
} finally {
|
|
198
|
+
v !== void 0 && clearTimeout(v), t.signal && E && t.signal.removeEventListener("abort", E), a === h && (a = null);
|
|
199
|
+
}
|
|
200
|
+
}, t);
|
|
201
|
+
return d.abort = () => {
|
|
202
|
+
a && a.abort(new DOMException("Request aborted", "AbortError"));
|
|
203
|
+
}, d;
|
|
204
|
+
};
|
|
205
|
+
function it(e = {}) {
|
|
206
|
+
return (t, n = {}) => {
|
|
207
|
+
const r = e, o = K({}, r.query ?? {}, n.query ?? {});
|
|
208
|
+
return N(t, {
|
|
209
|
+
...r,
|
|
210
|
+
...n,
|
|
211
|
+
headers: ee(r.headers, n.headers),
|
|
212
|
+
query: Object.keys(o).length > 0 ? o : void 0
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
var U = class extends Error {
|
|
217
|
+
constructor(e, t, n, r) {
|
|
218
|
+
super(e), this.name = "HttpError", this.config = t, this.code = n, this.response = r;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
function Q() {
|
|
222
|
+
const e = [];
|
|
223
|
+
let t = 0;
|
|
224
|
+
return {
|
|
225
|
+
use(n, r) {
|
|
226
|
+
const o = t++;
|
|
227
|
+
return e.push({
|
|
228
|
+
id: o,
|
|
229
|
+
fulfilled: n,
|
|
230
|
+
rejected: r
|
|
231
|
+
}), o;
|
|
232
|
+
},
|
|
233
|
+
eject(n) {
|
|
234
|
+
const r = e.findIndex((o) => o?.id === n);
|
|
235
|
+
r !== -1 && (e[r] = null);
|
|
236
|
+
},
|
|
237
|
+
clear() {
|
|
238
|
+
e.length = 0;
|
|
239
|
+
},
|
|
240
|
+
forEach(n) {
|
|
241
|
+
for (const r of e) r && n(r);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
var Be = (e) => e >= 200 && e < 300, ze = (e) => {
|
|
246
|
+
if (e.code === "PARSE") return !1;
|
|
247
|
+
if (e.code === "TIMEOUT" || e.code === "NETWORK") return !0;
|
|
248
|
+
const t = e.response?.status;
|
|
249
|
+
return t !== void 0 && t >= 500;
|
|
250
|
+
}, je = (e) => {
|
|
251
|
+
if (e != null)
|
|
252
|
+
return typeof e == "number" ? { count: e } : e;
|
|
253
|
+
}, He = (e, t) => e == null ? Math.min(1e3 * 2 ** t, 3e4) : typeof e == "number" ? e : e(t), Ve = (e, t) => new Promise((n, r) => {
|
|
254
|
+
if (t?.aborted) {
|
|
255
|
+
r(t.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
let o;
|
|
259
|
+
const i = () => {
|
|
260
|
+
clearTimeout(o), t?.removeEventListener("abort", i), r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
261
|
+
};
|
|
262
|
+
o = setTimeout(() => {
|
|
263
|
+
t?.removeEventListener("abort", i), n();
|
|
264
|
+
}, e), t && t.addEventListener("abort", i, { once: !0 });
|
|
265
|
+
}), ne = (...e) => {
|
|
266
|
+
const t = new Headers();
|
|
267
|
+
for (const n of e)
|
|
268
|
+
n && new Headers(n).forEach((r, o) => {
|
|
269
|
+
t.set(o, r);
|
|
270
|
+
});
|
|
271
|
+
return t;
|
|
272
|
+
}, We = (e) => typeof e == "string" || e instanceof Blob || e instanceof FormData || e instanceof URLSearchParams || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer || typeof ReadableStream < "u" && e instanceof ReadableStream ? !0 : typeof e == "object" && e !== null && ArrayBuffer.isView(e), Fe = (e, t) => e == null || We(e) ? e : (t.has("content-type") || t.set("content-type", "application/json"), JSON.stringify(e)), Je = (e, t) => {
|
|
273
|
+
for (const [n, r] of Object.entries(t))
|
|
274
|
+
if (r != null) {
|
|
275
|
+
if (Array.isArray(r)) {
|
|
276
|
+
for (const o of r) o != null && e.searchParams.append(n, String(o));
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
e.searchParams.set(n, String(r));
|
|
280
|
+
}
|
|
281
|
+
}, Ge = (e, t) => {
|
|
282
|
+
const n = typeof window < "u" && /^https?:/i.test(window.location.href) ? window.location.href : "http://localhost", r = t ? new URL(t, n).toString() : n;
|
|
283
|
+
return new URL(e, r);
|
|
284
|
+
}, Qe = async (e, t, n) => {
|
|
285
|
+
if (t === "response") return e;
|
|
286
|
+
if (t === "text") return await e.text();
|
|
287
|
+
if (t === "blob") return await e.blob();
|
|
288
|
+
if (t === "arrayBuffer") return await e.arrayBuffer();
|
|
289
|
+
if (t === "formData") return await e.formData();
|
|
290
|
+
const r = await e.text();
|
|
291
|
+
if (r)
|
|
292
|
+
try {
|
|
293
|
+
return JSON.parse(r);
|
|
294
|
+
} catch (o) {
|
|
295
|
+
throw new U(`Failed to parse JSON response${e.url ? ` for ${e.url}` : ""} (status ${e.status}): ${o instanceof Error ? o.message : String(o)}`, n, "PARSE", {
|
|
296
|
+
data: r,
|
|
297
|
+
status: e.status,
|
|
298
|
+
statusText: e.statusText,
|
|
299
|
+
headers: e.headers,
|
|
300
|
+
config: n
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}, Ke = (e, t) => {
|
|
304
|
+
const n = e.body;
|
|
305
|
+
if (!n) return e;
|
|
306
|
+
const r = parseInt(e.headers.get("content-length") ?? "0", 10) || 0;
|
|
307
|
+
let o = 0;
|
|
308
|
+
const i = n.getReader(), a = new ReadableStream({
|
|
309
|
+
async pull(s) {
|
|
310
|
+
const { done: d, value: c } = await i.read();
|
|
311
|
+
if (d) {
|
|
312
|
+
s.close();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
o += c.byteLength, t({
|
|
316
|
+
loaded: o,
|
|
317
|
+
total: r,
|
|
318
|
+
percent: r > 0 ? Math.round(o / r * 100) : void 0
|
|
319
|
+
}), s.enqueue(c);
|
|
320
|
+
},
|
|
321
|
+
cancel(s) {
|
|
322
|
+
i.cancel(s);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return new Response(a, {
|
|
326
|
+
status: e.status,
|
|
327
|
+
statusText: e.statusText,
|
|
328
|
+
headers: e.headers
|
|
329
|
+
});
|
|
330
|
+
}, Ye = async (e) => {
|
|
331
|
+
const t = X().fetch, n = e.parseAs ?? t?.parseAs ?? "json", r = e.fetcher ?? fetch, o = e.validateStatus ?? Be, i = Ge(e.url ?? "/", e.baseUrl ?? t?.baseUrl);
|
|
332
|
+
e.query && Je(i, e.query);
|
|
333
|
+
const a = ne(t?.headers, e.headers), s = Fe(e.body, a), d = {};
|
|
334
|
+
e.method && (d.method = e.method.toUpperCase()), d.headers = a, s != null && (d.body = s), e.cache && (d.cache = e.cache), e.credentials && (d.credentials = e.credentials), e.integrity && (d.integrity = e.integrity), e.keepalive !== void 0 && (d.keepalive = e.keepalive), e.mode && (d.mode = e.mode), e.redirect && (d.redirect = e.redirect), e.referrer && (d.referrer = e.referrer), e.referrerPolicy && (d.referrerPolicy = e.referrerPolicy);
|
|
335
|
+
let c, l = e.signal, m;
|
|
336
|
+
if (e.timeout && e.timeout > 0) {
|
|
337
|
+
const u = new AbortController();
|
|
338
|
+
e.signal && (m = () => u.abort(e.signal?.reason), e.signal.addEventListener("abort", m, { once: !0 })), c = setTimeout(() => {
|
|
339
|
+
u.abort(new DOMException("Request timeout", "TimeoutError"));
|
|
340
|
+
}, e.timeout), l = u.signal;
|
|
341
|
+
}
|
|
342
|
+
l && (d.signal = l);
|
|
343
|
+
try {
|
|
344
|
+
let u = await r(i.toString(), d);
|
|
345
|
+
if (e.onDownloadProgress && (u = Ke(u, e.onDownloadProgress)), !o(u.status)) throw new U(`Request failed with status ${u.status}`, e, "ERR_BAD_RESPONSE", {
|
|
346
|
+
data: void 0,
|
|
347
|
+
status: u.status,
|
|
348
|
+
statusText: u.statusText,
|
|
349
|
+
headers: u.headers,
|
|
350
|
+
config: e
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
data: await Qe(u, n, e),
|
|
354
|
+
status: u.status,
|
|
355
|
+
statusText: u.statusText,
|
|
356
|
+
headers: u.headers,
|
|
357
|
+
config: e
|
|
358
|
+
};
|
|
359
|
+
} catch (u) {
|
|
360
|
+
if (u instanceof U) throw u;
|
|
361
|
+
if (u instanceof DOMException && (u.name === "AbortError" || u.name === "TimeoutError")) {
|
|
362
|
+
const p = u.name === "TimeoutError" || u.message === "Request timeout";
|
|
363
|
+
throw new U(p ? `Request timeout of ${e.timeout}ms exceeded` : "Request aborted", e, p ? "TIMEOUT" : "ABORT");
|
|
364
|
+
}
|
|
365
|
+
throw new U(u instanceof Error ? u.message : String(u), e, "NETWORK");
|
|
366
|
+
} finally {
|
|
367
|
+
c !== void 0 && clearTimeout(c), e.signal && m && e.signal.removeEventListener("abort", m);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
function ae(e = {}) {
|
|
371
|
+
const t = Q(), n = Q(), r = (a) => {
|
|
372
|
+
const s = K({}, e.query ?? {}, a.query ?? {});
|
|
373
|
+
return {
|
|
374
|
+
...e,
|
|
375
|
+
...a,
|
|
376
|
+
headers: ne(e.headers, a.headers),
|
|
377
|
+
query: Object.keys(s).length > 0 ? s : void 0
|
|
378
|
+
};
|
|
379
|
+
}, o = async (a) => {
|
|
380
|
+
let s = a;
|
|
381
|
+
const d = [];
|
|
382
|
+
t.forEach((u) => d.push(u));
|
|
383
|
+
for (const { fulfilled: u, rejected: p } of d) try {
|
|
384
|
+
u && (s = await u(s));
|
|
385
|
+
} catch (y) {
|
|
386
|
+
if (p) {
|
|
387
|
+
const w = await p(y);
|
|
388
|
+
if (pe(w)) s = w;
|
|
389
|
+
else throw y;
|
|
390
|
+
} else throw y;
|
|
391
|
+
}
|
|
392
|
+
const c = je(s.retry);
|
|
393
|
+
let l;
|
|
394
|
+
const m = (c?.count ?? 0) + 1;
|
|
395
|
+
for (let u = 0; u < m; u++) try {
|
|
396
|
+
let p = await Ye(s);
|
|
397
|
+
const y = [];
|
|
398
|
+
n.forEach((w) => y.push(w));
|
|
399
|
+
for (const { fulfilled: w, rejected: R } of y) try {
|
|
400
|
+
w && (p = await w(p));
|
|
401
|
+
} catch (b) {
|
|
402
|
+
if (R) {
|
|
403
|
+
const f = await R(b);
|
|
404
|
+
if (f && typeof f == "object" && "data" in f) p = f;
|
|
405
|
+
else throw b;
|
|
406
|
+
} else throw b;
|
|
407
|
+
}
|
|
408
|
+
return p;
|
|
409
|
+
} catch (p) {
|
|
410
|
+
const y = p instanceof U ? p : new U(p instanceof Error ? p.message : String(p), s, "NETWORK");
|
|
411
|
+
if (l = y, !(c && (c.retryOn ?? ze)(y, u)) || u >= m - 1) {
|
|
412
|
+
const R = [];
|
|
413
|
+
n.forEach((f) => R.push(f));
|
|
414
|
+
let b = y;
|
|
415
|
+
for (const { rejected: f } of R) if (f) try {
|
|
416
|
+
const h = await f(b);
|
|
417
|
+
if (h && typeof h == "object" && "data" in h) return h;
|
|
418
|
+
h != null && (b = h);
|
|
419
|
+
} catch (h) {
|
|
420
|
+
h != null && (b = h);
|
|
421
|
+
}
|
|
422
|
+
throw b instanceof Error || (b = y), b;
|
|
423
|
+
}
|
|
424
|
+
const w = c ? He(c.delay, u) : 0;
|
|
425
|
+
c?.onRetry?.(y, u + 1), await Ve(w, s.signal);
|
|
426
|
+
}
|
|
427
|
+
throw l;
|
|
428
|
+
}, i = (a) => o(r(a));
|
|
429
|
+
return {
|
|
430
|
+
request: i,
|
|
431
|
+
get: (a, s = {}) => i({
|
|
432
|
+
...s,
|
|
433
|
+
url: a,
|
|
434
|
+
method: "GET"
|
|
435
|
+
}),
|
|
436
|
+
post: (a, s, d = {}) => i({
|
|
437
|
+
...d,
|
|
438
|
+
url: a,
|
|
439
|
+
method: "POST",
|
|
440
|
+
body: s
|
|
441
|
+
}),
|
|
442
|
+
put: (a, s, d = {}) => i({
|
|
443
|
+
...d,
|
|
444
|
+
url: a,
|
|
445
|
+
method: "PUT",
|
|
446
|
+
body: s
|
|
447
|
+
}),
|
|
448
|
+
patch: (a, s, d = {}) => i({
|
|
449
|
+
...d,
|
|
450
|
+
url: a,
|
|
451
|
+
method: "PATCH",
|
|
452
|
+
body: s
|
|
453
|
+
}),
|
|
454
|
+
delete: (a, s = {}) => i({
|
|
455
|
+
...s,
|
|
456
|
+
url: a,
|
|
457
|
+
method: "DELETE"
|
|
458
|
+
}),
|
|
459
|
+
head: (a, s = {}) => i({
|
|
460
|
+
...s,
|
|
461
|
+
url: a,
|
|
462
|
+
method: "HEAD"
|
|
463
|
+
}),
|
|
464
|
+
options: (a, s = {}) => i({
|
|
465
|
+
...s,
|
|
466
|
+
url: a,
|
|
467
|
+
method: "OPTIONS"
|
|
468
|
+
}),
|
|
469
|
+
interceptors: {
|
|
470
|
+
request: t,
|
|
471
|
+
response: n
|
|
472
|
+
},
|
|
473
|
+
defaults: e
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
var ut = ae();
|
|
477
|
+
function ct(e = {}) {
|
|
478
|
+
const { concurrency: t = 6 } = e;
|
|
479
|
+
if (!Number.isInteger(t) || t < 1) throw new Error("Request queue concurrency must be a positive integer");
|
|
480
|
+
const n = [];
|
|
481
|
+
let r = 0;
|
|
482
|
+
const o = () => {
|
|
483
|
+
for (; r < t && n.length > 0; ) {
|
|
484
|
+
const i = n.shift();
|
|
485
|
+
r++, Promise.resolve().then(i.execute).then(i.resolve, i.reject).finally(() => {
|
|
486
|
+
r--, o();
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
return {
|
|
491
|
+
add(i) {
|
|
492
|
+
return new Promise((a, s) => {
|
|
493
|
+
n.push({
|
|
494
|
+
execute: i,
|
|
495
|
+
resolve: a,
|
|
496
|
+
reject: s
|
|
497
|
+
}), o();
|
|
498
|
+
});
|
|
499
|
+
},
|
|
500
|
+
get pending() {
|
|
501
|
+
return r;
|
|
502
|
+
},
|
|
503
|
+
get size() {
|
|
504
|
+
return n.length;
|
|
505
|
+
},
|
|
506
|
+
clear() {
|
|
507
|
+
const i = n.splice(0);
|
|
508
|
+
for (const a of i) a.reject(/* @__PURE__ */ new Error("Request queue cleared"));
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
var lt = (e, t) => {
|
|
513
|
+
const n = q(e);
|
|
514
|
+
return {
|
|
515
|
+
get value() {
|
|
516
|
+
return n.value;
|
|
517
|
+
},
|
|
518
|
+
set value(r) {
|
|
519
|
+
t(r);
|
|
520
|
+
},
|
|
521
|
+
peek() {
|
|
522
|
+
return n.peek();
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
}, dt = (e, t = {}) => {
|
|
526
|
+
const { initialPage: n = 1, ...r } = t, o = C(n), i = N(() => e(o.value), {
|
|
527
|
+
...r,
|
|
528
|
+
watch: r.watch
|
|
529
|
+
});
|
|
530
|
+
return {
|
|
531
|
+
...i,
|
|
532
|
+
page: o,
|
|
533
|
+
next: async () => (o.value = o.peek() + 1, i.execute()),
|
|
534
|
+
prev: async () => {
|
|
535
|
+
const c = o.peek();
|
|
536
|
+
return c > 1 && (o.value = c - 1), i.execute();
|
|
537
|
+
},
|
|
538
|
+
goTo: async (c) => (o.value = Math.max(1, c), i.execute())
|
|
539
|
+
};
|
|
540
|
+
}, ft = (e, t) => {
|
|
541
|
+
const { getNextCursor: n, transform: r, initialCursor: o, immediate: i = !0, onSuccess: a, onError: s, ...d } = t, c = C([]), l = C(t.defaultValue), m = C(null), u = C("idle"), p = q(() => u.value === "pending"), y = C(o), w = q(() => c.value.length === 0 || y.value !== void 0);
|
|
542
|
+
let R = !1, b = 0;
|
|
543
|
+
const f = (S) => r ? r(S) : S, h = async () => {
|
|
544
|
+
if (R) return l.peek();
|
|
545
|
+
const S = ++b;
|
|
546
|
+
u.value = "pending", m.value = null;
|
|
547
|
+
try {
|
|
548
|
+
const O = N(e(y.peek()), {
|
|
549
|
+
...d,
|
|
550
|
+
immediate: !1,
|
|
551
|
+
watch: void 0
|
|
552
|
+
}), L = await O.execute(), D = O.error.peek();
|
|
553
|
+
if (O.dispose(), R || S !== b) return l.peek();
|
|
554
|
+
if (D)
|
|
555
|
+
return m.value = D, u.value = "error", s?.(D), l.peek();
|
|
556
|
+
if (L !== void 0) {
|
|
557
|
+
const x = L, A = [...c.peek(), x];
|
|
558
|
+
c.value = A, y.value = n(x, A);
|
|
559
|
+
const k = f(A);
|
|
560
|
+
return l.value = k, u.value = "success", a?.(k), k;
|
|
561
|
+
}
|
|
562
|
+
return u.value = "success", l.peek();
|
|
563
|
+
} catch (O) {
|
|
564
|
+
if (R || S !== b) return l.peek();
|
|
565
|
+
const L = O instanceof Error ? O : new Error(String(O));
|
|
566
|
+
return m.value = L, u.value = "error", s?.(L), l.peek();
|
|
567
|
+
}
|
|
568
|
+
}, v = async () => (c.value = [], y.value = o, l.value = t.defaultValue, m.value = null, u.value = "idle", b += 1, h()), g = () => {
|
|
569
|
+
b += 1, c.value = [], y.value = o, l.value = t.defaultValue, m.value = null, u.value = "idle";
|
|
570
|
+
}, E = () => {
|
|
571
|
+
R || (R = !0, b += 1);
|
|
572
|
+
};
|
|
573
|
+
return i && h(), {
|
|
574
|
+
data: l,
|
|
575
|
+
pages: c,
|
|
576
|
+
error: m,
|
|
577
|
+
status: u,
|
|
578
|
+
pending: p,
|
|
579
|
+
hasMore: w,
|
|
580
|
+
fetchNextPage: h,
|
|
581
|
+
refresh: v,
|
|
582
|
+
clear: g,
|
|
583
|
+
dispose: E
|
|
584
|
+
};
|
|
585
|
+
}, vt = (e, t) => {
|
|
586
|
+
let n = !1, r = null;
|
|
587
|
+
try {
|
|
588
|
+
if (r = globalThis.localStorage, r) {
|
|
589
|
+
const a = `__bquery_test_${Math.random().toString(36).slice(2, 9)}__`, s = "__test__";
|
|
590
|
+
try {
|
|
591
|
+
r.setItem(a, s), r.getItem(a), n = !0;
|
|
592
|
+
} finally {
|
|
593
|
+
try {
|
|
594
|
+
r.removeItem(a);
|
|
595
|
+
} catch {
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
} catch {
|
|
600
|
+
n = !1;
|
|
601
|
+
}
|
|
602
|
+
let o = t;
|
|
603
|
+
if (n && r) try {
|
|
604
|
+
const a = r.getItem(e);
|
|
605
|
+
a !== null && (o = JSON.parse(a));
|
|
606
|
+
} catch {
|
|
607
|
+
}
|
|
608
|
+
const i = C(o);
|
|
609
|
+
return n && r && z(() => {
|
|
610
|
+
try {
|
|
611
|
+
r.setItem(e, JSON.stringify(i.value));
|
|
612
|
+
} catch {
|
|
613
|
+
}
|
|
614
|
+
}), i;
|
|
615
|
+
}, mt = (e, t) => {
|
|
616
|
+
const { interval: n, enabled: r = !0, pauseOnHidden: o = !0, pauseOnOffline: i = !0, immediate: a = !0, ...s } = t;
|
|
617
|
+
if (!Number.isFinite(n) || n < 1) throw new Error("Polling interval must be a finite number of at least 1");
|
|
618
|
+
const d = C(!1), c = C(!1), l = C(!1), m = typeof r == "function" ? r : () => r, u = q(() => m() && !d.value && !(o && c.value) && !(i && l.value)), p = N(e, {
|
|
619
|
+
...s,
|
|
620
|
+
immediate: a && m()
|
|
621
|
+
});
|
|
622
|
+
let y, w = [];
|
|
623
|
+
const R = () => {
|
|
624
|
+
b(), y = setInterval(() => {
|
|
625
|
+
p.execute();
|
|
626
|
+
}, n);
|
|
627
|
+
}, b = () => {
|
|
628
|
+
y !== void 0 && (clearInterval(y), y = void 0);
|
|
629
|
+
}, f = z(() => {
|
|
630
|
+
const g = u.value;
|
|
631
|
+
V(() => {
|
|
632
|
+
g ? R() : b();
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
if (o && typeof document < "u") {
|
|
636
|
+
c.value = document.hidden;
|
|
637
|
+
const g = () => {
|
|
638
|
+
c.value = document.hidden;
|
|
639
|
+
};
|
|
640
|
+
document.addEventListener("visibilitychange", g), w.push(() => document.removeEventListener("visibilitychange", g));
|
|
641
|
+
}
|
|
642
|
+
if (i && typeof window < "u") {
|
|
643
|
+
const g = () => {
|
|
644
|
+
l.value = !1;
|
|
645
|
+
}, E = () => {
|
|
646
|
+
l.value = !0;
|
|
647
|
+
};
|
|
648
|
+
window.addEventListener("online", g), window.addEventListener("offline", E), w.push(() => {
|
|
649
|
+
window.removeEventListener("online", g), window.removeEventListener("offline", E);
|
|
650
|
+
}), l.value = typeof navigator < "u" && navigator.onLine !== void 0 ? !navigator.onLine : !1;
|
|
651
|
+
}
|
|
652
|
+
const h = p.dispose;
|
|
653
|
+
return {
|
|
654
|
+
...p,
|
|
655
|
+
pause: () => {
|
|
656
|
+
d.value = !0;
|
|
657
|
+
},
|
|
658
|
+
resume: () => {
|
|
659
|
+
d.value = !1;
|
|
660
|
+
},
|
|
661
|
+
isActive: u,
|
|
662
|
+
dispose: () => {
|
|
663
|
+
b(), f();
|
|
664
|
+
for (const g of w) g();
|
|
665
|
+
w = [], h();
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
}, se = /* @__PURE__ */ Symbol("bquery.readonlySignal"), Xe = (e) => typeof e == "object" && e !== null && Object.prototype.hasOwnProperty.call(e, se), ht = (e) => Object.defineProperties({}, {
|
|
669
|
+
value: {
|
|
670
|
+
get() {
|
|
671
|
+
return e.value;
|
|
672
|
+
},
|
|
673
|
+
enumerable: !0
|
|
674
|
+
},
|
|
675
|
+
peek: {
|
|
676
|
+
value() {
|
|
677
|
+
return e.peek();
|
|
678
|
+
},
|
|
679
|
+
enumerable: !0
|
|
680
|
+
},
|
|
681
|
+
[se]: {
|
|
682
|
+
value: !0,
|
|
683
|
+
enumerable: !1,
|
|
684
|
+
configurable: !1,
|
|
685
|
+
writable: !1
|
|
686
|
+
}
|
|
687
|
+
}), pt = (e, t = {}) => {
|
|
688
|
+
const { optimistic: n = !1, onMutationSuccess: r, onMutationError: o, ...i } = t, a = N(e, { ...i }), s = C(!1), d = q(() => s.value);
|
|
689
|
+
let c = !1;
|
|
690
|
+
const l = () => {
|
|
691
|
+
const R = typeof e == "function" ? e() : e;
|
|
692
|
+
return R instanceof URL ? R.toString() : R;
|
|
693
|
+
}, m = () => {
|
|
694
|
+
const { defaultValue: R, transform: b, onSuccess: f, onError: h, ...v } = i;
|
|
695
|
+
return v;
|
|
696
|
+
}, u = async (R, b, f, h) => {
|
|
697
|
+
if (c) return a.data.peek();
|
|
698
|
+
const v = a.data.peek();
|
|
699
|
+
n && h !== void 0 && (a.data.value = h), s.value = !0, a.error.value = null;
|
|
700
|
+
try {
|
|
701
|
+
const g = N(l(), {
|
|
702
|
+
...m(),
|
|
703
|
+
method: b,
|
|
704
|
+
body: f ?? void 0,
|
|
705
|
+
immediate: !1,
|
|
706
|
+
watch: void 0
|
|
707
|
+
}), E = await g.execute(), S = g.error.peek();
|
|
708
|
+
return g.dispose(), c ? a.data.peek() : S ? (n && h !== void 0 && (a.data.value = v), a.error.value = S, a.status.value = "error", s.value = !1, o?.(S, R), a.data.peek()) : (b !== "DELETE" && E !== void 0 && (a.data.value = E), s.value = !1, a.status.value = "success", r?.(E, R), E);
|
|
709
|
+
} catch (g) {
|
|
710
|
+
if (c) return a.data.peek();
|
|
711
|
+
n && h !== void 0 && (a.data.value = v);
|
|
712
|
+
const E = g instanceof Error ? g : new Error(String(g));
|
|
713
|
+
return a.error.value = E, a.status.value = "error", s.value = !1, o?.(E, R), a.data.peek();
|
|
714
|
+
}
|
|
715
|
+
}, p = {
|
|
716
|
+
fetch: () => a.execute(),
|
|
717
|
+
create: (R) => u("create", "POST", R),
|
|
718
|
+
update: (R) => {
|
|
719
|
+
const b = a.data.peek();
|
|
720
|
+
return u("update", "PUT", R, n && b !== void 0 ? {
|
|
721
|
+
...b,
|
|
722
|
+
...R
|
|
723
|
+
} : void 0);
|
|
724
|
+
},
|
|
725
|
+
patch: (R) => {
|
|
726
|
+
const b = a.data.peek();
|
|
727
|
+
return u("patch", "PATCH", R, n && b !== void 0 ? {
|
|
728
|
+
...b,
|
|
729
|
+
...R
|
|
730
|
+
} : void 0);
|
|
731
|
+
},
|
|
732
|
+
remove: async () => {
|
|
733
|
+
await u("remove", "DELETE"), !c && a.error.peek() == null && (a.data.value = void 0);
|
|
734
|
+
}
|
|
735
|
+
}, y = a.dispose, w = () => {
|
|
736
|
+
c || (c = !0, y());
|
|
737
|
+
};
|
|
738
|
+
return {
|
|
739
|
+
data: a.data,
|
|
740
|
+
error: a.error,
|
|
741
|
+
status: a.status,
|
|
742
|
+
pending: a.pending,
|
|
743
|
+
isMutating: d,
|
|
744
|
+
actions: p,
|
|
745
|
+
refresh: a.execute,
|
|
746
|
+
clear: a.clear,
|
|
747
|
+
dispose: w
|
|
748
|
+
};
|
|
749
|
+
}, yt = (e, t = {}) => {
|
|
750
|
+
const { method: n = "POST", ...r } = t, o = C(void 0), i = C(null), a = C("idle"), s = q(() => a.value === "pending");
|
|
751
|
+
return {
|
|
752
|
+
data: o,
|
|
753
|
+
error: i,
|
|
754
|
+
status: a,
|
|
755
|
+
pending: s,
|
|
756
|
+
submit: async (l) => {
|
|
757
|
+
a.value = "pending", i.value = null;
|
|
758
|
+
try {
|
|
759
|
+
const m = N(e, {
|
|
760
|
+
...r,
|
|
761
|
+
method: n,
|
|
762
|
+
body: l,
|
|
763
|
+
immediate: !1,
|
|
764
|
+
watch: void 0
|
|
765
|
+
}), u = await m.execute(), p = m.error.peek();
|
|
766
|
+
if (m.dispose(), p) {
|
|
767
|
+
i.value = p, a.value = "error";
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
return o.value = u, a.value = "success", u;
|
|
771
|
+
} catch (m) {
|
|
772
|
+
i.value = m instanceof Error ? m : new Error(String(m)), a.value = "error";
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
clear: () => {
|
|
777
|
+
o.value = void 0, i.value = null, a.value = "idle";
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
}, gt = (e, t = {}) => {
|
|
781
|
+
const n = ae({ ...t });
|
|
782
|
+
let r = e;
|
|
783
|
+
for (; r.endsWith("/"); ) r = r.slice(0, -1);
|
|
784
|
+
return {
|
|
785
|
+
list: (o) => n.get(r, o),
|
|
786
|
+
get: (o, i) => n.get(`${r}/${encodeURIComponent(String(o))}`, i),
|
|
787
|
+
create: (o, i) => n.post(r, o, i),
|
|
788
|
+
update: (o, i, a) => n.put(`${r}/${encodeURIComponent(String(o))}`, i, a),
|
|
789
|
+
patch: (o, i, a) => n.patch(`${r}/${encodeURIComponent(String(o))}`, i, a),
|
|
790
|
+
remove: (o, i) => n.delete(`${r}/${encodeURIComponent(String(o))}`, i),
|
|
791
|
+
http: n
|
|
792
|
+
};
|
|
793
|
+
}, Et = (e, t = {}) => {
|
|
794
|
+
const { getId: n = (f) => f.id, optimistic: r = !1, onMutationSuccess: o, onMutationError: i, ...a } = t, s = N(e, { ...a }), d = C(!1), c = q(() => d.value);
|
|
795
|
+
let l = !1;
|
|
796
|
+
const m = () => {
|
|
797
|
+
const f = typeof e == "function" ? e() : e;
|
|
798
|
+
return f instanceof URL ? f.toString() : f;
|
|
799
|
+
}, u = () => {
|
|
800
|
+
let f = m();
|
|
801
|
+
for (; f.endsWith("/"); ) f = f.slice(0, -1);
|
|
802
|
+
return f;
|
|
803
|
+
}, p = () => {
|
|
804
|
+
const { defaultValue: f, transform: h, onSuccess: v, onError: g, ...E } = a;
|
|
805
|
+
return E;
|
|
806
|
+
}, y = async (f, h, v, g, E, S) => {
|
|
807
|
+
if (!l) {
|
|
808
|
+
r && E && E(), d.value = !0, s.error.value = null;
|
|
809
|
+
try {
|
|
810
|
+
const O = N(`${u()}${v}`, {
|
|
811
|
+
...p(),
|
|
812
|
+
method: h,
|
|
813
|
+
body: g ?? void 0,
|
|
814
|
+
immediate: !1,
|
|
815
|
+
watch: void 0
|
|
816
|
+
}), L = await O.execute(), D = O.error.peek();
|
|
817
|
+
if (O.dispose(), l) return;
|
|
818
|
+
if (D) {
|
|
819
|
+
r && S && S(), s.error.value = D, s.status.value = "error", d.value = !1, i?.(D, f);
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
return d.value = !1, s.status.value = "success", o?.(f), L;
|
|
823
|
+
} catch (O) {
|
|
824
|
+
if (l) return;
|
|
825
|
+
r && S && S();
|
|
826
|
+
const L = O instanceof Error ? O : new Error(String(O));
|
|
827
|
+
s.error.value = L, s.status.value = "error", d.value = !1, i?.(L, f);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}, w = {
|
|
832
|
+
fetch: () => s.execute(),
|
|
833
|
+
add: async (f) => {
|
|
834
|
+
const h = s.data.peek(), v = f, g = h?.length ?? 0, E = await y("add", "POST", "", f, r ? () => {
|
|
835
|
+
s.data.value = [...h ?? [], v];
|
|
836
|
+
} : void 0, r ? () => {
|
|
837
|
+
s.data.value = h;
|
|
838
|
+
} : void 0);
|
|
839
|
+
if (E !== void 0 && !l) {
|
|
840
|
+
const S = s.data.peek() ?? [];
|
|
841
|
+
if (r) {
|
|
842
|
+
const O = [...S];
|
|
843
|
+
g < O.length && O[g] === v ? O[g] = E : O.push(E), s.data.value = O;
|
|
844
|
+
} else s.data.value = [...S, E];
|
|
845
|
+
}
|
|
846
|
+
return E;
|
|
847
|
+
},
|
|
848
|
+
update: async (f, h) => {
|
|
849
|
+
const v = s.data.peek(), g = await y("update", "PUT", `/${encodeURIComponent(String(f))}`, h, r && v ? () => {
|
|
850
|
+
s.data.value = v.map((E) => n(E) === f ? {
|
|
851
|
+
...E,
|
|
852
|
+
...h
|
|
853
|
+
} : E);
|
|
854
|
+
} : void 0, r ? () => {
|
|
855
|
+
s.data.value = v;
|
|
856
|
+
} : void 0);
|
|
857
|
+
if (g !== void 0 && !l) {
|
|
858
|
+
const E = s.data.peek() ?? [];
|
|
859
|
+
s.data.value = E.map((S) => n(S) === f ? g : S);
|
|
860
|
+
}
|
|
861
|
+
return g;
|
|
862
|
+
},
|
|
863
|
+
patch: async (f, h) => {
|
|
864
|
+
const v = s.data.peek(), g = await y("patch", "PATCH", `/${encodeURIComponent(String(f))}`, h, r && v ? () => {
|
|
865
|
+
s.data.value = v.map((E) => n(E) === f ? {
|
|
866
|
+
...E,
|
|
867
|
+
...h
|
|
868
|
+
} : E);
|
|
869
|
+
} : void 0, r ? () => {
|
|
870
|
+
s.data.value = v;
|
|
871
|
+
} : void 0);
|
|
872
|
+
if (g !== void 0 && !l) {
|
|
873
|
+
const E = s.data.peek() ?? [];
|
|
874
|
+
s.data.value = E.map((S) => n(S) === f ? g : S);
|
|
875
|
+
}
|
|
876
|
+
return g;
|
|
877
|
+
},
|
|
878
|
+
remove: async (f) => {
|
|
879
|
+
const h = s.data.peek();
|
|
880
|
+
if (await y("remove", "DELETE", `/${encodeURIComponent(String(f))}`, void 0, r && h ? () => {
|
|
881
|
+
s.data.value = h.filter((v) => n(v) !== f);
|
|
882
|
+
} : void 0, r ? () => {
|
|
883
|
+
s.data.value = h;
|
|
884
|
+
} : void 0), !r && !l && s.error.peek() == null) {
|
|
885
|
+
const v = s.data.peek() ?? [];
|
|
886
|
+
s.data.value = v.filter((g) => n(g) !== f);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}, R = s.dispose, b = () => {
|
|
890
|
+
l || (l = !0, R());
|
|
891
|
+
};
|
|
892
|
+
return {
|
|
893
|
+
data: s.data,
|
|
894
|
+
error: s.error,
|
|
895
|
+
status: s.status,
|
|
896
|
+
pending: s.pending,
|
|
897
|
+
isMutating: c,
|
|
898
|
+
actions: w,
|
|
899
|
+
refresh: s.execute,
|
|
900
|
+
clear: s.clear,
|
|
901
|
+
dispose: b
|
|
902
|
+
};
|
|
903
|
+
}, H = /* @__PURE__ */ new Map();
|
|
904
|
+
function wt(e, t) {
|
|
905
|
+
const n = H.get(e);
|
|
906
|
+
if (n) return n;
|
|
907
|
+
const r = t().finally(() => {
|
|
908
|
+
H.delete(e);
|
|
909
|
+
});
|
|
910
|
+
return H.set(e, r), r;
|
|
911
|
+
}
|
|
912
|
+
var bt = (e) => e instanceof Y, St = (e) => e instanceof Z, Rt = (e) => e instanceof Y || e instanceof Z || Xe(e) ? e.value : e, oe = (e, t, n = {}) => {
|
|
913
|
+
const { immediate: r = !1, equals: o = Object.is } = n;
|
|
914
|
+
let i, a = !0;
|
|
915
|
+
return z(() => {
|
|
916
|
+
const s = e.value;
|
|
917
|
+
if (a) {
|
|
918
|
+
a = !1, i = s, r && t(s, void 0);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
o(s, i) || (t(s, i), i = s);
|
|
922
|
+
});
|
|
923
|
+
}, Tt = (e, t, n, r = {}) => {
|
|
924
|
+
const { immediate: o = !1, equals: i = Object.is } = r, a = Number.isFinite(n) ? Math.max(0, n) : 0;
|
|
925
|
+
let s = !1, d, c;
|
|
926
|
+
const l = () => {
|
|
927
|
+
m.cancel(), s = !1, c = void 0;
|
|
928
|
+
}, m = ge(() => {
|
|
929
|
+
if (s) {
|
|
930
|
+
try {
|
|
931
|
+
t(d, c);
|
|
932
|
+
} catch (p) {
|
|
933
|
+
console.error("bQuery reactive: Error in watchDebounce callback", p);
|
|
934
|
+
}
|
|
935
|
+
s = !1, c = void 0;
|
|
936
|
+
}
|
|
937
|
+
}, a);
|
|
938
|
+
o && t(e.peek(), void 0);
|
|
939
|
+
const u = oe(e, (p, y) => {
|
|
940
|
+
s || (c = y), d = p, s = !0, m();
|
|
941
|
+
}, { equals: i });
|
|
942
|
+
return Se() && Ee(l), () => {
|
|
943
|
+
u(), l();
|
|
944
|
+
};
|
|
945
|
+
}, Ot = (e, t, n, r = {}) => {
|
|
946
|
+
const { immediate: o = !1, equals: i = Object.is } = r, a = ye((d, c) => {
|
|
947
|
+
t(d, c);
|
|
948
|
+
}, Number.isFinite(n) ? Math.max(0, n) : 0);
|
|
949
|
+
o && a(e.peek(), void 0);
|
|
950
|
+
const s = oe(e, (d, c) => {
|
|
951
|
+
a(d, c);
|
|
952
|
+
}, { equals: i });
|
|
953
|
+
return () => {
|
|
954
|
+
s(), a.cancel();
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
function ie(e) {
|
|
958
|
+
return e === !1 ? !1 : e === !0 || e === void 0 ? {} : e;
|
|
959
|
+
}
|
|
960
|
+
var Ze = (e) => e ? e === !0 ? {} : e : !1, ue = (e, t) => {
|
|
961
|
+
const n = t.delay ?? 1e3, r = t.factor ?? 2, o = t.maxDelay ?? 3e4;
|
|
962
|
+
return Math.min(n * r ** e, o);
|
|
963
|
+
}, et = (e, t = {}) => {
|
|
964
|
+
const { protocols: n, immediate: r = !0, historySize: o = 0, onOpen: i, onMessage: a, onClose: s, onError: d, onReconnect: c } = t, l = t.serialize ?? ((T) => JSON.stringify(T)), m = t.deserialize ?? ((T) => {
|
|
965
|
+
const P = T.data;
|
|
966
|
+
if (typeof P == "string") try {
|
|
967
|
+
return JSON.parse(P);
|
|
968
|
+
} catch {
|
|
969
|
+
return P;
|
|
970
|
+
}
|
|
971
|
+
return P;
|
|
972
|
+
}), u = C("CLOSED"), p = C(void 0), y = C(null), w = C([]), R = C(0), b = C(0), f = C(0), h = q(() => u.value === "OPEN");
|
|
973
|
+
let v = null, g = !1, E = !1, S, O, L, D = 0, x = !1, A = 0;
|
|
974
|
+
const k = [], $ = ie(t.autoReconnect), M = Ze(t.heartbeat), ce = () => {
|
|
975
|
+
if (!M) return;
|
|
976
|
+
_();
|
|
977
|
+
const T = M.interval ?? 3e4, P = M.pongTimeout ?? 1e4, I = M.message ?? "ping";
|
|
978
|
+
O = setInterval(() => {
|
|
979
|
+
v?.readyState === WebSocket.OPEN && (A = Date.now(), v.send(I), L !== void 0 && clearTimeout(L), L = setTimeout(() => {
|
|
980
|
+
v?.close(4e3, "Heartbeat timeout");
|
|
981
|
+
}, P));
|
|
982
|
+
}, T);
|
|
983
|
+
}, _ = () => {
|
|
984
|
+
O !== void 0 && (clearInterval(O), O = void 0), L !== void 0 && (clearTimeout(L), L = void 0);
|
|
985
|
+
}, le = () => {
|
|
986
|
+
L !== void 0 && (clearTimeout(L), L = void 0), A > 0 && (b.value = Date.now() - A, A = 0);
|
|
987
|
+
}, de = (T) => {
|
|
988
|
+
if (g || E || !$) return;
|
|
989
|
+
const P = $.maxAttempts ?? 1 / 0;
|
|
990
|
+
if (D >= P || $.shouldReconnect && !$.shouldReconnect(T, D)) return;
|
|
991
|
+
const I = ue(D, $);
|
|
992
|
+
S = setTimeout(() => {
|
|
993
|
+
D++, R.value = D, x = !0, j();
|
|
994
|
+
}, I);
|
|
995
|
+
}, F = () => {
|
|
996
|
+
S !== void 0 && (clearTimeout(S), S = void 0);
|
|
997
|
+
}, fe = () => {
|
|
998
|
+
if (!v || v.readyState !== WebSocket.OPEN) return;
|
|
999
|
+
let T = 0;
|
|
1000
|
+
for (; T < k.length && v.readyState === WebSocket.OPEN; T++)
|
|
1001
|
+
v.send(k[T]);
|
|
1002
|
+
T > 0 && k.splice(0, T);
|
|
1003
|
+
}, ve = () => {
|
|
1004
|
+
const T = typeof e == "function" ? e() : e;
|
|
1005
|
+
return T instanceof URL ? T.toString() : T;
|
|
1006
|
+
}, j = () => {
|
|
1007
|
+
if (!g) {
|
|
1008
|
+
F(), v && (_(), A = 0, v.onopen = null, v.onmessage = null, v.onclose = null, v.onerror = null, (v.readyState === WebSocket.OPEN || v.readyState === WebSocket.CONNECTING) && v.close(), v = null), E = !1, u.value = "CONNECTING", y.value = null;
|
|
1009
|
+
try {
|
|
1010
|
+
v = new WebSocket(ve(), n);
|
|
1011
|
+
} catch {
|
|
1012
|
+
u.value = "CLOSED";
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
v.onopen = (T) => {
|
|
1016
|
+
u.value = "OPEN";
|
|
1017
|
+
const P = x, I = D;
|
|
1018
|
+
D = 0, R.value = 0, x = !1, fe(), ce(), i?.(T), P && c?.(I);
|
|
1019
|
+
}, v.onmessage = (T) => {
|
|
1020
|
+
if (M) {
|
|
1021
|
+
const I = M.responseMessage;
|
|
1022
|
+
(I === void 0 || T.data === I) && le();
|
|
1023
|
+
}
|
|
1024
|
+
const P = m(T);
|
|
1025
|
+
if (p.value = P, o > 0) {
|
|
1026
|
+
const I = [...w.peek(), P];
|
|
1027
|
+
w.value = I.length > o ? I.slice(-o) : I;
|
|
1028
|
+
}
|
|
1029
|
+
a?.(P, T);
|
|
1030
|
+
}, v.onclose = (T) => {
|
|
1031
|
+
u.value = "CLOSED", _(), E || (f.value = Date.now()), s?.(T), !E && !g && de(T);
|
|
1032
|
+
}, v.onerror = (T) => {
|
|
1033
|
+
y.value = T, d?.(T);
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
}, J = (T, P) => {
|
|
1037
|
+
E = !0, F(), _(), v && (v.readyState === WebSocket.OPEN || v.readyState === WebSocket.CONNECTING) && (u.value = "CLOSING", v.close(T, P));
|
|
1038
|
+
}, me = (T) => {
|
|
1039
|
+
g || G(l(T));
|
|
1040
|
+
}, G = (T) => {
|
|
1041
|
+
g || (v?.readyState === WebSocket.OPEN ? v.send(T) : k.push(T));
|
|
1042
|
+
}, he = () => {
|
|
1043
|
+
g || (g = !0, J(), k.length = 0, v = null);
|
|
1044
|
+
};
|
|
1045
|
+
return r && j(), {
|
|
1046
|
+
status: u,
|
|
1047
|
+
data: p,
|
|
1048
|
+
error: y,
|
|
1049
|
+
history: w,
|
|
1050
|
+
isConnected: h,
|
|
1051
|
+
reconnectAttempts: R,
|
|
1052
|
+
latency: b,
|
|
1053
|
+
lastDisconnectedAt: f,
|
|
1054
|
+
send: me,
|
|
1055
|
+
sendRaw: G,
|
|
1056
|
+
open: j,
|
|
1057
|
+
close: J,
|
|
1058
|
+
dispose: he
|
|
1059
|
+
};
|
|
1060
|
+
}, xt = (e, t = {}, n = {}) => {
|
|
1061
|
+
const r = n.getChannel ?? ((l) => l.channel), o = n.wrap ?? ((l, m) => ({
|
|
1062
|
+
channel: l,
|
|
1063
|
+
data: m
|
|
1064
|
+
})), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), s = et(e, {
|
|
1065
|
+
...t,
|
|
1066
|
+
onMessage: (l, m) => {
|
|
1067
|
+
const u = r(l);
|
|
1068
|
+
if (u !== void 0) {
|
|
1069
|
+
const p = i.get(u);
|
|
1070
|
+
p && (p.value = l);
|
|
1071
|
+
}
|
|
1072
|
+
t.onMessage?.(l, m);
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
return {
|
|
1076
|
+
subscribe: (l) => {
|
|
1077
|
+
let m = i.get(l);
|
|
1078
|
+
m || (m = C(void 0), i.set(l, m)), a.set(l, (a.get(l) ?? 0) + 1);
|
|
1079
|
+
let u = !1;
|
|
1080
|
+
return {
|
|
1081
|
+
data: m,
|
|
1082
|
+
unsubscribe: () => {
|
|
1083
|
+
if (u) return;
|
|
1084
|
+
u = !0;
|
|
1085
|
+
const p = (a.get(l) ?? 1) - 1;
|
|
1086
|
+
p <= 0 ? (a.delete(l), i.delete(l)) : a.set(l, p);
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
},
|
|
1090
|
+
publish: (l, m) => {
|
|
1091
|
+
s.send(o(l, m));
|
|
1092
|
+
},
|
|
1093
|
+
ws: s
|
|
1094
|
+
};
|
|
1095
|
+
}, Ct = (e, t = {}) => {
|
|
1096
|
+
const { immediate: n = !0, events: r = [], eventSourceInit: o, onOpen: i, onMessage: a, onError: s } = t, d = t.deserialize ?? ((x) => {
|
|
1097
|
+
try {
|
|
1098
|
+
return JSON.parse(x);
|
|
1099
|
+
} catch {
|
|
1100
|
+
return x;
|
|
1101
|
+
}
|
|
1102
|
+
}), c = C("CLOSED"), l = C(void 0), m = C(void 0), u = C(null), p = q(() => c.value === "OPEN"), y = ie(t.autoReconnect);
|
|
1103
|
+
let w = null, R = !1, b = !1, f, h = 0;
|
|
1104
|
+
const v = () => {
|
|
1105
|
+
const x = typeof e == "function" ? e() : e;
|
|
1106
|
+
return x instanceof URL ? x.toString() : x;
|
|
1107
|
+
}, g = (x) => (A) => {
|
|
1108
|
+
const k = d(A.data);
|
|
1109
|
+
l.value = k, m.value = x, a?.(k, A);
|
|
1110
|
+
}, E = () => {
|
|
1111
|
+
f !== void 0 && (clearTimeout(f), f = void 0);
|
|
1112
|
+
}, S = () => {
|
|
1113
|
+
if (R || b || !y) return;
|
|
1114
|
+
const x = y.maxAttempts ?? 1 / 0;
|
|
1115
|
+
if (h >= x) return;
|
|
1116
|
+
const A = ue(h, y);
|
|
1117
|
+
f = setTimeout(() => {
|
|
1118
|
+
h++, O();
|
|
1119
|
+
}, A);
|
|
1120
|
+
}, O = () => {
|
|
1121
|
+
if (!R) {
|
|
1122
|
+
E(), w && (w.close(), w = null), b = !1, c.value = "CONNECTING", u.value = null;
|
|
1123
|
+
try {
|
|
1124
|
+
w = new EventSource(v(), o);
|
|
1125
|
+
} catch {
|
|
1126
|
+
c.value = "CLOSED";
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
w.onopen = (x) => {
|
|
1130
|
+
c.value = "OPEN", h = 0, i?.(x);
|
|
1131
|
+
}, w.onerror = (x) => {
|
|
1132
|
+
u.value = x, s?.(x), w?.readyState === EventSource.CLOSED && (c.value = "CLOSED", !b && !R && S());
|
|
1133
|
+
}, w.addEventListener("message", g("message"));
|
|
1134
|
+
for (const x of r) w.addEventListener(x, g(x));
|
|
1135
|
+
}
|
|
1136
|
+
}, L = () => {
|
|
1137
|
+
b = !0, E(), w && (w.close(), w = null), c.value = "CLOSED";
|
|
1138
|
+
}, D = () => {
|
|
1139
|
+
R || (R = !0, L());
|
|
1140
|
+
};
|
|
1141
|
+
return n && O(), {
|
|
1142
|
+
status: c,
|
|
1143
|
+
data: l,
|
|
1144
|
+
eventName: m,
|
|
1145
|
+
error: u,
|
|
1146
|
+
isConnected: p,
|
|
1147
|
+
open: O,
|
|
1148
|
+
close: L,
|
|
1149
|
+
dispose: D
|
|
1150
|
+
};
|
|
1151
|
+
};
|
|
1152
|
+
export {
|
|
1153
|
+
ae as C,
|
|
1154
|
+
qe as D,
|
|
1155
|
+
it as E,
|
|
1156
|
+
N as O,
|
|
1157
|
+
U as S,
|
|
1158
|
+
ut as T,
|
|
1159
|
+
mt as _,
|
|
1160
|
+
Tt as a,
|
|
1161
|
+
dt as b,
|
|
1162
|
+
St as c,
|
|
1163
|
+
wt as d,
|
|
1164
|
+
pt as f,
|
|
1165
|
+
ht as g,
|
|
1166
|
+
Xe as h,
|
|
1167
|
+
oe as i,
|
|
1168
|
+
ot as k,
|
|
1169
|
+
bt as l,
|
|
1170
|
+
yt as m,
|
|
1171
|
+
et as n,
|
|
1172
|
+
Ot as o,
|
|
1173
|
+
Et as p,
|
|
1174
|
+
xt as r,
|
|
1175
|
+
Rt as s,
|
|
1176
|
+
Ct as t,
|
|
1177
|
+
gt as u,
|
|
1178
|
+
vt as v,
|
|
1179
|
+
ct as w,
|
|
1180
|
+
lt as x,
|
|
1181
|
+
ft as y
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
//# sourceMappingURL=reactive-BjpLkclt.js.map
|