@ahoo-wang/fetcher-eventstream 0.1.0 → 0.1.2
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 +3 -0
- package/dist/eventStreamConverter.d.ts +5 -1
- package/dist/eventStreamConverter.d.ts.map +1 -1
- package/dist/eventStreamInterceptor.d.ts +1 -1
- package/dist/eventStreamInterceptor.d.ts.map +1 -1
- package/dist/serverSentEventTransformStream.d.ts +0 -4
- package/dist/serverSentEventTransformStream.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@ Support for text/event-stream in Fetcher, enabling Server-Sent Events (SSE) func
|
|
|
14
14
|
- **Interceptor Integration**: Automatically adds `eventStream()` method to responses with `text/event-stream` content type
|
|
15
15
|
- **SSE Parsing**: Parses Server-Sent Events according to the specification, including data, event, id, and retry fields
|
|
16
16
|
- **Streaming Support**: Handles chunked data and multi-line events correctly
|
|
17
|
+
- **Comment Handling**: Properly ignores comment lines (lines starting with `:`) as per SSE specification
|
|
18
|
+
- **Event ID Tracking**: Maintains last event ID for automatic reconnection
|
|
19
|
+
- **Retry Management**: Handles retry timeout values for connection reattempts
|
|
17
20
|
- **TypeScript Support**: Complete TypeScript type definitions
|
|
18
21
|
|
|
19
22
|
## Installation
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServerSentEvent } from './serverSentEventTransformStream';
|
|
2
|
+
/**
|
|
3
|
+
* ServerSentEventStream is a ReadableStream of ServerSentEvent objects
|
|
4
|
+
*/
|
|
5
|
+
export type ServerSentEventStream = ReadableStream<ServerSentEvent>;
|
|
2
6
|
/**
|
|
3
7
|
* Responsible for handling event stream responses, including converting Response to event stream (ReadableStream<ServerSentEvent>).
|
|
4
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventStreamConverter.d.ts","sourceRoot":"","sources":["../src/eventStreamConverter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"eventStreamConverter.d.ts","sourceRoot":"","sources":["../src/eventStreamConverter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;AAEpE;;GAEG;AACH,qBAAa,oBAAoB;IAC/B;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,qBAAqB;CAchE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventStreamInterceptor.d.ts","sourceRoot":"","sources":["../src/eventStreamInterceptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventStreamInterceptor.d.ts","sourceRoot":"","sources":["../src/eventStreamInterceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,QAAQ;QAChB,WAAW,CAAC,IAAI,qBAAqB,CAAC;KACvC;CACF;AAED,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;CAYxC"}
|
|
@@ -12,10 +12,6 @@ export interface ServerSentEvent {
|
|
|
12
12
|
/** The reconnection interval (in milliseconds) to wait before retrying the connection */
|
|
13
13
|
retry?: number;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* ServerSentEventStream is a ReadableStream of ServerSentEvent objects
|
|
17
|
-
*/
|
|
18
|
-
export type ServerSentEventStream = ReadableStream<ServerSentEvent>;
|
|
19
15
|
export declare enum ServerSentEventField {
|
|
20
16
|
ID = "id",
|
|
21
17
|
RETRY = "retry",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSentEventTransformStream.d.ts","sourceRoot":"","sources":["../src/serverSentEventTransformStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"serverSentEventTransformStream.d.ts","sourceRoot":"","sources":["../src/serverSentEventTransformStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,oBAAoB;IAC9B,EAAE,OAAO;IACT,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AA0CD;;;GAGG;AACH,qBAAa,0BACX,YAAW,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC;IAG/C,OAAO,CAAC,YAAY,CAKlB;IAEF;;;;OAIG;IACH,SAAS,CACP,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,gCAAgC,CAAC,eAAe,CAAC;IAkE/D;;;OAGG;IACH,KAAK,CAAC,UAAU,EAAE,gCAAgC,CAAC,eAAe,CAAC;CAwBpE;AAED;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,eAAe,CACjE,MAAM,EACN,eAAe,CAChB;;CAIA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-eventstream",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Support for text/event-stream in Fetcher",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ahoo-wang/fetcher": "0.1.
|
|
36
|
+
"@ahoo-wang/fetcher": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@vitest/coverage-v8": "^3.2.4",
|