@whatwg-node/fetch 0.4.2 → 0.4.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @whatwg-node/fetch
2
2
 
3
+ ## 0.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9502102`](https://github.com/ardatan/whatwg-node/commit/9502102b265945b37ee38b276ec1533fae0f308f) Thanks [@ardatan](https://github.com/ardatan)! - Breaking Change: Event API is no longer available in this ponyfill; use @whatwg-node/events instead.
8
+
9
+ ## 0.4.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`c9f05f2`](https://github.com/ardatan/whatwg-node/commit/c9f05f21fb96f63bc22359e3b7981cb9b3b727b5) Thanks [@ardatan](https://github.com/ardatan)! - Add ponyfills for Response.redirect, Response.json and Response.error
14
+
3
15
  ## 0.4.2
4
16
 
5
17
  ### Patch Changes
@@ -25,13 +25,6 @@ module.exports = function createNodePonyfill(opts = {}) {
25
25
  ponyfills.Blob = globalThis.Blob;
26
26
  ponyfills.crypto = globalThis.crypto;
27
27
 
28
- if (!globalThis.Event || !globalThis.EventTarget) {
29
- require('event-target-polyfill');
30
- }
31
-
32
- ponyfills.Event = globalThis.Event;
33
- ponyfills.EventTarget = globalThis.EventTarget;
34
-
35
28
  if (!ponyfills.AbortController) {
36
29
  const abortControllerModule = require("abort-controller");
37
30
  ponyfills.AbortController =
@@ -319,5 +312,34 @@ module.exports = function createNodePonyfill(opts = {}) {
319
312
 
320
313
  }
321
314
  }
315
+
316
+ if (!ponyfills.Response.redirect) {
317
+ ponyfills.Response.redirect = function (url, status = 302) {
318
+ return new ponyfills.Response(null, {
319
+ status,
320
+ headers: {
321
+ Location: url,
322
+ },
323
+ });
324
+ };
325
+ }
326
+ if (!ponyfills.Response.json) {
327
+ ponyfills.Response.json = function (data, init = {}) {
328
+ return new ponyfills.Response(JSON.stringify(data), {
329
+ ...init,
330
+ headers: {
331
+ "Content-Type": "application/json",
332
+ ...init.headers,
333
+ },
334
+ });
335
+ };
336
+ }
337
+ if (!ponyfills.Response.error) {
338
+ ponyfills.Response.error = function () {
339
+ return new ponyfills.Response(null, {
340
+ status: 500,
341
+ });
342
+ };
343
+ }
322
344
  return ponyfills;
323
345
  }
@@ -13,10 +13,8 @@ const crypto = globalThis.crypto;
13
13
  const btoa = globalThis.btoa;
14
14
  const TextDecoder = globalThis.TextDecoder;
15
15
  const TextEncoder = globalThis.TextEncoder;
16
- const Event = globalThis.Event;
17
- const EventTarget = globalThis.EventTarget;
18
16
 
19
- export const create = () => globalThis;
17
+ export const createFetch = () => globalThis;
20
18
  export {
21
19
  fetch,
22
20
  Headers,
@@ -33,6 +31,4 @@ export {
33
31
  btoa,
34
32
  TextDecoder,
35
33
  TextEncoder,
36
- Event,
37
- EventTarget,
38
34
  };
@@ -13,6 +13,4 @@ module.exports.crypto = globalThis.crypto;
13
13
  module.exports.btoa = globalThis.btoa;
14
14
  module.exports.TextEncoder = globalThis.TextEncoder;
15
15
  module.exports.TextDecoder = globalThis.TextDecoder;
16
- module.exports.Event = globalThis.Event;
17
- module.exports.EventTarget = globalThis.EventTarget;
18
16
  module.exports.createFetch = () => globalThis;
package/dist/index.d.ts CHANGED
@@ -15,8 +15,6 @@ declare const _crypto: typeof crypto;
15
15
  declare const _btoa: typeof btoa;
16
16
  declare const _TextEncoder: typeof TextEncoder;
17
17
  declare const _TextDecoder: typeof TextDecoder;
18
- declare const _Event: typeof Event;
19
- declare const _EventTarget: typeof EventTarget;
20
18
 
21
19
  declare module "@whatwg-node/fetch" {
22
20
  export const fetch: typeof _fetch;
@@ -34,8 +32,6 @@ declare module "@whatwg-node/fetch" {
34
32
  export const btoa: typeof _btoa;
35
33
  export const TextDecoder: typeof _TextDecoder;
36
34
  export const TextEncoder: typeof _TextEncoder;
37
- export const Event: typeof _Event;
38
- export const EventTarget: typeof _EventTarget;
39
35
  export interface FormDataLimits {
40
36
  /* Max field name size (in bytes). Default: 100. */
41
37
  fieldNameSize?: number;
@@ -69,9 +65,7 @@ declare module "@whatwg-node/fetch" {
69
65
  crypto: typeof _crypto,
70
66
  btoa: typeof _btoa,
71
67
  TextEncoder: typeof _TextEncoder,
72
- TextDecoder: typeof _TextDecoder,
73
- Event: typeof _Event,
74
- EventTarget: typeof _EventTarget
68
+ TextDecoder: typeof _TextDecoder
75
69
  });
76
70
  }
77
71
 
@@ -17,7 +17,5 @@ module.exports.crypto = ponyfills.crypto;
17
17
  module.exports.btoa = ponyfills.btoa;
18
18
  module.exports.TextEncoder = ponyfills.TextEncoder;
19
19
  module.exports.TextDecoder = ponyfills.TextDecoder;
20
- module.exports.Event = ponyfills.Event;
21
- module.exports.EventTarget = ponyfills.EventTarget;
22
20
 
23
21
  exports.createFetch = createNodePonyfill;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/fetch",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Cross Platform Smart Fetch Ponyfill",
5
5
  "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
6
6
  "repository": {
@@ -21,7 +21,6 @@
21
21
  "@peculiar/webcrypto": "^1.4.0",
22
22
  "abort-controller": "^3.0.0",
23
23
  "busboy": "^1.6.0",
24
- "event-target-polyfill": "^0.0.3",
25
24
  "form-data-encoder": "^1.7.1",
26
25
  "formdata-node": "^4.3.1",
27
26
  "node-fetch": "^2.6.7",