@hyperframes/inspector 0.8.158 → 0.8.160
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/inspection.js +42 -1
- package/dist/service.js +138 -28
- package/package.json +3 -3
package/dist/inspection.js
CHANGED
|
@@ -1783,6 +1783,45 @@
|
|
|
1783
1783
|
"reversed",
|
|
1784
1784
|
"defaults"
|
|
1785
1785
|
]);
|
|
1786
|
+
var PAGE_RESET = /* @__PURE__ */ new Set(["*", "html", "body", ":root", "html *", "body *", ":root *", "* *"]);
|
|
1787
|
+
function selectorAlternatives(selector) {
|
|
1788
|
+
const parts = [];
|
|
1789
|
+
let depth = 0;
|
|
1790
|
+
let quote;
|
|
1791
|
+
let start = 0;
|
|
1792
|
+
for (let i = 0; i < selector.length; i += 1) {
|
|
1793
|
+
const ch = selector[i];
|
|
1794
|
+
if (ch === "\\") {
|
|
1795
|
+
i += 1;
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
if (quote) {
|
|
1799
|
+
if (ch === quote) quote = void 0;
|
|
1800
|
+
continue;
|
|
1801
|
+
}
|
|
1802
|
+
if (ch === '"' || ch === "'") {
|
|
1803
|
+
quote = ch;
|
|
1804
|
+
continue;
|
|
1805
|
+
}
|
|
1806
|
+
if (ch === "/" && selector[i + 1] === "*") {
|
|
1807
|
+
const end = selector.indexOf("*/", i + 2);
|
|
1808
|
+
i = end < 0 ? selector.length : end + 1;
|
|
1809
|
+
continue;
|
|
1810
|
+
}
|
|
1811
|
+
if (ch === "(" || ch === "[") depth += 1;
|
|
1812
|
+
else if (ch === ")" || ch === "]") depth = Math.max(0, depth - 1);
|
|
1813
|
+
else if (ch === "," && depth === 0) {
|
|
1814
|
+
parts.push(selector.slice(start, i));
|
|
1815
|
+
start = i + 1;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
parts.push(selector.slice(start));
|
|
1819
|
+
return parts;
|
|
1820
|
+
}
|
|
1821
|
+
function authoredCssSelector(selector) {
|
|
1822
|
+
const specific = selectorAlternatives(selector).map((part) => part.trim()).filter((part) => part && !PAGE_RESET.has(part.replace(/\s+/g, " ").toLowerCase()));
|
|
1823
|
+
return specific.length > 0 ? specific.join(", ") : null;
|
|
1824
|
+
}
|
|
1786
1825
|
function installInspection(win, generation, limit = 2e4) {
|
|
1787
1826
|
const records = /* @__PURE__ */ new WeakMap();
|
|
1788
1827
|
const attachments = /* @__PURE__ */ new WeakMap();
|
|
@@ -1970,8 +2009,10 @@
|
|
|
1970
2009
|
};
|
|
1971
2010
|
});
|
|
1972
2011
|
const css = q.cssRules.filter((rule) => {
|
|
2012
|
+
const selector = authoredCssSelector(rule.selector);
|
|
2013
|
+
if (!selector) return false;
|
|
1973
2014
|
try {
|
|
1974
|
-
return scope.some((el) => el.matches(
|
|
2015
|
+
return scope.some((el) => el.matches(selector));
|
|
1975
2016
|
} catch {
|
|
1976
2017
|
return false;
|
|
1977
2018
|
}
|