@impakers/debug 1.4.7 → 1.4.8
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/react.js +48 -46
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +48 -46
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1569,59 +1569,61 @@ function findNearestComponentSource(element, maxAncestors = 10) {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
|
|
1571
1571
|
// src/utils/capture-element.ts
|
|
1572
|
-
var UNSUPPORTED_RE =
|
|
1572
|
+
var UNSUPPORTED_RE = /\b(?:oklab|oklch|color-mix|(?<![\w-])lab|(?<![\w-])lch)\s*\(/i;
|
|
1573
|
+
var COLOR_PROPS = [
|
|
1574
|
+
"color",
|
|
1575
|
+
"background-color",
|
|
1576
|
+
"background-image",
|
|
1577
|
+
"background",
|
|
1578
|
+
"border-color",
|
|
1579
|
+
"border-top-color",
|
|
1580
|
+
"border-right-color",
|
|
1581
|
+
"border-bottom-color",
|
|
1582
|
+
"border-left-color",
|
|
1583
|
+
"outline-color",
|
|
1584
|
+
"text-decoration-color",
|
|
1585
|
+
"box-shadow",
|
|
1586
|
+
"text-shadow",
|
|
1587
|
+
"caret-color",
|
|
1588
|
+
"column-rule-color",
|
|
1589
|
+
"fill",
|
|
1590
|
+
"stroke",
|
|
1591
|
+
"stop-color",
|
|
1592
|
+
"flood-color",
|
|
1593
|
+
"lighting-color"
|
|
1594
|
+
];
|
|
1573
1595
|
function sanitizeUnsupportedColors(clonedDoc) {
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1596
|
+
const allEls = clonedDoc.querySelectorAll("*");
|
|
1597
|
+
for (let i = 0; i < allEls.length; i++) {
|
|
1598
|
+
const el = allEls[i];
|
|
1599
|
+
if (!el.style) continue;
|
|
1600
|
+
let cs = null;
|
|
1601
|
+
for (const prop of COLOR_PROPS) {
|
|
1602
|
+
const inlineVal = el.style.getPropertyValue(prop);
|
|
1603
|
+
if (inlineVal && UNSUPPORTED_RE.test(inlineVal)) {
|
|
1604
|
+
el.style.setProperty(prop, getFallback(prop));
|
|
1605
|
+
continue;
|
|
1582
1606
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
if (UNSUPPORTED_RE.test(text)) {
|
|
1589
|
-
styleEl.textContent = text.replace(
|
|
1590
|
-
/[^{};\n]+:\s*[^;{}]*(?:oklab|oklch|color-mix|lch|lab)\([^)]*(?:\([^)]*\))*[^)]*\)[^;{}]*/gi,
|
|
1591
|
-
""
|
|
1592
|
-
);
|
|
1593
|
-
}
|
|
1594
|
-
});
|
|
1595
|
-
clonedDoc.querySelectorAll("*").forEach((el) => {
|
|
1596
|
-
const s = el.style;
|
|
1597
|
-
if (!s?.cssText) return;
|
|
1598
|
-
if (UNSUPPORTED_RE.test(s.cssText)) {
|
|
1599
|
-
s.cssText = s.cssText.replace(
|
|
1600
|
-
/[^;]*(?:oklab|oklch|color-mix|lch|lab)\([^)]*(?:\([^)]*\))*[^)]*\)[^;]*/gi,
|
|
1601
|
-
""
|
|
1602
|
-
);
|
|
1603
|
-
}
|
|
1604
|
-
});
|
|
1605
|
-
}
|
|
1606
|
-
function sanitizeCSSRules(sheet, rules) {
|
|
1607
|
-
for (let j = rules.length - 1; j >= 0; j--) {
|
|
1608
|
-
const rule = rules[j];
|
|
1609
|
-
if ("cssRules" in rule && rule.cssRules) {
|
|
1610
|
-
sanitizeCSSRules(sheet, rule.cssRules);
|
|
1611
|
-
continue;
|
|
1612
|
-
}
|
|
1613
|
-
if (rule instanceof CSSStyleRule) {
|
|
1614
|
-
const style = rule.style;
|
|
1615
|
-
for (let k = style.length - 1; k >= 0; k--) {
|
|
1616
|
-
const prop = style[k];
|
|
1617
|
-
const val = style.getPropertyValue(prop);
|
|
1618
|
-
if (UNSUPPORTED_RE.test(val)) {
|
|
1619
|
-
style.setProperty(prop, "transparent");
|
|
1607
|
+
if (!cs) {
|
|
1608
|
+
try {
|
|
1609
|
+
cs = clonedDoc.defaultView.getComputedStyle(el);
|
|
1610
|
+
} catch {
|
|
1611
|
+
break;
|
|
1620
1612
|
}
|
|
1621
1613
|
}
|
|
1614
|
+
const val = cs.getPropertyValue(prop);
|
|
1615
|
+
if (val && UNSUPPORTED_RE.test(val)) {
|
|
1616
|
+
el.style.setProperty(prop, getFallback(prop));
|
|
1617
|
+
}
|
|
1622
1618
|
}
|
|
1623
1619
|
}
|
|
1624
1620
|
}
|
|
1621
|
+
function getFallback(prop) {
|
|
1622
|
+
if (prop === "background-image" || prop === "background") return "none";
|
|
1623
|
+
if (prop === "box-shadow" || prop === "text-shadow") return "none";
|
|
1624
|
+
if (prop === "color") return "inherit";
|
|
1625
|
+
return "transparent";
|
|
1626
|
+
}
|
|
1625
1627
|
async function captureElement(el, options = {}) {
|
|
1626
1628
|
const { quality = 0.7, maxScale = 2 } = options;
|
|
1627
1629
|
const html2canvas = (await import("html2canvas")).default;
|