@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.cjs
CHANGED
|
@@ -9624,44 +9624,45 @@ class IframeManager {
|
|
|
9624
9624
|
}
|
|
9625
9625
|
}
|
|
9626
9626
|
}
|
|
9627
|
-
function makeid$1(length = 8) {
|
|
9628
|
-
var result2 = "";
|
|
9629
|
-
var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
9630
|
-
var charactersLength = characters.length;
|
|
9631
|
-
for (var i2 = 0; i2 < length; i2++) {
|
|
9632
|
-
result2 += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
9633
|
-
}
|
|
9634
|
-
return result2;
|
|
9635
|
-
}
|
|
9636
9627
|
const _StormSnapshotManager = class _StormSnapshotManager2 {
|
|
9637
9628
|
constructor() {
|
|
9638
|
-
__publicField(this, "id", makeid$1());
|
|
9639
9629
|
__publicField(this, "lastFullSnapshot", -1);
|
|
9640
9630
|
__publicField(this, "intervalBetweenSnapshots", 150);
|
|
9631
|
+
__publicField(this, "debounceTimeout", null);
|
|
9632
|
+
__publicField(this, "debounceTime", 10);
|
|
9641
9633
|
if (_StormSnapshotManager2.instance) {
|
|
9642
9634
|
return _StormSnapshotManager2.instance;
|
|
9643
9635
|
}
|
|
9644
9636
|
_StormSnapshotManager2.instance = this;
|
|
9645
9637
|
}
|
|
9646
|
-
|
|
9647
|
-
|
|
9638
|
+
//we're debouncing here because of how mutation buffers work.
|
|
9639
|
+
//multiple observers create their own mutation buffer, and
|
|
9640
|
+
//each buffer will handle mutations storms, so multiple buffers
|
|
9641
|
+
//will probably request a full snapshot at (basically) the same time.
|
|
9642
|
+
//we want to ensure all buffers have requested a full snapshot
|
|
9643
|
+
//(so we can be sure that all mutations have been made)
|
|
9644
|
+
//before we actually take a full snapshot.
|
|
9645
|
+
//also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
|
|
9646
|
+
//in a somewhat quick succession, we want to record activity between them
|
|
9647
|
+
//not just one full snapshot after all the storms:
|
|
9648
|
+
//[mutation storm] [full snapshot] [mutation storm] [full snapshot]
|
|
9649
|
+
//NOT
|
|
9650
|
+
//[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
|
|
9651
|
+
requestFullSnapshot() {
|
|
9652
|
+
if (this.debounceTimeout) {
|
|
9653
|
+
clearTimeout(this.debounceTimeout);
|
|
9654
|
+
}
|
|
9655
|
+
this.debounceTimeout = setTimeout(() => {
|
|
9656
|
+
this.debounceTimeout = null;
|
|
9657
|
+
this.takeSnapshot();
|
|
9658
|
+
}, this.debounceTime);
|
|
9659
|
+
}
|
|
9660
|
+
takeSnapshot() {
|
|
9648
9661
|
if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
|
|
9649
|
-
console.log(
|
|
9650
|
-
"requestFullSnapshot: too soon",
|
|
9651
|
-
"storm snapshot mng id:",
|
|
9652
|
-
this.id,
|
|
9653
|
-
"bufferId:",
|
|
9654
|
-
bufferId
|
|
9655
|
-
);
|
|
9662
|
+
console.log("StormSnapshotManager, takeSnapshot: too soon");
|
|
9656
9663
|
return;
|
|
9657
9664
|
}
|
|
9658
|
-
console.log(
|
|
9659
|
-
"taking full snapshot",
|
|
9660
|
-
"storm snapshot mng id:",
|
|
9661
|
-
this.id,
|
|
9662
|
-
"bufferId:",
|
|
9663
|
-
bufferId
|
|
9664
|
-
);
|
|
9665
|
+
console.log("StormSnapshotManager, takeSnapshot: taking full snapshot");
|
|
9665
9666
|
takeFullSnapshot();
|
|
9666
9667
|
this.lastFullSnapshot = Date.now();
|
|
9667
9668
|
}
|
|
@@ -9797,11 +9798,14 @@ class MutationBuffer {
|
|
|
9797
9798
|
__publicField(this, "unattachedDoc");
|
|
9798
9799
|
__publicField(this, "bufId", makeid());
|
|
9799
9800
|
__publicField(this, "stormBatches", []);
|
|
9800
|
-
__publicField(this, "stormInfo");
|
|
9801
|
+
__publicField(this, "stormInfo", null);
|
|
9801
9802
|
__publicField(this, "stormSettings", {
|
|
9802
|
-
batchSize:
|
|
9803
|
-
|
|
9804
|
-
|
|
9803
|
+
batchSize: 150,
|
|
9804
|
+
//was 300
|
|
9805
|
+
timeout: 30,
|
|
9806
|
+
//was 50
|
|
9807
|
+
mutationLimit: 800
|
|
9808
|
+
//was 1500
|
|
9805
9809
|
});
|
|
9806
9810
|
__publicField(this, "handleStormMutations", (muts) => {
|
|
9807
9811
|
const time = Date.now();
|
|
@@ -9819,12 +9823,6 @@ class MutationBuffer {
|
|
|
9819
9823
|
};
|
|
9820
9824
|
}
|
|
9821
9825
|
this.stormInfo.totalMutations += muts.length;
|
|
9822
|
-
console.log(
|
|
9823
|
-
"current storm mutations",
|
|
9824
|
-
this.stormInfo.totalMutations,
|
|
9825
|
-
"buffer id:",
|
|
9826
|
-
this.bufId
|
|
9827
|
-
);
|
|
9828
9826
|
if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
|
|
9829
9827
|
this.stormInfo.stormExceededLimit = true;
|
|
9830
9828
|
this.stormBatches = [];
|
|
@@ -9834,9 +9832,14 @@ class MutationBuffer {
|
|
|
9834
9832
|
mutations: muts
|
|
9835
9833
|
});
|
|
9836
9834
|
}
|
|
9835
|
+
clearTimeout(this.stormInfo.timeout);
|
|
9837
9836
|
if (muts.length < this.stormSettings.batchSize) {
|
|
9838
|
-
clearTimeout(this.stormInfo.timeout);
|
|
9839
9837
|
this.handleStormFinish();
|
|
9838
|
+
} else {
|
|
9839
|
+
this.stormInfo.timeout = setTimeout(
|
|
9840
|
+
this.handleStormFinish,
|
|
9841
|
+
this.stormSettings.timeout
|
|
9842
|
+
);
|
|
9840
9843
|
}
|
|
9841
9844
|
});
|
|
9842
9845
|
__publicField(this, "handleStormFinish", () => {
|
|
@@ -9865,7 +9868,7 @@ class MutationBuffer {
|
|
|
9865
9868
|
this.processInternalMutations(muts, true);
|
|
9866
9869
|
} else {
|
|
9867
9870
|
this.stormBatches = [];
|
|
9868
|
-
stormSnapshotManager.requestFullSnapshot(
|
|
9871
|
+
stormSnapshotManager.requestFullSnapshot();
|
|
9869
9872
|
}
|
|
9870
9873
|
});
|
|
9871
9874
|
__publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
|
|
@@ -9873,20 +9876,9 @@ class MutationBuffer {
|
|
|
9873
9876
|
this.handleStormMutations(muts);
|
|
9874
9877
|
return;
|
|
9875
9878
|
}
|
|
9876
|
-
const start = performance.now();
|
|
9877
9879
|
for (const mut of muts) {
|
|
9878
9880
|
this.processMutation(mut);
|
|
9879
9881
|
}
|
|
9880
|
-
console.log(
|
|
9881
|
-
muts.length,
|
|
9882
|
-
"mutations processed in",
|
|
9883
|
-
performance.now() - start,
|
|
9884
|
-
"ms",
|
|
9885
|
-
"overrideStorm",
|
|
9886
|
-
overrideStorm,
|
|
9887
|
-
"buffer id:",
|
|
9888
|
-
this.bufId
|
|
9889
|
-
);
|
|
9890
9882
|
this.emit();
|
|
9891
9883
|
});
|
|
9892
9884
|
__publicField(this, "processMutations", (mutations) => {
|