@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.
- package/dist/record.cjs +109 -37
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +109 -37
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +109 -37
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +19 -19
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.cjs
CHANGED
|
@@ -1005,10 +1005,7 @@ function serializeElementNode(n2, options) {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
if (tagName === "canvas" && recordCanvas) {
|
|
1007
1007
|
if (n2.__context === "2d") {
|
|
1008
|
-
|
|
1009
|
-
const tempBoolean = !is2DCanvasBlank(n2);
|
|
1010
|
-
console.timeEnd("canvas-blank-check");
|
|
1011
|
-
if (tempBoolean) {
|
|
1008
|
+
if (!is2DCanvasBlank(n2)) {
|
|
1012
1009
|
attributes.rr_dataURL = n2.toDataURL(
|
|
1013
1010
|
dataURLOptions.type,
|
|
1014
1011
|
dataURLOptions.quality
|
|
@@ -9397,7 +9394,11 @@ class MutationBuffer {
|
|
|
9397
9394
|
__publicField(this, "processedNodeManager");
|
|
9398
9395
|
__publicField(this, "unattachedDoc");
|
|
9399
9396
|
__publicField(this, "processMutations", (mutations) => {
|
|
9400
|
-
|
|
9397
|
+
console.time("processMutations");
|
|
9398
|
+
for (const mut of mutations) {
|
|
9399
|
+
this.processMutation(mut);
|
|
9400
|
+
}
|
|
9401
|
+
console.timeEnd("processMutations");
|
|
9401
9402
|
this.emit();
|
|
9402
9403
|
});
|
|
9403
9404
|
__publicField(this, "emit", () => {
|
|
@@ -9548,34 +9549,91 @@ class MutationBuffer {
|
|
|
9548
9549
|
addList.removeNode(node2.value);
|
|
9549
9550
|
pushAdd(node2.value);
|
|
9550
9551
|
}
|
|
9551
|
-
const
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9552
|
+
const payloadTexts = [];
|
|
9553
|
+
for (const text of this.texts) {
|
|
9554
|
+
const n2 = text.node;
|
|
9555
|
+
const parent = index.parentNode(n2);
|
|
9556
|
+
if (parent && parent.tagName === "TEXTAREA") {
|
|
9557
|
+
this.genTextAreaValueMutation(parent);
|
|
9558
|
+
}
|
|
9559
|
+
const id = this.mirror.getId(n2);
|
|
9560
|
+
if (!addedIds.has(id) && this.mirror.has(id)) {
|
|
9561
|
+
payloadTexts.push({
|
|
9562
|
+
id,
|
|
9560
9563
|
value: text.value
|
|
9561
|
-
};
|
|
9562
|
-
}
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9564
|
+
});
|
|
9565
|
+
}
|
|
9566
|
+
}
|
|
9567
|
+
const payloadAttributes = [];
|
|
9568
|
+
for (const attribute of this.attributes) {
|
|
9569
|
+
const { attributes } = attribute;
|
|
9570
|
+
if (typeof attributes.style === "string") {
|
|
9571
|
+
const diffAsStr = JSON.stringify(attribute.styleDiff);
|
|
9572
|
+
const unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
|
|
9573
|
+
if (diffAsStr.length < attributes.style.length) {
|
|
9574
|
+
if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
|
|
9575
|
+
attributes.style = attribute.styleDiff;
|
|
9572
9576
|
}
|
|
9573
9577
|
}
|
|
9574
|
-
|
|
9575
|
-
|
|
9578
|
+
}
|
|
9579
|
+
const id = this.mirror.getId(attribute.node);
|
|
9580
|
+
if (!addedIds.has(id) && this.mirror.has(id)) {
|
|
9581
|
+
payloadAttributes.push({
|
|
9582
|
+
id,
|
|
9576
9583
|
attributes
|
|
9577
|
-
};
|
|
9578
|
-
}
|
|
9584
|
+
});
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
const payload = {
|
|
9588
|
+
texts: payloadTexts,
|
|
9589
|
+
attributes: payloadAttributes,
|
|
9590
|
+
//original implementation instead of "payloadTexts"
|
|
9591
|
+
// this.texts
|
|
9592
|
+
// .map((text) => {
|
|
9593
|
+
// const n = text.node;
|
|
9594
|
+
// const parent = dom.parentNode(n);
|
|
9595
|
+
// if (parent && (parent as Element).tagName === 'TEXTAREA') {
|
|
9596
|
+
// // the node is being ignored as it isn't in the mirror, so shift mutation to attributes on parent textarea
|
|
9597
|
+
// this.genTextAreaValueMutation(parent as HTMLTextAreaElement);
|
|
9598
|
+
// }
|
|
9599
|
+
// return {
|
|
9600
|
+
// id: this.mirror.getId(n),
|
|
9601
|
+
// value: text.value,
|
|
9602
|
+
// };
|
|
9603
|
+
// })
|
|
9604
|
+
// // no need to include them on added elements, as they have just been serialized with up to date attribubtes
|
|
9605
|
+
// .filter((text) => !addedIds.has(text.id))
|
|
9606
|
+
// // text mutation's id was not in the mirror map means the target node has been removed
|
|
9607
|
+
// .filter((text) => this.mirror.has(text.id)),
|
|
9608
|
+
//original implementation instead of "payloadAttributes"
|
|
9609
|
+
// this.attributes
|
|
9610
|
+
// .map((attribute) => {
|
|
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
|
+
// // check if the style diff is actually shorter than the regular string based mutation
|
|
9616
|
+
// // (which was the whole point of #464 'compact style mutation').
|
|
9617
|
+
// if (diffAsStr.length < attributes.style.length) {
|
|
9618
|
+
// // also: CSSOM fails badly when var() is present on shorthand properties, so only proceed with
|
|
9619
|
+
// // the compact style mutation if these have all been accounted for
|
|
9620
|
+
// if (
|
|
9621
|
+
// (diffAsStr + unchangedAsStr).split('var(').length ===
|
|
9622
|
+
// attributes.style.split('var(').length
|
|
9623
|
+
// ) {
|
|
9624
|
+
// attributes.style = attribute.styleDiff;
|
|
9625
|
+
// }
|
|
9626
|
+
// }
|
|
9627
|
+
// }
|
|
9628
|
+
// return {
|
|
9629
|
+
// id: this.mirror.getId(attribute.node),
|
|
9630
|
+
// attributes: attributes,
|
|
9631
|
+
// };
|
|
9632
|
+
// })
|
|
9633
|
+
// // no need to include them on added elements, as they have just been serialized with up to date attribubtes
|
|
9634
|
+
// .filter((attribute) => !addedIds.has(attribute.id))
|
|
9635
|
+
// // attribute mutation's id was not in the mirror map means the target node has been removed
|
|
9636
|
+
// .filter((attribute) => this.mirror.has(attribute.id)),
|
|
9579
9637
|
removes: this.removes,
|
|
9580
9638
|
adds
|
|
9581
9639
|
};
|
|
@@ -9732,8 +9790,11 @@ class MutationBuffer {
|
|
|
9732
9790
|
this.genTextAreaValueMutation(m.target);
|
|
9733
9791
|
return;
|
|
9734
9792
|
}
|
|
9735
|
-
|
|
9736
|
-
|
|
9793
|
+
for (let i2 = 0; i2 < m.addedNodes.length; i2++) {
|
|
9794
|
+
this.genAdds(m.addedNodes[i2], m.target);
|
|
9795
|
+
}
|
|
9796
|
+
for (let i2 = 0; i2 < m.removedNodes.length; i2++) {
|
|
9797
|
+
const n2 = m.removedNodes[i2];
|
|
9737
9798
|
const nodeId = this.mirror.getId(n2);
|
|
9738
9799
|
const parentId = isShadowRoot(m.target) ? this.mirror.getId(index.host(m.target)) : this.mirror.getId(m.target);
|
|
9739
9800
|
if (isBlocked(m.target, this.blockClass, this.blockSelector, false) || isIgnored(n2, this.mirror, this.slimDOMOptions) || !isSerialized(n2, this.mirror)) {
|
|
@@ -9755,7 +9816,7 @@ class MutationBuffer {
|
|
|
9755
9816
|
processRemoves(n2, this.removesSubTreeCache);
|
|
9756
9817
|
}
|
|
9757
9818
|
this.mapRemoves.push(n2);
|
|
9758
|
-
}
|
|
9819
|
+
}
|
|
9759
9820
|
break;
|
|
9760
9821
|
}
|
|
9761
9822
|
}
|
|
@@ -9780,12 +9841,17 @@ class MutationBuffer {
|
|
|
9780
9841
|
this.droppedSet.delete(n2);
|
|
9781
9842
|
}
|
|
9782
9843
|
if (!isBlocked(n2, this.blockClass, this.blockSelector, false)) {
|
|
9783
|
-
index.childNodes(n2)
|
|
9844
|
+
const childNodes2 = index.childNodes(n2);
|
|
9845
|
+
for (let i2 = 0; i2 < childNodes2.length; i2++) {
|
|
9846
|
+
this.genAdds(childNodes2[i2]);
|
|
9847
|
+
}
|
|
9784
9848
|
if (hasShadowRoot(n2)) {
|
|
9785
|
-
index.childNodes(index.shadowRoot(n2))
|
|
9849
|
+
const shadowRootChildNodes = index.childNodes(index.shadowRoot(n2));
|
|
9850
|
+
for (let i2 = 0; i2 < shadowRootChildNodes.length; i2++) {
|
|
9851
|
+
const childN = shadowRootChildNodes[i2];
|
|
9786
9852
|
this.processedNodeManager.add(childN, this);
|
|
9787
9853
|
this.genAdds(childN, n2);
|
|
9788
|
-
}
|
|
9854
|
+
}
|
|
9789
9855
|
}
|
|
9790
9856
|
}
|
|
9791
9857
|
});
|
|
@@ -9845,7 +9911,10 @@ class MutationBuffer {
|
|
|
9845
9911
|
}
|
|
9846
9912
|
function deepDelete(addsSet, n2) {
|
|
9847
9913
|
addsSet.delete(n2);
|
|
9848
|
-
index.childNodes(n2)
|
|
9914
|
+
const childNodes2 = index.childNodes(n2);
|
|
9915
|
+
for (let i2 = 0; i2 < childNodes2.length; i2++) {
|
|
9916
|
+
deepDelete(addsSet, childNodes2[i2]);
|
|
9917
|
+
}
|
|
9849
9918
|
}
|
|
9850
9919
|
function processRemoves(n2, cache) {
|
|
9851
9920
|
const queue = [n2];
|
|
@@ -9853,7 +9922,10 @@ function processRemoves(n2, cache) {
|
|
|
9853
9922
|
const next = queue.pop();
|
|
9854
9923
|
if (cache.has(next)) continue;
|
|
9855
9924
|
cache.add(next);
|
|
9856
|
-
index.childNodes(next)
|
|
9925
|
+
const childNodes2 = index.childNodes(next);
|
|
9926
|
+
for (let i2 = 0; i2 < childNodes2.length; i2++) {
|
|
9927
|
+
queue.push(childNodes2[i2]);
|
|
9928
|
+
}
|
|
9857
9929
|
}
|
|
9858
9930
|
return;
|
|
9859
9931
|
}
|