@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.js
CHANGED
|
@@ -5455,7 +5455,29 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
5455
5455
|
}
|
|
5456
5456
|
return false;
|
|
5457
5457
|
}
|
|
5458
|
+
function serializeAdoptedStyleSheets(sheets, onAdoptedStyleSheet, emittedStyleIds) {
|
|
5459
|
+
return Array.from(sheets).map((sheet) => {
|
|
5460
|
+
const styleId = onAdoptedStyleSheet(sheet);
|
|
5461
|
+
let rules2 = [];
|
|
5462
|
+
if (!emittedStyleIds.has(styleId)) {
|
|
5463
|
+
emittedStyleIds.add(styleId);
|
|
5464
|
+
try {
|
|
5465
|
+
rules2 = Array.from(sheet.cssRules, (rule2, index2) => ({
|
|
5466
|
+
rule: stringifyRule(rule2, sheet.href),
|
|
5467
|
+
index: index2
|
|
5468
|
+
}));
|
|
5469
|
+
} catch (e2) {
|
|
5470
|
+
if (e2 instanceof DOMException && e2.name === "SecurityError") ;
|
|
5471
|
+
else {
|
|
5472
|
+
throw e2;
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
return { styleId, rules: rules2 };
|
|
5477
|
+
});
|
|
5478
|
+
}
|
|
5458
5479
|
function serializeNodeWithId(n2, options) {
|
|
5480
|
+
var _a22, _b2;
|
|
5459
5481
|
const {
|
|
5460
5482
|
doc,
|
|
5461
5483
|
mirror: mirror2,
|
|
@@ -5474,6 +5496,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5474
5496
|
inlineImages = false,
|
|
5475
5497
|
recordCanvas = false,
|
|
5476
5498
|
onSerialize,
|
|
5499
|
+
onAdoptedStyleSheet,
|
|
5477
5500
|
onIframeLoad,
|
|
5478
5501
|
iframeLoadTimeout = 5e3,
|
|
5479
5502
|
onStylesheetLoad,
|
|
@@ -5483,6 +5506,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5483
5506
|
cssCaptured = false,
|
|
5484
5507
|
applyBackgroundColorToBlockedElements = false
|
|
5485
5508
|
} = options;
|
|
5509
|
+
const emittedStyleIds = options._emittedStyleIds ?? /* @__PURE__ */ new Set();
|
|
5486
5510
|
let { needsMask } = options;
|
|
5487
5511
|
let { preserveWhiteSpace = true } = options;
|
|
5488
5512
|
if (!needsMask) {
|
|
@@ -5538,8 +5562,26 @@ function serializeNodeWithId(n2, options) {
|
|
|
5538
5562
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
5539
5563
|
delete serializedNode.needBlock;
|
|
5540
5564
|
const shadowRootEl = index$1.shadowRoot(n2);
|
|
5541
|
-
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
5565
|
+
if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
|
|
5542
5566
|
serializedNode.isShadowHost = true;
|
|
5567
|
+
if (onAdoptedStyleSheet && ((_a22 = shadowRootEl.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
5568
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5569
|
+
shadowRootEl.adoptedStyleSheets,
|
|
5570
|
+
onAdoptedStyleSheet,
|
|
5571
|
+
emittedStyleIds
|
|
5572
|
+
);
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
}
|
|
5576
|
+
if (serializedNode.type === NodeType$3.Document && onAdoptedStyleSheet) {
|
|
5577
|
+
const doc2 = n2;
|
|
5578
|
+
if ((_b2 = doc2.adoptedStyleSheets) == null ? void 0 : _b2.length) {
|
|
5579
|
+
serializedNode.adoptedStyleSheets = serializeAdoptedStyleSheets(
|
|
5580
|
+
doc2.adoptedStyleSheets,
|
|
5581
|
+
onAdoptedStyleSheet,
|
|
5582
|
+
emittedStyleIds
|
|
5583
|
+
);
|
|
5584
|
+
}
|
|
5543
5585
|
}
|
|
5544
5586
|
if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
|
|
5545
5587
|
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
|
|
@@ -5565,6 +5607,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
5565
5607
|
recordCanvas,
|
|
5566
5608
|
preserveWhiteSpace,
|
|
5567
5609
|
onSerialize,
|
|
5610
|
+
onAdoptedStyleSheet,
|
|
5611
|
+
_emittedStyleIds: emittedStyleIds,
|
|
5568
5612
|
onIframeLoad,
|
|
5569
5613
|
iframeLoadTimeout,
|
|
5570
5614
|
onStylesheetLoad,
|
|
@@ -5626,6 +5670,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
5626
5670
|
recordCanvas,
|
|
5627
5671
|
preserveWhiteSpace,
|
|
5628
5672
|
onSerialize,
|
|
5673
|
+
onAdoptedStyleSheet,
|
|
5629
5674
|
onIframeLoad,
|
|
5630
5675
|
iframeLoadTimeout,
|
|
5631
5676
|
onStylesheetLoad,
|
|
@@ -5705,6 +5750,7 @@ function snapshot(n2, options) {
|
|
|
5705
5750
|
dataURLOptions,
|
|
5706
5751
|
preserveWhiteSpace,
|
|
5707
5752
|
onSerialize,
|
|
5753
|
+
onAdoptedStyleSheet,
|
|
5708
5754
|
onIframeLoad,
|
|
5709
5755
|
iframeLoadTimeout,
|
|
5710
5756
|
onStylesheetLoad,
|
|
@@ -5767,6 +5813,7 @@ function snapshot(n2, options) {
|
|
|
5767
5813
|
recordCanvas,
|
|
5768
5814
|
preserveWhiteSpace,
|
|
5769
5815
|
onSerialize,
|
|
5816
|
+
onAdoptedStyleSheet,
|
|
5770
5817
|
onIframeLoad,
|
|
5771
5818
|
iframeLoadTimeout,
|
|
5772
5819
|
onStylesheetLoad,
|
|
@@ -16857,6 +16904,7 @@ class Replayer {
|
|
|
16857
16904
|
__publicField2(this, "lastSelectionData", null);
|
|
16858
16905
|
__publicField2(this, "constructedStyleMutations", []);
|
|
16859
16906
|
__publicField2(this, "adoptedStyleSheets", []);
|
|
16907
|
+
__publicField2(this, "snapshotAdoptedStyleSheetQueue", []);
|
|
16860
16908
|
__publicField2(this, "handleResize", (dimension) => {
|
|
16861
16909
|
this.iframe.style.display = "inherit";
|
|
16862
16910
|
for (const el of [this.mouseTail, this.iframe]) {
|
|
@@ -17136,6 +17184,14 @@ class Replayer {
|
|
|
17136
17184
|
this.applyAdoptedStyleSheet(data);
|
|
17137
17185
|
});
|
|
17138
17186
|
this.adoptedStyleSheets = [];
|
|
17187
|
+
this.snapshotAdoptedStyleSheetQueue.forEach(
|
|
17188
|
+
({ id, adoptedStyleSheets }) => {
|
|
17189
|
+
const node2 = this.mirror.getNode(id);
|
|
17190
|
+
if (node2)
|
|
17191
|
+
this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
|
|
17192
|
+
}
|
|
17193
|
+
);
|
|
17194
|
+
this.snapshotAdoptedStyleSheetQueue = [];
|
|
17139
17195
|
}
|
|
17140
17196
|
if (this.mousePos) {
|
|
17141
17197
|
this.moveAndHover(
|
|
@@ -17509,6 +17565,7 @@ class Replayer {
|
|
|
17509
17565
|
const collectedIframes = [];
|
|
17510
17566
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17511
17567
|
const afterAppend = (builtNode, id) => {
|
|
17568
|
+
var _a22;
|
|
17512
17569
|
if (builtNode.nodeName === "DIALOG")
|
|
17513
17570
|
collectedDialogs.add(builtNode);
|
|
17514
17571
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17520,6 +17577,10 @@ class Replayer {
|
|
|
17520
17577
|
this.mirror
|
|
17521
17578
|
);
|
|
17522
17579
|
}
|
|
17580
|
+
const sn = this.mirror.getMeta(builtNode);
|
|
17581
|
+
if (sn && "adoptedStyleSheets" in sn && ((_a22 = sn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17582
|
+
this.applySnapshotAdoptedStyleSheets(builtNode, sn.adoptedStyleSheets);
|
|
17583
|
+
}
|
|
17523
17584
|
for (const plugin of this.config.plugins || []) {
|
|
17524
17585
|
if (plugin.onBuild)
|
|
17525
17586
|
plugin.onBuild(builtNode, {
|
|
@@ -17636,6 +17697,7 @@ class Replayer {
|
|
|
17636
17697
|
const collectedIframes = [];
|
|
17637
17698
|
const collectedDialogs = /* @__PURE__ */ new Set();
|
|
17638
17699
|
const afterAppend = (builtNode, id) => {
|
|
17700
|
+
var _a22;
|
|
17639
17701
|
if (builtNode.nodeName === "DIALOG")
|
|
17640
17702
|
collectedDialogs.add(builtNode);
|
|
17641
17703
|
this.collectIframeAndAttachDocument(collectedIframes, builtNode);
|
|
@@ -17648,6 +17710,25 @@ class Replayer {
|
|
|
17648
17710
|
head
|
|
17649
17711
|
);
|
|
17650
17712
|
}
|
|
17713
|
+
{
|
|
17714
|
+
const nodeSn = mirror2.getMeta(
|
|
17715
|
+
builtNode
|
|
17716
|
+
);
|
|
17717
|
+
if (nodeSn && "adoptedStyleSheets" in nodeSn && ((_a22 = nodeSn.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
|
|
17718
|
+
if (this.usingVirtualDom) {
|
|
17719
|
+
const id2 = mirror2.getId(builtNode);
|
|
17720
|
+
this.snapshotAdoptedStyleSheetQueue.push({
|
|
17721
|
+
id: id2,
|
|
17722
|
+
adoptedStyleSheets: nodeSn.adoptedStyleSheets
|
|
17723
|
+
});
|
|
17724
|
+
} else {
|
|
17725
|
+
this.applySnapshotAdoptedStyleSheets(
|
|
17726
|
+
builtNode,
|
|
17727
|
+
nodeSn.adoptedStyleSheets
|
|
17728
|
+
);
|
|
17729
|
+
}
|
|
17730
|
+
}
|
|
17731
|
+
}
|
|
17651
17732
|
if (this.usingVirtualDom) return;
|
|
17652
17733
|
for (const plugin of this.config.plugins || []) {
|
|
17653
17734
|
if (plugin.onBuild)
|
|
@@ -18533,6 +18614,44 @@ class Replayer {
|
|
|
18533
18614
|
rule2.style.removeProperty(data.remove.property);
|
|
18534
18615
|
}
|
|
18535
18616
|
}
|
|
18617
|
+
applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets) {
|
|
18618
|
+
var _a22;
|
|
18619
|
+
let hostWindow = null;
|
|
18620
|
+
if (hasShadowRoot(node2))
|
|
18621
|
+
hostWindow = ((_a22 = node2.ownerDocument) == null ? void 0 : _a22.defaultView) || null;
|
|
18622
|
+
else if (node2.nodeName === "#document")
|
|
18623
|
+
hostWindow = node2.defaultView;
|
|
18624
|
+
if (!hostWindow) return;
|
|
18625
|
+
const sheets = [];
|
|
18626
|
+
for (const { styleId, rules: rules2 } of adoptedStyleSheets) {
|
|
18627
|
+
const existing = this.styleMirror.getStyle(styleId);
|
|
18628
|
+
if (existing) {
|
|
18629
|
+
if (rules2.length) {
|
|
18630
|
+
this.applyStyleSheetRule(
|
|
18631
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18632
|
+
existing
|
|
18633
|
+
);
|
|
18634
|
+
}
|
|
18635
|
+
sheets.push(existing);
|
|
18636
|
+
continue;
|
|
18637
|
+
}
|
|
18638
|
+
try {
|
|
18639
|
+
const sheet = new hostWindow.CSSStyleSheet();
|
|
18640
|
+
this.styleMirror.add(sheet, styleId);
|
|
18641
|
+
if (rules2.length) {
|
|
18642
|
+
this.applyStyleSheetRule(
|
|
18643
|
+
{ source: IncrementalSource.StyleSheetRule, adds: rules2 },
|
|
18644
|
+
sheet
|
|
18645
|
+
);
|
|
18646
|
+
}
|
|
18647
|
+
sheets.push(sheet);
|
|
18648
|
+
} catch (e2) {
|
|
18649
|
+
}
|
|
18650
|
+
}
|
|
18651
|
+
if (hasShadowRoot(node2)) node2.shadowRoot.adoptedStyleSheets = sheets;
|
|
18652
|
+
else if (node2.nodeName === "#document")
|
|
18653
|
+
node2.adoptedStyleSheets = sheets;
|
|
18654
|
+
}
|
|
18536
18655
|
applyAdoptedStyleSheet(data) {
|
|
18537
18656
|
var _a22;
|
|
18538
18657
|
const targetHost = this.mirror.getNode(data.id);
|