@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
package/dist/rrweb-player.cjs
CHANGED
|
@@ -5457,7 +5457,29 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
5457
5457
|
}
|
|
5458
5458
|
return false;
|
|
5459
5459
|
}
|
|
5460
|
+
function serializeAdoptedStyleSheets(sheets, onAdoptedStyleSheet, emittedStyleIds) {
|
|
5461
|
+
return Array.from(sheets).map((sheet) => {
|
|
5462
|
+
const styleId = onAdoptedStyleSheet(sheet);
|
|
5463
|
+
let rules2 = [];
|
|
5464
|
+
if (!emittedStyleIds.has(styleId)) {
|
|
5465
|
+
emittedStyleIds.add(styleId);
|
|
5466
|
+
try {
|
|
5467
|
+
rules2 = Array.from(sheet.cssRules, (rule2, index2) => ({
|
|
5468
|
+
rule: stringifyRule(rule2, sheet.href),
|
|
5469
|
+
index: index2
|
|
5470
|
+
}));
|
|
5471
|
+
} catch (e2) {
|
|
5472
|
+
if (e2 instanceof DOMException && e2.name === "SecurityError") ;
|
|
5473
|
+
else {
|
|
5474
|
+
throw e2;
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
return { styleId, rules: rules2 };
|
|
5479
|
+
});
|
|
5480
|
+
}
|
|
5460
5481
|
function serializeNodeWithId(n2, options) {
|
|
5482
|
+
var _a22, _b2;
|
|
5461
5483
|
const {
|
|
5462
5484
|
doc,
|
|
5463
5485
|
mirror: mirror2,
|
|
@@ -5476,6 +5498,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5476
5498
|
inlineImages = false,
|
|
5477
5499
|
recordCanvas = false,
|
|
5478
5500
|
onSerialize,
|
|
5501
|
+
onAdoptedStyleSheet,
|
|
5479
5502
|
onIframeLoad,
|
|
5480
5503
|
iframeLoadTimeout = 5e3,
|
|
5481
5504
|
onStylesheetLoad,
|
|
@@ -5485,6 +5508,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5485
5508
|
cssCaptured = false,
|
|
5486
5509
|
applyBackgroundColorToBlockedElements = false
|
|
5487
5510
|
} = options;
|
|
5511
|
+
const emittedStyleIds = options._emittedStyleIds ?? /* @__PURE__ */ new Set();
|
|
5488
5512
|
let { needsMask } = options;
|
|
5489
5513
|
let { preserveWhiteSpace = true } = options;
|
|
5490
5514
|
if (!needsMask) {
|
|
@@ -5540,8 +5564,26 @@ function serializeNodeWithId(n2, options) {
|
|
|
5540
5564
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
5541
5565
|
delete serializedNode.needBlock;
|
|
5542
5566
|
const shadowRootEl = index$1.shadowRoot(n2);
|
|
5543
|
-
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
5567
|
+
if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
|
|
5544
5568
|
serializedNode.isShadowHost = true;
|
|
5569
|
+
if (onAdoptedStyleSheet && ((_a22 = shadowRootEl.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
5570
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5571
|
+
shadowRootEl.adoptedStyleSheets,
|
|
5572
|
+
onAdoptedStyleSheet,
|
|
5573
|
+
emittedStyleIds
|
|
5574
|
+
);
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
if (serializedNode.type === NodeType$3.Document && onAdoptedStyleSheet) {
|
|
5579
|
+
const doc2 = n2;
|
|
5580
|
+
if ((_b2 = doc2.adoptedStyleSheets) == null ? void 0 : _b2.length) {
|
|
5581
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5582
|
+
doc2.adoptedStyleSheets,
|
|
5583
|
+
onAdoptedStyleSheet,
|
|
5584
|
+
emittedStyleIds
|
|
5585
|
+
);
|
|
5586
|
+
}
|
|
5545
5587
|
}
|
|
5546
5588
|
if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
|
|
5547
5589
|
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
|
|
@@ -5567,6 +5609,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
5567
5609
|
recordCanvas,
|
|
5568
5610
|
preserveWhiteSpace,
|
|
5569
5611
|
onSerialize,
|
|
5612
|
+
onAdoptedStyleSheet,
|
|
5613
|
+
_emittedStyleIds: emittedStyleIds,
|
|
5570
5614
|
onIframeLoad,
|
|
5571
5615
|
iframeLoadTimeout,
|
|
5572
5616
|
onStylesheetLoad,
|
|
@@ -5628,6 +5672,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5628
5672
|
recordCanvas,
|
|
5629
5673
|
preserveWhiteSpace,
|
|
5630
5674
|
onSerialize,
|
|
5675
|
+
onAdoptedStyleSheet,
|
|
5631
5676
|
onIframeLoad,
|
|
5632
5677
|
iframeLoadTimeout,
|
|
5633
5678
|
onStylesheetLoad,
|
|
@@ -5707,6 +5752,7 @@ function snapshot(n2, options) {
|
|
|
5707
5752
|
dataURLOptions,
|
|
5708
5753
|
preserveWhiteSpace,
|
|
5709
5754
|
onSerialize,
|
|
5755
|
+
onAdoptedStyleSheet,
|
|
5710
5756
|
onIframeLoad,
|
|
5711
5757
|
iframeLoadTimeout,
|
|
5712
5758
|
onStylesheetLoad,
|
|
@@ -5769,6 +5815,7 @@ function snapshot(n2, options) {
|
|
|
5769
5815
|
recordCanvas,
|
|
5770
5816
|
preserveWhiteSpace,
|
|
5771
5817
|
onSerialize,
|
|
5818
|
+
onAdoptedStyleSheet,
|
|
5772
5819
|
onIframeLoad,
|
|
5773
5820
|
iframeLoadTimeout,
|
|
5774
5821
|
onStylesheetLoad,
|
|
@@ -16859,6 +16906,7 @@ class Replayer {
|
|
|
16859
16906
|
__publicField2(this, "lastSelectionData", null);
|
|
16860
16907
|
__publicField2(this, "constructedStyleMutations", []);
|
|
16861
16908
|
__publicField2(this, "adoptedStyleSheets", []);
|
|
16909
|
+
__publicField2(this, "snapshotAdoptedStyleSheetQueue", []);
|
|
16862
16910
|
__publicField2(this, "handleResize", (dimension) => {
|
|
16863
16911
|
this.iframe.style.display = "inherit";
|
|
16864
16912
|
for (const el of [this.mouseTail, this.iframe]) {
|
|
@@ -17138,6 +17186,14 @@ class Replayer {
|
|
|
17138
17186
|
this.applyAdoptedStyleSheet(data);
|
|
17139
17187
|
});
|
|
17140
17188
|
this.adoptedStyleSheets = [];
|
|
17189
|
+
this.snapshotAdoptedStyleSheetQueue.forEach(
|
|
17190
|
+
({ id, adoptedStyleSheets }) => {
|
|
17191
|
+
const node2 = this.mirror.getNode(id);
|
|
17192
|
+
if (node2)
|
|
17193
|
+
this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
|
|
17194
|
+
}
|
|
17195
|
+
);
|
|
17196
|
+
this.snapshotAdoptedStyleSheetQueue = [];
|
|
17141
17197
|
}
|
|
17142
17198
|
if (this.mousePos) {
|
|
17143
17199
|
this.moveAndHover(
|
|
@@ -17511,6 +17567,7 @@ class Replayer {
|
|
|
17511
17567
|
const collectedIframes = [];
|
|
17512
17568
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17513
17569
|
const afterAppend = (builtNode, id) => {
|
|
17570
|
+
var _a22;
|
|
17514
17571
|
if (builtNode.nodeName === "DIALOG")
|
|
17515
17572
|
collectedDialogs.add(builtNode);
|
|
17516
17573
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17522,6 +17579,10 @@ class Replayer {
|
|
|
17522
17579
|
this.mirror
|
|
17523
17580
|
);
|
|
17524
17581
|
}
|
|
17582
|
+
const sn = this.mirror.getMeta(builtNode);
|
|
17583
|
+
if (sn && "adoptedStyleSheets" in sn && ((_a22 = sn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17584
|
+
this.applySnapshotAdoptedStyleSheets(builtNode, sn.adoptedStyleSheets);
|
|
17585
|
+
}
|
|
17525
17586
|
for (const plugin of this.config.plugins || []) {
|
|
17526
17587
|
if (plugin.onBuild)
|
|
17527
17588
|
plugin.onBuild(builtNode, {
|
|
@@ -17638,6 +17699,7 @@ class Replayer {
|
|
|
17638
17699
|
const collectedIframes = [];
|
|
17639
17700
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17640
17701
|
const afterAppend = (builtNode, id) => {
|
|
17702
|
+
var _a22;
|
|
17641
17703
|
if (builtNode.nodeName === "DIALOG")
|
|
17642
17704
|
collectedDialogs.add(builtNode);
|
|
17643
17705
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17650,6 +17712,25 @@ class Replayer {
|
|
|
17650
17712
|
head
|
|
17651
17713
|
);
|
|
17652
17714
|
}
|
|
17715
|
+
{
|
|
17716
|
+
const nodeSn = mirror2.getMeta(
|
|
17717
|
+
builtNode
|
|
17718
|
+
);
|
|
17719
|
+
if (nodeSn && "adoptedStyleSheets" in nodeSn && ((_a22 = nodeSn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17720
|
+
if (this.usingVirtualDom) {
|
|
17721
|
+
const id2 = mirror2.getId(builtNode);
|
|
17722
|
+
this.snapshotAdoptedStyleSheetQueue.push({
|
|
17723
|
+
id: id2,
|
|
17724
|
+
adoptedStyleSheets: nodeSn.adoptedStyleSheets
|
|
17725
|
+
});
|
|
17726
|
+
} else {
|
|
17727
|
+
this.applySnapshotAdoptedStyleSheets(
|
|
17728
|
+
builtNode,
|
|
17729
|
+
nodeSn.adoptedStyleSheets
|
|
17730
|
+
);
|
|
17731
|
+
}
|
|
17732
|
+
}
|
|
17733
|
+
}
|
|
17653
17734
|
if (this.usingVirtualDom) return;
|
|
17654
17735
|
for (const plugin of this.config.plugins || []) {
|
|
17655
17736
|
if (plugin.onBuild)
|
|
@@ -18535,6 +18616,44 @@ class Replayer {
|
|
|
18535
18616
|
rule2.style.removeProperty(data.remove.property);
|
|
18536
18617
|
}
|
|
18537
18618
|
}
|
|
18619
|
+
applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets) {
|
|
18620
|
+
var _a22;
|
|
18621
|
+
let hostWindow = null;
|
|
18622
|
+
if (hasShadowRoot(node2))
|
|
18623
|
+
hostWindow = ((_a22 = node2.ownerDocument) == null ? void 0 : _a22.defaultView) || null;
|
|
18624
|
+
else if (node2.nodeName === "#document")
|
|
18625
|
+
hostWindow = node2.defaultView;
|
|
18626
|
+
if (!hostWindow) return;
|
|
18627
|
+
const sheets = [];
|
|
18628
|
+
for (const { styleId, rules: rules2 } of adoptedStyleSheets) {
|
|
18629
|
+
const existing = this.styleMirror.getStyle(styleId);
|
|
18630
|
+
if (existing) {
|
|
18631
|
+
if (rules2.length) {
|
|
18632
|
+
this.applyStyleSheetRule(
|
|
18633
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18634
|
+
existing
|
|
18635
|
+
);
|
|
18636
|
+
}
|
|
18637
|
+
sheets.push(existing);
|
|
18638
|
+
continue;
|
|
18639
|
+
}
|
|
18640
|
+
try {
|
|
18641
|
+
const sheet = new hostWindow.CSSStyleSheet();
|
|
18642
|
+
this.styleMirror.add(sheet, styleId);
|
|
18643
|
+
if (rules2.length) {
|
|
18644
|
+
this.applyStyleSheetRule(
|
|
18645
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18646
|
+
sheet
|
|
18647
|
+
);
|
|
18648
|
+
}
|
|
18649
|
+
sheets.push(sheet);
|
|
18650
|
+
} catch (e2) {
|
|
18651
|
+
}
|
|
18652
|
+
}
|
|
18653
|
+
if (hasShadowRoot(node2)) node2.shadowRoot.adoptedStyleSheets = sheets;
|
|
18654
|
+
else if (node2.nodeName === "#document")
|
|
18655
|
+
node2.adoptedStyleSheets = sheets;
|
|
18656
|
+
}
|
|
18538
18657
|
applyAdoptedStyleSheet(data) {
|
|
18539
18658
|
var _a22;
|
|
18540
18659
|
const targetHost = this.mirror.getNode(data.id);
|