@glimt/record 0.0.34 → 0.0.36

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
@@ -1170,7 +1170,6 @@ function serializeTextNode(n2, options) {
1170
1170
  };
1171
1171
  }
1172
1172
  function serializeElementNode(n2, options) {
1173
- const start = performance.now();
1174
1173
  const {
1175
1174
  doc,
1176
1175
  blockClass,
@@ -1369,19 +1368,6 @@ function serializeElementNode(n2, options) {
1369
1368
  if (customElements.get(tagName)) isCustomElement = true;
1370
1369
  } catch (e2) {
1371
1370
  }
1372
- const took = performance.now() - start;
1373
- if (!window.serialization_perf_map) window.serialization_perf_map = {};
1374
- if (!(tagName in window.serialization_perf_map)) {
1375
- window.serialization_perf_map[tagName] = {
1376
- avg: 0,
1377
- times: []
1378
- };
1379
- }
1380
- window.serialization_perf_map[tagName].times.push(took);
1381
- if (window.serialization_perf_map[tagName].times.length > 1e3) {
1382
- window.serialization_perf_map[tagName].times.shift();
1383
- }
1384
- window.serialization_perf_map[tagName].avg = window.serialization_perf_map[tagName].times.reduce((a2, b) => a2 + b, 0) / window.serialization_perf_map[tagName].times.length;
1385
1371
  return {
1386
1372
  type: NodeType$2.Element,
1387
1373
  tagName,
@@ -9642,7 +9628,10 @@ const _StormSnapshotManager = class _StormSnapshotManager2 {
9642
9628
  //before we actually take a full snapshot.
9643
9629
  //also, we want a low debounceTime, bc if theres multiple, distinctive mutation storms,
9644
9630
  //in a somewhat quick succession, we want to record activity between them
9645
- //not just one full snapshot after all the storms
9631
+ //not just one full snapshot after all the storms:
9632
+ //[mutation storm] [full snapshot] [mutation storm] [full snapshot]
9633
+ //NOT
9634
+ //[mutation storm] [timeout] [mutation storm] [full snapshot] (in this case, we probably miss all events which fired during the timeout)
9646
9635
  requestFullSnapshot() {
9647
9636
  if (this.debounceTimeout) {
9648
9637
  clearTimeout(this.debounceTimeout);
@@ -9746,15 +9735,6 @@ class DoubleLinkedList {
9746
9735
  }
9747
9736
  }
9748
9737
  const moveKey = (id, parentId) => `${id}@${parentId}`;
9749
- function makeid(length = 8) {
9750
- var result2 = "";
9751
- var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
9752
- var charactersLength = characters.length;
9753
- for (var i2 = 0; i2 < length; i2++) {
9754
- result2 += characters.charAt(Math.floor(Math.random() * charactersLength));
9755
- }
9756
- return result2;
9757
- }
9758
9738
  class MutationBuffer {
9759
9739
  constructor() {
9760
9740
  __publicField(this, "frozen", false);
@@ -9791,22 +9771,19 @@ class MutationBuffer {
9791
9771
  __publicField(this, "canvasManager");
9792
9772
  __publicField(this, "processedNodeManager");
9793
9773
  __publicField(this, "unattachedDoc");
9794
- __publicField(this, "bufId", makeid());
9795
9774
  __publicField(this, "stormBatches", []);
9796
- __publicField(this, "stormInfo");
9775
+ __publicField(this, "stormInfo", null);
9797
9776
  __publicField(this, "stormSettings", {
9798
- batchSize: 300,
9799
- timeout: 50,
9800
- mutationLimit: 1500
9777
+ batchSize: 150,
9778
+ //was 300
9779
+ timeout: 30,
9780
+ //was 50
9781
+ mutationLimit: 800
9782
+ //was 1500
9801
9783
  });
9802
9784
  __publicField(this, "handleStormMutations", (muts) => {
9803
9785
  const time = Date.now();
9804
9786
  if (this.stormInfo == null) {
9805
- console.log(
9806
- "detected probable mutation storm start",
9807
- "buffer id:",
9808
- this.bufId
9809
- );
9810
9787
  this.stormInfo = {
9811
9788
  startedAt: time,
9812
9789
  totalMutations: 0,
@@ -9815,12 +9792,6 @@ class MutationBuffer {
9815
9792
  };
9816
9793
  }
9817
9794
  this.stormInfo.totalMutations += muts.length;
9818
- console.log(
9819
- "current storm mutations",
9820
- this.stormInfo.totalMutations,
9821
- "buffer id:",
9822
- this.bufId
9823
- );
9824
9795
  if (this.stormInfo.totalMutations >= this.stormSettings.mutationLimit) {
9825
9796
  this.stormInfo.stormExceededLimit = true;
9826
9797
  this.stormBatches = [];
@@ -9830,26 +9801,19 @@ class MutationBuffer {
9830
9801
  mutations: muts
9831
9802
  });
9832
9803
  }
9804
+ clearTimeout(this.stormInfo.timeout);
9833
9805
  if (muts.length < this.stormSettings.batchSize) {
9834
- clearTimeout(this.stormInfo.timeout);
9835
9806
  this.handleStormFinish();
9807
+ } else {
9808
+ this.stormInfo.timeout = setTimeout(
9809
+ this.handleStormFinish,
9810
+ this.stormSettings.timeout
9811
+ );
9836
9812
  }
9837
9813
  });
9838
9814
  __publicField(this, "handleStormFinish", () => {
9839
9815
  if (!this.stormInfo) return;
9840
9816
  const { stormExceededLimit } = this.stormInfo;
9841
- console.log(
9842
- "mutation storm finished",
9843
- "totalMutations:",
9844
- this.stormInfo.totalMutations,
9845
- "stormExceededLimit:",
9846
- stormExceededLimit,
9847
- "storm duration:",
9848
- Date.now() - this.stormInfo.startedAt,
9849
- "ms",
9850
- "buffer id:",
9851
- this.bufId
9852
- );
9853
9817
  clearTimeout(this.stormInfo.timeout);
9854
9818
  this.stormInfo = null;
9855
9819
  if (!stormExceededLimit) {
@@ -9869,20 +9833,9 @@ class MutationBuffer {
9869
9833
  this.handleStormMutations(muts);
9870
9834
  return;
9871
9835
  }
9872
- const start = performance.now();
9873
9836
  for (const mut of muts) {
9874
9837
  this.processMutation(mut);
9875
9838
  }
9876
- console.log(
9877
- muts.length,
9878
- "mutations processed in",
9879
- performance.now() - start,
9880
- "ms",
9881
- "overrideStorm",
9882
- overrideStorm,
9883
- "buffer id:",
9884
- this.bufId
9885
- );
9886
9839
  this.emit();
9887
9840
  });
9888
9841
  __publicField(this, "processMutations", (mutations) => {
@@ -10348,6 +10301,7 @@ class MutationBuffer {
10348
10301
  }
10349
10302
  });
10350
10303
  }
10304
+ // private bufId: string = makeid();
10351
10305
  init(options) {
10352
10306
  [
10353
10307
  "mutationCb",
@@ -12424,7 +12378,6 @@ function record(options = {}) {
12424
12378
  if (!recordDOM) {
12425
12379
  return;
12426
12380
  }
12427
- const start = performance.now();
12428
12381
  wrappedEmit(
12429
12382
  {
12430
12383
  type: EventType.Meta,
@@ -12492,7 +12445,6 @@ function record(options = {}) {
12492
12445
  document.adoptedStyleSheets,
12493
12446
  mirror.getId(document)
12494
12447
  );
12495
- console.log("full snapshot took", performance.now() - start, "ms");
12496
12448
  };
12497
12449
  try {
12498
12450
  const handlers = [];