@ahoo-wang/fetcher-react 3.2.8 → 3.3.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/dist/index.es.js CHANGED
@@ -1,503 +1,484 @@
1
- var M = Object.defineProperty;
2
- var g = (e, t) => M(e, "name", { value: t, configurable: !0 });
3
- import { useRef as v, useCallback as s, useEffect as F, useState as Q, useMemo as E, useReducer as O, useSyncExternalStore as q } from "react";
4
- import { nameGenerator as k } from "@ahoo-wang/fetcher-eventbus";
5
- import { produce as K } from "immer";
6
- import { fetcherRegistrar as U, getFetcher as V } from "@ahoo-wang/fetcher";
7
- function D() {
8
- const e = v(!1), t = s(() => e.current, []);
9
- return F(() => (e.current = !0, () => {
1
+ var U = Object.defineProperty;
2
+ var m = (t, e) => U(t, "name", { value: e, configurable: !0 });
3
+ import { useRef as L, useEffect as p, useState as P, useCallback as h, useMemo as A, useReducer as z, useSyncExternalStore as G } from "react";
4
+ import { c as w } from "react/compiler-runtime";
5
+ import { nameGenerator as T } from "@ahoo-wang/fetcher-eventbus";
6
+ import { produce as V } from "immer";
7
+ import { fetcherRegistrar as N, getFetcher as j } from "@ahoo-wang/fetcher";
8
+ function K() {
9
+ const t = w(3), e = L(!1);
10
+ let r;
11
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ m(() => e.current, "t0"), t[0] = r) : r = t[0];
12
+ const c = r;
13
+ let s, o;
14
+ return t[1] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ m(() => (e.current = !0, () => {
10
15
  e.current = !1;
11
- }), []), t;
16
+ }), "t1"), o = [], t[1] = s, t[2] = o) : (s = t[1], o = t[2]), p(s, o), c;
12
17
  }
13
- g(D, "useMounted");
14
- function S(e) {
15
- const t = v(e);
16
- return t.current = e, t;
18
+ m(K, "useMounted");
19
+ function I(t) {
20
+ const e = L(t);
21
+ return e.current = t, e;
17
22
  }
18
- g(S, "useLatest");
19
- var z = /* @__PURE__ */ ((e) => (e.IDLE = "idle", e.LOADING = "loading", e.SUCCESS = "success", e.ERROR = "error", e))(z || {});
20
- function G(e) {
21
- const [t, n] = Q(
22
- e?.initialStatus ?? "idle"
23
+ m(I, "useLatest");
24
+ var k = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.LOADING = "loading", t.SUCCESS = "success", t.ERROR = "error", t))(k || {});
25
+ function B(t) {
26
+ const [e, r] = P(
27
+ t?.initialStatus ?? "idle"
23
28
  /* IDLE */
24
- ), [u, o] = Q(void 0), [l, i] = Q(void 0), r = D(), d = S(e), a = s(() => {
25
- r() && (n(
29
+ ), [c, s] = P(void 0), [o, d] = P(void 0), i = K(), u = I(t), l = h(() => {
30
+ i() && (r(
26
31
  "loading"
27
32
  /* LOADING */
28
- ), i(void 0));
29
- }, [r]), f = s(
30
- async (m) => {
31
- if (r()) {
32
- o(m), n(
33
- "success"
34
- /* SUCCESS */
35
- ), i(void 0);
36
- try {
37
- await d.current?.onSuccess?.(m);
38
- } catch (y) {
39
- console.warn("PromiseState onSuccess callback error:", y);
40
- }
33
+ ), d(void 0));
34
+ }, [i]), a = h(async (b) => {
35
+ if (i()) {
36
+ s(b), r(
37
+ "success"
38
+ /* SUCCESS */
39
+ ), d(void 0);
40
+ try {
41
+ await u.current?.onSuccess?.(b);
42
+ } catch (g) {
43
+ console.warn("PromiseState onSuccess callback error:", g);
41
44
  }
42
- },
43
- [r, d]
44
- ), c = s(
45
- async (m) => {
46
- if (r()) {
47
- i(m), n(
48
- "error"
49
- /* ERROR */
50
- ), o(void 0);
51
- try {
52
- await d.current?.onError?.(m);
53
- } catch (y) {
54
- console.warn("PromiseState onError callback error:", y);
55
- }
45
+ }
46
+ }, [i, u]), n = h(async (b) => {
47
+ if (i()) {
48
+ d(b), r(
49
+ "error"
50
+ /* ERROR */
51
+ ), s(void 0);
52
+ try {
53
+ await u.current?.onError?.(b);
54
+ } catch (g) {
55
+ console.warn("PromiseState onError callback error:", g);
56
56
  }
57
- },
58
- [r, d]
59
- ), b = s(() => {
60
- r() && (n(
57
+ }
58
+ }, [i, u]), f = h(() => {
59
+ i() && (r(
61
60
  "idle"
62
61
  /* IDLE */
63
- ), i(void 0), o(void 0));
64
- }, [r]);
65
- return E(
66
- () => ({
67
- status: t,
68
- loading: t === "loading",
69
- result: u,
70
- error: l,
71
- setLoading: a,
72
- setSuccess: f,
73
- setError: c,
74
- setIdle: b
75
- }),
76
- [t, u, l, a, f, c, b]
77
- );
62
+ ), d(void 0), s(void 0));
63
+ }, [i]);
64
+ return A(() => ({
65
+ status: e,
66
+ loading: e === "loading",
67
+ result: c,
68
+ error: o,
69
+ setLoading: l,
70
+ setSuccess: a,
71
+ setError: n,
72
+ setIdle: f
73
+ }), [e, c, o, l, a, n, f]);
78
74
  }
79
- g(G, "usePromiseState");
80
- function T() {
81
- const e = v(0), t = s(() => ++e.current, []), n = s(() => e.current, []), u = s((i) => i === e.current, []), o = s(() => {
82
- e.current++;
83
- }, []), l = s(() => {
75
+ m(B, "usePromiseState");
76
+ function H() {
77
+ const t = w(6), e = L(0);
78
+ let r;
79
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ m(() => e.current = e.current + 1, "t0"), t[0] = r) : r = t[0];
80
+ const c = r;
81
+ let s;
82
+ t[1] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ m(() => e.current, "t1"), t[1] = s) : s = t[1];
83
+ const o = s;
84
+ let d;
85
+ t[2] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ m((b) => b === e.current, "t2"), t[2] = d) : d = t[2];
86
+ const i = d;
87
+ let u;
88
+ t[3] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ m(() => {
89
+ e.current = e.current + 1;
90
+ }, "t3"), t[3] = u) : u = t[3];
91
+ const l = u;
92
+ let a;
93
+ t[4] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ m(() => {
84
94
  e.current = 0;
85
- }, []);
86
- return E(() => ({
87
- generate: t,
88
- current: n,
89
- isLatest: u,
90
- invalidate: o,
91
- reset: l
92
- }), [t, n, u, o, l]);
95
+ }, "t4"), t[4] = a) : a = t[4];
96
+ const n = a;
97
+ let f;
98
+ return t[5] === Symbol.for("react.memo_cache_sentinel") ? (f = {
99
+ generate: c,
100
+ current: o,
101
+ isLatest: i,
102
+ invalidate: l,
103
+ reset: n
104
+ }, t[5] = f) : f = t[5], f;
93
105
  }
94
- g(T, "useRequestId");
95
- function p(e) {
106
+ m(H, "useRequestId");
107
+ function M(t) {
96
108
  const {
97
- loading: t,
98
- result: n,
99
- error: u,
100
- status: o,
101
- setLoading: l,
102
- setSuccess: i,
103
- setError: r,
104
- setIdle: d
105
- } = G(e), a = D(), f = T(), c = v(void 0), b = e?.propagateError, m = e?.onAbort, y = s(async () => {
109
+ loading: e,
110
+ result: r,
111
+ error: c,
112
+ status: s,
113
+ setLoading: o,
114
+ setSuccess: d,
115
+ setError: i,
116
+ setIdle: u
117
+ } = B(t), l = K(), a = H(), n = L(void 0), f = t?.propagateError, b = t?.onAbort, g = h(async () => {
106
118
  try {
107
- await m?.();
108
- } catch (w) {
109
- console.warn("useExecutePromise onAbort callback error:", w);
119
+ await b?.();
120
+ } catch (S) {
121
+ console.warn("useExecutePromise onAbort callback error:", S);
110
122
  }
111
- }, [m]), C = s(
112
- async (w) => {
113
- c.current && (c.current.abort(), await y());
114
- const I = new AbortController();
115
- c.current = I;
116
- const A = f.generate();
117
- l();
118
- try {
119
- const R = await w(I);
120
- a() && f.isLatest(A) && await i(R);
121
- } catch (R) {
122
- if (R instanceof Error && R.name === "AbortError") {
123
- a() && d();
124
- return;
125
- }
126
- if (a() && f.isLatest(A) && await r(R), b)
127
- throw R;
128
- } finally {
129
- c.current === I && (c.current = void 0);
123
+ }, [b]), v = h(async (S) => {
124
+ n.current && (n.current.abort(), await g());
125
+ const x = new AbortController();
126
+ n.current = x;
127
+ const R = a.generate();
128
+ o();
129
+ try {
130
+ const y = await S(x);
131
+ l() && a.isLatest(R) && await d(y);
132
+ } catch (y) {
133
+ if (y instanceof Error && y.name === "AbortError") {
134
+ l() && u();
135
+ return;
130
136
  }
131
- },
132
- [
133
- l,
134
- i,
135
- r,
136
- d,
137
- a,
138
- f,
139
- b,
140
- y
141
- ]
142
- ), x = s(() => {
143
- a() && d();
144
- }, [d, a]), h = s(async () => {
145
- x(), c.current && (c.current.abort(), c.current = void 0, await y());
146
- }, [x, y]);
147
- return F(() => () => {
148
- h();
149
- }, [h]), E(
150
- () => ({
151
- loading: t,
152
- result: n,
153
- error: u,
154
- status: o,
155
- execute: C,
156
- reset: x,
157
- abort: h
158
- }),
159
- [t, n, u, o, C, x, h]
160
- );
161
- }
162
- g(p, "useExecutePromise");
163
- function Y() {
164
- const e = v(/* @__PURE__ */ new Map()), t = s((c) => e.current.get(c), []), n = s(
165
- (c, b) => e.current.set(c, b),
166
- []
167
- ), u = s((c) => e.current.has(c), []), o = s((c) => e.current.delete(c), []), l = s(() => e.current.clear(), []), i = s(() => e.current.keys(), []), r = s(() => e.current.values(), []), d = s(() => e.current.entries(), []), a = s(() => e.current[Symbol.iterator](), []), f = s((c) => (b) => {
168
- b ? e.current.set(c, b) : e.current.delete(c);
169
- }, []);
170
- return F(() => () => {
171
- e.current.clear();
172
- }, []), E(
173
- () => ({
174
- register: f,
175
- get: t,
176
- set: n,
177
- has: u,
178
- delete: o,
179
- clear: l,
180
- keys: i,
181
- values: r,
182
- entries: d,
183
- get size() {
184
- return e.current.size;
185
- },
186
- [Symbol.iterator]: a
187
- }),
188
- [f, t, n, u, o, l, i, r, d, a]
189
- );
137
+ if (l() && a.isLatest(R) && await i(y), f)
138
+ throw y;
139
+ } finally {
140
+ n.current === x && (n.current = void 0);
141
+ }
142
+ }, [o, d, i, u, l, a, f, g]), _ = h(() => {
143
+ l() && u();
144
+ }, [u, l]), E = h(async () => {
145
+ _(), n.current && (n.current.abort(), n.current = void 0, await g());
146
+ }, [_, g]);
147
+ return p(() => () => {
148
+ E();
149
+ }, [E]), A(() => ({
150
+ loading: e,
151
+ result: r,
152
+ error: c,
153
+ status: s,
154
+ execute: v,
155
+ reset: _,
156
+ abort: E
157
+ }), [e, r, c, s, v, _, E]);
190
158
  }
191
- g(Y, "useRefs");
192
- function P(e, t) {
193
- if (t.leading === !1 && t.trailing === !1)
194
- throw new Error(
195
- "useDebouncedCallback: at least one of leading or trailing must be true"
196
- );
197
- const n = v(
198
- void 0
199
- ), u = v(!1), o = S(e), l = S(t), i = s(() => n.current !== void 0, []), r = s(() => {
200
- n.current !== void 0 && (clearTimeout(n.current), n.current = void 0);
159
+ m(M, "useExecutePromise");
160
+ function ce() {
161
+ const t = L(/* @__PURE__ */ new Map()), e = h((n) => t.current.get(n), []), r = h((n, f) => t.current.set(n, f), []), c = h((n) => t.current.has(n), []), s = h((n) => t.current.delete(n), []), o = h(() => t.current.clear(), []), d = h(() => t.current.keys(), []), i = h(() => t.current.values(), []), u = h(() => t.current.entries(), []), l = h(() => t.current[Symbol.iterator](), []), a = h((n) => (f) => {
162
+ f ? t.current.set(n, f) : t.current.delete(n);
201
163
  }, []);
202
- F(() => () => {
203
- r();
204
- }, [r]);
205
- const d = s(
206
- (...a) => {
207
- const { leading: f = !1, trailing: c = !0, delay: b } = l.current;
208
- r(), f && !u.current && (o.current(...a), u.current = !0), c && (n.current = setTimeout(() => {
209
- u.current || o.current(...a), u.current = !1, n.current = void 0;
210
- }, b));
164
+ return p(() => () => {
165
+ t.current.clear();
166
+ }, []), A(() => ({
167
+ register: a,
168
+ get: e,
169
+ set: r,
170
+ has: c,
171
+ delete: s,
172
+ clear: o,
173
+ keys: d,
174
+ values: i,
175
+ entries: u,
176
+ get size() {
177
+ return t.current.size;
211
178
  },
212
- [o, l, r]
213
- );
214
- return E(
215
- () => ({
216
- run: d,
217
- cancel: r,
218
- isPending: i
219
- }),
220
- [d, r, i]
221
- );
179
+ [Symbol.iterator]: l
180
+ }), [a, e, r, c, s, o, d, i, u, l]);
222
181
  }
223
- g(P, "useDebouncedCallback");
224
- function Z(e) {
225
- const { loading: t, result: n, error: u, execute: o, reset: l, abort: i, status: r } = p(e), { run: d, cancel: a, isPending: f } = P(
226
- o,
227
- e.debounce
228
- );
229
- return E(
230
- () => ({
231
- loading: t,
232
- result: n,
233
- error: u,
234
- status: r,
235
- reset: l,
236
- abort: i,
237
- run: d,
238
- cancel: a,
239
- isPending: f
240
- }),
241
- [t, n, u, r, l, i, d, a, f]
242
- );
182
+ m(ce, "useRefs");
183
+ function O(t, e) {
184
+ const r = w(9);
185
+ if (e.leading === !1 && e.trailing === !1)
186
+ throw new Error("useDebouncedCallback: at least one of leading or trailing must be true");
187
+ const c = L(void 0), s = L(!1), o = I(t), d = I(e);
188
+ let i;
189
+ r[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ m(() => c.current !== void 0, "t0"), r[0] = i) : i = r[0];
190
+ const u = i;
191
+ let l;
192
+ r[1] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ m(() => {
193
+ c.current !== void 0 && (clearTimeout(c.current), c.current = void 0);
194
+ }, "t1"), r[1] = l) : l = r[1];
195
+ const a = l;
196
+ let n, f;
197
+ r[2] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ m(() => () => {
198
+ a();
199
+ }, "t2"), f = [a], r[2] = n, r[3] = f) : (n = r[2], f = r[3]), p(n, f);
200
+ let b;
201
+ r[4] !== o || r[5] !== d ? (b = /* @__PURE__ */ m((..._) => {
202
+ const E = _, {
203
+ leading: S,
204
+ trailing: x,
205
+ delay: R
206
+ } = d.current, y = S === void 0 ? !1 : S, F = x === void 0 ? !0 : x;
207
+ a(), y && !s.current && (o.current(...E), s.current = !0), F && (c.current = setTimeout(() => {
208
+ s.current || o.current(...E), s.current = !1, c.current = void 0;
209
+ }, R));
210
+ }, "t4"), r[4] = o, r[5] = d, r[6] = b) : b = r[6];
211
+ const g = b;
212
+ let v;
213
+ return r[7] !== g ? (v = {
214
+ run: g,
215
+ cancel: a,
216
+ isPending: u
217
+ }, r[7] = g, r[8] = v) : v = r[8], v;
243
218
  }
244
- g(Z, "useDebouncedExecutePromise");
245
- function _() {
246
- const [, e] = O((t) => t + 1, 0);
247
- return e;
219
+ m(O, "useDebouncedCallback");
220
+ function se(t) {
221
+ const e = w(10), {
222
+ loading: r,
223
+ result: c,
224
+ error: s,
225
+ execute: o,
226
+ reset: d,
227
+ abort: i,
228
+ status: u
229
+ } = M(t), {
230
+ run: l,
231
+ cancel: a,
232
+ isPending: n
233
+ } = O(o, t.debounce);
234
+ let f;
235
+ return e[0] !== i || e[1] !== a || e[2] !== s || e[3] !== n || e[4] !== r || e[5] !== d || e[6] !== c || e[7] !== l || e[8] !== u ? (f = {
236
+ loading: r,
237
+ result: c,
238
+ error: s,
239
+ status: u,
240
+ reset: d,
241
+ abort: i,
242
+ run: l,
243
+ cancel: a,
244
+ isPending: n
245
+ }, e[0] = i, e[1] = a, e[2] = s, e[3] = n, e[4] = r, e[5] = d, e[6] = c, e[7] = l, e[8] = u, e[9] = f) : f = e[9], f;
248
246
  }
249
- g(_, "useForceUpdate");
250
- function N(e, t) {
251
- const n = s(
252
- (r) => e.addListener({
253
- name: k.generate("useKeyStorage"),
254
- // Generate unique listener name
255
- handle: r
256
- // Callback to trigger React re-render on storage changes
257
- }),
258
- [e]
259
- // Recreate subscription only if keyStorage changes
260
- ), u = s(() => {
261
- const r = e.get();
262
- return r !== null ? r : t ?? null;
263
- }, [e, t]), o = q(n, u, u), l = s(
264
- (r) => e.set(r),
265
- [e]
266
- // Recreate setter only if keyStorage changes
267
- ), i = s(
268
- () => e.remove(),
269
- [e]
270
- // Recreate remover only if keyStorage changes
271
- );
272
- return [o, l, i];
247
+ m(se, "useDebouncedExecutePromise");
248
+ function oe() {
249
+ const [, t] = z(J, 0);
250
+ return t;
273
251
  }
274
- g(N, "useKeyStorage");
275
- function $(e, t) {
276
- const [n, u, o] = N(
277
- e,
278
- t
279
- ), l = s(
280
- (i) => {
281
- const r = K(n, i);
282
- if (r === null) {
283
- o();
284
- return;
285
- }
286
- return u(r);
287
- },
288
- [n, u, o]
289
- );
290
- return [n, l, o];
252
+ m(oe, "useForceUpdate");
253
+ function J(t) {
254
+ return t + 1;
291
255
  }
292
- g($, "useImmerKeyStorage");
293
- function j(e) {
294
- const { fetcher: t = U.default } = e || {}, {
295
- loading: n,
296
- result: u,
297
- error: o,
298
- status: l,
299
- execute: i,
300
- reset: r,
301
- abort: d
302
- } = p(e), [a, f] = Q(
303
- void 0
304
- ), c = S(e), b = V(t), m = s(
305
- async (x) => {
306
- try {
307
- await i(async (h) => {
308
- x.abortController = h;
309
- const w = await b.exchange(
310
- x,
311
- c.current
312
- );
313
- return f(w), await w.extractResult();
314
- });
315
- } catch (h) {
316
- throw f(void 0), h;
317
- }
318
- },
319
- [i, b, c]
320
- ), y = s(() => {
321
- r(), f(void 0);
322
- }, [r]), C = s(() => {
323
- d(), f(void 0);
324
- }, [d]);
325
- return E(
326
- () => ({
327
- loading: n,
328
- result: u,
329
- error: o,
330
- status: l,
331
- exchange: a,
332
- execute: m,
333
- reset: y,
334
- abort: C
335
- }),
336
- [n, u, o, l, a, m, y, C]
337
- );
256
+ m(J, "_temp");
257
+ function W(t, e) {
258
+ const r = w(13);
259
+ let c;
260
+ r[0] !== t ? (c = /* @__PURE__ */ m((b) => t.addListener({
261
+ name: T.generate("useKeyStorage"),
262
+ handle: b
263
+ }), "t0"), r[0] = t, r[1] = c) : c = r[1];
264
+ const s = c;
265
+ let o;
266
+ r[2] !== e || r[3] !== t ? (o = /* @__PURE__ */ m(() => {
267
+ const b = t.get();
268
+ return b !== null ? b : e ?? null;
269
+ }, "t1"), r[2] = e, r[3] = t, r[4] = o) : o = r[4];
270
+ const d = o, i = G(s, d, d);
271
+ let u;
272
+ r[5] !== t ? (u = /* @__PURE__ */ m((b) => t.set(b), "t2"), r[5] = t, r[6] = u) : u = r[6];
273
+ const l = u;
274
+ let a;
275
+ r[7] !== t ? (a = /* @__PURE__ */ m(() => t.remove(), "t3"), r[7] = t, r[8] = a) : a = r[8];
276
+ const n = a;
277
+ let f;
278
+ return r[9] !== n || r[10] !== l || r[11] !== i ? (f = [i, l, n], r[9] = n, r[10] = l, r[11] = i, r[12] = f) : f = r[12], f;
338
279
  }
339
- g(j, "useFetcher");
340
- function ee(e) {
341
- const { loading: t, result: n, error: u, status: o, exchange: l, execute: i, reset: r, abort: d } = j(e), { run: a, cancel: f, isPending: c } = P(
342
- i,
343
- e.debounce
344
- );
345
- return E(
346
- () => ({
347
- loading: t,
348
- result: n,
349
- error: u,
350
- status: o,
351
- exchange: l,
352
- reset: r,
353
- abort: d,
354
- run: a,
355
- cancel: f,
356
- isPending: c
357
- }),
358
- [
359
- t,
360
- n,
361
- u,
362
- o,
363
- l,
364
- r,
365
- d,
366
- a,
367
- f,
368
- c
369
- ]
370
- );
280
+ m(W, "useKeyStorage");
281
+ function ue(t, e) {
282
+ const r = w(8), [c, s, o] = W(t, e);
283
+ let d;
284
+ r[0] !== o || r[1] !== s || r[2] !== c ? (d = /* @__PURE__ */ m((l) => {
285
+ const a = V(c, l);
286
+ if (a === null) {
287
+ o();
288
+ return;
289
+ }
290
+ return s(a);
291
+ }, "t0"), r[0] = o, r[1] = s, r[2] = c, r[3] = d) : d = r[3];
292
+ const i = d;
293
+ let u;
294
+ return r[4] !== o || r[5] !== i || r[6] !== c ? (u = [c, i, o], r[4] = o, r[5] = i, r[6] = c, r[7] = u) : u = r[7], u;
371
295
  }
372
- g(ee, "useDebouncedFetcher");
373
- function L(e) {
374
- const t = S(e), {
375
- loading: n,
376
- result: u,
377
- error: o,
378
- status: l,
296
+ m(ue, "useImmerKeyStorage");
297
+ function X(t) {
298
+ const e = w(21);
299
+ let r;
300
+ e[0] !== t ? (r = t || {}, e[0] = t, e[1] = r) : r = e[1];
301
+ const {
302
+ fetcher: c
303
+ } = r, s = c === void 0 ? N.default : c, {
304
+ loading: o,
305
+ result: d,
306
+ error: i,
307
+ status: u,
308
+ execute: l,
309
+ reset: a,
310
+ abort: n
311
+ } = M(t), [f, b] = P(void 0), g = I(t);
312
+ let v;
313
+ e[2] !== s ? (v = j(s), e[2] = s, e[3] = v) : v = e[3];
314
+ const _ = v;
315
+ let E;
316
+ e[4] !== _ || e[5] !== g || e[6] !== l ? (E = /* @__PURE__ */ m(async (q) => {
317
+ try {
318
+ await l(async (D) => {
319
+ q.abortController = D;
320
+ const $ = await _.exchange(q, g.current);
321
+ return b($), await $.extractResult();
322
+ });
323
+ } catch (D) {
324
+ const $ = D;
325
+ throw b(void 0), $;
326
+ }
327
+ }, "t3"), e[4] = _, e[5] = g, e[6] = l, e[7] = E) : E = e[7];
328
+ const S = E;
329
+ let x;
330
+ e[8] !== a ? (x = /* @__PURE__ */ m(() => {
331
+ a(), b(void 0);
332
+ }, "t4"), e[8] = a, e[9] = x) : x = e[9];
333
+ const R = x;
334
+ let y;
335
+ e[10] !== n ? (y = /* @__PURE__ */ m(() => {
336
+ n(), b(void 0);
337
+ }, "t5"), e[10] = n, e[11] = y) : y = e[11];
338
+ const F = y;
339
+ let Q;
340
+ return e[12] !== F || e[13] !== i || e[14] !== f || e[15] !== S || e[16] !== o || e[17] !== R || e[18] !== d || e[19] !== u ? (Q = {
341
+ loading: o,
342
+ result: d,
343
+ error: i,
344
+ status: u,
345
+ exchange: f,
346
+ execute: S,
347
+ reset: R,
348
+ abort: F
349
+ }, e[12] = F, e[13] = i, e[14] = f, e[15] = S, e[16] = o, e[17] = R, e[18] = d, e[19] = u, e[20] = Q) : Q = e[20], Q;
350
+ }
351
+ m(X, "useFetcher");
352
+ function le(t) {
353
+ const e = w(11), {
354
+ loading: r,
355
+ result: c,
356
+ error: s,
357
+ status: o,
358
+ exchange: d,
379
359
  execute: i,
380
- reset: r,
381
- abort: d
382
- } = p(t.current), a = v(e.initialQuery), f = s(
383
- async (y) => t.current.execute(
384
- a.current,
385
- t.current.attributes,
386
- y
387
- ),
388
- [a, t]
389
- ), c = s(() => i(f), [i, f]), b = s(() => a.current, [a]), m = s(
390
- (y) => {
391
- a.current = y, t.current.autoExecute && c();
392
- },
393
- [a, t, c]
394
- );
395
- return F(() => {
396
- t.current.autoExecute && c();
397
- }, [t, c]), E(
398
- () => ({
399
- loading: n,
400
- result: u,
401
- error: o,
402
- status: l,
403
- execute: c,
404
- reset: r,
405
- abort: d,
406
- getQuery: b,
407
- setQuery: m
408
- }),
409
- [n, u, o, l, c, r, d, b, m]
410
- );
360
+ reset: u,
361
+ abort: l
362
+ } = X(t), {
363
+ run: a,
364
+ cancel: n,
365
+ isPending: f
366
+ } = O(i, t.debounce);
367
+ let b;
368
+ return e[0] !== l || e[1] !== n || e[2] !== s || e[3] !== d || e[4] !== f || e[5] !== r || e[6] !== u || e[7] !== c || e[8] !== a || e[9] !== o ? (b = {
369
+ loading: r,
370
+ result: c,
371
+ error: s,
372
+ status: o,
373
+ exchange: d,
374
+ reset: u,
375
+ abort: l,
376
+ run: a,
377
+ cancel: n,
378
+ isPending: f
379
+ }, e[0] = l, e[1] = n, e[2] = s, e[3] = d, e[4] = f, e[5] = r, e[6] = u, e[7] = c, e[8] = a, e[9] = o, e[10] = b) : b = e[10], b;
411
380
  }
412
- g(L, "useQuery");
413
- function te(e) {
414
- return L(e);
381
+ m(le, "useDebouncedFetcher");
382
+ function C(t) {
383
+ const e = I(t), {
384
+ loading: r,
385
+ result: c,
386
+ error: s,
387
+ status: o,
388
+ execute: d,
389
+ reset: i,
390
+ abort: u
391
+ } = M(e.current), l = L(t.initialQuery), a = h(async (g) => e.current.execute(l.current, e.current.attributes, g), [l, e]), n = h(() => d(a), [d, a]), f = h(() => l.current, [l]), b = h((g) => {
392
+ l.current = g, e.current.autoExecute && n();
393
+ }, [l, e, n]);
394
+ return p(() => {
395
+ e.current.autoExecute && n();
396
+ }, [e, n]), A(() => ({
397
+ loading: r,
398
+ result: c,
399
+ error: s,
400
+ status: o,
401
+ execute: n,
402
+ reset: i,
403
+ abort: u,
404
+ getQuery: f,
405
+ setQuery: b
406
+ }), [r, c, s, o, n, i, u, f, b]);
415
407
  }
416
- g(te, "usePagedQuery");
417
- function re(e) {
418
- return L(e);
408
+ m(C, "useQuery");
409
+ function ae(t) {
410
+ return C(t);
419
411
  }
420
- g(re, "useSingleQuery");
421
- function ne(e) {
422
- return L(e);
412
+ m(ae, "usePagedQuery");
413
+ function ie(t) {
414
+ return C(t);
423
415
  }
424
- g(ne, "useCountQuery");
425
- function ce(e) {
426
- return L(e);
416
+ m(ie, "useSingleQuery");
417
+ function fe(t) {
418
+ return C(t);
427
419
  }
428
- g(ce, "useListQuery");
429
- function se(e) {
430
- return L(
431
- e
432
- );
420
+ m(fe, "useCountQuery");
421
+ function de(t) {
422
+ return C(t);
433
423
  }
434
- g(se, "useListStreamQuery");
435
- function ue(e) {
436
- const {
437
- loading: t,
438
- result: n,
439
- error: u,
424
+ m(de, "useListQuery");
425
+ function me(t) {
426
+ return C(t);
427
+ }
428
+ m(me, "useListStreamQuery");
429
+ function be(t) {
430
+ const e = w(12), {
431
+ loading: r,
432
+ result: c,
433
+ error: s,
440
434
  status: o,
441
- execute: l,
435
+ execute: d,
442
436
  reset: i,
443
- abort: r,
444
- getQuery: d,
437
+ abort: u,
438
+ getQuery: l,
445
439
  setQuery: a
446
- } = L(e), { run: f, cancel: c, isPending: b } = P(
447
- l,
448
- e.debounce
449
- );
450
- return E(
451
- () => ({
452
- loading: t,
453
- result: n,
454
- error: u,
455
- status: o,
456
- reset: i,
457
- abort: r,
458
- getQuery: d,
459
- setQuery: a,
460
- run: f,
461
- cancel: c,
462
- isPending: b
463
- }),
464
- [
465
- t,
466
- n,
467
- u,
468
- o,
469
- i,
470
- r,
471
- d,
472
- a,
473
- f,
474
- c,
475
- b
476
- ]
477
- );
440
+ } = C(t), {
441
+ run: n,
442
+ cancel: f,
443
+ isPending: b
444
+ } = O(d, t.debounce);
445
+ let g;
446
+ return e[0] !== u || e[1] !== f || e[2] !== s || e[3] !== l || e[4] !== b || e[5] !== r || e[6] !== i || e[7] !== c || e[8] !== n || e[9] !== a || e[10] !== o ? (g = {
447
+ loading: r,
448
+ result: c,
449
+ error: s,
450
+ status: o,
451
+ reset: i,
452
+ abort: u,
453
+ getQuery: l,
454
+ setQuery: a,
455
+ run: n,
456
+ cancel: f,
457
+ isPending: b
458
+ }, e[0] = u, e[1] = f, e[2] = s, e[3] = l, e[4] = b, e[5] = r, e[6] = i, e[7] = c, e[8] = n, e[9] = a, e[10] = o, e[11] = g) : g = e[11], g;
478
459
  }
479
- g(ue, "useDebouncedQuery");
460
+ m(be, "useDebouncedQuery");
480
461
  export {
481
- z as PromiseStatus,
482
- ne as useCountQuery,
483
- P as useDebouncedCallback,
484
- Z as useDebouncedExecutePromise,
485
- ee as useDebouncedFetcher,
486
- ue as useDebouncedQuery,
487
- p as useExecutePromise,
488
- j as useFetcher,
489
- _ as useForceUpdate,
490
- $ as useImmerKeyStorage,
491
- N as useKeyStorage,
492
- S as useLatest,
493
- ce as useListQuery,
494
- se as useListStreamQuery,
495
- D as useMounted,
496
- te as usePagedQuery,
497
- G as usePromiseState,
498
- L as useQuery,
499
- Y as useRefs,
500
- T as useRequestId,
501
- re as useSingleQuery
462
+ k as PromiseStatus,
463
+ fe as useCountQuery,
464
+ O as useDebouncedCallback,
465
+ se as useDebouncedExecutePromise,
466
+ le as useDebouncedFetcher,
467
+ be as useDebouncedQuery,
468
+ M as useExecutePromise,
469
+ X as useFetcher,
470
+ oe as useForceUpdate,
471
+ ue as useImmerKeyStorage,
472
+ W as useKeyStorage,
473
+ I as useLatest,
474
+ de as useListQuery,
475
+ me as useListStreamQuery,
476
+ K as useMounted,
477
+ ae as usePagedQuery,
478
+ B as usePromiseState,
479
+ C as useQuery,
480
+ ce as useRefs,
481
+ H as useRequestId,
482
+ ie as useSingleQuery
502
483
  };
503
484
  //# sourceMappingURL=index.es.js.map