@csszyx/unplugin 0.11.10 → 0.11.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 +2 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/{unplugin.CVMbUfH5.mjs → unplugin.B2RUVK6Z.mjs} +118 -20
- package/dist/shared/{unplugin.CjCKWnoX.d.cts → unplugin.BK7BIeBn.d.cts} +15 -1
- package/dist/shared/{unplugin.CjCKWnoX.d.mts → unplugin.BK7BIeBn.d.mts} +15 -1
- package/dist/shared/{unplugin.CRuVOB4Q.cjs → unplugin.CJcFsJcf.cjs} +120 -21
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const cssMangler = require('./css-mangler.cjs');
|
|
6
|
-
const unplugin = require('./shared/unplugin.
|
|
6
|
+
const unplugin = require('./shared/unplugin.CJcFsJcf.cjs');
|
|
7
7
|
const types = require('@csszyx/types');
|
|
8
8
|
require('postcss');
|
|
9
9
|
require('postcss-selector-parser');
|
|
@@ -31,6 +31,7 @@ exports.escapeCSSClassName = cssMangler.escapeCSSClassName;
|
|
|
31
31
|
exports.mangleCSS = cssMangler.mangleCSS;
|
|
32
32
|
exports.mangleCSSSync = cssMangler.mangleCSSSync;
|
|
33
33
|
exports.unescapeTailwindClass = cssMangler.unescapeTailwindClass;
|
|
34
|
+
exports.allocateMangleTokens = unplugin.allocateMangleTokens;
|
|
34
35
|
exports.appendTailwindSourceDirective = unplugin.appendTailwindSourceDirective;
|
|
35
36
|
exports.assertNoRSCBoundaryViolation = unplugin.assertNoRSCBoundaryViolation;
|
|
36
37
|
exports.assertNoRSCGraphViolation = unplugin.assertNoRSCGraphViolation;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { CSSManglerOptions, CSSManglerResult, MangleMap, createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.cjs';
|
|
2
2
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
3
|
-
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.
|
|
3
|
+
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.BK7BIeBn.cjs';
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
export = undefined;
|
|
6
|
-
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, M as MangleHybridHazards, o as ParsedTheme, p as RSCBoundaryViolation, q as RSCModuleRecord, r as
|
|
6
|
+
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, M as MangleHybridHazards, o as ParsedTheme, p as RSCBoundaryViolation, q as RSCModuleRecord, r as allocateMangleTokens, s as appendTailwindSourceDirective, t as assertNoRSCBoundaryViolation, u as assertNoRSCGraphViolation, v as collectMangleHybridHazards, w as computeSafelistRelPath, x as createGlobalVarMapAssetSource, y as createRSCModuleRecord, z as cssHasContentScope, A as cssImportsTailwind, D as deleteRSCModuleRecord, E as esbuildPlugin, F as extractGlobalVarAliasesForManifest, H as fileMayContainSafelistableSz, I as findLocalImportSources, J as findRSCBoundaryViolation, K as findRSCGraphViolation, L as hasInjectableTailwindCandidate, N as hasTokens, O as hasUseClientDirective, Q as hasUseServerDirective, T as isCompileSourceOptedIn, U as isHardIgnoredPath, W as isMonorepoPackage, X as isPackagesSkippedSource, Y as isRSCServerModule, Z as mangleCodeClassesSync, _ as mangleEligibleClasses, $ as mangleHybridHazardMessage, a0 as mergeThemes, a1 as missingTailwindEntryMessage, a2 as normalizeGlobalVarAliasesForCache, a3 as parseThemeBlocks, a4 as recordGlobalVarSourceFile, a5 as resolveCompileSourceDirs, a6 as resolveNativeCacheIdentity, a7 as rollupPlugin, a8 as scanCustomPropertyNames, a9 as shouldEmitWarning, aa as shouldTrackGlobalVarSources, ab as shouldWarnMissingTailwindEntry, ac as shouldWarnUnscopedMonorepo, ad as skippedSzFilesMessage, B as unplugin, ae as unscopedMonorepoMessage, af as vitePlugin, ag as webpackPlugin } from './shared/unplugin.BK7BIeBn.cjs';
|
|
7
7
|
import 'postcss';
|
|
8
8
|
import '@csszyx/compiler';
|
|
9
9
|
import 'esbuild';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CSSManglerOptions, CSSManglerResult, MangleMap, createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.mjs';
|
|
2
2
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
3
|
-
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.
|
|
4
|
-
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, M as MangleHybridHazards, o as ParsedTheme, p as RSCBoundaryViolation, q as RSCModuleRecord, r as
|
|
3
|
+
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.BK7BIeBn.mjs';
|
|
4
|
+
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, M as MangleHybridHazards, o as ParsedTheme, p as RSCBoundaryViolation, q as RSCModuleRecord, r as allocateMangleTokens, s as appendTailwindSourceDirective, t as assertNoRSCBoundaryViolation, u as assertNoRSCGraphViolation, v as collectMangleHybridHazards, w as computeSafelistRelPath, x as createGlobalVarMapAssetSource, y as createRSCModuleRecord, z as cssHasContentScope, A as cssImportsTailwind, B as default, D as deleteRSCModuleRecord, E as esbuildPlugin, F as extractGlobalVarAliasesForManifest, H as fileMayContainSafelistableSz, I as findLocalImportSources, J as findRSCBoundaryViolation, K as findRSCGraphViolation, L as hasInjectableTailwindCandidate, N as hasTokens, O as hasUseClientDirective, Q as hasUseServerDirective, T as isCompileSourceOptedIn, U as isHardIgnoredPath, W as isMonorepoPackage, X as isPackagesSkippedSource, Y as isRSCServerModule, Z as mangleCodeClassesSync, _ as mangleEligibleClasses, $ as mangleHybridHazardMessage, a0 as mergeThemes, a1 as missingTailwindEntryMessage, a2 as normalizeGlobalVarAliasesForCache, a3 as parseThemeBlocks, a4 as recordGlobalVarSourceFile, a5 as resolveCompileSourceDirs, a6 as resolveNativeCacheIdentity, a7 as rollupPlugin, a8 as scanCustomPropertyNames, a9 as shouldEmitWarning, aa as shouldTrackGlobalVarSources, ab as shouldWarnMissingTailwindEntry, ac as shouldWarnUnscopedMonorepo, ad as skippedSzFilesMessage, B as unplugin, ae as unscopedMonorepoMessage, af as vitePlugin, ag as webpackPlugin } from './shared/unplugin.BK7BIeBn.mjs';
|
|
5
5
|
import 'postcss';
|
|
6
6
|
import '@csszyx/compiler';
|
|
7
7
|
import 'esbuild';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.mjs';
|
|
2
|
-
export { a as
|
|
2
|
+
export { a as allocateMangleTokens, b as appendTailwindSourceDirective, c as assertNoRSCBoundaryViolation, d as assertNoRSCGraphViolation, e as collectMangleHybridHazards, f as computeSafelistRelPath, g as createGlobalVarAliasValidationOptions, h as createGlobalVarMapAssetSource, i as createGlobalVarScanCacheKey, j as createRSCModuleRecord, k as cssHasContentScope, l as cssImportsTailwind, u as default, m as deleteRSCModuleRecord, n as esbuildPlugin, o as extractGlobalVarAliasesForManifest, p as fileMayContainSafelistableSz, q as findLocalImportSources, r as findRSCBoundaryViolation, s as findRSCGraphViolation, t as hasInjectableTailwindCandidate, v as hasTokens, w as hasUseClientDirective, x as hasUseServerDirective, y as isCompileSourceOptedIn, z as isHardIgnoredPath, A as isMonorepoPackage, B as isPackagesSkippedSource, C as isRSCServerModule, D as isTailwindReservedGlobalVar, E as mangleCodeClassesSync, F as mangleEligibleClasses, G as mangleHybridHazardMessage, H as mergeThemes, I as missingTailwindEntryMessage, J as normalizeGlobalVarAliasesForCache, K as parseThemeBlocks, L as planGlobalVarAliases, M as readGlobalVarScanCache, N as recordGlobalVarSourceFile, O as resolveCompileSourceDirs, P as resolveGlobalVarScanCacheDir, Q as resolveNativeCacheIdentity, R as rewriteGlobalVarCssAliases, S as rollupPlugin, T as scanCustomPropertyNames, U as scanGlobalVarCss, V as shouldEmitWarning, W as shouldTrackGlobalVarSources, X as shouldWarnMissingTailwindEntry, Y as shouldWarnUnscopedMonorepo, Z as skippedSzFilesMessage, u as unplugin, _ as unscopedMonorepoMessage, $ as validateGlobalVarAliasInputs, a0 as vitePlugin, a1 as webpackPlugin, a2 as writeGlobalVarScanCache } from './shared/unplugin.B2RUVK6Z.mjs';
|
|
3
3
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
4
4
|
import 'postcss';
|
|
5
5
|
import 'postcss-selector-parser';
|
|
@@ -2137,7 +2137,7 @@ export default checksum;
|
|
|
2137
2137
|
`;
|
|
2138
2138
|
}
|
|
2139
2139
|
function isVirtualModule(id) {
|
|
2140
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID;
|
|
2140
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
2141
2141
|
}
|
|
2142
2142
|
function resolveVirtualModule(id) {
|
|
2143
2143
|
if (id === VIRTUAL_MODULE_ID) {
|
|
@@ -2149,8 +2149,56 @@ function resolveVirtualModule(id) {
|
|
|
2149
2149
|
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
2150
2150
|
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
2151
2151
|
}
|
|
2152
|
+
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
2153
|
+
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
2154
|
+
}
|
|
2152
2155
|
return void 0;
|
|
2153
2156
|
}
|
|
2157
|
+
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
2158
|
+
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
2159
|
+
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
2160
|
+
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
2161
|
+
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
2162
|
+
function createMangleRuntimeModule(globalVarAliasPrefix) {
|
|
2163
|
+
return `/**
|
|
2164
|
+
* Auto-generated by csszyx: installs the runtime mangle map from the bundle.
|
|
2165
|
+
*
|
|
2166
|
+
* @generated
|
|
2167
|
+
*/
|
|
2168
|
+
|
|
2169
|
+
const m = ${MANGLE_MAP_PLACEHOLDER};
|
|
2170
|
+
const vm = ${VAR_MANGLE_MAP_PLACEHOLDER};
|
|
2171
|
+
const gp = ${JSON.stringify(globalVarAliasPrefix)};
|
|
2172
|
+
const checksum = "${CHECKSUM_PLACEHOLDER}";
|
|
2173
|
+
|
|
2174
|
+
if (typeof window !== 'undefined' && !window.__csszyx) {
|
|
2175
|
+
const r = {};
|
|
2176
|
+
const vr = {};
|
|
2177
|
+
for (const k in m) r[m[k]] = k;
|
|
2178
|
+
for (const vk in vm) {
|
|
2179
|
+
const vv = vm[vk];
|
|
2180
|
+
const vs = Array.isArray(vv) ? vv : [vv];
|
|
2181
|
+
for (const v of vs) (vr[v] || (vr[v] = [])).push(vk);
|
|
2182
|
+
}
|
|
2183
|
+
window.__csszyx = {
|
|
2184
|
+
mangleMap: m,
|
|
2185
|
+
varMangleMap: vm,
|
|
2186
|
+
checksum,
|
|
2187
|
+
decode: (c) => r[c],
|
|
2188
|
+
encode: (c) => m[c],
|
|
2189
|
+
decodeVar: (v) => vr[v] || [],
|
|
2190
|
+
encodeVar: (v) => vm[v],
|
|
2191
|
+
decodeGlobalVar: (v) => {
|
|
2192
|
+
const a = vr[v] || [];
|
|
2193
|
+
return v.indexOf(gp) === 0 ? a[0] : undefined;
|
|
2194
|
+
},
|
|
2195
|
+
decodeAll: (el) => (el.className || '').split(' ').map((c) => r[c] || c),
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
export {};
|
|
2200
|
+
`;
|
|
2201
|
+
}
|
|
2154
2202
|
function createThemeGroupsModule(tokens) {
|
|
2155
2203
|
const payload = JSON.stringify({
|
|
2156
2204
|
colors: tokens.colors,
|
|
@@ -2175,9 +2223,6 @@ function registerWebpackAssetProcessor(compiler, processAssets) {
|
|
|
2175
2223
|
);
|
|
2176
2224
|
});
|
|
2177
2225
|
}
|
|
2178
|
-
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
2179
|
-
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
2180
|
-
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
2181
2226
|
const UNKNOWN_PACKAGE_VERSION = "0.0.0";
|
|
2182
2227
|
const TRANSFORM_CACHE_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
2183
2228
|
const TRANSFORM_CACHE_MAX_ENTRIES = 1e4;
|
|
@@ -2433,6 +2478,30 @@ function fileMayContainSafelistableSz(content) {
|
|
|
2433
2478
|
function mangleEligibleClasses(ownedClasses, authoredClasses) {
|
|
2434
2479
|
return sortStrings$1([...ownedClasses].filter((className) => !authoredClasses.has(className)));
|
|
2435
2480
|
}
|
|
2481
|
+
const tokenByIndex = [];
|
|
2482
|
+
function tokenAt(index) {
|
|
2483
|
+
const cached = tokenByIndex[index];
|
|
2484
|
+
if (cached !== void 0) {
|
|
2485
|
+
return cached;
|
|
2486
|
+
}
|
|
2487
|
+
const fresh = encode(index);
|
|
2488
|
+
tokenByIndex[index] = fresh;
|
|
2489
|
+
return fresh;
|
|
2490
|
+
}
|
|
2491
|
+
function allocateMangleTokens(eligibleClasses, forbiddenTokens) {
|
|
2492
|
+
const map = {};
|
|
2493
|
+
let tokenIndex = 0;
|
|
2494
|
+
for (const className of eligibleClasses) {
|
|
2495
|
+
let token = tokenAt(tokenIndex);
|
|
2496
|
+
while (forbiddenTokens.has(token)) {
|
|
2497
|
+
tokenIndex++;
|
|
2498
|
+
token = tokenAt(tokenIndex);
|
|
2499
|
+
}
|
|
2500
|
+
map[className] = token;
|
|
2501
|
+
tokenIndex++;
|
|
2502
|
+
}
|
|
2503
|
+
return map;
|
|
2504
|
+
}
|
|
2436
2505
|
function isPackagesSkippedSource(id, sourceDirs = []) {
|
|
2437
2506
|
const p = normalizeForMatch(id);
|
|
2438
2507
|
if (p.includes("node_modules")) {
|
|
@@ -3830,18 +3899,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3830
3899
|
}
|
|
3831
3900
|
}
|
|
3832
3901
|
function finalizeMangleMap() {
|
|
3833
|
-
const
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
tokenIndex++;
|
|
3843
|
-
}
|
|
3844
|
-
state.mangleMap = newMap;
|
|
3902
|
+
const forbiddenTokens = /* @__PURE__ */ new Set([
|
|
3903
|
+
...mangleReserved,
|
|
3904
|
+
...state.authoredClasses,
|
|
3905
|
+
...state.ownedClasses
|
|
3906
|
+
]);
|
|
3907
|
+
state.mangleMap = allocateMangleTokens(
|
|
3908
|
+
mangleEligibleClasses(state.ownedClasses, state.authoredClasses),
|
|
3909
|
+
forbiddenTokens
|
|
3910
|
+
);
|
|
3845
3911
|
assertVarMangleMapSize(state.varMangleMap, varMangleMapMaxBytes);
|
|
3846
3912
|
state.checksum = compute_mangle_checksum(
|
|
3847
3913
|
createHydrationMangleMap(state.mangleMap, state.varMangleMap)
|
|
@@ -3874,14 +3940,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3874
3940
|
if (result.includes(CHECKSUM_PLACEHOLDER)) {
|
|
3875
3941
|
result = result.split(CHECKSUM_PLACEHOLDER).join(state.checksum);
|
|
3876
3942
|
}
|
|
3943
|
+
const isEvalWrapped = result.includes("eval(") && result.includes("sourceURL=webpack");
|
|
3877
3944
|
if (result.includes(MANGLE_MAP_PLACEHOLDER)) {
|
|
3878
3945
|
const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.mangleMap));
|
|
3879
|
-
const escapedMap =
|
|
3946
|
+
const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
|
|
3880
3947
|
result = result.split(MANGLE_MAP_PLACEHOLDER).join(escapedMap);
|
|
3881
3948
|
}
|
|
3882
3949
|
if (result.includes(VAR_MANGLE_MAP_PLACEHOLDER)) {
|
|
3883
3950
|
const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.varMangleMap));
|
|
3884
|
-
const escapedMap =
|
|
3951
|
+
const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
|
|
3885
3952
|
result = result.split(VAR_MANGLE_MAP_PLACEHOLDER).join(escapedMap);
|
|
3886
3953
|
}
|
|
3887
3954
|
return result;
|
|
@@ -4012,6 +4079,18 @@ function createCsszyxPlugins(options = {}) {
|
|
|
4012
4079
|
}
|
|
4013
4080
|
return `import '${THEME_GROUPS_VIRTUAL_ID}';
|
|
4014
4081
|
${transformedCode}`;
|
|
4082
|
+
}
|
|
4083
|
+
const MANGLE_RUNTIME_CONSUMER_RE = /from\s*['"](?:csszyx|@csszyx\/runtime)['"]/;
|
|
4084
|
+
let activeFramework;
|
|
4085
|
+
function injectMangleRuntime(transformedCode, id) {
|
|
4086
|
+
if (activeFramework !== "vite" && activeFramework !== "rollup") {
|
|
4087
|
+
return null;
|
|
4088
|
+
}
|
|
4089
|
+
if (!manglingEnabled || !shouldProcessSource(id) || !MANGLE_RUNTIME_CONSUMER_RE.test(transformedCode) || transformedCode.includes(MANGLE_RUNTIME_VIRTUAL_ID)) {
|
|
4090
|
+
return null;
|
|
4091
|
+
}
|
|
4092
|
+
return insertRuntimeImport(transformedCode, `import '${MANGLE_RUNTIME_VIRTUAL_ID}';
|
|
4093
|
+
`);
|
|
4015
4094
|
}
|
|
4016
4095
|
function collectPreTransformClasses(output) {
|
|
4017
4096
|
if (!output.transformed && !output.code.includes("class=") && !output.code.includes("className=")) {
|
|
@@ -4055,7 +4134,7 @@ ${transformedCode}`;
|
|
|
4055
4134
|
* @returns true only for csszyx virtual modules
|
|
4056
4135
|
*/
|
|
4057
4136
|
loadInclude(id) {
|
|
4058
|
-
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
4137
|
+
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID || id === RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
4059
4138
|
},
|
|
4060
4139
|
/**
|
|
4061
4140
|
* Loads virtual module content — generates mangle map or checksum module code.
|
|
@@ -4076,6 +4155,9 @@ ${transformedCode}`;
|
|
|
4076
4155
|
finalizeMangleMap();
|
|
4077
4156
|
return createChecksumModule(state.checksum);
|
|
4078
4157
|
}
|
|
4158
|
+
if (id === RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
4159
|
+
return createMangleRuntimeModule(globalVarAliasPrefix);
|
|
4160
|
+
}
|
|
4079
4161
|
if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
|
|
4080
4162
|
const theme = state.parsedTheme;
|
|
4081
4163
|
return createThemeGroupsModule({
|
|
@@ -4142,6 +4224,11 @@ ${transformedCode}`;
|
|
|
4142
4224
|
output.code = themedCode;
|
|
4143
4225
|
output.transformed = true;
|
|
4144
4226
|
}
|
|
4227
|
+
const mangleRuntimeCode = injectMangleRuntime(output.code, id);
|
|
4228
|
+
if (mangleRuntimeCode !== null) {
|
|
4229
|
+
output.code = mangleRuntimeCode;
|
|
4230
|
+
output.transformed = true;
|
|
4231
|
+
}
|
|
4145
4232
|
if (matchesScriptExtension(id, SCRIPT_ID_EXTENSIONS)) {
|
|
4146
4233
|
assertNoRSCBoundaryViolation(output.code, id);
|
|
4147
4234
|
const record = createRSCModuleRecord(output.code, id);
|
|
@@ -4205,6 +4292,10 @@ ${transformedCode}`;
|
|
|
4205
4292
|
* @param compiler - the Webpack compiler instance
|
|
4206
4293
|
*/
|
|
4207
4294
|
webpack(compiler) {
|
|
4295
|
+
activeFramework = "webpack";
|
|
4296
|
+
if (compiler.options?.mode === "development") {
|
|
4297
|
+
manglingEnabled = false;
|
|
4298
|
+
}
|
|
4208
4299
|
compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
|
|
4209
4300
|
announceActiveParser();
|
|
4210
4301
|
const root = compiler.context || process.cwd();
|
|
@@ -4225,6 +4316,12 @@ ${transformedCode}`;
|
|
|
4225
4316
|
});
|
|
4226
4317
|
}
|
|
4227
4318
|
},
|
|
4319
|
+
rollup: {
|
|
4320
|
+
/** Records the rollup lane for the mangle-runtime gate. */
|
|
4321
|
+
buildStart() {
|
|
4322
|
+
activeFramework = "rollup";
|
|
4323
|
+
}
|
|
4324
|
+
},
|
|
4228
4325
|
vite: {
|
|
4229
4326
|
/**
|
|
4230
4327
|
* Vite hook: pre-scans source files when config is resolved.
|
|
@@ -4232,6 +4329,7 @@ ${transformedCode}`;
|
|
|
4232
4329
|
* @param config - the resolved Vite configuration object
|
|
4233
4330
|
*/
|
|
4234
4331
|
configResolved(config) {
|
|
4332
|
+
activeFramework = "vite";
|
|
4235
4333
|
announceActiveParser();
|
|
4236
4334
|
const root = config.root || process.cwd();
|
|
4237
4335
|
state.rootDir = root;
|
|
@@ -4598,4 +4696,4 @@ const esbuildPlugin = (options = {}) => {
|
|
|
4598
4696
|
};
|
|
4599
4697
|
};
|
|
4600
4698
|
|
|
4601
|
-
export {
|
|
4699
|
+
export { validateGlobalVarAliasInputs as $, isMonorepoPackage as A, isPackagesSkippedSource as B, isRSCServerModule as C, isTailwindReservedGlobalVar as D, mangleCodeClassesSync as E, mangleEligibleClasses as F, mangleHybridHazardMessage as G, mergeThemes as H, missingTailwindEntryMessage as I, normalizeGlobalVarAliasesForCache as J, parseThemeBlocks as K, planGlobalVarAliases as L, readGlobalVarScanCache as M, recordGlobalVarSourceFile as N, resolveCompileSourceDirs as O, resolveGlobalVarScanCacheDir as P, resolveNativeCacheIdentity as Q, rewriteGlobalVarCssAliases as R, rollupPlugin as S, scanCustomPropertyNames as T, scanGlobalVarCss as U, shouldEmitWarning as V, shouldTrackGlobalVarSources as W, shouldWarnMissingTailwindEntry as X, shouldWarnUnscopedMonorepo as Y, skippedSzFilesMessage as Z, unscopedMonorepoMessage as _, allocateMangleTokens as a, vitePlugin as a0, webpackPlugin as a1, writeGlobalVarScanCache as a2, appendTailwindSourceDirective as b, assertNoRSCBoundaryViolation as c, assertNoRSCGraphViolation as d, collectMangleHybridHazards as e, computeSafelistRelPath as f, createGlobalVarAliasValidationOptions as g, createGlobalVarMapAssetSource as h, createGlobalVarScanCacheKey as i, createRSCModuleRecord as j, cssHasContentScope as k, cssImportsTailwind as l, deleteRSCModuleRecord as m, esbuildPlugin as n, extractGlobalVarAliasesForManifest as o, fileMayContainSafelistableSz as p, findLocalImportSources as q, findRSCBoundaryViolation as r, findRSCGraphViolation as s, hasInjectableTailwindCandidate as t, unplugin as u, hasTokens as v, hasUseClientDirective as w, hasUseServerDirective as x, isCompileSourceOptedIn as y, isHardIgnoredPath as z };
|
|
@@ -725,6 +725,20 @@ declare function fileMayContainSafelistableSz(content: string): boolean;
|
|
|
725
725
|
* @returns Owned classes with hybrid raw consumers removed.
|
|
726
726
|
*/
|
|
727
727
|
declare function mangleEligibleClasses(ownedClasses: ReadonlySet<string>, authoredClasses: ReadonlySet<string>): string[];
|
|
728
|
+
/**
|
|
729
|
+
* Allocate a short token per eligible class, skipping forbidden names.
|
|
730
|
+
*
|
|
731
|
+
* The forbidden set carries `mangleExclude`, every authored class, AND every
|
|
732
|
+
* owned class name. Reserving the owned names keeps the map's key space and
|
|
733
|
+
* token space disjoint, which is what lets a runtime consumer resolve a token
|
|
734
|
+
* with one map lookup: a string that is a map key is always an original class,
|
|
735
|
+
* never a token some other class was mangled to.
|
|
736
|
+
*
|
|
737
|
+
* @param eligibleClasses Classes to mangle, in stable sorted order.
|
|
738
|
+
* @param forbiddenTokens Names the allocator must never emit as a token.
|
|
739
|
+
* @returns The class → token map.
|
|
740
|
+
*/
|
|
741
|
+
declare function allocateMangleTokens(eligibleClasses: readonly string[], forbiddenTokens: ReadonlySet<string>): Record<string, string>;
|
|
728
742
|
/**
|
|
729
743
|
* Whether a file is workspace-package source that csszyx skipped only because it
|
|
730
744
|
* lives under `/packages/` and is not under any opted-in `compileSources`
|
|
@@ -855,5 +869,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
855
869
|
*/
|
|
856
870
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
857
871
|
|
|
858
|
-
export {
|
|
872
|
+
export { mangleHybridHazardMessage as $, cssImportsTailwind as A, unplugin as B, deleteRSCModuleRecord as D, esbuildPlugin as E, extractGlobalVarAliasesForManifest as F, fileMayContainSafelistableSz as H, findLocalImportSources as I, findRSCBoundaryViolation as J, findRSCGraphViolation as K, hasInjectableTailwindCandidate as L, hasTokens as N, hasUseClientDirective as O, hasUseServerDirective as Q, isCompileSourceOptedIn as T, isHardIgnoredPath as U, isMonorepoPackage as W, isPackagesSkippedSource as X, isRSCServerModule as Y, mangleCodeClassesSync as Z, mangleEligibleClasses as _, mergeThemes as a0, missingTailwindEntryMessage as a1, normalizeGlobalVarAliasesForCache as a2, parseThemeBlocks as a3, recordGlobalVarSourceFile as a4, resolveCompileSourceDirs as a5, resolveNativeCacheIdentity as a6, rollupPlugin as a7, scanCustomPropertyNames as a8, shouldEmitWarning as a9, shouldTrackGlobalVarSources as aa, shouldWarnMissingTailwindEntry as ab, shouldWarnUnscopedMonorepo as ac, skippedSzFilesMessage as ad, unscopedMonorepoMessage as ae, vitePlugin as af, webpackPlugin as ag, allocateMangleTokens as r, appendTailwindSourceDirective as s, assertNoRSCBoundaryViolation as t, assertNoRSCGraphViolation as u, collectMangleHybridHazards as v, computeSafelistRelPath as w, createGlobalVarMapAssetSource as x, createRSCModuleRecord as y, cssHasContentScope as z };
|
|
859
873
|
export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n, ParsedTheme as o, RSCBoundaryViolation as p, RSCModuleRecord as q };
|
|
@@ -725,6 +725,20 @@ declare function fileMayContainSafelistableSz(content: string): boolean;
|
|
|
725
725
|
* @returns Owned classes with hybrid raw consumers removed.
|
|
726
726
|
*/
|
|
727
727
|
declare function mangleEligibleClasses(ownedClasses: ReadonlySet<string>, authoredClasses: ReadonlySet<string>): string[];
|
|
728
|
+
/**
|
|
729
|
+
* Allocate a short token per eligible class, skipping forbidden names.
|
|
730
|
+
*
|
|
731
|
+
* The forbidden set carries `mangleExclude`, every authored class, AND every
|
|
732
|
+
* owned class name. Reserving the owned names keeps the map's key space and
|
|
733
|
+
* token space disjoint, which is what lets a runtime consumer resolve a token
|
|
734
|
+
* with one map lookup: a string that is a map key is always an original class,
|
|
735
|
+
* never a token some other class was mangled to.
|
|
736
|
+
*
|
|
737
|
+
* @param eligibleClasses Classes to mangle, in stable sorted order.
|
|
738
|
+
* @param forbiddenTokens Names the allocator must never emit as a token.
|
|
739
|
+
* @returns The class → token map.
|
|
740
|
+
*/
|
|
741
|
+
declare function allocateMangleTokens(eligibleClasses: readonly string[], forbiddenTokens: ReadonlySet<string>): Record<string, string>;
|
|
728
742
|
/**
|
|
729
743
|
* Whether a file is workspace-package source that csszyx skipped only because it
|
|
730
744
|
* lives under `/packages/` and is not under any opted-in `compileSources`
|
|
@@ -855,5 +869,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
855
869
|
*/
|
|
856
870
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
857
871
|
|
|
858
|
-
export {
|
|
872
|
+
export { mangleHybridHazardMessage as $, cssImportsTailwind as A, unplugin as B, deleteRSCModuleRecord as D, esbuildPlugin as E, extractGlobalVarAliasesForManifest as F, fileMayContainSafelistableSz as H, findLocalImportSources as I, findRSCBoundaryViolation as J, findRSCGraphViolation as K, hasInjectableTailwindCandidate as L, hasTokens as N, hasUseClientDirective as O, hasUseServerDirective as Q, isCompileSourceOptedIn as T, isHardIgnoredPath as U, isMonorepoPackage as W, isPackagesSkippedSource as X, isRSCServerModule as Y, mangleCodeClassesSync as Z, mangleEligibleClasses as _, mergeThemes as a0, missingTailwindEntryMessage as a1, normalizeGlobalVarAliasesForCache as a2, parseThemeBlocks as a3, recordGlobalVarSourceFile as a4, resolveCompileSourceDirs as a5, resolveNativeCacheIdentity as a6, rollupPlugin as a7, scanCustomPropertyNames as a8, shouldEmitWarning as a9, shouldTrackGlobalVarSources as aa, shouldWarnMissingTailwindEntry as ab, shouldWarnUnscopedMonorepo as ac, skippedSzFilesMessage as ad, unscopedMonorepoMessage as ae, vitePlugin as af, webpackPlugin as ag, allocateMangleTokens as r, appendTailwindSourceDirective as s, assertNoRSCBoundaryViolation as t, assertNoRSCGraphViolation as u, collectMangleHybridHazards as v, computeSafelistRelPath as w, createGlobalVarMapAssetSource as x, createRSCModuleRecord as y, cssHasContentScope as z };
|
|
859
873
|
export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n, ParsedTheme as o, RSCBoundaryViolation as p, RSCModuleRecord as q };
|
|
@@ -2157,7 +2157,7 @@ export default checksum;
|
|
|
2157
2157
|
`;
|
|
2158
2158
|
}
|
|
2159
2159
|
function isVirtualModule(id) {
|
|
2160
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID;
|
|
2160
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
2161
2161
|
}
|
|
2162
2162
|
function resolveVirtualModule(id) {
|
|
2163
2163
|
if (id === VIRTUAL_MODULE_ID) {
|
|
@@ -2169,8 +2169,56 @@ function resolveVirtualModule(id) {
|
|
|
2169
2169
|
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
2170
2170
|
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
2171
2171
|
}
|
|
2172
|
+
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
2173
|
+
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
2174
|
+
}
|
|
2172
2175
|
return void 0;
|
|
2173
2176
|
}
|
|
2177
|
+
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
2178
|
+
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
2179
|
+
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
2180
|
+
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
2181
|
+
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
2182
|
+
function createMangleRuntimeModule(globalVarAliasPrefix) {
|
|
2183
|
+
return `/**
|
|
2184
|
+
* Auto-generated by csszyx: installs the runtime mangle map from the bundle.
|
|
2185
|
+
*
|
|
2186
|
+
* @generated
|
|
2187
|
+
*/
|
|
2188
|
+
|
|
2189
|
+
const m = ${MANGLE_MAP_PLACEHOLDER};
|
|
2190
|
+
const vm = ${VAR_MANGLE_MAP_PLACEHOLDER};
|
|
2191
|
+
const gp = ${JSON.stringify(globalVarAliasPrefix)};
|
|
2192
|
+
const checksum = "${CHECKSUM_PLACEHOLDER}";
|
|
2193
|
+
|
|
2194
|
+
if (typeof window !== 'undefined' && !window.__csszyx) {
|
|
2195
|
+
const r = {};
|
|
2196
|
+
const vr = {};
|
|
2197
|
+
for (const k in m) r[m[k]] = k;
|
|
2198
|
+
for (const vk in vm) {
|
|
2199
|
+
const vv = vm[vk];
|
|
2200
|
+
const vs = Array.isArray(vv) ? vv : [vv];
|
|
2201
|
+
for (const v of vs) (vr[v] || (vr[v] = [])).push(vk);
|
|
2202
|
+
}
|
|
2203
|
+
window.__csszyx = {
|
|
2204
|
+
mangleMap: m,
|
|
2205
|
+
varMangleMap: vm,
|
|
2206
|
+
checksum,
|
|
2207
|
+
decode: (c) => r[c],
|
|
2208
|
+
encode: (c) => m[c],
|
|
2209
|
+
decodeVar: (v) => vr[v] || [],
|
|
2210
|
+
encodeVar: (v) => vm[v],
|
|
2211
|
+
decodeGlobalVar: (v) => {
|
|
2212
|
+
const a = vr[v] || [];
|
|
2213
|
+
return v.indexOf(gp) === 0 ? a[0] : undefined;
|
|
2214
|
+
},
|
|
2215
|
+
decodeAll: (el) => (el.className || '').split(' ').map((c) => r[c] || c),
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
export {};
|
|
2220
|
+
`;
|
|
2221
|
+
}
|
|
2174
2222
|
function createThemeGroupsModule(tokens) {
|
|
2175
2223
|
const payload = JSON.stringify({
|
|
2176
2224
|
colors: tokens.colors,
|
|
@@ -2195,9 +2243,6 @@ function registerWebpackAssetProcessor(compiler, processAssets) {
|
|
|
2195
2243
|
);
|
|
2196
2244
|
});
|
|
2197
2245
|
}
|
|
2198
|
-
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
2199
|
-
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
2200
|
-
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
2201
2246
|
const UNKNOWN_PACKAGE_VERSION = "0.0.0";
|
|
2202
2247
|
const TRANSFORM_CACHE_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
2203
2248
|
const TRANSFORM_CACHE_MAX_ENTRIES = 1e4;
|
|
@@ -2231,9 +2276,9 @@ let _hasWarnedTransformCacheVersion = false;
|
|
|
2231
2276
|
let _hasWarnedNativeFallback = false;
|
|
2232
2277
|
const _loggedActiveParsers = /* @__PURE__ */ new Set();
|
|
2233
2278
|
const _babelFallbackFiles = /* @__PURE__ */ new Set();
|
|
2234
|
-
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.
|
|
2279
|
+
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.CJcFsJcf.cjs', document.baseURI).href)));
|
|
2235
2280
|
const PLUGIN_VERSION = findPackageVersionFromFile(
|
|
2236
|
-
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.
|
|
2281
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.CJcFsJcf.cjs', document.baseURI).href))),
|
|
2237
2282
|
UNKNOWN_PACKAGE_VERSION
|
|
2238
2283
|
);
|
|
2239
2284
|
const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
|
|
@@ -2453,6 +2498,30 @@ function fileMayContainSafelistableSz(content) {
|
|
|
2453
2498
|
function mangleEligibleClasses(ownedClasses, authoredClasses) {
|
|
2454
2499
|
return compiler.sortStrings([...ownedClasses].filter((className) => !authoredClasses.has(className)));
|
|
2455
2500
|
}
|
|
2501
|
+
const tokenByIndex = [];
|
|
2502
|
+
function tokenAt(index) {
|
|
2503
|
+
const cached = tokenByIndex[index];
|
|
2504
|
+
if (cached !== void 0) {
|
|
2505
|
+
return cached;
|
|
2506
|
+
}
|
|
2507
|
+
const fresh = core.encode(index);
|
|
2508
|
+
tokenByIndex[index] = fresh;
|
|
2509
|
+
return fresh;
|
|
2510
|
+
}
|
|
2511
|
+
function allocateMangleTokens(eligibleClasses, forbiddenTokens) {
|
|
2512
|
+
const map = {};
|
|
2513
|
+
let tokenIndex = 0;
|
|
2514
|
+
for (const className of eligibleClasses) {
|
|
2515
|
+
let token = tokenAt(tokenIndex);
|
|
2516
|
+
while (forbiddenTokens.has(token)) {
|
|
2517
|
+
tokenIndex++;
|
|
2518
|
+
token = tokenAt(tokenIndex);
|
|
2519
|
+
}
|
|
2520
|
+
map[className] = token;
|
|
2521
|
+
tokenIndex++;
|
|
2522
|
+
}
|
|
2523
|
+
return map;
|
|
2524
|
+
}
|
|
2456
2525
|
function isPackagesSkippedSource(id, sourceDirs = []) {
|
|
2457
2526
|
const p = normalizeForMatch(id);
|
|
2458
2527
|
if (p.includes("node_modules")) {
|
|
@@ -3850,18 +3919,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3850
3919
|
}
|
|
3851
3920
|
}
|
|
3852
3921
|
function finalizeMangleMap() {
|
|
3853
|
-
const
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
tokenIndex++;
|
|
3863
|
-
}
|
|
3864
|
-
state.mangleMap = newMap;
|
|
3922
|
+
const forbiddenTokens = /* @__PURE__ */ new Set([
|
|
3923
|
+
...mangleReserved,
|
|
3924
|
+
...state.authoredClasses,
|
|
3925
|
+
...state.ownedClasses
|
|
3926
|
+
]);
|
|
3927
|
+
state.mangleMap = allocateMangleTokens(
|
|
3928
|
+
mangleEligibleClasses(state.ownedClasses, state.authoredClasses),
|
|
3929
|
+
forbiddenTokens
|
|
3930
|
+
);
|
|
3865
3931
|
assertVarMangleMapSize(state.varMangleMap, varMangleMapMaxBytes);
|
|
3866
3932
|
state.checksum = core.compute_mangle_checksum(
|
|
3867
3933
|
createHydrationMangleMap(state.mangleMap, state.varMangleMap)
|
|
@@ -3894,14 +3960,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3894
3960
|
if (result.includes(CHECKSUM_PLACEHOLDER)) {
|
|
3895
3961
|
result = result.split(CHECKSUM_PLACEHOLDER).join(state.checksum);
|
|
3896
3962
|
}
|
|
3963
|
+
const isEvalWrapped = result.includes("eval(") && result.includes("sourceURL=webpack");
|
|
3897
3964
|
if (result.includes(MANGLE_MAP_PLACEHOLDER)) {
|
|
3898
3965
|
const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.mangleMap));
|
|
3899
|
-
const escapedMap =
|
|
3966
|
+
const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
|
|
3900
3967
|
result = result.split(MANGLE_MAP_PLACEHOLDER).join(escapedMap);
|
|
3901
3968
|
}
|
|
3902
3969
|
if (result.includes(VAR_MANGLE_MAP_PLACEHOLDER)) {
|
|
3903
3970
|
const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.varMangleMap));
|
|
3904
|
-
const escapedMap =
|
|
3971
|
+
const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
|
|
3905
3972
|
result = result.split(VAR_MANGLE_MAP_PLACEHOLDER).join(escapedMap);
|
|
3906
3973
|
}
|
|
3907
3974
|
return result;
|
|
@@ -4032,6 +4099,18 @@ function createCsszyxPlugins(options = {}) {
|
|
|
4032
4099
|
}
|
|
4033
4100
|
return `import '${THEME_GROUPS_VIRTUAL_ID}';
|
|
4034
4101
|
${transformedCode}`;
|
|
4102
|
+
}
|
|
4103
|
+
const MANGLE_RUNTIME_CONSUMER_RE = /from\s*['"](?:csszyx|@csszyx\/runtime)['"]/;
|
|
4104
|
+
let activeFramework;
|
|
4105
|
+
function injectMangleRuntime(transformedCode, id) {
|
|
4106
|
+
if (activeFramework !== "vite" && activeFramework !== "rollup") {
|
|
4107
|
+
return null;
|
|
4108
|
+
}
|
|
4109
|
+
if (!manglingEnabled || !shouldProcessSource(id) || !MANGLE_RUNTIME_CONSUMER_RE.test(transformedCode) || transformedCode.includes(MANGLE_RUNTIME_VIRTUAL_ID)) {
|
|
4110
|
+
return null;
|
|
4111
|
+
}
|
|
4112
|
+
return insertRuntimeImport(transformedCode, `import '${MANGLE_RUNTIME_VIRTUAL_ID}';
|
|
4113
|
+
`);
|
|
4035
4114
|
}
|
|
4036
4115
|
function collectPreTransformClasses(output) {
|
|
4037
4116
|
if (!output.transformed && !output.code.includes("class=") && !output.code.includes("className=")) {
|
|
@@ -4075,7 +4154,7 @@ ${transformedCode}`;
|
|
|
4075
4154
|
* @returns true only for csszyx virtual modules
|
|
4076
4155
|
*/
|
|
4077
4156
|
loadInclude(id) {
|
|
4078
|
-
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
4157
|
+
return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID || id === RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
4079
4158
|
},
|
|
4080
4159
|
/**
|
|
4081
4160
|
* Loads virtual module content — generates mangle map or checksum module code.
|
|
@@ -4096,6 +4175,9 @@ ${transformedCode}`;
|
|
|
4096
4175
|
finalizeMangleMap();
|
|
4097
4176
|
return createChecksumModule(state.checksum);
|
|
4098
4177
|
}
|
|
4178
|
+
if (id === RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
4179
|
+
return createMangleRuntimeModule(globalVarAliasPrefix);
|
|
4180
|
+
}
|
|
4099
4181
|
if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
|
|
4100
4182
|
const theme = state.parsedTheme;
|
|
4101
4183
|
return createThemeGroupsModule({
|
|
@@ -4162,6 +4244,11 @@ ${transformedCode}`;
|
|
|
4162
4244
|
output.code = themedCode;
|
|
4163
4245
|
output.transformed = true;
|
|
4164
4246
|
}
|
|
4247
|
+
const mangleRuntimeCode = injectMangleRuntime(output.code, id);
|
|
4248
|
+
if (mangleRuntimeCode !== null) {
|
|
4249
|
+
output.code = mangleRuntimeCode;
|
|
4250
|
+
output.transformed = true;
|
|
4251
|
+
}
|
|
4165
4252
|
if (matchesScriptExtension(id, SCRIPT_ID_EXTENSIONS)) {
|
|
4166
4253
|
assertNoRSCBoundaryViolation(output.code, id);
|
|
4167
4254
|
const record = createRSCModuleRecord(output.code, id);
|
|
@@ -4225,6 +4312,10 @@ ${transformedCode}`;
|
|
|
4225
4312
|
* @param compiler - the Webpack compiler instance
|
|
4226
4313
|
*/
|
|
4227
4314
|
webpack(compiler) {
|
|
4315
|
+
activeFramework = "webpack";
|
|
4316
|
+
if (compiler.options?.mode === "development") {
|
|
4317
|
+
manglingEnabled = false;
|
|
4318
|
+
}
|
|
4228
4319
|
compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
|
|
4229
4320
|
announceActiveParser();
|
|
4230
4321
|
const root = compiler.context || process.cwd();
|
|
@@ -4245,6 +4336,12 @@ ${transformedCode}`;
|
|
|
4245
4336
|
});
|
|
4246
4337
|
}
|
|
4247
4338
|
},
|
|
4339
|
+
rollup: {
|
|
4340
|
+
/** Records the rollup lane for the mangle-runtime gate. */
|
|
4341
|
+
buildStart() {
|
|
4342
|
+
activeFramework = "rollup";
|
|
4343
|
+
}
|
|
4344
|
+
},
|
|
4248
4345
|
vite: {
|
|
4249
4346
|
/**
|
|
4250
4347
|
* Vite hook: pre-scans source files when config is resolved.
|
|
@@ -4252,6 +4349,7 @@ ${transformedCode}`;
|
|
|
4252
4349
|
* @param config - the resolved Vite configuration object
|
|
4253
4350
|
*/
|
|
4254
4351
|
configResolved(config) {
|
|
4352
|
+
activeFramework = "vite";
|
|
4255
4353
|
announceActiveParser();
|
|
4256
4354
|
const root = config.root || process.cwd();
|
|
4257
4355
|
state.rootDir = root;
|
|
@@ -4618,6 +4716,7 @@ const esbuildPlugin = (options = {}) => {
|
|
|
4618
4716
|
};
|
|
4619
4717
|
};
|
|
4620
4718
|
|
|
4719
|
+
exports.allocateMangleTokens = allocateMangleTokens;
|
|
4621
4720
|
exports.appendTailwindSourceDirective = appendTailwindSourceDirective;
|
|
4622
4721
|
exports.assertNoRSCBoundaryViolation = assertNoRSCBoundaryViolation;
|
|
4623
4722
|
exports.assertNoRSCGraphViolation = assertNoRSCGraphViolation;
|
package/dist/vite.cjs
CHANGED
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
package/dist/webpack.cjs
CHANGED
package/dist/webpack.d.cts
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/unplugin",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.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": "^3.3.0",
|
|
120
|
-
"@csszyx/compiler": "0.11.
|
|
121
|
-
"@csszyx/
|
|
122
|
-
"@csszyx/
|
|
123
|
-
"@csszyx/
|
|
124
|
-
"@csszyx/
|
|
120
|
+
"@csszyx/compiler": "0.11.11",
|
|
121
|
+
"@csszyx/svelte-adapter": "0.11.11",
|
|
122
|
+
"@csszyx/core": "0.11.11",
|
|
123
|
+
"@csszyx/types": "0.11.11",
|
|
124
|
+
"@csszyx/vue-adapter": "0.11.11"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@csszyx/runtime": "^0.11.
|
|
127
|
+
"@csszyx/runtime": "^0.11.11"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@tailwindcss/node": "4.3.3",
|