@trops/dash-core 0.1.639 → 0.1.640

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.
@@ -76449,6 +76449,19 @@ var memoryTools = { MEMORY_SERVER: MEMORY_SERVER$1, MEMORY_TOOLS: MEMORY_TOOLS$1
76449
76449
  * Pure (NFR-006): no Electron, no I/O.
76450
76450
  */
76451
76451
 
76452
+ /**
76453
+ * Copied dashboards reuse widget ids, so one eventType can come from several
76454
+ * dashboards. A subscription picked in the bot form records its dashboard
76455
+ * (`source.workspaceId`); it then only matches events published from that
76456
+ * dashboard. Unstamped events and dashboard-less subscriptions still match.
76457
+ */
76458
+ function sameDashboard(sub, event) {
76459
+ const want = sub.source && sub.source.workspaceId;
76460
+ const got = event.workspaceId;
76461
+ if (want == null || want === "" || got == null || got === "") return true;
76462
+ return String(want) === String(got);
76463
+ }
76464
+
76452
76465
  /**
76453
76466
  * @param {Array<object>} bots bot definitions (each may have `subscriptions`)
76454
76467
  * @param {{ eventType: string, workspaceId?: string }} event
@@ -76463,7 +76476,9 @@ function matchSubscribedBots$1(bots, event, opts = {}) {
76463
76476
  return bots.filter((bot) => {
76464
76477
  if (!bot || bot.id === excludeBotId) return false;
76465
76478
  const subs = Array.isArray(bot.subscriptions) ? bot.subscriptions : [];
76466
- const subscribed = subs.some((s) => s && s.eventType === event.eventType);
76479
+ const subscribed = subs.some(
76480
+ (s) => s && s.eventType === event.eventType && sameDashboard(s, event),
76481
+ );
76467
76482
  if (!subscribed) return false;
76468
76483
 
76469
76484
  // Workspace scoping (forward-compatible): only enforced once events carry a
@@ -82580,8 +82595,15 @@ function createMainApi$1(extensions = {}) {
82580
82595
  mcpDashServer: mcpDashServerApi$1,
82581
82596
 
82582
82597
  widgetEvent: {
82583
- publish: (eventType, content) => {
82584
- ipcRenderer.send("widget-event:publish", { eventType, content });
82598
+ // meta.workspaceId = the publishing dashboard (bot subscriptions use it).
82599
+ publish: (eventType, content, meta) => {
82600
+ const workspaceId = meta && meta.workspaceId;
82601
+ ipcRenderer.send(
82602
+ "widget-event:publish",
82603
+ workspaceId
82604
+ ? { eventType, content, workspaceId }
82605
+ : { eventType, content },
82606
+ );
82585
82607
  },
82586
82608
  getLastEvents: () => ipcRenderer.invoke("widget-event:get-last-events"),
82587
82609
  },