@csszyx/unplugin 0.10.9 → 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 +4 -2
- package/dist/index.d.cts +3 -158
- package/dist/index.d.mts +3 -158
- package/dist/index.mjs +2 -2
- package/dist/next-prebuild.cjs +2 -2
- package/dist/next-prebuild.mjs +2 -2
- package/dist/next-turbo-loader.cjs +2 -2
- package/dist/next-turbo-loader.mjs +2 -2
- package/dist/shared/{unplugin.uLmLkr10.mjs → unplugin.B45ZkNXD.mjs} +1 -1
- package/dist/shared/{unplugin.BImj9Vcx.cjs → unplugin.Bh2aAL4a.cjs} +1 -1
- package/dist/shared/{unplugin.BpWUtI9U.mjs → unplugin.CGqFVGlB.mjs} +14 -1
- package/dist/shared/{unplugin.BAOVOPKJ.mjs → unplugin.CiSDltfp.mjs} +154 -40
- package/dist/shared/{unplugin.pmTknYLy.cjs → unplugin.D32Rb29j.cjs} +14 -0
- package/dist/shared/{unplugin.CK6U5gAP.d.mts → unplugin.D3qsS8Pe.d.cts} +269 -3
- package/dist/shared/{unplugin.CK6U5gAP.d.cts → unplugin.D3qsS8Pe.d.mts} +269 -3
- package/dist/shared/{unplugin.CyZkpgQK.cjs → unplugin.q0k37crS.cjs} +157 -41
- package/dist/vite.cjs +2 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +2 -2
- package/dist/webpack.cjs +2 -2
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +2 -2
- package/package.json +7 -7
|
@@ -15,7 +15,7 @@ const unplugin$1 = require('unplugin');
|
|
|
15
15
|
const cssMangler = require('../css-mangler.cjs');
|
|
16
16
|
const htmlEscape = require('./unplugin.BCwRIUs_.cjs');
|
|
17
17
|
const node_crypto = require('node:crypto');
|
|
18
|
-
const transformCache = require('./unplugin.
|
|
18
|
+
const transformCache = require('./unplugin.D32Rb29j.cjs');
|
|
19
19
|
const postcss = require('postcss');
|
|
20
20
|
const valueParser = require('postcss-value-parser');
|
|
21
21
|
|
|
@@ -1026,6 +1026,8 @@ const EMPTY_THEME = {
|
|
|
1026
1026
|
colors: [],
|
|
1027
1027
|
spacings: [],
|
|
1028
1028
|
fonts: [],
|
|
1029
|
+
textSizes: [],
|
|
1030
|
+
fontWeights: [],
|
|
1029
1031
|
radii: [],
|
|
1030
1032
|
shadows: [],
|
|
1031
1033
|
breakpoints: []
|
|
@@ -1095,7 +1097,12 @@ function categorizeProperty(prop) {
|
|
|
1095
1097
|
const categoryMap = [
|
|
1096
1098
|
["color-", "colors"],
|
|
1097
1099
|
["spacing-", "spacings"],
|
|
1100
|
+
// `font-weight-` MUST precede `font-`: startsWith would otherwise route
|
|
1101
|
+
// `font-weight-chunky` into font FAMILIES as token "weight-chunky".
|
|
1102
|
+
["font-weight-", "fontWeights"],
|
|
1098
1103
|
["font-", "fonts"],
|
|
1104
|
+
// `--text-*` defines font-size utilities (text-huge) in Tailwind v4.
|
|
1105
|
+
["text-", "textSizes"],
|
|
1099
1106
|
["radius-", "radii"],
|
|
1100
1107
|
["shadow-", "shadows"],
|
|
1101
1108
|
["breakpoint-", "breakpoints"]
|
|
@@ -1118,6 +1125,8 @@ function parseThemeBlocks(cssContent) {
|
|
|
1118
1125
|
colors: /* @__PURE__ */ new Set(),
|
|
1119
1126
|
spacings: /* @__PURE__ */ new Set(),
|
|
1120
1127
|
fonts: /* @__PURE__ */ new Set(),
|
|
1128
|
+
textSizes: /* @__PURE__ */ new Set(),
|
|
1129
|
+
fontWeights: /* @__PURE__ */ new Set(),
|
|
1121
1130
|
radii: /* @__PURE__ */ new Set(),
|
|
1122
1131
|
shadows: /* @__PURE__ */ new Set(),
|
|
1123
1132
|
breakpoints: /* @__PURE__ */ new Set()
|
|
@@ -1137,6 +1146,8 @@ function parseThemeBlocks(cssContent) {
|
|
|
1137
1146
|
colors: htmlEscape.sortStrings(result.colors),
|
|
1138
1147
|
spacings: htmlEscape.sortStrings(result.spacings),
|
|
1139
1148
|
fonts: htmlEscape.sortStrings(result.fonts),
|
|
1149
|
+
textSizes: htmlEscape.sortStrings(result.textSizes),
|
|
1150
|
+
fontWeights: htmlEscape.sortStrings(result.fontWeights),
|
|
1140
1151
|
radii: htmlEscape.sortStrings(result.radii),
|
|
1141
1152
|
shadows: htmlEscape.sortStrings(result.shadows),
|
|
1142
1153
|
breakpoints: htmlEscape.sortStrings(result.breakpoints)
|
|
@@ -1150,6 +1161,8 @@ function mergeThemes(themes) {
|
|
|
1150
1161
|
colors: /* @__PURE__ */ new Set(),
|
|
1151
1162
|
spacings: /* @__PURE__ */ new Set(),
|
|
1152
1163
|
fonts: /* @__PURE__ */ new Set(),
|
|
1164
|
+
textSizes: /* @__PURE__ */ new Set(),
|
|
1165
|
+
fontWeights: /* @__PURE__ */ new Set(),
|
|
1153
1166
|
radii: /* @__PURE__ */ new Set(),
|
|
1154
1167
|
shadows: /* @__PURE__ */ new Set(),
|
|
1155
1168
|
breakpoints: /* @__PURE__ */ new Set()
|
|
@@ -1165,6 +1178,8 @@ function mergeThemes(themes) {
|
|
|
1165
1178
|
colors: htmlEscape.sortStrings(merged.colors),
|
|
1166
1179
|
spacings: htmlEscape.sortStrings(merged.spacings),
|
|
1167
1180
|
fonts: htmlEscape.sortStrings(merged.fonts),
|
|
1181
|
+
textSizes: htmlEscape.sortStrings(merged.textSizes),
|
|
1182
|
+
fontWeights: htmlEscape.sortStrings(merged.fontWeights),
|
|
1168
1183
|
radii: htmlEscape.sortStrings(merged.radii),
|
|
1169
1184
|
shadows: htmlEscape.sortStrings(merged.shadows),
|
|
1170
1185
|
breakpoints: htmlEscape.sortStrings(merged.breakpoints)
|
|
@@ -1488,6 +1503,12 @@ function generateThemeDts(opts) {
|
|
|
1488
1503
|
if (theme.fonts.length > 0) {
|
|
1489
1504
|
entries.push(` fonts: ${toUnion(theme.fonts)};`);
|
|
1490
1505
|
}
|
|
1506
|
+
if (theme.textSizes.length > 0) {
|
|
1507
|
+
entries.push(` textSizes: ${toUnion(theme.textSizes)};`);
|
|
1508
|
+
}
|
|
1509
|
+
if (theme.fontWeights.length > 0) {
|
|
1510
|
+
entries.push(` fontWeights: ${toUnion(theme.fontWeights)};`);
|
|
1511
|
+
}
|
|
1491
1512
|
if (theme.radii.length > 0) {
|
|
1492
1513
|
entries.push(` radii: ${toUnion(theme.radii)};`);
|
|
1493
1514
|
}
|
|
@@ -1538,6 +1559,8 @@ function writeThemeDts(opts) {
|
|
|
1538
1559
|
|
|
1539
1560
|
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
1540
1561
|
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
1562
|
+
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
1563
|
+
const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
|
|
1541
1564
|
const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
|
|
1542
1565
|
const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
|
|
1543
1566
|
function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
|
|
@@ -1578,7 +1601,7 @@ export default checksum;
|
|
|
1578
1601
|
`;
|
|
1579
1602
|
}
|
|
1580
1603
|
function isVirtualModule(id) {
|
|
1581
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID;
|
|
1604
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID;
|
|
1582
1605
|
}
|
|
1583
1606
|
function resolveVirtualModule(id) {
|
|
1584
1607
|
if (id === VIRTUAL_MODULE_ID) {
|
|
@@ -1587,8 +1610,25 @@ function resolveVirtualModule(id) {
|
|
|
1587
1610
|
if (id === VIRTUAL_CHECKSUM_ID) {
|
|
1588
1611
|
return RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
1589
1612
|
}
|
|
1613
|
+
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
1614
|
+
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
1615
|
+
}
|
|
1590
1616
|
return void 0;
|
|
1591
1617
|
}
|
|
1618
|
+
function createThemeGroupsModule(tokens) {
|
|
1619
|
+
const payload = JSON.stringify({
|
|
1620
|
+
colors: tokens.colors,
|
|
1621
|
+
textSizes: tokens.textSizes,
|
|
1622
|
+
fontFamilies: tokens.fontFamilies,
|
|
1623
|
+
fontWeights: tokens.fontWeights
|
|
1624
|
+
});
|
|
1625
|
+
return [
|
|
1626
|
+
"// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
|
|
1627
|
+
"import { registerSzcnGroups } from '@csszyx/runtime';",
|
|
1628
|
+
`registerSzcnGroups(${payload});`,
|
|
1629
|
+
"export {};"
|
|
1630
|
+
].join("\n");
|
|
1631
|
+
}
|
|
1592
1632
|
|
|
1593
1633
|
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
1594
1634
|
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
@@ -1597,6 +1637,7 @@ const UNKNOWN_PACKAGE_VERSION = "0.0.0";
|
|
|
1597
1637
|
const TRANSFORM_CACHE_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1598
1638
|
const TRANSFORM_CACHE_MAX_ENTRIES = 1e4;
|
|
1599
1639
|
const TRANSFORM_MEMORY_CACHE_MAX_ENTRIES = 1e3;
|
|
1640
|
+
const TRANSFORM_MEMORY_CACHE_MAX_CODE_CHARS = 32e6;
|
|
1600
1641
|
const MAX_SAFELIST_CLASSES = 1e5;
|
|
1601
1642
|
const DEFAULT_VAR_MANGLE_MAP_MAX_BYTES = 100 * 1024;
|
|
1602
1643
|
const GLOBAL_VAR_ALIAS_MAP_OWNER = "\0csszyx:global-var-aliases";
|
|
@@ -1609,11 +1650,11 @@ const RUNTIME_HELPER_IMPORT_RE = {
|
|
|
1609
1650
|
let _hasWarnedTsConfig = false;
|
|
1610
1651
|
let _hasWarnedTransformCacheVersion = false;
|
|
1611
1652
|
let _hasWarnedNativeFallback = false;
|
|
1612
|
-
|
|
1653
|
+
const _loggedActiveParsers = /* @__PURE__ */ new Set();
|
|
1613
1654
|
const _babelFallbackFiles = /* @__PURE__ */ new Set();
|
|
1614
|
-
const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.
|
|
1655
|
+
const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.q0k37crS.cjs', document.baseURI).href)));
|
|
1615
1656
|
const PLUGIN_VERSION = findPackageVersionFromFile(
|
|
1616
|
-
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.
|
|
1657
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.q0k37crS.cjs', document.baseURI).href))),
|
|
1617
1658
|
UNKNOWN_PACKAGE_VERSION
|
|
1618
1659
|
);
|
|
1619
1660
|
const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
|
|
@@ -1817,7 +1858,10 @@ function isHardIgnoredPath(id, sourceDirs = []) {
|
|
|
1817
1858
|
return false;
|
|
1818
1859
|
}
|
|
1819
1860
|
function fileMayContainSafelistableSz(content) {
|
|
1820
|
-
return content.includes("sz=") || content.includes("sz:") || content.includes("szv(")
|
|
1861
|
+
return content.includes("sz=") || content.includes("szs=") || content.includes("sz:") || content.includes("szv(") || content.includes("szr(") || // dynamic() literal args are extracted for the safelist, but a module
|
|
1862
|
+
// containing ONLY dynamic() calls never passed this gate — the
|
|
1863
|
+
// engine-parity harness caught its classes missing on all engines.
|
|
1864
|
+
content.includes("dynamic(");
|
|
1821
1865
|
}
|
|
1822
1866
|
function isPackagesSkippedSource(id, sourceDirs = []) {
|
|
1823
1867
|
const p = normalizeForMatch(id);
|
|
@@ -1869,6 +1913,9 @@ function recordFileVarMangleEntries(state, filename, entries) {
|
|
|
1869
1913
|
}
|
|
1870
1914
|
state.varMangleMap = buildVarMangleMap(state.varMangleEntriesByFile);
|
|
1871
1915
|
}
|
|
1916
|
+
function shouldTrackGlobalVarSources(config) {
|
|
1917
|
+
return config?.enabled === true;
|
|
1918
|
+
}
|
|
1872
1919
|
function recordGlobalVarSourceFile(state, filename, code) {
|
|
1873
1920
|
const normalizedFilename = normalizeSourceFilename(filename);
|
|
1874
1921
|
if (!/\.[tj]sx?(?:\?.*)?$/.test(normalizedFilename)) {
|
|
@@ -2143,11 +2190,11 @@ function traceBenchTiming(label, filename, elapsedMs) {
|
|
|
2143
2190
|
}
|
|
2144
2191
|
function runThemeScan(rootDir, scanCss) {
|
|
2145
2192
|
if (!scanCss) {
|
|
2146
|
-
return;
|
|
2193
|
+
return null;
|
|
2147
2194
|
}
|
|
2148
2195
|
const sourceFiles = expandFilePatterns(rootDir, scanCss).filter((file) => file.endsWith(".css"));
|
|
2149
2196
|
if (sourceFiles.length === 0) {
|
|
2150
|
-
return;
|
|
2197
|
+
return null;
|
|
2151
2198
|
}
|
|
2152
2199
|
const themes = sourceFiles.map((f) => {
|
|
2153
2200
|
try {
|
|
@@ -2187,6 +2234,7 @@ function runThemeScan(rootDir, scanCss) {
|
|
|
2187
2234
|
} catch {
|
|
2188
2235
|
}
|
|
2189
2236
|
}
|
|
2237
|
+
return merged;
|
|
2190
2238
|
}
|
|
2191
2239
|
function findPackageVersionFromModule(specifier, fallback) {
|
|
2192
2240
|
try {
|
|
@@ -2425,6 +2473,16 @@ function mangleCodeClassesSync(code, mangleMap) {
|
|
|
2425
2473
|
}
|
|
2426
2474
|
return `${sep}${ws}"${mangled.join(" ")}"`;
|
|
2427
2475
|
});
|
|
2476
|
+
result = result.replace(/\bszs:\s*\{([^{}]*)\}/g, (whole, body) => {
|
|
2477
|
+
const mangledBody = body.replace(
|
|
2478
|
+
/"((?:[^"\\]|\\.)*)"/g,
|
|
2479
|
+
(_m, inner) => `"${mangleClassString(inner)}"`
|
|
2480
|
+
).replace(
|
|
2481
|
+
/'((?:[^'\\]|\\.)*)'/g,
|
|
2482
|
+
(_m, inner) => `'${mangleClassString(inner)}'`
|
|
2483
|
+
);
|
|
2484
|
+
return whole.replace(body, mangledBody);
|
|
2485
|
+
});
|
|
2428
2486
|
return result;
|
|
2429
2487
|
}
|
|
2430
2488
|
function assertGlobalVarMangleConfig(options) {
|
|
@@ -2459,6 +2517,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2459
2517
|
const cacheEnabled = cacheRequested && cacheVersionsKnown;
|
|
2460
2518
|
const varMangleMapMaxBytes = resolveVarMangleMapMaxBytes();
|
|
2461
2519
|
const globalVarMangleConfig = options.production?.mangleGlobalVars;
|
|
2520
|
+
const globalVarSourceTrackingEnabled = shouldTrackGlobalVarSources(globalVarMangleConfig);
|
|
2462
2521
|
const globalVarAliasPrefix = globalVarMangleConfig?.aliasPrefix ?? types.CSSZYX_GLOBAL_ALIAS_PREFIX;
|
|
2463
2522
|
const encodedGlobalVarAliasPrefix = encodeURIComponent(globalVarAliasPrefix);
|
|
2464
2523
|
const earlyGlobalVarAliasEntries = createEarlyGlobalVarAliasEntries(
|
|
@@ -2484,21 +2543,25 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2484
2543
|
defaultParser: types.DEFAULT_BUILD_CONFIG.parser ?? "rust",
|
|
2485
2544
|
isRustAvailable: compiler.isRustTransformAvailable
|
|
2486
2545
|
});
|
|
2487
|
-
|
|
2488
|
-
_hasWarnedNativeFallback
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2546
|
+
function announceActiveParser() {
|
|
2547
|
+
if (parserDegraded && !_hasWarnedNativeFallback) {
|
|
2548
|
+
_hasWarnedNativeFallback = true;
|
|
2549
|
+
console.warn(
|
|
2550
|
+
"[csszyx] No prebuilt native binary (@csszyx/core-*) is available for this platform, so the default `rust` parser fell back to `oxc`. Output classes are identical (parity-tested); only parse speed differs. To use the native engine, install the matching @csszyx/core-<platform> package (or do not omit optional dependencies). Set `build.parser` explicitly to silence this."
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2553
|
+
if (!_loggedActiveParsers.has(parserMode)) {
|
|
2554
|
+
_loggedActiveParsers.add(parserMode);
|
|
2555
|
+
const detail = parserDegraded ? "oxc (degraded from default `rust`: no native binary for this platform)" : parserMode === "rust" ? "rust (native engine)" : parserMode;
|
|
2556
|
+
console.warn(`[csszyx] active parser: ${detail}`);
|
|
2557
|
+
}
|
|
2497
2558
|
}
|
|
2498
2559
|
let evictedCacheRoot = null;
|
|
2499
2560
|
const transformMemoryCache = /* @__PURE__ */ new Map();
|
|
2561
|
+
let transformMemoryCacheCodeChars = 0;
|
|
2500
2562
|
const state = {
|
|
2501
2563
|
classes: /* @__PURE__ */ new Set(),
|
|
2564
|
+
parsedTheme: null,
|
|
2502
2565
|
sawTailwindEntry: false,
|
|
2503
2566
|
sawAnyCss: false,
|
|
2504
2567
|
tailwindWarningEmitted: false,
|
|
@@ -2526,7 +2589,16 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2526
2589
|
state.varMangleEntriesByFile.set(GLOBAL_VAR_ALIAS_MAP_OWNER, earlyGlobalVarAliasEntries);
|
|
2527
2590
|
}
|
|
2528
2591
|
const SAFELIST_FILENAME = "csszyx-classes.html";
|
|
2529
|
-
const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2592
|
+
const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2593
|
+
".tsx",
|
|
2594
|
+
".jsx",
|
|
2595
|
+
".ts",
|
|
2596
|
+
".js",
|
|
2597
|
+
".mjs",
|
|
2598
|
+
".cjs",
|
|
2599
|
+
".mts",
|
|
2600
|
+
".cts"
|
|
2601
|
+
]);
|
|
2530
2602
|
const IGNORE_DIRS = /* @__PURE__ */ new Set(["node_modules", ".next", ".git", "dist", "build", ".turbo"]);
|
|
2531
2603
|
function isUserExcluded(id) {
|
|
2532
2604
|
return matchesAnyPattern(id, options.exclude, state.rootDir);
|
|
@@ -2568,6 +2640,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2568
2640
|
assertGlobalVarPlanMatchesEarlyAliases(result, earlyGlobalVarAliasEntries);
|
|
2569
2641
|
return result;
|
|
2570
2642
|
}
|
|
2643
|
+
function trackGlobalVarSourceFile(filename, code) {
|
|
2644
|
+
if (!globalVarSourceTrackingEnabled) {
|
|
2645
|
+
return;
|
|
2646
|
+
}
|
|
2647
|
+
recordGlobalVarSourceFile(state, filename, code);
|
|
2648
|
+
}
|
|
2571
2649
|
let compileSourceDirs = [];
|
|
2572
2650
|
let compileSourceDirsRoot = null;
|
|
2573
2651
|
function refreshCompileSourceDirs() {
|
|
@@ -2588,7 +2666,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2588
2666
|
return isHardIgnoredPath(id, compileSourceDirs);
|
|
2589
2667
|
}
|
|
2590
2668
|
function shouldProcessSource(id) {
|
|
2591
|
-
return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (/\.[tj]sx
|
|
2669
|
+
return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (/\.([cm]?[tj]s|[tj]sx)(\?.*)?$/.test(id) || id.endsWith(".vue") || id.endsWith(".svelte"));
|
|
2592
2670
|
}
|
|
2593
2671
|
function shouldProcessCss(id) {
|
|
2594
2672
|
return !isHardIgnored(id) && !isUserExcluded(id) && /\.css(\?.*)?$/.test(id);
|
|
@@ -2769,21 +2847,28 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2769
2847
|
filePath: file.filePath,
|
|
2770
2848
|
result: transformConfiguredSource(file.content, file.filePath)
|
|
2771
2849
|
});
|
|
2772
|
-
} catch {
|
|
2850
|
+
} catch (err) {
|
|
2851
|
+
console.warn(
|
|
2852
|
+
`[csszyx] prescan skipped ${file.filePath}: transform failed, so none of its classes reached the safelist. ${err instanceof Error ? err.message : String(err)}`
|
|
2853
|
+
);
|
|
2773
2854
|
}
|
|
2774
2855
|
}
|
|
2775
2856
|
return results;
|
|
2776
2857
|
}
|
|
2777
2858
|
function rememberTransformCacheEntry(key, result) {
|
|
2778
|
-
transformMemoryCache.
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
}
|
|
2783
|
-
const oldest = transformMemoryCache.keys().next().value;
|
|
2784
|
-
if (oldest) {
|
|
2785
|
-
transformMemoryCache.delete(oldest);
|
|
2859
|
+
const existing = transformMemoryCache.get(key);
|
|
2860
|
+
if (existing) {
|
|
2861
|
+
transformMemoryCacheCodeChars -= existing.code.length;
|
|
2862
|
+
transformMemoryCache.delete(key);
|
|
2786
2863
|
}
|
|
2864
|
+
transformMemoryCache.set(key, result);
|
|
2865
|
+
transformMemoryCacheCodeChars += result.code.length;
|
|
2866
|
+
transformMemoryCacheCodeChars = transformCache.evictMemoryCacheToBudget(
|
|
2867
|
+
transformMemoryCache,
|
|
2868
|
+
transformMemoryCacheCodeChars,
|
|
2869
|
+
TRANSFORM_MEMORY_CACHE_MAX_ENTRIES,
|
|
2870
|
+
TRANSFORM_MEMORY_CACHE_MAX_CODE_CHARS
|
|
2871
|
+
);
|
|
2787
2872
|
}
|
|
2788
2873
|
function evictTransformCacheOnce() {
|
|
2789
2874
|
if (!cacheEnabled) {
|
|
@@ -2841,7 +2926,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2841
2926
|
} catch {
|
|
2842
2927
|
return;
|
|
2843
2928
|
}
|
|
2844
|
-
if (content.includes("sz=") || content.includes("sz:")) {
|
|
2929
|
+
if (content.includes("sz=") || content.includes("szs=") || content.includes("sz:")) {
|
|
2845
2930
|
state.skippedSzFiles.add(filePath);
|
|
2846
2931
|
}
|
|
2847
2932
|
}
|
|
@@ -2891,6 +2976,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2891
2976
|
scanDir(sourceDir);
|
|
2892
2977
|
}
|
|
2893
2978
|
for (const { filePath, result } of transformPrescanSources(prescanSources)) {
|
|
2979
|
+
if (result.classes.size === 0 && result.rawClassNames.size === 0 && result.diagnostics.some((d) => d.includes("[csszyx] parse error in "))) {
|
|
2980
|
+
console.warn(
|
|
2981
|
+
`[csszyx] prescan skipped ${filePath}: the file failed to parse, so none of its classes reached the safelist. Fix the syntax error (or check the file extension matches its contents).`
|
|
2982
|
+
);
|
|
2983
|
+
continue;
|
|
2984
|
+
}
|
|
2894
2985
|
if (!result.transformed && result.classes.size === 0) {
|
|
2895
2986
|
continue;
|
|
2896
2987
|
}
|
|
@@ -3081,7 +3172,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3081
3172
|
* @returns true only for csszyx virtual modules
|
|
3082
3173
|
*/
|
|
3083
3174
|
loadInclude(id) {
|
|
3084
|
-
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
3175
|
+
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
3085
3176
|
},
|
|
3086
3177
|
/**
|
|
3087
3178
|
* Loads virtual module content — generates mangle map or checksum module code.
|
|
@@ -3102,6 +3193,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3102
3193
|
finalizeMangleMap();
|
|
3103
3194
|
return createChecksumModule(state.checksum);
|
|
3104
3195
|
}
|
|
3196
|
+
if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
|
|
3197
|
+
const theme = state.parsedTheme;
|
|
3198
|
+
return createThemeGroupsModule({
|
|
3199
|
+
colors: theme?.colors ?? [],
|
|
3200
|
+
textSizes: theme?.textSizes ?? [],
|
|
3201
|
+
fontFamilies: theme?.fonts ?? [],
|
|
3202
|
+
fontWeights: theme?.fontWeights ?? []
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3105
3205
|
return null;
|
|
3106
3206
|
},
|
|
3107
3207
|
/**
|
|
@@ -3124,11 +3224,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3124
3224
|
* @returns transformed code with source map, or null if no changes were made
|
|
3125
3225
|
*/
|
|
3126
3226
|
transform(code, id) {
|
|
3227
|
+
announceActiveParser();
|
|
3127
3228
|
if (!shouldProcessCss(id) && !shouldProcessSource(id)) {
|
|
3128
3229
|
return null;
|
|
3129
3230
|
}
|
|
3130
3231
|
if (shouldProcessSource(id)) {
|
|
3131
|
-
|
|
3232
|
+
trackGlobalVarSourceFile(id, code);
|
|
3132
3233
|
}
|
|
3133
3234
|
if (/\.[tj]sx?(\?.*)?$/.test(id)) {
|
|
3134
3235
|
assertNoRSCBoundaryViolation(code, id);
|
|
@@ -3160,7 +3261,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3160
3261
|
let usesColorVar = false;
|
|
3161
3262
|
let transformed = false;
|
|
3162
3263
|
let szClasses;
|
|
3163
|
-
const hasSzProp = code.includes("sz=") || /\bsz\s*:\s*["'{]/.test(code) || code.includes('sz: "');
|
|
3264
|
+
const hasSzProp = code.includes("sz=") || code.includes("szs=") || /\bsz\s*:\s*["'{]/.test(code) || code.includes('sz: "');
|
|
3164
3265
|
if (hasSzProp) {
|
|
3165
3266
|
if (id.endsWith(".vue")) {
|
|
3166
3267
|
const result = vueAdapter.preprocess(code, options);
|
|
@@ -3258,6 +3359,11 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3258
3359
|
transformed = true;
|
|
3259
3360
|
}
|
|
3260
3361
|
}
|
|
3362
|
+
if (/\bszcn\s*\(/.test(code) && !transformedCode.includes(THEME_GROUPS_VIRTUAL_ID) && shouldProcessSource(id)) {
|
|
3363
|
+
transformedCode = `import '${THEME_GROUPS_VIRTUAL_ID}';
|
|
3364
|
+
${transformedCode}`;
|
|
3365
|
+
transformed = true;
|
|
3366
|
+
}
|
|
3261
3367
|
if (/\.[tj]sx?(\?.*)?$/.test(id)) {
|
|
3262
3368
|
assertNoRSCBoundaryViolation(transformedCode, id);
|
|
3263
3369
|
const record = createRSCModuleRecord(transformedCode, id);
|
|
@@ -3334,13 +3440,14 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3334
3440
|
*/
|
|
3335
3441
|
webpack(compiler) {
|
|
3336
3442
|
compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
|
|
3443
|
+
announceActiveParser();
|
|
3337
3444
|
const root = compiler.context || process.cwd();
|
|
3338
3445
|
state.rootDir = root;
|
|
3339
3446
|
evictTransformCacheOnce();
|
|
3340
3447
|
if (state.classes.size === 0) {
|
|
3341
3448
|
prescanAndWriteClasses();
|
|
3342
3449
|
}
|
|
3343
|
-
runThemeScan(root, options.build?.scanCss);
|
|
3450
|
+
state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
|
|
3344
3451
|
});
|
|
3345
3452
|
if (options.build?.scanCss) {
|
|
3346
3453
|
compiler.hooks.thisCompilation.tap("csszyx:theme-deps", (compilation) => {
|
|
@@ -3358,6 +3465,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3358
3465
|
* @param config - the resolved Vite configuration object
|
|
3359
3466
|
*/
|
|
3360
3467
|
configResolved(config) {
|
|
3468
|
+
announceActiveParser();
|
|
3361
3469
|
const root = config.root || process.cwd();
|
|
3362
3470
|
state.rootDir = root;
|
|
3363
3471
|
if (config.command === "serve") {
|
|
@@ -3365,7 +3473,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3365
3473
|
}
|
|
3366
3474
|
evictTransformCacheOnce();
|
|
3367
3475
|
prescanAndWriteClasses();
|
|
3368
|
-
runThemeScan(root, options.build?.scanCss);
|
|
3476
|
+
state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
|
|
3369
3477
|
},
|
|
3370
3478
|
/**
|
|
3371
3479
|
* Vite HMR hook: re-runs theme scan when a watched CSS file changes,
|
|
@@ -3377,7 +3485,13 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3377
3485
|
if (scanCss) {
|
|
3378
3486
|
const root = ctx.server.config.root || process.cwd();
|
|
3379
3487
|
if (matchesAnyPattern(ctx.file, scanCss, root)) {
|
|
3380
|
-
runThemeScan(root, scanCss);
|
|
3488
|
+
state.parsedTheme = runThemeScan(root, scanCss) ?? state.parsedTheme;
|
|
3489
|
+
const themeGroupsModule = ctx.server.moduleGraph.getModuleById(
|
|
3490
|
+
RESOLVED_THEME_GROUPS_VIRTUAL_ID
|
|
3491
|
+
);
|
|
3492
|
+
if (themeGroupsModule) {
|
|
3493
|
+
ctx.server.moduleGraph.invalidateModule(themeGroupsModule);
|
|
3494
|
+
}
|
|
3381
3495
|
}
|
|
3382
3496
|
}
|
|
3383
3497
|
if (!shouldProcessSource(ctx.file)) {
|
|
@@ -3389,8 +3503,8 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3389
3503
|
} catch {
|
|
3390
3504
|
return;
|
|
3391
3505
|
}
|
|
3392
|
-
if (!fileContent.includes("sz=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
|
|
3393
|
-
|
|
3506
|
+
if (!fileContent.includes("sz=") && !fileContent.includes("szs=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
|
|
3507
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3394
3508
|
recordFileVarMangleEntries(state, ctx.file, []);
|
|
3395
3509
|
recordFileCSSVariableMetrics(state, ctx.file, null);
|
|
3396
3510
|
return;
|
|
@@ -3404,19 +3518,19 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3404
3518
|
node_perf_hooks.performance.now() - hmrTransformStarted
|
|
3405
3519
|
);
|
|
3406
3520
|
} catch {
|
|
3407
|
-
|
|
3521
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3408
3522
|
recordFileVarMangleEntries(state, ctx.file, []);
|
|
3409
3523
|
recordFileCSSVariableMetrics(state, ctx.file, null);
|
|
3410
3524
|
return;
|
|
3411
3525
|
}
|
|
3412
3526
|
if (!result.transformed) {
|
|
3413
|
-
|
|
3527
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3414
3528
|
recordFileVarMangleEntries(state, ctx.file, []);
|
|
3415
3529
|
recordFileCSSVariableMetrics(state, ctx.file, null);
|
|
3416
3530
|
return;
|
|
3417
3531
|
}
|
|
3418
3532
|
const sizeBefore = state.classes.size;
|
|
3419
|
-
|
|
3533
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3420
3534
|
for (const cls of result.classes) {
|
|
3421
3535
|
addSafelistClass(cls);
|
|
3422
3536
|
state.ownedClasses.add(cls);
|
|
@@ -3836,6 +3950,7 @@ exports.normalizeGlobalVarAliasesForCache = normalizeGlobalVarAliasesForCache;
|
|
|
3836
3950
|
exports.parseThemeBlocks = parseThemeBlocks;
|
|
3837
3951
|
exports.planGlobalVarAliases = planGlobalVarAliases;
|
|
3838
3952
|
exports.readGlobalVarScanCache = readGlobalVarScanCache;
|
|
3953
|
+
exports.recordGlobalVarSourceFile = recordGlobalVarSourceFile;
|
|
3839
3954
|
exports.resolveCompileSourceDirs = resolveCompileSourceDirs;
|
|
3840
3955
|
exports.resolveGlobalVarScanCacheDir = resolveGlobalVarScanCacheDir;
|
|
3841
3956
|
exports.resolveNativeCacheIdentity = resolveNativeCacheIdentity;
|
|
@@ -3843,6 +3958,7 @@ exports.rewriteGlobalVarCssAliases = rewriteGlobalVarCssAliases;
|
|
|
3843
3958
|
exports.rollupPlugin = rollupPlugin;
|
|
3844
3959
|
exports.scanGlobalVarCss = scanGlobalVarCss;
|
|
3845
3960
|
exports.shouldEmitWarning = shouldEmitWarning;
|
|
3961
|
+
exports.shouldTrackGlobalVarSources = shouldTrackGlobalVarSources;
|
|
3846
3962
|
exports.shouldWarnMissingTailwindEntry = shouldWarnMissingTailwindEntry;
|
|
3847
3963
|
exports.shouldWarnUnscopedMonorepo = shouldWarnUnscopedMonorepo;
|
|
3848
3964
|
exports.skippedSzFilesMessage = skippedSzFilesMessage;
|
package/dist/vite.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const unplugin = require('./shared/unplugin.
|
|
5
|
+
const unplugin = require('./shared/unplugin.q0k37crS.cjs');
|
|
6
6
|
require('node:fs');
|
|
7
7
|
require('node:module');
|
|
8
8
|
require('node:path');
|
|
@@ -20,7 +20,7 @@ require('postcss');
|
|
|
20
20
|
require('postcss-selector-parser');
|
|
21
21
|
require('./shared/unplugin.BCwRIUs_.cjs');
|
|
22
22
|
require('node:crypto');
|
|
23
|
-
require('./shared/unplugin.
|
|
23
|
+
require('./shared/unplugin.D32Rb29j.cjs');
|
|
24
24
|
require('postcss-value-parser');
|
|
25
25
|
|
|
26
26
|
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Y as vitePlugin } from './shared/unplugin.CiSDltfp.mjs';
|
|
2
2
|
import 'node:fs';
|
|
3
3
|
import 'node:module';
|
|
4
4
|
import 'node:path';
|
|
@@ -16,7 +16,7 @@ import 'postcss';
|
|
|
16
16
|
import 'postcss-selector-parser';
|
|
17
17
|
import './shared/unplugin.B1mblcm-.mjs';
|
|
18
18
|
import 'node:crypto';
|
|
19
|
-
import './shared/unplugin.
|
|
19
|
+
import './shared/unplugin.CGqFVGlB.mjs';
|
|
20
20
|
import 'postcss-value-parser';
|
|
21
21
|
|
|
22
22
|
|
package/dist/webpack.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const unplugin = require('./shared/unplugin.
|
|
5
|
+
const unplugin = require('./shared/unplugin.q0k37crS.cjs');
|
|
6
6
|
require('node:fs');
|
|
7
7
|
require('node:module');
|
|
8
8
|
require('node:path');
|
|
@@ -20,7 +20,7 @@ require('postcss');
|
|
|
20
20
|
require('postcss-selector-parser');
|
|
21
21
|
require('./shared/unplugin.BCwRIUs_.cjs');
|
|
22
22
|
require('node:crypto');
|
|
23
|
-
require('./shared/unplugin.
|
|
23
|
+
require('./shared/unplugin.D32Rb29j.cjs');
|
|
24
24
|
require('postcss-value-parser');
|
|
25
25
|
|
|
26
26
|
|
package/dist/webpack.d.cts
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Z as webpackPlugin } from './shared/unplugin.CiSDltfp.mjs';
|
|
2
2
|
import 'node:fs';
|
|
3
3
|
import 'node:module';
|
|
4
4
|
import 'node:path';
|
|
@@ -16,7 +16,7 @@ import 'postcss';
|
|
|
16
16
|
import 'postcss-selector-parser';
|
|
17
17
|
import './shared/unplugin.B1mblcm-.mjs';
|
|
18
18
|
import 'node:crypto';
|
|
19
|
-
import './shared/unplugin.
|
|
19
|
+
import './shared/unplugin.CGqFVGlB.mjs';
|
|
20
20
|
import 'postcss-value-parser';
|
|
21
21
|
|
|
22
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/unplugin",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"description": "Vite and Webpack integration for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
"postcss-value-parser": "^4.2.0",
|
|
118
118
|
"proper-lockfile": "^4.1.2",
|
|
119
119
|
"unplugin": "^1.10.1",
|
|
120
|
-
"@csszyx/compiler": "0.10.
|
|
121
|
-
"@csszyx/core": "0.10.
|
|
122
|
-
"@csszyx/
|
|
123
|
-
"@csszyx/vue-adapter": "0.10.
|
|
124
|
-
"@csszyx/
|
|
120
|
+
"@csszyx/compiler": "0.10.11",
|
|
121
|
+
"@csszyx/core": "0.10.11",
|
|
122
|
+
"@csszyx/types": "0.10.11",
|
|
123
|
+
"@csszyx/vue-adapter": "0.10.11",
|
|
124
|
+
"@csszyx/svelte-adapter": "0.10.11"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@csszyx/runtime": "^0.10.
|
|
127
|
+
"@csszyx/runtime": "^0.10.11"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@types/node": "^20.11.0",
|