cross-tab-worker-databus 0.20.67 → 0.20.70
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 +18 -0
- package/dist/centrifuge.d.ts +2 -0
- package/dist/centrifuge.d.ts.map +1 -1
- package/dist/centrifuge.js +5 -1
- package/dist/centrifuge.js.map +2 -2
- package/dist/{chunk-RJS3M3EE.js → chunk-IKBJIREH.js} +16 -5
- package/dist/chunk-IKBJIREH.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +19 -4
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +17 -4
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts +3 -0
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts +7 -0
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/core/types.d.ts +14 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +2 -2
- package/dist/websocket.d.ts +2 -0
- package/dist/websocket.d.ts.map +1 -1
- package/docs/roadmap.md +20 -1
- package/docs/zh/roadmap.md +20 -1
- package/package.json +1 -1
- package/dist/chunk-RJS3M3EE.js.map +0 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -321,6 +321,7 @@ var BatchingStorageWriter = class {
|
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
// src/core/cluster.ts
|
|
324
|
+
var CLUSTER_PROTOCOL_VERSION = 1;
|
|
324
325
|
var DEFAULT_HEARTBEAT_INTERVAL_MS = 3e3;
|
|
325
326
|
var DEFAULT_WORKER_TTL_MS = 1e4;
|
|
326
327
|
var DEFAULT_STORAGE_PREFIX = "cross-tab-worker-databus";
|
|
@@ -424,6 +425,7 @@ var WorkerClusterRuntime = class {
|
|
|
424
425
|
this.workerId = options.workerId ?? `worker-${this.tabId}-${this.environment.randomId()}`;
|
|
425
426
|
const now = this.environment.now();
|
|
426
427
|
this.currentRecord = {
|
|
428
|
+
protocolVersion: CLUSTER_PROTOCOL_VERSION,
|
|
427
429
|
workerId: this.workerId,
|
|
428
430
|
tabId: this.tabId,
|
|
429
431
|
load: 0,
|
|
@@ -745,15 +747,18 @@ var WorkerClusterRuntime = class {
|
|
|
745
747
|
}
|
|
746
748
|
/** Read-only snapshot of the cluster state (workers, routes, assignments). */
|
|
747
749
|
getSnapshot() {
|
|
750
|
+
const workers = this.storage ? this.readWorkers() : [{ ...this.currentRecord }];
|
|
748
751
|
const routes = this.storage ? readAllByPrefix(this.storage, this.routePrefix).map(({ value }) => ({
|
|
749
752
|
...value,
|
|
750
753
|
topic: this.knownTopics.get(value.topicKey) ?? null
|
|
751
754
|
})) : [];
|
|
752
755
|
return {
|
|
756
|
+
protocolVersion: CLUSTER_PROTOCOL_VERSION,
|
|
757
|
+
peerProtocolVersions: Object.fromEntries(workers.map((worker) => [worker.workerId, worker.protocolVersion ?? null])),
|
|
753
758
|
coordinated: Boolean(this.storage && this.channel),
|
|
754
759
|
suspended: this.suspended,
|
|
755
760
|
currentWorker: { ...this.currentRecord },
|
|
756
|
-
workers:
|
|
761
|
+
workers: workers.map((worker) => ({ ...worker })),
|
|
757
762
|
routes,
|
|
758
763
|
subscribedTopics: Array.from(this.subscribedTopics),
|
|
759
764
|
assignedTopics: Array.from(this.assignedTopics.values()),
|
|
@@ -1006,7 +1011,7 @@ var WorkerClusterRuntime = class {
|
|
|
1006
1011
|
send(message) {
|
|
1007
1012
|
if (!this.channel) return false;
|
|
1008
1013
|
try {
|
|
1009
|
-
this.channel.postMessage(message);
|
|
1014
|
+
this.channel.postMessage({ ...message, protocolVersion: CLUSTER_PROTOCOL_VERSION });
|
|
1010
1015
|
return true;
|
|
1011
1016
|
} catch {
|
|
1012
1017
|
return false;
|
|
@@ -1408,6 +1413,7 @@ function roundMs(value) {
|
|
|
1408
1413
|
|
|
1409
1414
|
// src/core/data-bus.ts
|
|
1410
1415
|
var PUBLICATION_EVENT = "DATABUS_PUBLICATION";
|
|
1416
|
+
var SDK_VERSION = "0.20.69";
|
|
1411
1417
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
1412
1418
|
var PersistenceRetryCancelledError = class extends Error {
|
|
1413
1419
|
constructor() {
|
|
@@ -1911,15 +1917,20 @@ var CrossTabDataBus = class {
|
|
|
1911
1917
|
getDiagnostics() {
|
|
1912
1918
|
let messages = 0;
|
|
1913
1919
|
if (this.replayBuffers) for (const buffer of this.replayBuffers.values()) messages += buffer.length;
|
|
1920
|
+
const cluster = this.cluster.getSnapshot();
|
|
1921
|
+
const unknownMessages = this.cluster.getUnknownMessageStats();
|
|
1922
|
+
const transport = this.transport;
|
|
1914
1923
|
return {
|
|
1915
1924
|
status: this.status,
|
|
1925
|
+
sdkVersion: SDK_VERSION,
|
|
1916
1926
|
started: this.started,
|
|
1917
1927
|
transportReady: this.transportReady,
|
|
1918
1928
|
recovery: this.getRecoveryStats(),
|
|
1919
1929
|
dedup: this.getDedupStats(),
|
|
1920
1930
|
replay: { enabled: Boolean(this.replayBuffers), topics: this.replayBuffers?.size ?? 0, messages },
|
|
1921
|
-
protocol: {
|
|
1922
|
-
|
|
1931
|
+
protocol: { version: cluster.protocolVersion, unknownMessages: unknownMessages.count, lastUnknownMessageType: unknownMessages.lastType, peers: cluster.peerProtocolVersions },
|
|
1932
|
+
transport: { name: transport.diagnosticsName ?? transport.constructor.name, backend: transport.diagnosticsBackend ?? null },
|
|
1933
|
+
cluster
|
|
1923
1934
|
};
|
|
1924
1935
|
}
|
|
1925
1936
|
/**
|
|
@@ -2580,6 +2591,8 @@ var WebSocketTransport = class {
|
|
|
2580
2591
|
constructor(connection) {
|
|
2581
2592
|
this.connection = connection;
|
|
2582
2593
|
}
|
|
2594
|
+
diagnosticsName = "websocket";
|
|
2595
|
+
diagnosticsBackend = "native-websocket";
|
|
2583
2596
|
socket = null;
|
|
2584
2597
|
handlers = null;
|
|
2585
2598
|
subscribedTopics = /* @__PURE__ */ new Set();
|