@glimt/record 0.0.35 → 0.0.37

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
@@ -1172,7 +1172,6 @@ function serializeTextNode(n2, options) {
1172
1172
  };
1173
1173
  }
1174
1174
  function serializeElementNode(n2, options) {
1175
- const start = performance.now();
1176
1175
  const {
1177
1176
  doc,
1178
1177
  blockClass,
@@ -1214,6 +1213,8 @@ function serializeElementNode(n2, options) {
1214
1213
  delete attributes.rel;
1215
1214
  delete attributes.href;
1216
1215
  attributes._cssText = cssText;
1216
+ } else {
1217
+ console.log("failed to extract stylesheets from link element", n2);
1217
1218
  }
1218
1219
  }
1219
1220
  if (tagName === "style" && n2.sheet) {
@@ -1371,19 +1372,6 @@ function serializeElementNode(n2, options) {
1371
1372
  if (customElements.get(tagName)) isCustomElement = true;
1372
1373
  } catch (e2) {
1373
1374
  }
1374
- const took = performance.now() - start;
1375
- if (!window.serialization_perf_map) window.serialization_perf_map = {};
1376
- if (!(tagName in window.serialization_perf_map)) {
1377
- window.serialization_perf_map[tagName] = {
1378
- avg: 0,
1379
- times: []
1380
- };
1381
- }
1382
- window.serialization_perf_map[tagName].times.push(took);
1383
- if (window.serialization_perf_map[tagName].times.length > 1e3) {
1384
- window.serialization_perf_map[tagName].times.shift();
1385
- }
1386
- 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;
1387
1375
  return {
1388
1376
  type: NodeType$2.Element,
1389
1377
  tagName,
@@ -9751,15 +9739,6 @@ class DoubleLinkedList {
9751
9739
  }
9752
9740
  }
9753
9741
  const moveKey = (id, parentId) => `${id}@${parentId}`;
9754
- function makeid(length = 8) {
9755
- var result2 = "";
9756
- var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
9757
- var charactersLength = characters.length;
9758
- for (var i2 = 0; i2 < length; i2++) {
9759
- result2 += characters.charAt(Math.floor(Math.random() * charactersLength));
9760
- }
9761
- return result2;
9762
- }
9763
9742
  class MutationBuffer {
9764
9743
  constructor() {
9765
9744
  __publicField(this, "frozen", false);
@@ -9796,7 +9775,6 @@ class MutationBuffer {
9796
9775
  __publicField(this, "canvasManager");
9797
9776
  __publicField(this, "processedNodeManager");
9798
9777
  __publicField(this, "unattachedDoc");
9799
- __publicField(this, "bufId", makeid());
9800
9778
  __publicField(this, "stormBatches", []);
9801
9779
  __publicField(this, "stormInfo", null);
9802
9780
  __publicField(this, "stormSettings", {
@@ -9810,11 +9788,6 @@ class MutationBuffer {
9810
9788
  __publicField(this, "handleStormMutations", (muts) => {
9811
9789
  const time = Date.now();
9812
9790
  if (this.stormInfo == null) {
9813
- console.log(
9814
- "detected probable mutation storm start",
9815
- "buffer id:",
9816
- this.bufId
9817
- );
9818
9791
  this.stormInfo = {
9819
9792
  startedAt: time,
9820
9793
  totalMutations: 0,
@@ -9845,18 +9818,6 @@ class MutationBuffer {
9845
9818
  __publicField(this, "handleStormFinish", () => {
9846
9819
  if (!this.stormInfo) return;
9847
9820
  const { stormExceededLimit } = this.stormInfo;
9848
- console.log(
9849
- "mutation storm finished",
9850
- "totalMutations:",
9851
- this.stormInfo.totalMutations,
9852
- "stormExceededLimit:",
9853
- stormExceededLimit,
9854
- "storm duration:",
9855
- Date.now() - this.stormInfo.startedAt,
9856
- "ms",
9857
- "buffer id:",
9858
- this.bufId
9859
- );
9860
9821
  clearTimeout(this.stormInfo.timeout);
9861
9822
  this.stormInfo = null;
9862
9823
  if (!stormExceededLimit) {
@@ -10344,6 +10305,7 @@ class MutationBuffer {
10344
10305
  }
10345
10306
  });
10346
10307
  }
10308
+ // private bufId: string = makeid();
10347
10309
  init(options) {
10348
10310
  [
10349
10311
  "mutationCb",
@@ -12420,7 +12382,6 @@ function record(options = {}) {
12420
12382
  if (!recordDOM) {
12421
12383
  return;
12422
12384
  }
12423
- const start = performance.now();
12424
12385
  wrappedEmit(
12425
12386
  {
12426
12387
  type: EventType.Meta,
@@ -12488,7 +12449,6 @@ function record(options = {}) {
12488
12449
  document.adoptedStyleSheets,
12489
12450
  mirror.getId(document)
12490
12451
  );
12491
- console.log("full snapshot took", performance.now() - start, "ms");
12492
12452
  };
12493
12453
  try {
12494
12454
  const handlers = [];
@@ -12622,12 +12582,27 @@ function record(options = {}) {
12622
12582
  console.warn(error);
12623
12583
  }
12624
12584
  });
12585
+ let initedAt = null;
12625
12586
  const init = () => {
12587
+ initedAt = Date.now();
12626
12588
  takeFullSnapshot$1();
12627
12589
  handlers.push(observe(document));
12628
12590
  recording = true;
12629
12591
  };
12592
+ const customOnLoad = () => {
12593
+ window.removeEventListener("load", customOnLoad);
12594
+ if (!recording || initedAt == null) return;
12595
+ console.log("customOnLoad wants to take a full snapshot");
12596
+ if (Date.now() - initedAt <= 10) {
12597
+ console.log("customOnLoad skipping full snapshot bc it was too soon");
12598
+ return;
12599
+ }
12600
+ console.log("customOnLoad taking full snapshot bc race condition");
12601
+ takeFullSnapshot$1();
12602
+ };
12603
+ window.addEventListener("load", customOnLoad);
12630
12604
  if (document.readyState === "interactive" || document.readyState === "complete") {
12605
+ console.log("fired init() bc readyState === 'interactive' || 'complete'");
12631
12606
  init();
12632
12607
  } else {
12633
12608
  handlers.push(
@@ -12636,7 +12611,10 @@ function record(options = {}) {
12636
12611
  type: EventType.DomContentLoaded,
12637
12612
  data: {}
12638
12613
  });
12639
- if (recordAfter === "DOMContentLoaded") init();
12614
+ if (recordAfter === "DOMContentLoaded") {
12615
+ console.log("fired init() bc listener 'DOMContentLoaded'");
12616
+ init();
12617
+ }
12640
12618
  })
12641
12619
  );
12642
12620
  handlers.push(
@@ -12647,7 +12625,10 @@ function record(options = {}) {
12647
12625
  type: EventType.Load,
12648
12626
  data: {}
12649
12627
  });
12650
- if (recordAfter === "load") init();
12628
+ if (recordAfter === "load") {
12629
+ console.log("fired init() bc listener 'load'");
12630
+ init();
12631
+ }
12651
12632
  },
12652
12633
  window
12653
12634
  )