@glimt/record 0.0.38 → 0.0.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/record.cjs CHANGED
@@ -443,7 +443,7 @@ function isShadowRoot(n2) {
443
443
  function isNativeShadowDom(shadowRoot2) {
444
444
  return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
445
445
  }
446
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
446
+ function fixBrowserCompatibilityIssuesInCSS$1(cssText) {
447
447
  if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
448
448
  cssText = cssText.replace(
449
449
  /\sbackground-clip:\s*text;/g,
@@ -452,7 +452,7 @@ function fixBrowserCompatibilityIssuesInCSS(cssText) {
452
452
  }
453
453
  return cssText;
454
454
  }
455
- function escapeImportStatement(rule2) {
455
+ function escapeImportStatement$1(rule2) {
456
456
  const { cssText } = rule2;
457
457
  if (cssText.split('"').length < 3) return cssText;
458
458
  const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
@@ -469,7 +469,7 @@ function escapeImportStatement(rule2) {
469
469
  }
470
470
  return statement.join(" ") + ";";
471
471
  }
472
- function stringifyStylesheet(s2) {
472
+ function stringifyStylesheet$1(s2) {
473
473
  try {
474
474
  const rules2 = s2.rules || s2.cssRules;
475
475
  if (!rules2) {
@@ -481,47 +481,47 @@ function stringifyStylesheet(s2) {
481
481
  }
482
482
  const stringifiedRules = Array.from(
483
483
  rules2,
484
- (rule2) => stringifyRule(rule2, sheetHref)
484
+ (rule2) => stringifyRule$1(rule2, sheetHref)
485
485
  ).join("");
486
- return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
486
+ return fixBrowserCompatibilityIssuesInCSS$1(stringifiedRules);
487
487
  } catch (error) {
488
488
  return null;
489
489
  }
490
490
  }
491
- function stringifyRule(rule2, sheetHref) {
492
- if (isCSSImportRule(rule2)) {
491
+ function stringifyRule$1(rule2, sheetHref) {
492
+ if (isCSSImportRule$1(rule2)) {
493
493
  let importStringified;
494
494
  try {
495
495
  importStringified = // for same-origin stylesheets,
496
496
  // we can access the imported stylesheet rules directly
497
- stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
498
- escapeImportStatement(rule2);
497
+ stringifyStylesheet$1(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
498
+ escapeImportStatement$1(rule2);
499
499
  } catch (error) {
500
500
  importStringified = rule2.cssText;
501
501
  }
502
502
  if (rule2.styleSheet.href) {
503
- return absolutifyURLs(importStringified, rule2.styleSheet.href);
503
+ return absolutifyURLs$1(importStringified, rule2.styleSheet.href);
504
504
  }
505
505
  return importStringified;
506
506
  } else {
507
507
  let ruleStringified = rule2.cssText;
508
- if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
509
- ruleStringified = fixSafariColons(ruleStringified);
508
+ if (isCSSStyleRule$1(rule2) && rule2.selectorText.includes(":")) {
509
+ ruleStringified = fixSafariColons$1(ruleStringified);
510
510
  }
511
511
  if (sheetHref) {
512
- return absolutifyURLs(ruleStringified, sheetHref);
512
+ return absolutifyURLs$1(ruleStringified, sheetHref);
513
513
  }
514
514
  return ruleStringified;
515
515
  }
516
516
  }
517
- function fixSafariColons(cssStringified) {
517
+ function fixSafariColons$1(cssStringified) {
518
518
  const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
519
519
  return cssStringified.replace(regex, "$1\\$2");
520
520
  }
521
- function isCSSImportRule(rule2) {
521
+ function isCSSImportRule$1(rule2) {
522
522
  return "styleSheet" in rule2;
523
523
  }
524
- function isCSSStyleRule(rule2) {
524
+ function isCSSStyleRule$1(rule2) {
525
525
  return "selectorText" in rule2;
526
526
  }
527
527
  class Mirror {
@@ -658,7 +658,7 @@ function extractFileExtension(path, baseURL) {
658
658
  const match = url.pathname.match(regex);
659
659
  return (match == null ? void 0 : match[1]) ?? null;
660
660
  }
661
- function extractOrigin(url) {
661
+ function extractOrigin$1(url) {
662
662
  let origin = "";
663
663
  if (url.indexOf("//") > -1) {
664
664
  origin = url.split("/").slice(0, 3).join("/");
@@ -668,27 +668,27 @@ function extractOrigin(url) {
668
668
  origin = origin.split("?")[0];
669
669
  return origin;
670
670
  }
671
- const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
672
- const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
673
- const URL_WWW_MATCH = /^www\..*/i;
674
- const DATA_URI = /^(data:)([^,]*),(.*)/i;
675
- function absolutifyURLs(cssText, href) {
671
+ const URL_IN_CSS_REF$1 = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
672
+ const URL_PROTOCOL_MATCH$1 = /^(?:[a-z+]+:)?\/\//i;
673
+ const URL_WWW_MATCH$1 = /^www\..*/i;
674
+ const DATA_URI$1 = /^(data:)([^,]*),(.*)/i;
675
+ function absolutifyURLs$1(cssText, href) {
676
676
  return (cssText || "").replace(
677
- URL_IN_CSS_REF,
677
+ URL_IN_CSS_REF$1,
678
678
  (origin, quote1, path1, quote2, path2, path3) => {
679
679
  const filePath = path1 || path2 || path3;
680
680
  const maybeQuote = quote1 || quote2 || "";
681
681
  if (!filePath) {
682
682
  return origin;
683
683
  }
684
- if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
684
+ if (URL_PROTOCOL_MATCH$1.test(filePath) || URL_WWW_MATCH$1.test(filePath)) {
685
685
  return `url(${maybeQuote}${filePath}${maybeQuote})`;
686
686
  }
687
- if (DATA_URI.test(filePath)) {
687
+ if (DATA_URI$1.test(filePath)) {
688
688
  return `url(${maybeQuote}${filePath}${maybeQuote})`;
689
689
  }
690
690
  if (filePath[0] === "/") {
691
- return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
691
+ return `url(${maybeQuote}${extractOrigin$1(href) + filePath}${maybeQuote})`;
692
692
  }
693
693
  const stack = href.split("/");
694
694
  const parts = filePath.split("/");
@@ -811,6 +811,108 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
811
811
  function markCssSplits(cssText, style) {
812
812
  return splitCssText(cssText, style).join("/* rr_split */");
813
813
  }
814
+ const CLEANUP_DEBOUNCE_TIME$1 = 1e3 * 60 * 5;
815
+ const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
816
+ constructor() {
817
+ __publicField$1(this, "currentHref", null);
818
+ __publicField$1(this, "clones", {});
819
+ __publicField$1(this, "cleanTimeout", null);
820
+ if (_AsyncStylesheetManager.instance) return _AsyncStylesheetManager.instance;
821
+ _AsyncStylesheetManager.instance = this;
822
+ }
823
+ onLoad(href) {
824
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
825
+ console.log("AsyncStylesheetManager, onLoad: href:", href);
826
+ const styleSheets2 = Array.from(document.styleSheets);
827
+ let clonedStyleSheet = null;
828
+ document.head.removeChild(this.clones[href].clone);
829
+ for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
830
+ if (styleSheets2[i2].href === href) {
831
+ clonedStyleSheet = styleSheets2[i2];
832
+ break;
833
+ }
834
+ }
835
+ if (!clonedStyleSheet) return;
836
+ const newCssText = stringifyStylesheet$1(clonedStyleSheet);
837
+ if (!newCssText) return;
838
+ console.log(
839
+ "AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation..."
840
+ );
841
+ this.clones[href].cssText = newCssText;
842
+ this.clones[href].loaded = true;
843
+ this.clones[href].original.setAttribute(
844
+ "data-rrweb-mutation",
845
+ Date.now().toString()
846
+ );
847
+ }
848
+ onLoadError(href) {
849
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
850
+ document.head.removeChild(this.clones[href].clone);
851
+ }
852
+ removeAllCloneElements() {
853
+ for (const clone of Object.values(this.clones)) {
854
+ if (!clone) continue;
855
+ document.head.removeChild(clone.clone);
856
+ }
857
+ }
858
+ onCleanTimeout() {
859
+ console.log("AsyncStylesheetManager, onCleanTimeout: cleaning up");
860
+ this.cleanTimeout = null;
861
+ this.removeAllCloneElements();
862
+ }
863
+ blowCache() {
864
+ console.log("AsyncStylesheetManager, blowCache: blowing cache");
865
+ this.clones = {};
866
+ this.removeAllCloneElements();
867
+ }
868
+ registerClone({ forElement }) {
869
+ if (this.currentHref != null && document.location.href !== this.currentHref)
870
+ this.blowCache();
871
+ this.currentHref = document.location.href;
872
+ const href = forElement.href;
873
+ console.log(
874
+ "AsyncStylesheetManager, registerClone: wants a clone for href:",
875
+ href
876
+ );
877
+ if (!href) return;
878
+ if (href in this.clones && this.clones[href] !== void 0) return;
879
+ if (forElement.getAttribute("crossorigin") === "anonymous") return;
880
+ console.log(
881
+ "AsyncStylesheetManager, registerClone: registering clone for href:",
882
+ href
883
+ );
884
+ const clone = forElement.cloneNode();
885
+ clone.setAttribute("crossorigin", "anonymous");
886
+ clone.setAttribute("data-rrweb-link-cloned", "true");
887
+ document.head.appendChild(clone);
888
+ this.clones[href] = {
889
+ original: forElement,
890
+ clone,
891
+ loaded: false,
892
+ cssText: null
893
+ };
894
+ clone.onload = () => {
895
+ this.onLoad(href);
896
+ };
897
+ clone.onerror = () => {
898
+ this.onLoadError(href);
899
+ };
900
+ if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
901
+ this.cleanTimeout = setTimeout(this.onCleanTimeout, CLEANUP_DEBOUNCE_TIME$1);
902
+ }
903
+ getClonedCssTextIfAvailable(href) {
904
+ if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
905
+ console.log(
906
+ "AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText!"
907
+ );
908
+ return this.clones[href].cssText;
909
+ }
910
+ return null;
911
+ }
912
+ };
913
+ __publicField$1(_AsyncStylesheetManager$1, "instance");
914
+ let AsyncStylesheetManager$1 = _AsyncStylesheetManager$1;
915
+ const asyncStylesheetManager = new AsyncStylesheetManager$1();
814
916
  let _id = 1;
815
917
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
816
918
  const IGNORED_NODE = -2;
@@ -922,7 +1024,7 @@ function transformAttribute(doc, tagName, name, value) {
922
1024
  } else if (name === "srcset") {
923
1025
  return getAbsoluteSrcsetString(doc, value);
924
1026
  } else if (name === "style") {
925
- return absolutifyURLs(value, getHref(doc));
1027
+ return absolutifyURLs$1(value, getHref(doc));
926
1028
  } else if (tagName === "object" && name === "data") {
927
1029
  return absoluteToDoc(doc, value);
928
1030
  }
@@ -1159,7 +1261,7 @@ function serializeTextNode(n2, options) {
1159
1261
  } else if (!cssCaptured) {
1160
1262
  textContent2 = index.textContent(n2);
1161
1263
  if (isStyle && textContent2) {
1162
- textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
1264
+ textContent2 = absolutifyURLs$1(textContent2, getHref(options.doc));
1163
1265
  }
1164
1266
  }
1165
1267
  if (!isStyle && !isScript && textContent2 && needsMask) {
@@ -1202,23 +1304,32 @@ function serializeElementNode(n2, options) {
1202
1304
  }
1203
1305
  }
1204
1306
  if (tagName === "link" && inlineStylesheet) {
1205
- const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1307
+ const styleSheets2 = Array.from(doc.styleSheets);
1308
+ const styleSheetIndex = styleSheets2.findIndex((s2) => {
1206
1309
  return s2.href === n2.href;
1207
1310
  });
1311
+ const stylesheet = styleSheets2[styleSheetIndex];
1208
1312
  let cssText = null;
1209
1313
  if (stylesheet) {
1210
- cssText = stringifyStylesheet(stylesheet);
1314
+ cssText = stringifyStylesheet$1(stylesheet);
1315
+ }
1316
+ if (!cssText) {
1317
+ cssText = asyncStylesheetManager.getClonedCssTextIfAvailable(
1318
+ n2.href
1319
+ );
1211
1320
  }
1212
1321
  if (cssText) {
1213
1322
  delete attributes.rel;
1214
1323
  delete attributes.href;
1215
1324
  attributes._cssText = cssText;
1216
1325
  } else {
1217
- console.log("failed to extract stylesheets from link element", n2);
1326
+ asyncStylesheetManager.registerClone({
1327
+ forElement: n2
1328
+ });
1218
1329
  }
1219
1330
  }
1220
1331
  if (tagName === "style" && n2.sheet) {
1221
- let cssText = stringifyStylesheet(
1332
+ let cssText = stringifyStylesheet$1(
1222
1333
  n2.sheet
1223
1334
  );
1224
1335
  if (cssText) {
@@ -5368,6 +5479,240 @@ postcss$1$1.Node;
5368
5479
  var __defProp2 = Object.defineProperty;
5369
5480
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5370
5481
  var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
5482
+ var __defProp22 = Object.defineProperty;
5483
+ var __defNormalProp22 = (obj, key, value) => key in obj ? __defProp22(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5484
+ var __publicField22 = (obj, key, value) => __defNormalProp22(obj, typeof key !== "symbol" ? key + "" : key, value);
5485
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
5486
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
5487
+ cssText = cssText.replace(
5488
+ /\sbackground-clip:\s*text;/g,
5489
+ " -webkit-background-clip: text; background-clip: text;"
5490
+ );
5491
+ }
5492
+ return cssText;
5493
+ }
5494
+ function escapeImportStatement(rule2) {
5495
+ const { cssText } = rule2;
5496
+ if (cssText.split('"').length < 3) return cssText;
5497
+ const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
5498
+ if (rule2.layerName === "") {
5499
+ statement.push(`layer`);
5500
+ } else if (rule2.layerName) {
5501
+ statement.push(`layer(${rule2.layerName})`);
5502
+ }
5503
+ if (rule2.supportsText) {
5504
+ statement.push(`supports(${rule2.supportsText})`);
5505
+ }
5506
+ if (rule2.media.length) {
5507
+ statement.push(rule2.media.mediaText);
5508
+ }
5509
+ return statement.join(" ") + ";";
5510
+ }
5511
+ function stringifyStylesheet(s2) {
5512
+ try {
5513
+ const rules2 = s2.rules || s2.cssRules;
5514
+ if (!rules2) {
5515
+ return null;
5516
+ }
5517
+ let sheetHref = s2.href;
5518
+ if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
5519
+ sheetHref = s2.ownerNode.ownerDocument.location.href;
5520
+ }
5521
+ const stringifiedRules = Array.from(
5522
+ rules2,
5523
+ (rule2) => stringifyRule(rule2, sheetHref)
5524
+ ).join("");
5525
+ return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
5526
+ } catch (error) {
5527
+ return null;
5528
+ }
5529
+ }
5530
+ function stringifyRule(rule2, sheetHref) {
5531
+ if (isCSSImportRule(rule2)) {
5532
+ let importStringified;
5533
+ try {
5534
+ importStringified = // for same-origin stylesheets,
5535
+ // we can access the imported stylesheet rules directly
5536
+ stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
5537
+ escapeImportStatement(rule2);
5538
+ } catch (error) {
5539
+ importStringified = rule2.cssText;
5540
+ }
5541
+ if (rule2.styleSheet.href) {
5542
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
5543
+ }
5544
+ return importStringified;
5545
+ } else {
5546
+ let ruleStringified = rule2.cssText;
5547
+ if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
5548
+ ruleStringified = fixSafariColons(ruleStringified);
5549
+ }
5550
+ if (sheetHref) {
5551
+ return absolutifyURLs(ruleStringified, sheetHref);
5552
+ }
5553
+ return ruleStringified;
5554
+ }
5555
+ }
5556
+ function fixSafariColons(cssStringified) {
5557
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
5558
+ return cssStringified.replace(regex, "$1\\$2");
5559
+ }
5560
+ function isCSSImportRule(rule2) {
5561
+ return "styleSheet" in rule2;
5562
+ }
5563
+ function isCSSStyleRule(rule2) {
5564
+ return "selectorText" in rule2;
5565
+ }
5566
+ function extractOrigin(url) {
5567
+ let origin = "";
5568
+ if (url.indexOf("//") > -1) {
5569
+ origin = url.split("/").slice(0, 3).join("/");
5570
+ } else {
5571
+ origin = url.split("/")[0];
5572
+ }
5573
+ origin = origin.split("?")[0];
5574
+ return origin;
5575
+ }
5576
+ const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
5577
+ const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
5578
+ const URL_WWW_MATCH = /^www\..*/i;
5579
+ const DATA_URI = /^(data:)([^,]*),(.*)/i;
5580
+ function absolutifyURLs(cssText, href) {
5581
+ return (cssText || "").replace(
5582
+ URL_IN_CSS_REF,
5583
+ (origin, quote1, path1, quote2, path2, path3) => {
5584
+ const filePath = path1 || path2 || path3;
5585
+ const maybeQuote = quote1 || quote2 || "";
5586
+ if (!filePath) {
5587
+ return origin;
5588
+ }
5589
+ if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
5590
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
5591
+ }
5592
+ if (DATA_URI.test(filePath)) {
5593
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
5594
+ }
5595
+ if (filePath[0] === "/") {
5596
+ return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
5597
+ }
5598
+ const stack = href.split("/");
5599
+ const parts = filePath.split("/");
5600
+ stack.pop();
5601
+ for (const part of parts) {
5602
+ if (part === ".") {
5603
+ continue;
5604
+ } else if (part === "..") {
5605
+ stack.pop();
5606
+ } else {
5607
+ stack.push(part);
5608
+ }
5609
+ }
5610
+ return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
5611
+ }
5612
+ );
5613
+ }
5614
+ const CLEANUP_DEBOUNCE_TIME = 1e3 * 60 * 5;
5615
+ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5616
+ constructor() {
5617
+ __publicField22(this, "currentHref", null);
5618
+ __publicField22(this, "clones", {});
5619
+ __publicField22(this, "cleanTimeout", null);
5620
+ if (_AsyncStylesheetManager22.instance) return _AsyncStylesheetManager22.instance;
5621
+ _AsyncStylesheetManager22.instance = this;
5622
+ }
5623
+ onLoad(href) {
5624
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5625
+ console.log("AsyncStylesheetManager, onLoad: href:", href);
5626
+ const styleSheets2 = Array.from(document.styleSheets);
5627
+ let clonedStyleSheet = null;
5628
+ document.head.removeChild(this.clones[href].clone);
5629
+ for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
5630
+ if (styleSheets2[i2].href === href) {
5631
+ clonedStyleSheet = styleSheets2[i2];
5632
+ break;
5633
+ }
5634
+ }
5635
+ if (!clonedStyleSheet) return;
5636
+ const newCssText = stringifyStylesheet(clonedStyleSheet);
5637
+ if (!newCssText) return;
5638
+ console.log(
5639
+ "AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation..."
5640
+ );
5641
+ this.clones[href].cssText = newCssText;
5642
+ this.clones[href].loaded = true;
5643
+ this.clones[href].original.setAttribute(
5644
+ "data-rrweb-mutation",
5645
+ Date.now().toString()
5646
+ );
5647
+ }
5648
+ onLoadError(href) {
5649
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5650
+ document.head.removeChild(this.clones[href].clone);
5651
+ }
5652
+ removeAllCloneElements() {
5653
+ for (const clone of Object.values(this.clones)) {
5654
+ if (!clone) continue;
5655
+ document.head.removeChild(clone.clone);
5656
+ }
5657
+ }
5658
+ onCleanTimeout() {
5659
+ console.log("AsyncStylesheetManager, onCleanTimeout: cleaning up");
5660
+ this.cleanTimeout = null;
5661
+ this.removeAllCloneElements();
5662
+ }
5663
+ blowCache() {
5664
+ console.log("AsyncStylesheetManager, blowCache: blowing cache");
5665
+ this.clones = {};
5666
+ this.removeAllCloneElements();
5667
+ }
5668
+ registerClone({ forElement }) {
5669
+ if (this.currentHref != null && document.location.href !== this.currentHref)
5670
+ this.blowCache();
5671
+ this.currentHref = document.location.href;
5672
+ const href = forElement.href;
5673
+ console.log(
5674
+ "AsyncStylesheetManager, registerClone: wants a clone for href:",
5675
+ href
5676
+ );
5677
+ if (!href) return;
5678
+ if (href in this.clones && this.clones[href] !== void 0) return;
5679
+ if (forElement.getAttribute("crossorigin") === "anonymous") return;
5680
+ console.log(
5681
+ "AsyncStylesheetManager, registerClone: registering clone for href:",
5682
+ href
5683
+ );
5684
+ const clone = forElement.cloneNode();
5685
+ clone.setAttribute("crossorigin", "anonymous");
5686
+ clone.setAttribute("data-rrweb-link-cloned", "true");
5687
+ document.head.appendChild(clone);
5688
+ this.clones[href] = {
5689
+ original: forElement,
5690
+ clone,
5691
+ loaded: false,
5692
+ cssText: null
5693
+ };
5694
+ clone.onload = () => {
5695
+ this.onLoad(href);
5696
+ };
5697
+ clone.onerror = () => {
5698
+ this.onLoadError(href);
5699
+ };
5700
+ if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
5701
+ this.cleanTimeout = setTimeout(this.onCleanTimeout, CLEANUP_DEBOUNCE_TIME);
5702
+ }
5703
+ getClonedCssTextIfAvailable(href) {
5704
+ if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
5705
+ console.log(
5706
+ "AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText!"
5707
+ );
5708
+ return this.clones[href].cssText;
5709
+ }
5710
+ return null;
5711
+ }
5712
+ };
5713
+ __publicField22(_AsyncStylesheetManager2, "instance");
5714
+ let AsyncStylesheetManager = _AsyncStylesheetManager2;
5715
+ new AsyncStylesheetManager();
5371
5716
  function getDefaultExportFromCjs(x2) {
5372
5717
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
5373
5718
  }
@@ -12122,7 +12467,7 @@ class StylesheetManager {
12122
12467
  styles.push({
12123
12468
  styleId,
12124
12469
  rules: Array.from(sheet.rules || CSSRule, (r2, index2) => ({
12125
- rule: stringifyRule(r2, sheet.href),
12470
+ rule: stringifyRule$1(r2, sheet.href),
12126
12471
  index: index2
12127
12472
  }))
12128
12473
  });
@@ -12591,22 +12936,17 @@ function record(options = {}) {
12591
12936
  };
12592
12937
  const customOnLoad = () => {
12593
12938
  window.removeEventListener("load", customOnLoad);
12594
- console.log("customOnLoad fired", recording, initedAt);
12595
12939
  if (!recording || initedAt == null) return;
12596
- console.log("customOnLoad wants to take a full snapshot");
12597
12940
  if (Date.now() - initedAt <= 10) {
12598
- console.log("customOnLoad skipping full snapshot bc it was too soon");
12599
12941
  return;
12600
12942
  }
12601
- console.log("customOnLoad taking full snapshot bc race condition");
12602
12943
  takeFullSnapshot$1();
12603
12944
  };
12604
12945
  window.addEventListener("load", customOnLoad);
12605
12946
  if (document.readyState === "interactive" || document.readyState === "complete") {
12606
- console.log(
12607
- "fired init() bc readyState === 'interactive' || 'complete'",
12608
- document.readyState
12609
- );
12947
+ if (document.readyState === "complete") {
12948
+ window.removeEventListener("load", customOnLoad);
12949
+ }
12610
12950
  init();
12611
12951
  } else {
12612
12952
  handlers.push(
@@ -12616,7 +12956,6 @@ function record(options = {}) {
12616
12956
  data: {}
12617
12957
  });
12618
12958
  if (recordAfter === "DOMContentLoaded") {
12619
- console.log("fired init() bc listener 'DOMContentLoaded'");
12620
12959
  init();
12621
12960
  }
12622
12961
  })
@@ -12630,7 +12969,6 @@ function record(options = {}) {
12630
12969
  data: {}
12631
12970
  });
12632
12971
  if (recordAfter === "load") {
12633
- console.log("fired init() bc listener 'load'");
12634
12972
  init();
12635
12973
  }
12636
12974
  },