@csszyx/compiler 0.10.10 → 0.10.11
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 +55 -23
- package/dist/index.mjs +56 -24
- package/dist/shared/{compiler.mibv6qPF.cjs → compiler.dkTeNO_S.cjs} +12 -0
- package/dist/shared/{compiler.CghwJ6p5.mjs → compiler.zZfo8y65.mjs} +12 -0
- package/dist/transform-core.cjs +1 -1
- package/dist/transform-core.mjs +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const core = require('@csszyx/core');
|
|
4
|
-
const transformCore = require('./shared/compiler.
|
|
4
|
+
const transformCore = require('./shared/compiler.dkTeNO_S.cjs');
|
|
5
5
|
const oxcParser = require('oxc-parser');
|
|
6
6
|
const t = require('@babel/types');
|
|
7
7
|
const node_crypto = require('node:crypto');
|
|
@@ -789,22 +789,23 @@ function transformSourceCode(source, filename, options) {
|
|
|
789
789
|
transformed = true;
|
|
790
790
|
}
|
|
791
791
|
},
|
|
792
|
-
// ── dynamic() literal extraction
|
|
793
|
-
// Detects `dynamic({...})`
|
|
794
|
-
// with statically-analyzable arguments
|
|
795
|
-
// class tokens to collectedClasses so
|
|
796
|
-
// includes them in csszyx-classes.html
|
|
797
|
-
//
|
|
798
|
-
// without
|
|
792
|
+
// ── dynamic() / szr() literal extraction ─────────────────────────
|
|
793
|
+
// Detects `dynamic({...})` / `szr({...})` and their
|
|
794
|
+
// `(CONST_IDENTIFIER)` forms with statically-analyzable arguments
|
|
795
|
+
// and adds the resulting class tokens to collectedClasses so
|
|
796
|
+
// prescanAndWriteClasses() includes them in csszyx-classes.html
|
|
797
|
+
// for Tailwind to scan. A bare static `szr({...})` type-checks and
|
|
798
|
+
// resolves at runtime, so without this its classes were silently
|
|
799
|
+
// dead under Tailwind `source(none)`.
|
|
799
800
|
CallExpression(path) {
|
|
800
801
|
const callee = path.node.callee;
|
|
801
|
-
if (!t__namespace.isIdentifier(callee) || callee.name !== "dynamic") {
|
|
802
|
+
if (!t__namespace.isIdentifier(callee) || callee.name !== "dynamic" && callee.name !== "szr") {
|
|
802
803
|
return;
|
|
803
804
|
}
|
|
804
805
|
if (path.node.arguments.length === 0) {
|
|
805
806
|
return;
|
|
806
807
|
}
|
|
807
|
-
const arg = path.node.arguments[0];
|
|
808
|
+
const arg = unwrapTsExpression(path.node.arguments[0]);
|
|
808
809
|
if (t__namespace.isObjectExpression(arg)) {
|
|
809
810
|
const staticObj = evaluateStaticObject(arg);
|
|
810
811
|
if (!staticObj) {
|
|
@@ -818,10 +819,7 @@ function transformSourceCode(source, filename, options) {
|
|
|
818
819
|
}
|
|
819
820
|
return;
|
|
820
821
|
}
|
|
821
|
-
|
|
822
|
-
while (t__namespace.isTSAsExpression(argExpr) || t__namespace.isTSSatisfiesExpression(argExpr)) {
|
|
823
|
-
argExpr = argExpr.expression;
|
|
824
|
-
}
|
|
822
|
+
const argExpr = arg;
|
|
825
823
|
if (t__namespace.isIdentifier(argExpr)) {
|
|
826
824
|
const binding = path.scope.getBinding(argExpr.name);
|
|
827
825
|
if (!binding) {
|
|
@@ -1150,16 +1148,27 @@ function readStaticConfigObject(configExpr, key, scope) {
|
|
|
1150
1148
|
}
|
|
1151
1149
|
return null;
|
|
1152
1150
|
}
|
|
1151
|
+
function unwrapTsExpression(node) {
|
|
1152
|
+
let current = node;
|
|
1153
|
+
while (t__namespace.isTSSatisfiesExpression(current) || t__namespace.isTSAsExpression(current) || t__namespace.isTSNonNullExpression(current) || t__namespace.isParenthesizedExpression(current)) {
|
|
1154
|
+
current = current.expression;
|
|
1155
|
+
}
|
|
1156
|
+
return current;
|
|
1157
|
+
}
|
|
1153
1158
|
function resolveToConstObjectExpression(node, scope) {
|
|
1154
|
-
|
|
1155
|
-
|
|
1159
|
+
const unwrapped = unwrapTsExpression(node);
|
|
1160
|
+
if (t__namespace.isObjectExpression(unwrapped)) {
|
|
1161
|
+
return unwrapped;
|
|
1156
1162
|
}
|
|
1157
|
-
if (t__namespace.isIdentifier(
|
|
1158
|
-
const binding = scope.getBinding(
|
|
1163
|
+
if (t__namespace.isIdentifier(unwrapped)) {
|
|
1164
|
+
const binding = scope.getBinding(unwrapped.name);
|
|
1159
1165
|
if (binding?.kind === "const" && binding.constant) {
|
|
1160
1166
|
const declNode = binding.path.node;
|
|
1161
|
-
if (t__namespace.isVariableDeclarator(declNode)
|
|
1162
|
-
|
|
1167
|
+
if (t__namespace.isVariableDeclarator(declNode)) {
|
|
1168
|
+
const init = unwrapTsExpression(declNode.init);
|
|
1169
|
+
if (t__namespace.isObjectExpression(init)) {
|
|
1170
|
+
return init;
|
|
1171
|
+
}
|
|
1163
1172
|
}
|
|
1164
1173
|
}
|
|
1165
1174
|
}
|
|
@@ -1184,7 +1193,7 @@ function evaluateStaticObject(node) {
|
|
|
1184
1193
|
} else {
|
|
1185
1194
|
return null;
|
|
1186
1195
|
}
|
|
1187
|
-
const value = prop.value;
|
|
1196
|
+
const value = unwrapTsExpression(prop.value);
|
|
1188
1197
|
if (t__namespace.isStringLiteral(value)) {
|
|
1189
1198
|
result[key] = value.value;
|
|
1190
1199
|
} else if (t__namespace.isNumericLiteral(value)) {
|
|
@@ -2555,7 +2564,7 @@ function transformOxc(source, filename, options) {
|
|
|
2555
2564
|
const effectiveFilename = filename ?? "file.tsx";
|
|
2556
2565
|
transformCore.setSzWarnLocation(void 0);
|
|
2557
2566
|
const astBudget = options?.astBudget ?? AST_BUDGET;
|
|
2558
|
-
const parsed = oxcParser.parseSync(effectiveFilename, source);
|
|
2567
|
+
const parsed = /\.(?:js|mjs|cjs)$/.test(effectiveFilename) ? oxcParser.parseSync(effectiveFilename, source, { lang: "jsx" }) : oxcParser.parseSync(effectiveFilename, source);
|
|
2559
2568
|
if (parsed.errors.length > 0) {
|
|
2560
2569
|
throw new Error(
|
|
2561
2570
|
`oxc-parser errors in ${effectiveFilename}: ` + parsed.errors.map((e) => e.message).join("; ")
|
|
@@ -3132,6 +3141,24 @@ function transformOxc(source, filename, options) {
|
|
|
3132
3141
|
];
|
|
3133
3142
|
const mergedAttr = mergedClasses.length === 0 ? "className={undefined}" : `className="${mergedClasses.join(" ")}"`;
|
|
3134
3143
|
if (classNameAttr) {
|
|
3144
|
+
const classNameValue = classNameAttr.value;
|
|
3145
|
+
if (existingRaw === null && classNameValue && classNameValue.type === "JSXExpressionContainer") {
|
|
3146
|
+
const exprNode = classNameValue.expression;
|
|
3147
|
+
const exprSource = source.slice(exprNode.start, exprNode.end);
|
|
3148
|
+
edits.overwrite(
|
|
3149
|
+
classNameAttr.start,
|
|
3150
|
+
classNameAttr.end,
|
|
3151
|
+
`className={_szMerge(${exprSource}, ${JSON.stringify(szDerived.join(" "))})}`
|
|
3152
|
+
);
|
|
3153
|
+
for (const szAttr of szAttrs) {
|
|
3154
|
+
const deleteStart = whitespaceStart(source, szAttr.start);
|
|
3155
|
+
edits.remove(deleteStart, szAttr.end);
|
|
3156
|
+
}
|
|
3157
|
+
usesRuntime = true;
|
|
3158
|
+
usesMerge = true;
|
|
3159
|
+
transformed = true;
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3135
3162
|
edits.overwrite(classNameAttr.start, classNameAttr.end, mergedAttr);
|
|
3136
3163
|
for (const szAttr of szAttrs) {
|
|
3137
3164
|
const deleteStart = whitespaceStart(source, szAttr.start);
|
|
@@ -3645,7 +3672,11 @@ function assertAstBudget(root, filename, astBudget) {
|
|
|
3645
3672
|
});
|
|
3646
3673
|
}
|
|
3647
3674
|
function collectDynamicCallClasses(node, filename, bindings, classes) {
|
|
3648
|
-
if (node.callee.type !== "Identifier"
|
|
3675
|
+
if (node.callee.type !== "Identifier") {
|
|
3676
|
+
return;
|
|
3677
|
+
}
|
|
3678
|
+
const calleeName = node.callee.name;
|
|
3679
|
+
if (calleeName !== "dynamic" && calleeName !== "szr") {
|
|
3649
3680
|
return;
|
|
3650
3681
|
}
|
|
3651
3682
|
const [firstArg] = node.arguments;
|
|
@@ -4621,6 +4652,7 @@ function extractKeyName(key) {
|
|
|
4621
4652
|
return null;
|
|
4622
4653
|
}
|
|
4623
4654
|
function astValueToSzValue(node, filename, bindings, branchPick) {
|
|
4655
|
+
node = unwrapExpression(node);
|
|
4624
4656
|
if (branchPick && node.type === "ConditionalExpression") {
|
|
4625
4657
|
return astValueToSzValue(
|
|
4626
4658
|
node[branchPick],
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { init, version, transform_sz, encode } from '@csszyx/core';
|
|
2
|
-
import { t as transform, s as setSzWarnLocation, f as formatSzWarnLocation, C as COLOR_PROPERTIES, P as PROPERTY_MAP, g as getCSSVariableName, a as PropertyCategory, K as KNOWN_VARIANTS, b as getVariantPrefix, c as getPropertyCategory, d as stripInvalidColorStrings } from './shared/compiler.
|
|
3
|
-
export { B as BOOLEAN_SHORTHANDS, e as PROPERTY_CATEGORY_MAP, R as REMOVED_BOOLEAN_SUGAR, S as SPECIAL_VARIANTS, h as SUGGESTION_MAP, i as isValidSzProp, n as normalizeClassName } from './shared/compiler.
|
|
2
|
+
import { t as transform, s as setSzWarnLocation, f as formatSzWarnLocation, C as COLOR_PROPERTIES, P as PROPERTY_MAP, g as getCSSVariableName, a as PropertyCategory, K as KNOWN_VARIANTS, b as getVariantPrefix, c as getPropertyCategory, d as stripInvalidColorStrings } from './shared/compiler.zZfo8y65.mjs';
|
|
3
|
+
export { B as BOOLEAN_SHORTHANDS, e as PROPERTY_CATEGORY_MAP, R as REMOVED_BOOLEAN_SUGAR, S as SPECIAL_VARIANTS, h as SUGGESTION_MAP, i as isValidSzProp, n as normalizeClassName } from './shared/compiler.zZfo8y65.mjs';
|
|
4
4
|
import { parseSync } from 'oxc-parser';
|
|
5
5
|
import * as t from '@babel/types';
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
@@ -770,22 +770,23 @@ function transformSourceCode(source, filename, options) {
|
|
|
770
770
|
transformed = true;
|
|
771
771
|
}
|
|
772
772
|
},
|
|
773
|
-
// ── dynamic() literal extraction
|
|
774
|
-
// Detects `dynamic({...})`
|
|
775
|
-
// with statically-analyzable arguments
|
|
776
|
-
// class tokens to collectedClasses so
|
|
777
|
-
// includes them in csszyx-classes.html
|
|
778
|
-
//
|
|
779
|
-
// without
|
|
773
|
+
// ── dynamic() / szr() literal extraction ─────────────────────────
|
|
774
|
+
// Detects `dynamic({...})` / `szr({...})` and their
|
|
775
|
+
// `(CONST_IDENTIFIER)` forms with statically-analyzable arguments
|
|
776
|
+
// and adds the resulting class tokens to collectedClasses so
|
|
777
|
+
// prescanAndWriteClasses() includes them in csszyx-classes.html
|
|
778
|
+
// for Tailwind to scan. A bare static `szr({...})` type-checks and
|
|
779
|
+
// resolves at runtime, so without this its classes were silently
|
|
780
|
+
// dead under Tailwind `source(none)`.
|
|
780
781
|
CallExpression(path) {
|
|
781
782
|
const callee = path.node.callee;
|
|
782
|
-
if (!t.isIdentifier(callee) || callee.name !== "dynamic") {
|
|
783
|
+
if (!t.isIdentifier(callee) || callee.name !== "dynamic" && callee.name !== "szr") {
|
|
783
784
|
return;
|
|
784
785
|
}
|
|
785
786
|
if (path.node.arguments.length === 0) {
|
|
786
787
|
return;
|
|
787
788
|
}
|
|
788
|
-
const arg = path.node.arguments[0];
|
|
789
|
+
const arg = unwrapTsExpression(path.node.arguments[0]);
|
|
789
790
|
if (t.isObjectExpression(arg)) {
|
|
790
791
|
const staticObj = evaluateStaticObject(arg);
|
|
791
792
|
if (!staticObj) {
|
|
@@ -799,10 +800,7 @@ function transformSourceCode(source, filename, options) {
|
|
|
799
800
|
}
|
|
800
801
|
return;
|
|
801
802
|
}
|
|
802
|
-
|
|
803
|
-
while (t.isTSAsExpression(argExpr) || t.isTSSatisfiesExpression(argExpr)) {
|
|
804
|
-
argExpr = argExpr.expression;
|
|
805
|
-
}
|
|
803
|
+
const argExpr = arg;
|
|
806
804
|
if (t.isIdentifier(argExpr)) {
|
|
807
805
|
const binding = path.scope.getBinding(argExpr.name);
|
|
808
806
|
if (!binding) {
|
|
@@ -1131,16 +1129,27 @@ function readStaticConfigObject(configExpr, key, scope) {
|
|
|
1131
1129
|
}
|
|
1132
1130
|
return null;
|
|
1133
1131
|
}
|
|
1132
|
+
function unwrapTsExpression(node) {
|
|
1133
|
+
let current = node;
|
|
1134
|
+
while (t.isTSSatisfiesExpression(current) || t.isTSAsExpression(current) || t.isTSNonNullExpression(current) || t.isParenthesizedExpression(current)) {
|
|
1135
|
+
current = current.expression;
|
|
1136
|
+
}
|
|
1137
|
+
return current;
|
|
1138
|
+
}
|
|
1134
1139
|
function resolveToConstObjectExpression(node, scope) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1140
|
+
const unwrapped = unwrapTsExpression(node);
|
|
1141
|
+
if (t.isObjectExpression(unwrapped)) {
|
|
1142
|
+
return unwrapped;
|
|
1137
1143
|
}
|
|
1138
|
-
if (t.isIdentifier(
|
|
1139
|
-
const binding = scope.getBinding(
|
|
1144
|
+
if (t.isIdentifier(unwrapped)) {
|
|
1145
|
+
const binding = scope.getBinding(unwrapped.name);
|
|
1140
1146
|
if (binding?.kind === "const" && binding.constant) {
|
|
1141
1147
|
const declNode = binding.path.node;
|
|
1142
|
-
if (t.isVariableDeclarator(declNode)
|
|
1143
|
-
|
|
1148
|
+
if (t.isVariableDeclarator(declNode)) {
|
|
1149
|
+
const init = unwrapTsExpression(declNode.init);
|
|
1150
|
+
if (t.isObjectExpression(init)) {
|
|
1151
|
+
return init;
|
|
1152
|
+
}
|
|
1144
1153
|
}
|
|
1145
1154
|
}
|
|
1146
1155
|
}
|
|
@@ -1165,7 +1174,7 @@ function evaluateStaticObject(node) {
|
|
|
1165
1174
|
} else {
|
|
1166
1175
|
return null;
|
|
1167
1176
|
}
|
|
1168
|
-
const value = prop.value;
|
|
1177
|
+
const value = unwrapTsExpression(prop.value);
|
|
1169
1178
|
if (t.isStringLiteral(value)) {
|
|
1170
1179
|
result[key] = value.value;
|
|
1171
1180
|
} else if (t.isNumericLiteral(value)) {
|
|
@@ -2536,7 +2545,7 @@ function transformOxc(source, filename, options) {
|
|
|
2536
2545
|
const effectiveFilename = filename ?? "file.tsx";
|
|
2537
2546
|
setSzWarnLocation(void 0);
|
|
2538
2547
|
const astBudget = options?.astBudget ?? AST_BUDGET;
|
|
2539
|
-
const parsed = parseSync(effectiveFilename, source);
|
|
2548
|
+
const parsed = /\.(?:js|mjs|cjs)$/.test(effectiveFilename) ? parseSync(effectiveFilename, source, { lang: "jsx" }) : parseSync(effectiveFilename, source);
|
|
2540
2549
|
if (parsed.errors.length > 0) {
|
|
2541
2550
|
throw new Error(
|
|
2542
2551
|
`oxc-parser errors in ${effectiveFilename}: ` + parsed.errors.map((e) => e.message).join("; ")
|
|
@@ -3113,6 +3122,24 @@ function transformOxc(source, filename, options) {
|
|
|
3113
3122
|
];
|
|
3114
3123
|
const mergedAttr = mergedClasses.length === 0 ? "className={undefined}" : `className="${mergedClasses.join(" ")}"`;
|
|
3115
3124
|
if (classNameAttr) {
|
|
3125
|
+
const classNameValue = classNameAttr.value;
|
|
3126
|
+
if (existingRaw === null && classNameValue && classNameValue.type === "JSXExpressionContainer") {
|
|
3127
|
+
const exprNode = classNameValue.expression;
|
|
3128
|
+
const exprSource = source.slice(exprNode.start, exprNode.end);
|
|
3129
|
+
edits.overwrite(
|
|
3130
|
+
classNameAttr.start,
|
|
3131
|
+
classNameAttr.end,
|
|
3132
|
+
`className={_szMerge(${exprSource}, ${JSON.stringify(szDerived.join(" "))})}`
|
|
3133
|
+
);
|
|
3134
|
+
for (const szAttr of szAttrs) {
|
|
3135
|
+
const deleteStart = whitespaceStart(source, szAttr.start);
|
|
3136
|
+
edits.remove(deleteStart, szAttr.end);
|
|
3137
|
+
}
|
|
3138
|
+
usesRuntime = true;
|
|
3139
|
+
usesMerge = true;
|
|
3140
|
+
transformed = true;
|
|
3141
|
+
return;
|
|
3142
|
+
}
|
|
3116
3143
|
edits.overwrite(classNameAttr.start, classNameAttr.end, mergedAttr);
|
|
3117
3144
|
for (const szAttr of szAttrs) {
|
|
3118
3145
|
const deleteStart = whitespaceStart(source, szAttr.start);
|
|
@@ -3626,7 +3653,11 @@ function assertAstBudget(root, filename, astBudget) {
|
|
|
3626
3653
|
});
|
|
3627
3654
|
}
|
|
3628
3655
|
function collectDynamicCallClasses(node, filename, bindings, classes) {
|
|
3629
|
-
if (node.callee.type !== "Identifier"
|
|
3656
|
+
if (node.callee.type !== "Identifier") {
|
|
3657
|
+
return;
|
|
3658
|
+
}
|
|
3659
|
+
const calleeName = node.callee.name;
|
|
3660
|
+
if (calleeName !== "dynamic" && calleeName !== "szr") {
|
|
3630
3661
|
return;
|
|
3631
3662
|
}
|
|
3632
3663
|
const [firstArg] = node.arguments;
|
|
@@ -4602,6 +4633,7 @@ function extractKeyName(key) {
|
|
|
4602
4633
|
return null;
|
|
4603
4634
|
}
|
|
4604
4635
|
function astValueToSzValue(node, filename, bindings, branchPick) {
|
|
4636
|
+
node = unwrapExpression(node);
|
|
4605
4637
|
if (branchPick && node.type === "ConditionalExpression") {
|
|
4606
4638
|
return astValueToSzValue(
|
|
4607
4639
|
node[branchPick],
|
|
@@ -1186,6 +1186,8 @@ function handleImportant(value) {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
return { value, important: false };
|
|
1188
1188
|
}
|
|
1189
|
+
const ALPHA_SAFE_NAMED_COLORS = /* @__PURE__ */ new Set(["white", "black", "transparent", "current", "inherit"]);
|
|
1190
|
+
const _warnedOpacityTokens = /* @__PURE__ */ new Set();
|
|
1189
1191
|
function formatOpacity(op) {
|
|
1190
1192
|
if (typeof op === "number") {
|
|
1191
1193
|
if (Number.isInteger(op * 2)) {
|
|
@@ -1649,6 +1651,13 @@ function transformImpl(szProp, prefix, mangleMap) {
|
|
|
1649
1651
|
const colorBase = rawColorBase.startsWith("--") ? `(${rawColorBase})` : needsArbitraryBrackets(rawColorBase) ? `[${normalizeArbitraryValue(rawColorBase)}]` : normalizeArbitraryValue(rawColorBase);
|
|
1650
1652
|
if (colorObj.op !== void 0) {
|
|
1651
1653
|
const opStr = formatOpacity(colorObj.op);
|
|
1654
|
+
if (process.env.NODE_ENV !== "production" && typeof window === "undefined" && !rawColorBase.startsWith("--") && !needsArbitraryBrackets(rawColorBase) && !/-\d{2,3}$/.test(rawColorBase) && !ALPHA_SAFE_NAMED_COLORS.has(rawColorBase) && !_warnedOpacityTokens.has(rawColorBase)) {
|
|
1655
|
+
_warnedOpacityTokens.add(rawColorBase);
|
|
1656
|
+
const at = szWarnLocation ? ` at ${szWarnLocation}` : "";
|
|
1657
|
+
console.warn(
|
|
1658
|
+
`[csszyx] "${prefix}${twPrefix}-${colorBase}/${opStr}"${at}: the /${opStr} opacity applies only if the "${rawColorBase}" theme token is alpha-capable (oklch or space-separated RGB). A comma-separated RGB triplet, or a token that resolves through its own alpha variable, silently ignores the modifier \u2014 verify the emitted rule.`
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1652
1661
|
classes.push(`${prefix}${twPrefix}-${colorBase}/${opStr}`);
|
|
1653
1662
|
} else {
|
|
1654
1663
|
classes.push(`${prefix}${twPrefix}-${colorBase}`);
|
|
@@ -2385,6 +2394,9 @@ function transformImpl(szProp, prefix, mangleMap) {
|
|
|
2385
2394
|
hintProjectScanOnce(szWarnLocation);
|
|
2386
2395
|
}
|
|
2387
2396
|
}
|
|
2397
|
+
if (/^\d+(?:\.\d+)?$/.test(rawKey)) {
|
|
2398
|
+
continue;
|
|
2399
|
+
}
|
|
2388
2400
|
if (value === true) {
|
|
2389
2401
|
if (BOOLEAN_SHORTHANDS.has(rawKey)) {
|
|
2390
2402
|
const mappedClass = BOOLEAN_TO_CLASS[rawKey] || key;
|
|
@@ -1184,6 +1184,8 @@ function handleImportant(value) {
|
|
|
1184
1184
|
}
|
|
1185
1185
|
return { value, important: false };
|
|
1186
1186
|
}
|
|
1187
|
+
const ALPHA_SAFE_NAMED_COLORS = /* @__PURE__ */ new Set(["white", "black", "transparent", "current", "inherit"]);
|
|
1188
|
+
const _warnedOpacityTokens = /* @__PURE__ */ new Set();
|
|
1187
1189
|
function formatOpacity(op) {
|
|
1188
1190
|
if (typeof op === "number") {
|
|
1189
1191
|
if (Number.isInteger(op * 2)) {
|
|
@@ -1647,6 +1649,13 @@ function transformImpl(szProp, prefix, mangleMap) {
|
|
|
1647
1649
|
const colorBase = rawColorBase.startsWith("--") ? `(${rawColorBase})` : needsArbitraryBrackets(rawColorBase) ? `[${normalizeArbitraryValue(rawColorBase)}]` : normalizeArbitraryValue(rawColorBase);
|
|
1648
1650
|
if (colorObj.op !== void 0) {
|
|
1649
1651
|
const opStr = formatOpacity(colorObj.op);
|
|
1652
|
+
if (process.env.NODE_ENV !== "production" && typeof window === "undefined" && !rawColorBase.startsWith("--") && !needsArbitraryBrackets(rawColorBase) && !/-\d{2,3}$/.test(rawColorBase) && !ALPHA_SAFE_NAMED_COLORS.has(rawColorBase) && !_warnedOpacityTokens.has(rawColorBase)) {
|
|
1653
|
+
_warnedOpacityTokens.add(rawColorBase);
|
|
1654
|
+
const at = szWarnLocation ? ` at ${szWarnLocation}` : "";
|
|
1655
|
+
console.warn(
|
|
1656
|
+
`[csszyx] "${prefix}${twPrefix}-${colorBase}/${opStr}"${at}: the /${opStr} opacity applies only if the "${rawColorBase}" theme token is alpha-capable (oklch or space-separated RGB). A comma-separated RGB triplet, or a token that resolves through its own alpha variable, silently ignores the modifier \u2014 verify the emitted rule.`
|
|
1657
|
+
);
|
|
1658
|
+
}
|
|
1650
1659
|
classes.push(`${prefix}${twPrefix}-${colorBase}/${opStr}`);
|
|
1651
1660
|
} else {
|
|
1652
1661
|
classes.push(`${prefix}${twPrefix}-${colorBase}`);
|
|
@@ -2383,6 +2392,9 @@ function transformImpl(szProp, prefix, mangleMap) {
|
|
|
2383
2392
|
hintProjectScanOnce(szWarnLocation);
|
|
2384
2393
|
}
|
|
2385
2394
|
}
|
|
2395
|
+
if (/^\d+(?:\.\d+)?$/.test(rawKey)) {
|
|
2396
|
+
continue;
|
|
2397
|
+
}
|
|
2386
2398
|
if (value === true) {
|
|
2387
2399
|
if (BOOLEAN_SHORTHANDS.has(rawKey)) {
|
|
2388
2400
|
const mappedClass = BOOLEAN_TO_CLASS[rawKey] || key;
|
package/dist/transform-core.cjs
CHANGED
package/dist/transform-core.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BOOLEAN_SHORTHANDS, K as KNOWN_VARIANTS, M as MAX_SZ_DEPTH, P as PROPERTY_MAP, R as REMOVED_BOOLEAN_SUGAR, S as SPECIAL_VARIANTS, h as SUGGESTION_MAP, j as SzDepthError, V as VARIANT_MAP, f as formatSzWarnLocation, b as getVariantPrefix, k as isForbiddenSzKey, i as isValidSzProp, l as normalizeArbitraryValue, m as normalizeArbitraryVariant, n as normalizeClassName, s as setSzWarnLocation, t as transform } from './shared/compiler.
|
|
1
|
+
export { B as BOOLEAN_SHORTHANDS, K as KNOWN_VARIANTS, M as MAX_SZ_DEPTH, P as PROPERTY_MAP, R as REMOVED_BOOLEAN_SUGAR, S as SPECIAL_VARIANTS, h as SUGGESTION_MAP, j as SzDepthError, V as VARIANT_MAP, f as formatSzWarnLocation, b as getVariantPrefix, k as isForbiddenSzKey, i as isValidSzProp, l as normalizeArbitraryValue, m as normalizeArbitraryVariant, n as normalizeClassName, s as setSzWarnLocation, t as transform } from './shared/compiler.zZfo8y65.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/compiler",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"description": "Core compiler and transformation logic for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@babel/types": "^7.23.6",
|
|
66
66
|
"magic-string": "0.30.21",
|
|
67
67
|
"oxc-parser": "0.131.0",
|
|
68
|
-
"@csszyx/core": "0.10.
|
|
68
|
+
"@csszyx/core": "0.10.11"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/babel__core": "^7.20.5",
|