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