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