@cendarsoss/pusher-js 8.4.13 → 8.4.15
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 +928 -928
- package/DELTA_USAGE.md +0 -0
- package/IMPORT_GUIDE.md +0 -0
- package/bun.lock +1819 -171
- package/dist/node/pusher.js +22 -38
- package/dist/node/pusher.js.map +1 -1
- package/dist/web/pusher.mjs +22 -38
- package/dist/web/pusher.mjs.map +1 -1
- package/examples/delta-seamless-example.html +0 -0
- package/interactive/public/delta-compression.js +43 -29
- package/package.json +1 -1
- package/src/core/delta/channel_state.ts +3 -2
- package/src/core/delta/manager.ts +21 -40
- package/src/filter.ts +0 -0
- package/src/index.ts +0 -0
- package/vite.config.js +0 -0
- package/vite.config.node.js +0 -0
package/dist/web/pusher.mjs
CHANGED
|
@@ -4280,7 +4280,7 @@ class ChannelState {
|
|
|
4280
4280
|
constructor(channelName) {
|
|
4281
4281
|
this.channelName = channelName;
|
|
4282
4282
|
this.conflationKey = null;
|
|
4283
|
-
this.maxMessagesPerKey =
|
|
4283
|
+
this.maxMessagesPerKey = 30;
|
|
4284
4284
|
this.conflationCaches = /* @__PURE__ */ new Map();
|
|
4285
4285
|
this.baseMessage = null;
|
|
4286
4286
|
this.baseSequence = null;
|
|
@@ -4293,7 +4293,7 @@ class ChannelState {
|
|
|
4293
4293
|
*/
|
|
4294
4294
|
initializeFromCacheSync(data) {
|
|
4295
4295
|
this.conflationKey = data.conflation_key || null;
|
|
4296
|
-
this.maxMessagesPerKey = data.max_messages_per_key || 10;
|
|
4296
|
+
this.maxMessagesPerKey = Math.max(data.max_messages_per_key || 10, 30);
|
|
4297
4297
|
this.conflationCaches.clear();
|
|
4298
4298
|
if (data.states) {
|
|
4299
4299
|
for (const [key, messages] of Object.entries(data.states)) {
|
|
@@ -5225,6 +5225,7 @@ class Xdelta3Decoder {
|
|
|
5225
5225
|
}
|
|
5226
5226
|
class DeltaCompressionManager {
|
|
5227
5227
|
constructor(options = {}, sendEventCallback) {
|
|
5228
|
+
this.defaultAlgorithm = "fossil";
|
|
5228
5229
|
this.options = {
|
|
5229
5230
|
enabled: options.enabled !== false,
|
|
5230
5231
|
algorithms: options.algorithms || ["fossil", "xdelta3"],
|
|
@@ -5303,6 +5304,9 @@ class DeltaCompressionManager {
|
|
|
5303
5304
|
*/
|
|
5304
5305
|
handleEnabled(data) {
|
|
5305
5306
|
this.enabled = data.enabled || true;
|
|
5307
|
+
if (data.algorithm) {
|
|
5308
|
+
this.defaultAlgorithm = data.algorithm;
|
|
5309
|
+
}
|
|
5306
5310
|
this.log("Delta compression enabled", data);
|
|
5307
5311
|
}
|
|
5308
5312
|
/**
|
|
@@ -5331,7 +5335,7 @@ class DeltaCompressionManager {
|
|
|
5331
5335
|
const event = deltaData.event;
|
|
5332
5336
|
const delta2 = deltaData.delta;
|
|
5333
5337
|
const sequence = deltaData.seq;
|
|
5334
|
-
const algorithm = deltaData.algorithm || "fossil";
|
|
5338
|
+
const algorithm = deltaData.algorithm || this.defaultAlgorithm || "fossil";
|
|
5335
5339
|
const conflationKey = deltaData.conflation_key;
|
|
5336
5340
|
const baseIndex = deltaData.base_index;
|
|
5337
5341
|
this.log("Received delta message", {
|
|
@@ -5353,43 +5357,30 @@ class DeltaCompressionManager {
|
|
|
5353
5357
|
baseMessage = channelState.getBaseMessage(conflationKey, baseIndex);
|
|
5354
5358
|
if (!baseMessage) {
|
|
5355
5359
|
this.error(
|
|
5356
|
-
`No base message
|
|
5357
|
-
|
|
5358
|
-
|
|
5360
|
+
`No base message for channel ${channel}, key ${conflationKey}, index ${baseIndex}`
|
|
5361
|
+
);
|
|
5362
|
+
if (this.options.debug) {
|
|
5363
|
+
this.log("Current conflation cache snapshot", {
|
|
5359
5364
|
channel,
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
deltaSeq: sequence,
|
|
5363
|
-
channelStateConflationKey: channelState.conflationKey,
|
|
5364
|
-
channelStateBaseMessage: channelState.baseMessage ? "exists" : null,
|
|
5365
|
-
channelStateBaseSequence: channelState.baseSequence,
|
|
5366
|
-
channelStateLastSequence: channelState.lastSequence,
|
|
5367
|
-
conflationCacheKeys: Array.from(channelState.conflationCaches.keys()),
|
|
5368
|
-
conflationCacheSizes: Array.from(
|
|
5365
|
+
conflationKey: channelState.conflationKey,
|
|
5366
|
+
cacheSizes: Array.from(
|
|
5369
5367
|
channelState.conflationCaches.entries()
|
|
5370
5368
|
).map(([key, cache]) => ({ key, size: cache.length }))
|
|
5371
|
-
}
|
|
5372
|
-
|
|
5369
|
+
});
|
|
5370
|
+
}
|
|
5373
5371
|
this.requestResync(channel);
|
|
5374
5372
|
return null;
|
|
5375
5373
|
}
|
|
5376
5374
|
} else {
|
|
5377
5375
|
baseMessage = channelState.baseMessage;
|
|
5378
5376
|
if (!baseMessage) {
|
|
5379
|
-
this.error(
|
|
5380
|
-
|
|
5381
|
-
{
|
|
5382
|
-
path: "legacy",
|
|
5377
|
+
this.error(`No base message for channel ${channel}`);
|
|
5378
|
+
if (this.options.debug) {
|
|
5379
|
+
this.log("Channel state missing base", {
|
|
5383
5380
|
channel,
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
channelStateConflationKey: channelState.conflationKey,
|
|
5388
|
-
channelStateBaseMessage: null,
|
|
5389
|
-
channelStateBaseSequence: channelState.baseSequence,
|
|
5390
|
-
channelStateLastSequence: channelState.lastSequence
|
|
5391
|
-
}
|
|
5392
|
-
);
|
|
5381
|
+
lastSequence: channelState.lastSequence
|
|
5382
|
+
});
|
|
5383
|
+
}
|
|
5393
5384
|
this.requestResync(channel);
|
|
5394
5385
|
return null;
|
|
5395
5386
|
}
|
|
@@ -5436,17 +5427,10 @@ class DeltaCompressionManager {
|
|
|
5436
5427
|
});
|
|
5437
5428
|
try {
|
|
5438
5429
|
const parsedMessage = JSON.parse(reconstructedMessage);
|
|
5439
|
-
let data = parsedMessage.data || parsedMessage;
|
|
5440
|
-
if (typeof data === "string") {
|
|
5441
|
-
try {
|
|
5442
|
-
data = JSON.parse(data);
|
|
5443
|
-
} catch (e) {
|
|
5444
|
-
}
|
|
5445
|
-
}
|
|
5446
5430
|
return {
|
|
5447
5431
|
event,
|
|
5448
5432
|
channel,
|
|
5449
|
-
data
|
|
5433
|
+
data: parsedMessage.data || parsedMessage
|
|
5450
5434
|
};
|
|
5451
5435
|
} catch (e) {
|
|
5452
5436
|
return {
|