@otonoma/paranet-client 2.17.0 → 2.18.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-eBiJ1Egw.cjs → index-AtS3JMf_.cjs} +295 -161
- package/dist/cjs/index-AtS3JMf_.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/{index-PztyZob7.mjs → index-HCY5Ez1I.mjs} +295 -161
- package/dist/esm/index-HCY5Ez1I.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-eBiJ1Egw.cjs.map +0 -1
- package/dist/esm/index-PztyZob7.mjs.map +0 -1
|
@@ -8949,7 +8949,7 @@ async function connectH1$1 (client, socket) {
|
|
|
8949
8949
|
|
|
8950
8950
|
function clearIdleSocketValidation (socket) {
|
|
8951
8951
|
if (socket[kIdleSocketValidationTimeout]) {
|
|
8952
|
-
|
|
8952
|
+
clearImmediate(socket[kIdleSocketValidationTimeout]);
|
|
8953
8953
|
socket[kIdleSocketValidationTimeout] = null;
|
|
8954
8954
|
}
|
|
8955
8955
|
|
|
@@ -8958,15 +8958,23 @@ function clearIdleSocketValidation (socket) {
|
|
|
8958
8958
|
|
|
8959
8959
|
function scheduleIdleSocketValidation (client, socket) {
|
|
8960
8960
|
socket[kIdleSocketValidation] = 1;
|
|
8961
|
-
|
|
8961
|
+
// Yield to the check phase (after poll) so unsolicited bytes / FIN / RST
|
|
8962
|
+
// already pending on this idle keep-alive socket are processed before the
|
|
8963
|
+
// next request is written (GHSA-35p6-xmwp-9g52).
|
|
8964
|
+
//
|
|
8965
|
+
// setTimeout(0) pays Node's ~1ms timer floor on every sequential reuse
|
|
8966
|
+
// (#5493). setImmediate avoids that, but an *unref'd* Immediate lets poll
|
|
8967
|
+
// block for ~500ms when the event loop is otherwise idle (#5600 / #5606).
|
|
8968
|
+
// A ref'd Immediate both keeps the pending request alive and makes poll
|
|
8969
|
+
// return immediately — the hybrid those issues asked for.
|
|
8970
|
+
socket[kIdleSocketValidationTimeout] = setImmediate(() => {
|
|
8962
8971
|
socket[kIdleSocketValidationTimeout] = null;
|
|
8963
8972
|
socket[kIdleSocketValidation] = 2;
|
|
8964
8973
|
|
|
8965
8974
|
if (client[kSocket$1] === socket && !socket.destroyed) {
|
|
8966
8975
|
client[kResume$3]();
|
|
8967
8976
|
}
|
|
8968
|
-
}
|
|
8969
|
-
socket[kIdleSocketValidationTimeout].unref?.();
|
|
8977
|
+
});
|
|
8970
8978
|
}
|
|
8971
8979
|
|
|
8972
8980
|
/**
|
|
@@ -12471,6 +12479,7 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12471
12479
|
this.end = null;
|
|
12472
12480
|
this.etag = null;
|
|
12473
12481
|
this.resume = null;
|
|
12482
|
+
this.headersSent = false;
|
|
12474
12483
|
|
|
12475
12484
|
// Handle possible onConnect duplication
|
|
12476
12485
|
this.handler.onConnect(reason => {
|
|
@@ -12483,6 +12492,20 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12483
12492
|
});
|
|
12484
12493
|
}
|
|
12485
12494
|
|
|
12495
|
+
checkpointResponseEnd (headers, resume) {
|
|
12496
|
+
if (this.end == null && this.opts.method !== 'HEAD') {
|
|
12497
|
+
const contentLength = headers['content-length'];
|
|
12498
|
+
this.end = contentLength != null ? Number(contentLength) - 1 : null;
|
|
12499
|
+
|
|
12500
|
+
assert$7(
|
|
12501
|
+
this.end == null || Number.isFinite(this.end),
|
|
12502
|
+
'invalid content-length'
|
|
12503
|
+
);
|
|
12504
|
+
}
|
|
12505
|
+
|
|
12506
|
+
this.resume = this.end != null ? resume : null;
|
|
12507
|
+
}
|
|
12508
|
+
|
|
12486
12509
|
onRequestSent () {
|
|
12487
12510
|
if (this.handler.onRequestSent) {
|
|
12488
12511
|
this.handler.onRequestSent();
|
|
@@ -12572,6 +12595,8 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12572
12595
|
|
|
12573
12596
|
if (statusCode >= 300) {
|
|
12574
12597
|
if (this.retryOpts.statusCodes.includes(statusCode) === false) {
|
|
12598
|
+
this.headersSent = true;
|
|
12599
|
+
this.checkpointResponseEnd(headers, resume);
|
|
12575
12600
|
return this.handler.onHeaders(
|
|
12576
12601
|
statusCode,
|
|
12577
12602
|
rawHeaders,
|
|
@@ -12640,8 +12665,15 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12640
12665
|
|
|
12641
12666
|
const { start, size, end = size - 1 } = contentRange;
|
|
12642
12667
|
|
|
12643
|
-
|
|
12644
|
-
|
|
12668
|
+
if (this.start !== start || (this.end != null && this.end !== end)) {
|
|
12669
|
+
this.abort(
|
|
12670
|
+
new RequestRetryError('Content-Range mismatch', statusCode, {
|
|
12671
|
+
headers,
|
|
12672
|
+
data: { count: this.retryCount }
|
|
12673
|
+
})
|
|
12674
|
+
);
|
|
12675
|
+
return false
|
|
12676
|
+
}
|
|
12645
12677
|
|
|
12646
12678
|
this.resume = resume;
|
|
12647
12679
|
return true
|
|
@@ -12653,6 +12685,7 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12653
12685
|
const range = parseRangeHeader(headers['content-range']);
|
|
12654
12686
|
|
|
12655
12687
|
if (range == null) {
|
|
12688
|
+
this.headersSent = true;
|
|
12656
12689
|
return this.handler.onHeaders(
|
|
12657
12690
|
statusCode,
|
|
12658
12691
|
rawHeaders,
|
|
@@ -12691,6 +12724,7 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12691
12724
|
);
|
|
12692
12725
|
|
|
12693
12726
|
this.resume = resume;
|
|
12727
|
+
this.headersSent = true;
|
|
12694
12728
|
this.etag = headers.etag != null ? headers.etag : null;
|
|
12695
12729
|
|
|
12696
12730
|
// Weak etags are not useful for comparison nor cache
|
|
@@ -12730,7 +12764,7 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12730
12764
|
}
|
|
12731
12765
|
|
|
12732
12766
|
onError (err) {
|
|
12733
|
-
if (this.aborted || isDisturbed(this.opts.body)) {
|
|
12767
|
+
if (this.aborted || isDisturbed(this.opts.body) || (this.headersSent && this.resume == null)) {
|
|
12734
12768
|
return this.handler.onError(err)
|
|
12735
12769
|
}
|
|
12736
12770
|
|
|
@@ -24639,7 +24673,7 @@ function requireConnection () {
|
|
|
24639
24673
|
// is specified, the server needs to include the same field and one of
|
|
24640
24674
|
// the selected subprotocol values in its response for the connection to
|
|
24641
24675
|
// be established.
|
|
24642
|
-
if (!requestProtocols.includes(secProtocol)) {
|
|
24676
|
+
if (requestProtocols === null || !requestProtocols.includes(secProtocol)) {
|
|
24643
24677
|
failWebsocketConnection(ws, 'Protocol was not set in the opening handshake.');
|
|
24644
24678
|
return
|
|
24645
24679
|
}
|
|
@@ -24886,7 +24920,12 @@ function requirePermessageDeflate () {
|
|
|
24886
24920
|
|
|
24887
24921
|
if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
|
|
24888
24922
|
callback(new MessageSizeExceededError());
|
|
24923
|
+
// The inflater may still hold buffered input that can emit a late
|
|
24924
|
+
// zlib error. Remove the data listener, then deterministically stop
|
|
24925
|
+
// the stream so a subsequent 'error' cannot fire without a listener
|
|
24926
|
+
// (which would terminate the process as an unhandled error event).
|
|
24889
24927
|
this.#inflate.removeAllListeners();
|
|
24928
|
+
this.#inflate.destroy();
|
|
24890
24929
|
this.#inflate = null;
|
|
24891
24930
|
return
|
|
24892
24931
|
}
|
|
@@ -26235,6 +26274,49 @@ function requireEventsourceStream () {
|
|
|
26235
26274
|
*/
|
|
26236
26275
|
const SPACE = 0x20;
|
|
26237
26276
|
|
|
26277
|
+
const DATA = Buffer.from('data');
|
|
26278
|
+
const EVENT = Buffer.from('event');
|
|
26279
|
+
const ID = Buffer.from('id');
|
|
26280
|
+
const RETRY = Buffer.from('retry');
|
|
26281
|
+
|
|
26282
|
+
function isASCIINumberBytes (buffer, start) {
|
|
26283
|
+
if (start >= buffer.length) {
|
|
26284
|
+
return false
|
|
26285
|
+
}
|
|
26286
|
+
|
|
26287
|
+
for (let i = start; i < buffer.length; i++) {
|
|
26288
|
+
if (buffer[i] < 0x30 || buffer[i] > 0x39) {
|
|
26289
|
+
return false
|
|
26290
|
+
}
|
|
26291
|
+
}
|
|
26292
|
+
|
|
26293
|
+
return true
|
|
26294
|
+
}
|
|
26295
|
+
|
|
26296
|
+
function isValidLastEventIdBytes (buffer, start) {
|
|
26297
|
+
for (let i = start; i < buffer.length; i++) {
|
|
26298
|
+
if (buffer[i] === 0x00) {
|
|
26299
|
+
return false
|
|
26300
|
+
}
|
|
26301
|
+
}
|
|
26302
|
+
|
|
26303
|
+
return true
|
|
26304
|
+
}
|
|
26305
|
+
|
|
26306
|
+
function isFieldName (line, length, field) {
|
|
26307
|
+
if (length !== field.length) {
|
|
26308
|
+
return false
|
|
26309
|
+
}
|
|
26310
|
+
|
|
26311
|
+
for (let i = 0; i < length; i++) {
|
|
26312
|
+
if (line[i] !== field[i]) {
|
|
26313
|
+
return false
|
|
26314
|
+
}
|
|
26315
|
+
}
|
|
26316
|
+
|
|
26317
|
+
return true
|
|
26318
|
+
}
|
|
26319
|
+
|
|
26238
26320
|
/**
|
|
26239
26321
|
* @typedef {object} EventSourceStreamEvent
|
|
26240
26322
|
* @type {object}
|
|
@@ -26275,11 +26357,14 @@ function requireEventsourceStream () {
|
|
|
26275
26357
|
eventEndCheck = false
|
|
26276
26358
|
|
|
26277
26359
|
/**
|
|
26278
|
-
* @type {Buffer}
|
|
26360
|
+
* @type {Buffer[]}
|
|
26279
26361
|
*/
|
|
26280
|
-
|
|
26362
|
+
chunks = []
|
|
26281
26363
|
|
|
26364
|
+
chunkIndex = 0
|
|
26282
26365
|
pos = 0
|
|
26366
|
+
lineChunkIndex = 0
|
|
26367
|
+
linePos = 0
|
|
26283
26368
|
|
|
26284
26369
|
event = {
|
|
26285
26370
|
data: undefined,
|
|
@@ -26318,92 +26403,20 @@ function requireEventsourceStream () {
|
|
|
26318
26403
|
return
|
|
26319
26404
|
}
|
|
26320
26405
|
|
|
26321
|
-
|
|
26322
|
-
// processing it
|
|
26323
|
-
// TODO: Investigate if there is a more performant way to handle
|
|
26324
|
-
// incoming chunks
|
|
26325
|
-
// see: https://github.com/nodejs/undici/issues/2630
|
|
26326
|
-
if (this.buffer) {
|
|
26327
|
-
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
26328
|
-
} else {
|
|
26329
|
-
this.buffer = chunk;
|
|
26330
|
-
}
|
|
26406
|
+
this.chunks.push(chunk);
|
|
26331
26407
|
|
|
26332
26408
|
// Strip leading byte-order-mark if we opened the stream and started
|
|
26333
26409
|
// the processing of the incoming data
|
|
26334
26410
|
if (this.checkBOM) {
|
|
26335
|
-
|
|
26336
|
-
|
|
26337
|
-
|
|
26338
|
-
if (this.buffer[0] === BOM[0]) {
|
|
26339
|
-
// If it is, we need to wait for more data
|
|
26340
|
-
callback();
|
|
26341
|
-
return
|
|
26342
|
-
}
|
|
26343
|
-
// Set the checkBOM flag to false as we don't need to check for the
|
|
26344
|
-
// BOM anymore
|
|
26345
|
-
this.checkBOM = false;
|
|
26346
|
-
|
|
26347
|
-
// The buffer only contains one byte so we need to wait for more data
|
|
26348
|
-
callback();
|
|
26349
|
-
return
|
|
26350
|
-
case 2:
|
|
26351
|
-
// Check if the first two bytes are the same as the first two bytes
|
|
26352
|
-
// of the BOM
|
|
26353
|
-
if (
|
|
26354
|
-
this.buffer[0] === BOM[0] &&
|
|
26355
|
-
this.buffer[1] === BOM[1]
|
|
26356
|
-
) {
|
|
26357
|
-
// If it is, we need to wait for more data, because the third byte
|
|
26358
|
-
// is needed to determine if it is the BOM or not
|
|
26359
|
-
callback();
|
|
26360
|
-
return
|
|
26361
|
-
}
|
|
26362
|
-
|
|
26363
|
-
// Set the checkBOM flag to false as we don't need to check for the
|
|
26364
|
-
// BOM anymore
|
|
26365
|
-
this.checkBOM = false;
|
|
26366
|
-
break
|
|
26367
|
-
case 3:
|
|
26368
|
-
// Check if the first three bytes are the same as the first three
|
|
26369
|
-
// bytes of the BOM
|
|
26370
|
-
if (
|
|
26371
|
-
this.buffer[0] === BOM[0] &&
|
|
26372
|
-
this.buffer[1] === BOM[1] &&
|
|
26373
|
-
this.buffer[2] === BOM[2]
|
|
26374
|
-
) {
|
|
26375
|
-
// If it is, we can drop the buffered data, as it is only the BOM
|
|
26376
|
-
this.buffer = Buffer.alloc(0);
|
|
26377
|
-
// Set the checkBOM flag to false as we don't need to check for the
|
|
26378
|
-
// BOM anymore
|
|
26379
|
-
this.checkBOM = false;
|
|
26380
|
-
|
|
26381
|
-
// Await more data
|
|
26382
|
-
callback();
|
|
26383
|
-
return
|
|
26384
|
-
}
|
|
26385
|
-
// If it is not the BOM, we can start processing the data
|
|
26386
|
-
this.checkBOM = false;
|
|
26387
|
-
break
|
|
26388
|
-
default:
|
|
26389
|
-
// The buffer is longer than 3 bytes, so we can drop the BOM if it is
|
|
26390
|
-
// present
|
|
26391
|
-
if (
|
|
26392
|
-
this.buffer[0] === BOM[0] &&
|
|
26393
|
-
this.buffer[1] === BOM[1] &&
|
|
26394
|
-
this.buffer[2] === BOM[2]
|
|
26395
|
-
) {
|
|
26396
|
-
// Remove the BOM from the buffer
|
|
26397
|
-
this.buffer = this.buffer.subarray(3);
|
|
26398
|
-
}
|
|
26399
|
-
|
|
26400
|
-
// Set the checkBOM flag to false as we don't need to check for the
|
|
26401
|
-
this.checkBOM = false;
|
|
26402
|
-
break
|
|
26411
|
+
if (this.handleBOM()) {
|
|
26412
|
+
callback();
|
|
26413
|
+
return
|
|
26403
26414
|
}
|
|
26404
26415
|
}
|
|
26405
26416
|
|
|
26406
|
-
while (this.
|
|
26417
|
+
while (this.hasCurrentByte()) {
|
|
26418
|
+
const byte = this.currentByte();
|
|
26419
|
+
|
|
26407
26420
|
// If the previous line ended with an end-of-line, we need to check
|
|
26408
26421
|
// if the next character is also an end-of-line.
|
|
26409
26422
|
if (this.eventEndCheck) {
|
|
@@ -26416,10 +26429,9 @@ function requireEventsourceStream () {
|
|
|
26416
26429
|
if (this.crlfCheck) {
|
|
26417
26430
|
// If the current character is a line feed, we can remove it
|
|
26418
26431
|
// from the buffer and reset the crlfCheck flag
|
|
26419
|
-
if (
|
|
26420
|
-
this.buffer = this.buffer.subarray(this.pos + 1);
|
|
26421
|
-
this.pos = 0;
|
|
26432
|
+
if (byte === LF) {
|
|
26422
26433
|
this.crlfCheck = false;
|
|
26434
|
+
this.consumeCurrentByte();
|
|
26423
26435
|
|
|
26424
26436
|
// It is possible that the line feed is not the end of the
|
|
26425
26437
|
// event. We need to check if the next character is an
|
|
@@ -26435,19 +26447,17 @@ function requireEventsourceStream () {
|
|
|
26435
26447
|
this.crlfCheck = false;
|
|
26436
26448
|
}
|
|
26437
26449
|
|
|
26438
|
-
if (
|
|
26450
|
+
if (byte === LF || byte === CR) {
|
|
26439
26451
|
// If the current character is a carriage return, we need to
|
|
26440
26452
|
// set the crlfCheck flag to true, as we need to check if the
|
|
26441
26453
|
// next character is a line feed so we can remove it from the
|
|
26442
26454
|
// buffer
|
|
26443
|
-
if (
|
|
26455
|
+
if (byte === CR) {
|
|
26444
26456
|
this.crlfCheck = true;
|
|
26445
26457
|
}
|
|
26446
26458
|
|
|
26447
|
-
this.
|
|
26448
|
-
this.
|
|
26449
|
-
if (
|
|
26450
|
-
this.event.data !== undefined || this.event.event || this.event.id || this.event.retry) {
|
|
26459
|
+
this.consumeCurrentByte();
|
|
26460
|
+
if (this.hasPendingEvent()) {
|
|
26451
26461
|
this.processEvent(this.event);
|
|
26452
26462
|
}
|
|
26453
26463
|
this.clearEvent();
|
|
@@ -26461,22 +26471,18 @@ function requireEventsourceStream () {
|
|
|
26461
26471
|
|
|
26462
26472
|
// If the current character is an end-of-line, we can process the
|
|
26463
26473
|
// line
|
|
26464
|
-
if (
|
|
26474
|
+
if (byte === LF || byte === CR) {
|
|
26465
26475
|
// If the current character is a carriage return, we need to
|
|
26466
26476
|
// set the crlfCheck flag to true, as we need to check if the
|
|
26467
26477
|
// next character is a line feed
|
|
26468
|
-
if (
|
|
26478
|
+
if (byte === CR) {
|
|
26469
26479
|
this.crlfCheck = true;
|
|
26470
26480
|
}
|
|
26471
26481
|
|
|
26472
26482
|
// In any case, we can process the line as we reached an
|
|
26473
26483
|
// end-of-line character
|
|
26474
|
-
this.parseLine(this.
|
|
26475
|
-
|
|
26476
|
-
// Remove the processed line from the buffer
|
|
26477
|
-
this.buffer = this.buffer.subarray(this.pos + 1);
|
|
26478
|
-
// Reset the position as we removed the processed line from the buffer
|
|
26479
|
-
this.pos = 0;
|
|
26484
|
+
this.parseLine(this.readLine(), this.event);
|
|
26485
|
+
this.consumeCurrentByte();
|
|
26480
26486
|
// A line was processed and this could be the end of the event. We need
|
|
26481
26487
|
// to check if the next line is empty to determine if the event is
|
|
26482
26488
|
// finished.
|
|
@@ -26484,7 +26490,7 @@ function requireEventsourceStream () {
|
|
|
26484
26490
|
continue
|
|
26485
26491
|
}
|
|
26486
26492
|
|
|
26487
|
-
this.
|
|
26493
|
+
this.advanceCursor();
|
|
26488
26494
|
}
|
|
26489
26495
|
|
|
26490
26496
|
callback();
|
|
@@ -26509,64 +26515,53 @@ function requireEventsourceStream () {
|
|
|
26509
26515
|
return
|
|
26510
26516
|
}
|
|
26511
26517
|
|
|
26512
|
-
let
|
|
26513
|
-
let
|
|
26518
|
+
let fieldLength = line.length;
|
|
26519
|
+
let valueStart = line.length;
|
|
26514
26520
|
|
|
26515
26521
|
// If the line contains a U+003A COLON character (:)
|
|
26516
26522
|
if (colonPosition !== -1) {
|
|
26517
|
-
|
|
26518
|
-
// character (:), and let field be that string.
|
|
26519
|
-
// TODO: Investigate if there is a more performant way to extract the
|
|
26520
|
-
// field
|
|
26521
|
-
// see: https://github.com/nodejs/undici/issues/2630
|
|
26522
|
-
field = line.subarray(0, colonPosition).toString('utf8');
|
|
26523
|
+
fieldLength = colonPosition;
|
|
26523
26524
|
|
|
26524
26525
|
// Collect the characters on the line after the first U+003A COLON
|
|
26525
26526
|
// character (:), and let value be that string.
|
|
26526
26527
|
// If value starts with a U+0020 SPACE character, remove it from value.
|
|
26527
|
-
|
|
26528
|
+
valueStart = colonPosition + 1;
|
|
26528
26529
|
if (line[valueStart] === SPACE) {
|
|
26529
26530
|
++valueStart;
|
|
26530
26531
|
}
|
|
26531
|
-
|
|
26532
|
-
// value
|
|
26533
|
-
// see: https://github.com/nodejs/undici/issues/2630
|
|
26534
|
-
value = line.subarray(valueStart).toString('utf8');
|
|
26532
|
+
}
|
|
26535
26533
|
|
|
26536
|
-
|
|
26537
|
-
|
|
26538
|
-
|
|
26539
|
-
|
|
26540
|
-
|
|
26541
|
-
|
|
26542
|
-
|
|
26543
|
-
|
|
26544
|
-
|
|
26545
|
-
|
|
26546
|
-
|
|
26547
|
-
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
|
|
26551
|
-
|
|
26552
|
-
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
26566
|
-
|
|
26567
|
-
event[field] = value;
|
|
26568
|
-
}
|
|
26569
|
-
break
|
|
26534
|
+
if (isFieldName(line, fieldLength, DATA)) {
|
|
26535
|
+
const value = line.toString('utf8', valueStart);
|
|
26536
|
+
|
|
26537
|
+
if (event.data === undefined) {
|
|
26538
|
+
event.data = value;
|
|
26539
|
+
} else {
|
|
26540
|
+
event.data += `\n${value}`;
|
|
26541
|
+
}
|
|
26542
|
+
return
|
|
26543
|
+
}
|
|
26544
|
+
|
|
26545
|
+
if (isFieldName(line, fieldLength, RETRY)) {
|
|
26546
|
+
if (isASCIINumberBytes(line, valueStart)) {
|
|
26547
|
+
event.retry = line.toString('utf8', valueStart);
|
|
26548
|
+
}
|
|
26549
|
+
return
|
|
26550
|
+
}
|
|
26551
|
+
|
|
26552
|
+
if (isFieldName(line, fieldLength, ID)) {
|
|
26553
|
+
if (isValidLastEventIdBytes(line, valueStart)) {
|
|
26554
|
+
event.id = line.toString('utf8', valueStart);
|
|
26555
|
+
}
|
|
26556
|
+
return
|
|
26557
|
+
}
|
|
26558
|
+
|
|
26559
|
+
if (isFieldName(line, fieldLength, EVENT)) {
|
|
26560
|
+
const value = line.toString('utf8', valueStart);
|
|
26561
|
+
|
|
26562
|
+
if (value.length > 0) {
|
|
26563
|
+
event.event = value;
|
|
26564
|
+
}
|
|
26570
26565
|
}
|
|
26571
26566
|
}
|
|
26572
26567
|
|
|
@@ -26596,12 +26591,151 @@ function requireEventsourceStream () {
|
|
|
26596
26591
|
}
|
|
26597
26592
|
|
|
26598
26593
|
clearEvent () {
|
|
26599
|
-
this.event =
|
|
26600
|
-
|
|
26601
|
-
|
|
26602
|
-
|
|
26603
|
-
|
|
26604
|
-
|
|
26594
|
+
this.event.data = undefined;
|
|
26595
|
+
this.event.event = undefined;
|
|
26596
|
+
this.event.id = undefined;
|
|
26597
|
+
this.event.retry = undefined;
|
|
26598
|
+
}
|
|
26599
|
+
|
|
26600
|
+
hasPendingEvent () {
|
|
26601
|
+
return this.event.data !== undefined ||
|
|
26602
|
+
this.event.event !== undefined ||
|
|
26603
|
+
this.event.id !== undefined ||
|
|
26604
|
+
this.event.retry !== undefined
|
|
26605
|
+
}
|
|
26606
|
+
|
|
26607
|
+
hasCurrentByte () {
|
|
26608
|
+
return this.chunkIndex < this.chunks.length &&
|
|
26609
|
+
this.pos < this.chunks[this.chunkIndex].length
|
|
26610
|
+
}
|
|
26611
|
+
|
|
26612
|
+
currentByte () {
|
|
26613
|
+
return this.chunks[this.chunkIndex][this.pos]
|
|
26614
|
+
}
|
|
26615
|
+
|
|
26616
|
+
consumeCurrentByte () {
|
|
26617
|
+
this.advanceCursor();
|
|
26618
|
+
this.syncLineStartToCursor();
|
|
26619
|
+
}
|
|
26620
|
+
|
|
26621
|
+
advanceCursor () {
|
|
26622
|
+
this.pos++;
|
|
26623
|
+
|
|
26624
|
+
while (this.chunkIndex < this.chunks.length && this.pos >= this.chunks[this.chunkIndex].length) {
|
|
26625
|
+
this.chunkIndex++;
|
|
26626
|
+
this.pos = 0;
|
|
26627
|
+
}
|
|
26628
|
+
}
|
|
26629
|
+
|
|
26630
|
+
syncLineStartToCursor () {
|
|
26631
|
+
this.lineChunkIndex = this.chunkIndex;
|
|
26632
|
+
this.linePos = this.pos;
|
|
26633
|
+
this.dropConsumedChunks();
|
|
26634
|
+
}
|
|
26635
|
+
|
|
26636
|
+
dropConsumedChunks () {
|
|
26637
|
+
while (this.lineChunkIndex > 0) {
|
|
26638
|
+
this.chunks.shift();
|
|
26639
|
+
this.lineChunkIndex--;
|
|
26640
|
+
this.chunkIndex--;
|
|
26641
|
+
}
|
|
26642
|
+
|
|
26643
|
+
if (this.chunkIndex === this.chunks.length) {
|
|
26644
|
+
this.chunks.length = 0;
|
|
26645
|
+
this.chunkIndex = 0;
|
|
26646
|
+
this.pos = 0;
|
|
26647
|
+
this.lineChunkIndex = 0;
|
|
26648
|
+
this.linePos = 0;
|
|
26649
|
+
}
|
|
26650
|
+
}
|
|
26651
|
+
|
|
26652
|
+
readLine () {
|
|
26653
|
+
if (this.lineChunkIndex === this.chunkIndex) {
|
|
26654
|
+
return this.chunks[this.chunkIndex].subarray(this.linePos, this.pos)
|
|
26655
|
+
}
|
|
26656
|
+
|
|
26657
|
+
const chunks = [];
|
|
26658
|
+
let length = 0;
|
|
26659
|
+
|
|
26660
|
+
for (let i = this.lineChunkIndex; i <= this.chunkIndex; i++) {
|
|
26661
|
+
const chunk = this.chunks[i];
|
|
26662
|
+
const start = i === this.lineChunkIndex ? this.linePos : 0;
|
|
26663
|
+
const end = i === this.chunkIndex ? this.pos : chunk.length;
|
|
26664
|
+
const slice = chunk.subarray(start, end);
|
|
26665
|
+
length += slice.length;
|
|
26666
|
+
chunks.push(slice);
|
|
26667
|
+
}
|
|
26668
|
+
|
|
26669
|
+
return Buffer.concat(chunks, length)
|
|
26670
|
+
}
|
|
26671
|
+
|
|
26672
|
+
peekBufferedByte (offset) {
|
|
26673
|
+
let chunkIndex = this.lineChunkIndex;
|
|
26674
|
+
let pos = this.linePos;
|
|
26675
|
+
|
|
26676
|
+
while (chunkIndex < this.chunks.length) {
|
|
26677
|
+
const chunk = this.chunks[chunkIndex];
|
|
26678
|
+
const remaining = chunk.length - pos;
|
|
26679
|
+
|
|
26680
|
+
if (offset < remaining) {
|
|
26681
|
+
return chunk[pos + offset]
|
|
26682
|
+
}
|
|
26683
|
+
|
|
26684
|
+
offset -= remaining;
|
|
26685
|
+
chunkIndex++;
|
|
26686
|
+
pos = 0;
|
|
26687
|
+
}
|
|
26688
|
+
}
|
|
26689
|
+
|
|
26690
|
+
discardLeadingBytes (count) {
|
|
26691
|
+
while (count > 0 && this.lineChunkIndex < this.chunks.length) {
|
|
26692
|
+
const chunk = this.chunks[this.lineChunkIndex];
|
|
26693
|
+
const remaining = chunk.length - this.linePos;
|
|
26694
|
+
|
|
26695
|
+
if (count < remaining) {
|
|
26696
|
+
this.linePos += count;
|
|
26697
|
+
count = 0;
|
|
26698
|
+
} else {
|
|
26699
|
+
count -= remaining;
|
|
26700
|
+
this.lineChunkIndex++;
|
|
26701
|
+
this.linePos = 0;
|
|
26702
|
+
}
|
|
26703
|
+
}
|
|
26704
|
+
|
|
26705
|
+
this.chunkIndex = this.lineChunkIndex;
|
|
26706
|
+
this.pos = this.linePos;
|
|
26707
|
+
this.dropConsumedChunks();
|
|
26708
|
+
}
|
|
26709
|
+
|
|
26710
|
+
handleBOM () {
|
|
26711
|
+
const first = this.peekBufferedByte(0);
|
|
26712
|
+
const second = this.peekBufferedByte(1);
|
|
26713
|
+
const third = this.peekBufferedByte(2);
|
|
26714
|
+
|
|
26715
|
+
if (second === undefined) {
|
|
26716
|
+
if (first === BOM[0]) {
|
|
26717
|
+
return true
|
|
26718
|
+
}
|
|
26719
|
+
|
|
26720
|
+
this.checkBOM = false;
|
|
26721
|
+
return true
|
|
26722
|
+
}
|
|
26723
|
+
|
|
26724
|
+
if (third === undefined) {
|
|
26725
|
+
if (first === BOM[0] && second === BOM[1]) {
|
|
26726
|
+
return true
|
|
26727
|
+
}
|
|
26728
|
+
|
|
26729
|
+
this.checkBOM = false;
|
|
26730
|
+
return false
|
|
26731
|
+
}
|
|
26732
|
+
|
|
26733
|
+
if (first === BOM[0] && second === BOM[1] && third === BOM[2]) {
|
|
26734
|
+
this.discardLeadingBytes(3);
|
|
26735
|
+
}
|
|
26736
|
+
|
|
26737
|
+
this.checkBOM = false;
|
|
26738
|
+
return !this.hasCurrentByte()
|
|
26605
26739
|
}
|
|
26606
26740
|
}
|
|
26607
26741
|
|
|
@@ -27321,4 +27455,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
|
|
|
27321
27455
|
}, [undici]);
|
|
27322
27456
|
|
|
27323
27457
|
exports.index = index;
|
|
27324
|
-
//# sourceMappingURL=index-
|
|
27458
|
+
//# sourceMappingURL=index-AtS3JMf_.cjs.map
|