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