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
|
@@ -307,10 +307,51 @@ function publicationMetadata(messageId, timestamp) {
|
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
// src/utils/error-utils.ts
|
|
311
|
+
function serializeError(error) {
|
|
312
|
+
if (error instanceof Error) {
|
|
313
|
+
return {
|
|
314
|
+
name: error.name,
|
|
315
|
+
message: error.message,
|
|
316
|
+
...error.stack ? { stack: error.stack } : {}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
const context = error === void 0 ? void 0 : error;
|
|
320
|
+
return {
|
|
321
|
+
name: "CentrifugeError",
|
|
322
|
+
message: typeof error === "string" ? error : "Centrifuge worker operation failed.",
|
|
323
|
+
...context === void 0 || !isStructuredCloneable(context) ? {} : { context }
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function isStructuredCloneable(value) {
|
|
327
|
+
if (typeof structuredClone !== "function") return true;
|
|
328
|
+
try {
|
|
329
|
+
structuredClone(value);
|
|
330
|
+
return true;
|
|
331
|
+
} catch {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function deserializeWorkerError(error) {
|
|
336
|
+
const result = new Error(error.message);
|
|
337
|
+
result.name = error.name;
|
|
338
|
+
if (error.stack) result.stack = error.stack;
|
|
339
|
+
if (error.context !== void 0) Object.assign(result, { context: error.context });
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
function describeFailure(error) {
|
|
343
|
+
try {
|
|
344
|
+
if (error instanceof Error) return error.message;
|
|
345
|
+
return String(error);
|
|
346
|
+
} catch {
|
|
347
|
+
return `[unstringifiable ${typeof error}]`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
310
351
|
// src/utils/validation.ts
|
|
311
352
|
function assertPositiveSafeInteger(value, name) {
|
|
312
353
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
313
|
-
throw new TypeError(`${name} must be a positive safe integer, got ${
|
|
354
|
+
throw new TypeError(`${name} must be a positive safe integer, got ${describeFailure(value)}.`);
|
|
314
355
|
}
|
|
315
356
|
}
|
|
316
357
|
function assertPositiveFiniteNumber(value, name) {
|
|
@@ -325,7 +366,7 @@ function assertNonNegativeFiniteNumber(value, name) {
|
|
|
325
366
|
}
|
|
326
367
|
function assertPruneStrategy(value) {
|
|
327
368
|
const allowed = [PRUNE_STRATEGY.COUNT, PRUNE_STRATEGY.AGE, PRUNE_STRATEGY.BOTH];
|
|
328
|
-
if (!allowed.includes(
|
|
369
|
+
if (!allowed.includes(describeFailure(value))) {
|
|
329
370
|
throw new TypeError("pruneStrategy must be count, age, or both.");
|
|
330
371
|
}
|
|
331
372
|
}
|
|
@@ -400,7 +441,7 @@ function assertHeartbeatInterval(value) {
|
|
|
400
441
|
if (value === Infinity) return;
|
|
401
442
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) return;
|
|
402
443
|
throw new TypeError(
|
|
403
|
-
`Centrifuge heartbeatIntervalMs must be a positive number or Infinity, got ${
|
|
444
|
+
`Centrifuge heartbeatIntervalMs must be a positive number or Infinity, got ${describeFailure(value)}.`
|
|
404
445
|
);
|
|
405
446
|
}
|
|
406
447
|
function assertPublicTopic(operation, topic) {
|
|
@@ -1130,6 +1171,7 @@ var WorkerClusterRuntime = class {
|
|
|
1130
1171
|
/** Handle a point-to-point CONTROL message (SUBSCRIBE / UNSUBSCRIBE / PUBLISH). */
|
|
1131
1172
|
handleControlMessage(message) {
|
|
1132
1173
|
if (message.targetWorkerId !== this.workerId) return;
|
|
1174
|
+
if (message.topicKey !== void 0 && createOpaqueKey(message.topic) !== message.topicKey) return;
|
|
1133
1175
|
this.rememberTopic(message.topic);
|
|
1134
1176
|
switch (message.action) {
|
|
1135
1177
|
case CONTROL_ACTION.SUBSCRIBE: {
|
|
@@ -2346,7 +2388,7 @@ var DedupManager = class {
|
|
|
2346
2388
|
};
|
|
2347
2389
|
|
|
2348
2390
|
// src/core/version.ts
|
|
2349
|
-
var SDK_VERSION = true ? "0.21.
|
|
2391
|
+
var SDK_VERSION = true ? "0.21.5" : "";
|
|
2350
2392
|
|
|
2351
2393
|
// src/core/data-bus.ts
|
|
2352
2394
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
@@ -2964,7 +3006,7 @@ var CrossTabDataBus = class {
|
|
|
2964
3006
|
* the most recent successful open, or `null` until the transport reaches
|
|
2965
3007
|
* `ready`. */
|
|
2966
3008
|
getRecoveryStats() {
|
|
2967
|
-
const errorMessage = this.lastError
|
|
3009
|
+
const errorMessage = this.lastError === null ? null : describeFailure(this.lastError);
|
|
2968
3010
|
return {
|
|
2969
3011
|
attempt: this.recoveryAttempt,
|
|
2970
3012
|
exhausted: this.recoveryExhausted,
|
|
@@ -3235,7 +3277,7 @@ var CrossTabDataBus = class {
|
|
|
3235
3277
|
}
|
|
3236
3278
|
this.lastFailure = {
|
|
3237
3279
|
source,
|
|
3238
|
-
message:
|
|
3280
|
+
message: describeFailure(error),
|
|
3239
3281
|
at
|
|
3240
3282
|
};
|
|
3241
3283
|
if (source === FAILURE_SOURCE.PERSISTENCE) {
|
|
@@ -3406,7 +3448,6 @@ var CrossTabDataBus = class {
|
|
|
3406
3448
|
}
|
|
3407
3449
|
}
|
|
3408
3450
|
);
|
|
3409
|
-
void opening.catch(() => void 0);
|
|
3410
3451
|
return opening;
|
|
3411
3452
|
}
|
|
3412
3453
|
/**
|
|
@@ -3536,6 +3577,8 @@ export {
|
|
|
3536
3577
|
isWildcardTopic,
|
|
3537
3578
|
topicMatchesPattern,
|
|
3538
3579
|
publicationMetadata,
|
|
3580
|
+
serializeError,
|
|
3581
|
+
deserializeWorkerError,
|
|
3539
3582
|
assertPositiveSafeInteger,
|
|
3540
3583
|
assertPositiveFiniteNumber,
|
|
3541
3584
|
assertPruneStrategy,
|
|
@@ -3547,4 +3590,4 @@ export {
|
|
|
3547
3590
|
parseDataBusPublication,
|
|
3548
3591
|
selectWorkerBackend
|
|
3549
3592
|
};
|
|
3550
|
-
//# sourceMappingURL=chunk-
|
|
3593
|
+
//# sourceMappingURL=chunk-RWUDSL24.js.map
|