sse-stream-plugin-react 0.0.0-stage → 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ryan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,117 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # sse-stream-plugin-react
2
+
3
+ [sse-stream-plugin-sdk](../core) 的 React Hooks 封装。将插件化 SSE SDK 封装为声明式响应式 API,自动管理实例生命周期与事件订阅。
4
+
5
+ ## 安装
6
+
7
+ 需要同时安装核心 SDK:
8
+
9
+ ```bash
10
+ npm install sse-stream-plugin-react sse-stream-plugin-sdk
11
+ # 或
12
+ pnpm add sse-stream-plugin-react sse-stream-plugin-sdk
13
+ ```
14
+
15
+ > `react` 为 peerDependency,要求 `>=16.8.0`。
16
+
17
+ ## 快速开始
18
+
19
+ ```tsx
20
+ import { useSSEStream } from 'sse-stream-plugin-react'
21
+ import { recommendedPlugins } from 'sse-stream-plugin-sdk'
22
+
23
+ function Chat() {
24
+ const { text, loading, status, start, stop } = useSSEStream({
25
+ url: 'https://api.example.com/stream',
26
+ method: 'POST',
27
+ getBody: () => JSON.stringify({ prompt: '你好' }),
28
+ headers: { 'Content-Type': 'application/json' },
29
+ plugins: recommendedPlugins(),
30
+ onMessage: (data) => console.log(data),
31
+ onError: (err) => console.error(err),
32
+ })
33
+
34
+ return (
35
+ <div>
36
+ <button onClick={start} disabled={loading}>发送</button>
37
+ <button onClick={stop}>停止</button>
38
+ <p>{status}</p>
39
+ <pre>{text}</pre>
40
+ </div>
41
+ )
42
+ }
43
+ ```
44
+
45
+ ## API
46
+
47
+ ### `useSSEStream(options)`
48
+
49
+ #### 入参 `UseSSEStreamOptions`
50
+
51
+ 继承 `PluginSSEOptions` 的核心字段,并追加事件回调与动态 body:
52
+
53
+ | 字段 | 类型 | 说明 |
54
+ |------|------|------|
55
+ | `url` | `string` | 请求地址(必填) |
56
+ | `method` | `'GET' \| 'POST'` | 请求方法,默认 `GET` |
57
+ | `body` | `string` | 请求体字符串 |
58
+ | `getBody` | `() => string` | 每次 `start` 时动态生成请求体,优先级高于 `body` |
59
+ | `headers` | `Record<string, string>` | 自定义请求头 |
60
+ | `transport` | `string \| TransportFactory` | 传输层,省略则自动探测 `fetch` |
61
+ | `parser` | `ParserFactory` | 自定义解析器 |
62
+ | `plugins` | `SSEPlugin[]` | 插件列表 |
63
+ | `onMessage` | `(data, event) => void` | 收到 message 事件回调 |
64
+ | `onOpen` | `(info: { transport }) => void` | 连接打开回调 |
65
+ | `onEnd` | `() => void` | 流结束回调 |
66
+ | `onError` | `(err) => void` | 错误回调 |
67
+
68
+ > 事件回调通过 `ref` 始终取最新值,不会出现闭包过期问题。
69
+
70
+ #### 返回值 `UseSSEStreamReturn`
71
+
72
+ | 字段 | 类型 | 说明 |
73
+ |------|------|------|
74
+ | `text` | `string` | 已拼接的消息文本(`message` 事件 `data` 累加) |
75
+ | `status` | `string` | 连接状态描述 |
76
+ | `loading` | `boolean` | 是否处于连接中/流式接收中 |
77
+ | `msgCount` | `number` | 已接收 message 事件条数 |
78
+ | `charCount` | `number` | 已接收字符总数 |
79
+ | `start` | `() => void` | 发起一次连接(先销毁旧连接) |
80
+ | `stop` | `() => void` | 手动断开并销毁实例 |
81
+ | `instance` | `PluginSSE \| null` | 当前实例(便于 `use()` 追加插件等高级操作) |
82
+
83
+ ## 生命周期
84
+
85
+ - 组件卸载时自动 `destroy()` 实例并清空订阅,无需手动清理
86
+ - `start()` 会先销毁旧连接再创建新连接,可重复调用
87
+
88
+ ## 高级用法
89
+
90
+ ### 通过 `instance` 追加插件
91
+
92
+ ```tsx
93
+ const { instance, start } = useSSEStream({ url, method: 'POST' })
94
+
95
+ useEffect(() => {
96
+ if (instance) {
97
+ instance.use(loggerPlugin())
98
+ }
99
+ }, [instance])
100
+ ```
101
+
102
+ ### 小程序环境
103
+
104
+ 通过 `transport` 传入小程序传输层工厂:
105
+
106
+ ```tsx
107
+ import { createMpTransport } from 'sse-stream-plugin-sdk'
108
+
109
+ useSSEStream({
110
+ url,
111
+ transport: createMpTransport(() => wx),
112
+ })
113
+ ```
114
+
115
+ ## License
116
+
117
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var sseStreamPluginSdk = require('sse-stream-plugin-sdk');
5
+
6
+ /**
7
+ * @file React Hook:将插件化 SSE SDK 封装为声明式响应式 API
8
+ * @description
9
+ * - 实例用 useRef 持有,不进入 React 状态;
10
+ * - start() 内按需创建 PluginSSE,组件卸载时自动 destroy();
11
+ * - 事件回调通过 optionsRef 始终取最新值,避免闭包过期;
12
+ * - 暴露 text/status/loading 等响应式状态与 start/stop 方法。
13
+ */
14
+ function useSSEStream(options) {
15
+ // 始终保存最新入参,start 内读取,保证回调与配置不过期
16
+ const optionsRef = react.useRef(options);
17
+ optionsRef.current = options;
18
+ const sseRef = react.useRef(null);
19
+ const [text, setText] = react.useState('');
20
+ const [status, setStatus] = react.useState('未连接');
21
+ const [loading, setLoading] = react.useState(false);
22
+ const [msgCount, setMsgCount] = react.useState(0);
23
+ const [charCount, setCharCount] = react.useState(0);
24
+ // 组件卸载:释放连接、清空订阅
25
+ react.useEffect(() => {
26
+ return () => {
27
+ sseRef.current?.destroy();
28
+ sseRef.current = null;
29
+ };
30
+ }, []);
31
+ const stop = react.useCallback(() => {
32
+ sseRef.current?.destroy();
33
+ sseRef.current = null;
34
+ setStatus('已手动断开');
35
+ setLoading(false);
36
+ }, []);
37
+ const start = react.useCallback(() => {
38
+ const { url, method, body, headers, transport, parser, plugins, getBody, onMessage, onOpen, onEnd, onError, } = optionsRef.current;
39
+ // 销毁旧连接(含旧实例的全部事件订阅)
40
+ sseRef.current?.destroy();
41
+ setText('');
42
+ setMsgCount(0);
43
+ setCharCount(0);
44
+ setStatus('连接中…');
45
+ setLoading(true);
46
+ const sse = new sseStreamPluginSdk.PluginSSE({
47
+ url,
48
+ method: method ?? 'GET',
49
+ body: getBody ? getBody() : body,
50
+ headers,
51
+ transport,
52
+ parser,
53
+ plugins,
54
+ });
55
+ sse.on('open', ({ transport: name }) => {
56
+ setStatus(`已连接(${name})`);
57
+ onOpen?.({ transport: name });
58
+ });
59
+ sse.on('message', (data, event) => {
60
+ setText((prev) => prev + data);
61
+ setMsgCount((n) => n + 1);
62
+ setCharCount((n) => n + data.length);
63
+ onMessage?.(data, event);
64
+ });
65
+ sse.on('end', () => {
66
+ setStatus('流正常结束');
67
+ setLoading(false);
68
+ onEnd?.();
69
+ });
70
+ sse.on('error', (err) => {
71
+ const msg = err instanceof Error ? err.message : String(err);
72
+ setStatus(`错误:${msg}`);
73
+ setLoading(false);
74
+ onError?.(err);
75
+ });
76
+ sseRef.current = sse;
77
+ sse.connect();
78
+ }, []);
79
+ return {
80
+ text,
81
+ status,
82
+ loading,
83
+ msgCount,
84
+ charCount,
85
+ start,
86
+ stop,
87
+ instance: sseRef.current,
88
+ };
89
+ }
90
+
91
+ exports.useSSEStream = useSSEStream;
92
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/useSSEStream.ts"],"sourcesContent":[null],"names":["useRef","useState","useEffect","useCallback","PluginSSE"],"mappings":";;;;;AAAA;;;;;;;AAOG;AAuCG,SAAU,YAAY,CAAC,OAA4B,EAAA;;AAEvD,IAAA,MAAM,UAAU,GAAGA,YAAM,CAAC,OAAO,CAAC;AAClC,IAAA,UAAU,CAAC,OAAO,GAAG,OAAO;AAE5B,IAAA,MAAM,MAAM,GAAGA,YAAM,CAAmB,IAAI,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAGC,cAAQ,CAAC,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC7C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAGA,cAAQ,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAGA,cAAQ,CAAC,CAAC,CAAC;;IAG7CC,eAAS,CAAC,MAAK;AACb,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AACzB,YAAA,MAAM,CAAC,OAAO,GAAG,IAAI;AACvB,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,IAAI,GAAGC,iBAAW,CAAC,MAAK;AAC5B,QAAA,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AACzB,QAAA,MAAM,CAAC,OA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AC,GAAG,IAAI,CAAC,MAAM,CAAC;AACpC,YAAA,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC;AAC1B,QAAA,CAAC,CAAC;AACF,QAAA,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAK;YACjB,SAAS,CAAC,OAAO,CAAC;YAClB,UAAU,CAAC,KAAK,CAAC;YACjB,KAAK,IAAI;AACX,QAAA,CAAC,CAAC;QACF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAY,KAAI;AAC/B,YAAA,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,GAAG,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC;AAC5D,YAAA,SAAS,CAAC,CAAA,GAAA,EAAM,GAAG,CAAA,CAAE,CAAC;YACtB,UAAU,CAAC,KAAK,CAAC;AACjB,YAAA,OAAO,GAAG,GAAG,CAAC;AAChB,QAAA,CAAC,CAAC;AAEF,QAAA,MAAM,CAAC,OAAO,GAAG,GAAG;QACpB,GAAG,CAAC,OAAO,EAAE;IACf,CAAC,EAAE,EAAE,CAAC;IAEN,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO;QACP,QAAQ;QACR,SAAS;QACT,KAAK;QACL,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,OAAO;KACzB;AACH;;"}
@@ -0,0 +1,37 @@
1
+ import { PluginSSEOptions, ParsedEvent, PluginSSE } from 'sse-stream-plugin-sdk';
2
+
3
+ /**
4
+ * Hook 入参:在核心 PluginSSEOptions 基础上追加动态 body 与事件回调
5
+ */
6
+ interface UseSSEStreamOptions extends Pick<PluginSSEOptions, 'url' | 'method' | 'body' | 'headers' | 'transport' | 'parser' | 'plugins'> {
7
+ /** 每次 start 时动态生成请求体(如带当前 prompt),优先级高于 body */
8
+ getBody?: () => string;
9
+ onMessage?: (data: string, event: ParsedEvent) => void;
10
+ onOpen?: (info: {
11
+ transport: string;
12
+ }) => void;
13
+ onEnd?: () => void;
14
+ onError?: (err: unknown) => void;
15
+ }
16
+ interface UseSSEStreamReturn {
17
+ /** 已拼接的消息文本(message 事件 data 累加) */
18
+ text: string;
19
+ /** 连接状态描述 */
20
+ status: string;
21
+ /** 是否处于连接中/流式接收中 */
22
+ loading: boolean;
23
+ /** 已接收 message 事件条数 */
24
+ msgCount: number;
25
+ /** 已接收字符总数 */
26
+ charCount: number;
27
+ /** 发起一次连接(先销毁旧连接) */
28
+ start: () => void;
29
+ /** 手动断开并销毁实例 */
30
+ stop: () => void;
31
+ /** 当前 PluginSSE 实例(便于 use() 追加插件等高级操作) */
32
+ instance: PluginSSE | null;
33
+ }
34
+ declare function useSSEStream(options: UseSSEStreamOptions): UseSSEStreamReturn;
35
+
36
+ export { useSSEStream };
37
+ export type { UseSSEStreamOptions, UseSSEStreamReturn };
package/dist/index.mjs ADDED
@@ -0,0 +1,90 @@
1
+ import { useRef, useState, useEffect, useCallback } from 'react';
2
+ import { PluginSSE } from 'sse-stream-plugin-sdk';
3
+
4
+ /**
5
+ * @file React Hook:将插件化 SSE SDK 封装为声明式响应式 API
6
+ * @description
7
+ * - 实例用 useRef 持有,不进入 React 状态;
8
+ * - start() 内按需创建 PluginSSE,组件卸载时自动 destroy();
9
+ * - 事件回调通过 optionsRef 始终取最新值,避免闭包过期;
10
+ * - 暴露 text/status/loading 等响应式状态与 start/stop 方法。
11
+ */
12
+ function useSSEStream(options) {
13
+ // 始终保存最新入参,start 内读取,保证回调与配置不过期
14
+ const optionsRef = useRef(options);
15
+ optionsRef.current = options;
16
+ const sseRef = useRef(null);
17
+ const [text, setText] = useState('');
18
+ const [status, setStatus] = useState('未连接');
19
+ const [loading, setLoading] = useState(false);
20
+ const [msgCount, setMsgCount] = useState(0);
21
+ const [charCount, setCharCount] = useState(0);
22
+ // 组件卸载:释放连接、清空订阅
23
+ useEffect(() => {
24
+ return () => {
25
+ sseRef.current?.destroy();
26
+ sseRef.current = null;
27
+ };
28
+ }, []);
29
+ const stop = useCallback(() => {
30
+ sseRef.current?.destroy();
31
+ sseRef.current = null;
32
+ setStatus('已手动断开');
33
+ setLoading(false);
34
+ }, []);
35
+ const start = useCallback(() => {
36
+ const { url, method, body, headers, transport, parser, plugins, getBody, onMessage, onOpen, onEnd, onError, } = optionsRef.current;
37
+ // 销毁旧连接(含旧实例的全部事件订阅)
38
+ sseRef.current?.destroy();
39
+ setText('');
40
+ setMsgCount(0);
41
+ setCharCount(0);
42
+ setStatus('连接中…');
43
+ setLoading(true);
44
+ const sse = new PluginSSE({
45
+ url,
46
+ method: method ?? 'GET',
47
+ body: getBody ? getBody() : body,
48
+ headers,
49
+ transport,
50
+ parser,
51
+ plugins,
52
+ });
53
+ sse.on('open', ({ transport: name }) => {
54
+ setStatus(`已连接(${name})`);
55
+ onOpen?.({ transport: name });
56
+ });
57
+ sse.on('message', (data, event) => {
58
+ setText((prev) => prev + data);
59
+ setMsgCount((n) => n + 1);
60
+ setCharCount((n) => n + data.length);
61
+ onMessage?.(data, event);
62
+ });
63
+ sse.on('end', () => {
64
+ setStatus('流正常结束');
65
+ setLoading(false);
66
+ onEnd?.();
67
+ });
68
+ sse.on('error', (err) => {
69
+ const msg = err instanceof Error ? err.message : String(err);
70
+ setStatus(`错误:${msg}`);
71
+ setLoading(false);
72
+ onError?.(err);
73
+ });
74
+ sseRef.current = sse;
75
+ sse.connect();
76
+ }, []);
77
+ return {
78
+ text,
79
+ status,
80
+ loading,
81
+ msgCount,
82
+ charCount,
83
+ start,
84
+ stop,
85
+ instance: sseRef.current,
86
+ };
87
+ }
88
+
89
+ export { useSSEStream };
90
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/useSSEStream.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;AAOG;AAuCG,SAAU,YAAY,CAAC,OAA4B,EAAA;;AAEvD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;AAClC,IAAA,UAAU,CAAC,OAAO,GA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C;YACtB,UAAU,CAAC,KAAK,CAAC;AACjB,YAAA,OAAO,GAAG,GAAG,CAAC;AAChB,QAAA,CAAC,CAAC;AAEF,QAAA,MAAM,CAAC,OAAO,GAAG,GAAG;QACpB,GAAG,CAAC,OAAO,EAAE;IACf,CAAC,EAAE,EAAE,CAAC;IAEN,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO;QACP,QAAQ;QACR,SAAS;QACT,KAAK;QACL,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,OAAO;KACzB;AACH;;"}
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "sse-stream-plugin-react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "React Hooks for sse-stream-plugin-sdk",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "sse",
9
+ "server-sent-events",
10
+ "stream",
11
+ "react",
12
+ "hooks"
13
+ ],
14
+ "main": "dist/index.cjs",
15
+ "module": "dist/index.mjs",
16
+ "types": "dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.mjs",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "LICENSE",
27
+ "README.md"
28
+ ],
29
+ "scripts": {
30
+ "build": "rollup -c",
31
+ "build:prod": "rollup -c --environment NODE_ENV:production"
32
+ },
33
+ "peerDependencies": {
34
+ "react": ">=16.8.0",
35
+ "sse-stream-plugin-sdk": "^1.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/react": "^19.2.18",
39
+ "react": "^19.2.8",
40
+ "sse-stream-plugin-sdk": "workspace:*"
41
+ }
42
+ }