@langchain/langgraph-sdk 0.0.38 → 0.0.40
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/client.cjs +10 -67
- package/dist/client.d.ts +18 -23
- package/dist/client.js +10 -67
- package/dist/index.d.ts +3 -0
- package/dist/react/debug.cjs +32 -0
- package/dist/react/debug.d.ts +23 -0
- package/dist/react/debug.js +28 -0
- package/dist/react/index.cjs +5 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/stream.cjs +411 -0
- package/dist/react/stream.d.ts +46 -0
- package/dist/react/stream.js +407 -0
- package/dist/types.d.ts +6 -16
- package/dist/types.messages.d.ts +88 -0
- package/dist/types.stream.cjs +2 -0
- package/dist/types.stream.d.ts +156 -0
- package/dist/types.stream.js +1 -0
- package/dist/utils/async_caller.cjs +2 -1
- package/dist/utils/async_caller.js +2 -1
- package/dist/utils/sse.cjs +157 -0
- package/dist/utils/sse.d.ts +11 -0
- package/dist/utils/sse.js +152 -0
- package/package.json +23 -3
- package/react.cjs +1 -0
- package/react.d.cts +1 -0
- package/react.d.ts +1 -0
- package/react.js +1 -0
- package/dist/utils/eventsource-parser/index.cjs +0 -7
- package/dist/utils/eventsource-parser/index.d.ts +0 -2
- package/dist/utils/eventsource-parser/index.js +0 -3
- package/dist/utils/eventsource-parser/parse.cjs +0 -150
- package/dist/utils/eventsource-parser/parse.d.ts +0 -18
- package/dist/utils/eventsource-parser/parse.js +0 -146
- package/dist/utils/eventsource-parser/stream.cjs +0 -34
- package/dist/utils/eventsource-parser/stream.d.ts +0 -17
- package/dist/utils/eventsource-parser/stream.js +0 -30
- package/dist/utils/eventsource-parser/types.d.ts +0 -81
- /package/dist/{utils/eventsource-parser/types.cjs → types.messages.cjs} +0 -0
- /package/dist/{utils/eventsource-parser/types.js → types.messages.js} +0 -0
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createParser = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Creates a new EventSource parser.
|
|
6
|
-
*
|
|
7
|
-
* @param onParse - Callback to invoke when a new event is parsed, or a new reconnection interval
|
|
8
|
-
* has been sent from the server
|
|
9
|
-
*
|
|
10
|
-
* @returns A new EventSource parser, with `parse` and `reset` methods.
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
function createParser(onParse) {
|
|
14
|
-
// Processing state
|
|
15
|
-
let isFirstChunk;
|
|
16
|
-
let buffer;
|
|
17
|
-
let startingPosition;
|
|
18
|
-
let startingFieldLength;
|
|
19
|
-
// Event state
|
|
20
|
-
let eventId;
|
|
21
|
-
let eventName;
|
|
22
|
-
let data;
|
|
23
|
-
reset();
|
|
24
|
-
return { feed, reset };
|
|
25
|
-
function reset() {
|
|
26
|
-
isFirstChunk = true;
|
|
27
|
-
buffer = "";
|
|
28
|
-
startingPosition = 0;
|
|
29
|
-
startingFieldLength = -1;
|
|
30
|
-
eventId = undefined;
|
|
31
|
-
eventName = undefined;
|
|
32
|
-
data = "";
|
|
33
|
-
}
|
|
34
|
-
function feed(chunk) {
|
|
35
|
-
buffer = buffer ? buffer + chunk : chunk;
|
|
36
|
-
// Strip any UTF8 byte order mark (BOM) at the start of the stream.
|
|
37
|
-
// Note that we do not strip any non - UTF8 BOM, as eventsource streams are
|
|
38
|
-
// always decoded as UTF8 as per the specification.
|
|
39
|
-
if (isFirstChunk && hasBom(buffer)) {
|
|
40
|
-
buffer = buffer.slice(BOM.length);
|
|
41
|
-
}
|
|
42
|
-
isFirstChunk = false;
|
|
43
|
-
// Set up chunk-specific processing state
|
|
44
|
-
const length = buffer.length;
|
|
45
|
-
let position = 0;
|
|
46
|
-
let discardTrailingNewline = false;
|
|
47
|
-
// Read the current buffer byte by byte
|
|
48
|
-
while (position < length) {
|
|
49
|
-
// EventSource allows for carriage return + line feed, which means we
|
|
50
|
-
// need to ignore a linefeed character if the previous character was a
|
|
51
|
-
// carriage return
|
|
52
|
-
// @todo refactor to reduce nesting, consider checking previous byte?
|
|
53
|
-
// @todo but consider multiple chunks etc
|
|
54
|
-
if (discardTrailingNewline) {
|
|
55
|
-
if (buffer[position] === "\n") {
|
|
56
|
-
++position;
|
|
57
|
-
}
|
|
58
|
-
discardTrailingNewline = false;
|
|
59
|
-
}
|
|
60
|
-
let lineLength = -1;
|
|
61
|
-
let fieldLength = startingFieldLength;
|
|
62
|
-
let character;
|
|
63
|
-
for (let index = startingPosition; lineLength < 0 && index < length; ++index) {
|
|
64
|
-
character = buffer[index];
|
|
65
|
-
if (character === ":" && fieldLength < 0) {
|
|
66
|
-
fieldLength = index - position;
|
|
67
|
-
}
|
|
68
|
-
else if (character === "\r") {
|
|
69
|
-
discardTrailingNewline = true;
|
|
70
|
-
lineLength = index - position;
|
|
71
|
-
}
|
|
72
|
-
else if (character === "\n") {
|
|
73
|
-
lineLength = index - position;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (lineLength < 0) {
|
|
77
|
-
startingPosition = length - position;
|
|
78
|
-
startingFieldLength = fieldLength;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
startingPosition = 0;
|
|
83
|
-
startingFieldLength = -1;
|
|
84
|
-
}
|
|
85
|
-
parseEventStreamLine(buffer, position, fieldLength, lineLength);
|
|
86
|
-
position += lineLength + 1;
|
|
87
|
-
}
|
|
88
|
-
if (position === length) {
|
|
89
|
-
// If we consumed the entire buffer to read the event, reset the buffer
|
|
90
|
-
buffer = "";
|
|
91
|
-
}
|
|
92
|
-
else if (position > 0) {
|
|
93
|
-
// If there are bytes left to process, set the buffer to the unprocessed
|
|
94
|
-
// portion of the buffer only
|
|
95
|
-
buffer = buffer.slice(position);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
|
|
99
|
-
if (lineLength === 0) {
|
|
100
|
-
// We reached the last line of this event
|
|
101
|
-
if (data.length > 0) {
|
|
102
|
-
onParse({
|
|
103
|
-
type: "event",
|
|
104
|
-
id: eventId,
|
|
105
|
-
event: eventName || undefined,
|
|
106
|
-
data: data.slice(0, -1), // remove trailing newline
|
|
107
|
-
});
|
|
108
|
-
data = "";
|
|
109
|
-
eventId = undefined;
|
|
110
|
-
}
|
|
111
|
-
eventName = undefined;
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const noValue = fieldLength < 0;
|
|
115
|
-
const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
|
|
116
|
-
let step = 0;
|
|
117
|
-
if (noValue) {
|
|
118
|
-
step = lineLength;
|
|
119
|
-
}
|
|
120
|
-
else if (lineBuffer[index + fieldLength + 1] === " ") {
|
|
121
|
-
step = fieldLength + 2;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
step = fieldLength + 1;
|
|
125
|
-
}
|
|
126
|
-
const position = index + step;
|
|
127
|
-
const valueLength = lineLength - step;
|
|
128
|
-
const value = lineBuffer.slice(position, position + valueLength).toString();
|
|
129
|
-
if (field === "data") {
|
|
130
|
-
data += value ? `${value}\n` : "\n";
|
|
131
|
-
}
|
|
132
|
-
else if (field === "event") {
|
|
133
|
-
eventName = value;
|
|
134
|
-
}
|
|
135
|
-
else if (field === "id" && !value.includes("\u0000")) {
|
|
136
|
-
eventId = value;
|
|
137
|
-
}
|
|
138
|
-
else if (field === "retry") {
|
|
139
|
-
const retry = parseInt(value, 10);
|
|
140
|
-
if (!Number.isNaN(retry)) {
|
|
141
|
-
onParse({ type: "reconnect-interval", value: retry });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.createParser = createParser;
|
|
147
|
-
const BOM = [239, 187, 191];
|
|
148
|
-
function hasBom(buffer) {
|
|
149
|
-
return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
|
|
150
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EventSource/Server-Sent Events parser
|
|
3
|
-
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
4
|
-
*
|
|
5
|
-
* Based on code from the {@link https://github.com/EventSource/eventsource | EventSource module},
|
|
6
|
-
* which is licensed under the MIT license. And copyrighted the EventSource GitHub organisation.
|
|
7
|
-
*/
|
|
8
|
-
import type { EventSourceParseCallback, EventSourceParser } from "./types.js";
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new EventSource parser.
|
|
11
|
-
*
|
|
12
|
-
* @param onParse - Callback to invoke when a new event is parsed, or a new reconnection interval
|
|
13
|
-
* has been sent from the server
|
|
14
|
-
*
|
|
15
|
-
* @returns A new EventSource parser, with `parse` and `reset` methods.
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export declare function createParser(onParse: EventSourceParseCallback): EventSourceParser;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new EventSource parser.
|
|
3
|
-
*
|
|
4
|
-
* @param onParse - Callback to invoke when a new event is parsed, or a new reconnection interval
|
|
5
|
-
* has been sent from the server
|
|
6
|
-
*
|
|
7
|
-
* @returns A new EventSource parser, with `parse` and `reset` methods.
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export function createParser(onParse) {
|
|
11
|
-
// Processing state
|
|
12
|
-
let isFirstChunk;
|
|
13
|
-
let buffer;
|
|
14
|
-
let startingPosition;
|
|
15
|
-
let startingFieldLength;
|
|
16
|
-
// Event state
|
|
17
|
-
let eventId;
|
|
18
|
-
let eventName;
|
|
19
|
-
let data;
|
|
20
|
-
reset();
|
|
21
|
-
return { feed, reset };
|
|
22
|
-
function reset() {
|
|
23
|
-
isFirstChunk = true;
|
|
24
|
-
buffer = "";
|
|
25
|
-
startingPosition = 0;
|
|
26
|
-
startingFieldLength = -1;
|
|
27
|
-
eventId = undefined;
|
|
28
|
-
eventName = undefined;
|
|
29
|
-
data = "";
|
|
30
|
-
}
|
|
31
|
-
function feed(chunk) {
|
|
32
|
-
buffer = buffer ? buffer + chunk : chunk;
|
|
33
|
-
// Strip any UTF8 byte order mark (BOM) at the start of the stream.
|
|
34
|
-
// Note that we do not strip any non - UTF8 BOM, as eventsource streams are
|
|
35
|
-
// always decoded as UTF8 as per the specification.
|
|
36
|
-
if (isFirstChunk && hasBom(buffer)) {
|
|
37
|
-
buffer = buffer.slice(BOM.length);
|
|
38
|
-
}
|
|
39
|
-
isFirstChunk = false;
|
|
40
|
-
// Set up chunk-specific processing state
|
|
41
|
-
const length = buffer.length;
|
|
42
|
-
let position = 0;
|
|
43
|
-
let discardTrailingNewline = false;
|
|
44
|
-
// Read the current buffer byte by byte
|
|
45
|
-
while (position < length) {
|
|
46
|
-
// EventSource allows for carriage return + line feed, which means we
|
|
47
|
-
// need to ignore a linefeed character if the previous character was a
|
|
48
|
-
// carriage return
|
|
49
|
-
// @todo refactor to reduce nesting, consider checking previous byte?
|
|
50
|
-
// @todo but consider multiple chunks etc
|
|
51
|
-
if (discardTrailingNewline) {
|
|
52
|
-
if (buffer[position] === "\n") {
|
|
53
|
-
++position;
|
|
54
|
-
}
|
|
55
|
-
discardTrailingNewline = false;
|
|
56
|
-
}
|
|
57
|
-
let lineLength = -1;
|
|
58
|
-
let fieldLength = startingFieldLength;
|
|
59
|
-
let character;
|
|
60
|
-
for (let index = startingPosition; lineLength < 0 && index < length; ++index) {
|
|
61
|
-
character = buffer[index];
|
|
62
|
-
if (character === ":" && fieldLength < 0) {
|
|
63
|
-
fieldLength = index - position;
|
|
64
|
-
}
|
|
65
|
-
else if (character === "\r") {
|
|
66
|
-
discardTrailingNewline = true;
|
|
67
|
-
lineLength = index - position;
|
|
68
|
-
}
|
|
69
|
-
else if (character === "\n") {
|
|
70
|
-
lineLength = index - position;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (lineLength < 0) {
|
|
74
|
-
startingPosition = length - position;
|
|
75
|
-
startingFieldLength = fieldLength;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
startingPosition = 0;
|
|
80
|
-
startingFieldLength = -1;
|
|
81
|
-
}
|
|
82
|
-
parseEventStreamLine(buffer, position, fieldLength, lineLength);
|
|
83
|
-
position += lineLength + 1;
|
|
84
|
-
}
|
|
85
|
-
if (position === length) {
|
|
86
|
-
// If we consumed the entire buffer to read the event, reset the buffer
|
|
87
|
-
buffer = "";
|
|
88
|
-
}
|
|
89
|
-
else if (position > 0) {
|
|
90
|
-
// If there are bytes left to process, set the buffer to the unprocessed
|
|
91
|
-
// portion of the buffer only
|
|
92
|
-
buffer = buffer.slice(position);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
|
|
96
|
-
if (lineLength === 0) {
|
|
97
|
-
// We reached the last line of this event
|
|
98
|
-
if (data.length > 0) {
|
|
99
|
-
onParse({
|
|
100
|
-
type: "event",
|
|
101
|
-
id: eventId,
|
|
102
|
-
event: eventName || undefined,
|
|
103
|
-
data: data.slice(0, -1), // remove trailing newline
|
|
104
|
-
});
|
|
105
|
-
data = "";
|
|
106
|
-
eventId = undefined;
|
|
107
|
-
}
|
|
108
|
-
eventName = undefined;
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const noValue = fieldLength < 0;
|
|
112
|
-
const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
|
|
113
|
-
let step = 0;
|
|
114
|
-
if (noValue) {
|
|
115
|
-
step = lineLength;
|
|
116
|
-
}
|
|
117
|
-
else if (lineBuffer[index + fieldLength + 1] === " ") {
|
|
118
|
-
step = fieldLength + 2;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
step = fieldLength + 1;
|
|
122
|
-
}
|
|
123
|
-
const position = index + step;
|
|
124
|
-
const valueLength = lineLength - step;
|
|
125
|
-
const value = lineBuffer.slice(position, position + valueLength).toString();
|
|
126
|
-
if (field === "data") {
|
|
127
|
-
data += value ? `${value}\n` : "\n";
|
|
128
|
-
}
|
|
129
|
-
else if (field === "event") {
|
|
130
|
-
eventName = value;
|
|
131
|
-
}
|
|
132
|
-
else if (field === "id" && !value.includes("\u0000")) {
|
|
133
|
-
eventId = value;
|
|
134
|
-
}
|
|
135
|
-
else if (field === "retry") {
|
|
136
|
-
const retry = parseInt(value, 10);
|
|
137
|
-
if (!Number.isNaN(retry)) {
|
|
138
|
-
onParse({ type: "reconnect-interval", value: retry });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const BOM = [239, 187, 191];
|
|
144
|
-
function hasBom(buffer) {
|
|
145
|
-
return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
|
|
146
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventSourceParserStream = void 0;
|
|
4
|
-
const parse_js_1 = require("./parse.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* A TransformStream that ingests a stream of strings and produces a stream of ParsedEvents.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```
|
|
10
|
-
* const eventStream =
|
|
11
|
-
* response.body
|
|
12
|
-
* .pipeThrough(new TextDecoderStream())
|
|
13
|
-
* .pipeThrough(new EventSourceParserStream())
|
|
14
|
-
* ```
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
class EventSourceParserStream extends TransformStream {
|
|
18
|
-
constructor() {
|
|
19
|
-
let parser;
|
|
20
|
-
super({
|
|
21
|
-
start(controller) {
|
|
22
|
-
parser = (0, parse_js_1.createParser)((event) => {
|
|
23
|
-
if (event.type === "event") {
|
|
24
|
-
controller.enqueue(event);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
transform(chunk) {
|
|
29
|
-
parser.feed(chunk);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.EventSourceParserStream = EventSourceParserStream;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ParsedEvent } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* A TransformStream that ingests a stream of strings and produces a stream of ParsedEvents.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```
|
|
7
|
-
* const eventStream =
|
|
8
|
-
* response.body
|
|
9
|
-
* .pipeThrough(new TextDecoderStream())
|
|
10
|
-
* .pipeThrough(new EventSourceParserStream())
|
|
11
|
-
* ```
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare class EventSourceParserStream extends TransformStream<string, ParsedEvent> {
|
|
15
|
-
constructor();
|
|
16
|
-
}
|
|
17
|
-
export type { ParsedEvent } from "./types.js";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createParser } from "./parse.js";
|
|
2
|
-
/**
|
|
3
|
-
* A TransformStream that ingests a stream of strings and produces a stream of ParsedEvents.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```
|
|
7
|
-
* const eventStream =
|
|
8
|
-
* response.body
|
|
9
|
-
* .pipeThrough(new TextDecoderStream())
|
|
10
|
-
* .pipeThrough(new EventSourceParserStream())
|
|
11
|
-
* ```
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export class EventSourceParserStream extends TransformStream {
|
|
15
|
-
constructor() {
|
|
16
|
-
let parser;
|
|
17
|
-
super({
|
|
18
|
-
start(controller) {
|
|
19
|
-
parser = createParser((event) => {
|
|
20
|
-
if (event.type === "event") {
|
|
21
|
-
controller.enqueue(event);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
transform(chunk) {
|
|
26
|
-
parser.feed(chunk);
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EventSource parser instance.
|
|
3
|
-
*
|
|
4
|
-
* Needs to be reset between reconnections/when switching data source, using the `reset()` method.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export interface EventSourceParser {
|
|
9
|
-
/**
|
|
10
|
-
* Feeds the parser another chunk. The method _does not_ return a parsed message.
|
|
11
|
-
* Instead, if the chunk was a complete message (or completed a previously incomplete message),
|
|
12
|
-
* it will invoke the `onParse` callback used to create the parsers.
|
|
13
|
-
*
|
|
14
|
-
* @param chunk - The chunk to parse. Can be a partial, eg in the case of streaming messages.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
feed(chunk: string): void;
|
|
18
|
-
/**
|
|
19
|
-
* Resets the parser state. This is required when you have a new stream of messages -
|
|
20
|
-
* for instance in the case of a client being disconnected and reconnecting.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
reset(): void;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A parsed EventSource event
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export interface ParsedEvent {
|
|
32
|
-
/**
|
|
33
|
-
* Differentiates the type from reconnection intervals and other types of messages
|
|
34
|
-
* Not to be confused with `event`.
|
|
35
|
-
*/
|
|
36
|
-
type: "event";
|
|
37
|
-
/**
|
|
38
|
-
* The event type sent from the server. Note that this differs from the browser `EventSource`
|
|
39
|
-
* implementation in that browsers will default this to `message`, whereas this parser will
|
|
40
|
-
* leave this as `undefined` if not explicitly declared.
|
|
41
|
-
*/
|
|
42
|
-
event?: string;
|
|
43
|
-
/**
|
|
44
|
-
* ID of the message, if any was provided by the server. Can be used by clients to keep the
|
|
45
|
-
* last received message ID in sync when reconnecting.
|
|
46
|
-
*/
|
|
47
|
-
id?: string;
|
|
48
|
-
/**
|
|
49
|
-
* The data received for this message
|
|
50
|
-
*/
|
|
51
|
-
data: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* An event emitted from the parser when the server sends a value in the `retry` field,
|
|
55
|
-
* indicating how many seconds the client should wait before attempting to reconnect.
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export interface ReconnectInterval {
|
|
60
|
-
/**
|
|
61
|
-
* Differentiates the type from `event` and other types of messages
|
|
62
|
-
*/
|
|
63
|
-
type: "reconnect-interval";
|
|
64
|
-
/**
|
|
65
|
-
* Number of seconds to wait before reconnecting. Note that the parser does not care about
|
|
66
|
-
* this value at all - it only emits the value for clients to use.
|
|
67
|
-
*/
|
|
68
|
-
value: number;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* The different types of messages the parsed can emit to the `onParse` callback
|
|
72
|
-
*
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
|
-
export type ParseEvent = ParsedEvent | ReconnectInterval;
|
|
76
|
-
/**
|
|
77
|
-
* Callback passed as the `onParse` callback to a parser
|
|
78
|
-
*
|
|
79
|
-
* @public
|
|
80
|
-
*/
|
|
81
|
-
export type EventSourceParseCallback = (event: ParseEvent) => void;
|
|
File without changes
|
|
File without changes
|