@isdk/tool-electron 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.
@@ -0,0 +1,163 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / ElectronClientPubSubTransport
6
+
7
+ # Class: ElectronClientPubSubTransport
8
+
9
+ Defined in: [tool-electron/src/pubsub/electron-client.ts:53](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-client.ts#L53)
10
+
11
+ Renderer-side Pub/Sub transport over Electron IPC.
12
+
13
+ ## Param
14
+
15
+ Namespace for IPC channel generation. Supports `electron://` URI format
16
+ (e.g., `'electron://my-app'` → namespace `my-app`). Defaults to empty string
17
+ (call [setApiRoot](#setapiroot) before [connect](#connect)).
18
+
19
+ ## Param
20
+
21
+ Optional config.
22
+
23
+ ## Param
24
+
25
+ Injectable bridge with `on`, `off`, and `send` methods.
26
+ When provided, used instead of directly importing `ipcRenderer`.
27
+
28
+ ## Implements
29
+
30
+ - `IPubSubClientTransport`
31
+
32
+ ## Constructors
33
+
34
+ ### Constructor
35
+
36
+ > **new ElectronClientPubSubTransport**(`apiRoot?`, `options?`): `ElectronClientPubSubTransport`
37
+
38
+ Defined in: [tool-electron/src/pubsub/electron-client.ts:60](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-client.ts#L60)
39
+
40
+ #### Parameters
41
+
42
+ ##### apiRoot?
43
+
44
+ `string`
45
+
46
+ ##### options?
47
+
48
+ ###### bridge?
49
+
50
+ [`PubSubBridge`](../type-aliases/PubSubBridge.md)
51
+
52
+ #### Returns
53
+
54
+ `ElectronClientPubSubTransport`
55
+
56
+ ## Methods
57
+
58
+ ### cleanup()
59
+
60
+ > **cleanup**(): `Promise`\<`void`\>
61
+
62
+ Defined in: [tool-electron/src/pubsub/electron-client.ts:199](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-client.ts#L199)
63
+
64
+ Clean up all IPC listeners and event subscriptions.
65
+ Removes the downstream IPC listener and clears all registered event handlers.
66
+ Should be called when the transport is no longer needed (e.g., when the window closes).
67
+
68
+ #### Returns
69
+
70
+ `Promise`\<`void`\>
71
+
72
+ ***
73
+
74
+ ### connect()
75
+
76
+ > **connect**(`toolName`, `params?`): `PubSubClientStream`
77
+
78
+ Defined in: [tool-electron/src/pubsub/electron-client.ts:108](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-client.ts#L108)
79
+
80
+ Establish a PubSub connection stream.
81
+ Sends a `pubsub-connect:{ns}` IPC message and returns a `PubSubClientStream`
82
+ for subscribing to events and sending messages upstream.
83
+
84
+ #### Parameters
85
+
86
+ ##### toolName
87
+
88
+ `string`
89
+
90
+ Logical connection name (not used for channel routing;
91
+ channels are derived from the constructor's `apiRoot`).
92
+
93
+ ##### params?
94
+
95
+ `any`
96
+
97
+ Optional connection parameters (e.g., `{ events: ['event-a', 'event-b'] }`
98
+ for initial event subscriptions).
99
+
100
+ #### Returns
101
+
102
+ `PubSubClientStream`
103
+
104
+ A `PubSubClientStream` instance.
105
+
106
+ #### Implementation of
107
+
108
+ `IPubSubClientTransport.connect`
109
+
110
+ ***
111
+
112
+ ### disconnect()
113
+
114
+ > **disconnect**(`stream`): `void`
115
+
116
+ Defined in: [tool-electron/src/pubsub/electron-client.ts:190](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-client.ts#L190)
117
+
118
+ Disconnect a PubSub stream.
119
+ Delegates to `stream.close()` which sends a `pubsub-disconnect:{ns}` IPC message
120
+ and cleans up local event listeners.
121
+
122
+ #### Parameters
123
+
124
+ ##### stream
125
+
126
+ `PubSubClientStream`
127
+
128
+ The stream to disconnect.
129
+
130
+ #### Returns
131
+
132
+ `void`
133
+
134
+ #### Implementation of
135
+
136
+ `IPubSubClientTransport.disconnect`
137
+
138
+ ***
139
+
140
+ ### setApiRoot()
141
+
142
+ > **setApiRoot**(`apiRoot`): `void`
143
+
144
+ Defined in: [tool-electron/src/pubsub/electron-client.ts:70](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-client.ts#L70)
145
+
146
+ Set the API root (namespace) and derive IPC channel names.
147
+
148
+ #### Parameters
149
+
150
+ ##### apiRoot
151
+
152
+ `string`
153
+
154
+ Namespace in `electron://` URI format (e.g., `'electron://my-app'`).
155
+ The host is extracted as the namespace for PubSub channel generation.
156
+
157
+ #### Returns
158
+
159
+ `void`
160
+
161
+ #### Implementation of
162
+
163
+ `IPubSubClientTransport.setApiRoot`
@@ -0,0 +1,384 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / ElectronServerPubSubTransport
6
+
7
+ # Class: ElectronServerPubSubTransport
8
+
9
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:50](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L50)
10
+
11
+ Main-process Pub/Sub transport over Electron IPC.
12
+
13
+ ## Param
14
+
15
+ Namespace in `electron://` URI format (e.g., `'electron://my-app'`).
16
+ Used to derive all IPC channel names for PubSub communication.
17
+ Must be non-empty.
18
+
19
+ ## Param
20
+
21
+ Optional config.
22
+
23
+ ## Param
24
+
25
+ Injectable bridge with `on`, `removeAllListeners` methods.
26
+ When provided, used instead of directly importing `ipcMain`.
27
+
28
+ ## Implements
29
+
30
+ - `IPubSubServerTransport`
31
+
32
+ ## Constructors
33
+
34
+ ### Constructor
35
+
36
+ > **new ElectronServerPubSubTransport**(`namespace`, `options?`): `ElectronServerPubSubTransport`
37
+
38
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:63](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L63)
39
+
40
+ #### Parameters
41
+
42
+ ##### namespace
43
+
44
+ `string`
45
+
46
+ ##### options?
47
+
48
+ ###### ipcMain?
49
+
50
+ [`ServerPubSubIpcMain`](../type-aliases/ServerPubSubIpcMain.md)
51
+
52
+ #### Returns
53
+
54
+ `ElectronServerPubSubTransport`
55
+
56
+ ## Properties
57
+
58
+ ### name
59
+
60
+ > `readonly` **name**: `"electron"` = `'electron'`
61
+
62
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:51](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L51)
63
+
64
+ A unique, human-readable name for the transport (e.g., 'sse', 'websocket').
65
+
66
+ #### Implementation of
67
+
68
+ `IPubSubServerTransport.name`
69
+
70
+ ***
71
+
72
+ ### protocol
73
+
74
+ > `readonly` **protocol**: `"electron"`
75
+
76
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:52](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L52)
77
+
78
+ The protocol identifier.
79
+
80
+ #### Implementation of
81
+
82
+ `IPubSubServerTransport.protocol`
83
+
84
+ ## Methods
85
+
86
+ ### cleanup()
87
+
88
+ > **cleanup**(): `void`
89
+
90
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:254](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L254)
91
+
92
+ Clean up all IPC listeners and session state.
93
+ Removes `connect`, `disconnect`, and `upstream` IPC listeners,
94
+ clears all sessions and subscriptions.
95
+ Should be called when the transport is no longer needed (e.g., during app shutdown).
96
+
97
+ #### Returns
98
+
99
+ `void`
100
+
101
+ ***
102
+
103
+ ### connect()
104
+
105
+ > **connect**(`options?`): `PubSubServerSession`
106
+
107
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:117](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L117)
108
+
109
+ Connect a client session.
110
+ Called internally by the IPC listener (registered in [listen](#listen)) when
111
+ a client sends a `pubsub-connect:{ns}` message. Creates a `PubSubServerSession`
112
+ for the new client and stores it for event broadcasting.
113
+
114
+ #### Parameters
115
+
116
+ ##### options?
117
+
118
+ ###### events?
119
+
120
+ `string`[]
121
+
122
+ Optional initial event subscriptions for the session.
123
+
124
+ ###### req
125
+
126
+ `IpcMainEvent`
127
+
128
+ The `IpcMainEvent` from Electron IPC.
129
+
130
+ ###### res
131
+
132
+ `WebContents`
133
+
134
+ The `WebContents` of the client window.
135
+
136
+ #### Returns
137
+
138
+ `PubSubServerSession`
139
+
140
+ The newly created `PubSubServerSession`.
141
+
142
+ #### Throws
143
+
144
+ If `req` or `res` are not provided.
145
+
146
+ #### Implementation of
147
+
148
+ `IPubSubServerTransport.connect`
149
+
150
+ ***
151
+
152
+ ### getSessionFromReq()
153
+
154
+ > **getSessionFromReq**(`req`): `PubSubServerSession` \| `undefined`
155
+
156
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:266](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L266)
157
+
158
+ Find a client session by its IPC request event.
159
+
160
+ #### Parameters
161
+
162
+ ##### req
163
+
164
+ `IpcMainEvent`
165
+
166
+ The `IpcMainEvent` to look up.
167
+
168
+ #### Returns
169
+
170
+ `PubSubServerSession` \| `undefined`
171
+
172
+ The corresponding `PubSubServerSession`, or `undefined` if not found.
173
+
174
+ #### Implementation of
175
+
176
+ `IPubSubServerTransport.getSessionFromReq`
177
+
178
+ ***
179
+
180
+ ### listen()
181
+
182
+ > **listen**(): `void`
183
+
184
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:75](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L75)
185
+
186
+ Activates the transport by setting up listeners for IPC events.
187
+ This method should be called once in the main process during application setup.
188
+
189
+ #### Returns
190
+
191
+ `void`
192
+
193
+ ***
194
+
195
+ ### onConnection()
196
+
197
+ > **onConnection**(`cb`): `void`
198
+
199
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:234](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L234)
200
+
201
+ Register a callback for new client connections.
202
+
203
+ #### Parameters
204
+
205
+ ##### cb
206
+
207
+ (`s`) => `void`
208
+
209
+ Callback receiving the new `PubSubServerSession`.
210
+
211
+ #### Returns
212
+
213
+ `void`
214
+
215
+ #### Implementation of
216
+
217
+ `IPubSubServerTransport.onConnection`
218
+
219
+ ***
220
+
221
+ ### onDisconnect()
222
+
223
+ > **onDisconnect**(`cb`): `void`
224
+
225
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:240](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L240)
226
+
227
+ Register a callback for client disconnections.
228
+
229
+ #### Parameters
230
+
231
+ ##### cb
232
+
233
+ (`s`) => `void`
234
+
235
+ Callback receiving the disconnected `PubSubServerSession`.
236
+
237
+ #### Returns
238
+
239
+ `void`
240
+
241
+ #### Implementation of
242
+
243
+ `IPubSubServerTransport.onDisconnect`
244
+
245
+ ***
246
+
247
+ ### onMessage()
248
+
249
+ > **onMessage**(`cb`): `void`
250
+
251
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:246](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L246)
252
+
253
+ Register a callback for incoming messages from clients.
254
+
255
+ #### Parameters
256
+
257
+ ##### cb
258
+
259
+ (`session`, `event`, `data`, `ctx?`) => `void`
260
+
261
+ Callback receiving the session, event name, data, and optional context.
262
+
263
+ #### Returns
264
+
265
+ `void`
266
+
267
+ #### Implementation of
268
+
269
+ `IPubSubServerTransport.onMessage`
270
+
271
+ ***
272
+
273
+ ### publish()
274
+
275
+ > **publish**(`event`, `data`, `target?`, `ctx?`): `void`
276
+
277
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:210](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L210)
278
+
279
+ Publish an event to connected clients.
280
+ If `target.clientId` is provided, only the specified client(s) receive the event.
281
+ Otherwise, the event is broadcast to all subscribed clients.
282
+
283
+ #### Parameters
284
+
285
+ ##### event
286
+
287
+ `string`
288
+
289
+ The event name to publish.
290
+
291
+ ##### data
292
+
293
+ `any`
294
+
295
+ The event payload.
296
+
297
+ ##### target?
298
+
299
+ Optional target specification for directed delivery.
300
+
301
+ ###### clientId?
302
+
303
+ `string` \| `string`[]
304
+
305
+ A single client ID or array of client IDs to target.
306
+
307
+ ##### ctx?
308
+
309
+ `PubSubCtx`
310
+
311
+ Optional PubSub context.
312
+
313
+ #### Returns
314
+
315
+ `void`
316
+
317
+ #### Implementation of
318
+
319
+ `IPubSubServerTransport.publish`
320
+
321
+ ***
322
+
323
+ ### subscribe()
324
+
325
+ > **subscribe**(`session`, `events`): `void`
326
+
327
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:172](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L172)
328
+
329
+ Subscribe a client session to one or more events.
330
+ Events must be subscribed before they can be received by the client.
331
+
332
+ #### Parameters
333
+
334
+ ##### session
335
+
336
+ `PubSubServerSession`
337
+
338
+ The client session to subscribe.
339
+
340
+ ##### events
341
+
342
+ `string`[]
343
+
344
+ Array of event names to subscribe to.
345
+
346
+ #### Returns
347
+
348
+ `void`
349
+
350
+ #### Implementation of
351
+
352
+ `IPubSubServerTransport.subscribe`
353
+
354
+ ***
355
+
356
+ ### unsubscribe()
357
+
358
+ > **unsubscribe**(`session`, `events`): `void`
359
+
360
+ Defined in: [tool-electron/src/pubsub/electron-server.ts:191](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/pubsub/electron-server.ts#L191)
361
+
362
+ Unsubscribe a client session from one or more events.
363
+
364
+ #### Parameters
365
+
366
+ ##### session
367
+
368
+ `PubSubServerSession`
369
+
370
+ The client session to unsubscribe.
371
+
372
+ ##### events
373
+
374
+ `string`[]
375
+
376
+ Array of event names to unsubscribe from.
377
+
378
+ #### Returns
379
+
380
+ `void`
381
+
382
+ #### Implementation of
383
+
384
+ `IPubSubServerTransport.unsubscribe`