@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.
@@ -9348,6 +9348,40 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
9348
9348
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
9349
9349
  return NodeType2;
9350
9350
  })(NodeType || {});
9351
+ const _StormSnapshotManager = class _StormSnapshotManager2 {
9352
+ constructor() {
9353
+ __publicField(this, "fullSnapshotTaker", null);
9354
+ __publicField(this, "lastFullSnapshot", -1);
9355
+ __publicField(this, "intervalBetweenSnapshots", 150);
9356
+ if (_StormSnapshotManager2.instance) {
9357
+ return _StormSnapshotManager2.instance;
9358
+ }
9359
+ _StormSnapshotManager2.instance = this;
9360
+ }
9361
+ bindFullSnapshotTaker(takeFullSnapshot2) {
9362
+ this.fullSnapshotTaker = takeFullSnapshot2;
9363
+ }
9364
+ requestFullSnapshot(bufferId) {
9365
+ if (!this.fullSnapshotTaker) {
9366
+ console.log(
9367
+ "requestFullSnapshot: no full snapshot taker",
9368
+ "bufferId:",
9369
+ bufferId
9370
+ );
9371
+ return;
9372
+ }
9373
+ if (Date.now() - this.lastFullSnapshot < this.intervalBetweenSnapshots) {
9374
+ console.log("requestFullSnapshot: too soon", "bufferId:", bufferId);
9375
+ return;
9376
+ }
9377
+ console.log("taking full snapshot", "bufferId:", bufferId);
9378
+ this.fullSnapshotTaker();
9379
+ this.lastFullSnapshot = Date.now();
9380
+ }
9381
+ };
9382
+ __publicField(_StormSnapshotManager, "instance");
9383
+ let StormSnapshotManager = _StormSnapshotManager;
9384
+ const stormSnapshotManager = new StormSnapshotManager();
9351
9385
  function isNodeInLinkedList(n2) {
9352
9386
  return "__ln" in n2;
9353
9387
  }
@@ -9474,7 +9508,7 @@ class MutationBuffer {
9474
9508
  __publicField(this, "canvasManager");
9475
9509
  __publicField(this, "processedNodeManager");
9476
9510
  __publicField(this, "unattachedDoc");
9477
- __publicField(this, "myId", makeid());
9511
+ __publicField(this, "bufId", makeid());
9478
9512
  __publicField(this, "stormBatches", []);
9479
9513
  __publicField(this, "stormInfo");
9480
9514
  __publicField(this, "stormSettings", {
@@ -9488,7 +9522,7 @@ class MutationBuffer {
9488
9522
  console.log(
9489
9523
  "detected probable mutation storm start",
9490
9524
  "buffer id:",
9491
- this.myId
9525
+ this.bufId
9492
9526
  );
9493
9527
  this.stormInfo = {
9494
9528
  startedAt: time,
@@ -9502,7 +9536,7 @@ class MutationBuffer {
9502
9536
  "current storm mutations",
9503
9537
  this.stormInfo.totalMutations,
9504
9538
  "buffer id:",
9505
- this.myId
9539
+ this.bufId
9506
9540
  );
9507
9541
  if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
9508
9542
  this.stormInfo.stormExceededLimit = true;
@@ -9531,7 +9565,7 @@ class MutationBuffer {
9531
9565
  Date.now() - this.stormInfo.startedAt,
9532
9566
  "ms",
9533
9567
  "buffer id:",
9534
- this.myId
9568
+ this.bufId
9535
9569
  );
9536
9570
  clearTimeout(this.stormInfo.timeout);
9537
9571
  this.stormInfo = null;
@@ -9544,7 +9578,7 @@ class MutationBuffer {
9544
9578
  this.processInternalMutations(muts, true);
9545
9579
  } else {
9546
9580
  this.stormBatches = [];
9547
- takeFullSnapshot();
9581
+ stormSnapshotManager.requestFullSnapshot(this.bufId);
9548
9582
  }
9549
9583
  });
9550
9584
  __publicField(this, "processInternalMutations", (muts, overrideStorm = false) => {
@@ -9564,7 +9598,7 @@ class MutationBuffer {
9564
9598
  "overrideStorm",
9565
9599
  overrideStorm,
9566
9600
  "buffer id:",
9567
- this.myId
9601
+ this.bufId
9568
9602
  );
9569
9603
  this.emit();
9570
9604
  });
@@ -12672,6 +12706,7 @@ record.takeFullSnapshot = (isCheckout) => {
12672
12706
  }
12673
12707
  takeFullSnapshot$1(isCheckout);
12674
12708
  };
12709
+ stormSnapshotManager.bindFullSnapshotTaker(takeFullSnapshot$1);
12675
12710
  record.mirror = mirror;
12676
12711
  var n;
12677
12712
  !function(t2) {