cross-tab-worker-databus 0.7.0 → 0.8.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.
@@ -5005,7 +5005,7 @@ var CentrifugeSession = class {
5005
5005
  return;
5006
5006
  case "PUBLISH":
5007
5007
  case "PUBLISH_BIN":
5008
- this.publish(message.topic, message.data);
5008
+ this.publish(message.topic, message.data, message.messageId);
5009
5009
  return;
5010
5010
  case "STOP":
5011
5011
  this.stop();
@@ -5070,9 +5070,10 @@ var CentrifugeSession = class {
5070
5070
  subscription.unsubscribe();
5071
5071
  }
5072
5072
  /** Publish a message to the Centrifuge channel. */
5073
- publish(topic, data) {
5073
+ publish(topic, data, messageId) {
5074
5074
  if (!this.client) return this.postError(new Error("Centrifuge client is not initialized."));
5075
- void this.client.publish(topic, data).catch((error) => this.postError(error));
5075
+ const payload = messageId ? { data, messageId } : data;
5076
+ void this.client.publish(topic, payload).catch((error) => this.postError(error));
5076
5077
  }
5077
5078
  /** Forward a publication to the transport. Binary payloads take the
5078
5079
  * zero-copy `MESSAGE_BIN` path when `transferable` is enabled; everything
@@ -5084,7 +5085,9 @@ var CentrifugeSession = class {
5084
5085
  this.post({ type: "MESSAGE_BIN", topic, data }, [data]);
5085
5086
  return;
5086
5087
  }
5087
- this.post({ type: "MESSAGE", topic, data });
5088
+ const messageId = data && typeof data === "object" && typeof data.messageId === "string" ? data.messageId : void 0;
5089
+ const payload = messageId && Object.prototype.hasOwnProperty.call(data, "data") ? data.data : data;
5090
+ this.post({ type: "MESSAGE", topic, data: payload, ...messageId ? { messageId } : {} });
5088
5091
  }
5089
5092
  /** Disconnect the client and clear all subscriptions. */
5090
5093
  stop() {