cross-tab-worker-databus 0.20.97 → 0.21.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.
@@ -703,6 +703,12 @@ function assertClusterOptions(options) {
703
703
  }
704
704
  assertLoadWeightingOptions(options.loadWeighting);
705
705
  }
706
+ function assertPublicTopic(operation, topic) {
707
+ if (topic !== "") return;
708
+ throw new TypeError(
709
+ `CrossTabDataBus.${operation}("") addresses a channel no transport can route; use a non-empty topic.`
710
+ );
711
+ }
706
712
 
707
713
  // src/core/cluster.ts
708
714
  var CLUSTER_PROTOCOL_VERSION = 1;
@@ -2466,7 +2472,7 @@ var DedupManager = class {
2466
2472
  };
2467
2473
 
2468
2474
  // src/core/version.ts
2469
- var SDK_VERSION = true ? "0.20.97" : "";
2475
+ var SDK_VERSION = true ? "0.21.0" : "";
2470
2476
 
2471
2477
  // src/core/data-bus.ts
2472
2478
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
@@ -2557,10 +2563,6 @@ var CrossTabDataBus = class {
2557
2563
  // themselves demand: the failure path starts an on-demand reopen instead of
2558
2564
  // stranding them until some unrelated future operation arrives.
2559
2565
  recoveryWaiters = 0;
2560
- // Latch for the empty-topic deprecation warning so a hot publish path cannot
2561
- // fill the console. It is per-bus and never reset: the warning is about the
2562
- // caller's code, not about a transient runtime condition.
2563
- emptyTopicWarned = false;
2564
2566
  /** Monotonic generation incremented on every successful transport open.
2565
2567
  * Stays in lockstep with `lastSuccessAt` so callers can detect that the
2566
2568
  * transport has been reopened even if the timestamp window is short. */
@@ -2955,8 +2957,11 @@ var CrossTabDataBus = class {
2955
2957
  * unsubscribe function for convenience. During an explicit stop() the
2956
2958
  * registration is rejected through onError and a no-op cleanup is returned,
2957
2959
  * so a late subscriber cannot leak into a future restart.
2960
+ * @throws {TypeError} when `topic` is `''` — no transport can address such a
2961
+ * channel, so the subscription could never receive anything.
2958
2962
  */
2959
2963
  subscribe(topic, handler, options) {
2964
+ assertPublicTopic("subscribe", topic);
2960
2965
  if (this.stopping) {
2961
2966
  this.reportError(new Error(
2962
2967
  "CrossTabDataBus is stopping; subscribe() was not registered. Wait for stop() to resolve, then call start() before subscribing again."
@@ -2965,7 +2970,6 @@ var CrossTabDataBus = class {
2965
2970
  };
2966
2971
  }
2967
2972
  this.ensureStarted();
2968
- if (topic === "") this.warnEmptyTopic("subscribe");
2969
2973
  const handlers = this.topicHandlers.get(topic) ?? /* @__PURE__ */ new Set();
2970
2974
  const wasUnused = handlers.size === 0;
2971
2975
  handlers.add(handler);
@@ -3015,20 +3019,10 @@ var CrossTabDataBus = class {
3015
3019
  resetDedup() {
3016
3020
  this.dedupManager.reset();
3017
3021
  }
3018
- /** Warn (once per bus) that an empty topic is deprecated, without changing
3019
- * behavior yet. `''` flows through routing as a literal channel, so the
3020
- * subscription it creates can never be addressed by a transport: the message
3021
- * silently goes nowhere. A future minor rejects it at this boundary. */
3022
- warnEmptyTopic(operation) {
3023
- if (this.emptyTopicWarned) return;
3024
- this.emptyTopicWarned = true;
3025
- console.warn(
3026
- `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.`
3027
- );
3028
- }
3029
- /** Publish a message to `topic`. The owning Worker delivers it to the transport. */
3022
+ /** Publish a message to `topic`. The owning Worker delivers it to the transport.
3023
+ * @throws {TypeError} when `topic` is `''`; see `subscribe()`. */
3030
3024
  publish(topic, data, options) {
3031
- if (topic === "") this.warnEmptyTopic("publish");
3025
+ assertPublicTopic("publish", topic);
3032
3026
  this.ensureStarted();
3033
3027
  if (this.rejectPublishDuringStop("publish")) return;
3034
3028
  if (!this.cluster.publish(topic, data, options)) {
@@ -3043,11 +3037,14 @@ var CrossTabDataBus = class {
3043
3037
  * in one tick. Per-item dedup / replay / ordering is preserved; each item
3044
3038
  * may carry its own `messageId` / `timestamp` via `options`. Empty array is
3045
3039
  * a no-op; single-item array delegates to `publish()`.
3040
+ * @throws {TypeError} when `topic` is `''`; see `subscribe()`. Checked before
3041
+ * the empty-array no-op, so `publishBatch('', [])` throws too — the topic is
3042
+ * the caller's bug regardless of whether anything is carried.
3046
3043
  */
3047
3044
  publishBatch(topic, items) {
3045
+ assertPublicTopic("publishBatch", topic);
3048
3046
  this.ensureStarted();
3049
3047
  if (items.length === 0) return;
3050
- if (topic === "") this.warnEmptyTopic("publishBatch");
3051
3048
  if (this.rejectPublishDuringStop("publishBatch")) return;
3052
3049
  if (items.length === 1) {
3053
3050
  const first = items[0];