@amplitude/rrweb-player 2.0.0-alpha.39 → 2.0.0-alpha.40
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/rrweb-player.cjs +120 -1
- package/dist/rrweb-player.cjs.map +1 -1
- package/dist/rrweb-player.js +120 -1
- package/dist/rrweb-player.js.map +1 -1
- package/dist/rrweb-player.umd.cjs +121 -1
- package/dist/rrweb-player.umd.cjs.map +2 -2
- package/dist/rrweb-player.umd.min.cjs +28 -28
- package/dist/rrweb-player.umd.min.cjs.map +3 -3
- package/package.json +4 -4
|
@@ -5450,7 +5450,30 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
5450
5450
|
}
|
|
5451
5451
|
return false;
|
|
5452
5452
|
}
|
|
5453
|
+
function serializeAdoptedStyleSheets(sheets, onAdoptedStyleSheet, emittedStyleIds) {
|
|
5454
|
+
return Array.from(sheets).map((sheet) => {
|
|
5455
|
+
const styleId = onAdoptedStyleSheet(sheet);
|
|
5456
|
+
let rules2 = [];
|
|
5457
|
+
if (!emittedStyleIds.has(styleId)) {
|
|
5458
|
+
emittedStyleIds.add(styleId);
|
|
5459
|
+
try {
|
|
5460
|
+
rules2 = Array.from(sheet.cssRules, (rule2, index2) => ({
|
|
5461
|
+
rule: stringifyRule(rule2, sheet.href),
|
|
5462
|
+
index: index2
|
|
5463
|
+
}));
|
|
5464
|
+
} catch (e2) {
|
|
5465
|
+
if (e2 instanceof DOMException && e2.name === "SecurityError") ;
|
|
5466
|
+
else {
|
|
5467
|
+
throw e2;
|
|
5468
|
+
}
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
return { styleId, rules: rules2 };
|
|
5472
|
+
});
|
|
5473
|
+
}
|
|
5453
5474
|
function serializeNodeWithId(n2, options) {
|
|
5475
|
+
var _a4;
|
|
5476
|
+
var _a22, _b22;
|
|
5454
5477
|
const {
|
|
5455
5478
|
doc,
|
|
5456
5479
|
mirror: mirror2,
|
|
@@ -5469,6 +5492,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5469
5492
|
inlineImages = false,
|
|
5470
5493
|
recordCanvas = false,
|
|
5471
5494
|
onSerialize,
|
|
5495
|
+
onAdoptedStyleSheet,
|
|
5472
5496
|
onIframeLoad,
|
|
5473
5497
|
iframeLoadTimeout = 5e3,
|
|
5474
5498
|
onStylesheetLoad,
|
|
@@ -5478,6 +5502,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5478
5502
|
cssCaptured = false,
|
|
5479
5503
|
applyBackgroundColorToBlockedElements = false
|
|
5480
5504
|
} = options;
|
|
5505
|
+
const emittedStyleIds = (_a4 = options._emittedStyleIds) != null ? _a4 : /* @__PURE__ */ new Set();
|
|
5481
5506
|
let { needsMask } = options;
|
|
5482
5507
|
let { preserveWhiteSpace = true } = options;
|
|
5483
5508
|
if (!needsMask) {
|
|
@@ -5533,8 +5558,26 @@ function serializeNodeWithId(n2, options) {
|
|
|
5533
5558
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
5534
5559
|
delete serializedNode.needBlock;
|
|
5535
5560
|
const shadowRootEl = index$1.shadowRoot(n2);
|
|
5536
|
-
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
5561
|
+
if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
|
|
5537
5562
|
serializedNode.isShadowHost = true;
|
|
5563
|
+
if (onAdoptedStyleSheet && ((_a22 = shadowRootEl.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
5564
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5565
|
+
shadowRootEl.adoptedStyleSheets,
|
|
5566
|
+
onAdoptedStyleSheet,
|
|
5567
|
+
emittedStyleIds
|
|
5568
|
+
);
|
|
5569
|
+
}
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
if (serializedNode.type === NodeType$3.Document && onAdoptedStyleSheet) {
|
|
5573
|
+
const doc2 = n2;
|
|
5574
|
+
if ((_b22 = doc2.adoptedStyleSheets) == null ? void 0 : _b22.length) {
|
|
5575
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5576
|
+
doc2.adoptedStyleSheets,
|
|
5577
|
+
onAdoptedStyleSheet,
|
|
5578
|
+
emittedStyleIds
|
|
5579
|
+
);
|
|
5580
|
+
}
|
|
5538
5581
|
}
|
|
5539
5582
|
if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
|
|
5540
5583
|
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
|
|
@@ -5560,6 +5603,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
5560
5603
|
recordCanvas,
|
|
5561
5604
|
preserveWhiteSpace,
|
|
5562
5605
|
onSerialize,
|
|
5606
|
+
onAdoptedStyleSheet,
|
|
5607
|
+
_emittedStyleIds: emittedStyleIds,
|
|
5563
5608
|
onIframeLoad,
|
|
5564
5609
|
iframeLoadTimeout,
|
|
5565
5610
|
onStylesheetLoad,
|
|
@@ -5621,6 +5666,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5621
5666
|
recordCanvas,
|
|
5622
5667
|
preserveWhiteSpace,
|
|
5623
5668
|
onSerialize,
|
|
5669
|
+
onAdoptedStyleSheet,
|
|
5624
5670
|
onIframeLoad,
|
|
5625
5671
|
iframeLoadTimeout,
|
|
5626
5672
|
onStylesheetLoad,
|
|
@@ -5700,6 +5746,7 @@ function snapshot(n2, options) {
|
|
|
5700
5746
|
dataURLOptions,
|
|
5701
5747
|
preserveWhiteSpace,
|
|
5702
5748
|
onSerialize,
|
|
5749
|
+
onAdoptedStyleSheet,
|
|
5703
5750
|
onIframeLoad,
|
|
5704
5751
|
iframeLoadTimeout,
|
|
5705
5752
|
onStylesheetLoad,
|
|
@@ -5762,6 +5809,7 @@ function snapshot(n2, options) {
|
|
|
5762
5809
|
recordCanvas,
|
|
5763
5810
|
preserveWhiteSpace,
|
|
5764
5811
|
onSerialize,
|
|
5812
|
+
onAdoptedStyleSheet,
|
|
5765
5813
|
onIframeLoad,
|
|
5766
5814
|
iframeLoadTimeout,
|
|
5767
5815
|
onStylesheetLoad,
|
|
@@ -16852,6 +16900,7 @@ class Replayer {
|
|
|
16852
16900
|
__publicField2(this, "lastSelectionData", null);
|
|
16853
16901
|
__publicField2(this, "constructedStyleMutations", []);
|
|
16854
16902
|
__publicField2(this, "adoptedStyleSheets", []);
|
|
16903
|
+
__publicField2(this, "snapshotAdoptedStyleSheetQueue", []);
|
|
16855
16904
|
__publicField2(this, "handleResize", (dimension) => {
|
|
16856
16905
|
this.iframe.style.display = "inherit";
|
|
16857
16906
|
for (const el of [this.mouseTail, this.iframe]) {
|
|
@@ -17131,6 +17180,14 @@ class Replayer {
|
|
|
17131
17180
|
this.applyAdoptedStyleSheet(data);
|
|
17132
17181
|
});
|
|
17133
17182
|
this.adoptedStyleSheets = [];
|
|
17183
|
+
this.snapshotAdoptedStyleSheetQueue.forEach(
|
|
17184
|
+
({ id, adoptedStyleSheets }) => {
|
|
17185
|
+
const node2 = this.mirror.getNode(id);
|
|
17186
|
+
if (node2)
|
|
17187
|
+
this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
|
|
17188
|
+
}
|
|
17189
|
+
);
|
|
17190
|
+
this.snapshotAdoptedStyleSheetQueue = [];
|
|
17134
17191
|
}
|
|
17135
17192
|
if (this.mousePos) {
|
|
17136
17193
|
this.moveAndHover(
|
|
@@ -17505,6 +17562,7 @@ class Replayer {
|
|
|
17505
17562
|
const collectedIframes = [];
|
|
17506
17563
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17507
17564
|
const afterAppend = (builtNode, id) => {
|
|
17565
|
+
var _a22;
|
|
17508
17566
|
if (builtNode.nodeName === "DIALOG")
|
|
17509
17567
|
collectedDialogs.add(builtNode);
|
|
17510
17568
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17516,6 +17574,10 @@ class Replayer {
|
|
|
17516
17574
|
this.mirror
|
|
17517
17575
|
);
|
|
17518
17576
|
}
|
|
17577
|
+
const sn = this.mirror.getMeta(builtNode);
|
|
17578
|
+
if (sn && "adoptedStyleSheets" in sn && ((_a22 = sn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17579
|
+
this.applySnapshotAdoptedStyleSheets(builtNode, sn.adoptedStyleSheets);
|
|
17580
|
+
}
|
|
17519
17581
|
for (const plugin of this.config.plugins || []) {
|
|
17520
17582
|
if (plugin.onBuild)
|
|
17521
17583
|
plugin.onBuild(builtNode, {
|
|
@@ -17633,6 +17695,7 @@ class Replayer {
|
|
|
17633
17695
|
const collectedIframes = [];
|
|
17634
17696
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17635
17697
|
const afterAppend = (builtNode, id) => {
|
|
17698
|
+
var _a22;
|
|
17636
17699
|
if (builtNode.nodeName === "DIALOG")
|
|
17637
17700
|
collectedDialogs.add(builtNode);
|
|
17638
17701
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17645,6 +17708,25 @@ class Replayer {
|
|
|
17645
17708
|
head
|
|
17646
17709
|
);
|
|
17647
17710
|
}
|
|
17711
|
+
{
|
|
17712
|
+
const nodeSn = mirror2.getMeta(
|
|
17713
|
+
builtNode
|
|
17714
|
+
);
|
|
17715
|
+
if (nodeSn && "adoptedStyleSheets" in nodeSn && ((_a22 = nodeSn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17716
|
+
if (this.usingVirtualDom) {
|
|
17717
|
+
const id2 = mirror2.getId(builtNode);
|
|
17718
|
+
this.snapshotAdoptedStyleSheetQueue.push({
|
|
17719
|
+
id: id2,
|
|
17720
|
+
adoptedStyleSheets: nodeSn.adoptedStyleSheets
|
|
17721
|
+
});
|
|
17722
|
+
} else {
|
|
17723
|
+
this.applySnapshotAdoptedStyleSheets(
|
|
17724
|
+
builtNode,
|
|
17725
|
+
nodeSn.adoptedStyleSheets
|
|
17726
|
+
);
|
|
17727
|
+
}
|
|
17728
|
+
}
|
|
17729
|
+
}
|
|
17648
17730
|
if (this.usingVirtualDom) return;
|
|
17649
17731
|
for (const plugin of this.config.plugins || []) {
|
|
17650
17732
|
if (plugin.onBuild)
|
|
@@ -18528,6 +18610,44 @@ class Replayer {
|
|
|
18528
18610
|
rule2.style.removeProperty(data.remove.property);
|
|
18529
18611
|
}
|
|
18530
18612
|
}
|
|
18613
|
+
applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets) {
|
|
18614
|
+
var _a22;
|
|
18615
|
+
let hostWindow = null;
|
|
18616
|
+
if (hasShadowRoot(node2))
|
|
18617
|
+
hostWindow = ((_a22 = node2.ownerDocument) == null ? void 0 : _a22.defaultView) || null;
|
|
18618
|
+
else if (node2.nodeName === "#document")
|
|
18619
|
+
hostWindow = node2.defaultView;
|
|
18620
|
+
if (!hostWindow) return;
|
|
18621
|
+
const sheets = [];
|
|
18622
|
+
for (const { styleId, rules: rules2 } of adoptedStyleSheets) {
|
|
18623
|
+
const existing = this.styleMirror.getStyle(styleId);
|
|
18624
|
+
if (existing) {
|
|
18625
|
+
if (rules2.length) {
|
|
18626
|
+
this.applyStyleSheetRule(
|
|
18627
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18628
|
+
existing
|
|
18629
|
+
);
|
|
18630
|
+
}
|
|
18631
|
+
sheets.push(existing);
|
|
18632
|
+
continue;
|
|
18633
|
+
}
|
|
18634
|
+
try {
|
|
18635
|
+
const sheet = new hostWindow.CSSStyleSheet();
|
|
18636
|
+
this.styleMirror.add(sheet, styleId);
|
|
18637
|
+
if (rules2.length) {
|
|
18638
|
+
this.applyStyleSheetRule(
|
|
18639
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18640
|
+
sheet
|
|
18641
|
+
);
|
|
18642
|
+
}
|
|
18643
|
+
sheets.push(sheet);
|
|
18644
|
+
} catch (e2) {
|
|
18645
|
+
}
|
|
18646
|
+
}
|
|
18647
|
+
if (hasShadowRoot(node2)) node2.shadowRoot.adoptedStyleSheets = sheets;
|
|
18648
|
+
else if (node2.nodeName === "#document")
|
|
18649
|
+
node2.adoptedStyleSheets = sheets;
|
|
18650
|
+
}
|
|
18531
18651
|
applyAdoptedStyleSheet(data) {
|
|
18532
18652
|
var _a22;
|
|
18533
18653
|
const targetHost = this.mirror.getNode(data.id);
|