@csszyx/unplugin 0.11.9 → 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 +4 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/next-prebuild.cjs +3 -3
- package/dist/next-prebuild.d.cts +1 -1
- package/dist/next-prebuild.d.mts +1 -1
- package/dist/next-prebuild.mjs +3 -3
- package/dist/next-turbo-loader.cjs +4 -4
- package/dist/next-turbo-loader.d.cts +1 -1
- package/dist/next-turbo-loader.d.mts +1 -1
- package/dist/next-turbo-loader.mjs +4 -4
- package/dist/next-watcher.cjs +1 -1
- package/dist/next-watcher.mjs +1 -1
- package/dist/shared/{unplugin.Bqx2WfBV.mjs → unplugin.-yLpX1Ck.mjs} +2 -2
- package/dist/shared/{unplugin.wx3cvxxX.mjs → unplugin.B2RUVK6Z.mjs} +135 -39
- 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.jZsBqx54.cjs → unplugin.BZq6FKn2.cjs} +2 -2
- package/dist/shared/{unplugin.DUI48s3S.cjs → unplugin.CJcFsJcf.cjs} +137 -40
- package/dist/shared/{unplugin.DVCQC5wq.cjs → unplugin.CKIOVNOg.cjs} +9 -0
- package/dist/shared/{unplugin.CScQRdTp.d.cts → unplugin.CXV7fOa2.d.cts} +1 -1
- package/dist/shared/{unplugin.CScQRdTp.d.mts → unplugin.CXV7fOa2.d.mts} +1 -1
- package/dist/shared/{unplugin.DmuOKVS4.cjs → unplugin.Cnxm1DcC.cjs} +2 -2
- package/dist/shared/{unplugin.nnsa7OVW.mjs → unplugin.Lhzkcj-A.mjs} +2 -2
- package/dist/shared/{unplugin.D-K57LNR.mjs → unplugin.fOnGXWgS.mjs} +9 -1
- package/dist/vite.cjs +3 -3
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +3 -3
- package/dist/webpack.cjs +3 -3
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +3 -3
- package/package.json +17 -17
- package/dist/shared/{unplugin.7TELUwsj.mjs → unplugin.DMcbmP01.mjs} +46 -46
- package/dist/shared/{unplugin.WVn08Fln.cjs → unplugin.DblMogcN.cjs} +46 -46
|
@@ -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 };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const compiler = require('@csszyx/compiler');
|
|
5
|
-
const transformCache = require('./unplugin.
|
|
5
|
+
const transformCache = require('./unplugin.CKIOVNOg.cjs');
|
|
6
6
|
const node_crypto = require('node:crypto');
|
|
7
7
|
const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
|
|
8
8
|
|
|
@@ -150,7 +150,7 @@ function runNextSourceTransform(input, filename) {
|
|
|
150
150
|
throw error;
|
|
151
151
|
}
|
|
152
152
|
const result = compiler.transformSourceCode(input.source, filename, compilerOptions);
|
|
153
|
-
const reason =
|
|
153
|
+
const reason = transformCache.babelFallbackReason(error);
|
|
154
154
|
result.diagnostics.push(
|
|
155
155
|
`[csszyx] oxc parser fell back to Babel for ${filename}: ${reason}`
|
|
156
156
|
);
|
|
@@ -13,9 +13,9 @@ const svelteAdapter = require('@csszyx/svelte-adapter');
|
|
|
13
13
|
const types = require('@csszyx/types');
|
|
14
14
|
const vueAdapter = require('@csszyx/vue-adapter');
|
|
15
15
|
const unplugin$1 = require('unplugin');
|
|
16
|
+
const transformCache = require('./unplugin.CKIOVNOg.cjs');
|
|
16
17
|
const cssMangler = require('../css-mangler.cjs');
|
|
17
|
-
const runtimeImportScan = require('./unplugin.
|
|
18
|
-
const transformCache = require('./unplugin.DVCQC5wq.cjs');
|
|
18
|
+
const runtimeImportScan = require('./unplugin.Cnxm1DcC.cjs');
|
|
19
19
|
const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
|
|
20
20
|
const postcss = require('postcss');
|
|
21
21
|
const valueParser = require('postcss-value-parser');
|
|
@@ -456,8 +456,8 @@ function scanCssSourceWithOptionalCache(file, cacheDir) {
|
|
|
456
456
|
return result;
|
|
457
457
|
}
|
|
458
458
|
function normalizeBuildAssetPath(rootDir, fileName) {
|
|
459
|
-
return (path__namespace.isAbsolute(fileName) ? fileName : path__namespace.join(rootDir, fileName)).
|
|
460
|
-
|
|
459
|
+
return (path__namespace.isAbsolute(fileName) ? fileName : path__namespace.join(rootDir, fileName)).replaceAll(
|
|
460
|
+
"\\",
|
|
461
461
|
"/"
|
|
462
462
|
);
|
|
463
463
|
}
|
|
@@ -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")) {
|
|
@@ -2596,6 +2665,9 @@ function rewriteCssWithValidatedGlobalVarPlan(css, filePath, result) {
|
|
|
2596
2665
|
});
|
|
2597
2666
|
return rewrite.css;
|
|
2598
2667
|
}
|
|
2668
|
+
function isCssSyntaxError(error) {
|
|
2669
|
+
return !!error && typeof error === "object" && "name" in error && error.name === "CssSyntaxError";
|
|
2670
|
+
}
|
|
2599
2671
|
function assertGlobalVarPlanMatchesEarlyAliases(result, expectedEntries) {
|
|
2600
2672
|
const actualEntries = [...result.plan.aliases.entries()].sort(
|
|
2601
2673
|
([left], [right]) => left.localeCompare(right)
|
|
@@ -2885,6 +2957,14 @@ function scanClassExpression(source, from) {
|
|
|
2885
2957
|
}
|
|
2886
2958
|
return index;
|
|
2887
2959
|
}
|
|
2960
|
+
function findTemplateInterpolationEnd(templateContent, bodyStart) {
|
|
2961
|
+
let depth = 0;
|
|
2962
|
+
for (let cursor = bodyStart; cursor < templateContent.length; cursor++) {
|
|
2963
|
+
if (templateContent[cursor] === "{") depth++;
|
|
2964
|
+
else if (templateContent[cursor] === "}" && depth-- === 0) return cursor + 1;
|
|
2965
|
+
}
|
|
2966
|
+
return templateContent.length;
|
|
2967
|
+
}
|
|
2888
2968
|
function mangleCodeClassesSync(code, mangleMap) {
|
|
2889
2969
|
function mangleClassString(classString) {
|
|
2890
2970
|
return classString.split(/\s+/).filter(Boolean).map((cls) => {
|
|
@@ -2923,14 +3003,6 @@ function mangleCodeClassesSync(code, mangleMap) {
|
|
|
2923
3003
|
changed: mangled !== trimmed
|
|
2924
3004
|
};
|
|
2925
3005
|
}
|
|
2926
|
-
function findTemplateInterpolationEnd(templateContent, bodyStart) {
|
|
2927
|
-
let depth = 0;
|
|
2928
|
-
for (let cursor = bodyStart; cursor < templateContent.length; cursor++) {
|
|
2929
|
-
if (templateContent[cursor] === "{") depth++;
|
|
2930
|
-
else if (templateContent[cursor] === "}" && depth-- === 0) return cursor + 1;
|
|
2931
|
-
}
|
|
2932
|
-
return templateContent.length;
|
|
2933
|
-
}
|
|
2934
3006
|
function mangleTemplateInterpolation(inner) {
|
|
2935
3007
|
let changed = false;
|
|
2936
3008
|
const value = inner.replace(/"([^"]*)"/g, (quoted, classString) => {
|
|
@@ -3422,7 +3494,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3422
3494
|
}
|
|
3423
3495
|
function runBabelFallback(source, effectiveFilename, compilerOptions, error) {
|
|
3424
3496
|
const result = compiler.transformSourceCode(source, effectiveFilename, compilerOptions);
|
|
3425
|
-
const reason =
|
|
3497
|
+
const reason = transformCache.babelFallbackReason(error);
|
|
3426
3498
|
result.diagnostics.push(
|
|
3427
3499
|
`[csszyx] oxc parser fell back to Babel for ${effectiveFilename}: ${reason}`
|
|
3428
3500
|
);
|
|
@@ -3847,18 +3919,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3847
3919
|
}
|
|
3848
3920
|
}
|
|
3849
3921
|
function finalizeMangleMap() {
|
|
3850
|
-
const
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
tokenIndex++;
|
|
3860
|
-
}
|
|
3861
|
-
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
|
+
);
|
|
3862
3931
|
assertVarMangleMapSize(state.varMangleMap, varMangleMapMaxBytes);
|
|
3863
3932
|
state.checksum = core.compute_mangle_checksum(
|
|
3864
3933
|
createHydrationMangleMap(state.mangleMap, state.varMangleMap)
|
|
@@ -3891,14 +3960,15 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3891
3960
|
if (result.includes(CHECKSUM_PLACEHOLDER)) {
|
|
3892
3961
|
result = result.split(CHECKSUM_PLACEHOLDER).join(state.checksum);
|
|
3893
3962
|
}
|
|
3963
|
+
const isEvalWrapped = result.includes("eval(") && result.includes("sourceURL=webpack");
|
|
3894
3964
|
if (result.includes(MANGLE_MAP_PLACEHOLDER)) {
|
|
3895
3965
|
const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.mangleMap));
|
|
3896
|
-
const escapedMap =
|
|
3966
|
+
const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
|
|
3897
3967
|
result = result.split(MANGLE_MAP_PLACEHOLDER).join(escapedMap);
|
|
3898
3968
|
}
|
|
3899
3969
|
if (result.includes(VAR_MANGLE_MAP_PLACEHOLDER)) {
|
|
3900
3970
|
const jsonMap = escapeJsonForInlineScript(JSON.stringify(state.varMangleMap));
|
|
3901
|
-
const escapedMap =
|
|
3971
|
+
const escapedMap = isEvalWrapped ? escapeForDoubleQuotedString(jsonMap) : jsonMap;
|
|
3902
3972
|
result = result.split(VAR_MANGLE_MAP_PLACEHOLDER).join(escapedMap);
|
|
3903
3973
|
}
|
|
3904
3974
|
return result;
|
|
@@ -4029,6 +4099,18 @@ function createCsszyxPlugins(options = {}) {
|
|
|
4029
4099
|
}
|
|
4030
4100
|
return `import '${THEME_GROUPS_VIRTUAL_ID}';
|
|
4031
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
|
+
`);
|
|
4032
4114
|
}
|
|
4033
4115
|
function collectPreTransformClasses(output) {
|
|
4034
4116
|
if (!output.transformed && !output.code.includes("class=") && !output.code.includes("className=")) {
|
|
@@ -4072,7 +4154,7 @@ ${transformedCode}`;
|
|
|
4072
4154
|
* @returns true only for csszyx virtual modules
|
|
4073
4155
|
*/
|
|
4074
4156
|
loadInclude(id) {
|
|
4075
|
-
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;
|
|
4076
4158
|
},
|
|
4077
4159
|
/**
|
|
4078
4160
|
* Loads virtual module content — generates mangle map or checksum module code.
|
|
@@ -4093,6 +4175,9 @@ ${transformedCode}`;
|
|
|
4093
4175
|
finalizeMangleMap();
|
|
4094
4176
|
return createChecksumModule(state.checksum);
|
|
4095
4177
|
}
|
|
4178
|
+
if (id === RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
4179
|
+
return createMangleRuntimeModule(globalVarAliasPrefix);
|
|
4180
|
+
}
|
|
4096
4181
|
if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
|
|
4097
4182
|
const theme = state.parsedTheme;
|
|
4098
4183
|
return createThemeGroupsModule({
|
|
@@ -4159,6 +4244,11 @@ ${transformedCode}`;
|
|
|
4159
4244
|
output.code = themedCode;
|
|
4160
4245
|
output.transformed = true;
|
|
4161
4246
|
}
|
|
4247
|
+
const mangleRuntimeCode = injectMangleRuntime(output.code, id);
|
|
4248
|
+
if (mangleRuntimeCode !== null) {
|
|
4249
|
+
output.code = mangleRuntimeCode;
|
|
4250
|
+
output.transformed = true;
|
|
4251
|
+
}
|
|
4162
4252
|
if (matchesScriptExtension(id, SCRIPT_ID_EXTENSIONS)) {
|
|
4163
4253
|
assertNoRSCBoundaryViolation(output.code, id);
|
|
4164
4254
|
const record = createRSCModuleRecord(output.code, id);
|
|
@@ -4179,9 +4269,7 @@ ${transformedCode}`;
|
|
|
4179
4269
|
emitWarning(missingTailwindEntryMessage(state.ownedClasses.size));
|
|
4180
4270
|
}
|
|
4181
4271
|
if (!state.contentScopeWarningEmitted && options.contentScopeCheck !== false && state.sawTailwindEntry && !state.tailwindEntryScoped) {
|
|
4182
|
-
|
|
4183
|
-
state.inMonorepo = isMonorepoPackage(state.rootDir);
|
|
4184
|
-
}
|
|
4272
|
+
state.inMonorepo ??= isMonorepoPackage(state.rootDir);
|
|
4185
4273
|
if (shouldWarnUnscopedMonorepo(
|
|
4186
4274
|
state.sawTailwindEntry,
|
|
4187
4275
|
state.tailwindEntryScoped,
|
|
@@ -4224,6 +4312,10 @@ ${transformedCode}`;
|
|
|
4224
4312
|
* @param compiler - the Webpack compiler instance
|
|
4225
4313
|
*/
|
|
4226
4314
|
webpack(compiler) {
|
|
4315
|
+
activeFramework = "webpack";
|
|
4316
|
+
if (compiler.options?.mode === "development") {
|
|
4317
|
+
manglingEnabled = false;
|
|
4318
|
+
}
|
|
4227
4319
|
compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
|
|
4228
4320
|
announceActiveParser();
|
|
4229
4321
|
const root = compiler.context || process.cwd();
|
|
@@ -4244,6 +4336,12 @@ ${transformedCode}`;
|
|
|
4244
4336
|
});
|
|
4245
4337
|
}
|
|
4246
4338
|
},
|
|
4339
|
+
rollup: {
|
|
4340
|
+
/** Records the rollup lane for the mangle-runtime gate. */
|
|
4341
|
+
buildStart() {
|
|
4342
|
+
activeFramework = "rollup";
|
|
4343
|
+
}
|
|
4344
|
+
},
|
|
4247
4345
|
vite: {
|
|
4248
4346
|
/**
|
|
4249
4347
|
* Vite hook: pre-scans source files when config is resolved.
|
|
@@ -4251,6 +4349,7 @@ ${transformedCode}`;
|
|
|
4251
4349
|
* @param config - the resolved Vite configuration object
|
|
4252
4350
|
*/
|
|
4253
4351
|
configResolved(config) {
|
|
4352
|
+
activeFramework = "vite";
|
|
4254
4353
|
announceActiveParser();
|
|
4255
4354
|
const root = config.root || process.cwd();
|
|
4256
4355
|
state.rootDir = root;
|
|
@@ -4406,9 +4505,6 @@ ${transformedCode}`;
|
|
|
4406
4505
|
}
|
|
4407
4506
|
return manifest;
|
|
4408
4507
|
}
|
|
4409
|
-
function isCssSyntaxError(error) {
|
|
4410
|
-
return !!error && typeof error === "object" && "name" in error && error.name === "CssSyntaxError";
|
|
4411
|
-
}
|
|
4412
4508
|
function rewriteOutputCss(source, file, shouldMangle, mangledSources, externalClasses) {
|
|
4413
4509
|
let css = rewriteCssWithValidatedGlobalVarPlan(
|
|
4414
4510
|
source,
|
|
@@ -4620,6 +4716,7 @@ const esbuildPlugin = (options = {}) => {
|
|
|
4620
4716
|
};
|
|
4621
4717
|
};
|
|
4622
4718
|
|
|
4719
|
+
exports.allocateMangleTokens = allocateMangleTokens;
|
|
4623
4720
|
exports.appendTailwindSourceDirective = appendTailwindSourceDirective;
|
|
4624
4721
|
exports.assertNoRSCBoundaryViolation = assertNoRSCBoundaryViolation;
|
|
4625
4722
|
exports.assertNoRSCGraphViolation = assertNoRSCGraphViolation;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const compiler = require('@csszyx/compiler');
|
|
3
4
|
const node_crypto = require('node:crypto');
|
|
4
5
|
const fs = require('node:fs');
|
|
5
6
|
const path = require('node:path');
|
|
@@ -24,6 +25,13 @@ function normalizePathSeparators(value) {
|
|
|
24
25
|
return value.split(WINDOWS_PATH_SEPARATOR).join("/");
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
function babelFallbackReason(error) {
|
|
29
|
+
if (error instanceof compiler.OxcNotImplementedError) {
|
|
30
|
+
return error.detail;
|
|
31
|
+
}
|
|
32
|
+
return error instanceof Error ? error.message : String(error);
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
const CACHE_SCHEMA_VERSION = 10;
|
|
28
36
|
function resolveTransformCacheDir(rootDir, cacheDir) {
|
|
29
37
|
return path__namespace.resolve(rootDir, cacheDir ?? ".csszyx/cache", "transform");
|
|
@@ -223,6 +231,7 @@ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChar
|
|
|
223
231
|
return total;
|
|
224
232
|
}
|
|
225
233
|
|
|
234
|
+
exports.babelFallbackReason = babelFallbackReason;
|
|
226
235
|
exports.createTransformCacheKey = createTransformCacheKey;
|
|
227
236
|
exports.evictMemoryCacheToBudget = evictMemoryCacheToBudget;
|
|
228
237
|
exports.evictOldTransformCacheEntries = evictOldTransformCacheEntries;
|
|
@@ -11,13 +11,13 @@ function insertAfterUseDirective(code, insertion) {
|
|
|
11
11
|
if (triviaLength === 0) break;
|
|
12
12
|
offset += triviaLength;
|
|
13
13
|
}
|
|
14
|
-
const directive = code.slice(offset)
|
|
14
|
+
const directive = USE_DIRECTIVE_RE.exec(code.slice(offset));
|
|
15
15
|
if (!directive) return `${insertion}${code}`;
|
|
16
16
|
const insertionOffset = offset + directive[0].length;
|
|
17
17
|
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
18
18
|
}
|
|
19
19
|
function leadingTriviaLength(source) {
|
|
20
|
-
return
|
|
20
|
+
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
@@ -9,13 +9,13 @@ function insertAfterUseDirective(code, insertion) {
|
|
|
9
9
|
if (triviaLength === 0) break;
|
|
10
10
|
offset += triviaLength;
|
|
11
11
|
}
|
|
12
|
-
const directive = code.slice(offset)
|
|
12
|
+
const directive = USE_DIRECTIVE_RE.exec(code.slice(offset));
|
|
13
13
|
if (!directive) return `${insertion}${code}`;
|
|
14
14
|
const insertionOffset = offset + directive[0].length;
|
|
15
15
|
return `${code.slice(0, insertionOffset)}${insertion}${code.slice(insertionOffset)}`;
|
|
16
16
|
}
|
|
17
17
|
function leadingTriviaLength(source) {
|
|
18
|
-
return
|
|
18
|
+
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OxcNotImplementedError } from '@csszyx/compiler';
|
|
1
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
3
|
import * as fs from 'node:fs';
|
|
3
4
|
import * as path from 'node:path';
|
|
@@ -7,6 +8,13 @@ function normalizePathSeparators(value) {
|
|
|
7
8
|
return value.split(WINDOWS_PATH_SEPARATOR).join("/");
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
function babelFallbackReason(error) {
|
|
12
|
+
if (error instanceof OxcNotImplementedError) {
|
|
13
|
+
return error.detail;
|
|
14
|
+
}
|
|
15
|
+
return error instanceof Error ? error.message : String(error);
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
const CACHE_SCHEMA_VERSION = 10;
|
|
11
19
|
function resolveTransformCacheDir(rootDir, cacheDir) {
|
|
12
20
|
return path.resolve(rootDir, cacheDir ?? ".csszyx/cache", "transform");
|
|
@@ -206,4 +214,4 @@ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChar
|
|
|
206
214
|
return total;
|
|
207
215
|
}
|
|
208
216
|
|
|
209
|
-
export { readTransformCache as a,
|
|
217
|
+
export { readTransformCache as a, babelFallbackReason as b, createTransformCacheKey as c, evictMemoryCacheToBudget as d, evictOldTransformCacheEntries as e, normalizePathSeparators as n, resolveTransformCacheDir as r, writeTransformCache as w };
|
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.CJcFsJcf.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
require('node:fs');
|
|
8
8
|
require('node:module');
|
|
@@ -16,11 +16,11 @@ require('@csszyx/svelte-adapter');
|
|
|
16
16
|
require('@csszyx/types');
|
|
17
17
|
require('@csszyx/vue-adapter');
|
|
18
18
|
require('unplugin');
|
|
19
|
+
require('./shared/unplugin.CKIOVNOg.cjs');
|
|
19
20
|
require('./css-mangler.cjs');
|
|
20
21
|
require('postcss');
|
|
21
22
|
require('postcss-selector-parser');
|
|
22
|
-
require('./shared/unplugin.
|
|
23
|
-
require('./shared/unplugin.DVCQC5wq.cjs');
|
|
23
|
+
require('./shared/unplugin.Cnxm1DcC.cjs');
|
|
24
24
|
require('./shared/unplugin.BkRah5Ot.cjs');
|
|
25
25
|
require('postcss-value-parser');
|
|
26
26
|
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a0 as default } from './shared/unplugin.B2RUVK6Z.mjs';
|
|
2
2
|
import 'node:crypto';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:module';
|
|
@@ -12,10 +12,10 @@ import '@csszyx/svelte-adapter';
|
|
|
12
12
|
import '@csszyx/types';
|
|
13
13
|
import '@csszyx/vue-adapter';
|
|
14
14
|
import 'unplugin';
|
|
15
|
+
import './shared/unplugin.fOnGXWgS.mjs';
|
|
15
16
|
import './css-mangler.mjs';
|
|
16
17
|
import 'postcss';
|
|
17
18
|
import 'postcss-selector-parser';
|
|
18
|
-
import './shared/unplugin.
|
|
19
|
-
import './shared/unplugin.D-K57LNR.mjs';
|
|
19
|
+
import './shared/unplugin.Lhzkcj-A.mjs';
|
|
20
20
|
import './shared/unplugin.B3XoSRB8.mjs';
|
|
21
21
|
import 'postcss-value-parser';
|
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.CJcFsJcf.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
require('node:fs');
|
|
8
8
|
require('node:module');
|
|
@@ -16,11 +16,11 @@ require('@csszyx/svelte-adapter');
|
|
|
16
16
|
require('@csszyx/types');
|
|
17
17
|
require('@csszyx/vue-adapter');
|
|
18
18
|
require('unplugin');
|
|
19
|
+
require('./shared/unplugin.CKIOVNOg.cjs');
|
|
19
20
|
require('./css-mangler.cjs');
|
|
20
21
|
require('postcss');
|
|
21
22
|
require('postcss-selector-parser');
|
|
22
|
-
require('./shared/unplugin.
|
|
23
|
-
require('./shared/unplugin.DVCQC5wq.cjs');
|
|
23
|
+
require('./shared/unplugin.Cnxm1DcC.cjs');
|
|
24
24
|
require('./shared/unplugin.BkRah5Ot.cjs');
|
|
25
25
|
require('postcss-value-parser');
|
|
26
26
|
|
package/dist/webpack.d.cts
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a1 as default } from './shared/unplugin.B2RUVK6Z.mjs';
|
|
2
2
|
import 'node:crypto';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:module';
|
|
@@ -12,10 +12,10 @@ import '@csszyx/svelte-adapter';
|
|
|
12
12
|
import '@csszyx/types';
|
|
13
13
|
import '@csszyx/vue-adapter';
|
|
14
14
|
import 'unplugin';
|
|
15
|
+
import './shared/unplugin.fOnGXWgS.mjs';
|
|
15
16
|
import './css-mangler.mjs';
|
|
16
17
|
import 'postcss';
|
|
17
18
|
import 'postcss-selector-parser';
|
|
18
|
-
import './shared/unplugin.
|
|
19
|
-
import './shared/unplugin.D-K57LNR.mjs';
|
|
19
|
+
import './shared/unplugin.Lhzkcj-A.mjs';
|
|
20
20
|
import './shared/unplugin.B3XoSRB8.mjs';
|
|
21
21
|
import 'postcss-value-parser';
|