@amplitude/rrweb-player 2.1.4 → 2.1.6

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.
@@ -5558,8 +5558,10 @@ function serializeNodeWithId(n2, options) {
5558
5558
  onSerialize(n2);
5559
5559
  }
5560
5560
  let recordChild = !skipChild;
5561
+ let isBlockedElement = false;
5561
5562
  if (serializedNode.type === NodeType$3.Element) {
5562
- recordChild = recordChild && !serializedNode.needBlock;
5563
+ isBlockedElement = Boolean(serializedNode.needBlock);
5564
+ recordChild = recordChild && !isBlockedElement;
5563
5565
  delete serializedNode.needBlock;
5564
5566
  const shadowRootEl = index$1.shadowRoot(n2);
5565
5567
  if (shadowRootEl && isNativeShadowDom(shadowRootEl)) {
@@ -5644,7 +5646,7 @@ function serializeNodeWithId(n2, options) {
5644
5646
  if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
5645
5647
  serializedNode.isShadow = true;
5646
5648
  }
5647
- if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
5649
+ if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe" && !isBlockedElement) {
5648
5650
  onceIframeLoaded(
5649
5651
  n2,
5650
5652
  () => {
@@ -5671,6 +5673,7 @@ function serializeNodeWithId(n2, options) {
5671
5673
  preserveWhiteSpace,
5672
5674
  onSerialize,
5673
5675
  onAdoptedStyleSheet,
5676
+ _emittedStyleIds: emittedStyleIds,
5674
5677
  onIframeLoad,
5675
5678
  iframeLoadTimeout,
5676
5679
  onStylesheetLoad,
@@ -5751,6 +5754,7 @@ function snapshot(n2, options) {
5751
5754
  preserveWhiteSpace,
5752
5755
  onSerialize,
5753
5756
  onAdoptedStyleSheet,
5757
+ _emittedStyleIds,
5754
5758
  onIframeLoad,
5755
5759
  iframeLoadTimeout,
5756
5760
  onStylesheetLoad,
@@ -5814,6 +5818,7 @@ function snapshot(n2, options) {
5814
5818
  preserveWhiteSpace,
5815
5819
  onSerialize,
5816
5820
  onAdoptedStyleSheet,
5821
+ _emittedStyleIds,
5817
5822
  onIframeLoad,
5818
5823
  iframeLoadTimeout,
5819
5824
  onStylesheetLoad,
@@ -17360,9 +17365,7 @@ class Replayer {
17360
17365
  this.adoptedStyleSheets = [];
17361
17366
  this.snapshotAdoptedStyleSheetQueue.forEach(
17362
17367
  ({ id, adoptedStyleSheets }) => {
17363
- const node2 = this.mirror.getNode(id);
17364
- if (node2)
17365
- this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
17368
+ this.applyQueuedSnapshotAdoptedStyleSheets(id, adoptedStyleSheets);
17366
17369
  }
17367
17370
  );
17368
17371
  this.snapshotAdoptedStyleSheetQueue = [];
@@ -18414,8 +18417,22 @@ class Replayer {
18414
18417
  return;
18415
18418
  }
18416
18419
  const afterAppend = (node2, id) => {
18420
+ const inlineAdoptedStyleSheets = this.inlineAdoptedStyleSheetsFromMutationNode(mutation.node, node2);
18421
+ if (inlineAdoptedStyleSheets && this.usingVirtualDom) {
18422
+ this.snapshotAdoptedStyleSheetQueue.push({
18423
+ id,
18424
+ adoptedStyleSheets: inlineAdoptedStyleSheets
18425
+ });
18426
+ }
18417
18427
  if (this.usingVirtualDom) return;
18418
18428
  applyDialogToTopLevel(node2);
18429
+ if (inlineAdoptedStyleSheets) {
18430
+ this.ensureShadowHostForInlineAdoptedStyles(mutation.node, node2);
18431
+ this.applySnapshotAdoptedStyleSheets(
18432
+ node2,
18433
+ inlineAdoptedStyleSheets
18434
+ );
18435
+ }
18419
18436
  for (const plugin of this.config.plugins || []) {
18420
18437
  if (plugin.onBuild) plugin.onBuild(node2, { id, replayer: this });
18421
18438
  }
@@ -18533,6 +18550,22 @@ class Replayer {
18533
18550
  }
18534
18551
  }
18535
18552
  if (queue.length === pendingCount) {
18553
+ const queuedIds = new Set(queue.map((m) => m.node.id));
18554
+ let salvaged = 0;
18555
+ for (let i2 = 0; i2 < queue.length; i2++) {
18556
+ const m = queue[i2];
18557
+ if (!mirror2.getNode(m.node.id) && mirror2.getNode(m.parentId) && m.nextId !== null && m.nextId !== void 0 && m.nextId !== -1 && !mirror2.getNode(m.nextId) && !queuedIds.has(m.nextId)) {
18558
+ queue[i2] = { ...m, nextId: null };
18559
+ salvaged++;
18560
+ }
18561
+ }
18562
+ if (salvaged) {
18563
+ this.warn(
18564
+ "Inserting nodes without their next sibling since it was never recorded",
18565
+ salvaged
18566
+ );
18567
+ continue;
18568
+ }
18536
18569
  this.warn(
18537
18570
  "Dropping the resolve queue since none of the remaining nodes can be resolved",
18538
18571
  resolveTrees.map((tree) => ({
@@ -18803,6 +18836,39 @@ class Replayer {
18803
18836
  rule2.style.removeProperty(data.remove.property);
18804
18837
  }
18805
18838
  }
18839
+ applyQueuedSnapshotAdoptedStyleSheets(id, adoptedStyleSheets) {
18840
+ const node2 = this.mirror.getNode(id);
18841
+ if (!node2) return;
18842
+ const meta = this.mirror.getMeta(node2);
18843
+ if ((meta == null ? void 0 : meta.type) === NodeType.Element && meta.isShadowHost && node2.nodeType === Node.ELEMENT_NODE && !hasShadowRoot(node2)) {
18844
+ node2.attachShadow({ mode: "open" });
18845
+ }
18846
+ this.applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets);
18847
+ }
18848
+ inlineAdoptedStyleSheetsFromMutationNode(mutationNode, builtNode) {
18849
+ var _a22;
18850
+ if (!("adoptedStyleSheets" in mutationNode) || !((_a22 = mutationNode.adoptedStyleSheets) == null ? void 0 : _a22.length)) {
18851
+ return null;
18852
+ }
18853
+ if (mutationNode.type === NodeType.Document) {
18854
+ return mutationNode.adoptedStyleSheets;
18855
+ }
18856
+ if (mutationNode.type === NodeType.Element && mutationNode.isShadowHost) {
18857
+ return mutationNode.adoptedStyleSheets;
18858
+ }
18859
+ if (hasShadowRoot(builtNode)) {
18860
+ return mutationNode.adoptedStyleSheets;
18861
+ }
18862
+ return null;
18863
+ }
18864
+ ensureShadowHostForInlineAdoptedStyles(mutationNode, builtNode) {
18865
+ if (mutationNode.type !== NodeType.Element || !mutationNode.isShadowHost) {
18866
+ return;
18867
+ }
18868
+ const el = builtNode;
18869
+ if (el.nodeType !== Node.ELEMENT_NODE || hasShadowRoot(el)) return;
18870
+ el.attachShadow({ mode: "open" });
18871
+ }
18806
18872
  applySnapshotAdoptedStyleSheets(node2, adoptedStyleSheets) {
18807
18873
  var _a22;
18808
18874
  let hostWindow = null;