cross-tab-worker-databus 0.20.96 → 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.
- package/CHANGELOG.md +29 -0
- package/dist/centrifuge.d.ts.map +1 -1
- package/dist/centrifuge.js +1 -7
- package/dist/centrifuge.js.map +2 -2
- package/dist/{chunk-SSSJNWCH.js → chunk-EJDXU4DK.js} +18 -21
- package/dist/chunk-EJDXU4DK.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +17 -26
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +17 -20
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/data-bus.d.ts +7 -7
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/validation.d.ts +8 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/docs/api.md +1 -1
- package/docs/architecture.md +1 -0
- package/docs/benchmarks.md +7 -7
- package/docs/getting-started.md +3 -1
- package/docs/roadmap.md +21 -3
- package/docs/transports.md +1 -0
- package/docs/zh/api.md +1 -1
- package/docs/zh/architecture.md +1 -0
- package/docs/zh/benchmarks.md +7 -7
- package/docs/zh/getting-started.md +3 -1
- package/docs/zh/roadmap.md +21 -3
- package/docs/zh/transports.md +1 -0
- package/package.json +3 -2
- package/dist/chunk-SSSJNWCH.js.map +0 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -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.
|
|
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
|
-
/**
|
|
3019
|
-
*
|
|
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
|
-
|
|
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];
|