@axiom-lattice/client-sdk 4.3.0 → 4.3.1
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/__tests__/sse-parser.test.js +8 -7
- package/dist/__tests__/sse-parser.test.js.map +1 -1
- package/dist/index.js +7 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -24
- package/dist/index.mjs.map +1 -1
- package/dist/sse-parser.d.ts +0 -3
- package/dist/sse-parser.d.ts.map +1 -1
- package/dist/sse-parser.js +1 -19
- package/dist/sse-parser.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -913,8 +913,8 @@ var require_encoding = __commonJS({
|
|
|
913
913
|
}
|
|
914
914
|
return serializeStream.call(this, output);
|
|
915
915
|
};
|
|
916
|
-
function
|
|
917
|
-
if (!(this instanceof
|
|
916
|
+
function TextEncoder(label, options) {
|
|
917
|
+
if (!(this instanceof TextEncoder))
|
|
918
918
|
throw TypeError("Called as a function. Did you forget 'new'?");
|
|
919
919
|
options = ToDictionary(options);
|
|
920
920
|
this._encoding = null;
|
|
@@ -942,14 +942,14 @@ var require_encoding = __commonJS({
|
|
|
942
942
|
return enc;
|
|
943
943
|
}
|
|
944
944
|
if (Object.defineProperty) {
|
|
945
|
-
Object.defineProperty(
|
|
945
|
+
Object.defineProperty(TextEncoder.prototype, "encoding", {
|
|
946
946
|
/** @this {TextEncoder} */
|
|
947
947
|
get: function() {
|
|
948
948
|
return this._encoding.name.toLowerCase();
|
|
949
949
|
}
|
|
950
950
|
});
|
|
951
951
|
}
|
|
952
|
-
|
|
952
|
+
TextEncoder.prototype.encode = function encode2(opt_string, options) {
|
|
953
953
|
opt_string = opt_string === void 0 ? "" : String(opt_string);
|
|
954
954
|
options = ToDictionary(options);
|
|
955
955
|
if (!this._do_not_flush)
|
|
@@ -1805,7 +1805,7 @@ var require_encoding = __commonJS({
|
|
|
1805
1805
|
return new XUserDefinedDecoder(options);
|
|
1806
1806
|
};
|
|
1807
1807
|
if (!global["TextEncoder"])
|
|
1808
|
-
global["TextEncoder"] =
|
|
1808
|
+
global["TextEncoder"] = TextEncoder;
|
|
1809
1809
|
if (!global["TextDecoder"])
|
|
1810
1810
|
global["TextDecoder"] = TextDecoder2;
|
|
1811
1811
|
if (typeof module !== "undefined" && module.exports) {
|
|
@@ -3438,9 +3438,6 @@ var SseParseError = class extends Error {
|
|
|
3438
3438
|
}
|
|
3439
3439
|
};
|
|
3440
3440
|
async function* parseSseBody(body, options = {}) {
|
|
3441
|
-
const maxLine = options.maxLineBytes ?? 64 * 1024;
|
|
3442
|
-
const maxEvent = options.maxEventBytes ?? 1024 * 1024;
|
|
3443
|
-
const maxDataLines = options.maxDataLines ?? 1024;
|
|
3444
3441
|
const reader = body.getReader();
|
|
3445
3442
|
const decoder = new TextDecoder();
|
|
3446
3443
|
let buffer = "";
|
|
@@ -3448,13 +3445,11 @@ async function* parseSseBody(body, options = {}) {
|
|
|
3448
3445
|
let id;
|
|
3449
3446
|
let retry;
|
|
3450
3447
|
let data = [];
|
|
3451
|
-
let bytes = 0;
|
|
3452
3448
|
const dispatch = () => {
|
|
3453
3449
|
if (data.length === 0) {
|
|
3454
3450
|
event = "";
|
|
3455
3451
|
id = void 0;
|
|
3456
3452
|
retry = void 0;
|
|
3457
|
-
bytes = 0;
|
|
3458
3453
|
return void 0;
|
|
3459
3454
|
}
|
|
3460
3455
|
let parsed;
|
|
@@ -3470,13 +3465,10 @@ async function* parseSseBody(body, options = {}) {
|
|
|
3470
3465
|
id = void 0;
|
|
3471
3466
|
retry = void 0;
|
|
3472
3467
|
data = [];
|
|
3473
|
-
bytes = 0;
|
|
3474
3468
|
return result;
|
|
3475
3469
|
};
|
|
3476
3470
|
const processLine = (raw) => {
|
|
3477
3471
|
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
3478
|
-
if (new TextEncoder().encode(line).byteLength > maxLine)
|
|
3479
|
-
throw new SseParseError("SSE line is too large");
|
|
3480
3472
|
if (line === "")
|
|
3481
3473
|
return dispatch();
|
|
3482
3474
|
if (line.startsWith(":"))
|
|
@@ -3488,14 +3480,9 @@ async function* parseSseBody(body, options = {}) {
|
|
|
3488
3480
|
value = value.slice(1);
|
|
3489
3481
|
if (field === "event")
|
|
3490
3482
|
event = value;
|
|
3491
|
-
else if (field === "data")
|
|
3492
|
-
if (data.length >= maxDataLines)
|
|
3493
|
-
throw new SseParseError("Too many SSE data lines");
|
|
3483
|
+
else if (field === "data")
|
|
3494
3484
|
data.push(value);
|
|
3495
|
-
|
|
3496
|
-
if (bytes > maxEvent)
|
|
3497
|
-
throw new SseParseError("SSE event is too large");
|
|
3498
|
-
} else if (field === "id")
|
|
3485
|
+
else if (field === "id")
|
|
3499
3486
|
id = value;
|
|
3500
3487
|
else if (field === "retry") {
|
|
3501
3488
|
const parsed = Number(value);
|
|
@@ -3510,13 +3497,9 @@ async function* parseSseBody(body, options = {}) {
|
|
|
3510
3497
|
const chunk = await reader.read();
|
|
3511
3498
|
if (chunk.done) {
|
|
3512
3499
|
buffer += decoder.decode();
|
|
3513
|
-
if (new TextEncoder().encode(buffer).byteLength > maxLine)
|
|
3514
|
-
throw new SseParseError("SSE line is too large");
|
|
3515
3500
|
break;
|
|
3516
3501
|
}
|
|
3517
3502
|
buffer += decoder.decode(chunk.value, { stream: true });
|
|
3518
|
-
if (new TextEncoder().encode(buffer.slice(0, Math.max(0, findLineBreak(buffer) < 0 ? buffer.length : findLineBreak(buffer)))).byteLength > maxLine)
|
|
3519
|
-
throw new SseParseError("SSE line is too large");
|
|
3520
3503
|
let index = findLineBreak(buffer);
|
|
3521
3504
|
while (index >= 0) {
|
|
3522
3505
|
if (buffer[index] === "\r" && index === buffer.length - 1)
|