@ahoo-wang/fetcher 1.8.5 → 1.8.6

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
@@ -209,12 +209,12 @@ class j {
209
209
  */
210
210
  build(t, r) {
211
211
  const s = r?.path, o = r?.query, n = D(this.baseURL, t);
212
- let u = this.urlTemplateResolver.resolve(n, s);
212
+ let i = this.urlTemplateResolver.resolve(n, s);
213
213
  if (o) {
214
214
  const c = new URLSearchParams(o).toString();
215
- c && (u += "?" + c);
215
+ c && (i += "?" + c);
216
216
  }
217
- return u;
217
+ return i;
218
218
  }
219
219
  /**
220
220
  * Resolves a complete URL from a FetchRequest.
@@ -262,9 +262,9 @@ async function $(e) {
262
262
  if (!r)
263
263
  return e.abortController && (s.signal = e.abortController.signal), fetch(t, s);
264
264
  const o = e.abortController ?? new AbortController();
265
- s.signal = o.signal;
265
+ e.abortController = o, s.signal = o.signal;
266
266
  let n = null;
267
- const u = new Promise((c, p) => {
267
+ const i = new Promise((c, p) => {
268
268
  n = setTimeout(() => {
269
269
  n && clearTimeout(n);
270
270
  const I = new g(e);
@@ -272,7 +272,7 @@ async function $(e) {
272
272
  }, r);
273
273
  });
274
274
  try {
275
- return await Promise.race([fetch(t, s), u]);
275
+ return await Promise.race([fetch(t, s), i]);
276
276
  } finally {
277
277
  n && clearTimeout(n);
278
278
  }
@@ -292,7 +292,7 @@ class V {
292
292
  r.url = t.fetcher.urlBuilder.resolveRequestUrl(r);
293
293
  }
294
294
  }
295
- var i = /* @__PURE__ */ ((e) => (e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.DELETE = "DELETE", e.PATCH = "PATCH", e.HEAD = "HEAD", e.OPTIONS = "OPTIONS", e))(i || {});
295
+ var u = /* @__PURE__ */ ((e) => (e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.DELETE = "DELETE", e.PATCH = "PATCH", e.HEAD = "HEAD", e.OPTIONS = "OPTIONS", e))(u || {});
296
296
  const Et = "Content-Type", d = class d {
297
297
  };
298
298
  d.APPLICATION_JSON = "application/json", d.TEXT_EVENT_STREAM = "text/event-stream";
@@ -651,17 +651,17 @@ class rt {
651
651
  }
652
652
  }
653
653
  }
654
- const st = (e) => e, ot = (e) => e.requiredResponse, nt = (e) => e.requiredResponse.json(), ut = (e) => e.requiredResponse.text(), O = {
654
+ const st = (e) => e, ot = (e) => e.requiredResponse, nt = (e) => e.requiredResponse.json(), it = (e) => e.requiredResponse.text(), O = {
655
655
  Exchange: st,
656
656
  Response: ot,
657
657
  Json: nt,
658
- Text: ut
658
+ Text: it
659
659
  };
660
660
  function q(e, t) {
661
661
  if (!(e === void 0 && t === void 0))
662
662
  return t === void 0 ? e : e === void 0 ? t : { ...e, ...t };
663
663
  }
664
- function it(e, t) {
664
+ function ut(e, t) {
665
665
  if (t ??= /* @__PURE__ */ new Map(), !e)
666
666
  return t;
667
667
  if (e instanceof Map) {
@@ -675,7 +675,7 @@ function it(e, t) {
675
675
  }
676
676
  class ct {
677
677
  constructor(t) {
678
- this.fetcher = t.fetcher, this.request = t.request, this.resultExtractor = t.resultExtractor ?? O.Exchange, this.attributes = it(t.attributes), this._response = t.response, this.error = t.error;
678
+ this.fetcher = t.fetcher, this.request = t.request, this.resultExtractor = t.resultExtractor ?? O.Exchange, this.attributes = ut(t.attributes), this._response = t.response, this.error = t.error;
679
679
  }
680
680
  /**
681
681
  * Ensures that request headers object exists, creating it if necessary.
@@ -779,7 +779,7 @@ function dt(e, t) {
779
779
  }, s = {
780
780
  ...e.headers,
781
781
  ...t.headers
782
- }, o = t.method ?? e.method, n = t.body ?? e.body, u = t.timeout ?? e.timeout, c = t.signal ?? e.signal, p = t.abortController ?? e.abortController;
782
+ }, o = t.method ?? e.method, n = t.body ?? e.body, i = t.timeout ?? e.timeout, c = t.signal ?? e.signal, p = t.abortController ?? e.abortController;
783
783
  return {
784
784
  ...e,
785
785
  ...t,
@@ -787,7 +787,7 @@ function dt(e, t) {
787
787
  urlParams: r,
788
788
  headers: s,
789
789
  body: n,
790
- timeout: u,
790
+ timeout: i,
791
791
  signal: c,
792
792
  abortController: p
793
793
  };
@@ -864,12 +864,12 @@ class U {
864
864
  timeout: B(t.timeout, this.timeout)
865
865
  }, {
866
866
  resultExtractor: n,
867
- attributes: u
867
+ attributes: i
868
868
  } = w(C, r), c = new ct({
869
869
  fetcher: this,
870
870
  request: o,
871
871
  resultExtractor: n,
872
- attributes: u
872
+ attributes: i
873
873
  });
874
874
  return this.interceptors.exchange(c);
875
875
  }
@@ -941,7 +941,7 @@ class U {
941
941
  * @returns Promise that resolves to the HTTP response
942
942
  */
943
943
  async get(t, r = {}, s) {
944
- return this.methodFetch(i.GET, t, r, s);
944
+ return this.methodFetch(u.GET, t, r, s);
945
945
  }
946
946
  /**
947
947
  * Makes a PUT HTTP request.
@@ -960,7 +960,7 @@ class U {
960
960
  * @returns Promise that resolves to the HTTP response
961
961
  */
962
962
  async put(t, r = {}, s) {
963
- return this.methodFetch(i.PUT, t, r, s);
963
+ return this.methodFetch(u.PUT, t, r, s);
964
964
  }
965
965
  /**
966
966
  * Makes a POST HTTP request.
@@ -979,7 +979,7 @@ class U {
979
979
  * @returns Promise that resolves to the HTTP response
980
980
  */
981
981
  async post(t, r = {}, s) {
982
- return this.methodFetch(i.POST, t, r, s);
982
+ return this.methodFetch(u.POST, t, r, s);
983
983
  }
984
984
  /**
985
985
  * Makes a PATCH HTTP request.
@@ -998,7 +998,7 @@ class U {
998
998
  * @returns Promise that resolves to the HTTP response
999
999
  */
1000
1000
  async patch(t, r = {}, s) {
1001
- return this.methodFetch(i.PATCH, t, r, s);
1001
+ return this.methodFetch(u.PATCH, t, r, s);
1002
1002
  }
1003
1003
  /**
1004
1004
  * Makes a DELETE HTTP request.
@@ -1017,7 +1017,7 @@ class U {
1017
1017
  * @returns Promise that resolves to the HTTP response
1018
1018
  */
1019
1019
  async delete(t, r = {}, s) {
1020
- return this.methodFetch(i.DELETE, t, r, s);
1020
+ return this.methodFetch(u.DELETE, t, r, s);
1021
1021
  }
1022
1022
  /**
1023
1023
  * Makes a HEAD HTTP request.
@@ -1037,7 +1037,7 @@ class U {
1037
1037
  * @returns Promise that resolves to the HTTP response
1038
1038
  */
1039
1039
  async head(t, r = {}, s) {
1040
- return this.methodFetch(i.HEAD, t, r, s);
1040
+ return this.methodFetch(u.HEAD, t, r, s);
1041
1041
  }
1042
1042
  /**
1043
1043
  * Makes an OPTIONS HTTP request.
@@ -1057,7 +1057,7 @@ class U {
1057
1057
  * @returns Promise that resolves to the HTTP response
1058
1058
  */
1059
1059
  async options(t, r = {}, s) {
1060
- return this.methodFetch(i.OPTIONS, t, r, s);
1060
+ return this.methodFetch(u.OPTIONS, t, r, s);
1061
1061
  }
1062
1062
  }
1063
1063
  const y = "default";
@@ -1206,7 +1206,7 @@ export {
1206
1206
  U as Fetcher,
1207
1207
  l as FetcherError,
1208
1208
  ht as FetcherRegistrar,
1209
- i as HttpMethod,
1209
+ u as HttpMethod,
1210
1210
  _ as HttpStatusValidationError,
1211
1211
  rt as InterceptorManager,
1212
1212
  f as InterceptorRegistry,
@@ -1217,7 +1217,7 @@ export {
1217
1217
  Q as RequestBodyInterceptor,
1218
1218
  ot as ResponseResultExtractor,
1219
1219
  O as ResultExtractors,
1220
- ut as TextResultExtractor,
1220
+ it as TextResultExtractor,
1221
1221
  X as URL_RESOLVE_INTERCEPTOR_NAME,
1222
1222
  F as URL_RESOLVE_INTERCEPTOR_ORDER,
1223
1223
  m as UriTemplateResolver,
@@ -1234,7 +1234,7 @@ export {
1234
1234
  Rt as getFetcher,
1235
1235
  M as getUrlTemplateResolver,
1236
1236
  v as isAbsoluteURL,
1237
- it as mergeRecordToMap,
1237
+ ut as mergeRecordToMap,
1238
1238
  q as mergeRecords,
1239
1239
  dt as mergeRequest,
1240
1240
  w as mergeRequestOptions,