@glimt/record 0.0.39 → 0.0.41

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