@trops/dash-core 0.1.50 → 0.1.51
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/dist/electron/index.js +39 -68
- package/dist/electron/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -8348,6 +8348,17 @@ const {
|
|
|
8348
8348
|
LLM_STREAM_ERROR,
|
|
8349
8349
|
} = llmEvents$1;
|
|
8350
8350
|
|
|
8351
|
+
let _nextListenerId = 0;
|
|
8352
|
+
const _listenerMap = new Map();
|
|
8353
|
+
|
|
8354
|
+
function _addListener(channel, callback) {
|
|
8355
|
+
const id = String(++_nextListenerId);
|
|
8356
|
+
const wrapped = (_event, data) => callback(data);
|
|
8357
|
+
ipcRenderer$2.on(channel, wrapped);
|
|
8358
|
+
_listenerMap.set(id, { channel, wrapped });
|
|
8359
|
+
return id;
|
|
8360
|
+
}
|
|
8361
|
+
|
|
8351
8362
|
const llmApi$2 = {
|
|
8352
8363
|
/**
|
|
8353
8364
|
* sendMessage
|
|
@@ -8417,84 +8428,40 @@ const llmApi$2 = {
|
|
|
8417
8428
|
ipcRenderer$2.invoke(LLM_CLI_END_SESSION, { widgetUuid }),
|
|
8418
8429
|
|
|
8419
8430
|
// --- Stream event listeners ---
|
|
8420
|
-
// Each on* method returns
|
|
8421
|
-
//
|
|
8431
|
+
// Each on* method returns an opaque string ID. Strings cross the
|
|
8432
|
+
// contextBridge safely (unlike function refs which get proxied).
|
|
8433
|
+
// Use removeStreamListener(id) to clean up.
|
|
8422
8434
|
|
|
8423
|
-
/**
|
|
8424
|
-
|
|
8425
|
-
* Listen for text chunks as they stream in.
|
|
8426
|
-
* @returns {Function} wrapped callback for use with removeStreamListener
|
|
8427
|
-
*/
|
|
8428
|
-
onStreamDelta: (callback) => {
|
|
8429
|
-
const wrapped = (_event, data) => callback(data);
|
|
8430
|
-
ipcRenderer$2.on(LLM_STREAM_DELTA, wrapped);
|
|
8431
|
-
return wrapped;
|
|
8432
|
-
},
|
|
8435
|
+
/** @returns {string} listener ID */
|
|
8436
|
+
onStreamDelta: (callback) => _addListener(LLM_STREAM_DELTA, callback),
|
|
8433
8437
|
|
|
8434
|
-
/**
|
|
8435
|
-
|
|
8436
|
-
* Listen for tool call notifications.
|
|
8437
|
-
* @returns {Function} wrapped callback for use with removeStreamListener
|
|
8438
|
-
*/
|
|
8439
|
-
onStreamToolCall: (callback) => {
|
|
8440
|
-
const wrapped = (_event, data) => callback(data);
|
|
8441
|
-
ipcRenderer$2.on(LLM_STREAM_TOOL_CALL, wrapped);
|
|
8442
|
-
return wrapped;
|
|
8443
|
-
},
|
|
8438
|
+
/** @returns {string} listener ID */
|
|
8439
|
+
onStreamToolCall: (callback) => _addListener(LLM_STREAM_TOOL_CALL, callback),
|
|
8444
8440
|
|
|
8445
|
-
/**
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
* @returns {Function} wrapped callback for use with removeStreamListener
|
|
8449
|
-
*/
|
|
8450
|
-
onStreamToolResult: (callback) => {
|
|
8451
|
-
const wrapped = (_event, data) => callback(data);
|
|
8452
|
-
ipcRenderer$2.on(LLM_STREAM_TOOL_RESULT, wrapped);
|
|
8453
|
-
return wrapped;
|
|
8454
|
-
},
|
|
8441
|
+
/** @returns {string} listener ID */
|
|
8442
|
+
onStreamToolResult: (callback) =>
|
|
8443
|
+
_addListener(LLM_STREAM_TOOL_RESULT, callback),
|
|
8455
8444
|
|
|
8456
|
-
/**
|
|
8457
|
-
|
|
8458
|
-
* Listen for stream completion (final response).
|
|
8459
|
-
* @returns {Function} wrapped callback for use with removeStreamListener
|
|
8460
|
-
*/
|
|
8461
|
-
onStreamComplete: (callback) => {
|
|
8462
|
-
const wrapped = (_event, data) => callback(data);
|
|
8463
|
-
ipcRenderer$2.on(LLM_STREAM_COMPLETE, wrapped);
|
|
8464
|
-
return wrapped;
|
|
8465
|
-
},
|
|
8445
|
+
/** @returns {string} listener ID */
|
|
8446
|
+
onStreamComplete: (callback) => _addListener(LLM_STREAM_COMPLETE, callback),
|
|
8466
8447
|
|
|
8467
|
-
/**
|
|
8468
|
-
|
|
8469
|
-
* Listen for stream errors.
|
|
8470
|
-
* @returns {Function} wrapped callback for use with removeStreamListener
|
|
8471
|
-
*/
|
|
8472
|
-
onStreamError: (callback) => {
|
|
8473
|
-
const wrapped = (_event, data) => callback(data);
|
|
8474
|
-
ipcRenderer$2.on(LLM_STREAM_ERROR, wrapped);
|
|
8475
|
-
return wrapped;
|
|
8476
|
-
},
|
|
8448
|
+
/** @returns {string} listener ID */
|
|
8449
|
+
onStreamError: (callback) => _addListener(LLM_STREAM_ERROR, callback),
|
|
8477
8450
|
|
|
8478
8451
|
/**
|
|
8479
8452
|
* removeStreamListener
|
|
8480
|
-
* Remove a specific stream listener by
|
|
8453
|
+
* Remove a specific stream listener by its opaque ID.
|
|
8481
8454
|
*
|
|
8482
|
-
* @param {string}
|
|
8483
|
-
* @param {
|
|
8455
|
+
* @param {string} idOrChannel - listener ID (or legacy channel name when second arg is provided)
|
|
8456
|
+
* @param {string} [id] - listener ID when called with legacy (channel, id) signature
|
|
8484
8457
|
*/
|
|
8485
|
-
removeStreamListener: (
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
streamChannels: {
|
|
8493
|
-
delta: LLM_STREAM_DELTA,
|
|
8494
|
-
toolCall: LLM_STREAM_TOOL_CALL,
|
|
8495
|
-
toolResult: LLM_STREAM_TOOL_RESULT,
|
|
8496
|
-
complete: LLM_STREAM_COMPLETE,
|
|
8497
|
-
error: LLM_STREAM_ERROR,
|
|
8458
|
+
removeStreamListener: (idOrChannel, id) => {
|
|
8459
|
+
const listenerId = id !== undefined ? String(id) : String(idOrChannel);
|
|
8460
|
+
const entry = _listenerMap.get(listenerId);
|
|
8461
|
+
if (entry) {
|
|
8462
|
+
ipcRenderer$2.removeListener(entry.channel, entry.wrapped);
|
|
8463
|
+
_listenerMap.delete(listenerId);
|
|
8464
|
+
}
|
|
8498
8465
|
},
|
|
8499
8466
|
|
|
8500
8467
|
/**
|
|
@@ -8503,6 +8470,10 @@ const llmApi$2 = {
|
|
|
8503
8470
|
* Prefer removeStreamListener for scoped cleanup.
|
|
8504
8471
|
*/
|
|
8505
8472
|
removeAllStreamListeners: () => {
|
|
8473
|
+
for (const [, entry] of _listenerMap) {
|
|
8474
|
+
ipcRenderer$2.removeListener(entry.channel, entry.wrapped);
|
|
8475
|
+
}
|
|
8476
|
+
_listenerMap.clear();
|
|
8506
8477
|
ipcRenderer$2.removeAllListeners(LLM_STREAM_DELTA);
|
|
8507
8478
|
ipcRenderer$2.removeAllListeners(LLM_STREAM_TOOL_CALL);
|
|
8508
8479
|
ipcRenderer$2.removeAllListeners(LLM_STREAM_TOOL_RESULT);
|