cross-tab-worker-databus 0.20.89 → 0.20.91
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 +23 -0
- package/dist/centrifuge-session.d.ts.map +1 -1
- package/dist/centrifuge.js +7 -9
- package/dist/centrifuge.js.map +2 -2
- package/dist/centrifuge.shared.worker.js +6 -8
- package/dist/centrifuge.shared.worker.js.map +2 -2
- package/dist/centrifuge.worker.js +6 -8
- package/dist/centrifuge.worker.js.map +2 -2
- package/dist/{chunk-77BQELW4.js → chunk-DMM5KBNG.js} +9 -6
- package/dist/chunk-DMM5KBNG.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +14 -13
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +18 -6
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +2 -2
- package/dist/websocket.d.ts +3 -0
- package/dist/websocket.d.ts.map +1 -1
- package/docs/api.md +1 -1
- package/docs/architecture.md +7 -3
- package/docs/benchmarks.md +7 -7
- package/docs/capabilities.md +1 -1
- package/docs/release-checklist.md +2 -2
- package/docs/roadmap.md +19 -2
- package/docs/zh/api.md +2 -0
- package/docs/zh/architecture.md +7 -3
- package/docs/zh/benchmarks.md +7 -7
- package/docs/zh/capabilities.md +1 -1
- package/docs/zh/release-checklist.md +2 -2
- package/docs/zh/roadmap.md +19 -2
- package/package.json +1 -1
- package/dist/chunk-77BQELW4.js.map +0 -7
package/dist/cjs/centrifuge.cjs
CHANGED
|
@@ -851,10 +851,12 @@ var WorkerClusterRuntime = class {
|
|
|
851
851
|
const channel = this.channel;
|
|
852
852
|
this.channel = null;
|
|
853
853
|
this.handlers.onSuspend?.();
|
|
854
|
-
if (
|
|
855
|
-
globalThis.setTimeout
|
|
856
|
-
|
|
857
|
-
|
|
854
|
+
if (channel) {
|
|
855
|
+
if (typeof globalThis.setTimeout === "function") {
|
|
856
|
+
globalThis.setTimeout(() => channel.close(), 0);
|
|
857
|
+
} else {
|
|
858
|
+
channel.close();
|
|
859
|
+
}
|
|
858
860
|
}
|
|
859
861
|
}
|
|
860
862
|
/** Update the worker's connection status and persist the change. */
|
|
@@ -2338,7 +2340,7 @@ var DedupManager = class {
|
|
|
2338
2340
|
};
|
|
2339
2341
|
|
|
2340
2342
|
// src/core/version.ts
|
|
2341
|
-
var SDK_VERSION = true ? "0.20.
|
|
2343
|
+
var SDK_VERSION = true ? "0.20.91" : "";
|
|
2342
2344
|
|
|
2343
2345
|
// src/core/data-bus.ts
|
|
2344
2346
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
@@ -2520,6 +2522,7 @@ var CrossTabDataBus = class {
|
|
|
2520
2522
|
// own broadcastEvent call, which always posts a DataBusMessage.
|
|
2521
2523
|
onEvent: (eventType, payload, _sourceWorkerId, originTabId) => {
|
|
2522
2524
|
if (eventType !== PUBLICATION_EVENT) return;
|
|
2525
|
+
if (typeof payload !== "object" || payload === null || typeof payload.topic !== "string") return;
|
|
2523
2526
|
const incoming = payload;
|
|
2524
2527
|
const message = incoming.originTabId !== void 0 ? incoming : originTabId !== void 0 ? { ...incoming, originTabId } : incoming;
|
|
2525
2528
|
if (this.cluster.hasLocalSubscriber(message.topic)) this.dispatch(message);
|
|
@@ -3528,8 +3531,8 @@ var CentrifugeSession = class {
|
|
|
3528
3531
|
// Route credential fetches back to the main thread, where the
|
|
3529
3532
|
// application's credentialProvider lives (config must stay
|
|
3530
3533
|
// structured-cloneable, so functions cannot cross the boundary).
|
|
3531
|
-
getToken: () => this.requestToken("token"),
|
|
3532
|
-
getChannelToken: (channel) => this.requestToken("channelToken", channel)
|
|
3534
|
+
getToken: () => this.requestToken("token", lifecycle),
|
|
3535
|
+
getChannelToken: (channel) => this.requestToken("channelToken", lifecycle, channel)
|
|
3533
3536
|
} : config;
|
|
3534
3537
|
const client = new import_centrifuge.Centrifuge(url, clientOptions);
|
|
3535
3538
|
this.client = client;
|
|
@@ -3648,15 +3651,13 @@ var CentrifugeSession = class {
|
|
|
3648
3651
|
/** Issue a credential request to the main thread and await the response.
|
|
3649
3652
|
* Used as Centrifuge's `getToken` / `getChannelToken` when token bridging is
|
|
3650
3653
|
* enabled; resolved or rejected by a matching TOKEN_RESPONSE / TOKEN_ERROR. */
|
|
3651
|
-
requestToken(kind, channel) {
|
|
3652
|
-
|
|
3654
|
+
requestToken(kind, lifecycle, channel) {
|
|
3655
|
+
if (this.lifecycle !== lifecycle) {
|
|
3656
|
+
return Promise.reject(new Error("Centrifuge client lifecycle has ended before the credential was requested."));
|
|
3657
|
+
}
|
|
3653
3658
|
const requestId = this.nextRequestId;
|
|
3654
3659
|
this.nextRequestId += 1;
|
|
3655
3660
|
return new Promise((resolve, reject) => {
|
|
3656
|
-
if (this.lifecycle !== lifecycle) {
|
|
3657
|
-
reject(new Error("Centrifuge session stopped before the credential was requested."));
|
|
3658
|
-
return;
|
|
3659
|
-
}
|
|
3660
3661
|
this.pendingTokenRequests.set(requestId, { resolve, reject });
|
|
3661
3662
|
this.post({
|
|
3662
3663
|
type: CENTRIFUGE_OUTPUT_TYPE.TOKEN_REQUEST,
|