@xbg.solutions/bpsk-utils-sse 1.2.3
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/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/sse.d.ts +132 -0
- package/lib/utils/sse.d.ts.map +1 -0
- package/lib/utils/sse.js +359 -0
- package/lib/utils/sse.js.map +1 -0
- package/package.json +23 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,QAAQ;AACR,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/utils/sse.ts
|
|
3
|
+
* Server-Sent Events (SSE) Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides utilities for handling real-time event streams from the server.
|
|
6
|
+
* Includes automatic reconnection, error handling, and integration with the event system.
|
|
7
|
+
*
|
|
8
|
+
* SSE is ideal for:
|
|
9
|
+
* - Real-time notifications
|
|
10
|
+
* - Live updates (stock prices, analytics)
|
|
11
|
+
* - AI streaming responses
|
|
12
|
+
* - Server push notifications
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for SSE connection
|
|
16
|
+
*/
|
|
17
|
+
export interface SSEConfig {
|
|
18
|
+
/** The URL endpoint for the SSE stream */
|
|
19
|
+
url: string;
|
|
20
|
+
/** Whether to automatically reconnect on disconnect */
|
|
21
|
+
autoReconnect?: boolean;
|
|
22
|
+
/** Maximum number of reconnection attempts (0 = infinite) */
|
|
23
|
+
maxReconnectAttempts?: number;
|
|
24
|
+
/** Delay between reconnection attempts in milliseconds */
|
|
25
|
+
reconnectDelay?: number;
|
|
26
|
+
/** Request headers to include */
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
/** With credentials (for CORS) */
|
|
29
|
+
withCredentials?: boolean;
|
|
30
|
+
/** Event types to listen for (empty = all events) */
|
|
31
|
+
eventTypes?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* SSE event handler function
|
|
35
|
+
*/
|
|
36
|
+
export type SSEEventHandler = (data: any, event: MessageEvent) => void;
|
|
37
|
+
/**
|
|
38
|
+
* SSE error handler function
|
|
39
|
+
*/
|
|
40
|
+
export type SSEErrorHandler = (error: Error) => void;
|
|
41
|
+
/**
|
|
42
|
+
* SSE connection states
|
|
43
|
+
*/
|
|
44
|
+
export type SSEConnectionState = 'connecting' | 'open' | 'closed' | 'error';
|
|
45
|
+
/**
|
|
46
|
+
* SSE Connection wrapper with automatic reconnection
|
|
47
|
+
*/
|
|
48
|
+
export declare class SSEConnection {
|
|
49
|
+
private eventSource;
|
|
50
|
+
private config;
|
|
51
|
+
private handlers;
|
|
52
|
+
private errorHandlers;
|
|
53
|
+
private reconnectAttempts;
|
|
54
|
+
private reconnectTimer;
|
|
55
|
+
private state;
|
|
56
|
+
private manualClose;
|
|
57
|
+
constructor(config: SSEConfig);
|
|
58
|
+
/**
|
|
59
|
+
* Get current connection state
|
|
60
|
+
*/
|
|
61
|
+
getState(): SSEConnectionState;
|
|
62
|
+
/**
|
|
63
|
+
* Check if connected
|
|
64
|
+
*/
|
|
65
|
+
isConnected(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Connect to the SSE endpoint
|
|
68
|
+
*/
|
|
69
|
+
connect(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Setup EventSource event listeners
|
|
72
|
+
*/
|
|
73
|
+
private setupEventListeners;
|
|
74
|
+
/**
|
|
75
|
+
* Handle incoming message
|
|
76
|
+
*/
|
|
77
|
+
private handleMessage;
|
|
78
|
+
/**
|
|
79
|
+
* Handle reconnection logic
|
|
80
|
+
*/
|
|
81
|
+
private handleReconnect;
|
|
82
|
+
/**
|
|
83
|
+
* Handle connection errors
|
|
84
|
+
*/
|
|
85
|
+
private handleConnectionError;
|
|
86
|
+
/**
|
|
87
|
+
* Register event handler
|
|
88
|
+
*/
|
|
89
|
+
on(eventType: string, handler: SSEEventHandler): () => void;
|
|
90
|
+
/**
|
|
91
|
+
* Register error handler
|
|
92
|
+
*/
|
|
93
|
+
onError(handler: SSEErrorHandler): () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Disconnect from SSE endpoint
|
|
96
|
+
*/
|
|
97
|
+
disconnect(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Cleanup and disconnect
|
|
100
|
+
*/
|
|
101
|
+
destroy(): void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Create an SSE connection
|
|
105
|
+
*/
|
|
106
|
+
export declare function createSSEConnection(config: SSEConfig): SSEConnection;
|
|
107
|
+
/**
|
|
108
|
+
* Utility function for simple SSE usage
|
|
109
|
+
*/
|
|
110
|
+
export declare function streamSSE(url: string, onMessage: SSEEventHandler, options?: Partial<SSEConfig>): () => void;
|
|
111
|
+
/**
|
|
112
|
+
* Fetch with streaming response (for fetch-based streaming, not SSE)
|
|
113
|
+
*/
|
|
114
|
+
export declare function streamFetch(url: string, options?: RequestInit): AsyncGenerator<string, void, unknown>;
|
|
115
|
+
/**
|
|
116
|
+
* Example usage patterns for developers
|
|
117
|
+
*/
|
|
118
|
+
export declare const SSEExamples: {
|
|
119
|
+
/**
|
|
120
|
+
* Basic SSE connection
|
|
121
|
+
*/
|
|
122
|
+
basic: () => () => void;
|
|
123
|
+
/**
|
|
124
|
+
* AI streaming response
|
|
125
|
+
*/
|
|
126
|
+
aiStreaming: () => void;
|
|
127
|
+
/**
|
|
128
|
+
* Real-time notifications
|
|
129
|
+
*/
|
|
130
|
+
notifications: () => () => void;
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/utils/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAYH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,kCAAkC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5E;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAgD;IAChE,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,EAAE,SAAS;IAY7B;;OAEG;IACH,QAAQ,IAAI,kBAAkB;IAI9B;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,OAAO,IAAI,IAAI;IAiCf;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiD3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAsCrB;;OAEG;IACH,OAAO,CAAC,eAAe;IA2BvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;OAEG;IACH,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,IAAI;IAe3D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,IAAI;IAS7C;;OAEG;IACH,UAAU,IAAI,IAAI;IAsBlB;;OAEG;IACH,OAAO,IAAI,IAAI;CAKhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,CAEpE;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC3B,MAAM,IAAI,CAWZ;AAED;;GAEG;AACH,wBAAuB,WAAW,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CA0BvC;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;;IAoBH;;OAEG;;IA2BH;;OAEG;;CAiBJ,CAAC"}
|
package/lib/utils/sse.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/utils/sse.ts
|
|
3
|
+
* Server-Sent Events (SSE) Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides utilities for handling real-time event streams from the server.
|
|
6
|
+
* Includes automatic reconnection, error handling, and integration with the event system.
|
|
7
|
+
*
|
|
8
|
+
* SSE is ideal for:
|
|
9
|
+
* - Real-time notifications
|
|
10
|
+
* - Live updates (stock prices, analytics)
|
|
11
|
+
* - AI streaming responses
|
|
12
|
+
* - Server push notifications
|
|
13
|
+
*/
|
|
14
|
+
import { loggerService, publish, normalizeError } from '@xbg.solutions/bpsk-core';
|
|
15
|
+
// Create context-aware logger
|
|
16
|
+
const sseLogger = loggerService.withContext('SSE');
|
|
17
|
+
/**
|
|
18
|
+
* SSE Connection wrapper with automatic reconnection
|
|
19
|
+
*/
|
|
20
|
+
export class SSEConnection {
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.eventSource = null;
|
|
23
|
+
this.handlers = new Map();
|
|
24
|
+
this.errorHandlers = new Set();
|
|
25
|
+
this.reconnectAttempts = 0;
|
|
26
|
+
this.reconnectTimer = null;
|
|
27
|
+
this.state = 'closed';
|
|
28
|
+
this.manualClose = false;
|
|
29
|
+
this.config = {
|
|
30
|
+
autoReconnect: true,
|
|
31
|
+
maxReconnectAttempts: 5,
|
|
32
|
+
reconnectDelay: 3000,
|
|
33
|
+
headers: {},
|
|
34
|
+
withCredentials: false,
|
|
35
|
+
eventTypes: [],
|
|
36
|
+
...config
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get current connection state
|
|
41
|
+
*/
|
|
42
|
+
getState() {
|
|
43
|
+
return this.state;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if connected
|
|
47
|
+
*/
|
|
48
|
+
isConnected() {
|
|
49
|
+
return this.state === 'open';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Connect to the SSE endpoint
|
|
53
|
+
*/
|
|
54
|
+
connect() {
|
|
55
|
+
if (this.eventSource) {
|
|
56
|
+
sseLogger.warn('Already connected or connecting to SSE', {
|
|
57
|
+
url: this.config.url,
|
|
58
|
+
state: this.state
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
this.state = 'connecting';
|
|
64
|
+
this.manualClose = false;
|
|
65
|
+
sseLogger.info('Connecting to SSE endpoint', {
|
|
66
|
+
url: this.config.url,
|
|
67
|
+
withCredentials: this.config.withCredentials
|
|
68
|
+
});
|
|
69
|
+
// Create EventSource
|
|
70
|
+
this.eventSource = new EventSource(this.config.url, {
|
|
71
|
+
withCredentials: this.config.withCredentials
|
|
72
|
+
});
|
|
73
|
+
// Setup event listeners
|
|
74
|
+
this.setupEventListeners();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const normalizedError = normalizeError(error, 'Failed to create SSE connection');
|
|
78
|
+
sseLogger.error('SSE connection error', normalizedError);
|
|
79
|
+
this.handleConnectionError(normalizedError);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Setup EventSource event listeners
|
|
84
|
+
*/
|
|
85
|
+
setupEventListeners() {
|
|
86
|
+
if (!this.eventSource)
|
|
87
|
+
return;
|
|
88
|
+
// Handle connection open
|
|
89
|
+
this.eventSource.onopen = () => {
|
|
90
|
+
this.state = 'open';
|
|
91
|
+
this.reconnectAttempts = 0;
|
|
92
|
+
sseLogger.info('SSE connection established', {
|
|
93
|
+
url: this.config.url
|
|
94
|
+
});
|
|
95
|
+
// Publish connection event
|
|
96
|
+
publish('sse:connected', { url: this.config.url }, 'SSEConnection');
|
|
97
|
+
};
|
|
98
|
+
// Handle messages
|
|
99
|
+
this.eventSource.onmessage = (event) => {
|
|
100
|
+
this.handleMessage('message', event);
|
|
101
|
+
};
|
|
102
|
+
// Handle errors
|
|
103
|
+
this.eventSource.onerror = (event) => {
|
|
104
|
+
sseLogger.error('SSE connection error', new Error('EventSource error'), {
|
|
105
|
+
url: this.config.url,
|
|
106
|
+
readyState: this.eventSource?.readyState
|
|
107
|
+
});
|
|
108
|
+
this.state = 'error';
|
|
109
|
+
// EventSource automatically tries to reconnect, but we handle it manually
|
|
110
|
+
if (!this.manualClose && this.config.autoReconnect) {
|
|
111
|
+
this.handleReconnect();
|
|
112
|
+
}
|
|
113
|
+
// Publish error event
|
|
114
|
+
publish('sse:error', { url: this.config.url }, 'SSEConnection');
|
|
115
|
+
};
|
|
116
|
+
// Setup custom event type listeners
|
|
117
|
+
if (this.config.eventTypes.length > 0) {
|
|
118
|
+
this.config.eventTypes.forEach(eventType => {
|
|
119
|
+
this.eventSource.addEventListener(eventType, (event) => {
|
|
120
|
+
this.handleMessage(eventType, event);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Handle incoming message
|
|
127
|
+
*/
|
|
128
|
+
handleMessage(eventType, event) {
|
|
129
|
+
try {
|
|
130
|
+
// Parse data (if JSON)
|
|
131
|
+
let data = event.data;
|
|
132
|
+
try {
|
|
133
|
+
data = JSON.parse(event.data);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Not JSON, use raw data
|
|
137
|
+
}
|
|
138
|
+
sseLogger.info(`SSE message received: ${eventType}`, {
|
|
139
|
+
hasData: !!data
|
|
140
|
+
});
|
|
141
|
+
// Call registered handlers
|
|
142
|
+
const handlers = this.handlers.get(eventType);
|
|
143
|
+
if (handlers) {
|
|
144
|
+
handlers.forEach(handler => {
|
|
145
|
+
try {
|
|
146
|
+
handler(data, event);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const normalizedError = normalizeError(error, `Error in SSE handler for ${eventType}`);
|
|
150
|
+
sseLogger.error(`Handler error for ${eventType}`, normalizedError);
|
|
151
|
+
this.errorHandlers.forEach(errorHandler => errorHandler(normalizedError));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// Publish to event system
|
|
156
|
+
publish(`sse:${eventType}`, data, 'SSEConnection');
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const normalizedError = normalizeError(error, 'Error processing SSE message');
|
|
160
|
+
sseLogger.error('Message processing error', normalizedError);
|
|
161
|
+
this.errorHandlers.forEach(errorHandler => errorHandler(normalizedError));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Handle reconnection logic
|
|
166
|
+
*/
|
|
167
|
+
handleReconnect() {
|
|
168
|
+
if (this.manualClose)
|
|
169
|
+
return;
|
|
170
|
+
if (this.config.maxReconnectAttempts > 0 &&
|
|
171
|
+
this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
172
|
+
sseLogger.error('Max reconnection attempts reached', undefined, {
|
|
173
|
+
attempts: this.reconnectAttempts,
|
|
174
|
+
maxAttempts: this.config.maxReconnectAttempts
|
|
175
|
+
});
|
|
176
|
+
this.state = 'closed';
|
|
177
|
+
publish('sse:max_reconnects', { url: this.config.url }, 'SSEConnection');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.reconnectAttempts++;
|
|
181
|
+
sseLogger.info('Scheduling SSE reconnection', {
|
|
182
|
+
attempt: this.reconnectAttempts,
|
|
183
|
+
delay: this.config.reconnectDelay
|
|
184
|
+
});
|
|
185
|
+
this.reconnectTimer = window.setTimeout(() => {
|
|
186
|
+
this.disconnect();
|
|
187
|
+
this.connect();
|
|
188
|
+
}, this.config.reconnectDelay);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Handle connection errors
|
|
192
|
+
*/
|
|
193
|
+
handleConnectionError(error) {
|
|
194
|
+
this.state = 'error';
|
|
195
|
+
this.errorHandlers.forEach(handler => handler(error));
|
|
196
|
+
if (this.config.autoReconnect && !this.manualClose) {
|
|
197
|
+
this.handleReconnect();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Register event handler
|
|
202
|
+
*/
|
|
203
|
+
on(eventType, handler) {
|
|
204
|
+
if (!this.handlers.has(eventType)) {
|
|
205
|
+
this.handlers.set(eventType, new Set());
|
|
206
|
+
}
|
|
207
|
+
this.handlers.get(eventType).add(handler);
|
|
208
|
+
sseLogger.info(`Registered handler for SSE event: ${eventType}`);
|
|
209
|
+
// Return unsubscribe function
|
|
210
|
+
return () => {
|
|
211
|
+
this.handlers.get(eventType)?.delete(handler);
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Register error handler
|
|
216
|
+
*/
|
|
217
|
+
onError(handler) {
|
|
218
|
+
this.errorHandlers.add(handler);
|
|
219
|
+
// Return unsubscribe function
|
|
220
|
+
return () => {
|
|
221
|
+
this.errorHandlers.delete(handler);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Disconnect from SSE endpoint
|
|
226
|
+
*/
|
|
227
|
+
disconnect() {
|
|
228
|
+
this.manualClose = true;
|
|
229
|
+
if (this.reconnectTimer !== null) {
|
|
230
|
+
clearTimeout(this.reconnectTimer);
|
|
231
|
+
this.reconnectTimer = null;
|
|
232
|
+
}
|
|
233
|
+
if (this.eventSource) {
|
|
234
|
+
sseLogger.info('Disconnecting from SSE endpoint', {
|
|
235
|
+
url: this.config.url
|
|
236
|
+
});
|
|
237
|
+
this.eventSource.close();
|
|
238
|
+
this.eventSource = null;
|
|
239
|
+
this.state = 'closed';
|
|
240
|
+
// Publish disconnection event
|
|
241
|
+
publish('sse:disconnected', { url: this.config.url }, 'SSEConnection');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Cleanup and disconnect
|
|
246
|
+
*/
|
|
247
|
+
destroy() {
|
|
248
|
+
this.disconnect();
|
|
249
|
+
this.handlers.clear();
|
|
250
|
+
this.errorHandlers.clear();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create an SSE connection
|
|
255
|
+
*/
|
|
256
|
+
export function createSSEConnection(config) {
|
|
257
|
+
return new SSEConnection(config);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Utility function for simple SSE usage
|
|
261
|
+
*/
|
|
262
|
+
export function streamSSE(url, onMessage, options) {
|
|
263
|
+
const connection = createSSEConnection({
|
|
264
|
+
url,
|
|
265
|
+
...options
|
|
266
|
+
});
|
|
267
|
+
connection.on('message', onMessage);
|
|
268
|
+
connection.connect();
|
|
269
|
+
// Return cleanup function
|
|
270
|
+
return () => connection.destroy();
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Fetch with streaming response (for fetch-based streaming, not SSE)
|
|
274
|
+
*/
|
|
275
|
+
export async function* streamFetch(url, options) {
|
|
276
|
+
const response = await fetch(url, options);
|
|
277
|
+
if (!response.ok) {
|
|
278
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
279
|
+
}
|
|
280
|
+
const reader = response.body?.getReader();
|
|
281
|
+
if (!reader) {
|
|
282
|
+
throw new Error('Response body is not readable');
|
|
283
|
+
}
|
|
284
|
+
const decoder = new TextDecoder();
|
|
285
|
+
try {
|
|
286
|
+
while (true) {
|
|
287
|
+
const { done, value } = await reader.read();
|
|
288
|
+
if (done)
|
|
289
|
+
break;
|
|
290
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
291
|
+
yield chunk;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
reader.releaseLock();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Example usage patterns for developers
|
|
300
|
+
*/
|
|
301
|
+
export const SSEExamples = {
|
|
302
|
+
/**
|
|
303
|
+
* Basic SSE connection
|
|
304
|
+
*/
|
|
305
|
+
basic: () => {
|
|
306
|
+
const connection = createSSEConnection({
|
|
307
|
+
url: '/api/events',
|
|
308
|
+
autoReconnect: true
|
|
309
|
+
});
|
|
310
|
+
connection.on('message', (data) => {
|
|
311
|
+
console.log('Received:', data);
|
|
312
|
+
});
|
|
313
|
+
connection.onError((error) => {
|
|
314
|
+
console.error('SSE Error:', error);
|
|
315
|
+
});
|
|
316
|
+
connection.connect();
|
|
317
|
+
return () => connection.disconnect();
|
|
318
|
+
},
|
|
319
|
+
/**
|
|
320
|
+
* AI streaming response
|
|
321
|
+
*/
|
|
322
|
+
aiStreaming: () => {
|
|
323
|
+
const connection = createSSEConnection({
|
|
324
|
+
url: '/api/ai/stream',
|
|
325
|
+
eventTypes: ['token', 'complete', 'error']
|
|
326
|
+
});
|
|
327
|
+
let response = '';
|
|
328
|
+
connection.on('token', (data) => {
|
|
329
|
+
response += data.token;
|
|
330
|
+
// Update UI with new token
|
|
331
|
+
});
|
|
332
|
+
connection.on('complete', (data) => {
|
|
333
|
+
console.log('Complete response:', response);
|
|
334
|
+
connection.disconnect();
|
|
335
|
+
});
|
|
336
|
+
connection.on('error', (data) => {
|
|
337
|
+
console.error('AI Error:', data.error);
|
|
338
|
+
connection.disconnect();
|
|
339
|
+
});
|
|
340
|
+
connection.connect();
|
|
341
|
+
},
|
|
342
|
+
/**
|
|
343
|
+
* Real-time notifications
|
|
344
|
+
*/
|
|
345
|
+
notifications: () => {
|
|
346
|
+
const connection = createSSEConnection({
|
|
347
|
+
url: '/api/notifications/stream',
|
|
348
|
+
withCredentials: true,
|
|
349
|
+
autoReconnect: true
|
|
350
|
+
});
|
|
351
|
+
connection.on('notification', (data) => {
|
|
352
|
+
// Show toast notification
|
|
353
|
+
publish('notification:new', data, 'SSE');
|
|
354
|
+
});
|
|
355
|
+
connection.connect();
|
|
356
|
+
return () => connection.disconnect();
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/utils/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EACb,OAAO,EACP,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAElC,8BAA8B;AAC9B,MAAM,SAAS,GAAG,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAqCnD;;GAEG;AACH,MAAM,OAAO,aAAa;IAUx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AI,EAAE,EAAE;YACjC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;YAC5C,UAAU,CAAC,UAAU,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAC9B,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACvC,UAAU,CAAC,UAAU,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,aAAa,EAAE,GAAG,EAAE;QAClB,MAAM,UAAU,GAAG,mBAAmB,CAAC;YACrC,GAAG,EAAE,2BAA2B;YAChC,eAAe,EAAE,IAAI;YACrB,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;QAEH,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE;YACrC,0BAA0B;YAC1B,OAAO,CAAC,kBAAkB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,OAAO,EAAE,CAAC;QAErB,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACvC,CAAC;CACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xbg.solutions/bpsk-utils-sse",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"description": "XBG SSE - Server-sent events client",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"lib"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"build:watch": "tsc --watch",
|
|
14
|
+
"clean": "rm -rf lib",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@xbg.solutions/bpsk-core": "^1.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|