cross-tab-worker-databus 0.4.0 → 0.5.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 +13 -0
- package/dist/centrifuge.js +1 -1
- package/dist/{chunk-ZGQRELIV.js → chunk-W7DAXK4D.js} +33 -2
- package/dist/{chunk-ZGQRELIV.js.map → chunk-W7DAXK4D.js.map} +2 -2
- package/dist/cjs/centrifuge.cjs +32 -1
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +81 -1
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/core/data-bus.d.ts +12 -5
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/core/replay-persistence.d.ts +13 -0
- package/dist/core/replay-persistence.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -1
- package/dist/index.js.map +3 -3
- package/docs/README.md +2 -1
- package/docs/api.md +1 -1
- package/docs/roadmap.md +18 -0
- package/docs/zh/README.md +2 -1
- package/docs/zh/api.md +1 -1
- package/docs/zh/roadmap.md +18 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,19 @@
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.5.0] - 2026-08-31
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- 真实浏览器发布基准入口:`pnpm bench:browser`,在本地 Centrifuge 演示服务上用两个真实标签页分别测 dedicated/shared Worker 的跨 Tab 发布耗时。
|
|
27
|
+
- 可选 replay 持久化契约与 IndexedDB 实现:`createIndexedDbReplayPersistence({ maxPerTopic })`;默认仍为纯内存,持久化失败通过错误处理器报告。
|
|
28
|
+
- E2E:新增真实 Chrome reload 场景,验证 IndexedDB replay 历史在页面重建后恢复(总计 8 项 E2E)。
|
|
29
|
+
|
|
30
|
+
### Notes
|
|
31
|
+
|
|
32
|
+
- 当前基准包含页面点击、JSON 序列化、Worker/Storage/BroadcastChannel、服务端回显和接收端渲染,结果用于端到端回归趋势,不等同于核心 `publish()` 微基准。
|
|
33
|
+
- 2026-08-31 本机 Chrome 100 条消息采样:dedicated 约 34.03 ms/条,shared 约 33.89 ms/条;两者接近,暂不据此改动 publish 路径,避免在缺少核心 profile 时引入陈旧路由缓存。
|
|
34
|
+
|
|
22
35
|
## [0.3.0] - 2026-08-29
|
|
23
36
|
|
|
24
37
|
### Added
|
package/dist/centrifuge.js
CHANGED
|
@@ -1185,6 +1185,8 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1185
1185
|
// replay is enabled — buffering is opt-in and must cost nothing otherwise.
|
|
1186
1186
|
replayBuffers;
|
|
1187
1187
|
replayMaxPerTopic;
|
|
1188
|
+
replayPersistence;
|
|
1189
|
+
replayHydration;
|
|
1188
1190
|
initialConfig;
|
|
1189
1191
|
hasInitialConfig;
|
|
1190
1192
|
trace;
|
|
@@ -1224,6 +1226,8 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1224
1226
|
}
|
|
1225
1227
|
this.replayMaxPerTopic = replay?.maxPerTopic ?? DEFAULT_REPLAY_MAX_PER_TOPIC;
|
|
1226
1228
|
this.replayBuffers = replay ? /* @__PURE__ */ new Map() : null;
|
|
1229
|
+
this.replayPersistence = replay?.persistence ?? null;
|
|
1230
|
+
this.replayHydration = this.hydrateReplay();
|
|
1227
1231
|
const { autoStart, initialConfig, trace, transport, ...clusterOptions } = options;
|
|
1228
1232
|
this.transport = transport;
|
|
1229
1233
|
this.initialConfig = initialConfig;
|
|
@@ -1392,7 +1396,13 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1392
1396
|
typeof options.replay === "number" ? Math.floor(options.replay) : this.replayMaxPerTopic,
|
|
1393
1397
|
this.replayMaxPerTopic
|
|
1394
1398
|
);
|
|
1395
|
-
this.
|
|
1399
|
+
if (this.replayPersistence) {
|
|
1400
|
+
void this.replayHydration.then(() => {
|
|
1401
|
+
if (this.topicHandlers.get(topic)?.has(handler)) this.deliverReplay(topic, limit, handler);
|
|
1402
|
+
});
|
|
1403
|
+
} else {
|
|
1404
|
+
this.deliverReplay(topic, limit, handler);
|
|
1405
|
+
}
|
|
1396
1406
|
}
|
|
1397
1407
|
return () => this.unsubscribe(topic, handler);
|
|
1398
1408
|
}
|
|
@@ -1516,6 +1526,27 @@ var CrossTabDataBus = class _CrossTabDataBus {
|
|
|
1516
1526
|
}
|
|
1517
1527
|
buffer.push(message);
|
|
1518
1528
|
if (buffer.length > this.replayMaxPerTopic) buffer.shift();
|
|
1529
|
+
if (this.replayPersistence) {
|
|
1530
|
+
void this.replayPersistence.append(message).catch((error) => this.reportError(error));
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
async hydrateReplay() {
|
|
1534
|
+
if (!this.replayBuffers || !this.replayPersistence) {
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
try {
|
|
1538
|
+
for (const message of await this.replayPersistence.load()) {
|
|
1539
|
+
let buffer = this.replayBuffers.get(message.topic);
|
|
1540
|
+
if (!buffer) {
|
|
1541
|
+
buffer = [];
|
|
1542
|
+
this.replayBuffers.set(message.topic, buffer);
|
|
1543
|
+
}
|
|
1544
|
+
buffer.push(message);
|
|
1545
|
+
if (buffer.length > this.replayMaxPerTopic) buffer.shift();
|
|
1546
|
+
}
|
|
1547
|
+
} catch (error) {
|
|
1548
|
+
this.reportError(error);
|
|
1549
|
+
}
|
|
1519
1550
|
}
|
|
1520
1551
|
/** Deliver buffered history to a newly-registered handler. For an exact
|
|
1521
1552
|
* topic this is that topic's ring; for a wildcard subscription every
|
|
@@ -1735,4 +1766,4 @@ export {
|
|
|
1735
1766
|
CrossTabDataBus,
|
|
1736
1767
|
selectWorkerBackend
|
|
1737
1768
|
};
|
|
1738
|
-
//# sourceMappingURL=chunk-
|
|
1769
|
+
//# sourceMappingURL=chunk-W7DAXK4D.js.map
|