@ahoo-wang/fetcher-react 3.3.6 → 3.3.9

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,51 +1,51 @@
1
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";
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";
4
+ import { c as S } from "react/compiler-runtime";
5
5
  import { nameGenerator as T } from "@ahoo-wang/fetcher-eventbus";
6
6
  import { produce as V } from "immer";
7
7
  import { fetcherRegistrar as N, getFetcher as j } from "@ahoo-wang/fetcher";
8
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;
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
13
  let s, o;
14
- return t[1] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ m(() => (e.current = !0, () => {
14
+ return r[1] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ m(() => (e.current = !0, () => {
15
15
  e.current = !1;
16
- }), "t1"), o = [], t[1] = s, t[2] = o) : (s = t[1], o = t[2]), p(s, o), c;
16
+ }), "t1"), o = [], r[1] = s, r[2] = o) : (s = r[1], o = r[2]), C(s, o), n;
17
17
  }
18
18
  m(K, "useMounted");
19
- function I(t) {
20
- const e = L(t);
21
- return e.current = t, e;
19
+ function I(r) {
20
+ const e = L(r);
21
+ return e.current = r, e;
22
22
  }
23
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"
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"
28
28
  /* IDLE */
29
- ), [c, s] = P(void 0), [o, d] = P(void 0), i = K(), u = I(t), l = h(() => {
30
- i() && (r(
29
+ ), [n, s] = P(void 0), [o, f] = P(void 0), i = K(), u = I(r), l = h(() => {
30
+ i() && (t(
31
31
  "loading"
32
32
  /* LOADING */
33
- ), d(void 0));
33
+ ), f(void 0));
34
34
  }, [i]), a = h(async (b) => {
35
35
  if (i()) {
36
- s(b), r(
36
+ s(b), t(
37
37
  "success"
38
38
  /* SUCCESS */
39
- ), d(void 0);
39
+ ), f(void 0);
40
40
  try {
41
41
  await u.current?.onSuccess?.(b);
42
42
  } catch (g) {
43
43
  console.warn("PromiseState onSuccess callback error:", g);
44
44
  }
45
45
  }
46
- }, [i, u]), n = h(async (b) => {
46
+ }, [i, u]), c = h(async (b) => {
47
47
  if (i()) {
48
- d(b), r(
48
+ f(b), t(
49
49
  "error"
50
50
  /* ERROR */
51
51
  ), s(void 0);
@@ -55,260 +55,260 @@ function B(t) {
55
55
  console.warn("PromiseState onError callback error:", g);
56
56
  }
57
57
  }
58
- }, [i, u]), f = h(() => {
59
- i() && (r(
58
+ }, [i, u]), d = h(() => {
59
+ i() && (t(
60
60
  "idle"
61
61
  /* IDLE */
62
- ), d(void 0), s(void 0));
62
+ ), f(void 0), s(void 0));
63
63
  }, [i]);
64
64
  return A(() => ({
65
65
  status: e,
66
66
  loading: e === "loading",
67
- result: c,
67
+ result: n,
68
68
  error: o,
69
69
  setLoading: l,
70
70
  setSuccess: a,
71
- setError: n,
72
- setIdle: f
73
- }), [e, c, o, l, a, n, f]);
71
+ setError: c,
72
+ setIdle: d
73
+ }), [e, n, o, l, a, c, d]);
74
74
  }
75
75
  m(B, "usePromiseState");
76
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;
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
81
  let s;
82
- t[1] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ m(() => e.current, "t1"), t[1] = s) : s = t[1];
82
+ r[1] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ m(() => e.current, "t1"), r[1] = s) : s = r[1];
83
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;
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
87
  let u;
88
- t[3] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ m(() => {
88
+ r[3] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ m(() => {
89
89
  e.current = e.current + 1;
90
- }, "t3"), t[3] = u) : u = t[3];
90
+ }, "t3"), r[3] = u) : u = r[3];
91
91
  const l = u;
92
92
  let a;
93
- t[4] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ m(() => {
93
+ r[4] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ m(() => {
94
94
  e.current = 0;
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,
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 = {
99
+ generate: n,
100
100
  current: o,
101
101
  isLatest: i,
102
102
  invalidate: l,
103
- reset: n
104
- }, t[5] = f) : f = t[5], f;
103
+ reset: c
104
+ }, r[5] = d) : d = r[5], d;
105
105
  }
106
106
  m(H, "useRequestId");
107
- function M(t) {
107
+ function M(r) {
108
108
  const {
109
109
  loading: e,
110
- result: r,
111
- error: c,
110
+ result: t,
111
+ error: n,
112
112
  status: s,
113
113
  setLoading: o,
114
- setSuccess: d,
114
+ setSuccess: f,
115
115
  setError: i,
116
116
  setIdle: u
117
- } = B(t), l = K(), a = H(), n = L(void 0), f = t?.propagateError, b = t?.onAbort, g = h(async () => {
117
+ } = B(r), l = K(), a = H(), c = L(void 0), d = r?.propagateError, b = r?.onAbort, g = h(async () => {
118
118
  try {
119
119
  await b?.();
120
- } catch (S) {
121
- console.warn("useExecutePromise onAbort callback error:", S);
120
+ } catch (w) {
121
+ console.warn("useExecutePromise onAbort callback error:", w);
122
122
  }
123
- }, [b]), v = h(async (S) => {
124
- n.current && (n.current.abort(), await g());
123
+ }, [b]), v = h(async (w) => {
124
+ c.current && (c.current.abort(), await g());
125
125
  const x = new AbortController();
126
- n.current = x;
126
+ c.current = x;
127
127
  const R = a.generate();
128
128
  o();
129
129
  try {
130
- const y = await S(x);
131
- l() && a.isLatest(R) && await d(y);
130
+ const y = await w(x);
131
+ l() && a.isLatest(R) && await f(y);
132
132
  } catch (y) {
133
133
  if (y instanceof Error && y.name === "AbortError") {
134
134
  l() && u();
135
135
  return;
136
136
  }
137
- if (l() && a.isLatest(R) && await i(y), f)
137
+ if (l() && a.isLatest(R) && await i(y), d)
138
138
  throw y;
139
139
  } finally {
140
- n.current === x && (n.current = void 0);
140
+ c.current === x && (c.current = void 0);
141
141
  }
142
- }, [o, d, i, u, l, a, f, g]), _ = h(() => {
142
+ }, [o, f, i, u, l, a, d, g]), _ = h(() => {
143
143
  l() && u();
144
144
  }, [u, l]), E = h(async () => {
145
- _(), n.current && (n.current.abort(), n.current = void 0, await g());
145
+ _(), c.current && (c.current.abort(), c.current = void 0, await g());
146
146
  }, [_, g]);
147
- return p(() => () => {
147
+ return C(() => () => {
148
148
  E();
149
149
  }, [E]), A(() => ({
150
150
  loading: e,
151
- result: r,
152
- error: c,
151
+ result: t,
152
+ error: n,
153
153
  status: s,
154
154
  execute: v,
155
155
  reset: _,
156
156
  abort: E
157
- }), [e, r, c, s, v, _, E]);
157
+ }), [e, t, n, s, v, _, E]);
158
158
  }
159
159
  m(M, "useExecutePromise");
160
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);
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);
163
163
  }, []);
164
- return p(() => () => {
165
- t.current.clear();
164
+ return C(() => () => {
165
+ r.current.clear();
166
166
  }, []), A(() => ({
167
167
  register: a,
168
168
  get: e,
169
- set: r,
170
- has: c,
169
+ set: t,
170
+ has: n,
171
171
  delete: s,
172
172
  clear: o,
173
- keys: d,
173
+ keys: f,
174
174
  values: i,
175
175
  entries: u,
176
176
  get size() {
177
- return t.current.size;
177
+ return r.current.size;
178
178
  },
179
179
  [Symbol.iterator]: l
180
- }), [a, e, r, c, s, o, d, i, u, l]);
180
+ }), [a, e, t, n, s, o, f, i, u, l]);
181
181
  }
182
182
  m(ce, "useRefs");
183
- function O(t, e) {
184
- const r = w(9);
183
+ function O(r, e) {
184
+ const t = S(9);
185
185
  if (e.leading === !1 && e.trailing === !1)
186
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);
187
+ const n = L(void 0), s = L(!1), o = I(r), f = I(e);
188
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];
189
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ m(() => n.current !== void 0, "t0"), t[0] = i) : i = t[0];
190
190
  const u = i;
191
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];
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];
195
195
  const a = l;
196
- let n, f;
197
- r[2] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ m(() => () => {
196
+ let c, d;
197
+ t[2] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ m(() => () => {
198
198
  a();
199
- }, "t2"), f = [a], r[2] = n, r[3] = f) : (n = r[2], f = r[3]), p(n, f);
199
+ }, "t2"), d = [a], t[2] = c, t[3] = d) : (c = t[2], d = t[3]), C(c, d);
200
200
  let b;
201
- r[4] !== o || r[5] !== d ? (b = /* @__PURE__ */ m((..._) => {
201
+ t[4] !== o || t[5] !== f ? (b = /* @__PURE__ */ m((..._) => {
202
202
  const E = _, {
203
- leading: S,
203
+ leading: w,
204
204
  trailing: x,
205
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;
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
209
  }, R));
210
- }, "t4"), r[4] = o, r[5] = d, r[6] = b) : b = r[6];
210
+ }, "t4"), t[4] = o, t[5] = f, t[6] = b) : b = t[6];
211
211
  const g = b;
212
212
  let v;
213
- return r[7] !== g ? (v = {
213
+ return t[7] !== g ? (v = {
214
214
  run: g,
215
215
  cancel: a,
216
216
  isPending: u
217
- }, r[7] = g, r[8] = v) : v = r[8], v;
217
+ }, t[7] = g, t[8] = v) : v = t[8], v;
218
218
  }
219
219
  m(O, "useDebouncedCallback");
220
- function se(t) {
221
- const e = w(10), {
222
- loading: r,
223
- result: c,
220
+ function se(r) {
221
+ const e = S(10), {
222
+ loading: t,
223
+ result: n,
224
224
  error: s,
225
225
  execute: o,
226
- reset: d,
226
+ reset: f,
227
227
  abort: i,
228
228
  status: u
229
- } = M(t), {
229
+ } = M(r), {
230
230
  run: l,
231
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,
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,
237
+ result: n,
238
238
  error: s,
239
239
  status: u,
240
- reset: d,
240
+ reset: f,
241
241
  abort: i,
242
242
  run: l,
243
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;
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;
246
246
  }
247
247
  m(se, "useDebouncedExecutePromise");
248
248
  function oe() {
249
- const [, t] = z(J, 0);
250
- return t;
249
+ const [, r] = z(J, 0);
250
+ return r;
251
251
  }
252
252
  m(oe, "useForceUpdate");
253
- function J(t) {
254
- return t + 1;
253
+ function J(r) {
254
+ return r + 1;
255
255
  }
256
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({
257
+ function W(r, e) {
258
+ const t = S(13);
259
+ let n;
260
+ t[0] !== r ? (n = /* @__PURE__ */ m((b) => r.addListener({
261
261
  name: T.generate("useKeyStorage"),
262
262
  handle: b
263
- }), "t0"), r[0] = t, r[1] = c) : c = r[1];
264
- const s = c;
263
+ }), "t0"), t[0] = r, t[1] = n) : n = t[1];
264
+ const s = n;
265
265
  let o;
266
- r[2] !== e || r[3] !== t ? (o = /* @__PURE__ */ m(() => {
267
- const b = t.get();
266
+ t[2] !== e || t[3] !== r ? (o = /* @__PURE__ */ m(() => {
267
+ const b = r.get();
268
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);
269
+ }, "t1"), t[2] = e, t[3] = r, t[4] = o) : o = t[4];
270
+ const f = o, i = G(s, f, f);
271
271
  let u;
272
- r[5] !== t ? (u = /* @__PURE__ */ m((b) => t.set(b), "t2"), r[5] = t, r[6] = u) : u = r[6];
272
+ t[5] !== r ? (u = /* @__PURE__ */ m((b) => r.set(b), "t2"), t[5] = r, t[6] = u) : u = t[6];
273
273
  const l = u;
274
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;
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;
279
279
  }
280
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);
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
286
  if (a === null) {
287
287
  o();
288
288
  return;
289
289
  }
290
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;
291
+ }, "t0"), t[0] = o, t[1] = s, t[2] = n, t[3] = f) : f = t[3];
292
+ const i = f;
293
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;
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;
295
295
  }
296
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];
297
+ function X(r) {
298
+ const e = S(21);
299
+ let t;
300
+ e[0] !== r ? (t = r || {}, e[0] = r, e[1] = t) : t = e[1];
301
301
  const {
302
- fetcher: c
303
- } = r, s = c === void 0 ? N.default : c, {
302
+ fetcher: n
303
+ } = t, s = n === void 0 ? N.default : n, {
304
304
  loading: o,
305
- result: d,
305
+ result: f,
306
306
  error: i,
307
307
  status: u,
308
308
  execute: l,
309
309
  reset: a,
310
- abort: n
311
- } = M(t), [f, b] = P(void 0), g = I(t);
310
+ abort: c
311
+ } = M(r), [d, b] = P(void 0), g = I(r);
312
312
  let v;
313
313
  e[2] !== s ? (v = j(s), e[2] = s, e[3] = v) : v = e[3];
314
314
  const _ = v;
@@ -325,139 +325,161 @@ function X(t) {
325
325
  throw b(void 0), $;
326
326
  }
327
327
  }, "t3"), e[4] = _, e[5] = g, e[6] = l, e[7] = E) : E = e[7];
328
- const S = E;
328
+ const w = E;
329
329
  let x;
330
330
  e[8] !== a ? (x = /* @__PURE__ */ m(() => {
331
331
  a(), b(void 0);
332
332
  }, "t4"), e[8] = a, e[9] = x) : x = e[9];
333
333
  const R = x;
334
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 = {
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;
339
+ 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
341
  loading: o,
342
- result: d,
342
+ result: f,
343
343
  error: i,
344
344
  status: u,
345
- exchange: f,
346
- execute: S,
345
+ exchange: d,
346
+ execute: w,
347
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;
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;
350
350
  }
351
351
  m(X, "useFetcher");
352
- function le(t) {
353
- const e = w(11), {
354
- loading: r,
355
- result: c,
352
+ function le(r) {
353
+ const e = S(11), {
354
+ loading: t,
355
+ result: n,
356
356
  error: s,
357
357
  status: o,
358
- exchange: d,
358
+ exchange: f,
359
359
  execute: i,
360
360
  reset: u,
361
361
  abort: l
362
- } = X(t), {
362
+ } = X(r), {
363
363
  run: a,
364
- cancel: n,
365
- isPending: f
366
- } = O(i, t.debounce);
364
+ cancel: c,
365
+ isPending: d
366
+ } = O(i, r.debounce);
367
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,
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,
370
+ result: n,
371
371
  error: s,
372
372
  status: o,
373
- exchange: d,
373
+ exchange: f,
374
374
  reset: u,
375
375
  abort: l,
376
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;
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;
380
380
  }
381
381
  m(le, "useDebouncedFetcher");
382
- function C(t) {
383
- const e = I(t), {
384
- loading: r,
385
- result: c,
382
+ function F(r) {
383
+ const e = I(r), {
384
+ loading: t,
385
+ result: n,
386
386
  error: s,
387
387
  status: o,
388
- execute: d,
388
+ execute: f,
389
389
  reset: i,
390
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,
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,
398
+ result: n,
399
399
  error: s,
400
400
  status: o,
401
- execute: n,
401
+ execute: c,
402
402
  reset: i,
403
403
  abort: u,
404
- getQuery: f,
404
+ getQuery: d,
405
405
  setQuery: b
406
- }), [r, c, s, o, n, i, u, f, b]);
406
+ }), [t, n, s, o, c, i, u, d, b]);
407
407
  }
408
- m(C, "useQuery");
409
- function ae(t) {
410
- return C(t);
408
+ m(F, "useQuery");
409
+ function ae(r) {
410
+ return F(r);
411
411
  }
412
412
  m(ae, "usePagedQuery");
413
- function ie(t) {
414
- return C(t);
413
+ function ie(r) {
414
+ return F(r);
415
415
  }
416
416
  m(ie, "useSingleQuery");
417
- function fe(t) {
418
- return C(t);
417
+ function fe(r) {
418
+ return F(r);
419
419
  }
420
420
  m(fe, "useCountQuery");
421
- function de(t) {
422
- return C(t);
421
+ function de(r) {
422
+ return F(r);
423
423
  }
424
424
  m(de, "useListQuery");
425
- function me(t) {
426
- return C(t);
425
+ function me(r) {
426
+ return F(r);
427
427
  }
428
428
  m(me, "useListStreamQuery");
429
- function be(t) {
430
- const e = w(12), {
431
- loading: r,
432
- result: c,
429
+ function be(r) {
430
+ const e = S(12), {
431
+ loading: t,
432
+ result: n,
433
433
  error: s,
434
434
  status: o,
435
- execute: d,
435
+ execute: f,
436
436
  reset: i,
437
437
  abort: u,
438
438
  getQuery: l,
439
439
  setQuery: a
440
- } = C(t), {
441
- run: n,
442
- cancel: f,
440
+ } = F(r), {
441
+ run: c,
442
+ cancel: d,
443
443
  isPending: b
444
- } = O(d, t.debounce);
444
+ } = O(f, r.debounce);
445
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,
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,
448
+ result: n,
449
449
  error: s,
450
450
  status: o,
451
451
  reset: i,
452
452
  abort: u,
453
453
  getQuery: l,
454
454
  setQuery: a,
455
- run: n,
456
- cancel: f,
455
+ run: c,
456
+ cancel: d,
457
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;
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;
459
459
  }
460
460
  m(be, "useDebouncedQuery");
461
+ function ge(r) {
462
+ const e = S(13), {
463
+ bus: t,
464
+ 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;
481
+ }
482
+ m(ge, "useEventSubscription");
461
483
  export {
462
484
  k as PromiseStatus,
463
485
  fe as useCountQuery,
@@ -465,6 +487,7 @@ export {
465
487
  se as useDebouncedExecutePromise,
466
488
  le as useDebouncedFetcher,
467
489
  be as useDebouncedQuery,
490
+ ge as useEventSubscription,
468
491
  M as useExecutePromise,
469
492
  X as useFetcher,
470
493
  oe as useForceUpdate,
@@ -476,7 +499,7 @@ export {
476
499
  K as useMounted,
477
500
  ae as usePagedQuery,
478
501
  B as usePromiseState,
479
- C as useQuery,
502
+ F as useQuery,
480
503
  ce as useRefs,
481
504
  H as useRequestId,
482
505
  ie as useSingleQuery