@trops/dash-core 0.1.44 → 0.1.46

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/index.esm.js CHANGED
@@ -103,14 +103,36 @@ var event = {
103
103
  this.list = new Map();
104
104
  }
105
105
  };
106
+ var ipcBridgeListener = null;
106
107
  var DashboardPublisher = {
107
108
  sub: function sub(eventType, action, uuid) {
108
109
  event.on(eventType, action, uuid);
109
110
  },
110
111
  pub: function pub(eventType, content) {
112
+ var _window$mainApi;
111
113
  event.emit(eventType, content);
112
- // send to ALL
113
- // event.emit("DashboardPublisher.monitor", { eventType, content });
114
+
115
+ // Forward to other windows via IPC bridge
116
+ if ((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && _window$mainApi.widgetEvent) {
117
+ window.mainApi.widgetEvent.publish(eventType, content);
118
+ }
119
+ },
120
+ enableIpcBridge: function enableIpcBridge() {
121
+ var _window$mainApi2;
122
+ if (ipcBridgeListener) return;
123
+ if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.on)) return;
124
+ ipcBridgeListener = function ipcBridgeListener(_e, message) {
125
+ event.emit(message.eventType, message.content);
126
+ };
127
+ window.mainApi.on("widget-event:broadcast", ipcBridgeListener);
128
+ },
129
+ disableIpcBridge: function disableIpcBridge() {
130
+ var _window$mainApi3;
131
+ if (!ipcBridgeListener) return;
132
+ if ((_window$mainApi3 = window.mainApi) !== null && _window$mainApi3 !== void 0 && _window$mainApi3.removeListener) {
133
+ window.mainApi.removeListener("widget-event:broadcast", ipcBridgeListener);
134
+ }
135
+ ipcBridgeListener = null;
114
136
  },
115
137
  listeners: function listeners() {
116
138
  return event.list;
@@ -2452,6 +2474,12 @@ var DashboardWrapper = function DashboardWrapper(_ref) {
2452
2474
  w.setElectronApi(dashApi);
2453
2475
  return w;
2454
2476
  }, [dashApi]);
2477
+ useEffect(function () {
2478
+ DashboardPublisher.enableIpcBridge();
2479
+ return function () {
2480
+ return DashboardPublisher.disableIpcBridge();
2481
+ };
2482
+ }, []);
2455
2483
  var providers = (appContext === null || appContext === void 0 ? void 0 : appContext.providers) || EMPTY_PROVIDERS;
2456
2484
  var contextValue = useMemo(function () {
2457
2485
  return {