@barocss/kit 0.8.0 → 0.8.1
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/index.cjs +18 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -659,6 +659,9 @@ function hasCommentDelimiter(text) {
|
|
|
659
659
|
}
|
|
660
660
|
return false;
|
|
661
661
|
}
|
|
662
|
+
function hasHtmlEndTagOpener(text) {
|
|
663
|
+
return text.includes("</");
|
|
664
|
+
}
|
|
662
665
|
function isStructureSafeValue(value) {
|
|
663
666
|
if (hasCommentToken(value)) return false;
|
|
664
667
|
return isSafeVariantValue(value, true);
|
|
@@ -806,8 +809,11 @@ function parseUtility(value, ctx) {
|
|
|
806
809
|
priority
|
|
807
810
|
};
|
|
808
811
|
}
|
|
809
|
-
const isSafePrelude = (text) =>
|
|
810
|
-
const
|
|
812
|
+
const isSafePrelude = (text) => {
|
|
813
|
+
const t = String(text ?? "");
|
|
814
|
+
return !hasCommentDelimiter(t) && !hasHtmlEndTagOpener(t);
|
|
815
|
+
};
|
|
816
|
+
const isSafeDecl = (prop, value) => isStructureSafeValue(String(prop)) && isStructureSafeValue(String(value ?? "")) && !hasHtmlEndTagOpener(String(prop)) && !hasHtmlEndTagOpener(String(value ?? ""));
|
|
811
817
|
const importantPrefix = "!important";
|
|
812
818
|
function astToCss(ast, baseSelector, opts, _indent = "") {
|
|
813
819
|
const minify = opts?.minify;
|
|
@@ -1111,7 +1117,7 @@ function animationToCssVars(animations) {
|
|
|
1111
1117
|
}
|
|
1112
1118
|
return result;
|
|
1113
1119
|
}
|
|
1114
|
-
const COMMENT_OR_BLOCK = /\/\*|\*\/|[{};]
|
|
1120
|
+
const COMMENT_OR_BLOCK = /\/\*|\*\/|[{};]|<\//;
|
|
1115
1121
|
function keyframesBlock(name, frames) {
|
|
1116
1122
|
if (!name || COMMENT_OR_BLOCK.test(name) || /\s/.test(name) || !frames || typeof frames !== "object") return "";
|
|
1117
1123
|
let body = "";
|
|
@@ -1229,8 +1235,15 @@ function isSelfReferencingVar(name, value) {
|
|
|
1229
1235
|
const m = /^var\(\s*(--[\w-]+)\s*(?:,[\s\S]*)?\)$/.exec(value.trim());
|
|
1230
1236
|
return !!m && m[1] === name.trim();
|
|
1231
1237
|
}
|
|
1238
|
+
const SAFE_VAR_NAME = /^--(?:[\w-]|\\\.)+$/;
|
|
1239
|
+
function isSafeThemeVar(name, value) {
|
|
1240
|
+
if (typeof name !== "string" || !SAFE_VAR_NAME.test(name) || hasHtmlEndTagOpener(name)) return false;
|
|
1241
|
+
if (typeof value !== "string" && typeof value !== "number") return false;
|
|
1242
|
+
const v2 = String(value);
|
|
1243
|
+
return v2.trim() !== "" && isStructureSafeValue(v2) && !hasCommentDelimiter(v2) && !hasHtmlEndTagOpener(v2);
|
|
1244
|
+
}
|
|
1232
1245
|
function toCssVarsBlock(vars, extra = "") {
|
|
1233
|
-
return ":root,:host {\n" + Object.entries(vars).filter(([k, v2]) => !isSelfReferencingVar(k, v2)).map(([k, v2]) => ` ${k}: ${v2};`).join("\n") + "\n}\n" + extra + "\n";
|
|
1246
|
+
return ":root,:host {\n" + Object.entries(vars).filter(([k, v2]) => isSafeThemeVar(k, v2) && !isSelfReferencingVar(k, v2)).map(([k, v2]) => ` ${k}: ${v2};`).join("\n") + "\n}\n" + extra + "\n";
|
|
1234
1247
|
}
|
|
1235
1248
|
const BARO_VAR = /--baro-/g;
|
|
1236
1249
|
const PREFIXED_KEYS = /* @__PURE__ */ new Set(["prop", "value", "params", "selector", "nodes", "items"]);
|
|
@@ -8639,6 +8652,7 @@ exports.getPreflightCSS = getPreflightCSS;
|
|
|
8639
8652
|
exports.getUtility = getUtility;
|
|
8640
8653
|
exports.hasCommentDelimiter = hasCommentDelimiter;
|
|
8641
8654
|
exports.hasCommentToken = hasCommentToken;
|
|
8655
|
+
exports.hasHtmlEndTagOpener = hasHtmlEndTagOpener;
|
|
8642
8656
|
exports.hasPreset = hasPreset;
|
|
8643
8657
|
exports.isDebug = isDebug;
|
|
8644
8658
|
exports.isSafeVariantToken = isSafeVariantToken;
|