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