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