@csszyx/unplugin 0.10.10 → 0.10.12
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.Cq_8AIBn.cjs → unplugin.CoiN0OSE.cjs} +152 -41
- 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.Ble541_h.mjs → unplugin.DO7Y2Y-X.mjs} +149 -40
- 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 @@ import { createUnplugin } from 'unplugin';
|
|
|
15
15
|
import { mangleCSSSync } from '../css-mangler.mjs';
|
|
16
16
|
import { s as sortStrings, e as escapeHtmlAttribute } from './unplugin.B1mblcm-.mjs';
|
|
17
17
|
import { createHash } from 'node:crypto';
|
|
18
|
-
import { r as resolveTransformCacheDir, c as createTransformCacheKey, a as readTransformCache, w as writeTransformCache, e as evictOldTransformCacheEntries } from './unplugin.
|
|
18
|
+
import { r as resolveTransformCacheDir, c as createTransformCacheKey, a as readTransformCache, w as writeTransformCache, e as evictOldTransformCacheEntries, b as evictMemoryCacheToBudget } from './unplugin.CGqFVGlB.mjs';
|
|
19
19
|
import postcss from 'postcss';
|
|
20
20
|
import valueParser from 'postcss-value-parser';
|
|
21
21
|
|
|
@@ -1006,6 +1006,8 @@ const EMPTY_THEME = {
|
|
|
1006
1006
|
colors: [],
|
|
1007
1007
|
spacings: [],
|
|
1008
1008
|
fonts: [],
|
|
1009
|
+
textSizes: [],
|
|
1010
|
+
fontWeights: [],
|
|
1009
1011
|
radii: [],
|
|
1010
1012
|
shadows: [],
|
|
1011
1013
|
breakpoints: []
|
|
@@ -1075,7 +1077,12 @@ function categorizeProperty(prop) {
|
|
|
1075
1077
|
const categoryMap = [
|
|
1076
1078
|
["color-", "colors"],
|
|
1077
1079
|
["spacing-", "spacings"],
|
|
1080
|
+
// `font-weight-` MUST precede `font-`: startsWith would otherwise route
|
|
1081
|
+
// `font-weight-chunky` into font FAMILIES as token "weight-chunky".
|
|
1082
|
+
["font-weight-", "fontWeights"],
|
|
1078
1083
|
["font-", "fonts"],
|
|
1084
|
+
// `--text-*` defines font-size utilities (text-huge) in Tailwind v4.
|
|
1085
|
+
["text-", "textSizes"],
|
|
1079
1086
|
["radius-", "radii"],
|
|
1080
1087
|
["shadow-", "shadows"],
|
|
1081
1088
|
["breakpoint-", "breakpoints"]
|
|
@@ -1098,6 +1105,8 @@ function parseThemeBlocks(cssContent) {
|
|
|
1098
1105
|
colors: /* @__PURE__ */ new Set(),
|
|
1099
1106
|
spacings: /* @__PURE__ */ new Set(),
|
|
1100
1107
|
fonts: /* @__PURE__ */ new Set(),
|
|
1108
|
+
textSizes: /* @__PURE__ */ new Set(),
|
|
1109
|
+
fontWeights: /* @__PURE__ */ new Set(),
|
|
1101
1110
|
radii: /* @__PURE__ */ new Set(),
|
|
1102
1111
|
shadows: /* @__PURE__ */ new Set(),
|
|
1103
1112
|
breakpoints: /* @__PURE__ */ new Set()
|
|
@@ -1117,6 +1126,8 @@ function parseThemeBlocks(cssContent) {
|
|
|
1117
1126
|
colors: sortStrings(result.colors),
|
|
1118
1127
|
spacings: sortStrings(result.spacings),
|
|
1119
1128
|
fonts: sortStrings(result.fonts),
|
|
1129
|
+
textSizes: sortStrings(result.textSizes),
|
|
1130
|
+
fontWeights: sortStrings(result.fontWeights),
|
|
1120
1131
|
radii: sortStrings(result.radii),
|
|
1121
1132
|
shadows: sortStrings(result.shadows),
|
|
1122
1133
|
breakpoints: sortStrings(result.breakpoints)
|
|
@@ -1130,6 +1141,8 @@ function mergeThemes(themes) {
|
|
|
1130
1141
|
colors: /* @__PURE__ */ new Set(),
|
|
1131
1142
|
spacings: /* @__PURE__ */ new Set(),
|
|
1132
1143
|
fonts: /* @__PURE__ */ new Set(),
|
|
1144
|
+
textSizes: /* @__PURE__ */ new Set(),
|
|
1145
|
+
fontWeights: /* @__PURE__ */ new Set(),
|
|
1133
1146
|
radii: /* @__PURE__ */ new Set(),
|
|
1134
1147
|
shadows: /* @__PURE__ */ new Set(),
|
|
1135
1148
|
breakpoints: /* @__PURE__ */ new Set()
|
|
@@ -1145,6 +1158,8 @@ function mergeThemes(themes) {
|
|
|
1145
1158
|
colors: sortStrings(merged.colors),
|
|
1146
1159
|
spacings: sortStrings(merged.spacings),
|
|
1147
1160
|
fonts: sortStrings(merged.fonts),
|
|
1161
|
+
textSizes: sortStrings(merged.textSizes),
|
|
1162
|
+
fontWeights: sortStrings(merged.fontWeights),
|
|
1148
1163
|
radii: sortStrings(merged.radii),
|
|
1149
1164
|
shadows: sortStrings(merged.shadows),
|
|
1150
1165
|
breakpoints: sortStrings(merged.breakpoints)
|
|
@@ -1468,6 +1483,12 @@ function generateThemeDts(opts) {
|
|
|
1468
1483
|
if (theme.fonts.length > 0) {
|
|
1469
1484
|
entries.push(` fonts: ${toUnion(theme.fonts)};`);
|
|
1470
1485
|
}
|
|
1486
|
+
if (theme.textSizes.length > 0) {
|
|
1487
|
+
entries.push(` textSizes: ${toUnion(theme.textSizes)};`);
|
|
1488
|
+
}
|
|
1489
|
+
if (theme.fontWeights.length > 0) {
|
|
1490
|
+
entries.push(` fontWeights: ${toUnion(theme.fontWeights)};`);
|
|
1491
|
+
}
|
|
1471
1492
|
if (theme.radii.length > 0) {
|
|
1472
1493
|
entries.push(` radii: ${toUnion(theme.radii)};`);
|
|
1473
1494
|
}
|
|
@@ -1518,6 +1539,8 @@ function writeThemeDts(opts) {
|
|
|
1518
1539
|
|
|
1519
1540
|
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
1520
1541
|
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
1542
|
+
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
1543
|
+
const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
|
|
1521
1544
|
const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
|
|
1522
1545
|
const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
|
|
1523
1546
|
function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
|
|
@@ -1558,7 +1581,7 @@ export default checksum;
|
|
|
1558
1581
|
`;
|
|
1559
1582
|
}
|
|
1560
1583
|
function isVirtualModule(id) {
|
|
1561
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID;
|
|
1584
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID;
|
|
1562
1585
|
}
|
|
1563
1586
|
function resolveVirtualModule(id) {
|
|
1564
1587
|
if (id === VIRTUAL_MODULE_ID) {
|
|
@@ -1567,8 +1590,25 @@ function resolveVirtualModule(id) {
|
|
|
1567
1590
|
if (id === VIRTUAL_CHECKSUM_ID) {
|
|
1568
1591
|
return RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
1569
1592
|
}
|
|
1593
|
+
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
1594
|
+
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
1595
|
+
}
|
|
1570
1596
|
return void 0;
|
|
1571
1597
|
}
|
|
1598
|
+
function createThemeGroupsModule(tokens) {
|
|
1599
|
+
const payload = JSON.stringify({
|
|
1600
|
+
colors: tokens.colors,
|
|
1601
|
+
textSizes: tokens.textSizes,
|
|
1602
|
+
fontFamilies: tokens.fontFamilies,
|
|
1603
|
+
fontWeights: tokens.fontWeights
|
|
1604
|
+
});
|
|
1605
|
+
return [
|
|
1606
|
+
"// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
|
|
1607
|
+
"import { registerSzcnGroups } from '@csszyx/runtime';",
|
|
1608
|
+
`registerSzcnGroups(${payload});`,
|
|
1609
|
+
"export {};"
|
|
1610
|
+
].join("\n");
|
|
1611
|
+
}
|
|
1572
1612
|
|
|
1573
1613
|
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
1574
1614
|
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
@@ -1577,6 +1617,7 @@ const UNKNOWN_PACKAGE_VERSION = "0.0.0";
|
|
|
1577
1617
|
const TRANSFORM_CACHE_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1578
1618
|
const TRANSFORM_CACHE_MAX_ENTRIES = 1e4;
|
|
1579
1619
|
const TRANSFORM_MEMORY_CACHE_MAX_ENTRIES = 1e3;
|
|
1620
|
+
const TRANSFORM_MEMORY_CACHE_MAX_CODE_CHARS = 32e6;
|
|
1580
1621
|
const MAX_SAFELIST_CLASSES = 1e5;
|
|
1581
1622
|
const DEFAULT_VAR_MANGLE_MAP_MAX_BYTES = 100 * 1024;
|
|
1582
1623
|
const GLOBAL_VAR_ALIAS_MAP_OWNER = "\0csszyx:global-var-aliases";
|
|
@@ -1589,7 +1630,7 @@ const RUNTIME_HELPER_IMPORT_RE = {
|
|
|
1589
1630
|
let _hasWarnedTsConfig = false;
|
|
1590
1631
|
let _hasWarnedTransformCacheVersion = false;
|
|
1591
1632
|
let _hasWarnedNativeFallback = false;
|
|
1592
|
-
|
|
1633
|
+
const _loggedActiveParsers = /* @__PURE__ */ new Set();
|
|
1593
1634
|
const _babelFallbackFiles = /* @__PURE__ */ new Set();
|
|
1594
1635
|
const requireFromHere = createRequire(import.meta.url);
|
|
1595
1636
|
const PLUGIN_VERSION = findPackageVersionFromFile(
|
|
@@ -1797,7 +1838,10 @@ function isHardIgnoredPath(id, sourceDirs = []) {
|
|
|
1797
1838
|
return false;
|
|
1798
1839
|
}
|
|
1799
1840
|
function fileMayContainSafelistableSz(content) {
|
|
1800
|
-
return content.includes("sz=") || content.includes("szs=") || content.includes("sz:") || content.includes("szv(")
|
|
1841
|
+
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
|
|
1842
|
+
// containing ONLY dynamic() calls never passed this gate — the
|
|
1843
|
+
// engine-parity harness caught its classes missing on all engines.
|
|
1844
|
+
content.includes("dynamic(");
|
|
1801
1845
|
}
|
|
1802
1846
|
function isPackagesSkippedSource(id, sourceDirs = []) {
|
|
1803
1847
|
const p = normalizeForMatch(id);
|
|
@@ -1849,9 +1893,12 @@ function recordFileVarMangleEntries(state, filename, entries) {
|
|
|
1849
1893
|
}
|
|
1850
1894
|
state.varMangleMap = buildVarMangleMap(state.varMangleEntriesByFile);
|
|
1851
1895
|
}
|
|
1896
|
+
function shouldTrackGlobalVarSources(config) {
|
|
1897
|
+
return config?.enabled === true;
|
|
1898
|
+
}
|
|
1852
1899
|
function recordGlobalVarSourceFile(state, filename, code) {
|
|
1853
1900
|
const normalizedFilename = normalizeSourceFilename(filename);
|
|
1854
|
-
if (
|
|
1901
|
+
if (!matchesScriptExtension(normalizedFilename, SCRIPT_ID_EXTENSIONS)) {
|
|
1855
1902
|
return;
|
|
1856
1903
|
}
|
|
1857
1904
|
if (code === null) {
|
|
@@ -2123,11 +2170,11 @@ function traceBenchTiming(label, filename, elapsedMs) {
|
|
|
2123
2170
|
}
|
|
2124
2171
|
function runThemeScan(rootDir, scanCss) {
|
|
2125
2172
|
if (!scanCss) {
|
|
2126
|
-
return;
|
|
2173
|
+
return null;
|
|
2127
2174
|
}
|
|
2128
2175
|
const sourceFiles = expandFilePatterns(rootDir, scanCss).filter((file) => file.endsWith(".css"));
|
|
2129
2176
|
if (sourceFiles.length === 0) {
|
|
2130
|
-
return;
|
|
2177
|
+
return null;
|
|
2131
2178
|
}
|
|
2132
2179
|
const themes = sourceFiles.map((f) => {
|
|
2133
2180
|
try {
|
|
@@ -2167,6 +2214,7 @@ function runThemeScan(rootDir, scanCss) {
|
|
|
2167
2214
|
} catch {
|
|
2168
2215
|
}
|
|
2169
2216
|
}
|
|
2217
|
+
return merged;
|
|
2170
2218
|
}
|
|
2171
2219
|
function findPackageVersionFromModule(specifier, fallback) {
|
|
2172
2220
|
try {
|
|
@@ -2197,6 +2245,11 @@ function findPackageVersionFromFile(file, fallback) {
|
|
|
2197
2245
|
function normalizeSourceFilename(filename) {
|
|
2198
2246
|
return filename.replace(/\\/g, "/");
|
|
2199
2247
|
}
|
|
2248
|
+
const SCRIPT_ID_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
|
|
2249
|
+
const SOURCE_MODULE_EXTENSIONS = [...SCRIPT_ID_EXTENSIONS, ".cts", ".mts", ".cjs", ".mjs"];
|
|
2250
|
+
function matchesScriptExtension(id, extensions) {
|
|
2251
|
+
return extensions.some((ext) => id.endsWith(ext) || id.includes(`${ext}?`));
|
|
2252
|
+
}
|
|
2200
2253
|
function insertRuntimeImport(code, importStmt) {
|
|
2201
2254
|
const directiveMatch = code.match(DIRECTIVE_PROLOGUE_PREFIX_RE);
|
|
2202
2255
|
if (!directiveMatch) {
|
|
@@ -2449,6 +2502,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2449
2502
|
const cacheEnabled = cacheRequested && cacheVersionsKnown;
|
|
2450
2503
|
const varMangleMapMaxBytes = resolveVarMangleMapMaxBytes();
|
|
2451
2504
|
const globalVarMangleConfig = options.production?.mangleGlobalVars;
|
|
2505
|
+
const globalVarSourceTrackingEnabled = shouldTrackGlobalVarSources(globalVarMangleConfig);
|
|
2452
2506
|
const globalVarAliasPrefix = globalVarMangleConfig?.aliasPrefix ?? CSSZYX_GLOBAL_ALIAS_PREFIX;
|
|
2453
2507
|
const encodedGlobalVarAliasPrefix = encodeURIComponent(globalVarAliasPrefix);
|
|
2454
2508
|
const earlyGlobalVarAliasEntries = createEarlyGlobalVarAliasEntries(
|
|
@@ -2474,21 +2528,25 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2474
2528
|
defaultParser: DEFAULT_BUILD_CONFIG.parser ?? "rust",
|
|
2475
2529
|
isRustAvailable: isRustTransformAvailable
|
|
2476
2530
|
});
|
|
2477
|
-
|
|
2478
|
-
_hasWarnedNativeFallback
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2531
|
+
function announceActiveParser() {
|
|
2532
|
+
if (parserDegraded && !_hasWarnedNativeFallback) {
|
|
2533
|
+
_hasWarnedNativeFallback = true;
|
|
2534
|
+
console.warn(
|
|
2535
|
+
"[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."
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
if (!_loggedActiveParsers.has(parserMode)) {
|
|
2539
|
+
_loggedActiveParsers.add(parserMode);
|
|
2540
|
+
const detail = parserDegraded ? "oxc (degraded from default `rust`: no native binary for this platform)" : parserMode === "rust" ? "rust (native engine)" : parserMode;
|
|
2541
|
+
console.warn(`[csszyx] active parser: ${detail}`);
|
|
2542
|
+
}
|
|
2487
2543
|
}
|
|
2488
2544
|
let evictedCacheRoot = null;
|
|
2489
2545
|
const transformMemoryCache = /* @__PURE__ */ new Map();
|
|
2546
|
+
let transformMemoryCacheCodeChars = 0;
|
|
2490
2547
|
const state = {
|
|
2491
2548
|
classes: /* @__PURE__ */ new Set(),
|
|
2549
|
+
parsedTheme: null,
|
|
2492
2550
|
sawTailwindEntry: false,
|
|
2493
2551
|
sawAnyCss: false,
|
|
2494
2552
|
tailwindWarningEmitted: false,
|
|
@@ -2516,7 +2574,16 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2516
2574
|
state.varMangleEntriesByFile.set(GLOBAL_VAR_ALIAS_MAP_OWNER, earlyGlobalVarAliasEntries);
|
|
2517
2575
|
}
|
|
2518
2576
|
const SAFELIST_FILENAME = "csszyx-classes.html";
|
|
2519
|
-
const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2577
|
+
const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2578
|
+
".tsx",
|
|
2579
|
+
".jsx",
|
|
2580
|
+
".ts",
|
|
2581
|
+
".js",
|
|
2582
|
+
".mjs",
|
|
2583
|
+
".cjs",
|
|
2584
|
+
".mts",
|
|
2585
|
+
".cts"
|
|
2586
|
+
]);
|
|
2520
2587
|
const IGNORE_DIRS = /* @__PURE__ */ new Set(["node_modules", ".next", ".git", "dist", "build", ".turbo"]);
|
|
2521
2588
|
function isUserExcluded(id) {
|
|
2522
2589
|
return matchesAnyPattern(id, options.exclude, state.rootDir);
|
|
@@ -2558,6 +2625,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2558
2625
|
assertGlobalVarPlanMatchesEarlyAliases(result, earlyGlobalVarAliasEntries);
|
|
2559
2626
|
return result;
|
|
2560
2627
|
}
|
|
2628
|
+
function trackGlobalVarSourceFile(filename, code) {
|
|
2629
|
+
if (!globalVarSourceTrackingEnabled) {
|
|
2630
|
+
return;
|
|
2631
|
+
}
|
|
2632
|
+
recordGlobalVarSourceFile(state, filename, code);
|
|
2633
|
+
}
|
|
2561
2634
|
let compileSourceDirs = [];
|
|
2562
2635
|
let compileSourceDirsRoot = null;
|
|
2563
2636
|
function refreshCompileSourceDirs() {
|
|
@@ -2578,7 +2651,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2578
2651
|
return isHardIgnoredPath(id, compileSourceDirs);
|
|
2579
2652
|
}
|
|
2580
2653
|
function shouldProcessSource(id) {
|
|
2581
|
-
return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (
|
|
2654
|
+
return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (matchesScriptExtension(id, SOURCE_MODULE_EXTENSIONS) || id.endsWith(".vue") || id.endsWith(".svelte"));
|
|
2582
2655
|
}
|
|
2583
2656
|
function shouldProcessCss(id) {
|
|
2584
2657
|
return !isHardIgnored(id) && !isUserExcluded(id) && /\.css(\?.*)?$/.test(id);
|
|
@@ -2759,21 +2832,28 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2759
2832
|
filePath: file.filePath,
|
|
2760
2833
|
result: transformConfiguredSource(file.content, file.filePath)
|
|
2761
2834
|
});
|
|
2762
|
-
} catch {
|
|
2835
|
+
} catch (err) {
|
|
2836
|
+
console.warn(
|
|
2837
|
+
`[csszyx] prescan skipped ${file.filePath}: transform failed, so none of its classes reached the safelist. ${err instanceof Error ? err.message : String(err)}`
|
|
2838
|
+
);
|
|
2763
2839
|
}
|
|
2764
2840
|
}
|
|
2765
2841
|
return results;
|
|
2766
2842
|
}
|
|
2767
2843
|
function rememberTransformCacheEntry(key, result) {
|
|
2768
|
-
transformMemoryCache.
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
}
|
|
2773
|
-
const oldest = transformMemoryCache.keys().next().value;
|
|
2774
|
-
if (oldest) {
|
|
2775
|
-
transformMemoryCache.delete(oldest);
|
|
2844
|
+
const existing = transformMemoryCache.get(key);
|
|
2845
|
+
if (existing) {
|
|
2846
|
+
transformMemoryCacheCodeChars -= existing.code.length;
|
|
2847
|
+
transformMemoryCache.delete(key);
|
|
2776
2848
|
}
|
|
2849
|
+
transformMemoryCache.set(key, result);
|
|
2850
|
+
transformMemoryCacheCodeChars += result.code.length;
|
|
2851
|
+
transformMemoryCacheCodeChars = evictMemoryCacheToBudget(
|
|
2852
|
+
transformMemoryCache,
|
|
2853
|
+
transformMemoryCacheCodeChars,
|
|
2854
|
+
TRANSFORM_MEMORY_CACHE_MAX_ENTRIES,
|
|
2855
|
+
TRANSFORM_MEMORY_CACHE_MAX_CODE_CHARS
|
|
2856
|
+
);
|
|
2777
2857
|
}
|
|
2778
2858
|
function evictTransformCacheOnce() {
|
|
2779
2859
|
if (!cacheEnabled) {
|
|
@@ -2881,6 +2961,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2881
2961
|
scanDir(sourceDir);
|
|
2882
2962
|
}
|
|
2883
2963
|
for (const { filePath, result } of transformPrescanSources(prescanSources)) {
|
|
2964
|
+
if (result.classes.size === 0 && result.rawClassNames.size === 0 && result.diagnostics.some((d) => d.includes("[csszyx] parse error in "))) {
|
|
2965
|
+
console.warn(
|
|
2966
|
+
`[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).`
|
|
2967
|
+
);
|
|
2968
|
+
continue;
|
|
2969
|
+
}
|
|
2884
2970
|
if (!result.transformed && result.classes.size === 0) {
|
|
2885
2971
|
continue;
|
|
2886
2972
|
}
|
|
@@ -3071,7 +3157,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3071
3157
|
* @returns true only for csszyx virtual modules
|
|
3072
3158
|
*/
|
|
3073
3159
|
loadInclude(id) {
|
|
3074
|
-
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
3160
|
+
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
3075
3161
|
},
|
|
3076
3162
|
/**
|
|
3077
3163
|
* Loads virtual module content — generates mangle map or checksum module code.
|
|
@@ -3092,6 +3178,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3092
3178
|
finalizeMangleMap();
|
|
3093
3179
|
return createChecksumModule(state.checksum);
|
|
3094
3180
|
}
|
|
3181
|
+
if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
|
|
3182
|
+
const theme = state.parsedTheme;
|
|
3183
|
+
return createThemeGroupsModule({
|
|
3184
|
+
colors: theme?.colors ?? [],
|
|
3185
|
+
textSizes: theme?.textSizes ?? [],
|
|
3186
|
+
fontFamilies: theme?.fonts ?? [],
|
|
3187
|
+
fontWeights: theme?.fontWeights ?? []
|
|
3188
|
+
});
|
|
3189
|
+
}
|
|
3095
3190
|
return null;
|
|
3096
3191
|
},
|
|
3097
3192
|
/**
|
|
@@ -3114,13 +3209,14 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3114
3209
|
* @returns transformed code with source map, or null if no changes were made
|
|
3115
3210
|
*/
|
|
3116
3211
|
transform(code, id) {
|
|
3212
|
+
announceActiveParser();
|
|
3117
3213
|
if (!shouldProcessCss(id) && !shouldProcessSource(id)) {
|
|
3118
3214
|
return null;
|
|
3119
3215
|
}
|
|
3120
3216
|
if (shouldProcessSource(id)) {
|
|
3121
|
-
|
|
3217
|
+
trackGlobalVarSourceFile(id, code);
|
|
3122
3218
|
}
|
|
3123
|
-
if (
|
|
3219
|
+
if (matchesScriptExtension(id, SCRIPT_ID_EXTENSIONS)) {
|
|
3124
3220
|
assertNoRSCBoundaryViolation(code, id);
|
|
3125
3221
|
}
|
|
3126
3222
|
if (/\.css(\?.*)?$/.test(id)) {
|
|
@@ -3248,7 +3344,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3248
3344
|
transformed = true;
|
|
3249
3345
|
}
|
|
3250
3346
|
}
|
|
3251
|
-
if (
|
|
3347
|
+
if (/\bszcn\s*\(/.test(code) && !transformedCode.includes(THEME_GROUPS_VIRTUAL_ID) && shouldProcessSource(id)) {
|
|
3348
|
+
transformedCode = `import '${THEME_GROUPS_VIRTUAL_ID}';
|
|
3349
|
+
${transformedCode}`;
|
|
3350
|
+
transformed = true;
|
|
3351
|
+
}
|
|
3352
|
+
if (matchesScriptExtension(id, SCRIPT_ID_EXTENSIONS)) {
|
|
3252
3353
|
assertNoRSCBoundaryViolation(transformedCode, id);
|
|
3253
3354
|
const record = createRSCModuleRecord(transformedCode, id);
|
|
3254
3355
|
state.rscModules.set(record.id, record);
|
|
@@ -3324,13 +3425,14 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3324
3425
|
*/
|
|
3325
3426
|
webpack(compiler) {
|
|
3326
3427
|
compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
|
|
3428
|
+
announceActiveParser();
|
|
3327
3429
|
const root = compiler.context || process.cwd();
|
|
3328
3430
|
state.rootDir = root;
|
|
3329
3431
|
evictTransformCacheOnce();
|
|
3330
3432
|
if (state.classes.size === 0) {
|
|
3331
3433
|
prescanAndWriteClasses();
|
|
3332
3434
|
}
|
|
3333
|
-
runThemeScan(root, options.build?.scanCss);
|
|
3435
|
+
state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
|
|
3334
3436
|
});
|
|
3335
3437
|
if (options.build?.scanCss) {
|
|
3336
3438
|
compiler.hooks.thisCompilation.tap("csszyx:theme-deps", (compilation) => {
|
|
@@ -3348,6 +3450,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3348
3450
|
* @param config - the resolved Vite configuration object
|
|
3349
3451
|
*/
|
|
3350
3452
|
configResolved(config) {
|
|
3453
|
+
announceActiveParser();
|
|
3351
3454
|
const root = config.root || process.cwd();
|
|
3352
3455
|
state.rootDir = root;
|
|
3353
3456
|
if (config.command === "serve") {
|
|
@@ -3355,7 +3458,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3355
3458
|
}
|
|
3356
3459
|
evictTransformCacheOnce();
|
|
3357
3460
|
prescanAndWriteClasses();
|
|
3358
|
-
runThemeScan(root, options.build?.scanCss);
|
|
3461
|
+
state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
|
|
3359
3462
|
},
|
|
3360
3463
|
/**
|
|
3361
3464
|
* Vite HMR hook: re-runs theme scan when a watched CSS file changes,
|
|
@@ -3367,7 +3470,13 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3367
3470
|
if (scanCss) {
|
|
3368
3471
|
const root = ctx.server.config.root || process.cwd();
|
|
3369
3472
|
if (matchesAnyPattern(ctx.file, scanCss, root)) {
|
|
3370
|
-
runThemeScan(root, scanCss);
|
|
3473
|
+
state.parsedTheme = runThemeScan(root, scanCss) ?? state.parsedTheme;
|
|
3474
|
+
const themeGroupsModule = ctx.server.moduleGraph.getModuleById(
|
|
3475
|
+
RESOLVED_THEME_GROUPS_VIRTUAL_ID
|
|
3476
|
+
);
|
|
3477
|
+
if (themeGroupsModule) {
|
|
3478
|
+
ctx.server.moduleGraph.invalidateModule(themeGroupsModule);
|
|
3479
|
+
}
|
|
3371
3480
|
}
|
|
3372
3481
|
}
|
|
3373
3482
|
if (!shouldProcessSource(ctx.file)) {
|
|
@@ -3380,7 +3489,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3380
3489
|
return;
|
|
3381
3490
|
}
|
|
3382
3491
|
if (!fileContent.includes("sz=") && !fileContent.includes("szs=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
|
|
3383
|
-
|
|
3492
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3384
3493
|
recordFileVarMangleEntries(state, ctx.file, []);
|
|
3385
3494
|
recordFileCSSVariableMetrics(state, ctx.file, null);
|
|
3386
3495
|
return;
|
|
@@ -3394,19 +3503,19 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3394
3503
|
performance.now() - hmrTransformStarted
|
|
3395
3504
|
);
|
|
3396
3505
|
} catch {
|
|
3397
|
-
|
|
3506
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3398
3507
|
recordFileVarMangleEntries(state, ctx.file, []);
|
|
3399
3508
|
recordFileCSSVariableMetrics(state, ctx.file, null);
|
|
3400
3509
|
return;
|
|
3401
3510
|
}
|
|
3402
3511
|
if (!result.transformed) {
|
|
3403
|
-
|
|
3512
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3404
3513
|
recordFileVarMangleEntries(state, ctx.file, []);
|
|
3405
3514
|
recordFileCSSVariableMetrics(state, ctx.file, null);
|
|
3406
3515
|
return;
|
|
3407
3516
|
}
|
|
3408
3517
|
const sizeBefore = state.classes.size;
|
|
3409
|
-
|
|
3518
|
+
trackGlobalVarSourceFile(ctx.file, fileContent);
|
|
3410
3519
|
for (const cls of result.classes) {
|
|
3411
3520
|
addSafelistClass(cls);
|
|
3412
3521
|
state.ownedClasses.add(cls);
|
|
@@ -3791,4 +3900,4 @@ const esbuildPlugin = (options = {}) => {
|
|
|
3791
3900
|
};
|
|
3792
3901
|
};
|
|
3793
3902
|
|
|
3794
|
-
export { isRSCServerModule as A, isTailwindReservedGlobalVar as B, mangleCodeClassesSync as C, mangleHybridHazardMessage as D, mergeThemes as E, missingTailwindEntryMessage as F, normalizeGlobalVarAliasesForCache as G, parseThemeBlocks as H, planGlobalVarAliases as I, readGlobalVarScanCache as J,
|
|
3903
|
+
export { isRSCServerModule as A, isTailwindReservedGlobalVar as B, mangleCodeClassesSync as C, mangleHybridHazardMessage as D, mergeThemes as E, missingTailwindEntryMessage as F, normalizeGlobalVarAliasesForCache as G, parseThemeBlocks as H, planGlobalVarAliases as I, readGlobalVarScanCache as J, recordGlobalVarSourceFile as K, resolveCompileSourceDirs as L, resolveGlobalVarScanCacheDir as M, resolveNativeCacheIdentity as N, rewriteGlobalVarCssAliases as O, rollupPlugin as P, scanGlobalVarCss as Q, shouldEmitWarning as R, shouldTrackGlobalVarSources as S, shouldWarnMissingTailwindEntry as T, shouldWarnUnscopedMonorepo as U, skippedSzFilesMessage as V, unscopedMonorepoMessage as W, validateGlobalVarAliasInputs as X, vitePlugin as Y, webpackPlugin as Z, writeGlobalVarScanCache as _, appendTailwindSourceDirective as a, assertNoRSCBoundaryViolation as b, assertNoRSCGraphViolation as c, collectMangleHybridHazards as d, computeSafelistRelPath as e, createGlobalVarAliasValidationOptions as f, createGlobalVarMapAssetSource as g, createGlobalVarScanCacheKey as h, createRSCModuleRecord as i, cssHasContentScope as j, cssImportsTailwind as k, deleteRSCModuleRecord as l, esbuildPlugin as m, extractGlobalVarAliasesForManifest as n, fileMayContainSafelistableSz as o, findRSCBoundaryViolation as p, findRSCGraphViolation as q, hasInjectableTailwindCandidate as r, hasTokens as s, hasUseClientDirective as t, unplugin as u, hasUseServerDirective as v, isCompileSourceOptedIn as w, isHardIgnoredPath as x, isMonorepoPackage as y, isPackagesSkippedSource as z };
|
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.CoiN0OSE.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.DO7Y2Y-X.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.CoiN0OSE.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.DO7Y2Y-X.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.12",
|
|
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/
|
|
122
|
-
"@csszyx/
|
|
123
|
-
"@csszyx/
|
|
124
|
-
"@csszyx/
|
|
120
|
+
"@csszyx/compiler": "0.10.12",
|
|
121
|
+
"@csszyx/core": "0.10.12",
|
|
122
|
+
"@csszyx/vue-adapter": "0.10.12",
|
|
123
|
+
"@csszyx/types": "0.10.12",
|
|
124
|
+
"@csszyx/svelte-adapter": "0.10.12"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@csszyx/runtime": "^0.10.
|
|
127
|
+
"@csszyx/runtime": "^0.10.12"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@types/node": "^20.11.0",
|