cross-tab-worker-databus 0.20.95 → 0.20.97

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.
@@ -2468,7 +2468,7 @@ var DedupManager = class {
2468
2468
  };
2469
2469
 
2470
2470
  // src/core/version.ts
2471
- var SDK_VERSION = true ? "0.20.95" : "";
2471
+ var SDK_VERSION = true ? "0.20.97" : "";
2472
2472
 
2473
2473
  // src/core/data-bus.ts
2474
2474
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
@@ -2559,6 +2559,10 @@ var CrossTabDataBus = class {
2559
2559
  // themselves demand: the failure path starts an on-demand reopen instead of
2560
2560
  // stranding them until some unrelated future operation arrives.
2561
2561
  recoveryWaiters = 0;
2562
+ // Latch for the empty-topic deprecation warning so a hot publish path cannot
2563
+ // fill the console. It is per-bus and never reset: the warning is about the
2564
+ // caller's code, not about a transient runtime condition.
2565
+ emptyTopicWarned = false;
2562
2566
  /** Monotonic generation incremented on every successful transport open.
2563
2567
  * Stays in lockstep with `lastSuccessAt` so callers can detect that the
2564
2568
  * transport has been reopened even if the timestamp window is short. */
@@ -2963,6 +2967,7 @@ var CrossTabDataBus = class {
2963
2967
  };
2964
2968
  }
2965
2969
  this.ensureStarted();
2970
+ if (topic === "") this.warnEmptyTopic("subscribe");
2966
2971
  const handlers = this.topicHandlers.get(topic) ?? /* @__PURE__ */ new Set();
2967
2972
  const wasUnused = handlers.size === 0;
2968
2973
  handlers.add(handler);
@@ -3012,8 +3017,20 @@ var CrossTabDataBus = class {
3012
3017
  resetDedup() {
3013
3018
  this.dedupManager.reset();
3014
3019
  }
3020
+ /** Warn (once per bus) that an empty topic is deprecated, without changing
3021
+ * behavior yet. `''` flows through routing as a literal channel, so the
3022
+ * subscription it creates can never be addressed by a transport: the message
3023
+ * silently goes nowhere. A future minor rejects it at this boundary. */
3024
+ warnEmptyTopic(operation) {
3025
+ if (this.emptyTopicWarned) return;
3026
+ this.emptyTopicWarned = true;
3027
+ console.warn(
3028
+ `cross-tab-worker-databus: ${operation}("") addresses a channel no transport can route. Use a non-empty topic; passing "" is planned to throw in a future minor.`
3029
+ );
3030
+ }
3015
3031
  /** Publish a message to `topic`. The owning Worker delivers it to the transport. */
3016
3032
  publish(topic, data, options) {
3033
+ if (topic === "") this.warnEmptyTopic("publish");
3017
3034
  this.ensureStarted();
3018
3035
  if (this.rejectPublishDuringStop("publish")) return;
3019
3036
  if (!this.cluster.publish(topic, data, options)) {
@@ -3032,6 +3049,7 @@ var CrossTabDataBus = class {
3032
3049
  publishBatch(topic, items) {
3033
3050
  this.ensureStarted();
3034
3051
  if (items.length === 0) return;
3052
+ if (topic === "") this.warnEmptyTopic("publishBatch");
3035
3053
  if (this.rejectPublishDuringStop("publishBatch")) return;
3036
3054
  if (items.length === 1) {
3037
3055
  const first = items[0];
@@ -4200,9 +4218,6 @@ function createCentrifugeDataBus(options) {
4200
4218
  });
4201
4219
  }
4202
4220
  function createDefaultWorker() {
4203
- if (typeof Worker === "undefined") {
4204
- throw new Error("CentrifugeWorkerTransport requires a browser Worker implementation.");
4205
- }
4206
4221
  let workerUrl;
4207
4222
  try {
4208
4223
  workerUrl = new URL("./centrifuge.worker.js", import_meta.url);
@@ -4217,9 +4232,6 @@ function createDefaultWorker() {
4217
4232
  });
4218
4233
  }
4219
4234
  function createDefaultSharedWorker() {
4220
- if (typeof SharedWorker === "undefined") {
4221
- throw new Error("CentrifugeWorkerTransport requires a browser SharedWorker implementation.");
4222
- }
4223
4235
  let workerUrl;
4224
4236
  try {
4225
4237
  workerUrl = new URL("./centrifuge.shared.worker.js", import_meta.url);