@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/node/pusher.js
CHANGED
|
@@ -3549,7 +3549,7 @@ class ChannelState {
|
|
|
3549
3549
|
constructor(channelName) {
|
|
3550
3550
|
this.channelName = channelName;
|
|
3551
3551
|
this.conflationKey = null;
|
|
3552
|
-
this.maxMessagesPerKey =
|
|
3552
|
+
this.maxMessagesPerKey = 30;
|
|
3553
3553
|
this.conflationCaches = /* @__PURE__ */ new Map();
|
|
3554
3554
|
this.baseMessage = null;
|
|
3555
3555
|
this.baseSequence = null;
|
|
@@ -3562,7 +3562,7 @@ class ChannelState {
|
|
|
3562
3562
|
*/
|
|
3563
3563
|
initializeFromCacheSync(data) {
|
|
3564
3564
|
this.conflationKey = data.conflation_key || null;
|
|
3565
|
-
this.maxMessagesPerKey = data.max_messages_per_key || 10;
|
|
3565
|
+
this.maxMessagesPerKey = Math.max(data.max_messages_per_key || 10, 30);
|
|
3566
3566
|
this.conflationCaches.clear();
|
|
3567
3567
|
if (data.states) {
|
|
3568
3568
|
for (const [key, messages] of Object.entries(data.states)) {
|
|
@@ -3759,6 +3759,7 @@ class Xdelta3Decoder {
|
|
|
3759
3759
|
}
|
|
3760
3760
|
class DeltaCompressionManager {
|
|
3761
3761
|
constructor(options = {}, sendEventCallback) {
|
|
3762
|
+
this.defaultAlgorithm = "fossil";
|
|
3762
3763
|
this.options = {
|
|
3763
3764
|
enabled: options.enabled !== false,
|
|
3764
3765
|
algorithms: options.algorithms || ["fossil", "xdelta3"],
|
|
@@ -3837,6 +3838,9 @@ class DeltaCompressionManager {
|
|
|
3837
3838
|
*/
|
|
3838
3839
|
handleEnabled(data) {
|
|
3839
3840
|
this.enabled = data.enabled || true;
|
|
3841
|
+
if (data.algorithm) {
|
|
3842
|
+
this.defaultAlgorithm = data.algorithm;
|
|
3843
|
+
}
|
|
3840
3844
|
this.log("Delta compression enabled", data);
|
|
3841
3845
|
}
|
|
3842
3846
|
/**
|
|
@@ -3865,7 +3869,7 @@ class DeltaCompressionManager {
|
|
|
3865
3869
|
const event = deltaData.event;
|
|
3866
3870
|
const delta = deltaData.delta;
|
|
3867
3871
|
const sequence = deltaData.seq;
|
|
3868
|
-
const algorithm = deltaData.algorithm || "fossil";
|
|
3872
|
+
const algorithm = deltaData.algorithm || this.defaultAlgorithm || "fossil";
|
|
3869
3873
|
const conflationKey = deltaData.conflation_key;
|
|
3870
3874
|
const baseIndex = deltaData.base_index;
|
|
3871
3875
|
this.log("Received delta message", {
|
|
@@ -3887,43 +3891,30 @@ class DeltaCompressionManager {
|
|
|
3887
3891
|
baseMessage = channelState.getBaseMessage(conflationKey, baseIndex);
|
|
3888
3892
|
if (!baseMessage) {
|
|
3889
3893
|
this.error(
|
|
3890
|
-
`No base message
|
|
3891
|
-
|
|
3892
|
-
|
|
3894
|
+
`No base message for channel ${channel}, key ${conflationKey}, index ${baseIndex}`
|
|
3895
|
+
);
|
|
3896
|
+
if (this.options.debug) {
|
|
3897
|
+
this.log("Current conflation cache snapshot", {
|
|
3893
3898
|
channel,
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
deltaSeq: sequence,
|
|
3897
|
-
channelStateConflationKey: channelState.conflationKey,
|
|
3898
|
-
channelStateBaseMessage: channelState.baseMessage ? "exists" : null,
|
|
3899
|
-
channelStateBaseSequence: channelState.baseSequence,
|
|
3900
|
-
channelStateLastSequence: channelState.lastSequence,
|
|
3901
|
-
conflationCacheKeys: Array.from(channelState.conflationCaches.keys()),
|
|
3902
|
-
conflationCacheSizes: Array.from(
|
|
3899
|
+
conflationKey: channelState.conflationKey,
|
|
3900
|
+
cacheSizes: Array.from(
|
|
3903
3901
|
channelState.conflationCaches.entries()
|
|
3904
3902
|
).map(([key, cache]) => ({ key, size: cache.length }))
|
|
3905
|
-
}
|
|
3906
|
-
|
|
3903
|
+
});
|
|
3904
|
+
}
|
|
3907
3905
|
this.requestResync(channel);
|
|
3908
3906
|
return null;
|
|
3909
3907
|
}
|
|
3910
3908
|
} else {
|
|
3911
3909
|
baseMessage = channelState.baseMessage;
|
|
3912
3910
|
if (!baseMessage) {
|
|
3913
|
-
this.error(
|
|
3914
|
-
|
|
3915
|
-
{
|
|
3916
|
-
path: "legacy",
|
|
3911
|
+
this.error(`No base message for channel ${channel}`);
|
|
3912
|
+
if (this.options.debug) {
|
|
3913
|
+
this.log("Channel state missing base", {
|
|
3917
3914
|
channel,
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
channelStateConflationKey: channelState.conflationKey,
|
|
3922
|
-
channelStateBaseMessage: null,
|
|
3923
|
-
channelStateBaseSequence: channelState.baseSequence,
|
|
3924
|
-
channelStateLastSequence: channelState.lastSequence
|
|
3925
|
-
}
|
|
3926
|
-
);
|
|
3915
|
+
lastSequence: channelState.lastSequence
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3927
3918
|
this.requestResync(channel);
|
|
3928
3919
|
return null;
|
|
3929
3920
|
}
|
|
@@ -3970,17 +3961,10 @@ class DeltaCompressionManager {
|
|
|
3970
3961
|
});
|
|
3971
3962
|
try {
|
|
3972
3963
|
const parsedMessage = JSON.parse(reconstructedMessage);
|
|
3973
|
-
let data = parsedMessage.data || parsedMessage;
|
|
3974
|
-
if (typeof data === "string") {
|
|
3975
|
-
try {
|
|
3976
|
-
data = JSON.parse(data);
|
|
3977
|
-
} catch (e) {
|
|
3978
|
-
}
|
|
3979
|
-
}
|
|
3980
3964
|
return {
|
|
3981
3965
|
event,
|
|
3982
3966
|
channel,
|
|
3983
|
-
data
|
|
3967
|
+
data: parsedMessage.data || parsedMessage
|
|
3984
3968
|
};
|
|
3985
3969
|
} catch (e) {
|
|
3986
3970
|
return {
|