itd-api 0.11.0 → 0.12.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/events/index.cjs +3 -3
- package/dist/events/index.d.cts +2 -2
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +3 -3
- package/dist/index.cjs +28 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -19
- package/dist/index.d.ts +23 -19
- package/dist/index.js +26 -49
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +7 -8
- package/dist/node/index.d.ts +7 -8
- package/dist/node/index.js +2 -2
- package/dist/node/index.js.map +1 -1
- package/dist/rest/index.cjs +7 -4
- package/dist/rest/index.cjs.map +1 -1
- package/dist/rest/index.d.cts +5 -5
- package/dist/rest/index.d.ts +5 -5
- package/dist/rest/index.js +5 -5
- package/dist/rest/index.js.map +1 -1
- package/dist/shared/{events-CAb9G7Sf.d.ts → events-9215JDDd.d.ts} +2 -2
- package/dist/shared/{events-C6tmj8aW.cjs → events-BKyxZQNw.cjs} +246 -56
- package/dist/shared/events-BKyxZQNw.cjs.map +1 -0
- package/dist/shared/{events-Sc75x6rT.d.cts → events-FaXfdle0.d.cts} +2 -2
- package/dist/shared/{events-MWNcnfrq.js → events-_iYo8EP5.js} +246 -56
- package/dist/shared/events-_iYo8EP5.js.map +1 -0
- package/dist/shared/key-value-store-DYSPsqwq.cjs.map +1 -1
- package/dist/shared/key-value-store-w1Dn5Pjb.js.map +1 -1
- package/dist/shared/{multi-storage-C7-Gz6Z7.cjs → multi-storage-7Y3KCseI.cjs} +2 -2
- package/dist/shared/multi-storage-7Y3KCseI.cjs.map +1 -0
- package/dist/shared/{multi-storage-BLBrGN9Q.js → multi-storage-DiBSx64p.js} +2 -2
- package/dist/shared/multi-storage-DiBSx64p.js.map +1 -0
- package/dist/shared/{options-5tywTYId.cjs → options-D5ttspWk.cjs} +2 -2
- package/dist/shared/{options-5tywTYId.cjs.map → options-D5ttspWk.cjs.map} +1 -1
- package/dist/shared/{options-BerKicCs.js → options-DLlaETn_.js} +2 -2
- package/dist/shared/{options-BerKicCs.js.map → options-DLlaETn_.js.map} +1 -1
- package/dist/shared/{redact-DoC7lSsp.cjs → redact-BbhtA9o-.cjs} +13 -3
- package/dist/shared/redact-BbhtA9o-.cjs.map +1 -0
- package/dist/shared/{redact-C5oxIvcc.js → redact-DSfdmeY7.js} +13 -3
- package/dist/shared/redact-DSfdmeY7.js.map +1 -0
- package/dist/shared/{render-Dnc84B4M.cjs → render-BQvC5UxF.cjs} +134 -49
- package/dist/shared/render-BQvC5UxF.cjs.map +1 -0
- package/dist/shared/{render-CBroJPcV.d.ts → render-BS09ygcy.d.ts} +84 -70
- package/dist/shared/{render-DRh5_aRe.js → render-CFoF2WaH.js} +134 -49
- package/dist/shared/render-CFoF2WaH.js.map +1 -0
- package/dist/shared/{render-DM7AhTZW.d.cts → render-X2JCo1JS.d.cts} +84 -70
- package/dist/shared/storage-86wiHeXD.js.map +1 -1
- package/dist/shared/storage-CIjejZDt.cjs.map +1 -1
- package/dist/shared/{url-Bg61sk_Y.js → url-CdT4lMxQ.js} +25 -12
- package/dist/shared/url-CdT4lMxQ.js.map +1 -0
- package/dist/shared/{url-BOi-_mJT.d.ts → url-_R0oJ7gE.d.cts} +102 -53
- package/dist/shared/{url-BOi-_mJT.d.cts → url-_R0oJ7gE.d.ts} +102 -53
- package/dist/shared/{url-DTgkCWv5.cjs → url-ioIaywDi.cjs} +42 -11
- package/dist/shared/url-ioIaywDi.cjs.map +1 -0
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +4 -5
- package/dist/web/index.d.ts +4 -5
- package/dist/web/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/shared/events-C6tmj8aW.cjs.map +0 -1
- package/dist/shared/events-MWNcnfrq.js.map +0 -1
- package/dist/shared/multi-storage-BLBrGN9Q.js.map +0 -1
- package/dist/shared/multi-storage-C7-Gz6Z7.cjs.map +0 -1
- package/dist/shared/redact-C5oxIvcc.js.map +0 -1
- package/dist/shared/redact-DoC7lSsp.cjs.map +0 -1
- package/dist/shared/render-DRh5_aRe.js.map +0 -1
- package/dist/shared/render-Dnc84B4M.cjs.map +0 -1
- package/dist/shared/url-Bg61sk_Y.js.map +0 -1
- package/dist/shared/url-DTgkCWv5.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as pickArray, K as createClientRuntime, L as ITD_CATALOG, Q as pickString, X as pickNumber, _t as systemClock, i as bearerToken, l as readNotificationEvent, o as passthroughOperation, r as anonymousAuth, u as readUnreadCountEvent, vt as installAsyncDisposeFallback, y as EventChannelStatus } from "./url-CdT4lMxQ.js";
|
|
2
2
|
import { E as isItdAuthError, a as ItdAbortError, l as ItdConfigError, x as ItdStateError } from "./validate-D7_kq3g5.js";
|
|
3
|
-
import { D as fallbackLogger, T as supportsStreamingBody, a as redactUrl, d as buildQuery, h as joinUrl, t as maskSecret } from "./redact-
|
|
3
|
+
import { D as fallbackLogger, T as supportsStreamingBody, a as redactUrl, d as buildQuery, h as joinUrl, t as maskSecret } from "./redact-DSfdmeY7.js";
|
|
4
4
|
//#region src/core/emitter.ts
|
|
5
5
|
/**
|
|
6
6
|
* Минимальный типизированный источник событий.
|
|
@@ -912,82 +912,228 @@ var PollTransport = class {
|
|
|
912
912
|
}
|
|
913
913
|
};
|
|
914
914
|
//#endregion
|
|
915
|
-
//#region node_modules/eventsource-parser/dist/
|
|
915
|
+
//#region node_modules/eventsource-parser/dist/errors.js
|
|
916
|
+
/**
|
|
917
|
+
* Error thrown when encountering an issue during parsing.
|
|
918
|
+
*
|
|
919
|
+
* @public
|
|
920
|
+
*/
|
|
916
921
|
var ParseError = class extends Error {
|
|
917
922
|
constructor(message, options) {
|
|
918
|
-
super(message)
|
|
923
|
+
super(message);
|
|
924
|
+
this.name = "ParseError";
|
|
925
|
+
this.type = options.type;
|
|
926
|
+
this.field = options.field;
|
|
927
|
+
this.value = options.value;
|
|
928
|
+
this.line = options.line;
|
|
919
929
|
}
|
|
920
930
|
};
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region node_modules/eventsource-parser/dist/parse.js
|
|
933
|
+
/**
|
|
934
|
+
* EventSource/Server-Sent Events parser
|
|
935
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
936
|
+
*/
|
|
921
937
|
const LF = 10;
|
|
922
938
|
const CR = 13;
|
|
923
939
|
const SPACE = 32;
|
|
924
|
-
|
|
940
|
+
const MAX_FIELD_PREFIX_LENGTH = 6;
|
|
941
|
+
/**
|
|
942
|
+
* Creates a new EventSource parser.
|
|
943
|
+
*
|
|
944
|
+
* @param config - Parser configuration. Accepts callbacks (see {@link ParserCallbacks})
|
|
945
|
+
* and options like `maxBufferSize` (see {@link ParserConfig}).
|
|
946
|
+
*
|
|
947
|
+
* @returns A new EventSource parser, with `feed` and `reset` methods.
|
|
948
|
+
* @public
|
|
949
|
+
*/
|
|
925
950
|
function createParser(config) {
|
|
926
|
-
if (typeof config
|
|
927
|
-
const {
|
|
928
|
-
|
|
951
|
+
if (typeof config === "function") throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
|
|
952
|
+
const { maxBufferSize, onComment, onError, onEvent, onId, onRetry } = config;
|
|
953
|
+
const pendingFragments = [];
|
|
954
|
+
let pendingFragmentsLength = 0;
|
|
955
|
+
let bomPrefix = "";
|
|
956
|
+
let id;
|
|
957
|
+
let data = "";
|
|
958
|
+
let dataLines = 0;
|
|
959
|
+
let eventType;
|
|
960
|
+
let terminated = false;
|
|
961
|
+
let skippingLine = false;
|
|
962
|
+
let skipNextLineFeed = false;
|
|
963
|
+
/**
|
|
964
|
+
* Feeds a chunk of the SSE stream to the parser. Any trailing bytes that do
|
|
965
|
+
* not yet form a complete line are held back and prepended to the next chunk,
|
|
966
|
+
* so callers can pass arbitrary slices of the stream without worrying about
|
|
967
|
+
* line boundaries.
|
|
968
|
+
*
|
|
969
|
+
* Per the SSE spec, one leading UTF-8 BOM is stripped before parsing,
|
|
970
|
+
* even when split across chunks. This handles both the raw 3-byte form (0xEF 0xBB
|
|
971
|
+
* 0xBF) and a single decoded U+FEFF, so a leading BOM is ignored regardless of
|
|
972
|
+
* how the caller decoded the bytes.
|
|
973
|
+
*
|
|
974
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
|
|
975
|
+
*/
|
|
929
976
|
function feed(chunk) {
|
|
930
977
|
if (terminated) throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
|
|
931
|
-
if (
|
|
932
|
-
|
|
933
|
-
|
|
978
|
+
if (bomPrefix !== void 0) {
|
|
979
|
+
chunk = bomPrefix + chunk;
|
|
980
|
+
if (chunk === "" || chunk === "ï" || chunk === "ï»") {
|
|
981
|
+
bomPrefix = chunk;
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
bomPrefix = void 0;
|
|
985
|
+
chunk = chunk.replace(/^(?:\uFEFF|\xEF\xBB\xBF)/, "");
|
|
986
|
+
}
|
|
987
|
+
if (skippingLine || skipNextLineFeed) {
|
|
988
|
+
chunk = resumeAfterSkip(chunk);
|
|
989
|
+
if (!chunk) return;
|
|
990
|
+
}
|
|
991
|
+
if (!pendingFragments.length) {
|
|
992
|
+
const trailing = processLines(chunk);
|
|
993
|
+
if (trailing !== "") storeTrailing(trailing);
|
|
994
|
+
checkBufferSize();
|
|
934
995
|
return;
|
|
935
996
|
}
|
|
936
|
-
if (chunk.indexOf(
|
|
937
|
-
|
|
938
|
-
|
|
997
|
+
if (chunk.indexOf("\n") === -1 && chunk.indexOf("\r") === -1) {
|
|
998
|
+
if (pendingFragmentsLength < MAX_FIELD_PREFIX_LENGTH) {
|
|
999
|
+
if (!shouldBufferTrailing(pendingFragments.join("") + chunk.slice(0, MAX_FIELD_PREFIX_LENGTH - pendingFragmentsLength))) {
|
|
1000
|
+
pendingFragments.length = 0;
|
|
1001
|
+
pendingFragmentsLength = 0;
|
|
1002
|
+
skippingLine = true;
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
pendingFragments.push(chunk);
|
|
1007
|
+
pendingFragmentsLength += chunk.length;
|
|
1008
|
+
checkBufferSize();
|
|
939
1009
|
return;
|
|
940
1010
|
}
|
|
941
1011
|
pendingFragments.push(chunk);
|
|
942
1012
|
const input = pendingFragments.join("");
|
|
943
|
-
pendingFragments.length = 0
|
|
944
|
-
|
|
945
|
-
|
|
1013
|
+
pendingFragments.length = 0;
|
|
1014
|
+
pendingFragmentsLength = 0;
|
|
1015
|
+
storeTrailing(processLines(input));
|
|
1016
|
+
checkBufferSize();
|
|
1017
|
+
}
|
|
1018
|
+
function resumeAfterSkip(chunk) {
|
|
1019
|
+
if (chunk.length === 0) return chunk;
|
|
1020
|
+
if (skipNextLineFeed) {
|
|
1021
|
+
skipNextLineFeed = false;
|
|
1022
|
+
return chunk.charCodeAt(0) === LF ? chunk.slice(1) : chunk;
|
|
1023
|
+
}
|
|
1024
|
+
const crIndex = chunk.indexOf("\r");
|
|
1025
|
+
const lfIndex = chunk.indexOf("\n");
|
|
1026
|
+
const lineEnd = crIndex === -1 ? lfIndex : lfIndex === -1 ? crIndex : crIndex < lfIndex ? crIndex : lfIndex;
|
|
1027
|
+
if (lineEnd === -1) return "";
|
|
1028
|
+
if (lineEnd === chunk.length - 1 && chunk.charCodeAt(lineEnd) === CR) {
|
|
1029
|
+
skippingLine = false;
|
|
1030
|
+
skipNextLineFeed = true;
|
|
1031
|
+
return "";
|
|
1032
|
+
}
|
|
1033
|
+
skippingLine = false;
|
|
1034
|
+
return chunk.slice(lineEnd + (chunk.charCodeAt(lineEnd) === CR && chunk.charCodeAt(lineEnd + 1) === LF ? 2 : 1));
|
|
1035
|
+
}
|
|
1036
|
+
function storeTrailing(trailing) {
|
|
1037
|
+
if (!trailing) return;
|
|
1038
|
+
if (trailing.charCodeAt(trailing.length - 1) === CR) {
|
|
1039
|
+
parseLine(trailing, 0, trailing.length - 1);
|
|
1040
|
+
skipNextLineFeed = true;
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
if (shouldBufferTrailing(trailing)) {
|
|
1044
|
+
pendingFragments.push(trailing);
|
|
1045
|
+
pendingFragmentsLength = trailing.length;
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
skippingLine = true;
|
|
1049
|
+
}
|
|
1050
|
+
function shouldBufferTrailing(trailing) {
|
|
1051
|
+
const firstCharCode = trailing.charCodeAt(0);
|
|
1052
|
+
return firstCharCode === 58 && !!onComment || firstCharCode === 100 && isPotentialField(trailing, "data") || firstCharCode === 101 && isPotentialField(trailing, "event") || firstCharCode === 105 && isPotentialField(trailing, "id") || firstCharCode === 114 && isPotentialField(trailing, "retry");
|
|
946
1053
|
}
|
|
947
1054
|
function checkBufferSize() {
|
|
948
|
-
|
|
1055
|
+
if (maxBufferSize === void 0) return;
|
|
1056
|
+
if (pendingFragmentsLength + data.length <= maxBufferSize) return;
|
|
1057
|
+
terminated = true;
|
|
1058
|
+
pendingFragments.length = 0;
|
|
1059
|
+
pendingFragmentsLength = 0;
|
|
1060
|
+
id = void 0;
|
|
1061
|
+
data = "";
|
|
1062
|
+
dataLines = 0;
|
|
1063
|
+
eventType = void 0;
|
|
1064
|
+
skippingLine = false;
|
|
1065
|
+
skipNextLineFeed = false;
|
|
1066
|
+
onError === null || onError === void 0 || onError(new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, { type: "max-buffer-size-exceeded" }));
|
|
949
1067
|
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Splits `chunk` into SSE lines and dispatches each to the appropriate handler.
|
|
1070
|
+
* Returns any trailing bytes that did not terminate with a line break, so the
|
|
1071
|
+
* caller can prepend them to the next chunk.
|
|
1072
|
+
*
|
|
1073
|
+
* The SSE spec permits three line terminators: `\n`, `\r`, and `\r\n`. Real-world
|
|
1074
|
+
* streams almost always use plain `\n`, so we take a fast path when no `\r` is
|
|
1075
|
+
* present in the chunk. The slow path is spec-correct but does more work per line.
|
|
1076
|
+
*/
|
|
950
1077
|
function processLines(chunk) {
|
|
951
1078
|
let searchIndex = 0;
|
|
952
1079
|
if (chunk.indexOf("\r") === -1) {
|
|
953
|
-
let lfIndex = chunk.indexOf(
|
|
954
|
-
|
|
955
|
-
for (; lfIndex !== -1;) {
|
|
1080
|
+
let lfIndex = chunk.indexOf("\n", searchIndex);
|
|
1081
|
+
while (lfIndex !== -1) {
|
|
956
1082
|
if (searchIndex === lfIndex) {
|
|
957
|
-
|
|
1083
|
+
if (id !== void 0) onId === null || onId === void 0 || onId(id);
|
|
1084
|
+
if (dataLines > 0) onEvent === null || onEvent === void 0 || onEvent({
|
|
958
1085
|
id,
|
|
959
1086
|
event: eventType,
|
|
960
1087
|
data
|
|
961
|
-
})
|
|
962
|
-
|
|
1088
|
+
});
|
|
1089
|
+
id = void 0;
|
|
1090
|
+
data = "";
|
|
1091
|
+
dataLines = 0;
|
|
1092
|
+
eventType = void 0;
|
|
1093
|
+
searchIndex = lfIndex + 1;
|
|
1094
|
+
lfIndex = chunk.indexOf("\n", searchIndex);
|
|
963
1095
|
continue;
|
|
964
1096
|
}
|
|
965
1097
|
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
966
1098
|
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
967
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5
|
|
1099
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5;
|
|
1100
|
+
const value = chunk.slice(valueStart, lfIndex);
|
|
968
1101
|
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
969
|
-
|
|
1102
|
+
if (id !== void 0) onId === null || onId === void 0 || onId(id);
|
|
1103
|
+
onEvent === null || onEvent === void 0 || onEvent({
|
|
970
1104
|
id,
|
|
971
1105
|
event: eventType,
|
|
972
1106
|
data: value
|
|
973
|
-
})
|
|
974
|
-
|
|
1107
|
+
});
|
|
1108
|
+
id = void 0;
|
|
1109
|
+
data = "";
|
|
1110
|
+
eventType = void 0;
|
|
1111
|
+
searchIndex = lfIndex + 2;
|
|
1112
|
+
lfIndex = chunk.indexOf("\n", searchIndex);
|
|
975
1113
|
continue;
|
|
976
1114
|
}
|
|
977
|
-
data = dataLines === 0 ? value : `${data}
|
|
978
|
-
|
|
979
|
-
} else isEventPrefix(chunk, searchIndex, firstCharCode)
|
|
980
|
-
|
|
981
|
-
|
|
1115
|
+
data = dataLines === 0 ? value : `${data}\n${value}`;
|
|
1116
|
+
dataLines++;
|
|
1117
|
+
} else if (isEventPrefix(chunk, searchIndex, firstCharCode)) eventType = chunk.slice(chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6, lfIndex) || void 0;
|
|
1118
|
+
else parseLine(chunk, searchIndex, lfIndex);
|
|
1119
|
+
searchIndex = lfIndex + 1;
|
|
1120
|
+
lfIndex = chunk.indexOf("\n", searchIndex);
|
|
982
1121
|
}
|
|
983
1122
|
return chunk.slice(searchIndex);
|
|
984
1123
|
}
|
|
985
|
-
|
|
986
|
-
const crIndex = chunk.indexOf("\r", searchIndex)
|
|
987
|
-
|
|
1124
|
+
while (searchIndex < chunk.length) {
|
|
1125
|
+
const crIndex = chunk.indexOf("\r", searchIndex);
|
|
1126
|
+
const lfIndex = chunk.indexOf("\n", searchIndex);
|
|
988
1127
|
let lineEnd = -1;
|
|
989
|
-
if (crIndex !== -1 && lfIndex !== -1
|
|
990
|
-
|
|
1128
|
+
if (crIndex !== -1 && lfIndex !== -1) lineEnd = crIndex < lfIndex ? crIndex : lfIndex;
|
|
1129
|
+
else if (crIndex !== -1) {
|
|
1130
|
+
if (crIndex === chunk.length - 1) lineEnd = -1;
|
|
1131
|
+
else lineEnd = crIndex;
|
|
1132
|
+
} else if (lfIndex !== -1) lineEnd = lfIndex;
|
|
1133
|
+
if (lineEnd === -1) break;
|
|
1134
|
+
parseLine(chunk, searchIndex, lineEnd);
|
|
1135
|
+
searchIndex = lineEnd + 1;
|
|
1136
|
+
if (chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF) searchIndex++;
|
|
991
1137
|
}
|
|
992
1138
|
return chunk.slice(searchIndex);
|
|
993
1139
|
}
|
|
@@ -998,9 +1144,10 @@ ${value}`, dataLines++;
|
|
|
998
1144
|
}
|
|
999
1145
|
const firstCharCode = chunk.charCodeAt(start);
|
|
1000
1146
|
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
1001
|
-
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5
|
|
1002
|
-
|
|
1003
|
-
${
|
|
1147
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5;
|
|
1148
|
+
const value = chunk.slice(valueStart, end);
|
|
1149
|
+
data = dataLines === 0 ? value : `${data}\n${value}`;
|
|
1150
|
+
dataLines++;
|
|
1004
1151
|
return;
|
|
1005
1152
|
}
|
|
1006
1153
|
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
@@ -1008,23 +1155,25 @@ ${value2}`, dataLines++;
|
|
|
1008
1155
|
return;
|
|
1009
1156
|
}
|
|
1010
1157
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1158
|
+
const value = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
1159
|
+
if (!value.includes("\0")) id = value;
|
|
1013
1160
|
return;
|
|
1014
1161
|
}
|
|
1015
1162
|
if (firstCharCode === 58) {
|
|
1016
1163
|
if (onComment) {
|
|
1017
|
-
const
|
|
1018
|
-
onComment(
|
|
1164
|
+
const line = chunk.slice(start, end);
|
|
1165
|
+
onComment(line.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
1019
1166
|
}
|
|
1020
1167
|
return;
|
|
1021
1168
|
}
|
|
1022
|
-
const line = chunk.slice(start, end)
|
|
1169
|
+
const line = chunk.slice(start, end);
|
|
1170
|
+
const fieldSeparatorIndex = line.indexOf(":");
|
|
1023
1171
|
if (fieldSeparatorIndex === -1) {
|
|
1024
1172
|
processField(line, "", line);
|
|
1025
1173
|
return;
|
|
1026
1174
|
}
|
|
1027
|
-
const field = line.slice(0, fieldSeparatorIndex)
|
|
1175
|
+
const field = line.slice(0, fieldSeparatorIndex);
|
|
1176
|
+
const offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1;
|
|
1028
1177
|
processField(field, line.slice(fieldSeparatorIndex + offset), line);
|
|
1029
1178
|
}
|
|
1030
1179
|
function processField(field, value, line) {
|
|
@@ -1033,20 +1182,21 @@ ${value2}`, dataLines++;
|
|
|
1033
1182
|
eventType = value || void 0;
|
|
1034
1183
|
break;
|
|
1035
1184
|
case "data":
|
|
1036
|
-
data = dataLines === 0 ? value : `${data}
|
|
1037
|
-
|
|
1185
|
+
data = dataLines === 0 ? value : `${data}\n${value}`;
|
|
1186
|
+
dataLines++;
|
|
1038
1187
|
break;
|
|
1039
1188
|
case "id":
|
|
1040
|
-
value.includes("\0")
|
|
1189
|
+
if (!value.includes("\0")) id = value;
|
|
1041
1190
|
break;
|
|
1042
1191
|
case "retry":
|
|
1043
|
-
/^\d+$/.test(value)
|
|
1192
|
+
if (/^\d+$/.test(value)) onRetry === null || onRetry === void 0 || onRetry(parseInt(value, 10));
|
|
1193
|
+
else onError === null || onError === void 0 || onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
1044
1194
|
type: "invalid-retry",
|
|
1045
1195
|
value,
|
|
1046
1196
|
line
|
|
1047
1197
|
}));
|
|
1048
1198
|
break;
|
|
1049
|
-
default: onError(new ParseError(`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}
|
|
1199
|
+
default: onError === null || onError === void 0 || onError(new ParseError(`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}…` : field}"`, {
|
|
1050
1200
|
type: "unknown-field",
|
|
1051
1201
|
field,
|
|
1052
1202
|
value,
|
|
@@ -1055,30 +1205,70 @@ ${value}`, dataLines++;
|
|
|
1055
1205
|
}
|
|
1056
1206
|
}
|
|
1057
1207
|
function dispatchEvent() {
|
|
1058
|
-
|
|
1208
|
+
if (id !== void 0) onId === null || onId === void 0 || onId(id);
|
|
1209
|
+
if (dataLines > 0) onEvent === null || onEvent === void 0 || onEvent({
|
|
1059
1210
|
id,
|
|
1060
1211
|
event: eventType,
|
|
1061
1212
|
data
|
|
1062
|
-
})
|
|
1213
|
+
});
|
|
1214
|
+
id = void 0;
|
|
1215
|
+
data = "";
|
|
1216
|
+
dataLines = 0;
|
|
1217
|
+
eventType = void 0;
|
|
1063
1218
|
}
|
|
1064
1219
|
function reset(options = {}) {
|
|
1065
1220
|
if (options.consume && pendingFragments.length > 0) {
|
|
1066
1221
|
const incompleteLine = pendingFragments.join("");
|
|
1067
1222
|
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
1068
1223
|
}
|
|
1069
|
-
|
|
1224
|
+
bomPrefix = "";
|
|
1225
|
+
id = void 0;
|
|
1226
|
+
data = "";
|
|
1227
|
+
dataLines = 0;
|
|
1228
|
+
eventType = void 0;
|
|
1229
|
+
pendingFragments.length = 0;
|
|
1230
|
+
pendingFragmentsLength = 0;
|
|
1231
|
+
terminated = false;
|
|
1232
|
+
skippingLine = false;
|
|
1233
|
+
skipNextLineFeed = false;
|
|
1070
1234
|
}
|
|
1071
1235
|
return {
|
|
1072
1236
|
feed,
|
|
1073
1237
|
reset
|
|
1074
1238
|
};
|
|
1075
1239
|
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Checks if `chunk` starts with the literal `data:` at index `i`.
|
|
1242
|
+
*
|
|
1243
|
+
* Equivalent to `chunk.startsWith('data:', i)`, but benchmarks show this
|
|
1244
|
+
* hand-unrolled char-code comparison is ~20% faster on common event types.
|
|
1245
|
+
* The caller passes `firstCharCode` (the code at `i`) so it can be reused
|
|
1246
|
+
* across prefix checks.
|
|
1247
|
+
*
|
|
1248
|
+
* ASCII: 'd' = 100, 'a' = 97, 't' = 116, 'a' = 97, ':' = 58
|
|
1249
|
+
*/
|
|
1076
1250
|
function isDataPrefix(chunk, i, firstCharCode) {
|
|
1077
1251
|
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
1078
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Checks if `chunk` starts with the literal `event:` at index `i`.
|
|
1255
|
+
*
|
|
1256
|
+
* See {@link isDataPrefix} for why this is hand-unrolled rather than using
|
|
1257
|
+
* `String.prototype.startsWith`.
|
|
1258
|
+
*
|
|
1259
|
+
* ASCII: 'e' = 101, 'v' = 118, 'e' = 101, 'n' = 110, 't' = 116, ':' = 58
|
|
1260
|
+
*/
|
|
1079
1261
|
function isEventPrefix(chunk, i, firstCharCode) {
|
|
1080
1262
|
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
1081
1263
|
}
|
|
1264
|
+
function isPotentialField(line, field) {
|
|
1265
|
+
let i = 1;
|
|
1266
|
+
while (i < line.length && i < field.length) {
|
|
1267
|
+
if (line.charCodeAt(i) !== field.charCodeAt(i)) return false;
|
|
1268
|
+
i++;
|
|
1269
|
+
}
|
|
1270
|
+
return line.length <= field.length || line.charCodeAt(field.length) === 58;
|
|
1271
|
+
}
|
|
1082
1272
|
//#endregion
|
|
1083
1273
|
//#region src/events/transports/sse.ts
|
|
1084
1274
|
/** Путь потока уведомлений. */
|
|
@@ -2155,4 +2345,4 @@ var EventComposer = class EventComposer {
|
|
|
2155
2345
|
//#endregion
|
|
2156
2346
|
export { Emitter as _, WebSocketTransport as a, NotificationEventsTransport as c, NotificationUpdateOrigin as d, NotificationUpdateType as f, runEventMiddleware as g, UnauthorizedStreamError as h, createNotificationEventsClient as i, resolveNotificationEventsOptions as l, EventChannel as m, EventRouter as n, EVENT_OPERATIONS as o, createParser as p, NotificationEventsClient as r, NotificationEvents as s, EventComposer as t, setNotificationEventsConnectGuard as u, reportListenerError as v };
|
|
2157
2347
|
|
|
2158
|
-
//# sourceMappingURL=events-
|
|
2348
|
+
//# sourceMappingURL=events-_iYo8EP5.js.map
|