@relative-ci/core 6.0.0 → 6.0.1-beta.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.
Files changed (54) hide show
  1. package/lib/cjs/__/content-type/dist/index.js +155 -71
  2. package/lib/cjs/__/content-type/dist/index.js.map +1 -1
  3. package/lib/cjs/__/undici/lib/core/request.js +68 -2
  4. package/lib/cjs/__/undici/lib/core/request.js.map +1 -1
  5. package/lib/cjs/__/undici/lib/dispatcher/agent.js +6 -2
  6. package/lib/cjs/__/undici/lib/dispatcher/agent.js.map +1 -1
  7. package/lib/cjs/__/undici/lib/dispatcher/client-h1.js +18 -9
  8. package/lib/cjs/__/undici/lib/dispatcher/client-h1.js.map +1 -1
  9. package/lib/cjs/__/undici/lib/dispatcher/client-h2.js +73 -23
  10. package/lib/cjs/__/undici/lib/dispatcher/client-h2.js.map +1 -1
  11. package/lib/cjs/__/undici/lib/dispatcher/client.js +3 -2
  12. package/lib/cjs/__/undici/lib/dispatcher/client.js.map +1 -1
  13. package/lib/cjs/__/undici/lib/dispatcher/dispatcher-base.js +14 -0
  14. package/lib/cjs/__/undici/lib/dispatcher/dispatcher-base.js.map +1 -1
  15. package/lib/cjs/__/undici/lib/handler/retry-handler.js +4 -1
  16. package/lib/cjs/__/undici/lib/handler/retry-handler.js.map +1 -1
  17. package/lib/cjs/__/undici/lib/web/eventsource/eventsource-stream.js +93 -10
  18. package/lib/cjs/__/undici/lib/web/eventsource/eventsource-stream.js.map +1 -1
  19. package/lib/cjs/__/undici/lib/web/eventsource/eventsource.js +5 -1
  20. package/lib/cjs/__/undici/lib/web/eventsource/eventsource.js.map +1 -1
  21. package/lib/cjs/__/undici/lib/web/fetch/index.js +7 -9
  22. package/lib/cjs/__/undici/lib/web/fetch/index.js.map +1 -1
  23. package/lib/cjs/__/undici/lib/web/websocket/receiver.js +14 -0
  24. package/lib/cjs/__/undici/lib/web/websocket/receiver.js.map +1 -1
  25. package/lib/cjs/env/load.js +1 -1
  26. package/lib/cjs/env/load.js.map +1 -1
  27. package/lib/esm/__/content-type/dist/index.js +155 -71
  28. package/lib/esm/__/content-type/dist/index.js.map +1 -1
  29. package/lib/esm/__/undici/lib/core/request.js +68 -2
  30. package/lib/esm/__/undici/lib/core/request.js.map +1 -1
  31. package/lib/esm/__/undici/lib/dispatcher/agent.js +6 -2
  32. package/lib/esm/__/undici/lib/dispatcher/agent.js.map +1 -1
  33. package/lib/esm/__/undici/lib/dispatcher/client-h1.js +18 -9
  34. package/lib/esm/__/undici/lib/dispatcher/client-h1.js.map +1 -1
  35. package/lib/esm/__/undici/lib/dispatcher/client-h2.js +72 -23
  36. package/lib/esm/__/undici/lib/dispatcher/client-h2.js.map +1 -1
  37. package/lib/esm/__/undici/lib/dispatcher/client.js +3 -2
  38. package/lib/esm/__/undici/lib/dispatcher/client.js.map +1 -1
  39. package/lib/esm/__/undici/lib/dispatcher/dispatcher-base.js +10 -0
  40. package/lib/esm/__/undici/lib/dispatcher/dispatcher-base.js.map +1 -1
  41. package/lib/esm/__/undici/lib/handler/retry-handler.js +4 -1
  42. package/lib/esm/__/undici/lib/handler/retry-handler.js.map +1 -1
  43. package/lib/esm/__/undici/lib/web/eventsource/eventsource-stream.js +92 -10
  44. package/lib/esm/__/undici/lib/web/eventsource/eventsource-stream.js.map +1 -1
  45. package/lib/esm/__/undici/lib/web/eventsource/eventsource.js +5 -1
  46. package/lib/esm/__/undici/lib/web/eventsource/eventsource.js.map +1 -1
  47. package/lib/esm/__/undici/lib/web/fetch/index.js +7 -9
  48. package/lib/esm/__/undici/lib/web/fetch/index.js.map +1 -1
  49. package/lib/esm/__/undici/lib/web/websocket/receiver.js +14 -0
  50. package/lib/esm/__/undici/lib/web/websocket/receiver.js.map +1 -1
  51. package/lib/esm/env/load.js +1 -1
  52. package/lib/esm/env/load.js.map +1 -1
  53. package/lib/esm/index.js +2 -2
  54. package/package.json +10 -10
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var require$$0$1 = require('node:buffer');
3
4
  var require$$0 = require('node:stream');
4
5
  var util = require('./util.js');
5
6
 
6
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
8
 
9
+ var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
8
10
  var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
9
11
 
10
12
  var eventsourceStream;
@@ -13,6 +15,7 @@ var hasRequiredEventsourceStream;
13
15
  function requireEventsourceStream () {
14
16
  if (hasRequiredEventsourceStream) return eventsourceStream;
15
17
  hasRequiredEventsourceStream = 1;
18
+ const buffer = require$$0__default$1.default;
16
19
  const { Transform } = require$$0__default.default;
17
20
  const { isASCIINumber, isValidLastEventId } = util.__require();
18
21
 
@@ -37,11 +40,19 @@ function requireEventsourceStream () {
37
40
  */
38
41
  const SPACE = 0x20;
39
42
 
43
+ const defaultMaxEventSize = buffer.kStringMaxLength;
44
+
40
45
  const DATA = Buffer.from('data');
41
46
  const EVENT = Buffer.from('event');
42
47
  const ID = Buffer.from('id');
43
48
  const RETRY = Buffer.from('retry');
44
49
 
50
+ // Each data field creates a string node, and each unconsumed input chunk keeps
51
+ // a Buffer wrapper. The absolute ceiling protects the large default byte limit.
52
+ const minParserItems = 1024;
53
+ const maxParserItems = 131072;
54
+ const bytesPerParserItem = 128;
55
+
45
56
  function isASCIINumberBytes (buffer, start) {
46
57
  if (start >= buffer.length) {
47
58
  return false
@@ -80,6 +91,12 @@ function requireEventsourceStream () {
80
91
  return true
81
92
  }
82
93
 
94
+ function createMaxEventSizeExceededError () {
95
+ const error = new Error('EventSource message size exceeded');
96
+ error.aborted = false;
97
+ return error
98
+ }
99
+
83
100
  /**
84
101
  * @typedef {object} EventSourceStreamEvent
85
102
  * @type {object}
@@ -128,6 +145,13 @@ function requireEventsourceStream () {
128
145
  pos = 0
129
146
  lineChunkIndex = 0
130
147
  linePos = 0
148
+ lineLength = 0
149
+ eventSize = 0
150
+ eventFieldSizes = { data: 0, event: 0, id: 0, retry: 0 }
151
+ dataLineCount = 0
152
+ maxEventSize
153
+ maxDataLines
154
+ maxBufferedChunks
131
155
 
132
156
  event = {
133
157
  data: undefined,
@@ -138,6 +162,7 @@ function requireEventsourceStream () {
138
162
 
139
163
  /**
140
164
  * @param {object} options
165
+ * @param {number} [options.maxEventSize]
141
166
  * @param {eventSourceSettings} options.eventSourceSettings
142
167
  * @param {Function} [options.push]
143
168
  */
@@ -149,6 +174,12 @@ function requireEventsourceStream () {
149
174
  super(options);
150
175
 
151
176
  this.state = options.eventSourceSettings || {};
177
+ this.maxEventSize = options.maxEventSize ?? defaultMaxEventSize;
178
+ const parserItemLimit = this.maxEventSize > 0
179
+ ? Math.min(maxParserItems, Math.max(minParserItems, Math.floor(this.maxEventSize / bytesPerParserItem)))
180
+ : 0;
181
+ this.maxDataLines = parserItemLimit;
182
+ this.maxBufferedChunks = parserItemLimit;
152
183
  if (options.push) {
153
184
  this.push = options.push;
154
185
  }
@@ -166,6 +197,14 @@ function requireEventsourceStream () {
166
197
  return
167
198
  }
168
199
 
200
+ // A leading line ending can immediately release the currently buffered
201
+ // line, even when it uses the final allowed chunk slot.
202
+ if (this.maxEventSize > 0 &&
203
+ this.chunks.length >= this.maxBufferedChunks &&
204
+ chunk[0] !== LF && chunk[0] !== CR) {
205
+ callback(createMaxEventSizeExceededError());
206
+ return
207
+ }
169
208
  this.chunks.push(chunk);
170
209
 
171
210
  // Strip leading byte-order-mark if we opened the stream and started
@@ -244,7 +283,12 @@ function requireEventsourceStream () {
244
283
 
245
284
  // In any case, we can process the line as we reached an
246
285
  // end-of-line character
247
- this.parseLine(this.readLine(), this.event);
286
+ try {
287
+ this.parseLine(this.readLine(), this.event);
288
+ } catch (error) {
289
+ callback(error);
290
+ return
291
+ }
248
292
  this.consumeCurrentByte();
249
293
  // A line was processed and this could be the end of the event. We need
250
294
  // to check if the next line is empty to determine if the event is
@@ -253,15 +297,28 @@ function requireEventsourceStream () {
253
297
  continue
254
298
  }
255
299
 
300
+ // readLine() is only called after CR or LF. Reject an unfinished line
301
+ // before it can retain an unbounded number of decoded chunks. The seven
302
+ // extra bytes allow the longest field prefix ("event: " or "retry: ").
303
+ if (this.maxEventSize > 0 && ++this.lineLength > this.maxEventSize + 7) {
304
+ callback(createMaxEventSizeExceededError());
305
+ return
306
+ }
256
307
  this.advanceCursor();
257
308
  }
258
309
 
259
310
  callback();
260
311
  }
261
312
 
313
+ _destroy (error, callback) {
314
+ this.chunks.length = 0;
315
+ this.clearEvent();
316
+ super._destroy(error, callback);
317
+ }
318
+
262
319
  /**
263
320
  * @param {Buffer} line
264
- * @param {EventStreamEvent} event
321
+ * @param {EventSourceStreamEvent} event
265
322
  */
266
323
  parseLine (line, event) {
267
324
  // If the line is empty (a blank line)
@@ -295,6 +352,13 @@ function requireEventsourceStream () {
295
352
  }
296
353
 
297
354
  if (isFieldName(line, fieldLength, DATA)) {
355
+ if (this.maxEventSize > 0 && this.dataLineCount >= this.maxDataLines) {
356
+ throw createMaxEventSizeExceededError()
357
+ }
358
+ const valueBytes = line.length - valueStart;
359
+ const dataSize = this.eventFieldSizes.data + (event.data === undefined ? 0 : 1) + valueBytes;
360
+ this.setEventFieldSize('data', dataSize);
361
+
298
362
  const value = line.toString('utf8', valueStart);
299
363
 
300
364
  if (event.data === undefined) {
@@ -302,11 +366,13 @@ function requireEventsourceStream () {
302
366
  } else {
303
367
  event.data += `\n${value}`;
304
368
  }
369
+ this.dataLineCount++;
305
370
  return
306
371
  }
307
372
 
308
373
  if (isFieldName(line, fieldLength, RETRY)) {
309
374
  if (isASCIINumberBytes(line, valueStart)) {
375
+ this.setEventFieldSize('retry', line.length - valueStart);
310
376
  event.retry = line.toString('utf8', valueStart);
311
377
  }
312
378
  return
@@ -314,20 +380,29 @@ function requireEventsourceStream () {
314
380
 
315
381
  if (isFieldName(line, fieldLength, ID)) {
316
382
  if (isValidLastEventIdBytes(line, valueStart)) {
383
+ this.setEventFieldSize('id', line.length - valueStart);
317
384
  event.id = line.toString('utf8', valueStart);
318
385
  }
319
386
  return
320
387
  }
321
388
 
322
389
  if (isFieldName(line, fieldLength, EVENT)) {
323
- const value = line.toString('utf8', valueStart);
324
-
325
- if (value.length > 0) {
326
- event.event = value;
390
+ if (valueStart < line.length) {
391
+ this.setEventFieldSize('event', line.length - valueStart);
392
+ event.event = line.toString('utf8', valueStart);
327
393
  }
328
394
  }
329
395
  }
330
396
 
397
+ setEventFieldSize (field, size) {
398
+ const eventSize = this.eventSize - this.eventFieldSizes[field] + size;
399
+ if (this.maxEventSize > 0 && eventSize > this.maxEventSize) {
400
+ throw createMaxEventSizeExceededError()
401
+ }
402
+ this.eventSize = eventSize;
403
+ this.eventFieldSizes[field] = size;
404
+ }
405
+
331
406
  /**
332
407
  * @param {EventSourceStreamEvent} event
333
408
  */
@@ -358,6 +433,12 @@ function requireEventsourceStream () {
358
433
  this.event.event = undefined;
359
434
  this.event.id = undefined;
360
435
  this.event.retry = undefined;
436
+ this.eventSize = 0;
437
+ this.dataLineCount = 0;
438
+ this.eventFieldSizes.data = 0;
439
+ this.eventFieldSizes.event = 0;
440
+ this.eventFieldSizes.id = 0;
441
+ this.eventFieldSizes.retry = 0;
361
442
  }
362
443
 
363
444
  hasPendingEvent () {
@@ -393,14 +474,16 @@ function requireEventsourceStream () {
393
474
  syncLineStartToCursor () {
394
475
  this.lineChunkIndex = this.chunkIndex;
395
476
  this.linePos = this.pos;
477
+ this.lineLength = 0;
396
478
  this.dropConsumedChunks();
397
479
  }
398
480
 
399
481
  dropConsumedChunks () {
400
- while (this.lineChunkIndex > 0) {
401
- this.chunks.shift();
402
- this.lineChunkIndex--;
403
- this.chunkIndex--;
482
+ if (this.lineChunkIndex > 0) {
483
+ const consumed = this.lineChunkIndex;
484
+ this.chunks.splice(0, consumed);
485
+ this.lineChunkIndex = 0;
486
+ this.chunkIndex -= consumed;
404
487
  }
405
488
 
406
489
  if (this.chunkIndex === this.chunks.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"eventsource-stream.js","sources":["../../../../../../../../../node_modules/undici/lib/web/eventsource/eventsource-stream.js"],"sourcesContent":["'use strict'\nconst { Transform } = require('node:stream')\nconst { isASCIINumber, isValidLastEventId } = require('./util')\n\n/**\n * @type {number[]} BOM\n */\nconst BOM = [0xEF, 0xBB, 0xBF]\n/**\n * @type {10} LF\n */\nconst LF = 0x0A\n/**\n * @type {13} CR\n */\nconst CR = 0x0D\n/**\n * @type {58} COLON\n */\nconst COLON = 0x3A\n/**\n * @type {32} SPACE\n */\nconst SPACE = 0x20\n\nconst DATA = Buffer.from('data')\nconst EVENT = Buffer.from('event')\nconst ID = Buffer.from('id')\nconst RETRY = Buffer.from('retry')\n\nfunction isASCIINumberBytes (buffer, start) {\n if (start >= buffer.length) {\n return false\n }\n\n for (let i = start; i < buffer.length; i++) {\n if (buffer[i] < 0x30 || buffer[i] > 0x39) {\n return false\n }\n }\n\n return true\n}\n\nfunction isValidLastEventIdBytes (buffer, start) {\n for (let i = start; i < buffer.length; i++) {\n if (buffer[i] === 0x00) {\n return false\n }\n }\n\n return true\n}\n\nfunction isFieldName (line, length, field) {\n if (length !== field.length) {\n return false\n }\n\n for (let i = 0; i < length; i++) {\n if (line[i] !== field[i]) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * @typedef {object} EventSourceStreamEvent\n * @type {object}\n * @property {string} [event] The event type.\n * @property {string} [data] The data of the message.\n * @property {string} [id] A unique ID for the event.\n * @property {string} [retry] The reconnection time, in milliseconds.\n */\n\n/**\n * @typedef eventSourceSettings\n * @type {object}\n * @property {string} lastEventId The last event ID received from the server.\n * @property {string} origin The origin of the event source.\n * @property {number} reconnectionTime The reconnection time, in milliseconds.\n */\n\nclass EventSourceStream extends Transform {\n /**\n * @type {eventSourceSettings}\n */\n state = null\n\n /**\n * Leading byte-order-mark check.\n * @type {boolean}\n */\n checkBOM = true\n\n /**\n * @type {boolean}\n */\n crlfCheck = false\n\n /**\n * @type {boolean}\n */\n eventEndCheck = false\n\n /**\n * @type {Buffer[]}\n */\n chunks = []\n\n chunkIndex = 0\n pos = 0\n lineChunkIndex = 0\n linePos = 0\n\n event = {\n data: undefined,\n event: undefined,\n id: undefined,\n retry: undefined\n }\n\n /**\n * @param {object} options\n * @param {eventSourceSettings} options.eventSourceSettings\n * @param {Function} [options.push]\n */\n constructor (options = {}) {\n // Enable object mode as EventSourceStream emits objects of shape\n // EventSourceStreamEvent\n options.readableObjectMode = true\n\n super(options)\n\n this.state = options.eventSourceSettings || {}\n if (options.push) {\n this.push = options.push\n }\n }\n\n /**\n * @param {Buffer} chunk\n * @param {string} _encoding\n * @param {Function} callback\n * @returns {void}\n */\n _transform (chunk, _encoding, callback) {\n if (chunk.length === 0) {\n callback()\n return\n }\n\n this.chunks.push(chunk)\n\n // Strip leading byte-order-mark if we opened the stream and started\n // the processing of the incoming data\n if (this.checkBOM) {\n if (this.handleBOM()) {\n callback()\n return\n }\n }\n\n while (this.hasCurrentByte()) {\n const byte = this.currentByte()\n\n // If the previous line ended with an end-of-line, we need to check\n // if the next character is also an end-of-line.\n if (this.eventEndCheck) {\n // If the the current character is an end-of-line, then the event\n // is finished and we can process it\n\n // If the previous line ended with a carriage return, we need to\n // check if the current character is a line feed and remove it\n // from the buffer.\n if (this.crlfCheck) {\n // If the current character is a line feed, we can remove it\n // from the buffer and reset the crlfCheck flag\n if (byte === LF) {\n this.crlfCheck = false\n this.consumeCurrentByte()\n\n // It is possible that the line feed is not the end of the\n // event. We need to check if the next character is an\n // end-of-line character to determine if the event is\n // finished. We simply continue the loop to check the next\n // character.\n\n // As we removed the line feed from the buffer and set the\n // crlfCheck flag to false, we basically don't make any\n // distinction between a line feed and a carriage return.\n continue\n }\n this.crlfCheck = false\n }\n\n if (byte === LF || byte === CR) {\n // If the current character is a carriage return, we need to\n // set the crlfCheck flag to true, as we need to check if the\n // next character is a line feed so we can remove it from the\n // buffer\n if (byte === CR) {\n this.crlfCheck = true\n }\n\n this.consumeCurrentByte()\n if (this.hasPendingEvent()) {\n this.processEvent(this.event)\n }\n this.clearEvent()\n continue\n }\n // If the current character is not an end-of-line, then the event\n // is not finished and we have to reset the eventEndCheck flag\n this.eventEndCheck = false\n continue\n }\n\n // If the current character is an end-of-line, we can process the\n // line\n if (byte === LF || byte === CR) {\n // If the current character is a carriage return, we need to\n // set the crlfCheck flag to true, as we need to check if the\n // next character is a line feed\n if (byte === CR) {\n this.crlfCheck = true\n }\n\n // In any case, we can process the line as we reached an\n // end-of-line character\n this.parseLine(this.readLine(), this.event)\n this.consumeCurrentByte()\n // A line was processed and this could be the end of the event. We need\n // to check if the next line is empty to determine if the event is\n // finished.\n this.eventEndCheck = true\n continue\n }\n\n this.advanceCursor()\n }\n\n callback()\n }\n\n /**\n * @param {Buffer} line\n * @param {EventStreamEvent} event\n */\n parseLine (line, event) {\n // If the line is empty (a blank line)\n // Dispatch the event, as defined below.\n // This will be handled in the _transform method\n if (line.length === 0) {\n return\n }\n\n // If the line starts with a U+003A COLON character (:)\n // Ignore the line.\n const colonPosition = line.indexOf(COLON)\n if (colonPosition === 0) {\n return\n }\n\n let fieldLength = line.length\n let valueStart = line.length\n\n // If the line contains a U+003A COLON character (:)\n if (colonPosition !== -1) {\n fieldLength = colonPosition\n\n // Collect the characters on the line after the first U+003A COLON\n // character (:), and let value be that string.\n // If value starts with a U+0020 SPACE character, remove it from value.\n valueStart = colonPosition + 1\n if (line[valueStart] === SPACE) {\n ++valueStart\n }\n }\n\n if (isFieldName(line, fieldLength, DATA)) {\n const value = line.toString('utf8', valueStart)\n\n if (event.data === undefined) {\n event.data = value\n } else {\n event.data += `\\n${value}`\n }\n return\n }\n\n if (isFieldName(line, fieldLength, RETRY)) {\n if (isASCIINumberBytes(line, valueStart)) {\n event.retry = line.toString('utf8', valueStart)\n }\n return\n }\n\n if (isFieldName(line, fieldLength, ID)) {\n if (isValidLastEventIdBytes(line, valueStart)) {\n event.id = line.toString('utf8', valueStart)\n }\n return\n }\n\n if (isFieldName(line, fieldLength, EVENT)) {\n const value = line.toString('utf8', valueStart)\n\n if (value.length > 0) {\n event.event = value\n }\n }\n }\n\n /**\n * @param {EventSourceStreamEvent} event\n */\n processEvent (event) {\n if (event.retry && isASCIINumber(event.retry)) {\n this.state.reconnectionTime = parseInt(event.retry, 10)\n }\n\n if (event.id && isValidLastEventId(event.id)) {\n this.state.lastEventId = event.id\n }\n\n // only dispatch event, when data is provided\n if (event.data !== undefined) {\n this.push({\n type: event.event || 'message',\n options: {\n data: event.data,\n lastEventId: this.state.lastEventId,\n origin: this.state.origin\n }\n })\n }\n }\n\n clearEvent () {\n this.event.data = undefined\n this.event.event = undefined\n this.event.id = undefined\n this.event.retry = undefined\n }\n\n hasPendingEvent () {\n return this.event.data !== undefined ||\n this.event.event !== undefined ||\n this.event.id !== undefined ||\n this.event.retry !== undefined\n }\n\n hasCurrentByte () {\n return this.chunkIndex < this.chunks.length &&\n this.pos < this.chunks[this.chunkIndex].length\n }\n\n currentByte () {\n return this.chunks[this.chunkIndex][this.pos]\n }\n\n consumeCurrentByte () {\n this.advanceCursor()\n this.syncLineStartToCursor()\n }\n\n advanceCursor () {\n this.pos++\n\n while (this.chunkIndex < this.chunks.length && this.pos >= this.chunks[this.chunkIndex].length) {\n this.chunkIndex++\n this.pos = 0\n }\n }\n\n syncLineStartToCursor () {\n this.lineChunkIndex = this.chunkIndex\n this.linePos = this.pos\n this.dropConsumedChunks()\n }\n\n dropConsumedChunks () {\n while (this.lineChunkIndex > 0) {\n this.chunks.shift()\n this.lineChunkIndex--\n this.chunkIndex--\n }\n\n if (this.chunkIndex === this.chunks.length) {\n this.chunks.length = 0\n this.chunkIndex = 0\n this.pos = 0\n this.lineChunkIndex = 0\n this.linePos = 0\n }\n }\n\n readLine () {\n if (this.lineChunkIndex === this.chunkIndex) {\n return this.chunks[this.chunkIndex].subarray(this.linePos, this.pos)\n }\n\n const chunks = []\n let length = 0\n\n for (let i = this.lineChunkIndex; i <= this.chunkIndex; i++) {\n const chunk = this.chunks[i]\n const start = i === this.lineChunkIndex ? this.linePos : 0\n const end = i === this.chunkIndex ? this.pos : chunk.length\n const slice = chunk.subarray(start, end)\n length += slice.length\n chunks.push(slice)\n }\n\n return Buffer.concat(chunks, length)\n }\n\n peekBufferedByte (offset) {\n let chunkIndex = this.lineChunkIndex\n let pos = this.linePos\n\n while (chunkIndex < this.chunks.length) {\n const chunk = this.chunks[chunkIndex]\n const remaining = chunk.length - pos\n\n if (offset < remaining) {\n return chunk[pos + offset]\n }\n\n offset -= remaining\n chunkIndex++\n pos = 0\n }\n }\n\n discardLeadingBytes (count) {\n while (count > 0 && this.lineChunkIndex < this.chunks.length) {\n const chunk = this.chunks[this.lineChunkIndex]\n const remaining = chunk.length - this.linePos\n\n if (count < remaining) {\n this.linePos += count\n count = 0\n } else {\n count -= remaining\n this.lineChunkIndex++\n this.linePos = 0\n }\n }\n\n this.chunkIndex = this.lineChunkIndex\n this.pos = this.linePos\n this.dropConsumedChunks()\n }\n\n handleBOM () {\n const first = this.peekBufferedByte(0)\n const second = this.peekBufferedByte(1)\n const third = this.peekBufferedByte(2)\n\n if (second === undefined) {\n if (first === BOM[0]) {\n return true\n }\n\n this.checkBOM = false\n return true\n }\n\n if (third === undefined) {\n if (first === BOM[0] && second === BOM[1]) {\n return true\n }\n\n this.checkBOM = false\n return false\n }\n\n if (first === BOM[0] && second === BOM[1] && third === BOM[2]) {\n this.discardLeadingBytes(3)\n }\n\n this.checkBOM = false\n return !this.hasCurrentByte()\n }\n}\n\nmodule.exports = {\n EventSourceStream\n}\n"],"names":["require$$0","require$$1"],"mappings":";;;;;;;;;;;;;;;CACA,MAAM,EAAE,SAAS,EAAE,GAAGA;AACtB,CAAA,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAGC,cAAA;;AAE9C;AACA;AACA;AACA,CAAA,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI;AAC7B;AACA;AACA;AACA,CAAA,MAAM,EAAE,GAAG;AACX;AACA;AACA;AACA,CAAA,MAAM,EA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,IAAI,CAAC,cAAc;AAC/B,GAAA;AACA;;AAEA,CAAA,iBAAc,GAAG;GACf;AACF;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"eventsource-stream.js","sources":["../../../../../../../../../node_modules/undici/lib/web/eventsource/eventsource-stream.js"],"sourcesContent":["'use strict'\nconst buffer = require('node:buffer')\nconst { Transform } = require('node:stream')\nconst { isASCIINumber, isValidLastEventId } = require('./util')\n\n/**\n * @type {number[]} BOM\n */\nconst BOM = [0xEF, 0xBB, 0xBF]\n/**\n * @type {10} LF\n */\nconst LF = 0x0A\n/**\n * @type {13} CR\n */\nconst CR = 0x0D\n/**\n * @type {58} COLON\n */\nconst COLON = 0x3A\n/**\n * @type {32} SPACE\n */\nconst SPACE = 0x20\n\nconst defaultMaxEventSize = buffer.kStringMaxLength\n\nconst DATA = Buffer.from('data')\nconst EVENT = Buffer.from('event')\nconst ID = Buffer.from('id')\nconst RETRY = Buffer.from('retry')\n\n// Each data field creates a string node, and each unconsumed input chunk keeps\n// a Buffer wrapper. The absolute ceiling protects the large default byte limit.\nconst minParserItems = 1024\nconst maxParserItems = 131072\nconst bytesPerParserItem = 128\n\nfunction isASCIINumberBytes (buffer, start) {\n if (start >= buffer.length) {\n return false\n }\n\n for (let i = start; i < buffer.length; i++) {\n if (buffer[i] < 0x30 || buffer[i] > 0x39) {\n return false\n }\n }\n\n return true\n}\n\nfunction isValidLastEventIdBytes (buffer, start) {\n for (let i = start; i < buffer.length; i++) {\n if (buffer[i] === 0x00) {\n return false\n }\n }\n\n return true\n}\n\nfunction isFieldName (line, length, field) {\n if (length !== field.length) {\n return false\n }\n\n for (let i = 0; i < length; i++) {\n if (line[i] !== field[i]) {\n return false\n }\n }\n\n return true\n}\n\nfunction createMaxEventSizeExceededError () {\n const error = new Error('EventSource message size exceeded')\n error.aborted = false\n return error\n}\n\n/**\n * @typedef {object} EventSourceStreamEvent\n * @type {object}\n * @property {string} [event] The event type.\n * @property {string} [data] The data of the message.\n * @property {string} [id] A unique ID for the event.\n * @property {string} [retry] The reconnection time, in milliseconds.\n */\n\n/**\n * @typedef eventSourceSettings\n * @type {object}\n * @property {string} lastEventId The last event ID received from the server.\n * @property {string} origin The origin of the event source.\n * @property {number} reconnectionTime The reconnection time, in milliseconds.\n */\n\nclass EventSourceStream extends Transform {\n /**\n * @type {eventSourceSettings}\n */\n state = null\n\n /**\n * Leading byte-order-mark check.\n * @type {boolean}\n */\n checkBOM = true\n\n /**\n * @type {boolean}\n */\n crlfCheck = false\n\n /**\n * @type {boolean}\n */\n eventEndCheck = false\n\n /**\n * @type {Buffer[]}\n */\n chunks = []\n\n chunkIndex = 0\n pos = 0\n lineChunkIndex = 0\n linePos = 0\n lineLength = 0\n eventSize = 0\n eventFieldSizes = { data: 0, event: 0, id: 0, retry: 0 }\n dataLineCount = 0\n maxEventSize\n maxDataLines\n maxBufferedChunks\n\n event = {\n data: undefined,\n event: undefined,\n id: undefined,\n retry: undefined\n }\n\n /**\n * @param {object} options\n * @param {number} [options.maxEventSize]\n * @param {eventSourceSettings} options.eventSourceSettings\n * @param {Function} [options.push]\n */\n constructor (options = {}) {\n // Enable object mode as EventSourceStream emits objects of shape\n // EventSourceStreamEvent\n options.readableObjectMode = true\n\n super(options)\n\n this.state = options.eventSourceSettings || {}\n this.maxEventSize = options.maxEventSize ?? defaultMaxEventSize\n const parserItemLimit = this.maxEventSize > 0\n ? Math.min(maxParserItems, Math.max(minParserItems, Math.floor(this.maxEventSize / bytesPerParserItem)))\n : 0\n this.maxDataLines = parserItemLimit\n this.maxBufferedChunks = parserItemLimit\n if (options.push) {\n this.push = options.push\n }\n }\n\n /**\n * @param {Buffer} chunk\n * @param {string} _encoding\n * @param {Function} callback\n * @returns {void}\n */\n _transform (chunk, _encoding, callback) {\n if (chunk.length === 0) {\n callback()\n return\n }\n\n // A leading line ending can immediately release the currently buffered\n // line, even when it uses the final allowed chunk slot.\n if (this.maxEventSize > 0 &&\n this.chunks.length >= this.maxBufferedChunks &&\n chunk[0] !== LF && chunk[0] !== CR) {\n callback(createMaxEventSizeExceededError())\n return\n }\n this.chunks.push(chunk)\n\n // Strip leading byte-order-mark if we opened the stream and started\n // the processing of the incoming data\n if (this.checkBOM) {\n if (this.handleBOM()) {\n callback()\n return\n }\n }\n\n while (this.hasCurrentByte()) {\n const byte = this.currentByte()\n\n // If the previous line ended with an end-of-line, we need to check\n // if the next character is also an end-of-line.\n if (this.eventEndCheck) {\n // If the the current character is an end-of-line, then the event\n // is finished and we can process it\n\n // If the previous line ended with a carriage return, we need to\n // check if the current character is a line feed and remove it\n // from the buffer.\n if (this.crlfCheck) {\n // If the current character is a line feed, we can remove it\n // from the buffer and reset the crlfCheck flag\n if (byte === LF) {\n this.crlfCheck = false\n this.consumeCurrentByte()\n\n // It is possible that the line feed is not the end of the\n // event. We need to check if the next character is an\n // end-of-line character to determine if the event is\n // finished. We simply continue the loop to check the next\n // character.\n\n // As we removed the line feed from the buffer and set the\n // crlfCheck flag to false, we basically don't make any\n // distinction between a line feed and a carriage return.\n continue\n }\n this.crlfCheck = false\n }\n\n if (byte === LF || byte === CR) {\n // If the current character is a carriage return, we need to\n // set the crlfCheck flag to true, as we need to check if the\n // next character is a line feed so we can remove it from the\n // buffer\n if (byte === CR) {\n this.crlfCheck = true\n }\n\n this.consumeCurrentByte()\n if (this.hasPendingEvent()) {\n this.processEvent(this.event)\n }\n this.clearEvent()\n continue\n }\n // If the current character is not an end-of-line, then the event\n // is not finished and we have to reset the eventEndCheck flag\n this.eventEndCheck = false\n continue\n }\n\n // If the current character is an end-of-line, we can process the\n // line\n if (byte === LF || byte === CR) {\n // If the current character is a carriage return, we need to\n // set the crlfCheck flag to true, as we need to check if the\n // next character is a line feed\n if (byte === CR) {\n this.crlfCheck = true\n }\n\n // In any case, we can process the line as we reached an\n // end-of-line character\n try {\n this.parseLine(this.readLine(), this.event)\n } catch (error) {\n callback(error)\n return\n }\n this.consumeCurrentByte()\n // A line was processed and this could be the end of the event. We need\n // to check if the next line is empty to determine if the event is\n // finished.\n this.eventEndCheck = true\n continue\n }\n\n // readLine() is only called after CR or LF. Reject an unfinished line\n // before it can retain an unbounded number of decoded chunks. The seven\n // extra bytes allow the longest field prefix (\"event: \" or \"retry: \").\n if (this.maxEventSize > 0 && ++this.lineLength > this.maxEventSize + 7) {\n callback(createMaxEventSizeExceededError())\n return\n }\n this.advanceCursor()\n }\n\n callback()\n }\n\n _destroy (error, callback) {\n this.chunks.length = 0\n this.clearEvent()\n super._destroy(error, callback)\n }\n\n /**\n * @param {Buffer} line\n * @param {EventSourceStreamEvent} event\n */\n parseLine (line, event) {\n // If the line is empty (a blank line)\n // Dispatch the event, as defined below.\n // This will be handled in the _transform method\n if (line.length === 0) {\n return\n }\n\n // If the line starts with a U+003A COLON character (:)\n // Ignore the line.\n const colonPosition = line.indexOf(COLON)\n if (colonPosition === 0) {\n return\n }\n\n let fieldLength = line.length\n let valueStart = line.length\n\n // If the line contains a U+003A COLON character (:)\n if (colonPosition !== -1) {\n fieldLength = colonPosition\n\n // Collect the characters on the line after the first U+003A COLON\n // character (:), and let value be that string.\n // If value starts with a U+0020 SPACE character, remove it from value.\n valueStart = colonPosition + 1\n if (line[valueStart] === SPACE) {\n ++valueStart\n }\n }\n\n if (isFieldName(line, fieldLength, DATA)) {\n if (this.maxEventSize > 0 && this.dataLineCount >= this.maxDataLines) {\n throw createMaxEventSizeExceededError()\n }\n const valueBytes = line.length - valueStart\n const dataSize = this.eventFieldSizes.data + (event.data === undefined ? 0 : 1) + valueBytes\n this.setEventFieldSize('data', dataSize)\n\n const value = line.toString('utf8', valueStart)\n\n if (event.data === undefined) {\n event.data = value\n } else {\n event.data += `\\n${value}`\n }\n this.dataLineCount++\n return\n }\n\n if (isFieldName(line, fieldLength, RETRY)) {\n if (isASCIINumberBytes(line, valueStart)) {\n this.setEventFieldSize('retry', line.length - valueStart)\n event.retry = line.toString('utf8', valueStart)\n }\n return\n }\n\n if (isFieldName(line, fieldLength, ID)) {\n if (isValidLastEventIdBytes(line, valueStart)) {\n this.setEventFieldSize('id', line.length - valueStart)\n event.id = line.toString('utf8', valueStart)\n }\n return\n }\n\n if (isFieldName(line, fieldLength, EVENT)) {\n if (valueStart < line.length) {\n this.setEventFieldSize('event', line.length - valueStart)\n event.event = line.toString('utf8', valueStart)\n }\n }\n }\n\n setEventFieldSize (field, size) {\n const eventSize = this.eventSize - this.eventFieldSizes[field] + size\n if (this.maxEventSize > 0 && eventSize > this.maxEventSize) {\n throw createMaxEventSizeExceededError()\n }\n this.eventSize = eventSize\n this.eventFieldSizes[field] = size\n }\n\n /**\n * @param {EventSourceStreamEvent} event\n */\n processEvent (event) {\n if (event.retry && isASCIINumber(event.retry)) {\n this.state.reconnectionTime = parseInt(event.retry, 10)\n }\n\n if (event.id && isValidLastEventId(event.id)) {\n this.state.lastEventId = event.id\n }\n\n // only dispatch event, when data is provided\n if (event.data !== undefined) {\n this.push({\n type: event.event || 'message',\n options: {\n data: event.data,\n lastEventId: this.state.lastEventId,\n origin: this.state.origin\n }\n })\n }\n }\n\n clearEvent () {\n this.event.data = undefined\n this.event.event = undefined\n this.event.id = undefined\n this.event.retry = undefined\n this.eventSize = 0\n this.dataLineCount = 0\n this.eventFieldSizes.data = 0\n this.eventFieldSizes.event = 0\n this.eventFieldSizes.id = 0\n this.eventFieldSizes.retry = 0\n }\n\n hasPendingEvent () {\n return this.event.data !== undefined ||\n this.event.event !== undefined ||\n this.event.id !== undefined ||\n this.event.retry !== undefined\n }\n\n hasCurrentByte () {\n return this.chunkIndex < this.chunks.length &&\n this.pos < this.chunks[this.chunkIndex].length\n }\n\n currentByte () {\n return this.chunks[this.chunkIndex][this.pos]\n }\n\n consumeCurrentByte () {\n this.advanceCursor()\n this.syncLineStartToCursor()\n }\n\n advanceCursor () {\n this.pos++\n\n while (this.chunkIndex < this.chunks.length && this.pos >= this.chunks[this.chunkIndex].length) {\n this.chunkIndex++\n this.pos = 0\n }\n }\n\n syncLineStartToCursor () {\n this.lineChunkIndex = this.chunkIndex\n this.linePos = this.pos\n this.lineLength = 0\n this.dropConsumedChunks()\n }\n\n dropConsumedChunks () {\n if (this.lineChunkIndex > 0) {\n const consumed = this.lineChunkIndex\n this.chunks.splice(0, consumed)\n this.lineChunkIndex = 0\n this.chunkIndex -= consumed\n }\n\n if (this.chunkIndex === this.chunks.length) {\n this.chunks.length = 0\n this.chunkIndex = 0\n this.pos = 0\n this.lineChunkIndex = 0\n this.linePos = 0\n }\n }\n\n readLine () {\n if (this.lineChunkIndex === this.chunkIndex) {\n return this.chunks[this.chunkIndex].subarray(this.linePos, this.pos)\n }\n\n const chunks = []\n let length = 0\n\n for (let i = this.lineChunkIndex; i <= this.chunkIndex; i++) {\n const chunk = this.chunks[i]\n const start = i === this.lineChunkIndex ? this.linePos : 0\n const end = i === this.chunkIndex ? this.pos : chunk.length\n const slice = chunk.subarray(start, end)\n length += slice.length\n chunks.push(slice)\n }\n\n return Buffer.concat(chunks, length)\n }\n\n peekBufferedByte (offset) {\n let chunkIndex = this.lineChunkIndex\n let pos = this.linePos\n\n while (chunkIndex < this.chunks.length) {\n const chunk = this.chunks[chunkIndex]\n const remaining = chunk.length - pos\n\n if (offset < remaining) {\n return chunk[pos + offset]\n }\n\n offset -= remaining\n chunkIndex++\n pos = 0\n }\n }\n\n discardLeadingBytes (count) {\n while (count > 0 && this.lineChunkIndex < this.chunks.length) {\n const chunk = this.chunks[this.lineChunkIndex]\n const remaining = chunk.length - this.linePos\n\n if (count < remaining) {\n this.linePos += count\n count = 0\n } else {\n count -= remaining\n this.lineChunkIndex++\n this.linePos = 0\n }\n }\n\n this.chunkIndex = this.lineChunkIndex\n this.pos = this.linePos\n this.dropConsumedChunks()\n }\n\n handleBOM () {\n const first = this.peekBufferedByte(0)\n const second = this.peekBufferedByte(1)\n const third = this.peekBufferedByte(2)\n\n if (second === undefined) {\n if (first === BOM[0]) {\n return true\n }\n\n this.checkBOM = false\n return true\n }\n\n if (third === undefined) {\n if (first === BOM[0] && second === BOM[1]) {\n return true\n }\n\n this.checkBOM = false\n return false\n }\n\n if (first === BOM[0] && second === BOM[1] && third === BOM[2]) {\n this.discardLeadingBytes(3)\n }\n\n this.checkBOM = false\n return !this.hasCurrentByte()\n }\n}\n\nmodule.exports = {\n EventSourceStream\n}\n"],"names":["require$$0","require$$1","require$$2"],"mappings":";;;;;;;;;;;;;;;;;AACA,CAAA,MAAM,MAAM,GAAGA;CACf,MAAM,EAAE,SAAS,EAAE,GAAGC;AACtB,CAAA,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAGC,cAAA;;AAE9C;AACA;AACA;AACA,CAAA,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI;AAC7B;AACA;AACA;AACA,CAAA,MAAM,EAAE,GAAG;AACX;AACA;AACA;AACA,CAAA,MAAM,EAAE,GAAG;AACX;AACA;AACA;AACA,CAAA,MAAM,KAAK,GAAG;AACd;AACA;AACA;AACA,CAAA,MAAM,KAAK,GAAG;;CAEd,MAAM,mBAAmB,GAAG,MAAM,CAAC;;AAEnC,CAAA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM;AAC/B,CAAA,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO;AACjC,CAAA,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI;AAC3B,CAAA,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO;;AAEjC;AACA;AACA,CAAA,MAAM,cAAc,GAAG;AACvB,CAAA,MAAM,cAAc,GAAG;AACvB,CAAA,MAAM,kBAAkB,GAAG;;AAE3B,CAAA,SAAS,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE;AAC5C,GAAE,IAAI,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE;AAC9B,KAAI,OAAO;AACX,GAAA;;AAEA,GAAE,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EA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AI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;KAChB,IAAI,CAAC,kBAAkB;AAC3B,GAAA;;GAEE,SAAS,CAAC,GAAG;AACf,KAAI,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;AACzC,KAAI,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC1C,KAAI,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;;AAEzC,KAAI,IAAI,MAAM,KAAK,SAAS,EAAE;AAC9B,OAAM,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;AAC5B,SAAQ,OAAO;AACf,OAAA;;OAEM,IAAI,CAAC,QAAQ,GAAG;AACtB,OAAM,OAAO;AACb,KAAA;;AAEA,KAAI,IAAI,KAAK,KAAK,SAAS,EAAE;AAC7B,OAAM,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;AACjD,SAAQ,OAAO;AACf,OAAA;;OAEM,IAAI,CAAC,QAAQ,GAAG;AACtB,OAAM,OAAO;AACb,KAAA;;KAEI,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;AACnE,OAAM,IAAI,CAAC,mBAAmB,CAAC,CAAC;AAChC,KAAA;;KAEI,IAAI,CAAC,QAAQ,GAAG;AACpB,KAAI,OAAO,CAAC,IAAI,CAAC,cAAc;AAC/B,GAAA;AACA;;AAEA,CAAA,iBAAc,GAAG;GACf;AACF;;;;","x_google_ignoreList":[0]}
@@ -11,6 +11,7 @@ var response = require('../fetch/response.js');
11
11
  var util = require('./util.js');
12
12
  var util$1 = require('../../core/util.js');
13
13
  var util$2 = require('../fetch/util.js');
14
+ var global = require('../../global.js');
14
15
 
15
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
17
 
@@ -34,6 +35,7 @@ function requireEventsource () {
34
35
  const { delay } = util.__require();
35
36
  const { kEnumerableProperty } = util$1.__require();
36
37
  const { environmentSettingsObject } = util$2.__require();
38
+ const { getGlobalDispatcher } = global.__require();
37
39
 
38
40
  let experimentalWarned = false;
39
41
 
@@ -315,6 +317,7 @@ function requireEventsource () {
315
317
 
316
318
  const eventSourceStream = new EventSourceStream({
317
319
  eventSourceSettings: this.#state,
320
+ maxEventSize: this.#dispatcher.eventSourceOptions?.maxEventSize,
318
321
  push: (event) => {
319
322
  this.dispatchEvent(createFastMessageEvent(
320
323
  event.type,
@@ -493,7 +496,8 @@ function requireEventsource () {
493
496
  },
494
497
  {
495
498
  key: 'dispatcher', // undici only
496
- converter: webidl$1.converters.any
499
+ converter: webidl$1.converters.any,
500
+ defaultValue: () => getGlobalDispatcher()
497
501
  }
498
502
  ]);
499
503
 
@@ -1 +1 @@
1
- {"version":3,"file":"eventsource.js","sources":["../../../../../../../../../node_modules/undici/lib/web/eventsource/eventsource.js"],"sourcesContent":["'use strict'\n\nconst { pipeline } = require('node:stream')\nconst { fetching } = require('../fetch')\nconst { makeRequest } = require('../fetch/request')\nconst { webidl } = require('../fetch/webidl')\nconst { EventSourceStream } = require('./eventsource-stream')\nconst { parseMIMEType } = require('../fetch/data-url')\nconst { createFastMessageEvent } = require('../websocket/events')\nconst { isNetworkError } = require('../fetch/response')\nconst { delay } = require('./util')\nconst { kEnumerableProperty } = require('../../core/util')\nconst { environmentSettingsObject } = require('../fetch/util')\n\nlet experimentalWarned = false\n\n/**\n * A reconnection time, in milliseconds. This must initially be an implementation-defined value,\n * probably in the region of a few seconds.\n *\n * In Comparison:\n * - Chrome uses 3000ms.\n * - Deno uses 5000ms.\n *\n * @type {3000}\n */\nconst defaultReconnectionTime = 3000\n\n/**\n * The readyState attribute represents the state of the connection.\n * @enum\n * @readonly\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsource-readystate-dev\n */\n\n/**\n * The connection has not yet been established, or it was closed and the user\n * agent is reconnecting.\n * @type {0}\n */\nconst CONNECTING = 0\n\n/**\n * The user agent has an open connection and is dispatching events as it\n * receives them.\n * @type {1}\n */\nconst OPEN = 1\n\n/**\n * The connection is not open, and the user agent is not trying to reconnect.\n * @type {2}\n */\nconst CLOSED = 2\n\n/**\n * Requests for the element will have their mode set to \"cors\" and their credentials mode set to \"same-origin\".\n * @type {'anonymous'}\n */\nconst ANONYMOUS = 'anonymous'\n\n/**\n * Requests for the element will have their mode set to \"cors\" and their credentials mode set to \"include\".\n * @type {'use-credentials'}\n */\nconst USE_CREDENTIALS = 'use-credentials'\n\n/**\n * The EventSource interface is used to receive server-sent events. It\n * connects to a server over HTTP and receives events in text/event-stream\n * format without closing the connection.\n * @extends {EventTarget}\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events\n * @api public\n */\nclass EventSource extends EventTarget {\n #events = {\n open: null,\n error: null,\n message: null\n }\n\n #url = null\n #withCredentials = false\n\n #readyState = CONNECTING\n\n #request = null\n #controller = null\n\n #dispatcher\n\n /**\n * @type {import('./eventsource-stream').eventSourceSettings}\n */\n #state\n\n /**\n * Creates a new EventSource object.\n * @param {string} url\n * @param {EventSourceInit} [eventSourceInitDict]\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface\n */\n constructor (url, eventSourceInitDict = {}) {\n // 1. Let ev be a new EventSource object.\n super()\n\n webidl.util.markAsUncloneable(this)\n\n const prefix = 'EventSource constructor'\n webidl.argumentLengthCheck(arguments, 1, prefix)\n\n if (!experimentalWarned) {\n experimentalWarned = true\n process.emitWarning('EventSource is experimental, expect them to change at any time.', {\n code: 'UNDICI-ES'\n })\n }\n\n url = webidl.converters.USVString(url, prefix, 'url')\n eventSourceInitDict = webidl.converters.EventSourceInitDict(eventSourceInitDict, prefix, 'eventSourceInitDict')\n\n this.#dispatcher = eventSourceInitDict.dispatcher\n this.#state = {\n lastEventId: '',\n reconnectionTime: defaultReconnectionTime\n }\n\n // 2. Let settings be ev's relevant settings object.\n // https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object\n const settings = environmentSettingsObject\n\n let urlRecord\n\n try {\n // 3. Let urlRecord be the result of encoding-parsing a URL given url, relative to settings.\n urlRecord = new URL(url, settings.settingsObject.baseUrl)\n this.#state.origin = urlRecord.origin\n } catch (e) {\n // 4. If urlRecord is failure, then throw a \"SyntaxError\" DOMException.\n throw new DOMException(e, 'SyntaxError')\n }\n\n // 5. Set ev's url to urlRecord.\n this.#url = urlRecord.href\n\n // 6. Let corsAttributeState be Anonymous.\n let corsAttributeState = ANONYMOUS\n\n // 7. If the value of eventSourceInitDict's withCredentials member is true,\n // then set corsAttributeState to Use Credentials and set ev's\n // withCredentials attribute to true.\n if (eventSourceInitDict.withCredentials) {\n corsAttributeState = USE_CREDENTIALS\n this.#withCredentials = true\n }\n\n // 8. Let request be the result of creating a potential-CORS request given\n // urlRecord, the empty string, and corsAttributeState.\n const initRequest = {\n redirect: 'follow',\n keepalive: true,\n // @see https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes\n mode: 'cors',\n credentials: corsAttributeState === 'anonymous'\n ? 'same-origin'\n : 'omit',\n referrer: 'no-referrer'\n }\n\n // 9. Set request's client to settings.\n initRequest.client = environmentSettingsObject.settingsObject\n\n // 10. User agents may set (`Accept`, `text/event-stream`) in request's header list.\n initRequest.headersList = [['accept', { name: 'accept', value: 'text/event-stream' }]]\n\n // 11. Set request's cache mode to \"no-store\".\n initRequest.cache = 'no-store'\n\n // 12. Set request's initiator type to \"other\".\n initRequest.initiator = 'other'\n\n initRequest.urlList = [new URL(this.#url)]\n\n // 13. Set ev's request to request.\n this.#request = makeRequest(initRequest)\n\n this.#connect()\n }\n\n /**\n * Returns the state of this EventSource object's connection. It can have the\n * values described below.\n * @returns {0|1|2}\n * @readonly\n */\n get readyState () {\n return this.#readyState\n }\n\n /**\n * Returns the URL providing the event stream.\n * @readonly\n * @returns {string}\n */\n get url () {\n return this.#url\n }\n\n /**\n * Returns a boolean indicating whether the EventSource object was\n * instantiated with CORS credentials set (true), or not (false, the default).\n */\n get withCredentials () {\n return this.#withCredentials\n }\n\n #connect () {\n if (this.#readyState === CLOSED) return\n\n this.#readyState = CONNECTING\n\n const fetchParams = {\n request: this.#request,\n dispatcher: this.#dispatcher\n }\n\n // 14. Let processEventSourceEndOfBody given response res be the following step: if res is not a network error, then reestablish the connection.\n const processEventSourceEndOfBody = (response) => {\n if (isNetworkError(response)) {\n this.dispatchEvent(new Event('error'))\n this.close()\n }\n\n this.#reconnect()\n }\n\n // 15. Fetch request, with processResponseEndOfBody set to processEventSourceEndOfBody...\n fetchParams.processResponseEndOfBody = processEventSourceEndOfBody\n\n // and processResponse set to the following steps given response res:\n fetchParams.processResponse = (response) => {\n // 1. If res is an aborted network error, then fail the connection.\n\n if (isNetworkError(response)) {\n // 1. When a user agent is to fail the connection, the user agent\n // must queue a task which, if the readyState attribute is set to a\n // value other than CLOSED, sets the readyState attribute to CLOSED\n // and fires an event named error at the EventSource object. Once the\n // user agent has failed the connection, it does not attempt to\n // reconnect.\n if (response.aborted) {\n this.close()\n this.dispatchEvent(new Event('error'))\n return\n // 2. Otherwise, if res is a network error, then reestablish the\n // connection, unless the user agent knows that to be futile, in\n // which case the user agent may fail the connection.\n } else {\n this.#reconnect()\n return\n }\n }\n\n // 3. Otherwise, if res's status is not 200, or if res's `Content-Type`\n // is not `text/event-stream`, then fail the connection.\n const contentType = response.headersList.get('content-type', true)\n const mimeType = contentType !== null ? parseMIMEType(contentType) : 'failure'\n const contentTypeValid = mimeType !== 'failure' && mimeType.essence === 'text/event-stream'\n if (\n response.status !== 200 ||\n contentTypeValid === false\n ) {\n this.close()\n this.dispatchEvent(new Event('error'))\n return\n }\n\n // 4. Otherwise, announce the connection and interpret res's body\n // line by line.\n\n // When a user agent is to announce the connection, the user agent\n // must queue a task which, if the readyState attribute is set to a\n // value other than CLOSED, sets the readyState attribute to OPEN\n // and fires an event named open at the EventSource object.\n // @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model\n this.#readyState = OPEN\n this.dispatchEvent(new Event('open'))\n\n // If redirected to a different origin, set the origin to the new origin.\n this.#state.origin = response.urlList[response.urlList.length - 1].origin\n\n const eventSourceStream = new EventSourceStream({\n eventSourceSettings: this.#state,\n push: (event) => {\n this.dispatchEvent(createFastMessageEvent(\n event.type,\n event.options\n ))\n }\n })\n\n pipeline(response.body.stream,\n eventSourceStream,\n (error) => {\n if (\n error?.aborted === false\n ) {\n this.close()\n this.dispatchEvent(new Event('error'))\n }\n })\n }\n\n this.#controller = fetching(fetchParams)\n }\n\n /**\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model\n * @returns {Promise<void>}\n */\n async #reconnect () {\n // When a user agent is to reestablish the connection, the user agent must\n // run the following steps. These steps are run in parallel, not as part of\n // a task. (The tasks that it queues, of course, are run like normal tasks\n // and not themselves in parallel.)\n\n // 1. Queue a task to run the following steps:\n\n // 1. If the readyState attribute is set to CLOSED, abort the task.\n if (this.#readyState === CLOSED) return\n\n // 2. Set the readyState attribute to CONNECTING.\n this.#readyState = CONNECTING\n\n // 3. Fire an event named error at the EventSource object.\n this.dispatchEvent(new Event('error'))\n\n // 2. Wait a delay equal to the reconnection time of the event source.\n await delay(this.#state.reconnectionTime)\n\n // 5. Queue a task to run the following steps:\n\n // 1. If the EventSource object's readyState attribute is not set to\n // CONNECTING, then return.\n if (this.#readyState !== CONNECTING) return\n\n // 2. Let request be the EventSource object's request.\n // 3. If the EventSource object's last event ID string is not the empty\n // string, then:\n // 1. Let lastEventIDValue be the EventSource object's last event ID\n // string, encoded as UTF-8.\n // 2. Set (`Last-Event-ID`, lastEventIDValue) in request's header\n // list.\n if (this.#state.lastEventId.length) {\n this.#request.headersList.set('last-event-id', this.#state.lastEventId, true)\n }\n\n // 4. Fetch request and process the response obtained in this fashion, if any, as described earlier in this section.\n this.#connect()\n }\n\n /**\n * Closes the connection, if any, and sets the readyState attribute to\n * CLOSED.\n */\n close () {\n webidl.brandCheck(this, EventSource)\n\n if (this.#readyState === CLOSED) return\n this.#readyState = CLOSED\n this.#controller.abort()\n this.#request = null\n }\n\n get onopen () {\n return this.#events.open\n }\n\n set onopen (fn) {\n if (this.#events.open) {\n this.removeEventListener('open', this.#events.open)\n }\n\n if (typeof fn === 'function') {\n this.#events.open = fn\n this.addEventListener('open', fn)\n } else {\n this.#events.open = null\n }\n }\n\n get onmessage () {\n return this.#events.message\n }\n\n set onmessage (fn) {\n if (this.#events.message) {\n this.removeEventListener('message', this.#events.message)\n }\n\n if (typeof fn === 'function') {\n this.#events.message = fn\n this.addEventListener('message', fn)\n } else {\n this.#events.message = null\n }\n }\n\n get onerror () {\n return this.#events.error\n }\n\n set onerror (fn) {\n if (this.#events.error) {\n this.removeEventListener('error', this.#events.error)\n }\n\n if (typeof fn === 'function') {\n this.#events.error = fn\n this.addEventListener('error', fn)\n } else {\n this.#events.error = null\n }\n }\n}\n\nconst constantsPropertyDescriptors = {\n CONNECTING: {\n __proto__: null,\n configurable: false,\n enumerable: true,\n value: CONNECTING,\n writable: false\n },\n OPEN: {\n __proto__: null,\n configurable: false,\n enumerable: true,\n value: OPEN,\n writable: false\n },\n CLOSED: {\n __proto__: null,\n configurable: false,\n enumerable: true,\n value: CLOSED,\n writable: false\n }\n}\n\nObject.defineProperties(EventSource, constantsPropertyDescriptors)\nObject.defineProperties(EventSource.prototype, constantsPropertyDescriptors)\n\nObject.defineProperties(EventSource.prototype, {\n close: kEnumerableProperty,\n onerror: kEnumerableProperty,\n onmessage: kEnumerableProperty,\n onopen: kEnumerableProperty,\n readyState: kEnumerableProperty,\n url: kEnumerableProperty,\n withCredentials: kEnumerableProperty\n})\n\nwebidl.converters.EventSourceInitDict = webidl.dictionaryConverter([\n {\n key: 'withCredentials',\n converter: webidl.converters.boolean,\n defaultValue: () => false\n },\n {\n key: 'dispatcher', // undici only\n converter: webidl.converters.any\n }\n])\n\nmodule.exports = {\n EventSource,\n defaultReconnectionTime\n}\n"],"names":["require$$0","require$$1","require$$2","webidl","require$$3","require$$4","require$$5","require$$6","require$$7","require$$8","require$$9","require$$10"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;CAEA,MAAM,EAAE,QAAQ,EAAE,GAAGA;CACrB,MAAM,EAAE,QAAQ,EAAE,GAAGC,eAAA;CACrB,MAAM,EAAE,WAAW,EAAE,GAAGC,iBAAA;CACxB,MAAM,UAAEC,QAAM,EAAE,GAAGC,gBAAA;CACnB,MAAM,EAAE,iBAAiB,EAAE,GAAGC,2BAAA;CAC9B,MAAM,EAAE,aAAa,EAAE,GAAGC,iBAAA;CAC1B,MAAM,EAAE,sBAAsB,EAAE,GAAGC,gBAAA;CACnC,MAAM,EAAE,cAAc,EAAE,GAAGC,kBAAA;CAC3B,MAAM,EAAE,KAAK,EAAE,GAAGC,cAAA;CAClB,MAAM,EAAE,mBAAmB,EAAE,GAAGC,gBAAA;CAChC,MAAM,EAAE,yBAAyB,EAAE,GAAGC,gBAAA;;AAEtC,CAAA,IAAI,kBAAkB,GAAG;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAA,MAAM,uBAAuB,GAAG;;AAEhC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAA,MAAM,UAAU,GAAG;;AAEnB;AACA;AACA;AACA;AACA;AACA,CAAA,MAAM,IAAI,GAAG;;AAEb;AACA;AACA;AACA;AACA,CAAA,MAAM,MAAM,GAAG;;AAEf;AACA;AACA;AACA;AACA,CAAA,MAAM,SAAS,GAAG;;AAElB;AACA;AACA;AACA;AACA,CAAA,MAAM,eAAe,GAAG;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;CACA,MAAM,WAAW,SAAS,WAAW,CAAC;AACtC,GAAE,OAAO,GAAG;KACR,IAAI,EAAE,IAAI;KACV,KAAK,EAAE,IAAI;AACf,KAAI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E;KACN,SAAS,EAAE,IAAI;KACf,YAAY,EAAE,KAAK;KACnB,UAAU,EAAE,IAAI;KAChB,KAAK,EAAE,MAAM;AACjB,KAAI,QAAQ,EAAE;AACd;AACA;;AAEA,CAAA,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,4BAA4B;AACjE,CAAA,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE,4BAA4B;;AAE3E,CAAA,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE;GAC7C,KAAK,EAAE,mBAAmB;GAC1B,OAAO,EAAE,mBAAmB;GAC5B,SAAS,EAAE,mBAAmB;GAC9B,MAAM,EAAE,mBAAmB;GAC3B,UAAU,EAAE,mBAAmB;GAC/B,GAAG,EAAE,mBAAmB;AAC1B,GAAE,eAAe,EAAE;EAClB;;CAEDA,QAAM,CAAC,UAAU,CAAC,mBAAmB,GAAGA,QAAM,CAAC,mBAAmB,CAAC;GACjE;KACE,GAAG,EAAE,iBAAiB;AAC1B,KAAI,SAAS,EAAEA,QAAM,CAAC,UAAU,CAAC,OAAO;KACpC,YAAY,EAAE,MAAM;IACrB;GACD;KACE,GAAG,EAAE,YAAY;AACrB,KAAI,SAAS,EAAEA,QAAM,CAAC,UAAU,CAAC;AACjC;EACC;;AAED,CAAA,WAAc,GAAG;AACjB,GAAE,WAAW;GACX;AACF;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"eventsource.js","sources":["../../../../../../../../../node_modules/undici/lib/web/eventsource/eventsource.js"],"sourcesContent":["'use strict'\n\nconst { pipeline } = require('node:stream')\nconst { fetching } = require('../fetch')\nconst { makeRequest } = require('../fetch/request')\nconst { webidl } = require('../fetch/webidl')\nconst { EventSourceStream } = require('./eventsource-stream')\nconst { parseMIMEType } = require('../fetch/data-url')\nconst { createFastMessageEvent } = require('../websocket/events')\nconst { isNetworkError } = require('../fetch/response')\nconst { delay } = require('./util')\nconst { kEnumerableProperty } = require('../../core/util')\nconst { environmentSettingsObject } = require('../fetch/util')\nconst { getGlobalDispatcher } = require('../../global')\n\nlet experimentalWarned = false\n\n/**\n * A reconnection time, in milliseconds. This must initially be an implementation-defined value,\n * probably in the region of a few seconds.\n *\n * In Comparison:\n * - Chrome uses 3000ms.\n * - Deno uses 5000ms.\n *\n * @type {3000}\n */\nconst defaultReconnectionTime = 3000\n\n/**\n * The readyState attribute represents the state of the connection.\n * @enum\n * @readonly\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsource-readystate-dev\n */\n\n/**\n * The connection has not yet been established, or it was closed and the user\n * agent is reconnecting.\n * @type {0}\n */\nconst CONNECTING = 0\n\n/**\n * The user agent has an open connection and is dispatching events as it\n * receives them.\n * @type {1}\n */\nconst OPEN = 1\n\n/**\n * The connection is not open, and the user agent is not trying to reconnect.\n * @type {2}\n */\nconst CLOSED = 2\n\n/**\n * Requests for the element will have their mode set to \"cors\" and their credentials mode set to \"same-origin\".\n * @type {'anonymous'}\n */\nconst ANONYMOUS = 'anonymous'\n\n/**\n * Requests for the element will have their mode set to \"cors\" and their credentials mode set to \"include\".\n * @type {'use-credentials'}\n */\nconst USE_CREDENTIALS = 'use-credentials'\n\n/**\n * The EventSource interface is used to receive server-sent events. It\n * connects to a server over HTTP and receives events in text/event-stream\n * format without closing the connection.\n * @extends {EventTarget}\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events\n * @api public\n */\nclass EventSource extends EventTarget {\n #events = {\n open: null,\n error: null,\n message: null\n }\n\n #url = null\n #withCredentials = false\n\n #readyState = CONNECTING\n\n #request = null\n #controller = null\n\n #dispatcher\n\n /**\n * @type {import('./eventsource-stream').eventSourceSettings}\n */\n #state\n\n /**\n * Creates a new EventSource object.\n * @param {string} url\n * @param {EventSourceInit} [eventSourceInitDict]\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface\n */\n constructor (url, eventSourceInitDict = {}) {\n // 1. Let ev be a new EventSource object.\n super()\n\n webidl.util.markAsUncloneable(this)\n\n const prefix = 'EventSource constructor'\n webidl.argumentLengthCheck(arguments, 1, prefix)\n\n if (!experimentalWarned) {\n experimentalWarned = true\n process.emitWarning('EventSource is experimental, expect them to change at any time.', {\n code: 'UNDICI-ES'\n })\n }\n\n url = webidl.converters.USVString(url, prefix, 'url')\n eventSourceInitDict = webidl.converters.EventSourceInitDict(eventSourceInitDict, prefix, 'eventSourceInitDict')\n\n this.#dispatcher = eventSourceInitDict.dispatcher\n this.#state = {\n lastEventId: '',\n reconnectionTime: defaultReconnectionTime\n }\n\n // 2. Let settings be ev's relevant settings object.\n // https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object\n const settings = environmentSettingsObject\n\n let urlRecord\n\n try {\n // 3. Let urlRecord be the result of encoding-parsing a URL given url, relative to settings.\n urlRecord = new URL(url, settings.settingsObject.baseUrl)\n this.#state.origin = urlRecord.origin\n } catch (e) {\n // 4. If urlRecord is failure, then throw a \"SyntaxError\" DOMException.\n throw new DOMException(e, 'SyntaxError')\n }\n\n // 5. Set ev's url to urlRecord.\n this.#url = urlRecord.href\n\n // 6. Let corsAttributeState be Anonymous.\n let corsAttributeState = ANONYMOUS\n\n // 7. If the value of eventSourceInitDict's withCredentials member is true,\n // then set corsAttributeState to Use Credentials and set ev's\n // withCredentials attribute to true.\n if (eventSourceInitDict.withCredentials) {\n corsAttributeState = USE_CREDENTIALS\n this.#withCredentials = true\n }\n\n // 8. Let request be the result of creating a potential-CORS request given\n // urlRecord, the empty string, and corsAttributeState.\n const initRequest = {\n redirect: 'follow',\n keepalive: true,\n // @see https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes\n mode: 'cors',\n credentials: corsAttributeState === 'anonymous'\n ? 'same-origin'\n : 'omit',\n referrer: 'no-referrer'\n }\n\n // 9. Set request's client to settings.\n initRequest.client = environmentSettingsObject.settingsObject\n\n // 10. User agents may set (`Accept`, `text/event-stream`) in request's header list.\n initRequest.headersList = [['accept', { name: 'accept', value: 'text/event-stream' }]]\n\n // 11. Set request's cache mode to \"no-store\".\n initRequest.cache = 'no-store'\n\n // 12. Set request's initiator type to \"other\".\n initRequest.initiator = 'other'\n\n initRequest.urlList = [new URL(this.#url)]\n\n // 13. Set ev's request to request.\n this.#request = makeRequest(initRequest)\n\n this.#connect()\n }\n\n /**\n * Returns the state of this EventSource object's connection. It can have the\n * values described below.\n * @returns {0|1|2}\n * @readonly\n */\n get readyState () {\n return this.#readyState\n }\n\n /**\n * Returns the URL providing the event stream.\n * @readonly\n * @returns {string}\n */\n get url () {\n return this.#url\n }\n\n /**\n * Returns a boolean indicating whether the EventSource object was\n * instantiated with CORS credentials set (true), or not (false, the default).\n */\n get withCredentials () {\n return this.#withCredentials\n }\n\n #connect () {\n if (this.#readyState === CLOSED) return\n\n this.#readyState = CONNECTING\n\n const fetchParams = {\n request: this.#request,\n dispatcher: this.#dispatcher\n }\n\n // 14. Let processEventSourceEndOfBody given response res be the following step: if res is not a network error, then reestablish the connection.\n const processEventSourceEndOfBody = (response) => {\n if (isNetworkError(response)) {\n this.dispatchEvent(new Event('error'))\n this.close()\n }\n\n this.#reconnect()\n }\n\n // 15. Fetch request, with processResponseEndOfBody set to processEventSourceEndOfBody...\n fetchParams.processResponseEndOfBody = processEventSourceEndOfBody\n\n // and processResponse set to the following steps given response res:\n fetchParams.processResponse = (response) => {\n // 1. If res is an aborted network error, then fail the connection.\n\n if (isNetworkError(response)) {\n // 1. When a user agent is to fail the connection, the user agent\n // must queue a task which, if the readyState attribute is set to a\n // value other than CLOSED, sets the readyState attribute to CLOSED\n // and fires an event named error at the EventSource object. Once the\n // user agent has failed the connection, it does not attempt to\n // reconnect.\n if (response.aborted) {\n this.close()\n this.dispatchEvent(new Event('error'))\n return\n // 2. Otherwise, if res is a network error, then reestablish the\n // connection, unless the user agent knows that to be futile, in\n // which case the user agent may fail the connection.\n } else {\n this.#reconnect()\n return\n }\n }\n\n // 3. Otherwise, if res's status is not 200, or if res's `Content-Type`\n // is not `text/event-stream`, then fail the connection.\n const contentType = response.headersList.get('content-type', true)\n const mimeType = contentType !== null ? parseMIMEType(contentType) : 'failure'\n const contentTypeValid = mimeType !== 'failure' && mimeType.essence === 'text/event-stream'\n if (\n response.status !== 200 ||\n contentTypeValid === false\n ) {\n this.close()\n this.dispatchEvent(new Event('error'))\n return\n }\n\n // 4. Otherwise, announce the connection and interpret res's body\n // line by line.\n\n // When a user agent is to announce the connection, the user agent\n // must queue a task which, if the readyState attribute is set to a\n // value other than CLOSED, sets the readyState attribute to OPEN\n // and fires an event named open at the EventSource object.\n // @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model\n this.#readyState = OPEN\n this.dispatchEvent(new Event('open'))\n\n // If redirected to a different origin, set the origin to the new origin.\n this.#state.origin = response.urlList[response.urlList.length - 1].origin\n\n const eventSourceStream = new EventSourceStream({\n eventSourceSettings: this.#state,\n maxEventSize: this.#dispatcher.eventSourceOptions?.maxEventSize,\n push: (event) => {\n this.dispatchEvent(createFastMessageEvent(\n event.type,\n event.options\n ))\n }\n })\n\n pipeline(response.body.stream,\n eventSourceStream,\n (error) => {\n if (\n error?.aborted === false\n ) {\n this.close()\n this.dispatchEvent(new Event('error'))\n }\n })\n }\n\n this.#controller = fetching(fetchParams)\n }\n\n /**\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model\n * @returns {Promise<void>}\n */\n async #reconnect () {\n // When a user agent is to reestablish the connection, the user agent must\n // run the following steps. These steps are run in parallel, not as part of\n // a task. (The tasks that it queues, of course, are run like normal tasks\n // and not themselves in parallel.)\n\n // 1. Queue a task to run the following steps:\n\n // 1. If the readyState attribute is set to CLOSED, abort the task.\n if (this.#readyState === CLOSED) return\n\n // 2. Set the readyState attribute to CONNECTING.\n this.#readyState = CONNECTING\n\n // 3. Fire an event named error at the EventSource object.\n this.dispatchEvent(new Event('error'))\n\n // 2. Wait a delay equal to the reconnection time of the event source.\n await delay(this.#state.reconnectionTime)\n\n // 5. Queue a task to run the following steps:\n\n // 1. If the EventSource object's readyState attribute is not set to\n // CONNECTING, then return.\n if (this.#readyState !== CONNECTING) return\n\n // 2. Let request be the EventSource object's request.\n // 3. If the EventSource object's last event ID string is not the empty\n // string, then:\n // 1. Let lastEventIDValue be the EventSource object's last event ID\n // string, encoded as UTF-8.\n // 2. Set (`Last-Event-ID`, lastEventIDValue) in request's header\n // list.\n if (this.#state.lastEventId.length) {\n this.#request.headersList.set('last-event-id', this.#state.lastEventId, true)\n }\n\n // 4. Fetch request and process the response obtained in this fashion, if any, as described earlier in this section.\n this.#connect()\n }\n\n /**\n * Closes the connection, if any, and sets the readyState attribute to\n * CLOSED.\n */\n close () {\n webidl.brandCheck(this, EventSource)\n\n if (this.#readyState === CLOSED) return\n this.#readyState = CLOSED\n this.#controller.abort()\n this.#request = null\n }\n\n get onopen () {\n return this.#events.open\n }\n\n set onopen (fn) {\n if (this.#events.open) {\n this.removeEventListener('open', this.#events.open)\n }\n\n if (typeof fn === 'function') {\n this.#events.open = fn\n this.addEventListener('open', fn)\n } else {\n this.#events.open = null\n }\n }\n\n get onmessage () {\n return this.#events.message\n }\n\n set onmessage (fn) {\n if (this.#events.message) {\n this.removeEventListener('message', this.#events.message)\n }\n\n if (typeof fn === 'function') {\n this.#events.message = fn\n this.addEventListener('message', fn)\n } else {\n this.#events.message = null\n }\n }\n\n get onerror () {\n return this.#events.error\n }\n\n set onerror (fn) {\n if (this.#events.error) {\n this.removeEventListener('error', this.#events.error)\n }\n\n if (typeof fn === 'function') {\n this.#events.error = fn\n this.addEventListener('error', fn)\n } else {\n this.#events.error = null\n }\n }\n}\n\nconst constantsPropertyDescriptors = {\n CONNECTING: {\n __proto__: null,\n configurable: false,\n enumerable: true,\n value: CONNECTING,\n writable: false\n },\n OPEN: {\n __proto__: null,\n configurable: false,\n enumerable: true,\n value: OPEN,\n writable: false\n },\n CLOSED: {\n __proto__: null,\n configurable: false,\n enumerable: true,\n value: CLOSED,\n writable: false\n }\n}\n\nObject.defineProperties(EventSource, constantsPropertyDescriptors)\nObject.defineProperties(EventSource.prototype, constantsPropertyDescriptors)\n\nObject.defineProperties(EventSource.prototype, {\n close: kEnumerableProperty,\n onerror: kEnumerableProperty,\n onmessage: kEnumerableProperty,\n onopen: kEnumerableProperty,\n readyState: kEnumerableProperty,\n url: kEnumerableProperty,\n withCredentials: kEnumerableProperty\n})\n\nwebidl.converters.EventSourceInitDict = webidl.dictionaryConverter([\n {\n key: 'withCredentials',\n converter: webidl.converters.boolean,\n defaultValue: () => false\n },\n {\n key: 'dispatcher', // undici only\n converter: webidl.converters.any,\n defaultValue: () => getGlobalDispatcher()\n }\n])\n\nmodule.exports = {\n EventSource,\n defaultReconnectionTime\n}\n"],"names":["require$$0","require$$1","require$$2","webidl","require$$3","require$$4","require$$5","require$$6","require$$7","require$$8","require$$9","require$$10","require$$11"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;CAEA,MAAM,EAAE,QAAQ,EAAE,GAAGA;CACrB,MAAM,EAAE,QAAQ,EAAE,GAAGC,eAAA;CACrB,MAAM,EAAE,WAAW,EAAE,GAAGC,iBAAA;CACxB,MAAM,UAAEC,QAAM,EAAE,GAAGC,gBAAA;CACnB,MAAM,EAAE,iBAAiB,EAAE,GAAGC,2BAAA;CAC9B,MAAM,EAAE,aAAa,EAAE,GAAGC,iBAAA;CAC1B,MAAM,EAAE,sBAAsB,EAAE,GAAGC,gBAAA;CACnC,MAAM,EAAE,cAAc,EAAE,GAAGC,kBAAA;CAC3B,MAAM,EAAE,KAAK,EAAE,GAAGC,cAAA;CAClB,MAAM,EAAE,mBAAmB,EAAE,GAAGC,gBAAA;CAChC,MAAM,EAAE,yBAAyB,EAAE,GAAGC,gBAAA;CACtC,MAAM,EAAE,mBAAmB,EAAE,GAAGC,gBAAA;;AAEhC,CAAA,IAAI,kBAAkB,GAAG;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAA,MAAM,uBAAuB,GAAG;;AAEhC;AACA;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,EAAE,YAAY;AACrB,KAAI,SAAS,EAAEA,QAAM,CAAC,UAAU,CAAC,GAAG;KAChC,YAAY,EAAE,MAAM,mBAAmB;AAC3C;EACC;;AAED,CAAA,WAAc,GAAG;AACjB,GAAE,WAAW;GACX;AACF;;;;","x_google_ignoreList":[0]}
@@ -1908,8 +1908,10 @@ function requireFetch () {
1908
1908
  // 19. Run these steps in parallel:
1909
1909
 
1910
1910
  // 1. Run these steps, but abort when fetchParams is canceled:
1911
- fetchParams.controller.onAborted = onAborted;
1912
- fetchParams.controller.on('terminated', onAborted);
1911
+ if (!fetchParams.controller.resume) {
1912
+ fetchParams.controller.on('terminated', onAborted);
1913
+ }
1914
+
1913
1915
  fetchParams.controller.resume = async () => {
1914
1916
  // 1. While true
1915
1917
  while (true) {
@@ -2078,8 +2080,6 @@ function requireFetch () {
2078
2080
  }
2079
2081
  location = headersList.get('location', true);
2080
2082
 
2081
- this.body = new Readable({ read: resume });
2082
-
2083
2083
  const decoders = [];
2084
2084
 
2085
2085
  const willFollow = location && request.redirect === 'follow' &&
@@ -2097,7 +2097,7 @@ function requireFetch () {
2097
2097
  // CVE fix similar to urllib3 (GHSA-gm62-xv2j-4w53) and curl (CVE-2022-32206).
2098
2098
  const maxContentEncodings = 5;
2099
2099
  if (codings.length > maxContentEncodings) {
2100
- reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`));
2100
+ this.abort(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`));
2101
2101
  return true
2102
2102
  }
2103
2103
 
@@ -2130,6 +2130,8 @@ function requireFetch () {
2130
2130
  }
2131
2131
  }
2132
2132
 
2133
+ this.body = new Readable({ read: resume });
2134
+
2133
2135
  const onError = this.onError.bind(this);
2134
2136
 
2135
2137
  resolve({
@@ -2176,10 +2178,6 @@ function requireFetch () {
2176
2178
  fetchParams.controller.off('terminated', this.abort);
2177
2179
  }
2178
2180
 
2179
- if (fetchParams.controller.onAborted) {
2180
- fetchParams.controller.off('terminated', fetchParams.controller.onAborted);
2181
- }
2182
-
2183
2181
  fetchParams.controller.ended = true;
2184
2182
 
2185
2183
  this.body.push(null);