@fetchkit/ffetch 5.1.0 → 5.1.1

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.
@@ -23,9 +23,10 @@ __export(response_shortcuts_exports, {
23
23
  responseShortcutsPlugin: () => responseShortcutsPlugin
24
24
  });
25
25
  module.exports = __toCommonJS(response_shortcuts_exports);
26
+ var DECORATED = Symbol("ffetch.responseShortcutsDecorated");
26
27
  function attachResponseShortcuts(promise) {
27
28
  const decorated = promise;
28
- if (decorated.__ffetchResponseShortcutsDecorated__) {
29
+ if (decorated[DECORATED]) {
29
30
  return decorated;
30
31
  }
31
32
  Object.defineProperties(decorated, {
@@ -69,7 +70,7 @@ function attachResponseShortcuts(promise) {
69
70
  enumerable: false,
70
71
  configurable: false
71
72
  },
72
- __ffetchResponseShortcutsDecorated__: {
73
+ [DECORATED]: {
73
74
  value: true,
74
75
  writable: false,
75
76
  enumerable: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/response-shortcuts.ts"],"sourcesContent":["import type { ClientPlugin } from '../plugins.js'\r\n\r\nexport type ResponseShortcuts = {\r\n json: <T = unknown>() => Promise<T>\r\n text: () => Promise<string>\r\n blob: () => Promise<Blob>\r\n arrayBuffer: () => Promise<ArrayBuffer>\r\n formData: () => Promise<FormData>\r\n}\r\n\r\ntype ResponseShortcutsPromise = Promise<Response> & ResponseShortcuts\r\n\r\ntype DecoratedPromise = ResponseShortcutsPromise & {\r\n __ffetchResponseShortcutsDecorated__?: true\r\n}\r\n\r\nfunction attachResponseShortcuts(\r\n promise: Promise<Response>\r\n): ResponseShortcutsPromise {\r\n const decorated = promise as DecoratedPromise\r\n\r\n if (decorated.__ffetchResponseShortcutsDecorated__) {\r\n return decorated\r\n }\r\n\r\n Object.defineProperties(decorated, {\r\n json: {\r\n value: function json<T = unknown>(this: Promise<Response>) {\r\n return this.then((response) => response.json() as Promise<T>)\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n text: {\r\n value: function text(this: Promise<Response>) {\r\n return this.then((response) => response.text())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n blob: {\r\n value: function blob(this: Promise<Response>) {\r\n return this.then((response) => response.blob())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n arrayBuffer: {\r\n value: function arrayBuffer(this: Promise<Response>) {\r\n return this.then((response) => response.arrayBuffer())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n formData: {\r\n value: function formData(this: Promise<Response>) {\r\n return this.then((response) => response.formData())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n __ffetchResponseShortcutsDecorated__: {\r\n value: true,\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n })\r\n\r\n return decorated\r\n}\r\n\r\nexport function responseShortcutsPlugin(): ClientPlugin<\r\n Record<never, never>,\r\n ResponseShortcuts\r\n> {\r\n return {\r\n name: 'response-shortcuts',\r\n decoratePromise: (promise) => attachResponseShortcuts(promise),\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,SAAS,wBACP,SAC0B;AAC1B,QAAM,YAAY;AAElB,MAAI,UAAU,sCAAsC;AAClD,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB,WAAW;AAAA,IACjC,MAAM;AAAA,MACJ,OAAO,SAAS,OAA2C;AACzD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAe;AAAA,MAC9D;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,SAAS,OAA8B;AAC5C,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,SAAS,OAA8B;AAC5C,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,aAAa;AAAA,MACX,OAAO,SAAS,cAAqC;AACnD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,YAAY,CAAC;AAAA,MACvD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,UAAU;AAAA,MACR,OAAO,SAAS,WAAkC;AAChD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,SAAS,CAAC;AAAA,MACpD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,sCAAsC;AAAA,MACpC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEO,SAAS,0BAGd;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,CAAC,YAAY,wBAAwB,OAAO;AAAA,EAC/D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/plugins/response-shortcuts.ts"],"sourcesContent":["import type { ClientPlugin } from '../plugins.js'\n\nexport type ResponseShortcuts = {\n json: <T = unknown>() => Promise<T>\n text: () => Promise<string>\n blob: () => Promise<Blob>\n arrayBuffer: () => Promise<ArrayBuffer>\n formData: () => Promise<FormData>\n}\n\ntype ResponseShortcutsPromise = Promise<Response> & ResponseShortcuts\n\nconst DECORATED = Symbol('ffetch.responseShortcutsDecorated')\n\ntype DecoratedPromise = ResponseShortcutsPromise & {\n [DECORATED]?: true\n}\n\nfunction attachResponseShortcuts(\n promise: Promise<Response>\n): ResponseShortcutsPromise {\n const decorated = promise as DecoratedPromise\n\n if (decorated[DECORATED]) {\n return decorated\n }\n\n Object.defineProperties(decorated, {\n json: {\n value: function json<T = unknown>(this: Promise<Response>) {\n return this.then((response) => response.json() as Promise<T>)\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n text: {\n value: function text(this: Promise<Response>) {\n return this.then((response) => response.text())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n blob: {\n value: function blob(this: Promise<Response>) {\n return this.then((response) => response.blob())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n arrayBuffer: {\n value: function arrayBuffer(this: Promise<Response>) {\n return this.then((response) => response.arrayBuffer())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n formData: {\n value: function formData(this: Promise<Response>) {\n return this.then((response) => response.formData())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n [DECORATED]: {\n value: true,\n writable: false,\n enumerable: false,\n configurable: false,\n },\n })\n\n return decorated\n}\n\nexport function responseShortcutsPlugin(): ClientPlugin<\n Record<never, never>,\n ResponseShortcuts\n> {\n return {\n name: 'response-shortcuts',\n decoratePromise: (promise) => attachResponseShortcuts(promise),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,IAAM,YAAY,OAAO,mCAAmC;AAM5D,SAAS,wBACP,SAC0B;AAC1B,QAAM,YAAY;AAElB,MAAI,UAAU,SAAS,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB,WAAW;AAAA,IACjC,MAAM;AAAA,MACJ,OAAO,SAAS,OAA2C;AACzD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAe;AAAA,MAC9D;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,SAAS,OAA8B;AAC5C,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,SAAS,OAA8B;AAC5C,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,aAAa;AAAA,MACX,OAAO,SAAS,cAAqC;AACnD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,YAAY,CAAC;AAAA,MACvD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,UAAU;AAAA,MACR,OAAO,SAAS,WAAkC;AAChD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,SAAS,CAAC;AAAA,MACpD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,CAAC,SAAS,GAAG;AAAA,MACX,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEO,SAAS,0BAGd;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,CAAC,YAAY,wBAAwB,OAAO;AAAA,EAC/D;AACF;","names":[]}
@@ -1,7 +1,8 @@
1
1
  // src/plugins/response-shortcuts.ts
2
+ var DECORATED = Symbol("ffetch.responseShortcutsDecorated");
2
3
  function attachResponseShortcuts(promise) {
3
4
  const decorated = promise;
4
- if (decorated.__ffetchResponseShortcutsDecorated__) {
5
+ if (decorated[DECORATED]) {
5
6
  return decorated;
6
7
  }
7
8
  Object.defineProperties(decorated, {
@@ -45,7 +46,7 @@ function attachResponseShortcuts(promise) {
45
46
  enumerable: false,
46
47
  configurable: false
47
48
  },
48
- __ffetchResponseShortcutsDecorated__: {
49
+ [DECORATED]: {
49
50
  value: true,
50
51
  writable: false,
51
52
  enumerable: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/response-shortcuts.ts"],"sourcesContent":["import type { ClientPlugin } from '../plugins.js'\r\n\r\nexport type ResponseShortcuts = {\r\n json: <T = unknown>() => Promise<T>\r\n text: () => Promise<string>\r\n blob: () => Promise<Blob>\r\n arrayBuffer: () => Promise<ArrayBuffer>\r\n formData: () => Promise<FormData>\r\n}\r\n\r\ntype ResponseShortcutsPromise = Promise<Response> & ResponseShortcuts\r\n\r\ntype DecoratedPromise = ResponseShortcutsPromise & {\r\n __ffetchResponseShortcutsDecorated__?: true\r\n}\r\n\r\nfunction attachResponseShortcuts(\r\n promise: Promise<Response>\r\n): ResponseShortcutsPromise {\r\n const decorated = promise as DecoratedPromise\r\n\r\n if (decorated.__ffetchResponseShortcutsDecorated__) {\r\n return decorated\r\n }\r\n\r\n Object.defineProperties(decorated, {\r\n json: {\r\n value: function json<T = unknown>(this: Promise<Response>) {\r\n return this.then((response) => response.json() as Promise<T>)\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n text: {\r\n value: function text(this: Promise<Response>) {\r\n return this.then((response) => response.text())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n blob: {\r\n value: function blob(this: Promise<Response>) {\r\n return this.then((response) => response.blob())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n arrayBuffer: {\r\n value: function arrayBuffer(this: Promise<Response>) {\r\n return this.then((response) => response.arrayBuffer())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n formData: {\r\n value: function formData(this: Promise<Response>) {\r\n return this.then((response) => response.formData())\r\n },\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n __ffetchResponseShortcutsDecorated__: {\r\n value: true,\r\n writable: false,\r\n enumerable: false,\r\n configurable: false,\r\n },\r\n })\r\n\r\n return decorated\r\n}\r\n\r\nexport function responseShortcutsPlugin(): ClientPlugin<\r\n Record<never, never>,\r\n ResponseShortcuts\r\n> {\r\n return {\r\n name: 'response-shortcuts',\r\n decoratePromise: (promise) => attachResponseShortcuts(promise),\r\n }\r\n}\r\n"],"mappings":";AAgBA,SAAS,wBACP,SAC0B;AAC1B,QAAM,YAAY;AAElB,MAAI,UAAU,sCAAsC;AAClD,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB,WAAW;AAAA,IACjC,MAAM;AAAA,MACJ,OAAO,SAAS,OAA2C;AACzD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAe;AAAA,MAC9D;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,SAAS,OAA8B;AAC5C,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,SAAS,OAA8B;AAC5C,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC;AAAA,MAChD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,aAAa;AAAA,MACX,OAAO,SAAS,cAAqC;AACnD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,YAAY,CAAC;AAAA,MACvD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,UAAU;AAAA,MACR,OAAO,SAAS,WAAkC;AAChD,eAAO,KAAK,KAAK,CAAC,aAAa,SAAS,SAAS,CAAC;AAAA,MACpD;AAAA,MACA,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IACA,sCAAsC;AAAA,MACpC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEO,SAAS,0BAGd;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,CAAC,YAAY,wBAAwB,OAAO;AAAA,EAC/D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/plugins/response-shortcuts.ts"],"sourcesContent":["import type { ClientPlugin } from '../plugins.js'\n\nexport type ResponseShortcuts = {\n json: <T = unknown>() => Promise<T>\n text: () => Promise<string>\n blob: () => Promise<Blob>\n arrayBuffer: () => Promise<ArrayBuffer>\n formData: () => Promise<FormData>\n}\n\ntype ResponseShortcutsPromise = Promise<Response> & ResponseShortcuts\n\nconst DECORATED = Symbol('ffetch.responseShortcutsDecorated')\n\ntype DecoratedPromise = ResponseShortcutsPromise & {\n [DECORATED]?: true\n}\n\nfunction attachResponseShortcuts(\n promise: Promise<Response>\n): ResponseShortcutsPromise {\n const decorated = promise as DecoratedPromise\n\n if (decorated[DECORATED]) {\n return decorated\n }\n\n Object.defineProperties(decorated, {\n json: {\n value: function json<T = unknown>(this: Promise<Response>) {\n return this.then((response) => response.json() as Promise<T>)\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n text: {\n value: function text(this: Promise<Response>) {\n return this.then((response) => response.text())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n blob: {\n value: function blob(this: Promise<Response>) {\n return this.then((response) => response.blob())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n arrayBuffer: {\n value: function arrayBuffer(this: Promise<Response>) {\n return this.then((response) => response.arrayBuffer())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n formData: {\n value: function formData(this: Promise<Response>) {\n return this.then((response) => response.formData())\n },\n writable: false,\n enumerable: false,\n configurable: false,\n },\n [DECORATED]: {\n value: true,\n writable: false,\n enumerable: false,\n configurable: false,\n },\n })\n\n return decorated\n}\n\nexport function responseShortcutsPlugin(): ClientPlugin<\n Record<never, never>,\n ResponseShortcuts\n> {\n return {\n name: 'response-shortcuts',\n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SAAO;AACT;AAEO,SAAS,0BAGd;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,CAAC,YAAY,wBAAwB,OAAO;AAAA,EAC/D;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fetchkit/ffetch",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Fetch wrapper with configurable timeouts, retries, and TypeScript-first DX",
5
5
  "keywords": [
6
6
  "fetch",