@glimt/record 0.0.33 → 0.0.35
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/dist/record.cjs +41 -49
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +41 -49
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +41 -49
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +23 -23
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.umd.cjs
CHANGED
|
@@ -9666,44 +9666,45 @@ class IframeManager {
|
|
|
9666
9666
|
}
|
|
9667
9667
|
}
|
|
9668
9668
|
}
|
|
9669
|
-
function makeid$1(length = 8) {
|
|
9670
|
-
var result2 = "";
|
|
9671
|
-
var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
9672
|
-
var charactersLength = characters.length;
|
|
9673
|
-
for (var i2 = 0; i2 < length; i2++) {
|
|
9674
|
-
result2 += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
9675
|
-
}
|
|
9676
|
-
return result2;
|
|
9677
|
-
}
|
|
9678
9669
|
const _StormSnapshotManager = class _StormSnapshotManager2 {
|
|
9679
9670
|
constructor() {
|
|
9680
|
-
__publicField(this, "id", makeid$1());
|
|
9681
9671
|
__publicField(this, "lastFullSnapshot", -1);
|
|
9682
9672
|
__publicField(this, "intervalBetweenSnapshots", 150);
|
|
9673
|
+
__publicField(this, "debounceTimeout", null);
|
|
9674
|
+
__publicField(this, "debounceTime", 10);
|
|
9683
9675
|
if (_StormSnapshotManager2.instance) {
|
|
9684
9676
|
return _StormSnapshotManager2.instance;
|
|
9685
9677
|
}
|
|
9686
9678
|
_StormSnapshotManager2.instance = this;
|
|
9687
9679
|
}
|
|
9688
|
-
|
|
9689
|
-
|
|
9680
|
+
//we're debouncing here because of how mutation buffers work.
|
|
9681
|
+
//multiple observers create their own mutation buffer, and
|
|
9682
|
+
//each buffer will handle mutations storms, so multiple buffers
|
|
9683
|
+
//will probably request a full snapshot at (basically) the same time.
|
|
9684
|
+
//we want to ensure all buffers have requested a full snapshot
|
|
9685
|
+
//(so we can be sure that all mutations have been made)
|
|
9686
|
+
//before we actually take a full snapshot.
|
|
9687
|
+
//also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
|
|
9688
|
+
//in a somewhat quick succession, we want to record activity between them
|
|
9689
|
+
//not just one full snapshot after all the storms:
|
|
9690
|
+
//[mutation storm] [full snapshot] [mutation storm] [full snapshot]
|
|
9691
|
+
//NOT
|
|
9692
|
+
//[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
|
|
9693
|
+
requestFullSnapshot() {
|
|
9694
|
+
if (this.debounceTimeout) {
|
|
9695
|
+
clearTimeout(this.debounceTimeout);
|
|
9696
|
+
}
|
|
9697
|
+
this.debounceTimeout = setTimeout(() => {
|
|
9698
|
+
this.debounceTimeout = null;
|
|
9699
|
+
this.takeSnapshot();
|
|
9700
|
+
}, this.debounceTime);
|
|
9701
|
+
}
|
|
9702
|
+
takeSnapshot() {
|
|
9690
9703
|
if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
|
|
9691
|
-
console.log(
|
|
9692
|
-
"requestFullSnapshot: too soon",
|
|
9693
|
-
"storm snapshot mng id:",
|
|
9694
|
-
this.id,
|
|
9695
|
-
"bufferId:",
|
|
9696
|
-
bufferId
|
|
9697
|
-
);
|
|
9704
|
+
console.log("StormSnapshotManager, takeSnapshot: too soon");
|
|
9698
9705
|
return;
|
|
9699
9706
|
}
|
|
9700
|
-
console.log(
|
|
9701
|
-
"taking full snapshot",
|
|
9702
|
-
"storm snapshot mng id:",
|
|
9703
|
-
this.id,
|
|
9704
|
-
"bufferId:",
|
|
9705
|
-
bufferId
|
|
9706
|
-
);
|
|
9707
|
+
console.log("StormSnapshotManager, takeSnapshot: taking full snapshot");
|
|
9707
9708
|
takeFullSnapshot();
|
|
9708
9709
|
this.lastFullSnapshot = Date.now();
|
|
9709
9710
|
}
|
|
@@ -9839,11 +9840,14 @@ class MutationBuffer {
|
|
|
9839
9840
|
__publicField(this, "unattachedDoc");
|
|
9840
9841
|
__publicField(this, "bufId", makeid());
|
|
9841
9842
|
__publicField(this, "stormBatches", []);
|
|
9842
|
-
__publicField(this, "stormInfo");
|
|
9843
|
+
__publicField(this, "stormInfo", null);
|
|
9843
9844
|
__publicField(this, "stormSettings", {
|
|
9844
|
-
batchSize:
|
|
9845
|
-
|
|
9846
|
-
|
|
9845
|
+
batchSize: 150,
|
|
9846
|
+
//was 300
|
|
9847
|
+
timeout: 30,
|
|
9848
|
+
//was 50
|
|
9849
|
+
mutationLimit: 800
|
|
9850
|
+
//was 1500
|
|
9847
9851
|
});
|
|
9848
9852
|
__publicField(this, "handleStormMutations", (muts) => {
|
|
9849
9853
|
const time = Date.now();
|
|
@@ -9861,12 +9865,6 @@ class MutationBuffer {
|
|
|
9861
9865
|
};
|
|
9862
9866
|
}
|
|
9863
9867
|
this.stormInfo.totalMutations += muts.length;
|
|
9864
|
-
console.log(
|
|
9865
|
-
"current storm mutations",
|
|
9866
|
-
this.stormInfo.totalMutations,
|
|
9867
|
-
"buffer id:",
|
|
9868
|
-
this.bufId
|
|
9869
|
-
);
|
|
9870
9868
|
if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
|
|
9871
9869
|
this.stormInfo.stormExceededLimit = true;
|
|
9872
9870
|
this.stormBatches = [];
|
|
@@ -9876,9 +9874,14 @@ class MutationBuffer {
|
|
|
9876
9874
|
mutations: muts
|
|
9877
9875
|
});
|
|
9878
9876
|
}
|
|
9877
|
+
clearTimeout(this.stormInfo.timeout);
|
|
9879
9878
|
if (muts.length < this.stormSettings.batchSize) {
|
|
9880
|
-
clearTimeout(this.stormInfo.timeout);
|
|
9881
9879
|
this.handleStormFinish();
|
|
9880
|
+
} else {
|
|
9881
|
+
this.stormInfo.timeout = setTimeout(
|
|
9882
|
+
this.handleStormFinish,
|
|
9883
|
+
this.stormSettings.timeout
|
|
9884
|
+
);
|
|
9882
9885
|
}
|
|
9883
9886
|
});
|
|
9884
9887
|
__publicField(this, "handleStormFinish", () => {
|
|
@@ -9907,7 +9910,7 @@ class MutationBuffer {
|
|
|
9907
9910
|
this.processInternalMutations(muts, true);
|
|
9908
9911
|
} else {
|
|
9909
9912
|
this.stormBatches = [];
|
|
9910
|
-
stormSnapshotManager.requestFullSnapshot(
|
|
9913
|
+
stormSnapshotManager.requestFullSnapshot();
|
|
9911
9914
|
}
|
|
9912
9915
|
});
|
|
9913
9916
|
__publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
|
|
@@ -9915,20 +9918,9 @@ class MutationBuffer {
|
|
|
9915
9918
|
this.handleStormMutations(muts);
|
|
9916
9919
|
return;
|
|
9917
9920
|
}
|
|
9918
|
-
const start = performance.now();
|
|
9919
9921
|
for (const mut of muts) {
|
|
9920
9922
|
this.processMutation(mut);
|
|
9921
9923
|
}
|
|
9922
|
-
console.log(
|
|
9923
|
-
muts.length,
|
|
9924
|
-
"mutations processed in",
|
|
9925
|
-
performance.now() - start,
|
|
9926
|
-
"ms",
|
|
9927
|
-
"overrideStorm",
|
|
9928
|
-
overrideStorm,
|
|
9929
|
-
"buffer id:",
|
|
9930
|
-
this.bufId
|
|
9931
|
-
);
|
|
9932
9924
|
this.emit();
|
|
9933
9925
|
});
|
|
9934
9926
|
__publicField(this, "processMutations", (mutations) => {
|