@posthog/rrweb-player 0.0.37 → 0.0.38

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.
@@ -432,7 +432,182 @@ var NodeType$1$1 = /* @__PURE__ */ ((NodeType2) => {
432
432
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
433
433
  return NodeType2;
434
434
  })(NodeType$1$1 || {});
435
- function isElement(n2) {
435
+ const testableAccessors$2 = {
436
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
437
+ ShadowRoot: ["host", "styleSheets"],
438
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
439
+ MutationObserver: []
440
+ };
441
+ const testableMethods$2 = {
442
+ Node: ["contains", "getRootNode"],
443
+ ShadowRoot: ["getSelection"],
444
+ Element: [],
445
+ MutationObserver: ["constructor"]
446
+ };
447
+ const untaintedBasePrototype$2 = {};
448
+ function angularZoneUnpatchedAlternative$2(key) {
449
+ var _a2, _b2;
450
+ const angularUnpatchedVersionSymbol = (_b2 = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b2.call(_a2, key);
451
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
452
+ return globalThis[angularUnpatchedVersionSymbol];
453
+ } else {
454
+ return void 0;
455
+ }
456
+ }
457
+ function getUntaintedPrototype$2(key) {
458
+ if (untaintedBasePrototype$2[key])
459
+ return untaintedBasePrototype$2[key];
460
+ const candidate = angularZoneUnpatchedAlternative$2(key) || globalThis[key];
461
+ const defaultPrototype = candidate.prototype;
462
+ const accessorNames = key in testableAccessors$2 ? testableAccessors$2[key] : void 0;
463
+ const isUntaintedAccessors = Boolean(
464
+ accessorNames && // @ts-expect-error 2345
465
+ accessorNames.every(
466
+ (accessor) => {
467
+ var _a2, _b2;
468
+ return Boolean(
469
+ (_b2 = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b2.toString().includes("[native code]")
470
+ );
471
+ }
472
+ )
473
+ );
474
+ const methodNames = key in testableMethods$2 ? testableMethods$2[key] : void 0;
475
+ const isUntaintedMethods = Boolean(
476
+ methodNames && methodNames.every(
477
+ // @ts-expect-error 2345
478
+ (method) => {
479
+ var _a2;
480
+ return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
481
+ }
482
+ )
483
+ );
484
+ if (isUntaintedAccessors && isUntaintedMethods) {
485
+ untaintedBasePrototype$2[key] = candidate.prototype;
486
+ return candidate.prototype;
487
+ }
488
+ try {
489
+ const iframeEl = document.createElement("iframe");
490
+ document.body.appendChild(iframeEl);
491
+ const win = iframeEl.contentWindow;
492
+ if (!win) return candidate.prototype;
493
+ const untaintedObject = win[key].prototype;
494
+ document.body.removeChild(iframeEl);
495
+ if (!untaintedObject) return defaultPrototype;
496
+ return untaintedBasePrototype$2[key] = untaintedObject;
497
+ } catch (e2) {
498
+ return defaultPrototype;
499
+ }
500
+ }
501
+ const untaintedAccessorCache$2 = {};
502
+ function getUntaintedAccessor$2(key, instance2, accessor) {
503
+ var _a2;
504
+ const cacheKey = `${key}.${String(accessor)}`;
505
+ if (untaintedAccessorCache$2[cacheKey])
506
+ return untaintedAccessorCache$2[cacheKey].call(
507
+ instance2
508
+ );
509
+ const untaintedPrototype = getUntaintedPrototype$2(key);
510
+ const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
511
+ untaintedPrototype,
512
+ accessor
513
+ )) == null ? void 0 : _a2.get;
514
+ if (!untaintedAccessor) return instance2[accessor];
515
+ untaintedAccessorCache$2[cacheKey] = untaintedAccessor;
516
+ return untaintedAccessor.call(instance2);
517
+ }
518
+ const untaintedMethodCache$2 = {};
519
+ function getUntaintedMethod$2(key, instance2, method) {
520
+ const cacheKey = `${key}.${String(method)}`;
521
+ if (untaintedMethodCache$2[cacheKey])
522
+ return untaintedMethodCache$2[cacheKey].bind(
523
+ instance2
524
+ );
525
+ const untaintedPrototype = getUntaintedPrototype$2(key);
526
+ const untaintedMethod = untaintedPrototype[method];
527
+ if (typeof untaintedMethod !== "function") return instance2[method];
528
+ untaintedMethodCache$2[cacheKey] = untaintedMethod;
529
+ return untaintedMethod.bind(instance2);
530
+ }
531
+ function childNodes$2(n2) {
532
+ return getUntaintedAccessor$2("Node", n2, "childNodes");
533
+ }
534
+ function parentNode$2(n2) {
535
+ return getUntaintedAccessor$2("Node", n2, "parentNode");
536
+ }
537
+ function parentElement$2(n2) {
538
+ return getUntaintedAccessor$2("Node", n2, "parentElement");
539
+ }
540
+ function textContent$2(n2) {
541
+ return getUntaintedAccessor$2("Node", n2, "textContent");
542
+ }
543
+ function contains$2(n2, other) {
544
+ return getUntaintedMethod$2("Node", n2, "contains")(other);
545
+ }
546
+ function getRootNode$2(n2) {
547
+ return getUntaintedMethod$2("Node", n2, "getRootNode")();
548
+ }
549
+ function host$2(n2) {
550
+ if (!n2 || !("host" in n2)) return null;
551
+ return getUntaintedAccessor$2("ShadowRoot", n2, "host");
552
+ }
553
+ function styleSheets$2(n2) {
554
+ return n2.styleSheets;
555
+ }
556
+ function shadowRoot$2(n2) {
557
+ if (!n2 || !("shadowRoot" in n2)) return null;
558
+ return getUntaintedAccessor$2("Element", n2, "shadowRoot");
559
+ }
560
+ function querySelector$2(n2, selectors) {
561
+ return getUntaintedAccessor$2("Element", n2, "querySelector")(selectors);
562
+ }
563
+ function querySelectorAll$2(n2, selectors) {
564
+ return getUntaintedAccessor$2("Element", n2, "querySelectorAll")(selectors);
565
+ }
566
+ function mutationObserverCtor$2() {
567
+ return getUntaintedPrototype$2("MutationObserver").constructor;
568
+ }
569
+ function patch$2(source, name, replacement) {
570
+ try {
571
+ if (!(name in source)) {
572
+ return () => {
573
+ };
574
+ }
575
+ const original = source[name];
576
+ const wrapped = replacement(original);
577
+ if (typeof wrapped === "function") {
578
+ wrapped.prototype = wrapped.prototype || {};
579
+ Object.defineProperties(wrapped, {
580
+ __rrweb_original__: {
581
+ enumerable: false,
582
+ value: original
583
+ }
584
+ });
585
+ }
586
+ source[name] = wrapped;
587
+ return () => {
588
+ source[name] = original;
589
+ };
590
+ } catch (e2) {
591
+ return () => {
592
+ };
593
+ }
594
+ }
595
+ const index$2 = {
596
+ childNodes: childNodes$2,
597
+ parentNode: parentNode$2,
598
+ parentElement: parentElement$2,
599
+ textContent: textContent$2,
600
+ contains: contains$2,
601
+ getRootNode: getRootNode$2,
602
+ host: host$2,
603
+ styleSheets: styleSheets$2,
604
+ shadowRoot: shadowRoot$2,
605
+ querySelector: querySelector$2,
606
+ querySelectorAll: querySelectorAll$2,
607
+ mutationObserver: mutationObserverCtor$2,
608
+ patch: patch$2
609
+ };
610
+ function isElement$1(n2) {
436
611
  return n2.nodeType === n2.ELEMENT_NODE;
437
612
  }
438
613
  class Mirror {
@@ -465,6 +640,17 @@ class Mirror {
465
640
  (childNode) => this.removeNodeFromMap(childNode)
466
641
  );
467
642
  }
643
+ if (isElement$1(n2)) {
644
+ const shadowRootEl = index$2.shadowRoot(n2);
645
+ if (shadowRootEl) {
646
+ this.removeNodeFromMap(shadowRootEl);
647
+ }
648
+ if (n2.nodeName === "IFRAME" && n2.contentDocument) {
649
+ this.removeNodeFromMap(
650
+ n2.contentDocument
651
+ );
652
+ }
653
+ }
468
654
  }
469
655
  has(id) {
470
656
  return this.idNodeMap.has(id);
@@ -4797,7 +4983,7 @@ function buildNodeWithSN(n2, options) {
4797
4983
  console.warn("Failed to rebuild", childN);
4798
4984
  continue;
4799
4985
  }
4800
- if (childN.isShadow && isElement(node2) && node2.shadowRoot) {
4986
+ if (childN.isShadow && isElement$1(node2) && node2.shadowRoot) {
4801
4987
  node2.shadowRoot.appendChild(childNode);
4802
4988
  } else if (n2.type === NodeType$1$1.Document && childN.type == NodeType$1$1.Element) {
4803
4989
  const htmlElement = childNode;
@@ -4888,6 +5074,184 @@ var __publicField22 = (obj, key, value) => __defNormalProp222(obj, typeof key !=
4888
5074
  var __defProp2222 = Object.defineProperty;
4889
5075
  var __defNormalProp2222 = (obj, key, value) => key in obj ? __defProp2222(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4890
5076
  var __publicField222 = (obj, key, value) => __defNormalProp2222(obj, typeof key !== "symbol" ? key + "" : key, value);
5077
+ const testableAccessors$1 = {
5078
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
5079
+ ShadowRoot: ["host", "styleSheets"],
5080
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
5081
+ MutationObserver: []
5082
+ };
5083
+ const testableMethods$1 = {
5084
+ Node: ["contains", "getRootNode"],
5085
+ ShadowRoot: ["getSelection"],
5086
+ Element: [],
5087
+ MutationObserver: ["constructor"]
5088
+ };
5089
+ const untaintedBasePrototype$1 = {};
5090
+ function angularZoneUnpatchedAlternative$1(key) {
5091
+ var _a2, _b2;
5092
+ const angularUnpatchedVersionSymbol = (_b2 = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b2.call(_a2, key);
5093
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
5094
+ return globalThis[angularUnpatchedVersionSymbol];
5095
+ } else {
5096
+ return void 0;
5097
+ }
5098
+ }
5099
+ function getUntaintedPrototype$1(key) {
5100
+ if (untaintedBasePrototype$1[key])
5101
+ return untaintedBasePrototype$1[key];
5102
+ const candidate = angularZoneUnpatchedAlternative$1(key) || globalThis[key];
5103
+ const defaultPrototype = candidate.prototype;
5104
+ const accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
5105
+ const isUntaintedAccessors = Boolean(
5106
+ accessorNames && // @ts-expect-error 2345
5107
+ accessorNames.every(
5108
+ (accessor) => {
5109
+ var _a2, _b2;
5110
+ return Boolean(
5111
+ (_b2 = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b2.toString().includes("[native code]")
5112
+ );
5113
+ }
5114
+ )
5115
+ );
5116
+ const methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
5117
+ const isUntaintedMethods = Boolean(
5118
+ methodNames && methodNames.every(
5119
+ // @ts-expect-error 2345
5120
+ (method) => {
5121
+ var _a2;
5122
+ return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
5123
+ }
5124
+ )
5125
+ );
5126
+ if (isUntaintedAccessors && isUntaintedMethods) {
5127
+ untaintedBasePrototype$1[key] = candidate.prototype;
5128
+ return candidate.prototype;
5129
+ }
5130
+ try {
5131
+ const iframeEl = document.createElement("iframe");
5132
+ document.body.appendChild(iframeEl);
5133
+ const win = iframeEl.contentWindow;
5134
+ if (!win) return candidate.prototype;
5135
+ const untaintedObject = win[key].prototype;
5136
+ document.body.removeChild(iframeEl);
5137
+ if (!untaintedObject) return defaultPrototype;
5138
+ return untaintedBasePrototype$1[key] = untaintedObject;
5139
+ } catch (e2) {
5140
+ return defaultPrototype;
5141
+ }
5142
+ }
5143
+ const untaintedAccessorCache$1 = {};
5144
+ function getUntaintedAccessor$1(key, instance2, accessor) {
5145
+ var _a2;
5146
+ const cacheKey = `${key}.${String(accessor)}`;
5147
+ if (untaintedAccessorCache$1[cacheKey])
5148
+ return untaintedAccessorCache$1[cacheKey].call(
5149
+ instance2
5150
+ );
5151
+ const untaintedPrototype = getUntaintedPrototype$1(key);
5152
+ const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
5153
+ untaintedPrototype,
5154
+ accessor
5155
+ )) == null ? void 0 : _a2.get;
5156
+ if (!untaintedAccessor) return instance2[accessor];
5157
+ untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
5158
+ return untaintedAccessor.call(instance2);
5159
+ }
5160
+ const untaintedMethodCache$1 = {};
5161
+ function getUntaintedMethod$1(key, instance2, method) {
5162
+ const cacheKey = `${key}.${String(method)}`;
5163
+ if (untaintedMethodCache$1[cacheKey])
5164
+ return untaintedMethodCache$1[cacheKey].bind(
5165
+ instance2
5166
+ );
5167
+ const untaintedPrototype = getUntaintedPrototype$1(key);
5168
+ const untaintedMethod = untaintedPrototype[method];
5169
+ if (typeof untaintedMethod !== "function") return instance2[method];
5170
+ untaintedMethodCache$1[cacheKey] = untaintedMethod;
5171
+ return untaintedMethod.bind(instance2);
5172
+ }
5173
+ function childNodes$1(n2) {
5174
+ return getUntaintedAccessor$1("Node", n2, "childNodes");
5175
+ }
5176
+ function parentNode$1(n2) {
5177
+ return getUntaintedAccessor$1("Node", n2, "parentNode");
5178
+ }
5179
+ function parentElement$1(n2) {
5180
+ return getUntaintedAccessor$1("Node", n2, "parentElement");
5181
+ }
5182
+ function textContent$1(n2) {
5183
+ return getUntaintedAccessor$1("Node", n2, "textContent");
5184
+ }
5185
+ function contains$1(n2, other) {
5186
+ return getUntaintedMethod$1("Node", n2, "contains")(other);
5187
+ }
5188
+ function getRootNode$1(n2) {
5189
+ return getUntaintedMethod$1("Node", n2, "getRootNode")();
5190
+ }
5191
+ function host$1(n2) {
5192
+ if (!n2 || !("host" in n2)) return null;
5193
+ return getUntaintedAccessor$1("ShadowRoot", n2, "host");
5194
+ }
5195
+ function styleSheets$1(n2) {
5196
+ return n2.styleSheets;
5197
+ }
5198
+ function shadowRoot$1(n2) {
5199
+ if (!n2 || !("shadowRoot" in n2)) return null;
5200
+ return getUntaintedAccessor$1("Element", n2, "shadowRoot");
5201
+ }
5202
+ function querySelector$1(n2, selectors) {
5203
+ return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
5204
+ }
5205
+ function querySelectorAll$1(n2, selectors) {
5206
+ return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
5207
+ }
5208
+ function mutationObserverCtor$1() {
5209
+ return getUntaintedPrototype$1("MutationObserver").constructor;
5210
+ }
5211
+ function patch$1(source, name, replacement) {
5212
+ try {
5213
+ if (!(name in source)) {
5214
+ return () => {
5215
+ };
5216
+ }
5217
+ const original = source[name];
5218
+ const wrapped = replacement(original);
5219
+ if (typeof wrapped === "function") {
5220
+ wrapped.prototype = wrapped.prototype || {};
5221
+ Object.defineProperties(wrapped, {
5222
+ __rrweb_original__: {
5223
+ enumerable: false,
5224
+ value: original
5225
+ }
5226
+ });
5227
+ }
5228
+ source[name] = wrapped;
5229
+ return () => {
5230
+ source[name] = original;
5231
+ };
5232
+ } catch (e2) {
5233
+ return () => {
5234
+ };
5235
+ }
5236
+ }
5237
+ const index$1 = {
5238
+ childNodes: childNodes$1,
5239
+ parentNode: parentNode$1,
5240
+ parentElement: parentElement$1,
5241
+ textContent: textContent$1,
5242
+ contains: contains$1,
5243
+ getRootNode: getRootNode$1,
5244
+ host: host$1,
5245
+ styleSheets: styleSheets$1,
5246
+ shadowRoot: shadowRoot$1,
5247
+ querySelector: querySelector$1,
5248
+ querySelectorAll: querySelectorAll$1,
5249
+ mutationObserver: mutationObserverCtor$1,
5250
+ patch: patch$1
5251
+ };
5252
+ function isElement(n2) {
5253
+ return n2.nodeType === n2.ELEMENT_NODE;
5254
+ }
4891
5255
  let Mirror$1 = class Mirror2 {
4892
5256
  constructor() {
4893
5257
  __publicField222(this, "idNodeMap", /* @__PURE__ */ new Map());
@@ -4918,6 +5282,17 @@ let Mirror$1 = class Mirror2 {
4918
5282
  (childNode) => this.removeNodeFromMap(childNode)
4919
5283
  );
4920
5284
  }
5285
+ if (isElement(n2)) {
5286
+ const shadowRootEl = index$1.shadowRoot(n2);
5287
+ if (shadowRootEl) {
5288
+ this.removeNodeFromMap(shadowRootEl);
5289
+ }
5290
+ if (n2.nodeName === "IFRAME" && n2.contentDocument) {
5291
+ this.removeNodeFromMap(
5292
+ n2.contentDocument
5293
+ );
5294
+ }
5295
+ }
4921
5296
  }
4922
5297
  has(id) {
4923
5298
  return this.idNodeMap.has(id);