@glimt/record 0.0.30 → 0.0.32

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.js CHANGED
@@ -9304,6 +9304,40 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
9304
9304
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
9305
9305
  return NodeType2;
9306
9306
  })(NodeType || {});
9307
+ const _StormSnapshotManager = class _StormSnapshotManager2 {
9308
+ constructor() {
9309
+ __publicField(this, "fullSnapshotTaker", null);
9310
+ __publicField(this, "lastFullSnapshot", -1);
9311
+ __publicField(this, "intervalBetweenSnapshots", 150);
9312
+ if (_StormSnapshotManager2.instance) {
9313
+ return _StormSnapshotManager2.instance;
9314
+ }
9315
+ _StormSnapshotManager2.instance = this;
9316
+ }
9317
+ bindFullSnapshotTaker(takeFullSnapshot2) {
9318
+ this.fullSnapshotTaker = takeFullSnapshot2;
9319
+ }
9320
+ requestFullSnapshot(bufferId) {
9321
+ if (!this.fullSnapshotTaker) {
9322
+ console.log(
9323
+ "requestFullSnapshot: no full snapshot taker",
9324
+ "bufferId:",
9325
+ bufferId
9326
+ );
9327
+ return;
9328
+ }
9329
+ if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
9330
+ console.log("requestFullSnapshot: too soon", "bufferId:", bufferId);
9331
+ return;
9332
+ }
9333
+ console.log("taking full snapshot", "bufferId:", bufferId);
9334
+ this.fullSnapshotTaker();
9335
+ this.lastFullSnapshot = Date.now();
9336
+ }
9337
+ };
9338
+ __publicField(_StormSnapshotManager, "instance");
9339
+ let StormSnapshotManager = _StormSnapshotManager;
9340
+ const stormSnapshotManager = new StormSnapshotManager();
9307
9341
  function isNodeInLinkedList(n2) {
9308
9342
  return "__ln" in n2;
9309
9343
  }
@@ -9430,7 +9464,7 @@ class MutationBuffer {
9430
9464
  __publicField(this, "canvasManager");
9431
9465
  __publicField(this, "processedNodeManager");
9432
9466
  __publicField(this, "unattachedDoc");
9433
- __publicField(this, "myId", makeid());
9467
+ __publicField(this, "bufId", makeid());
9434
9468
  __publicField(this, "stormBatches", []);
9435
9469
  __publicField(this, "stormInfo");
9436
9470
  __publicField(this, "stormSettings", {
@@ -9444,7 +9478,7 @@ class MutationBuffer {
9444
9478
  console.log(
9445
9479
  "detected probable mutation storm start",
9446
9480
  "buffer id:",
9447
- this.myId
9481
+ this.bufId
9448
9482
  );
9449
9483
  this.stormInfo = {
9450
9484
  startedAt: time,
@@ -9458,7 +9492,7 @@ class MutationBuffer {
9458
9492
  "current storm mutations",
9459
9493
  this.stormInfo.totalMutations,
9460
9494
  "buffer id:",
9461
- this.myId
9495
+ this.bufId
9462
9496
  );
9463
9497
  if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
9464
9498
  this.stormInfo.stormExceededLimit = true;
@@ -9487,7 +9521,7 @@ class MutationBuffer {
9487
9521
  Date.now() - this.stormInfo.startedAt,
9488
9522
  "ms",
9489
9523
  "buffer id:",
9490
- this.myId
9524
+ this.bufId
9491
9525
  );
9492
9526
  clearTimeout(this.stormInfo.timeout);
9493
9527
  this.stormInfo = null;
@@ -9500,7 +9534,7 @@ class MutationBuffer {
9500
9534
  this.processInternalMutations(muts, true);
9501
9535
  } else {
9502
9536
  this.stormBatches = [];
9503
- takeFullSnapshot();
9537
+ stormSnapshotManager.requestFullSnapshot(this.bufId);
9504
9538
  }
9505
9539
  });
9506
9540
  __publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
@@ -9520,7 +9554,7 @@ class MutationBuffer {
9520
9554
  "overrideStorm",
9521
9555
  overrideStorm,
9522
9556
  "buffer id:",
9523
- this.myId
9557
+ this.bufId
9524
9558
  );
9525
9559
  this.emit();
9526
9560
  });
@@ -12645,6 +12679,7 @@ record.takeFullSnapshot = (isCheckout) => {
12645
12679
  }
12646
12680
  takeFullSnapshot$1(isCheckout);
12647
12681
  };
12682
+ stormSnapshotManager.bindFullSnapshotTaker(takeFullSnapshot$1);
12648
12683
  record.mirror = mirror;
12649
12684
  var n;
12650
12685
  !function(t2) {