react-native-nitro-sse 3.1.0 → 3.2.0-beta.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/README.md +15 -4
- package/lib/module/FetchSseDriver.js +845 -0
- package/lib/module/NitroSseClient.js +19 -17
- package/lib/module/SseDriver.js +31 -15
- package/lib/module/SseEventParser.js +238 -0
- package/lib/module/createNitroSse.js +12 -5
- package/lib/module/createNitroSse.native.js +24 -0
- package/lib/module/createNitroSse.web.js +13 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.native.js +8 -0
- package/lib/module/index.web.js +9 -0
- package/lib/module/useNitroSse.js +1 -1
- package/lib/typescript/src/FetchSseDriver.d.ts +92 -0
- package/lib/typescript/src/NitroSseClient.d.ts +4 -1
- package/lib/typescript/src/SseDriver.d.ts +8 -4
- package/lib/typescript/src/SseEventParser.d.ts +42 -0
- package/lib/typescript/src/createNitroSse.d.ts +2 -2
- package/lib/typescript/src/createNitroSse.native.d.ts +9 -0
- package/lib/typescript/src/createNitroSse.web.d.ts +8 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.native.d.ts +6 -0
- package/lib/typescript/src/index.web.d.ts +7 -0
- package/package.json +12 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHATWG Server-Sent Events (SSE) streaming parser.
|
|
3
|
+
*
|
|
4
|
+
* Implements the W3C/WHATWG SSE parsing algorithm with cross-platform parity
|
|
5
|
+
* matching iOS SseEventParser (Swift) and Android SseEventReader (Kotlin).
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAX_SSE_LINE_LENGTH: number;
|
|
8
|
+
export declare const MAX_SSE_EVENT_DATA_SIZE: number;
|
|
9
|
+
export interface SseEventParserDelegate {
|
|
10
|
+
onEvent(id: string | undefined, type: string | undefined, data: string): void;
|
|
11
|
+
onComment(comment: string): void;
|
|
12
|
+
onRetry(retryMs: number): void;
|
|
13
|
+
onIdUpdate(id: string | undefined): void;
|
|
14
|
+
onParseError(error: Error): void;
|
|
15
|
+
onLinesParsed(count: number): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class SseEventParser {
|
|
18
|
+
private _delegate;
|
|
19
|
+
private _buffer;
|
|
20
|
+
private _dataBuffer;
|
|
21
|
+
private _hasData;
|
|
22
|
+
private _eventType?;
|
|
23
|
+
private _lastEventId?;
|
|
24
|
+
private _isAtStreamStart;
|
|
25
|
+
private _skipLeadingLf;
|
|
26
|
+
constructor(delegate: SseEventParserDelegate, initialLastEventId?: string);
|
|
27
|
+
get lastEventId(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resets parser state for reconnection.
|
|
30
|
+
*/
|
|
31
|
+
reset(initialLastEventId?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Signals end of stream (EOF) — flushes pending line and pending event if any.
|
|
34
|
+
*/
|
|
35
|
+
endOfStream(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Feeds a decoded UTF-8 text chunk into the streaming parser.
|
|
38
|
+
*/
|
|
39
|
+
feed(chunk: string): void;
|
|
40
|
+
private _processLine;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=SseEventParser.d.ts.map
|
|
@@ -2,8 +2,8 @@ import type { SseClient } from './SseInterface';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates a high-performance SSE client that supports typed event listeners (`addEventListener`) and legacy batching.
|
|
4
4
|
*
|
|
5
|
-
* @returns An SseClient instance wrapping the native NitroSse implementation.
|
|
6
|
-
* @throws {NitroSseModuleNotFoundError} If the native NitroSse module cannot be found
|
|
5
|
+
* @returns An SseClient instance wrapping the native NitroSse implementation, or FetchSseDriver on Web.
|
|
6
|
+
* @throws {NitroSseModuleNotFoundError} If the native NitroSse module cannot be found on iOS/Android.
|
|
7
7
|
*/
|
|
8
8
|
export declare function createNitroSse(): SseClient;
|
|
9
9
|
//# sourceMappingURL=createNitroSse.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SseClient } from './SseInterface';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an SSE client for iOS and Android using Nitro Modules (JSI).
|
|
4
|
+
*
|
|
5
|
+
* @returns An SseClient instance backed by native NitroSse.
|
|
6
|
+
* @throws {NitroSseModuleNotFoundError} If the native NitroSse module cannot be found.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createNitroSse(): SseClient;
|
|
9
|
+
//# sourceMappingURL=createNitroSse.native.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SseClient } from './SseInterface';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an SSE client for Web platform using WHATWG fetch() and ReadableStream.
|
|
4
|
+
*
|
|
5
|
+
* @returns An SseClient instance backed by FetchSseDriver.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createNitroSse(): SseClient;
|
|
8
|
+
//# sourceMappingURL=createNitroSse.web.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './SseInterface';
|
|
2
|
+
export * from './useNitroSse';
|
|
3
|
+
export * from './NitroSseClient';
|
|
4
|
+
export * from './NitroSseError';
|
|
5
|
+
export * from './createNitroSse.web';
|
|
6
|
+
export { FetchSseDriver } from './FetchSseDriver';
|
|
7
|
+
//# sourceMappingURL=index.web.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-sse",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-beta.1",
|
|
4
4
|
"description": "High-performance Server-Sent Events (SSE) for React Native, powered by Nitro Modules.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
|
+
"react-native": "./lib/module/index.native.js",
|
|
7
|
+
"browser": "./lib/module/index.web.js",
|
|
6
8
|
"types": "./lib/typescript/src/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"types": "./lib/typescript/src/index.d.ts",
|
|
13
|
+
"react-native": {
|
|
14
|
+
"types": "./lib/typescript/src/index.native.d.ts",
|
|
15
|
+
"default": "./lib/module/index.native.js"
|
|
16
|
+
},
|
|
17
|
+
"browser": {
|
|
18
|
+
"types": "./lib/typescript/src/index.web.d.ts",
|
|
19
|
+
"default": "./lib/module/index.web.js"
|
|
20
|
+
},
|
|
10
21
|
"default": "./lib/module/index.js"
|
|
11
22
|
},
|
|
12
23
|
"./package.json": "./package.json"
|