@glimt/record 0.0.17 → 0.0.19

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.
@@ -1038,10 +1038,7 @@ function serializeElementNode(n2, options) {
1038
1038
  }
1039
1039
  if (tagName === "canvas" && recordCanvas) {
1040
1040
  if (n2.__context === "2d") {
1041
- console.time("canvas-blank-check");
1042
- const tempBoolean = !is2DCanvasBlank(n2);
1043
- console.timeEnd("canvas-blank-check");
1044
- if (tempBoolean) {
1041
+ if (!is2DCanvasBlank(n2)) {
1045
1042
  attributes.rr_dataURL = n2.toDataURL(
1046
1043
  dataURLOptions.type,
1047
1044
  dataURLOptions.quality
@@ -9439,7 +9436,11 @@ class MutationBuffer {
9439
9436
  __publicField(this, "processedNodeManager");
9440
9437
  __publicField(this, "unattachedDoc");
9441
9438
  __publicField(this, "processMutations", (mutations) => {
9442
- mutations.forEach(this.processMutation);
9439
+ console.time("processMutations");
9440
+ for (const mut of mutations) {
9441
+ this.processMutation(mut);
9442
+ }
9443
+ console.timeEnd("processMutations");
9443
9444
  this.emit();
9444
9445
  });
9445
9446
  __publicField(this, "emit", () => {
@@ -9590,34 +9591,91 @@ class MutationBuffer {
9590
9591
  addList.removeNode(node2.value);
9591
9592
  pushAdd(node2.value);
9592
9593
  }
9593
- const payload = {
9594
- texts: this.texts.map((text) => {
9595
- const n2 = text.node;
9596
- const parent = index.parentNode(n2);
9597
- if (parent && parent.tagName === "TEXTAREA") {
9598
- this.genTextAreaValueMutation(parent);
9599
- }
9600
- return {
9601
- id: this.mirror.getId(n2),
9594
+ const payloadTexts = [];
9595
+ for (const text of this.texts) {
9596
+ const n2 = text.node;
9597
+ const parent = index.parentNode(n2);
9598
+ if (parent && parent.tagName === "TEXTAREA") {
9599
+ this.genTextAreaValueMutation(parent);
9600
+ }
9601
+ const id = this.mirror.getId(n2);
9602
+ if (!addedIds.has(id) && this.mirror.has(id)) {
9603
+ payloadTexts.push({
9604
+ id,
9602
9605
  value: text.value
9603
- };
9604
- }).filter((text) => !addedIds.has(text.id)).filter((text) => this.mirror.has(text.id)),
9605
- attributes: this.attributes.map((attribute) => {
9606
- const { attributes } = attribute;
9607
- if (typeof attributes.style === "string") {
9608
- const diffAsStr = JSON.stringify(attribute.styleDiff);
9609
- const unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
9610
- if (diffAsStr.length < attributes.style.length) {
9611
- if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
9612
- attributes.style = attribute.styleDiff;
9613
- }
9606
+ });
9607
+ }
9608
+ }
9609
+ const payloadAttributes = [];
9610
+ for (const attribute of this.attributes) {
9611
+ const { attributes } = attribute;
9612
+ if (typeof attributes.style === "string") {
9613
+ const diffAsStr = JSON.stringify(attribute.styleDiff);
9614
+ const unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
9615
+ if (diffAsStr.length < attributes.style.length) {
9616
+ if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
9617
+ attributes.style = attribute.styleDiff;
9614
9618
  }
9615
9619
  }
9616
- return {
9617
- id: this.mirror.getId(attribute.node),
9620
+ }
9621
+ const id = this.mirror.getId(attribute.node);
9622
+ if (!addedIds.has(id) && this.mirror.has(id)) {
9623
+ payloadAttributes.push({
9624
+ id,
9618
9625
  attributes
9619
- };
9620
- }).filter((attribute) => !addedIds.has(attribute.id)).filter((attribute) => this.mirror.has(attribute.id)),
9626
+ });
9627
+ }
9628
+ }
9629
+ const payload = {
9630
+ texts: payloadTexts,
9631
+ attributes: payloadAttributes,
9632
+ //original implementation instead of "payloadTexts"
9633
+ // this.texts
9634
+ // .map((text) => {
9635
+ // const n = text.node;
9636
+ // const parent = dom.parentNode(n);
9637
+ // if (parent && (parent as Element).tagName === 'TEXTAREA') {
9638
+ // // the node is being ignored as it isn't in the mirror, so shift mutation to attributes on parent textarea
9639
+ // this.genTextAreaValueMutation(parent as HTMLTextAreaElement);
9640
+ // }
9641
+ // return {
9642
+ // id: this.mirror.getId(n),
9643
+ // value: text.value,
9644
+ // };
9645
+ // })
9646
+ // // no need to include them on added elements, as they have just been serialized with up to date attribubtes
9647
+ // .filter((text) => !addedIds.has(text.id))
9648
+ // // text mutation's id was not in the mirror map means the target node has been removed
9649
+ // .filter((text) => this.mirror.has(text.id)),
9650
+ //original implementation instead of "payloadAttributes"
9651
+ // this.attributes
9652
+ // .map((attribute) => {
9653
+ // const { attributes } = attribute;
9654
+ // if (typeof attributes.style === 'string') {
9655
+ // const diffAsStr = JSON.stringify(attribute.styleDiff);
9656
+ // const unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
9657
+ // // check if the style diff is actually shorter than the regular string based mutation
9658
+ // // (which was the whole point of #464 'compact style mutation').
9659
+ // if (diffAsStr.length < attributes.style.length) {
9660
+ // // also: CSSOM fails badly when var() is present on shorthand properties, so only proceed with
9661
+ // // the compact style mutation if these have all been accounted for
9662
+ // if (
9663
+ // (diffAsStr + unchangedAsStr).split('var(').length ===
9664
+ // attributes.style.split('var(').length
9665
+ // ) {
9666
+ // attributes.style = attribute.styleDiff;
9667
+ // }
9668
+ // }
9669
+ // }
9670
+ // return {
9671
+ // id: this.mirror.getId(attribute.node),
9672
+ // attributes: attributes,
9673
+ // };
9674
+ // })
9675
+ // // no need to include them on added elements, as they have just been serialized with up to date attribubtes
9676
+ // .filter((attribute) => !addedIds.has(attribute.id))
9677
+ // // attribute mutation's id was not in the mirror map means the target node has been removed
9678
+ // .filter((attribute) => this.mirror.has(attribute.id)),
9621
9679
  removes: this.removes,
9622
9680
  adds
9623
9681
  };
@@ -9774,8 +9832,11 @@ class MutationBuffer {
9774
9832
  this.genTextAreaValueMutation(m.target);
9775
9833
  return;
9776
9834
  }
9777
- m.addedNodes.forEach((n2) => this.genAdds(n2, m.target));
9778
- m.removedNodes.forEach((n2) => {
9835
+ for (let i2 = 0; i2 < m.addedNodes.length; i2++) {
9836
+ this.genAdds(m.addedNodes[i2], m.target);
9837
+ }
9838
+ for (let i2 = 0; i2 < m.removedNodes.length; i2++) {
9839
+ const n2 = m.removedNodes[i2];
9779
9840
  const nodeId = this.mirror.getId(n2);
9780
9841
  const parentId = isShadowRoot(m.target) ? this.mirror.getId(index.host(m.target)) : this.mirror.getId(m.target);
9781
9842
  if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n2, this.mirror, this.slimDOMOptions) || !isSerialized(n2, this.mirror)) {
@@ -9797,7 +9858,7 @@ class MutationBuffer {
9797
9858
  processRemoves(n2, this.removesSubTreeCache);
9798
9859
  }
9799
9860
  this.mapRemoves.push(n2);
9800
- });
9861
+ }
9801
9862
  break;
9802
9863
  }
9803
9864
  }
@@ -9822,12 +9883,17 @@ class MutationBuffer {
9822
9883
  this.droppedSet.delete(n2);
9823
9884
  }
9824
9885
  if (!isBlocked(n2, this.blockClass, this.blockSelector, false)) {
9825
- index.childNodes(n2).forEach((childN) => this.genAdds(childN));
9886
+ const childNodes2 = index.childNodes(n2);
9887
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
9888
+ this.genAdds(childNodes2[i2]);
9889
+ }
9826
9890
  if (hasShadowRoot(n2)) {
9827
- index.childNodes(index.shadowRoot(n2)).forEach((childN) => {
9891
+ const shadowRootChildNodes = index.childNodes(index.shadowRoot(n2));
9892
+ for (let i2 = 0; i2 < shadowRootChildNodes.length; i2++) {
9893
+ const childN = shadowRootChildNodes[i2];
9828
9894
  this.processedNodeManager.add(childN, this);
9829
9895
  this.genAdds(childN, n2);
9830
- });
9896
+ }
9831
9897
  }
9832
9898
  }
9833
9899
  });
@@ -9887,7 +9953,10 @@ class MutationBuffer {
9887
9953
  }
9888
9954
  function deepDelete(addsSet, n2) {
9889
9955
  addsSet.delete(n2);
9890
- index.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN));
9956
+ const childNodes2 = index.childNodes(n2);
9957
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
9958
+ deepDelete(addsSet, childNodes2[i2]);
9959
+ }
9891
9960
  }
9892
9961
  function processRemoves(n2, cache) {
9893
9962
  const queue = [n2];
@@ -9895,7 +9964,10 @@ function processRemoves(n2, cache) {
9895
9964
  const next = queue.pop();
9896
9965
  if (cache.has(next)) continue;
9897
9966
  cache.add(next);
9898
- index.childNodes(next).forEach((n22) => queue.push(n22));
9967
+ const childNodes2 = index.childNodes(next);
9968
+ for (let i2 = 0; i2 < childNodes2.length; i2++) {
9969
+ queue.push(childNodes2[i2]);
9970
+ }
9899
9971
  }
9900
9972
  return;
9901
9973
  }