@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 +385 -32
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +385 -32
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +385 -32
- package/dist/record.umd.cjs.map +3 -3
- package/dist/record.umd.min.cjs +24 -24
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.umd.cjs
CHANGED
|
@@ -475,7 +475,7 @@ function isShadowRoot(n2) {
|
|
|
475
475
|
function isNativeShadowDom(shadowRoot2) {
|
|
476
476
|
return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
|
|
477
477
|
}
|
|
478
|
-
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
478
|
+
function fixBrowserCompatibilityIssuesInCSS$1(cssText) {
|
|
479
479
|
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
480
480
|
cssText = cssText.replace(
|
|
481
481
|
/\sbackground-clip:\s*text;/g,
|
|
@@ -484,7 +484,7 @@ function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
|
484
484
|
}
|
|
485
485
|
return cssText;
|
|
486
486
|
}
|
|
487
|
-
function escapeImportStatement(rule2) {
|
|
487
|
+
function escapeImportStatement$1(rule2) {
|
|
488
488
|
const { cssText } = rule2;
|
|
489
489
|
if (cssText.split('"').length < 3) return cssText;
|
|
490
490
|
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
@@ -501,7 +501,7 @@ function escapeImportStatement(rule2) {
|
|
|
501
501
|
}
|
|
502
502
|
return statement.join(" ") + ";";
|
|
503
503
|
}
|
|
504
|
-
function stringifyStylesheet(s2) {
|
|
504
|
+
function stringifyStylesheet$1(s2) {
|
|
505
505
|
try {
|
|
506
506
|
const rules2 = s2.rules || s2.cssRules;
|
|
507
507
|
if (!rules2) {
|
|
@@ -513,47 +513,48 @@ function stringifyStylesheet(s2) {
|
|
|
513
513
|
}
|
|
514
514
|
const stringifiedRules = Array.from(
|
|
515
515
|
rules2,
|
|
516
|
-
(rule2) => stringifyRule(rule2, sheetHref)
|
|
516
|
+
(rule2) => stringifyRule$1(rule2, sheetHref)
|
|
517
517
|
).join("");
|
|
518
|
-
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
518
|
+
return fixBrowserCompatibilityIssuesInCSS$1(stringifiedRules);
|
|
519
519
|
} catch (error) {
|
|
520
|
+
console.log("stringifyStylesheet error:", error);
|
|
520
521
|
return null;
|
|
521
522
|
}
|
|
522
523
|
}
|
|
523
|
-
function stringifyRule(rule2, sheetHref) {
|
|
524
|
-
if (isCSSImportRule(rule2)) {
|
|
524
|
+
function stringifyRule$1(rule2, sheetHref) {
|
|
525
|
+
if (isCSSImportRule$1(rule2)) {
|
|
525
526
|
let importStringified;
|
|
526
527
|
try {
|
|
527
528
|
importStringified = // for same-origin stylesheets,
|
|
528
529
|
// we can access the imported stylesheet rules directly
|
|
529
|
-
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
530
|
-
escapeImportStatement(rule2);
|
|
530
|
+
stringifyStylesheet$1(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
531
|
+
escapeImportStatement$1(rule2);
|
|
531
532
|
} catch (error) {
|
|
532
533
|
importStringified = rule2.cssText;
|
|
533
534
|
}
|
|
534
535
|
if (rule2.styleSheet.href) {
|
|
535
|
-
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
536
|
+
return absolutifyURLs$1(importStringified, rule2.styleSheet.href);
|
|
536
537
|
}
|
|
537
538
|
return importStringified;
|
|
538
539
|
} else {
|
|
539
540
|
let ruleStringified = rule2.cssText;
|
|
540
|
-
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
541
|
-
ruleStringified = fixSafariColons(ruleStringified);
|
|
541
|
+
if (isCSSStyleRule$1(rule2) && rule2.selectorText.includes(":")) {
|
|
542
|
+
ruleStringified = fixSafariColons$1(ruleStringified);
|
|
542
543
|
}
|
|
543
544
|
if (sheetHref) {
|
|
544
|
-
return absolutifyURLs(ruleStringified, sheetHref);
|
|
545
|
+
return absolutifyURLs$1(ruleStringified, sheetHref);
|
|
545
546
|
}
|
|
546
547
|
return ruleStringified;
|
|
547
548
|
}
|
|
548
549
|
}
|
|
549
|
-
function fixSafariColons(cssStringified) {
|
|
550
|
+
function fixSafariColons$1(cssStringified) {
|
|
550
551
|
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
551
552
|
return cssStringified.replace(regex, "$1\\$2");
|
|
552
553
|
}
|
|
553
|
-
function isCSSImportRule(rule2) {
|
|
554
|
+
function isCSSImportRule$1(rule2) {
|
|
554
555
|
return "styleSheet" in rule2;
|
|
555
556
|
}
|
|
556
|
-
function isCSSStyleRule(rule2) {
|
|
557
|
+
function isCSSStyleRule$1(rule2) {
|
|
557
558
|
return "selectorText" in rule2;
|
|
558
559
|
}
|
|
559
560
|
class Mirror {
|
|
@@ -691,7 +692,7 @@ function extractFileExtension(path, baseURL) {
|
|
|
691
692
|
const match = url.pathname.match(regex);
|
|
692
693
|
return (_a2 = match == null ? void 0 : match[1]) != null ? _a2 : null;
|
|
693
694
|
}
|
|
694
|
-
function extractOrigin(url) {
|
|
695
|
+
function extractOrigin$1(url) {
|
|
695
696
|
let origin = "";
|
|
696
697
|
if (url.indexOf("//") > -1) {
|
|
697
698
|
origin = url.split("/").slice(0, 3).join("/");
|
|
@@ -701,27 +702,27 @@ function extractOrigin(url) {
|
|
|
701
702
|
origin = origin.split("?")[0];
|
|
702
703
|
return origin;
|
|
703
704
|
}
|
|
704
|
-
const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
705
|
-
const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
|
|
706
|
-
const URL_WWW_MATCH = /^www\..*/i;
|
|
707
|
-
const DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
708
|
-
function absolutifyURLs(cssText, href) {
|
|
705
|
+
const URL_IN_CSS_REF$1 = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
706
|
+
const URL_PROTOCOL_MATCH$1 = /^(?:[a-z+]+:)?\/\//i;
|
|
707
|
+
const URL_WWW_MATCH$1 = /^www\..*/i;
|
|
708
|
+
const DATA_URI$1 = /^(data:)([^,]*),(.*)/i;
|
|
709
|
+
function absolutifyURLs$1(cssText, href) {
|
|
709
710
|
return (cssText || "").replace(
|
|
710
|
-
URL_IN_CSS_REF,
|
|
711
|
+
URL_IN_CSS_REF$1,
|
|
711
712
|
(origin, quote1, path1, quote2, path2, path3) => {
|
|
712
713
|
const filePath = path1 || path2 || path3;
|
|
713
714
|
const maybeQuote = quote1 || quote2 || "";
|
|
714
715
|
if (!filePath) {
|
|
715
716
|
return origin;
|
|
716
717
|
}
|
|
717
|
-
if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
|
|
718
|
+
if (URL_PROTOCOL_MATCH$1.test(filePath) || URL_WWW_MATCH$1.test(filePath)) {
|
|
718
719
|
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
719
720
|
}
|
|
720
|
-
if (DATA_URI.test(filePath)) {
|
|
721
|
+
if (DATA_URI$1.test(filePath)) {
|
|
721
722
|
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
722
723
|
}
|
|
723
724
|
if (filePath[0] === "/") {
|
|
724
|
-
return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
|
|
725
|
+
return `url(${maybeQuote}${extractOrigin$1(href) + filePath}${maybeQuote})`;
|
|
725
726
|
}
|
|
726
727
|
const stack = href.split("/");
|
|
727
728
|
const parts = filePath.split("/");
|
|
@@ -844,6 +845,108 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
|
844
845
|
function markCssSplits(cssText, style) {
|
|
845
846
|
return splitCssText(cssText, style).join("/* rr_split */");
|
|
846
847
|
}
|
|
848
|
+
const CLEANUP_DEBOUNCE_TIME$1 = 1e3 * 60 * 5;
|
|
849
|
+
const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
|
|
850
|
+
constructor() {
|
|
851
|
+
__publicField$1(this, "currentHref", null);
|
|
852
|
+
__publicField$1(this, "clones", {});
|
|
853
|
+
__publicField$1(this, "cleanTimeout", null);
|
|
854
|
+
if (_AsyncStylesheetManager.instance) return _AsyncStylesheetManager.instance;
|
|
855
|
+
_AsyncStylesheetManager.instance = this;
|
|
856
|
+
}
|
|
857
|
+
onLoad(href) {
|
|
858
|
+
if (!(href in this.clones) || this.clones[href] === void 0) return;
|
|
859
|
+
console.log("AsyncStylesheetManager, onLoad: href:", href);
|
|
860
|
+
const styleSheets2 = Array.from(document.styleSheets);
|
|
861
|
+
let clonedStyleSheet = null;
|
|
862
|
+
document.head.removeChild(this.clones[href].clone);
|
|
863
|
+
for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
|
|
864
|
+
if (styleSheets2[i2].href === href) {
|
|
865
|
+
clonedStyleSheet = styleSheets2[i2];
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (!clonedStyleSheet) return;
|
|
870
|
+
const newCssText = stringifyStylesheet$1(clonedStyleSheet);
|
|
871
|
+
if (!newCssText) return;
|
|
872
|
+
console.log(
|
|
873
|
+
"AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation..."
|
|
874
|
+
);
|
|
875
|
+
this.clones[href].cssText = newCssText;
|
|
876
|
+
this.clones[href].loaded = true;
|
|
877
|
+
this.clones[href].original.setAttribute(
|
|
878
|
+
"data-rrweb-mutation",
|
|
879
|
+
Date.now().toString()
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
onLoadError(href) {
|
|
883
|
+
if (!(href in this.clones) || this.clones[href] === void 0) return;
|
|
884
|
+
document.head.removeChild(this.clones[href].clone);
|
|
885
|
+
}
|
|
886
|
+
removeAllCloneElements() {
|
|
887
|
+
for (const clone of Object.values(this.clones)) {
|
|
888
|
+
if (!clone) continue;
|
|
889
|
+
document.head.removeChild(clone.clone);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
onCleanTimeout() {
|
|
893
|
+
console.log("AsyncStylesheetManager, onCleanTimeout: cleaning up");
|
|
894
|
+
this.cleanTimeout = null;
|
|
895
|
+
this.removeAllCloneElements();
|
|
896
|
+
}
|
|
897
|
+
blowCache() {
|
|
898
|
+
console.log("AsyncStylesheetManager, blowCache: blowing cache");
|
|
899
|
+
this.clones = {};
|
|
900
|
+
this.removeAllCloneElements();
|
|
901
|
+
}
|
|
902
|
+
registerClone({ forElement }) {
|
|
903
|
+
if (this.currentHref != null && document.location.href !== this.currentHref)
|
|
904
|
+
this.blowCache();
|
|
905
|
+
this.currentHref = document.location.href;
|
|
906
|
+
const href = forElement.href;
|
|
907
|
+
console.log(
|
|
908
|
+
"AsyncStylesheetManager, registerClone: wants a clone for href:",
|
|
909
|
+
href
|
|
910
|
+
);
|
|
911
|
+
if (!href) return;
|
|
912
|
+
if (href in this.clones && this.clones[href] !== void 0) return;
|
|
913
|
+
if (forElement.getAttribute("crossorigin") === "anonymous") return;
|
|
914
|
+
console.log(
|
|
915
|
+
"AsyncStylesheetManager, registerClone: registering clone for href:",
|
|
916
|
+
href
|
|
917
|
+
);
|
|
918
|
+
const clone = forElement.cloneNode();
|
|
919
|
+
clone.setAttribute("crossorigin", "anonymous");
|
|
920
|
+
clone.setAttribute("data-rrweb-link-cloned", "true");
|
|
921
|
+
document.head.appendChild(clone);
|
|
922
|
+
this.clones[href] = {
|
|
923
|
+
original: forElement,
|
|
924
|
+
clone,
|
|
925
|
+
loaded: false,
|
|
926
|
+
cssText: null
|
|
927
|
+
};
|
|
928
|
+
clone.onload = () => {
|
|
929
|
+
this.onLoad(href);
|
|
930
|
+
};
|
|
931
|
+
clone.onerror = () => {
|
|
932
|
+
this.onLoadError(href);
|
|
933
|
+
};
|
|
934
|
+
if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
|
|
935
|
+
this.cleanTimeout = setTimeout(this.onCleanTimeout, CLEANUP_DEBOUNCE_TIME$1);
|
|
936
|
+
}
|
|
937
|
+
getClonedCssTextIfAvailable(href) {
|
|
938
|
+
if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
|
|
939
|
+
console.log(
|
|
940
|
+
"AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText!"
|
|
941
|
+
);
|
|
942
|
+
return this.clones[href].cssText;
|
|
943
|
+
}
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
__publicField$1(_AsyncStylesheetManager$1, "instance");
|
|
948
|
+
let AsyncStylesheetManager$1 = _AsyncStylesheetManager$1;
|
|
949
|
+
const asyncStylesheetManager = new AsyncStylesheetManager$1();
|
|
847
950
|
let _id = 1;
|
|
848
951
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
849
952
|
const IGNORED_NODE = -2;
|
|
@@ -955,7 +1058,7 @@ function transformAttribute(doc, tagName, name, value) {
|
|
|
955
1058
|
} else if (name === "srcset") {
|
|
956
1059
|
return getAbsoluteSrcsetString(doc, value);
|
|
957
1060
|
} else if (name === "style") {
|
|
958
|
-
return absolutifyURLs(value, getHref(doc));
|
|
1061
|
+
return absolutifyURLs$1(value, getHref(doc));
|
|
959
1062
|
} else if (tagName === "object" && name === "data") {
|
|
960
1063
|
return absoluteToDoc(doc, value);
|
|
961
1064
|
}
|
|
@@ -1192,7 +1295,7 @@ function serializeTextNode(n2, options) {
|
|
|
1192
1295
|
} else if (!cssCaptured) {
|
|
1193
1296
|
textContent2 = index.textContent(n2);
|
|
1194
1297
|
if (isStyle && textContent2) {
|
|
1195
|
-
textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
|
|
1298
|
+
textContent2 = absolutifyURLs$1(textContent2, getHref(options.doc));
|
|
1196
1299
|
}
|
|
1197
1300
|
}
|
|
1198
1301
|
if (!isStyle && !isScript && textContent2 && needsMask) {
|
|
@@ -1235,21 +1338,36 @@ function serializeElementNode(n2, options) {
|
|
|
1235
1338
|
}
|
|
1236
1339
|
}
|
|
1237
1340
|
if (tagName === "link" && inlineStylesheet) {
|
|
1238
|
-
const
|
|
1341
|
+
const styleSheets2 = Array.from(doc.styleSheets);
|
|
1342
|
+
const styleSheetIndex = styleSheets2.findIndex((s2) => {
|
|
1239
1343
|
return s2.href === n2.href;
|
|
1240
1344
|
});
|
|
1345
|
+
const stylesheet = styleSheets2[styleSheetIndex];
|
|
1241
1346
|
let cssText = null;
|
|
1242
1347
|
if (stylesheet) {
|
|
1243
|
-
cssText = stringifyStylesheet(stylesheet);
|
|
1348
|
+
cssText = stringifyStylesheet$1(stylesheet);
|
|
1349
|
+
}
|
|
1350
|
+
if (!cssText) {
|
|
1351
|
+
cssText = asyncStylesheetManager.getClonedCssTextIfAvailable(
|
|
1352
|
+
n2.href
|
|
1353
|
+
);
|
|
1244
1354
|
}
|
|
1245
1355
|
if (cssText) {
|
|
1246
1356
|
delete attributes.rel;
|
|
1247
1357
|
delete attributes.href;
|
|
1248
1358
|
attributes._cssText = cssText;
|
|
1359
|
+
} else {
|
|
1360
|
+
console.log(
|
|
1361
|
+
"missing cssText on first passthrough for href:",
|
|
1362
|
+
n2.href
|
|
1363
|
+
);
|
|
1364
|
+
asyncStylesheetManager.registerClone({
|
|
1365
|
+
forElement: n2
|
|
1366
|
+
});
|
|
1249
1367
|
}
|
|
1250
1368
|
}
|
|
1251
1369
|
if (tagName === "style" && n2.sheet) {
|
|
1252
|
-
let cssText = stringifyStylesheet(
|
|
1370
|
+
let cssText = stringifyStylesheet$1(
|
|
1253
1371
|
n2.sheet
|
|
1254
1372
|
);
|
|
1255
1373
|
if (cssText) {
|
|
@@ -5403,6 +5521,241 @@ postcss$1$1.Node;
|
|
|
5403
5521
|
var __defProp22 = Object.defineProperty;
|
|
5404
5522
|
var __defNormalProp22 = (obj, key, value) => key in obj ? __defProp22(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5405
5523
|
var __publicField2 = (obj, key, value) => __defNormalProp22(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5524
|
+
var __defProp222 = Object.defineProperty;
|
|
5525
|
+
var __defNormalProp222 = (obj, key, value) => key in obj ? __defProp222(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5526
|
+
var __publicField22 = (obj, key, value) => __defNormalProp222(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5527
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
5528
|
+
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
|
|
5529
|
+
cssText = cssText.replace(
|
|
5530
|
+
/\sbackground-clip:\s*text;/g,
|
|
5531
|
+
" -webkit-background-clip: text; background-clip: text;"
|
|
5532
|
+
);
|
|
5533
|
+
}
|
|
5534
|
+
return cssText;
|
|
5535
|
+
}
|
|
5536
|
+
function escapeImportStatement(rule2) {
|
|
5537
|
+
const { cssText } = rule2;
|
|
5538
|
+
if (cssText.split('"').length < 3) return cssText;
|
|
5539
|
+
const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
|
|
5540
|
+
if (rule2.layerName === "") {
|
|
5541
|
+
statement.push(`layer`);
|
|
5542
|
+
} else if (rule2.layerName) {
|
|
5543
|
+
statement.push(`layer(${rule2.layerName})`);
|
|
5544
|
+
}
|
|
5545
|
+
if (rule2.supportsText) {
|
|
5546
|
+
statement.push(`supports(${rule2.supportsText})`);
|
|
5547
|
+
}
|
|
5548
|
+
if (rule2.media.length) {
|
|
5549
|
+
statement.push(rule2.media.mediaText);
|
|
5550
|
+
}
|
|
5551
|
+
return statement.join(" ") + ";";
|
|
5552
|
+
}
|
|
5553
|
+
function stringifyStylesheet(s2) {
|
|
5554
|
+
try {
|
|
5555
|
+
const rules2 = s2.rules || s2.cssRules;
|
|
5556
|
+
if (!rules2) {
|
|
5557
|
+
return null;
|
|
5558
|
+
}
|
|
5559
|
+
let sheetHref = s2.href;
|
|
5560
|
+
if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
|
|
5561
|
+
sheetHref = s2.ownerNode.ownerDocument.location.href;
|
|
5562
|
+
}
|
|
5563
|
+
const stringifiedRules = Array.from(
|
|
5564
|
+
rules2,
|
|
5565
|
+
(rule2) => stringifyRule(rule2, sheetHref)
|
|
5566
|
+
).join("");
|
|
5567
|
+
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
5568
|
+
} catch (error) {
|
|
5569
|
+
console.log("stringifyStylesheet error:", error);
|
|
5570
|
+
return null;
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5573
|
+
function stringifyRule(rule2, sheetHref) {
|
|
5574
|
+
if (isCSSImportRule(rule2)) {
|
|
5575
|
+
let importStringified;
|
|
5576
|
+
try {
|
|
5577
|
+
importStringified = // for same-origin stylesheets,
|
|
5578
|
+
// we can access the imported stylesheet rules directly
|
|
5579
|
+
stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
|
|
5580
|
+
escapeImportStatement(rule2);
|
|
5581
|
+
} catch (error) {
|
|
5582
|
+
importStringified = rule2.cssText;
|
|
5583
|
+
}
|
|
5584
|
+
if (rule2.styleSheet.href) {
|
|
5585
|
+
return absolutifyURLs(importStringified, rule2.styleSheet.href);
|
|
5586
|
+
}
|
|
5587
|
+
return importStringified;
|
|
5588
|
+
} else {
|
|
5589
|
+
let ruleStringified = rule2.cssText;
|
|
5590
|
+
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
5591
|
+
ruleStringified = fixSafariColons(ruleStringified);
|
|
5592
|
+
}
|
|
5593
|
+
if (sheetHref) {
|
|
5594
|
+
return absolutifyURLs(ruleStringified, sheetHref);
|
|
5595
|
+
}
|
|
5596
|
+
return ruleStringified;
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
function fixSafariColons(cssStringified) {
|
|
5600
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
5601
|
+
return cssStringified.replace(regex, "$1\\$2");
|
|
5602
|
+
}
|
|
5603
|
+
function isCSSImportRule(rule2) {
|
|
5604
|
+
return "styleSheet" in rule2;
|
|
5605
|
+
}
|
|
5606
|
+
function isCSSStyleRule(rule2) {
|
|
5607
|
+
return "selectorText" in rule2;
|
|
5608
|
+
}
|
|
5609
|
+
function extractOrigin(url) {
|
|
5610
|
+
let origin = "";
|
|
5611
|
+
if (url.indexOf("//") > -1) {
|
|
5612
|
+
origin = url.split("/").slice(0, 3).join("/");
|
|
5613
|
+
} else {
|
|
5614
|
+
origin = url.split("/")[0];
|
|
5615
|
+
}
|
|
5616
|
+
origin = origin.split("?")[0];
|
|
5617
|
+
return origin;
|
|
5618
|
+
}
|
|
5619
|
+
const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
5620
|
+
const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
|
|
5621
|
+
const URL_WWW_MATCH = /^www\..*/i;
|
|
5622
|
+
const DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
5623
|
+
function absolutifyURLs(cssText, href) {
|
|
5624
|
+
return (cssText || "").replace(
|
|
5625
|
+
URL_IN_CSS_REF,
|
|
5626
|
+
(origin, quote1, path1, quote2, path2, path3) => {
|
|
5627
|
+
const filePath = path1 || path2 || path3;
|
|
5628
|
+
const maybeQuote = quote1 || quote2 || "";
|
|
5629
|
+
if (!filePath) {
|
|
5630
|
+
return origin;
|
|
5631
|
+
}
|
|
5632
|
+
if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
|
|
5633
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
5634
|
+
}
|
|
5635
|
+
if (DATA_URI.test(filePath)) {
|
|
5636
|
+
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
5637
|
+
}
|
|
5638
|
+
if (filePath[0] === "/") {
|
|
5639
|
+
return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
|
|
5640
|
+
}
|
|
5641
|
+
const stack = href.split("/");
|
|
5642
|
+
const parts = filePath.split("/");
|
|
5643
|
+
stack.pop();
|
|
5644
|
+
for (const part of parts) {
|
|
5645
|
+
if (part === ".") {
|
|
5646
|
+
continue;
|
|
5647
|
+
} else if (part === "..") {
|
|
5648
|
+
stack.pop();
|
|
5649
|
+
} else {
|
|
5650
|
+
stack.push(part);
|
|
5651
|
+
}
|
|
5652
|
+
}
|
|
5653
|
+
return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
|
|
5654
|
+
}
|
|
5655
|
+
);
|
|
5656
|
+
}
|
|
5657
|
+
const CLEANUP_DEBOUNCE_TIME = 1e3 * 60 * 5;
|
|
5658
|
+
const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
|
|
5659
|
+
constructor() {
|
|
5660
|
+
__publicField22(this, "currentHref", null);
|
|
5661
|
+
__publicField22(this, "clones", {});
|
|
5662
|
+
__publicField22(this, "cleanTimeout", null);
|
|
5663
|
+
if (_AsyncStylesheetManager22.instance) return _AsyncStylesheetManager22.instance;
|
|
5664
|
+
_AsyncStylesheetManager22.instance = this;
|
|
5665
|
+
}
|
|
5666
|
+
onLoad(href) {
|
|
5667
|
+
if (!(href in this.clones) || this.clones[href] === void 0) return;
|
|
5668
|
+
console.log("AsyncStylesheetManager, onLoad: href:", href);
|
|
5669
|
+
const styleSheets2 = Array.from(document.styleSheets);
|
|
5670
|
+
let clonedStyleSheet = null;
|
|
5671
|
+
document.head.removeChild(this.clones[href].clone);
|
|
5672
|
+
for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
|
|
5673
|
+
if (styleSheets2[i2].href === href) {
|
|
5674
|
+
clonedStyleSheet = styleSheets2[i2];
|
|
5675
|
+
break;
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
if (!clonedStyleSheet) return;
|
|
5679
|
+
const newCssText = stringifyStylesheet(clonedStyleSheet);
|
|
5680
|
+
if (!newCssText) return;
|
|
5681
|
+
console.log(
|
|
5682
|
+
"AsyncStylesheetManager, onLoad: success! did get new css text! forcing mutation..."
|
|
5683
|
+
);
|
|
5684
|
+
this.clones[href].cssText = newCssText;
|
|
5685
|
+
this.clones[href].loaded = true;
|
|
5686
|
+
this.clones[href].original.setAttribute(
|
|
5687
|
+
"data-rrweb-mutation",
|
|
5688
|
+
Date.now().toString()
|
|
5689
|
+
);
|
|
5690
|
+
}
|
|
5691
|
+
onLoadError(href) {
|
|
5692
|
+
if (!(href in this.clones) || this.clones[href] === void 0) return;
|
|
5693
|
+
document.head.removeChild(this.clones[href].clone);
|
|
5694
|
+
}
|
|
5695
|
+
removeAllCloneElements() {
|
|
5696
|
+
for (const clone of Object.values(this.clones)) {
|
|
5697
|
+
if (!clone) continue;
|
|
5698
|
+
document.head.removeChild(clone.clone);
|
|
5699
|
+
}
|
|
5700
|
+
}
|
|
5701
|
+
onCleanTimeout() {
|
|
5702
|
+
console.log("AsyncStylesheetManager, onCleanTimeout: cleaning up");
|
|
5703
|
+
this.cleanTimeout = null;
|
|
5704
|
+
this.removeAllCloneElements();
|
|
5705
|
+
}
|
|
5706
|
+
blowCache() {
|
|
5707
|
+
console.log("AsyncStylesheetManager, blowCache: blowing cache");
|
|
5708
|
+
this.clones = {};
|
|
5709
|
+
this.removeAllCloneElements();
|
|
5710
|
+
}
|
|
5711
|
+
registerClone({ forElement }) {
|
|
5712
|
+
if (this.currentHref != null && document.location.href !== this.currentHref)
|
|
5713
|
+
this.blowCache();
|
|
5714
|
+
this.currentHref = document.location.href;
|
|
5715
|
+
const href = forElement.href;
|
|
5716
|
+
console.log(
|
|
5717
|
+
"AsyncStylesheetManager, registerClone: wants a clone for href:",
|
|
5718
|
+
href
|
|
5719
|
+
);
|
|
5720
|
+
if (!href) return;
|
|
5721
|
+
if (href in this.clones && this.clones[href] !== void 0) return;
|
|
5722
|
+
if (forElement.getAttribute("crossorigin") === "anonymous") return;
|
|
5723
|
+
console.log(
|
|
5724
|
+
"AsyncStylesheetManager, registerClone: registering clone for href:",
|
|
5725
|
+
href
|
|
5726
|
+
);
|
|
5727
|
+
const clone = forElement.cloneNode();
|
|
5728
|
+
clone.setAttribute("crossorigin", "anonymous");
|
|
5729
|
+
clone.setAttribute("data-rrweb-link-cloned", "true");
|
|
5730
|
+
document.head.appendChild(clone);
|
|
5731
|
+
this.clones[href] = {
|
|
5732
|
+
original: forElement,
|
|
5733
|
+
clone,
|
|
5734
|
+
loaded: false,
|
|
5735
|
+
cssText: null
|
|
5736
|
+
};
|
|
5737
|
+
clone.onload = () => {
|
|
5738
|
+
this.onLoad(href);
|
|
5739
|
+
};
|
|
5740
|
+
clone.onerror = () => {
|
|
5741
|
+
this.onLoadError(href);
|
|
5742
|
+
};
|
|
5743
|
+
if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
|
|
5744
|
+
this.cleanTimeout = setTimeout(this.onCleanTimeout, CLEANUP_DEBOUNCE_TIME);
|
|
5745
|
+
}
|
|
5746
|
+
getClonedCssTextIfAvailable(href) {
|
|
5747
|
+
if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
|
|
5748
|
+
console.log(
|
|
5749
|
+
"AsyncStylesheetManager, getClonedCssTextIfAvailable: returning cloned cssText!"
|
|
5750
|
+
);
|
|
5751
|
+
return this.clones[href].cssText;
|
|
5752
|
+
}
|
|
5753
|
+
return null;
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
__publicField22(_AsyncStylesheetManager2, "instance");
|
|
5757
|
+
let AsyncStylesheetManager = _AsyncStylesheetManager2;
|
|
5758
|
+
new AsyncStylesheetManager();
|
|
5406
5759
|
function getDefaultExportFromCjs(x2) {
|
|
5407
5760
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
5408
5761
|
}
|
|
@@ -12158,7 +12511,7 @@ class StylesheetManager {
|
|
|
12158
12511
|
styles.push({
|
|
12159
12512
|
styleId,
|
|
12160
12513
|
rules: Array.from(sheet.rules || CSSRule, (r2, index2) => ({
|
|
12161
|
-
rule: stringifyRule(r2, sheet.href),
|
|
12514
|
+
rule: stringifyRule$1(r2, sheet.href),
|
|
12162
12515
|
index: index2
|
|
12163
12516
|
}))
|
|
12164
12517
|
});
|