@posthog/rrweb-player 0.0.37 → 0.0.39

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.
@@ -414,7 +414,182 @@ var NodeType$1$1 = /* @__PURE__ */ ((NodeType2) => {
414
414
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
415
415
  return NodeType2;
416
416
  })(NodeType$1$1 || {});
417
- function isElement(n2) {
417
+ const testableAccessors$2 = {
418
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
419
+ ShadowRoot: ["host", "styleSheets"],
420
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
421
+ MutationObserver: []
422
+ };
423
+ const testableMethods$2 = {
424
+ Node: ["contains", "getRootNode"],
425
+ ShadowRoot: ["getSelection"],
426
+ Element: [],
427
+ MutationObserver: ["constructor"]
428
+ };
429
+ const untaintedBasePrototype$2 = {};
430
+ function angularZoneUnpatchedAlternative$2(key) {
431
+ var _a2, _b2;
432
+ const angularUnpatchedVersionSymbol = (_b2 = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b2.call(_a2, key);
433
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
434
+ return globalThis[angularUnpatchedVersionSymbol];
435
+ } else {
436
+ return void 0;
437
+ }
438
+ }
439
+ function getUntaintedPrototype$2(key) {
440
+ if (untaintedBasePrototype$2[key])
441
+ return untaintedBasePrototype$2[key];
442
+ const candidate = angularZoneUnpatchedAlternative$2(key) || globalThis[key];
443
+ const defaultPrototype = candidate.prototype;
444
+ const accessorNames = key in testableAccessors$2 ? testableAccessors$2[key] : void 0;
445
+ const isUntaintedAccessors = Boolean(
446
+ accessorNames && // @ts-expect-error 2345
447
+ accessorNames.every(
448
+ (accessor) => {
449
+ var _a2, _b2;
450
+ return Boolean(
451
+ (_b2 = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b2.toString().includes("[native code]")
452
+ );
453
+ }
454
+ )
455
+ );
456
+ const methodNames = key in testableMethods$2 ? testableMethods$2[key] : void 0;
457
+ const isUntaintedMethods = Boolean(
458
+ methodNames && methodNames.every(
459
+ // @ts-expect-error 2345
460
+ (method) => {
461
+ var _a2;
462
+ return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
463
+ }
464
+ )
465
+ );
466
+ if (isUntaintedAccessors && isUntaintedMethods) {
467
+ untaintedBasePrototype$2[key] = candidate.prototype;
468
+ return candidate.prototype;
469
+ }
470
+ try {
471
+ const iframeEl = document.createElement("iframe");
472
+ document.body.appendChild(iframeEl);
473
+ const win = iframeEl.contentWindow;
474
+ if (!win) return candidate.prototype;
475
+ const untaintedObject = win[key].prototype;
476
+ document.body.removeChild(iframeEl);
477
+ if (!untaintedObject) return defaultPrototype;
478
+ return untaintedBasePrototype$2[key] = untaintedObject;
479
+ } catch {
480
+ return defaultPrototype;
481
+ }
482
+ }
483
+ const untaintedAccessorCache$2 = {};
484
+ function getUntaintedAccessor$2(key, instance2, accessor) {
485
+ var _a2;
486
+ const cacheKey = `${key}.${String(accessor)}`;
487
+ if (untaintedAccessorCache$2[cacheKey])
488
+ return untaintedAccessorCache$2[cacheKey].call(
489
+ instance2
490
+ );
491
+ const untaintedPrototype = getUntaintedPrototype$2(key);
492
+ const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
493
+ untaintedPrototype,
494
+ accessor
495
+ )) == null ? void 0 : _a2.get;
496
+ if (!untaintedAccessor) return instance2[accessor];
497
+ untaintedAccessorCache$2[cacheKey] = untaintedAccessor;
498
+ return untaintedAccessor.call(instance2);
499
+ }
500
+ const untaintedMethodCache$2 = {};
501
+ function getUntaintedMethod$2(key, instance2, method) {
502
+ const cacheKey = `${key}.${String(method)}`;
503
+ if (untaintedMethodCache$2[cacheKey])
504
+ return untaintedMethodCache$2[cacheKey].bind(
505
+ instance2
506
+ );
507
+ const untaintedPrototype = getUntaintedPrototype$2(key);
508
+ const untaintedMethod = untaintedPrototype[method];
509
+ if (typeof untaintedMethod !== "function") return instance2[method];
510
+ untaintedMethodCache$2[cacheKey] = untaintedMethod;
511
+ return untaintedMethod.bind(instance2);
512
+ }
513
+ function childNodes$2(n2) {
514
+ return getUntaintedAccessor$2("Node", n2, "childNodes");
515
+ }
516
+ function parentNode$2(n2) {
517
+ return getUntaintedAccessor$2("Node", n2, "parentNode");
518
+ }
519
+ function parentElement$2(n2) {
520
+ return getUntaintedAccessor$2("Node", n2, "parentElement");
521
+ }
522
+ function textContent$2(n2) {
523
+ return getUntaintedAccessor$2("Node", n2, "textContent");
524
+ }
525
+ function contains$2(n2, other) {
526
+ return getUntaintedMethod$2("Node", n2, "contains")(other);
527
+ }
528
+ function getRootNode$2(n2) {
529
+ return getUntaintedMethod$2("Node", n2, "getRootNode")();
530
+ }
531
+ function host$2(n2) {
532
+ if (!n2 || !("host" in n2)) return null;
533
+ return getUntaintedAccessor$2("ShadowRoot", n2, "host");
534
+ }
535
+ function styleSheets$2(n2) {
536
+ return n2.styleSheets;
537
+ }
538
+ function shadowRoot$2(n2) {
539
+ if (!n2 || !("shadowRoot" in n2)) return null;
540
+ return getUntaintedAccessor$2("Element", n2, "shadowRoot");
541
+ }
542
+ function querySelector$2(n2, selectors) {
543
+ return getUntaintedAccessor$2("Element", n2, "querySelector")(selectors);
544
+ }
545
+ function querySelectorAll$2(n2, selectors) {
546
+ return getUntaintedAccessor$2("Element", n2, "querySelectorAll")(selectors);
547
+ }
548
+ function mutationObserverCtor$2() {
549
+ return getUntaintedPrototype$2("MutationObserver").constructor;
550
+ }
551
+ function patch$2(source, name, replacement) {
552
+ try {
553
+ if (!(name in source)) {
554
+ return () => {
555
+ };
556
+ }
557
+ const original = source[name];
558
+ const wrapped = replacement(original);
559
+ if (typeof wrapped === "function") {
560
+ wrapped.prototype = wrapped.prototype || {};
561
+ Object.defineProperties(wrapped, {
562
+ __rrweb_original__: {
563
+ enumerable: false,
564
+ value: original
565
+ }
566
+ });
567
+ }
568
+ source[name] = wrapped;
569
+ return () => {
570
+ source[name] = original;
571
+ };
572
+ } catch {
573
+ return () => {
574
+ };
575
+ }
576
+ }
577
+ const index$2 = {
578
+ childNodes: childNodes$2,
579
+ parentNode: parentNode$2,
580
+ parentElement: parentElement$2,
581
+ textContent: textContent$2,
582
+ contains: contains$2,
583
+ getRootNode: getRootNode$2,
584
+ host: host$2,
585
+ styleSheets: styleSheets$2,
586
+ shadowRoot: shadowRoot$2,
587
+ querySelector: querySelector$2,
588
+ querySelectorAll: querySelectorAll$2,
589
+ mutationObserver: mutationObserverCtor$2,
590
+ patch: patch$2
591
+ };
592
+ function isElement$1(n2) {
418
593
  return n2.nodeType === n2.ELEMENT_NODE;
419
594
  }
420
595
  class Mirror {
@@ -447,6 +622,17 @@ class Mirror {
447
622
  (childNode) => this.removeNodeFromMap(childNode)
448
623
  );
449
624
  }
625
+ if (isElement$1(n2)) {
626
+ const shadowRootEl = index$2.shadowRoot(n2);
627
+ if (shadowRootEl) {
628
+ this.removeNodeFromMap(shadowRootEl);
629
+ }
630
+ if (n2.nodeName === "IFRAME" && n2.contentDocument) {
631
+ this.removeNodeFromMap(
632
+ n2.contentDocument
633
+ );
634
+ }
635
+ }
450
636
  }
451
637
  has(id) {
452
638
  return this.idNodeMap.has(id);
@@ -4779,7 +4965,7 @@ function buildNodeWithSN(n2, options) {
4779
4965
  console.warn("Failed to rebuild", childN);
4780
4966
  continue;
4781
4967
  }
4782
- if (childN.isShadow && isElement(node2) && node2.shadowRoot) {
4968
+ if (childN.isShadow && isElement$1(node2) && node2.shadowRoot) {
4783
4969
  node2.shadowRoot.appendChild(childNode);
4784
4970
  } else if (n2.type === NodeType$1$1.Document && childN.type == NodeType$1$1.Element) {
4785
4971
  const htmlElement = childNode;
@@ -4870,6 +5056,184 @@ var __publicField22 = (obj, key, value) => __defNormalProp22(obj, typeof key !==
4870
5056
  var __defProp222 = Object.defineProperty;
4871
5057
  var __defNormalProp222 = (obj, key, value) => key in obj ? __defProp222(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4872
5058
  var __publicField222 = (obj, key, value) => __defNormalProp222(obj, typeof key !== "symbol" ? key + "" : key, value);
5059
+ const testableAccessors$1 = {
5060
+ Node: ["childNodes", "parentNode", "parentElement", "textContent"],
5061
+ ShadowRoot: ["host", "styleSheets"],
5062
+ Element: ["shadowRoot", "querySelector", "querySelectorAll"],
5063
+ MutationObserver: []
5064
+ };
5065
+ const testableMethods$1 = {
5066
+ Node: ["contains", "getRootNode"],
5067
+ ShadowRoot: ["getSelection"],
5068
+ Element: [],
5069
+ MutationObserver: ["constructor"]
5070
+ };
5071
+ const untaintedBasePrototype$1 = {};
5072
+ function angularZoneUnpatchedAlternative$1(key) {
5073
+ var _a2, _b2;
5074
+ const angularUnpatchedVersionSymbol = (_b2 = (_a2 = globalThis == null ? void 0 : globalThis.Zone) == null ? void 0 : _a2.__symbol__) == null ? void 0 : _b2.call(_a2, key);
5075
+ if (angularUnpatchedVersionSymbol && globalThis[angularUnpatchedVersionSymbol]) {
5076
+ return globalThis[angularUnpatchedVersionSymbol];
5077
+ } else {
5078
+ return void 0;
5079
+ }
5080
+ }
5081
+ function getUntaintedPrototype$1(key) {
5082
+ if (untaintedBasePrototype$1[key])
5083
+ return untaintedBasePrototype$1[key];
5084
+ const candidate = angularZoneUnpatchedAlternative$1(key) || globalThis[key];
5085
+ const defaultPrototype = candidate.prototype;
5086
+ const accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
5087
+ const isUntaintedAccessors = Boolean(
5088
+ accessorNames && // @ts-expect-error 2345
5089
+ accessorNames.every(
5090
+ (accessor) => {
5091
+ var _a2, _b2;
5092
+ return Boolean(
5093
+ (_b2 = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b2.toString().includes("[native code]")
5094
+ );
5095
+ }
5096
+ )
5097
+ );
5098
+ const methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
5099
+ const isUntaintedMethods = Boolean(
5100
+ methodNames && methodNames.every(
5101
+ // @ts-expect-error 2345
5102
+ (method) => {
5103
+ var _a2;
5104
+ return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
5105
+ }
5106
+ )
5107
+ );
5108
+ if (isUntaintedAccessors && isUntaintedMethods) {
5109
+ untaintedBasePrototype$1[key] = candidate.prototype;
5110
+ return candidate.prototype;
5111
+ }
5112
+ try {
5113
+ const iframeEl = document.createElement("iframe");
5114
+ document.body.appendChild(iframeEl);
5115
+ const win = iframeEl.contentWindow;
5116
+ if (!win) return candidate.prototype;
5117
+ const untaintedObject = win[key].prototype;
5118
+ document.body.removeChild(iframeEl);
5119
+ if (!untaintedObject) return defaultPrototype;
5120
+ return untaintedBasePrototype$1[key] = untaintedObject;
5121
+ } catch {
5122
+ return defaultPrototype;
5123
+ }
5124
+ }
5125
+ const untaintedAccessorCache$1 = {};
5126
+ function getUntaintedAccessor$1(key, instance2, accessor) {
5127
+ var _a2;
5128
+ const cacheKey = `${key}.${String(accessor)}`;
5129
+ if (untaintedAccessorCache$1[cacheKey])
5130
+ return untaintedAccessorCache$1[cacheKey].call(
5131
+ instance2
5132
+ );
5133
+ const untaintedPrototype = getUntaintedPrototype$1(key);
5134
+ const untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(
5135
+ untaintedPrototype,
5136
+ accessor
5137
+ )) == null ? void 0 : _a2.get;
5138
+ if (!untaintedAccessor) return instance2[accessor];
5139
+ untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
5140
+ return untaintedAccessor.call(instance2);
5141
+ }
5142
+ const untaintedMethodCache$1 = {};
5143
+ function getUntaintedMethod$1(key, instance2, method) {
5144
+ const cacheKey = `${key}.${String(method)}`;
5145
+ if (untaintedMethodCache$1[cacheKey])
5146
+ return untaintedMethodCache$1[cacheKey].bind(
5147
+ instance2
5148
+ );
5149
+ const untaintedPrototype = getUntaintedPrototype$1(key);
5150
+ const untaintedMethod = untaintedPrototype[method];
5151
+ if (typeof untaintedMethod !== "function") return instance2[method];
5152
+ untaintedMethodCache$1[cacheKey] = untaintedMethod;
5153
+ return untaintedMethod.bind(instance2);
5154
+ }
5155
+ function childNodes$1(n2) {
5156
+ return getUntaintedAccessor$1("Node", n2, "childNodes");
5157
+ }
5158
+ function parentNode$1(n2) {
5159
+ return getUntaintedAccessor$1("Node", n2, "parentNode");
5160
+ }
5161
+ function parentElement$1(n2) {
5162
+ return getUntaintedAccessor$1("Node", n2, "parentElement");
5163
+ }
5164
+ function textContent$1(n2) {
5165
+ return getUntaintedAccessor$1("Node", n2, "textContent");
5166
+ }
5167
+ function contains$1(n2, other) {
5168
+ return getUntaintedMethod$1("Node", n2, "contains")(other);
5169
+ }
5170
+ function getRootNode$1(n2) {
5171
+ return getUntaintedMethod$1("Node", n2, "getRootNode")();
5172
+ }
5173
+ function host$1(n2) {
5174
+ if (!n2 || !("host" in n2)) return null;
5175
+ return getUntaintedAccessor$1("ShadowRoot", n2, "host");
5176
+ }
5177
+ function styleSheets$1(n2) {
5178
+ return n2.styleSheets;
5179
+ }
5180
+ function shadowRoot$1(n2) {
5181
+ if (!n2 || !("shadowRoot" in n2)) return null;
5182
+ return getUntaintedAccessor$1("Element", n2, "shadowRoot");
5183
+ }
5184
+ function querySelector$1(n2, selectors) {
5185
+ return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
5186
+ }
5187
+ function querySelectorAll$1(n2, selectors) {
5188
+ return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
5189
+ }
5190
+ function mutationObserverCtor$1() {
5191
+ return getUntaintedPrototype$1("MutationObserver").constructor;
5192
+ }
5193
+ function patch$1(source, name, replacement) {
5194
+ try {
5195
+ if (!(name in source)) {
5196
+ return () => {
5197
+ };
5198
+ }
5199
+ const original = source[name];
5200
+ const wrapped = replacement(original);
5201
+ if (typeof wrapped === "function") {
5202
+ wrapped.prototype = wrapped.prototype || {};
5203
+ Object.defineProperties(wrapped, {
5204
+ __rrweb_original__: {
5205
+ enumerable: false,
5206
+ value: original
5207
+ }
5208
+ });
5209
+ }
5210
+ source[name] = wrapped;
5211
+ return () => {
5212
+ source[name] = original;
5213
+ };
5214
+ } catch {
5215
+ return () => {
5216
+ };
5217
+ }
5218
+ }
5219
+ const index$1 = {
5220
+ childNodes: childNodes$1,
5221
+ parentNode: parentNode$1,
5222
+ parentElement: parentElement$1,
5223
+ textContent: textContent$1,
5224
+ contains: contains$1,
5225
+ getRootNode: getRootNode$1,
5226
+ host: host$1,
5227
+ styleSheets: styleSheets$1,
5228
+ shadowRoot: shadowRoot$1,
5229
+ querySelector: querySelector$1,
5230
+ querySelectorAll: querySelectorAll$1,
5231
+ mutationObserver: mutationObserverCtor$1,
5232
+ patch: patch$1
5233
+ };
5234
+ function isElement(n2) {
5235
+ return n2.nodeType === n2.ELEMENT_NODE;
5236
+ }
4873
5237
  let Mirror$1 = class Mirror2 {
4874
5238
  constructor() {
4875
5239
  __publicField222(this, "idNodeMap", /* @__PURE__ */ new Map());
@@ -4900,6 +5264,17 @@ let Mirror$1 = class Mirror2 {
4900
5264
  (childNode) => this.removeNodeFromMap(childNode)
4901
5265
  );
4902
5266
  }
5267
+ if (isElement(n2)) {
5268
+ const shadowRootEl = index$1.shadowRoot(n2);
5269
+ if (shadowRootEl) {
5270
+ this.removeNodeFromMap(shadowRootEl);
5271
+ }
5272
+ if (n2.nodeName === "IFRAME" && n2.contentDocument) {
5273
+ this.removeNodeFromMap(
5274
+ n2.contentDocument
5275
+ );
5276
+ }
5277
+ }
4903
5278
  }
4904
5279
  has(id) {
4905
5280
  return this.idNodeMap.has(id);
@@ -12306,6 +12681,8 @@ class Replayer {
12306
12681
  (_b2 = this.speedServiceSubscription) == null ? void 0 : _b2.unsubscribe();
12307
12682
  this.serviceSubscription = void 0;
12308
12683
  this.speedServiceSubscription = void 0;
12684
+ this.service.stop();
12685
+ this.speedService.stop();
12309
12686
  this.timeouts.forEach((timeout) => clearTimeout(timeout));
12310
12687
  this.timeouts.clear();
12311
12688
  this.styleSheetLoadListeners.forEach((handler, element2) => {