@deadair/sdk 0.87.4 → 0.87.5
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/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/sdk-options.d.ts +6 -2
- package/dist/sdk-options.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -100,7 +100,7 @@ function sseRequestHeaders(options) {
|
|
|
100
100
|
const headers = {
|
|
101
101
|
Accept: "text/event-stream"
|
|
102
102
|
};
|
|
103
|
-
if (options?.lastEventId
|
|
103
|
+
if (options?.lastEventId) headers["Last-Event-ID"] = options.lastEventId;
|
|
104
104
|
return headers;
|
|
105
105
|
}
|
|
106
106
|
__name(sseRequestHeaders, "sseRequestHeaders");
|
|
@@ -112,6 +112,7 @@ function parseSse(res, parse = (data) => JSON.parse(data)) {
|
|
|
112
112
|
const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
113
113
|
let buffer = "";
|
|
114
114
|
let data = [];
|
|
115
|
+
let idBuffer;
|
|
115
116
|
try {
|
|
116
117
|
for (; ; ) {
|
|
117
118
|
const chunk = await reader.read();
|
|
@@ -122,6 +123,7 @@ function parseSse(res, parse = (data) => JSON.parse(data)) {
|
|
|
122
123
|
const line = buffer.slice(0, end);
|
|
123
124
|
buffer = buffer.slice(buffer.startsWith("\r\n", end) ? end + 2 : end + 1);
|
|
124
125
|
if (line === "") {
|
|
126
|
+
lastEventId = idBuffer;
|
|
125
127
|
if (data.length > 0) yield parse(data.join("\n"));
|
|
126
128
|
data = [];
|
|
127
129
|
continue;
|
|
@@ -130,7 +132,7 @@ function parseSse(res, parse = (data) => JSON.parse(data)) {
|
|
|
130
132
|
const field = colon === -1 ? line : line.slice(0, colon);
|
|
131
133
|
const value = colon === -1 ? "" : line.slice(line.startsWith(" ", colon + 1) ? colon + 2 : colon + 1);
|
|
132
134
|
if (field === "data") data.push(value);
|
|
133
|
-
else if (field === "id" && !value.includes("\0"))
|
|
135
|
+
else if (field === "id" && !value.includes("\0")) idBuffer = value;
|
|
134
136
|
}
|
|
135
137
|
if (chunk.done) return;
|
|
136
138
|
}
|