cross-tab-worker-databus 0.21.3 → 0.21.5
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 +53 -0
- package/dist/centrifuge.js +4 -37
- package/dist/centrifuge.js.map +3 -3
- package/dist/centrifuge.shared.worker.js.map +1 -1
- package/dist/centrifuge.worker.js.map +1 -1
- package/dist/{chunk-CFFSSIUO.js → chunk-RWUDSL24.js} +51 -8
- package/dist/chunk-RWUDSL24.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +48 -40
- package/dist/cjs/centrifuge.cjs.map +3 -3
- package/dist/cjs/index.cjs +16 -6
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/error-utils.d.ts +13 -0
- package/dist/utils/error-utils.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +4 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/docs/roadmap.md +18 -1
- package/docs/zh/roadmap.md +18 -1
- package/package.json +1 -1
- package/dist/chunk-CFFSSIUO.js.map +0 -7
package/dist/cjs/centrifuge.cjs
CHANGED
|
@@ -598,10 +598,51 @@ function readAllByPrefix(storage, prefix) {
|
|
|
598
598
|
return listKeys(storage, prefix).map((key) => ({ key, value: readJson(storage, key) })).filter((entry) => entry.value !== null);
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
+
// src/utils/error-utils.ts
|
|
602
|
+
function serializeError(error) {
|
|
603
|
+
if (error instanceof Error) {
|
|
604
|
+
return {
|
|
605
|
+
name: error.name,
|
|
606
|
+
message: error.message,
|
|
607
|
+
...error.stack ? { stack: error.stack } : {}
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
const context = error === void 0 ? void 0 : error;
|
|
611
|
+
return {
|
|
612
|
+
name: "CentrifugeError",
|
|
613
|
+
message: typeof error === "string" ? error : "Centrifuge worker operation failed.",
|
|
614
|
+
...context === void 0 || !isStructuredCloneable(context) ? {} : { context }
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function isStructuredCloneable(value) {
|
|
618
|
+
if (typeof structuredClone !== "function") return true;
|
|
619
|
+
try {
|
|
620
|
+
structuredClone(value);
|
|
621
|
+
return true;
|
|
622
|
+
} catch {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function deserializeWorkerError(error) {
|
|
627
|
+
const result = new Error(error.message);
|
|
628
|
+
result.name = error.name;
|
|
629
|
+
if (error.stack) result.stack = error.stack;
|
|
630
|
+
if (error.context !== void 0) Object.assign(result, { context: error.context });
|
|
631
|
+
return result;
|
|
632
|
+
}
|
|
633
|
+
function describeFailure(error) {
|
|
634
|
+
try {
|
|
635
|
+
if (error instanceof Error) return error.message;
|
|
636
|
+
return String(error);
|
|
637
|
+
} catch {
|
|
638
|
+
return `[unstringifiable ${typeof error}]`;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
601
642
|
// src/utils/validation.ts
|
|
602
643
|
function assertPositiveSafeInteger(value, name) {
|
|
603
644
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
604
|
-
throw new TypeError(`${name} must be a positive safe integer, got ${
|
|
645
|
+
throw new TypeError(`${name} must be a positive safe integer, got ${describeFailure(value)}.`);
|
|
605
646
|
}
|
|
606
647
|
}
|
|
607
648
|
function assertPositiveFiniteNumber(value, name) {
|
|
@@ -616,7 +657,7 @@ function assertNonNegativeFiniteNumber(value, name) {
|
|
|
616
657
|
}
|
|
617
658
|
function assertPruneStrategy(value) {
|
|
618
659
|
const allowed = [PRUNE_STRATEGY.COUNT, PRUNE_STRATEGY.AGE, PRUNE_STRATEGY.BOTH];
|
|
619
|
-
if (!allowed.includes(
|
|
660
|
+
if (!allowed.includes(describeFailure(value))) {
|
|
620
661
|
throw new TypeError("pruneStrategy must be count, age, or both.");
|
|
621
662
|
}
|
|
622
663
|
}
|
|
@@ -691,7 +732,7 @@ function assertHeartbeatInterval(value) {
|
|
|
691
732
|
if (value === Infinity) return;
|
|
692
733
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return;
|
|
693
734
|
throw new TypeError(
|
|
694
|
-
`Centrifuge heartbeatIntervalMs must be a positive number or Infinity, got ${
|
|
735
|
+
`Centrifuge heartbeatIntervalMs must be a positive number or Infinity, got ${describeFailure(value)}.`
|
|
695
736
|
);
|
|
696
737
|
}
|
|
697
738
|
function assertPublicTopic(operation, topic) {
|
|
@@ -1258,6 +1299,7 @@ var WorkerClusterRuntime = class {
|
|
|
1258
1299
|
/** Handle a point-to-point CONTROL message (SUBSCRIBE / UNSUBSCRIBE / PUBLISH). */
|
|
1259
1300
|
handleControlMessage(message) {
|
|
1260
1301
|
if (message.targetWorkerId !== this.workerId) return;
|
|
1302
|
+
if (message.topicKey !== void 0 && createOpaqueKey(message.topic) !== message.topicKey) return;
|
|
1261
1303
|
this.rememberTopic(message.topic);
|
|
1262
1304
|
switch (message.action) {
|
|
1263
1305
|
case CONTROL_ACTION.SUBSCRIBE: {
|
|
@@ -2474,7 +2516,7 @@ var DedupManager = class {
|
|
|
2474
2516
|
};
|
|
2475
2517
|
|
|
2476
2518
|
// src/core/version.ts
|
|
2477
|
-
var SDK_VERSION = true ? "0.21.
|
|
2519
|
+
var SDK_VERSION = true ? "0.21.5" : "";
|
|
2478
2520
|
|
|
2479
2521
|
// src/core/data-bus.ts
|
|
2480
2522
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
@@ -3092,7 +3134,7 @@ var CrossTabDataBus = class {
|
|
|
3092
3134
|
* the most recent successful open, or `null` until the transport reaches
|
|
3093
3135
|
* `ready`. */
|
|
3094
3136
|
getRecoveryStats() {
|
|
3095
|
-
const errorMessage = this.lastError
|
|
3137
|
+
const errorMessage = this.lastError === null ? null : describeFailure(this.lastError);
|
|
3096
3138
|
return {
|
|
3097
3139
|
attempt: this.recoveryAttempt,
|
|
3098
3140
|
exhausted: this.recoveryExhausted,
|
|
@@ -3363,7 +3405,7 @@ var CrossTabDataBus = class {
|
|
|
3363
3405
|
}
|
|
3364
3406
|
this.lastFailure = {
|
|
3365
3407
|
source,
|
|
3366
|
-
message:
|
|
3408
|
+
message: describeFailure(error),
|
|
3367
3409
|
at
|
|
3368
3410
|
};
|
|
3369
3411
|
if (source === FAILURE_SOURCE.PERSISTENCE) {
|
|
@@ -3534,7 +3576,6 @@ var CrossTabDataBus = class {
|
|
|
3534
3576
|
}
|
|
3535
3577
|
}
|
|
3536
3578
|
);
|
|
3537
|
-
void opening.catch(() => void 0);
|
|
3538
3579
|
return opening;
|
|
3539
3580
|
}
|
|
3540
3581
|
/**
|
|
@@ -3642,39 +3683,6 @@ function parseDataBusPublication(value, fallbackTopic) {
|
|
|
3642
3683
|
};
|
|
3643
3684
|
}
|
|
3644
3685
|
|
|
3645
|
-
// src/utils/error-utils.ts
|
|
3646
|
-
function serializeError(error) {
|
|
3647
|
-
if (error instanceof Error) {
|
|
3648
|
-
return {
|
|
3649
|
-
name: error.name,
|
|
3650
|
-
message: error.message,
|
|
3651
|
-
...error.stack ? { stack: error.stack } : {}
|
|
3652
|
-
};
|
|
3653
|
-
}
|
|
3654
|
-
const context = error === void 0 ? void 0 : error;
|
|
3655
|
-
return {
|
|
3656
|
-
name: "CentrifugeError",
|
|
3657
|
-
message: typeof error === "string" ? error : "Centrifuge worker operation failed.",
|
|
3658
|
-
...context === void 0 || !isStructuredCloneable(context) ? {} : { context }
|
|
3659
|
-
};
|
|
3660
|
-
}
|
|
3661
|
-
function isStructuredCloneable(value) {
|
|
3662
|
-
if (typeof structuredClone !== "function") return true;
|
|
3663
|
-
try {
|
|
3664
|
-
structuredClone(value);
|
|
3665
|
-
return true;
|
|
3666
|
-
} catch {
|
|
3667
|
-
return false;
|
|
3668
|
-
}
|
|
3669
|
-
}
|
|
3670
|
-
function deserializeWorkerError(error) {
|
|
3671
|
-
const result = new Error(error.message);
|
|
3672
|
-
result.name = error.name;
|
|
3673
|
-
if (error.stack) result.stack = error.stack;
|
|
3674
|
-
if (error.context !== void 0) Object.assign(result, { context: error.context });
|
|
3675
|
-
return result;
|
|
3676
|
-
}
|
|
3677
|
-
|
|
3678
3686
|
// src/centrifuge-session.ts
|
|
3679
3687
|
var CentrifugeSession = class {
|
|
3680
3688
|
constructor(sink) {
|