@acrool/react-fetcher 0.0.2-alpha.6 → 0.0.2-alpha.8

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.
@@ -108,6 +108,7 @@ const Wn = (e, t) => async (r) => {
108
108
  url: t.url,
109
109
  method: n,
110
110
  data: l,
111
+ ...s,
111
112
  headers: {
112
113
  ...s == null ? void 0 : s.headers,
113
114
  "Content-Type": u
@@ -120,6 +121,7 @@ const Wn = (e, t) => async (r) => {
120
121
  url: t.url,
121
122
  method: n,
122
123
  data: l,
124
+ ...s,
123
125
  headers: {
124
126
  ...s == null ? void 0 : s.headers,
125
127
  "Content-Type": u
@@ -130,6 +132,7 @@ const Wn = (e, t) => async (r) => {
130
132
  url: t.url,
131
133
  method: n,
132
134
  params: o,
135
+ ...s,
133
136
  headers: {
134
137
  ...s == null ? void 0 : s.headers,
135
138
  "Content-Type": V.json
@@ -220,7 +223,7 @@ function tr() {
220
223
  return f = f.displayName, f || (f = w.displayName || w.name || "", f = f !== "" ? "ForwardRef(" + f + ")" : "ForwardRef"), f;
221
224
  case U:
222
225
  return w = f.displayName || null, w !== null ? w : e(f.type) || "Memo";
223
- case C:
226
+ case P:
224
227
  w = f._payload, f = f._init;
225
228
  try {
226
229
  return e(f(w));
@@ -241,17 +244,17 @@ function tr() {
241
244
  }
242
245
  if (w) {
243
246
  w = console;
244
- var _ = w.error, P = typeof Symbol == "function" && Symbol.toStringTag && f[Symbol.toStringTag] || f.constructor.name || "Object";
247
+ var _ = w.error, C = typeof Symbol == "function" && Symbol.toStringTag && f[Symbol.toStringTag] || f.constructor.name || "Object";
245
248
  return _.call(
246
249
  w,
247
250
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
248
- P
251
+ C
249
252
  ), t(f);
250
253
  }
251
254
  }
252
255
  function n(f) {
253
256
  if (f === R) return "<>";
254
- if (typeof f == "object" && f !== null && f.$$typeof === C)
257
+ if (typeof f == "object" && f !== null && f.$$typeof === P)
255
258
  return "<...>";
256
259
  try {
257
260
  var w = e(f);
@@ -292,7 +295,7 @@ function tr() {
292
295
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
293
296
  )), f = this.props.ref, f !== void 0 ? f : null;
294
297
  }
295
- function l(f, w, _, P, M, B, ge, Oe) {
298
+ function l(f, w, _, C, M, B, ge, Oe) {
296
299
  return _ = B.ref, f = {
297
300
  $$typeof: T,
298
301
  type: f,
@@ -324,13 +327,13 @@ function tr() {
324
327
  value: Oe
325
328
  }), Object.freeze && (Object.freeze(f.props), Object.freeze(f)), f;
326
329
  }
327
- function u(f, w, _, P, M, B, ge, Oe) {
330
+ function u(f, w, _, C, M, B, ge, Oe) {
328
331
  var k = w.children;
329
332
  if (k !== void 0)
330
- if (P)
333
+ if (C)
331
334
  if (Ht(k)) {
332
- for (P = 0; P < k.length; P++)
333
- p(k[P]);
335
+ for (C = 0; C < k.length; C++)
336
+ p(k[C]);
334
337
  Object.freeze && Object.freeze(k);
335
338
  } else
336
339
  console.error(
@@ -342,18 +345,18 @@ function tr() {
342
345
  var W = Object.keys(w).filter(function(zt) {
343
346
  return zt !== "key";
344
347
  });
345
- P = 0 < W.length ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}", Je[k + P] || (W = 0 < W.length ? "{" + W.join(": ..., ") + ": ...}" : "{}", console.error(
348
+ C = 0 < W.length ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}", Je[k + C] || (W = 0 < W.length ? "{" + W.join(": ..., ") + ": ...}" : "{}", console.error(
346
349
  `A props object containing a "key" prop is being spread into JSX:
347
350
  let props = %s;
348
351
  <%s {...props} />
349
352
  React keys must be passed directly to JSX without using spread:
350
353
  let props = %s;
351
354
  <%s key={someKey} {...props} />`,
352
- P,
355
+ C,
353
356
  k,
354
357
  W,
355
358
  k
356
- ), Je[k + P] = !0);
359
+ ), Je[k + C] = !0);
357
360
  }
358
361
  if (k = null, _ !== void 0 && (r(_), k = "" + _), i(w) && (r(w.key), k = "" + w.key), "key" in w) {
359
362
  _ = {};
@@ -377,7 +380,7 @@ React keys must be passed directly to JSX without using spread:
377
380
  function p(f) {
378
381
  typeof f == "object" && f !== null && f.$$typeof === T && f._store && (f._store.validated = 1);
379
382
  }
380
- var b = Vt, T = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), g = Symbol.for("react.profiler"), E = Symbol.for("react.consumer"), S = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), A = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), U = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), I = Symbol.for("react.activity"), X = Symbol.for("react.client.reference"), Te = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Ie = Object.prototype.hasOwnProperty, Ht = Array.isArray, Se = console.createTask ? console.createTask : function() {
383
+ var b = Vt, T = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), g = Symbol.for("react.profiler"), E = Symbol.for("react.consumer"), S = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), A = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), U = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), I = Symbol.for("react.activity"), X = Symbol.for("react.client.reference"), Te = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Ie = Object.prototype.hasOwnProperty, Ht = Array.isArray, Se = console.createTask ? console.createTask : function() {
381
384
  return null;
382
385
  };
383
386
  b = {
@@ -389,26 +392,26 @@ React keys must be passed directly to JSX without using spread:
389
392
  b,
390
393
  o
391
394
  )(), ze = Se(n(o)), Je = {};
392
- Z.Fragment = R, Z.jsx = function(f, w, _, P, M) {
395
+ Z.Fragment = R, Z.jsx = function(f, w, _, C, M) {
393
396
  var B = 1e4 > Te.recentlyCreatedOwnerStacks++;
394
397
  return u(
395
398
  f,
396
399
  w,
397
400
  _,
398
401
  !1,
399
- P,
402
+ C,
400
403
  M,
401
404
  B ? Error("react-stack-top-frame") : He,
402
405
  B ? Se(n(f)) : ze
403
406
  );
404
- }, Z.jsxs = function(f, w, _, P, M) {
407
+ }, Z.jsxs = function(f, w, _, C, M) {
405
408
  var B = 1e4 > Te.recentlyCreatedOwnerStacks++;
406
409
  return u(
407
410
  f,
408
411
  w,
409
412
  _,
410
413
  !0,
411
- P,
414
+ C,
412
415
  M,
413
416
  B ? Error("react-stack-top-frame") : He,
414
417
  B ? Se(n(f)) : ze
@@ -671,9 +674,9 @@ const fr = dt(null), Yn = ({
671
674
  }));
672
675
  });
673
676
  }, h = (E) => new Promise((S, O) => {
674
- var C, I;
677
+ var P, I;
675
678
  E.headers["Accept-Language"] = r;
676
- const A = (C = d()) == null ? void 0 : C.accessToken;
679
+ const A = (P = d()) == null ? void 0 : P.accessToken;
677
680
  if (!((I = E.fetchOptions) == null ? void 0 : I.forceGuest) && A && (E.headers.Authorization = [o, A].filter((X) => X).join(" ")), !(E && s ? s(E) : !1) && Q) {
678
681
  T(S, O)(E), O(new lr({
679
682
  message: "Token refreshing, so request save queues not send",
@@ -690,8 +693,8 @@ const fr = dt(null), Yn = ({
690
693
  c && v.warning("[FetcherProvider] interceptorsResponseError", { status: A, responseFirstError: N }), n && n(N);
691
694
  const U = O && s ? s(O) : !1;
692
695
  if (S && O && (A === 401 || N.code === "UNAUTHENTICATED")) {
693
- const C = d();
694
- return c && v.warning("[FetcherProvider] enter refresh token flow", { refreshToken: C == null ? void 0 : C.refreshToken }), Ue(C == null ? void 0 : C.refreshToken) || U || O.pendingRequest ? (Q = !1, c && v.warning("[FetcherProvider] no refreshToken/refreshAPI|pendingRequest fail, force logout"), p(), Promise.reject(new te(N))) : (Q || (Q = !0, c && v.warning("[FetcherProvider] refreshTokens"), u().then(() => {
696
+ const P = d();
697
+ return c && v.warning("[FetcherProvider] enter refresh token flow", { refreshToken: P == null ? void 0 : P.refreshToken }), Ue(P == null ? void 0 : P.refreshToken) || U || O.pendingRequest ? (Q = !1, c && v.warning("[FetcherProvider] no refreshToken/refreshAPI|pendingRequest fail, force logout"), p(), Promise.reject(new te(N))) : (Q || (Q = !0, c && v.warning("[FetcherProvider] refreshTokens"), u().then(() => {
695
698
  c && v.info("[FetcherProvider] refreshTokens success"), b(!0);
696
699
  }).catch(() => {
697
700
  c && v.danger("[FetcherProvider] refreshTokens fail"), b(!1);
@@ -760,18 +763,18 @@ function St(e, t) {
760
763
  return null;
761
764
  }
762
765
  const H = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, gt = (e) => !re(e) && e !== H;
763
- function Pe() {
766
+ function Ce() {
764
767
  const { caseless: e } = gt(this) && this || {}, t = {}, r = (n, s) => {
765
768
  const o = e && St(t, s) || s;
766
- le(t[o]) && le(n) ? t[o] = Pe(t[o], n) : le(n) ? t[o] = Pe({}, n) : Y(n) ? t[o] = n.slice() : t[o] = n;
769
+ le(t[o]) && le(n) ? t[o] = Ce(t[o], n) : le(n) ? t[o] = Ce({}, n) : Y(n) ? t[o] = n.slice() : t[o] = n;
767
770
  };
768
771
  for (let n = 0, s = arguments.length; n < s; n++)
769
772
  arguments[n] && ie(arguments[n], r);
770
773
  return t;
771
774
  }
772
- const Cr = (e, t, r, { allOwnKeys: n } = {}) => (ie(t, (s, o) => {
775
+ const Pr = (e, t, r, { allOwnKeys: n } = {}) => (ie(t, (s, o) => {
773
776
  r && j(s) ? e[o] = bt(s, r) : e[o] = s;
774
- }, { allOwnKeys: n }), e), Pr = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), kr = (e, t, r, n) => {
777
+ }, { allOwnKeys: n }), e), Cr = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), kr = (e, t, r, n) => {
775
778
  e.prototype = Object.create(t.prototype, n), e.prototype.constructor = e, Object.defineProperty(e, "super", {
776
779
  value: t.prototype
777
780
  }), r && Object.assign(e.prototype, r);
@@ -899,10 +902,10 @@ const Wr = (e) => {
899
902
  isTypedArray: Lr,
900
903
  isFileList: wr,
901
904
  forEach: ie,
902
- merge: Pe,
903
- extend: Cr,
905
+ merge: Ce,
906
+ extend: Pr,
904
907
  trim: Nr,
905
- stripBOM: Pr,
908
+ stripBOM: Cr,
906
909
  inherits: kr,
907
910
  toFlatObject: Fr,
908
911
  kindOf: me,
@@ -1078,11 +1081,11 @@ function tt(e) {
1078
1081
  function Be(e, t) {
1079
1082
  this._pairs = [], e && be(e, this, t);
1080
1083
  }
1081
- const Ct = Be.prototype;
1082
- Ct.append = function(t, r) {
1084
+ const Pt = Be.prototype;
1085
+ Pt.append = function(t, r) {
1083
1086
  this._pairs.push([t, r]);
1084
1087
  };
1085
- Ct.toString = function(t) {
1088
+ Pt.toString = function(t) {
1086
1089
  const r = t ? function(n) {
1087
1090
  return t.call(this, n, tt);
1088
1091
  } : tt;
@@ -1093,7 +1096,7 @@ Ct.toString = function(t) {
1093
1096
  function en(e) {
1094
1097
  return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
1095
1098
  }
1096
- function Pt(e, t, r) {
1099
+ function Ct(e, t, r) {
1097
1100
  if (!t)
1098
1101
  return e;
1099
1102
  const n = r && r.encode || en;
@@ -1692,7 +1695,7 @@ function J(e, t) {
1692
1695
  const Ut = (e) => {
1693
1696
  const t = J({}, e);
1694
1697
  let { data: r, withXSRFToken: n, xsrfHeaderName: s, xsrfCookieName: o, headers: i, auth: c } = t;
1695
- t.headers = i = L.from(i), t.url = Pt(Lt(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), c && i.set(
1698
+ t.headers = i = L.from(i), t.url = Ct(Lt(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), c && i.set(
1696
1699
  "Authorization",
1697
1700
  "Basic " + btoa((c.username || "") + ":" + (c.password ? unescape(encodeURIComponent(c.password)) : ""))
1698
1701
  );
@@ -1767,7 +1770,7 @@ const Ut = (e) => {
1767
1770
  }
1768
1771
  m.send(o || null);
1769
1772
  });
1770
- }, Cn = (e, t) => {
1773
+ }, Pn = (e, t) => {
1771
1774
  const { length: r } = e = e ? e.filter(Boolean) : [];
1772
1775
  if (t || r) {
1773
1776
  let n = new AbortController(), s;
@@ -1790,7 +1793,7 @@ const Ut = (e) => {
1790
1793
  const { signal: d } = n;
1791
1794
  return d.unsubscribe = () => a.asap(c), d;
1792
1795
  }
1793
- }, Pn = function* (e, t) {
1796
+ }, Cn = function* (e, t) {
1794
1797
  let r = e.byteLength;
1795
1798
  if (r < t) {
1796
1799
  yield e;
@@ -1801,7 +1804,7 @@ const Ut = (e) => {
1801
1804
  s = n + t, yield e.slice(n, s), n = s;
1802
1805
  }, kn = async function* (e, t) {
1803
1806
  for await (const r of Fn(e))
1804
- yield* Pn(r, t);
1807
+ yield* Cn(r, t);
1805
1808
  }, Fn = async function* (e) {
1806
1809
  if (e[Symbol.asyncIterator]) {
1807
1810
  yield* e;
@@ -1906,7 +1909,7 @@ const Ln = async (e) => {
1906
1909
  fetchOptions: b
1907
1910
  } = Ut(e);
1908
1911
  l = l ? (l + "").toLowerCase() : "text";
1909
- let T = Cn([s, o && o.toAbortSignal()], i), h;
1912
+ let T = Pn([s, o && o.toAbortSignal()], i), h;
1910
1913
  const R = T && T.unsubscribe && (() => {
1911
1914
  T.unsubscribe();
1912
1915
  });
@@ -1919,11 +1922,11 @@ const Ln = async (e) => {
1919
1922
  duplex: "half"
1920
1923
  }), N;
1921
1924
  if (a.isFormData(n) && (N = A.headers.get("content-type")) && u.setContentType(N), A.body) {
1922
- const [U, C] = st(
1925
+ const [U, P] = st(
1923
1926
  m,
1924
1927
  de(ot(d))
1925
1928
  );
1926
- n = at(A.body, ct, U, C);
1929
+ n = at(A.body, ct, U, P);
1927
1930
  }
1928
1931
  }
1929
1932
  a.isString(p) || (p = p ? "include" : "omit");
@@ -1944,13 +1947,13 @@ const Ln = async (e) => {
1944
1947
  ["status", "statusText", "headers"].forEach((I) => {
1945
1948
  A[I] = E[I];
1946
1949
  });
1947
- const N = a.toFiniteNumber(E.headers.get("content-length")), [U, C] = c && st(
1950
+ const N = a.toFiniteNumber(E.headers.get("content-length")), [U, P] = c && st(
1948
1951
  N,
1949
1952
  de(ot(c), !0)
1950
1953
  ) || [];
1951
1954
  E = new Response(
1952
1955
  at(E.body, ct, U, () => {
1953
- C && C(), R && R();
1956
+ P && P(), R && R();
1954
1957
  }),
1955
1958
  A
1956
1959
  );
@@ -2020,22 +2023,22 @@ const lt = (e) => `- ${e}`, Bn = (e) => a.isFunction(e) || e === null || e === !
2020
2023
  },
2021
2024
  adapters: je
2022
2025
  };
2023
- function Ce(e) {
2026
+ function Pe(e) {
2024
2027
  if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
2025
2028
  throw new K(null, e);
2026
2029
  }
2027
2030
  function ut(e) {
2028
- return Ce(e), e.headers = L.from(e.headers), e.data = Ne.call(
2031
+ return Pe(e), e.headers = L.from(e.headers), e.data = Ne.call(
2029
2032
  e,
2030
2033
  e.transformRequest
2031
2034
  ), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), qt.getAdapter(e.adapter || ae.adapter)(e).then(function(n) {
2032
- return Ce(e), n.data = Ne.call(
2035
+ return Pe(e), n.data = Ne.call(
2033
2036
  e,
2034
2037
  e.transformResponse,
2035
2038
  n
2036
2039
  ), n.headers = L.from(n.headers), n;
2037
2040
  }, function(n) {
2038
- return vt(n) || (Ce(e), n && n.response && (n.response.data = Ne.call(
2041
+ return vt(n) || (Pe(e), n && n.response && (n.response.data = Ne.call(
2039
2042
  e,
2040
2043
  e.transformResponse,
2041
2044
  n.response
@@ -2188,7 +2191,7 @@ let z = class {
2188
2191
  getUri(t) {
2189
2192
  t = J(this.defaults, t);
2190
2193
  const r = Lt(t.baseURL, t.url, t.allowAbsoluteUrls);
2191
- return Pt(r, t.params, t.paramsSerializer);
2194
+ return Ct(r, t.params, t.paramsSerializer);
2192
2195
  }
2193
2196
  };
2194
2197
  a.forEach(["delete", "get", "head", "options"], function(t) {
@@ -0,0 +1,10 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { IUseFetcherArgs } from './types';
3
+ import { TFileMapVariables } from './utils';
4
+ /**
5
+ * GrqpahQL 的查詢氣
6
+ * @param axiosInstance
7
+ * @param query
8
+ */
9
+ declare const createGraphQLFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, query: string) => ((args?: TArgs) => Promise<TData>);
10
+ export default createGraphQLFetcher;
@@ -0,0 +1,2 @@
1
+ export { default as createGraphQLFetcher } from './createGraphQLFetcher';
2
+ export type { IUseFetcherArgs as IUseGraphQLFetcherArgs } from './types';
@@ -1,4 +1,4 @@
1
- export declare enum ERequestHeader {
1
+ export declare enum ERequestHeaderContentType {
2
2
  formData = "multipart/form-data",
3
3
  formUrlDecode = "application/x-www-form-urlencoded",
4
4
  json = "application/json"
@@ -1 +1,3 @@
1
1
  export { default as createRestFulFetcher } from './createRestFulFetcher';
2
+ export type { IUseFetcherArgs as IUseRestFulFetcherArgs } from './types';
3
+ export type { ERequestHeaderContentType } from './config';
@@ -1,10 +1,10 @@
1
- import { ERequestHeader } from './config';
1
+ import { ERequestHeaderContentType } from './config';
2
2
  /**
3
3
  *
4
4
  * @param obj 送出物件
5
5
  * @param contentType
6
6
  */
7
- export declare function flattenObjectToFormData(obj: Record<string, any>, contentType: ERequestHeader): {
7
+ export declare function flattenObjectToFormData(obj: Record<string, any>, contentType: ERequestHeaderContentType): {
8
8
  body: FormData | string;
9
9
  contentType: string;
10
10
  };
@@ -1,3 +1,3 @@
1
- export * from './createGraphQL2Fetcher';
1
+ export * from './createGraphQLFetcher';
2
2
  export * from './createRestFulFetcher';
3
3
  export type { IRequestConfig } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acrool/react-fetcher",
3
- "version": "0.0.2-alpha.6",
3
+ "version": "0.0.2-alpha.8",
4
4
  "description": "Fetcher library based for Reactjs",
5
5
  "keywords": [
6
6
  "acrool",
@@ -1,10 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { IUseFetcherArgs } from './types';
3
- import { TFileMapVariables } from './utils';
4
- /**
5
- * GrqpahQL 的查詢氣
6
- * @param axiosInstance
7
- * @param query
8
- */
9
- declare const createGraphQL2Fetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, query: string) => ((args?: TArgs) => Promise<TData>);
10
- export default createGraphQL2Fetcher;
@@ -1 +0,0 @@
1
- export { default as createGraphQLFetcher } from './createGraphQL2Fetcher';