avancement planning

This commit is contained in:
2026-05-26 11:58:39 +02:00
parent 619a2b240a
commit 150b97cd2e
4892 changed files with 99214 additions and 429382 deletions
+23 -21
View File
@@ -10,13 +10,15 @@
* @returns A new EventSource parser, with `parse` and `reset` methods.
* @public
*/
export declare function createParser(callbacks: ParserCallbacks): EventSourceParser
export declare function createParser(
callbacks: ParserCallbacks,
): EventSourceParser;
/**
* The type of error that occurred.
* @public
*/
export declare type ErrorType = 'invalid-retry' | 'unknown-field'
export declare type ErrorType = "invalid-retry" | "unknown-field";
/**
* A parsed EventSource message event
@@ -29,16 +31,16 @@ export declare interface EventSourceMessage {
* implementation in that browsers will default this to `message`, whereas this parser will
* leave this as `undefined` if not explicitly declared.
*/
event?: string | undefined
event?: string | undefined;
/**
* ID of the message, if any was provided by the server. Can be used by clients to keep the
* last received message ID in sync when reconnecting.
*/
id?: string | undefined
id?: string | undefined;
/**
* The data received for this message
*/
data: string
data: string;
}
/**
@@ -57,7 +59,7 @@ export declare interface EventSourceParser {
* @param chunk - The chunk to parse. Can be a partial, eg in the case of streaming messages.
* @public
*/
feed(chunk: string): void
feed(chunk: string): void;
/**
* Resets the parser state. This is required when you have a new stream of messages -
* for instance in the case of a client being disconnected and reconnecting.
@@ -69,7 +71,7 @@ export declare interface EventSourceParser {
*
* @public
*/
reset(options?: {consume?: boolean}): void
reset(options?: { consume?: boolean }): void;
}
/**
@@ -81,28 +83,28 @@ export declare class ParseError extends Error {
/**
* The type of error that occurred.
*/
type: ErrorType
type: ErrorType;
/**
* In the case of an unknown field encountered in the stream, this will be the field name.
*/
field?: string | undefined
field?: string | undefined;
/**
* In the case of an unknown field encountered in the stream, this will be the value of the field.
*/
value?: string | undefined
value?: string | undefined;
/**
* The line that caused the error, if available.
*/
line?: string | undefined
line?: string | undefined;
constructor(
message: string,
options: {
type: ErrorType
field?: string
value?: string
line?: string
type: ErrorType;
field?: string;
value?: string;
line?: string;
},
)
);
}
/**
@@ -118,19 +120,19 @@ export declare interface ParserCallbacks {
*
* @param event - The parsed event/message
*/
onEvent?: ((event: EventSourceMessage) => void) | undefined
onEvent?: ((event: EventSourceMessage) => void) | undefined;
/**
* Callback for when the server sends a new reconnection interval through the `retry` field.
*
* @param retry - The number of milliseconds to wait before reconnecting.
*/
onRetry?: ((retry: number) => void) | undefined
onRetry?: ((retry: number) => void) | undefined;
/**
* Callback for when a comment is encountered in the stream.
*
* @param comment - The comment encountered in the stream.
*/
onComment?: ((comment: string) => void) | undefined
onComment?: ((comment: string) => void) | undefined;
/**
* Callback for when an error occurs during parsing. This is a catch-all for any errors
* that occur during parsing, and can be used to handle them in a custom way. Most clients
@@ -138,7 +140,7 @@ export declare interface ParserCallbacks {
*
* @param error - The error that occurred during parsing
*/
onError?: ((error: ParseError) => void) | undefined
onError?: ((error: ParseError) => void) | undefined;
}
export {}
export {};