undici 6.3.0 → 6.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -75,9 +75,10 @@
75
75
  "build:wasm": "node build/wasm.js --docker",
76
76
  "lint": "standard | snazzy",
77
77
  "lint:fix": "standard --fix | snazzy",
78
- "test": "node scripts/generate-pem && npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:wpt && npm run test:websocket && npm run test:jest && npm run test:typescript && npm run test:node-test",
78
+ "test": "node scripts/generate-pem && npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:jest && npm run test:typescript && npm run test:node-test",
79
79
  "test:cookies": "borp --coverage -p \"test/cookie/*.js\"",
80
80
  "test:node-fetch": "mocha --exit test/node-fetch",
81
+ "test:eventsource": "npm run build:node && borp --expose-gc --coverage -p \"test/eventsource/*.js\"",
81
82
  "test:fetch": "npm run build:node && borp --expose-gc --coverage -p \"test/fetch/*.js\" && borp --coverage -p \"test/webidl/*.js\"",
82
83
  "test:jest": "jest",
83
84
  "test:tap": "tap test/*.js",
@@ -86,13 +87,13 @@
86
87
  "test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w",
87
88
  "test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts",
88
89
  "test:websocket": "borp --coverage -p \"test/websocket/*.js\"",
89
- "test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs && node test/wpt/start-cacheStorage.mjs",
90
+ "test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs",
90
91
  "coverage": "nyc --reporter=text --reporter=html npm run test",
91
92
  "coverage:ci": "nyc --reporter=lcov npm run test",
92
93
  "bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
93
94
  "bench:server": "node benchmarks/server.js",
94
95
  "prebench:run": "node benchmarks/wait.js",
95
- "bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
96
+ "bench:run": "SAMPLES=100 CONNECTIONS=50 node benchmarks/benchmark.js",
96
97
  "serve:website": "docsify serve .",
97
98
  "prepare": "husky install",
98
99
  "fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
@@ -119,7 +120,7 @@
119
120
  "husky": "^8.0.1",
120
121
  "import-fresh": "^3.3.0",
121
122
  "jest": "^29.0.2",
122
- "jsdom": "^23.0.0",
123
+ "jsdom": "^24.0.0",
123
124
  "jsfuzz": "^1.0.15",
124
125
  "mitata": "^0.1.6",
125
126
  "mocha": "^10.0.0",
@@ -136,7 +137,11 @@
136
137
  "tsd": "^0.30.1",
137
138
  "typescript": "^5.0.2",
138
139
  "wait-on": "^7.0.1",
139
- "ws": "^8.11.0"
140
+ "ws": "^8.11.0",
141
+ "axios": "^1.6.5",
142
+ "got": "^14.0.0",
143
+ "node-fetch": "^3.3.2",
144
+ "request": "^2.88.2"
140
145
  },
141
146
  "engines": {
142
147
  "node": ">=18.0"
@@ -131,6 +131,8 @@ declare namespace Dispatcher {
131
131
  opaque?: unknown;
132
132
  /** Default: 0 */
133
133
  maxRedirections?: number;
134
+ /** Default: false */
135
+ redirectionLimitReached?: boolean;
134
136
  /** Default: `null` */
135
137
  responseHeader?: 'raw' | null;
136
138
  }
@@ -141,6 +143,8 @@ declare namespace Dispatcher {
141
143
  signal?: AbortSignal | EventEmitter | null;
142
144
  /** Default: 0 */
143
145
  maxRedirections?: number;
146
+ /** Default: false */
147
+ redirectionLimitReached?: boolean;
144
148
  /** Default: `null` */
145
149
  onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
146
150
  /** Default: `null` */
@@ -164,6 +168,8 @@ declare namespace Dispatcher {
164
168
  signal?: AbortSignal | EventEmitter | null;
165
169
  /** Default: 0 */
166
170
  maxRedirections?: number;
171
+ /** Default: false */
172
+ redirectionLimitReached?: boolean;
167
173
  /** Default: `null` */
168
174
  responseHeader?: 'raw' | null;
169
175
  }
@@ -229,7 +235,7 @@ declare namespace Dispatcher {
229
235
  * @link https://fetch.spec.whatwg.org/#body-mixin
230
236
  */
231
237
  interface BodyMixin {
232
- readonly body?: never; // throws on node v16.6.0
238
+ readonly body?: never;
233
239
  readonly bodyUsed: boolean;
234
240
  arrayBuffer(): Promise<ArrayBuffer>;
235
241
  blob(): Promise<Blob>;
@@ -0,0 +1,61 @@
1
+ import { MessageEvent, ErrorEvent } from './websocket'
2
+
3
+ import {
4
+ EventTarget,
5
+ Event,
6
+ EventListenerOptions,
7
+ AddEventListenerOptions,
8
+ EventListenerOrEventListenerObject
9
+ } from './patch'
10
+
11
+ interface EventSourceEventMap {
12
+ error: ErrorEvent
13
+ message: MessageEvent
14
+ open: Event
15
+ }
16
+
17
+ interface EventSource extends EventTarget {
18
+ close(): void
19
+ readonly CLOSED: 2
20
+ readonly CONNECTING: 0
21
+ readonly OPEN: 1
22
+ onerror: (this: EventSource, ev: ErrorEvent) => any
23
+ onmessage: (this: EventSource, ev: MessageEvent) => any
24
+ onopen: (this: EventSource, ev: Event) => any
25
+ readonly readyState: 0 | 1 | 2
26
+ readonly url: string
27
+ readonly withCredentials: boolean
28
+
29
+ addEventListener<K extends keyof EventSourceEventMap>(
30
+ type: K,
31
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
32
+ options?: boolean | AddEventListenerOptions
33
+ ): void
34
+ addEventListener(
35
+ type: string,
36
+ listener: EventListenerOrEventListenerObject,
37
+ options?: boolean | AddEventListenerOptions
38
+ ): void
39
+ removeEventListener<K extends keyof EventSourceEventMap>(
40
+ type: K,
41
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
42
+ options?: boolean | EventListenerOptions
43
+ ): void
44
+ removeEventListener(
45
+ type: string,
46
+ listener: EventListenerOrEventListenerObject,
47
+ options?: boolean | EventListenerOptions
48
+ ): void
49
+ }
50
+
51
+ export declare const EventSource: {
52
+ prototype: EventSource
53
+ new (url: string | URL, init: EventSourceInit): EventSource
54
+ readonly CLOSED: 2
55
+ readonly CONNECTING: 0
56
+ readonly OPEN: 1
57
+ }
58
+
59
+ interface EventSourceInit {
60
+ withCredentials?: boolean
61
+ }
@@ -1,9 +1,15 @@
1
1
  import Dispatcher from "./dispatcher";
2
2
 
3
- export declare class RedirectHandler implements Dispatcher.DispatchHandlers{
4
- constructor (dispatch: Dispatcher, maxRedirections: number, opts: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers)
3
+ export declare class RedirectHandler implements Dispatcher.DispatchHandlers {
4
+ constructor(
5
+ dispatch: Dispatcher,
6
+ maxRedirections: number,
7
+ opts: Dispatcher.DispatchOptions,
8
+ handler: Dispatcher.DispatchHandlers,
9
+ redirectionLimitReached: boolean
10
+ );
5
11
  }
6
12
 
7
- export declare class DecoratorHandler implements Dispatcher.DispatchHandlers{
8
- constructor (handler: Dispatcher.DispatchHandlers)
13
+ export declare class DecoratorHandler implements Dispatcher.DispatchHandlers {
14
+ constructor(handler: Dispatcher.DispatchHandlers);
9
15
  }
package/types/index.d.ts CHANGED
@@ -19,6 +19,7 @@ import { request, pipeline, stream, connect, upgrade } from './api'
19
19
 
20
20
  export * from './util'
21
21
  export * from './cookies'
22
+ export * from './eventsource'
22
23
  export * from './fetch'
23
24
  export * from './file'
24
25
  export * from './filereader'
@@ -44,9 +44,8 @@ declare class BodyReadable extends Readable {
44
44
  */
45
45
  readonly bodyUsed: boolean
46
46
 
47
- /** Throws on node 16.6.0
48
- *
49
- * If body is null, it should return null as the body
47
+ /**
48
+ * If body is null, it should return null as the body
50
49
  *
51
50
  * If body is not null, should return the body as a ReadableStream
52
51
  *
@@ -17,7 +17,7 @@ export type BinaryType = 'blob' | 'arraybuffer'
17
17
 
18
18
  interface WebSocketEventMap {
19
19
  close: CloseEvent
20
- error: Event
20
+ error: ErrorEvent
21
21
  message: MessageEvent
22
22
  open: Event
23
23
  }
@@ -124,6 +124,27 @@ export declare const MessageEvent: {
124
124
  new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>
125
125
  }
126
126
 
127
+ interface ErrorEventInit extends EventInit {
128
+ message?: string
129
+ filename?: string
130
+ lineno?: number
131
+ colno?: number
132
+ error?: any
133
+ }
134
+
135
+ interface ErrorEvent extends Event {
136
+ readonly message: string
137
+ readonly filename: string
138
+ readonly lineno: number
139
+ readonly colno: number
140
+ readonly error: any
141
+ }
142
+
143
+ export declare const ErrorEvent: {
144
+ prototype: ErrorEvent
145
+ new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent
146
+ }
147
+
127
148
  interface WebSocketInit {
128
149
  protocols?: string | string[],
129
150
  dispatcher?: Dispatcher,