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