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