cross-tab-worker-databus 0.21.3 → 0.21.4
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 +16 -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-WFVM7HPE.js} +50 -7
- package/dist/chunk-WFVM7HPE.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +47 -39
- package/dist/cjs/centrifuge.cjs.map +3 -3
- package/dist/cjs/index.cjs +15 -5
- package/dist/cjs/index.cjs.map +3 -3
- 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 +9 -1
- package/docs/zh/roadmap.md +9 -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) {
|
|
@@ -2474,7 +2515,7 @@ var DedupManager = class {
|
|
|
2474
2515
|
};
|
|
2475
2516
|
|
|
2476
2517
|
// src/core/version.ts
|
|
2477
|
-
var SDK_VERSION = true ? "0.21.
|
|
2518
|
+
var SDK_VERSION = true ? "0.21.4" : "";
|
|
2478
2519
|
|
|
2479
2520
|
// src/core/data-bus.ts
|
|
2480
2521
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
@@ -3092,7 +3133,7 @@ var CrossTabDataBus = class {
|
|
|
3092
3133
|
* the most recent successful open, or `null` until the transport reaches
|
|
3093
3134
|
* `ready`. */
|
|
3094
3135
|
getRecoveryStats() {
|
|
3095
|
-
const errorMessage = this.lastError
|
|
3136
|
+
const errorMessage = this.lastError === null ? null : describeFailure(this.lastError);
|
|
3096
3137
|
return {
|
|
3097
3138
|
attempt: this.recoveryAttempt,
|
|
3098
3139
|
exhausted: this.recoveryExhausted,
|
|
@@ -3363,7 +3404,7 @@ var CrossTabDataBus = class {
|
|
|
3363
3404
|
}
|
|
3364
3405
|
this.lastFailure = {
|
|
3365
3406
|
source,
|
|
3366
|
-
message:
|
|
3407
|
+
message: describeFailure(error),
|
|
3367
3408
|
at
|
|
3368
3409
|
};
|
|
3369
3410
|
if (source === FAILURE_SOURCE.PERSISTENCE) {
|
|
@@ -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) {
|