@glimt/record 0.0.71 → 0.0.72
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 +83 -63
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +83 -63
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +83 -63
- package/dist/record.umd.cjs.map +3 -3
- package/dist/record.umd.min.cjs +10 -10
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.js
CHANGED
|
@@ -10279,52 +10279,6 @@ const debugLog = (...args) => {
|
|
|
10279
10279
|
if (!isDebug()) return;
|
|
10280
10280
|
console.log("[recapt:rrweb]", ...args);
|
|
10281
10281
|
};
|
|
10282
|
-
const _StormSnapshotManager = class _StormSnapshotManager2 {
|
|
10283
|
-
constructor() {
|
|
10284
|
-
__publicField(this, "lastFullSnapshot", -1);
|
|
10285
|
-
__publicField(this, "intervalBetweenSnapshots", 150);
|
|
10286
|
-
__publicField(this, "debounceTimeout", null);
|
|
10287
|
-
__publicField(this, "debounceTime", 10);
|
|
10288
|
-
if (_StormSnapshotManager2.instance) {
|
|
10289
|
-
return _StormSnapshotManager2.instance;
|
|
10290
|
-
}
|
|
10291
|
-
_StormSnapshotManager2.instance = this;
|
|
10292
|
-
}
|
|
10293
|
-
//we're debouncing here because of how mutation buffers work.
|
|
10294
|
-
//multiple observers create their own mutation buffer, and
|
|
10295
|
-
//each buffer will handle mutations storms, so multiple buffers
|
|
10296
|
-
//will probably request a full snapshot at (basically) the same time.
|
|
10297
|
-
//we want to ensure all buffers have requested a full snapshot
|
|
10298
|
-
//(so we can be sure that all mutations have been made)
|
|
10299
|
-
//before we actually take a full snapshot.
|
|
10300
|
-
//also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
|
|
10301
|
-
//in a somewhat quick succession, we want to record activity between them
|
|
10302
|
-
//not just one full snapshot after all the storms:
|
|
10303
|
-
//[mutation storm] [full snapshot] [mutation storm] [full snapshot]
|
|
10304
|
-
//NOT
|
|
10305
|
-
//[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
|
|
10306
|
-
requestFullSnapshot() {
|
|
10307
|
-
if (this.debounceTimeout) {
|
|
10308
|
-
clearTimeout(this.debounceTimeout);
|
|
10309
|
-
}
|
|
10310
|
-
this.debounceTimeout = setTimeout(() => {
|
|
10311
|
-
this.debounceTimeout = null;
|
|
10312
|
-
this.takeSnapshot();
|
|
10313
|
-
}, this.debounceTime);
|
|
10314
|
-
}
|
|
10315
|
-
takeSnapshot() {
|
|
10316
|
-
if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
|
|
10317
|
-
debugLog("StormSnapshotManager, takeSnapshot: too soon");
|
|
10318
|
-
return;
|
|
10319
|
-
}
|
|
10320
|
-
debugLog("StormSnapshotManager, takeSnapshot: taking full snapshot");
|
|
10321
|
-
takeFullSnapshot();
|
|
10322
|
-
this.lastFullSnapshot = Date.now();
|
|
10323
|
-
}
|
|
10324
|
-
};
|
|
10325
|
-
__publicField(_StormSnapshotManager, "instance");
|
|
10326
|
-
let StormSnapshotManager = _StormSnapshotManager;
|
|
10327
|
-
const stormSnapshotManager = new StormSnapshotManager();
|
|
10328
10282
|
const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
10329
10283
|
constructor() {
|
|
10330
10284
|
__publicField(this, "mutTracker");
|
|
@@ -10335,6 +10289,9 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10335
10289
|
__publicField(this, "inGlobalStorm", false);
|
|
10336
10290
|
__publicField(this, "currentStormStartedAt", -1);
|
|
10337
10291
|
__publicField(this, "stormTimeLimit", 5e3);
|
|
10292
|
+
__publicField(this, "debounceTimeout", null);
|
|
10293
|
+
__publicField(this, "debounceTimeoutMs", 250);
|
|
10294
|
+
__publicField(this, "handleStormFinishMethods", {});
|
|
10338
10295
|
if (_MutationRateLimiter2.instance) {
|
|
10339
10296
|
return _MutationRateLimiter2.instance;
|
|
10340
10297
|
}
|
|
@@ -10359,11 +10316,19 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10359
10316
|
this.resetExitTracker();
|
|
10360
10317
|
this.currentStormStartedAt = -1;
|
|
10361
10318
|
}
|
|
10362
|
-
stormStopped() {
|
|
10319
|
+
stormStopped(stoppedByBuffer) {
|
|
10320
|
+
if (this.debounceTimeout) clearTimeout(this.debounceTimeout);
|
|
10363
10321
|
this.inGlobalStorm = false;
|
|
10364
10322
|
this.reset();
|
|
10323
|
+
for (const [bufId, method] of Object.entries(
|
|
10324
|
+
this.handleStormFinishMethods
|
|
10325
|
+
)) {
|
|
10326
|
+
if (bufId === stoppedByBuffer) continue;
|
|
10327
|
+
method();
|
|
10328
|
+
}
|
|
10329
|
+
this.handleStormFinishMethods = {};
|
|
10365
10330
|
}
|
|
10366
|
-
handleStormExit(muts) {
|
|
10331
|
+
handleStormExit(muts, bufId) {
|
|
10367
10332
|
const now = Date.now();
|
|
10368
10333
|
if (this.exitMutTracker.requested === -1) {
|
|
10369
10334
|
this.exitMutTracker = {
|
|
@@ -10390,29 +10355,40 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10390
10355
|
mutTracker: this.mutTracker,
|
|
10391
10356
|
exitMutTracker: this.exitMutTracker
|
|
10392
10357
|
});
|
|
10393
|
-
this.stormStopped();
|
|
10358
|
+
this.stormStopped(bufId);
|
|
10394
10359
|
return false;
|
|
10395
10360
|
}
|
|
10396
10361
|
}
|
|
10397
10362
|
}
|
|
10398
10363
|
return true;
|
|
10399
10364
|
}
|
|
10400
|
-
|
|
10401
|
-
return
|
|
10365
|
+
isInGlobalStorm() {
|
|
10366
|
+
return this.inGlobalStorm;
|
|
10367
|
+
}
|
|
10368
|
+
doDebounce() {
|
|
10369
|
+
if (this.debounceTimeout) clearTimeout(this.debounceTimeout);
|
|
10370
|
+
if (!this.inGlobalStorm) return;
|
|
10371
|
+
this.debounceTimeout = setTimeout(() => {
|
|
10372
|
+
this.debounceTimeout = null;
|
|
10373
|
+
this.stormStopped();
|
|
10374
|
+
}, this.debounceTimeoutMs);
|
|
10402
10375
|
}
|
|
10403
|
-
isStorming(muts) {
|
|
10376
|
+
isStorming(muts, buffer) {
|
|
10377
|
+
if (!(buffer.bufId in this.handleStormFinishMethods)) {
|
|
10378
|
+
this.handleStormFinishMethods[buffer.bufId] = buffer.handleStormFinish.bind(buffer);
|
|
10379
|
+
}
|
|
10404
10380
|
const now = Date.now();
|
|
10405
10381
|
if (this.inGlobalStorm) {
|
|
10382
|
+
this.doDebounce();
|
|
10406
10383
|
if (now - this.currentStormStartedAt > this.stormTimeLimit) {
|
|
10407
10384
|
debugLog(
|
|
10408
10385
|
`MutationRateLimiter, storm time limit reached, stopping storm`
|
|
10409
10386
|
);
|
|
10410
|
-
this.stormStopped();
|
|
10387
|
+
this.stormStopped(buffer.bufId);
|
|
10411
10388
|
return false;
|
|
10412
10389
|
}
|
|
10413
|
-
if (now - this.mutTracker.ts > this.interval)
|
|
10414
|
-
return this.handleStormExit(muts);
|
|
10415
|
-
}
|
|
10390
|
+
if (now - this.mutTracker.ts > this.interval)
|
|
10391
|
+
return this.handleStormExit(muts, buffer.bufId);
|
|
10416
10392
|
this.mutTracker.muts += muts;
|
|
10417
10393
|
this.mutTracker.ts = now;
|
|
10418
10394
|
return true;
|
|
@@ -10426,6 +10402,7 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10426
10402
|
this.inGlobalStorm = true;
|
|
10427
10403
|
debugLog(`MutationRateLimiter, detected global rolling storm`);
|
|
10428
10404
|
this.currentStormStartedAt = now;
|
|
10405
|
+
this.doDebounce();
|
|
10429
10406
|
return true;
|
|
10430
10407
|
}
|
|
10431
10408
|
}
|
|
@@ -10437,6 +10414,52 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10437
10414
|
__publicField(_MutationRateLimiter, "instance");
|
|
10438
10415
|
let MutationRateLimiter = _MutationRateLimiter;
|
|
10439
10416
|
const mutationRateLimiter = new MutationRateLimiter();
|
|
10417
|
+
const _StormSnapshotManager = class _StormSnapshotManager2 {
|
|
10418
|
+
constructor() {
|
|
10419
|
+
__publicField(this, "lastFullSnapshot", -1);
|
|
10420
|
+
__publicField(this, "intervalBetweenSnapshots", 150);
|
|
10421
|
+
__publicField(this, "debounceTimeout", null);
|
|
10422
|
+
__publicField(this, "debounceTime", 10);
|
|
10423
|
+
if (_StormSnapshotManager2.instance) {
|
|
10424
|
+
return _StormSnapshotManager2.instance;
|
|
10425
|
+
}
|
|
10426
|
+
_StormSnapshotManager2.instance = this;
|
|
10427
|
+
}
|
|
10428
|
+
//we're debouncing here because of how mutation buffers work.
|
|
10429
|
+
//multiple observers create their own mutation buffer, and
|
|
10430
|
+
//each buffer will handle mutations storms, so multiple buffers
|
|
10431
|
+
//will probably request a full snapshot at (basically) the same time.
|
|
10432
|
+
//we want to ensure all buffers have requested a full snapshot
|
|
10433
|
+
//(so we can be sure that all mutations have been made)
|
|
10434
|
+
//before we actually take a full snapshot.
|
|
10435
|
+
//also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
|
|
10436
|
+
//in a somewhat quick succession, we want to record activity between them
|
|
10437
|
+
//not just one full snapshot after all the storms:
|
|
10438
|
+
//[mutation storm] [full snapshot] [mutation storm] [full snapshot]
|
|
10439
|
+
//NOT
|
|
10440
|
+
//[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
|
|
10441
|
+
requestFullSnapshot() {
|
|
10442
|
+
if (this.debounceTimeout) {
|
|
10443
|
+
clearTimeout(this.debounceTimeout);
|
|
10444
|
+
}
|
|
10445
|
+
this.debounceTimeout = setTimeout(() => {
|
|
10446
|
+
this.debounceTimeout = null;
|
|
10447
|
+
this.takeSnapshot();
|
|
10448
|
+
}, this.debounceTime);
|
|
10449
|
+
}
|
|
10450
|
+
takeSnapshot() {
|
|
10451
|
+
if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
|
|
10452
|
+
debugLog("StormSnapshotManager, takeSnapshot: too soon");
|
|
10453
|
+
return;
|
|
10454
|
+
}
|
|
10455
|
+
debugLog("StormSnapshotManager, takeSnapshot: taking full snapshot");
|
|
10456
|
+
takeFullSnapshot();
|
|
10457
|
+
this.lastFullSnapshot = Date.now();
|
|
10458
|
+
}
|
|
10459
|
+
};
|
|
10460
|
+
__publicField(_StormSnapshotManager, "instance");
|
|
10461
|
+
let StormSnapshotManager = _StormSnapshotManager;
|
|
10462
|
+
const stormSnapshotManager = new StormSnapshotManager();
|
|
10440
10463
|
function isNodeInLinkedList(n2) {
|
|
10441
10464
|
return "__ln" in n2;
|
|
10442
10465
|
}
|
|
@@ -10562,7 +10585,7 @@ class MutationBuffer {
|
|
|
10562
10585
|
__publicField(this, "canvasManager");
|
|
10563
10586
|
__publicField(this, "processedNodeManager");
|
|
10564
10587
|
__publicField(this, "unattachedDoc");
|
|
10565
|
-
__publicField(this, "bufId",
|
|
10588
|
+
__publicField(this, "bufId", makeid());
|
|
10566
10589
|
__publicField(this, "stormBatches", []);
|
|
10567
10590
|
__publicField(this, "stormInfo", null);
|
|
10568
10591
|
__publicField(this, "stormSettings", {
|
|
@@ -10575,6 +10598,7 @@ class MutationBuffer {
|
|
|
10575
10598
|
});
|
|
10576
10599
|
__publicField(this, "debounceStormFinish", () => {
|
|
10577
10600
|
if (!this.stormInfo) return;
|
|
10601
|
+
if (mutationRateLimiter.isInGlobalStorm()) return;
|
|
10578
10602
|
this.stormInfo.timeout = setTimeout(
|
|
10579
10603
|
this.handleStormFinish,
|
|
10580
10604
|
this.stormSettings.timeout
|
|
@@ -10591,9 +10615,9 @@ class MutationBuffer {
|
|
|
10591
10615
|
this.stormInfo = {
|
|
10592
10616
|
startedAt: time,
|
|
10593
10617
|
totalMutations: 0,
|
|
10594
|
-
timeout: setTimeout(this.handleStormFinish, this.stormSettings.timeout),
|
|
10595
10618
|
stormExceededLimit: false
|
|
10596
10619
|
};
|
|
10620
|
+
if (canFinishStorm) this.debounceStormFinish();
|
|
10597
10621
|
}
|
|
10598
10622
|
this.stormInfo.totalMutations += muts.length;
|
|
10599
10623
|
if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
|
|
@@ -10614,10 +10638,6 @@ class MutationBuffer {
|
|
|
10614
10638
|
});
|
|
10615
10639
|
__publicField(this, "handleStormFinish", () => {
|
|
10616
10640
|
if (!this.stormInfo) return;
|
|
10617
|
-
if (!mutationRateLimiter.canMutationBufferExitMutationStorm()) {
|
|
10618
|
-
this.debounceStormFinish();
|
|
10619
|
-
return;
|
|
10620
|
-
}
|
|
10621
10641
|
const { stormExceededLimit } = this.stormInfo;
|
|
10622
10642
|
debugLog(
|
|
10623
10643
|
"mutation storm finished",
|
|
@@ -10647,7 +10667,7 @@ class MutationBuffer {
|
|
|
10647
10667
|
});
|
|
10648
10668
|
__publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
|
|
10649
10669
|
if (!overrideStorm) {
|
|
10650
|
-
const isStorming = mutationRateLimiter.isStorming(muts.length);
|
|
10670
|
+
const isStorming = mutationRateLimiter.isStorming(muts.length, this);
|
|
10651
10671
|
if (isStorming) {
|
|
10652
10672
|
this.handleStormMutations(muts, false);
|
|
10653
10673
|
return;
|