@csszyx/unplugin 0.14.5 → 0.15.0
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/README.md +4 -3
- package/dist/index.cjs +8 -7
- package/dist/index.d.cts +70 -3
- package/dist/index.d.mts +70 -3
- package/dist/index.mjs +4 -4
- package/dist/next-config.d.cts +1 -2
- package/dist/next-config.d.mts +1 -2
- package/dist/next-prebuild.cjs +9 -5
- package/dist/next-prebuild.d.cts +4 -2
- package/dist/next-prebuild.d.mts +4 -2
- package/dist/next-prebuild.mjs +8 -4
- package/dist/next-turbo-loader.cjs +20 -14
- package/dist/next-turbo-loader.d.cts +1 -1
- package/dist/next-turbo-loader.d.mts +1 -1
- package/dist/next-turbo-loader.mjs +19 -13
- package/dist/next-watcher.cjs +2 -2
- package/dist/next-watcher.d.cts +2 -2
- package/dist/next-watcher.d.mts +2 -2
- package/dist/next-watcher.mjs +2 -2
- package/dist/postcss.cjs +124 -0
- package/dist/postcss.d.cts +42 -0
- package/dist/postcss.d.mts +42 -0
- package/dist/postcss.mjs +107 -0
- package/dist/shared/{unplugin.NlPvn5P4.mjs → unplugin.AGR7mihU.mjs} +2 -6
- package/dist/shared/{unplugin.BnRf0Tvd.mjs → unplugin.BGufkSFT.mjs} +297 -173
- package/dist/shared/{unplugin.BXYakiXt.d.cts → unplugin.BHfqCocB.d.cts} +53 -55
- package/dist/shared/{unplugin.BXYakiXt.d.mts → unplugin.BHfqCocB.d.mts} +53 -55
- package/dist/shared/{unplugin.RGzhYt-D.cjs → unplugin.BLbrShMZ.cjs} +344 -221
- package/dist/shared/{unplugin.DVbPNK3W.cjs → unplugin.BbBYWFGT.cjs} +6 -6
- package/dist/shared/{unplugin.BZPdvVcj.mjs → unplugin.BourSpnZ.mjs} +105 -127
- package/dist/shared/{unplugin.CPEWNSA0.d.cts → unplugin.C2ilavL1.d.cts} +2 -0
- package/dist/shared/{unplugin.CPEWNSA0.d.mts → unplugin.C2ilavL1.d.mts} +2 -0
- package/dist/shared/{unplugin.D8BxOOkA.cjs → unplugin.C7i0agiO.cjs} +121 -142
- package/dist/shared/{unplugin.CdZxp0x-.d.mts → unplugin.CXCaQ3-s.d.cts} +1 -1
- package/dist/shared/{unplugin.xeED_qwh.d.cts → unplugin.CbNydVwv.d.mts} +1 -1
- package/dist/shared/unplugin.CqJS0BbD.mjs +211 -0
- package/dist/shared/{unplugin.VtXstzEh.cjs → unplugin.DX3rYT4P.cjs} +6 -11
- package/dist/shared/{unplugin.Cji6O5jv.cjs → unplugin.Dai5wlZ3.cjs} +27 -19
- package/dist/shared/{unplugin.DN95k991.mjs → unplugin.Dbc26ty6.mjs} +2 -2
- package/dist/shared/{unplugin.BU0O4IkX.mjs → unplugin.DmCOQc-b.mjs} +22 -16
- package/dist/shared/unplugin.KnDCM-sr.cjs +241 -0
- package/dist/vite.cjs +4 -4
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +4 -4
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.d.cts +2 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +4 -4
- package/package.json +19 -9
- package/dist/shared/unplugin.B3XoSRB8.mjs +0 -40
- package/dist/shared/unplugin.BkRah5Ot.cjs +0 -48
|
@@ -4,9 +4,9 @@ const fs = require('node:fs');
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const compiler = require('@csszyx/compiler');
|
|
6
6
|
const types = require('@csszyx/types');
|
|
7
|
-
const transformCache = require('./unplugin.
|
|
7
|
+
const transformCache = require('./unplugin.DX3rYT4P.cjs');
|
|
8
|
+
const safelistSource = require('./unplugin.KnDCM-sr.cjs');
|
|
8
9
|
const node_crypto = require('node:crypto');
|
|
9
|
-
const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
|
|
10
10
|
|
|
11
11
|
function _interopNamespaceCompat(e) {
|
|
12
12
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -124,7 +124,7 @@ function configWithImportedStaticSz(config, importedStaticSz) {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
function normalizeProviderPaths(providers) {
|
|
127
|
-
return [...new Set(providers.map(
|
|
127
|
+
return [...new Set(providers.map(safelistSource.normalizePathSeparators))];
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
function readPackageVersion(relativePackageJson, fromUrl) {
|
|
@@ -283,7 +283,7 @@ function createNextSourceTransformCacheInput(input, filename, producer) {
|
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
285
|
function normalizeSourceFilename(filename) {
|
|
286
|
-
return
|
|
286
|
+
return safelistSource.normalizePathSeparators(filename);
|
|
287
287
|
}
|
|
288
288
|
function normalizeGlobalVarAliasesForCache(aliases) {
|
|
289
289
|
if (!aliases) {
|
|
@@ -308,8 +308,8 @@ function collectNextTransformMetadata(result, source, sourcePath) {
|
|
|
308
308
|
return {
|
|
309
309
|
sourcePath,
|
|
310
310
|
sourceHash: node_crypto.createHash("sha256").update(source).digest("hex"),
|
|
311
|
-
classes:
|
|
312
|
-
rawClassNames:
|
|
311
|
+
classes: safelistSource.sortStrings(classes),
|
|
312
|
+
rawClassNames: safelistSource.sortStrings(result.rawClassNames),
|
|
313
313
|
recoveryTokenCount: result.recoveryTokens.size,
|
|
314
314
|
cssVariableCount: result.cssVariableMap.size
|
|
315
315
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
2
|
import path__default from 'node:path';
|
|
3
|
-
import { s as sortStrings } from './unplugin.
|
|
3
|
+
import { s as sortStrings } from './unplugin.CqJS0BbD.mjs';
|
|
4
4
|
|
|
5
5
|
const EMPTY_THEME = {
|
|
6
6
|
colors: [],
|
|
@@ -286,6 +286,109 @@ function leadingTriviaLength(source) {
|
|
|
286
286
|
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
290
|
+
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
291
|
+
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
292
|
+
const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
|
|
293
|
+
const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
|
|
294
|
+
const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
|
|
295
|
+
function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
|
|
296
|
+
return `/**
|
|
297
|
+
* Auto-generated mangle map for csszyx.
|
|
298
|
+
* This module is generated at build time and contains the mapping
|
|
299
|
+
* from original class names and CSS variable names to mangled names.
|
|
300
|
+
*
|
|
301
|
+
* @generated
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
export const mangleMap = ${JSON.stringify(mangleMap, null, 2)};
|
|
305
|
+
|
|
306
|
+
export const varMangleMap = ${JSON.stringify(varMangleMap, null, 2)};
|
|
307
|
+
|
|
308
|
+
export const cssVarMetrics = ${JSON.stringify(cssVarMetrics, null, 2)};
|
|
309
|
+
|
|
310
|
+
export const checksum = ${JSON.stringify(checksum)};
|
|
311
|
+
|
|
312
|
+
export default {
|
|
313
|
+
mangleMap,
|
|
314
|
+
varMangleMap,
|
|
315
|
+
cssVarMetrics,
|
|
316
|
+
checksum,
|
|
317
|
+
};
|
|
318
|
+
`;
|
|
319
|
+
}
|
|
320
|
+
function createChecksumModule(checksum) {
|
|
321
|
+
return `/**
|
|
322
|
+
* Auto-generated checksum for csszyx mangle map.
|
|
323
|
+
*
|
|
324
|
+
* @generated
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
export const checksum = ${JSON.stringify(checksum)};
|
|
328
|
+
|
|
329
|
+
export default checksum;
|
|
330
|
+
`;
|
|
331
|
+
}
|
|
332
|
+
function isVirtualModule(id) {
|
|
333
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
334
|
+
}
|
|
335
|
+
function resolveVirtualModule(id) {
|
|
336
|
+
if (id === VIRTUAL_MODULE_ID) {
|
|
337
|
+
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
338
|
+
}
|
|
339
|
+
if (id === VIRTUAL_CHECKSUM_ID) {
|
|
340
|
+
return RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
341
|
+
}
|
|
342
|
+
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
343
|
+
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
344
|
+
}
|
|
345
|
+
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
346
|
+
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
347
|
+
}
|
|
348
|
+
return void 0;
|
|
349
|
+
}
|
|
350
|
+
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
351
|
+
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
352
|
+
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
353
|
+
const CENSUS_PLACEHOLDER = "___CSSZYX_CENSUS___";
|
|
354
|
+
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
355
|
+
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
356
|
+
function createMangleRuntimeModule(globalVarAliasPrefix, exposeDebugGlobal = false) {
|
|
357
|
+
return `/**
|
|
358
|
+
* Auto-generated by csszyx: registers the runtime mangle map from the bundle.
|
|
359
|
+
*
|
|
360
|
+
* @generated
|
|
361
|
+
*/
|
|
362
|
+
import { installMangleRuntime } from '@csszyx/runtime/core';
|
|
363
|
+
|
|
364
|
+
installMangleRuntime({
|
|
365
|
+
mangleMap: ${MANGLE_MAP_PLACEHOLDER},
|
|
366
|
+
varMangleMap: ${VAR_MANGLE_MAP_PLACEHOLDER},
|
|
367
|
+
checksum: "${CHECKSUM_PLACEHOLDER}",
|
|
368
|
+
globalVarAliasPrefix: ${JSON.stringify(globalVarAliasPrefix)},
|
|
369
|
+
exposeDebugGlobal: ${exposeDebugGlobal},
|
|
370
|
+
});
|
|
371
|
+
`;
|
|
372
|
+
}
|
|
373
|
+
function createThemeGroupsModule(tokens) {
|
|
374
|
+
const payload = JSON.stringify({
|
|
375
|
+
colors: tokens.colors,
|
|
376
|
+
textSizes: tokens.textSizes,
|
|
377
|
+
fontFamilies: tokens.fontFamilies,
|
|
378
|
+
fontWeights: tokens.fontWeights
|
|
379
|
+
});
|
|
380
|
+
return [
|
|
381
|
+
"// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
|
|
382
|
+
"import { setSzcnGroups } from '@csszyx/runtime';",
|
|
383
|
+
// `set`, not `register`: this payload is the COMPLETE scanned set, so
|
|
384
|
+
// re-running it after a `@theme` edit has to drop the tokens the
|
|
385
|
+
// stylesheet lost. The source name scopes the replace, leaving an app's
|
|
386
|
+
// own hand-written registration untouched.
|
|
387
|
+
`setSzcnGroups(${payload}, 'build');`,
|
|
388
|
+
"export {};"
|
|
389
|
+
].join("\n");
|
|
390
|
+
}
|
|
391
|
+
|
|
289
392
|
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
290
393
|
function clauseNames(clauseBody) {
|
|
291
394
|
const names = [];
|
|
@@ -434,131 +537,6 @@ function discoverProjectTheme(rootDir, extraDirs = []) {
|
|
|
434
537
|
};
|
|
435
538
|
}
|
|
436
539
|
|
|
437
|
-
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
438
|
-
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
439
|
-
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
440
|
-
const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
|
|
441
|
-
const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
|
|
442
|
-
const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
|
|
443
|
-
function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
|
|
444
|
-
return `/**
|
|
445
|
-
* Auto-generated mangle map for csszyx.
|
|
446
|
-
* This module is generated at build time and contains the mapping
|
|
447
|
-
* from original class names and CSS variable names to mangled names.
|
|
448
|
-
*
|
|
449
|
-
* @generated
|
|
450
|
-
*/
|
|
451
|
-
|
|
452
|
-
export const mangleMap = ${JSON.stringify(mangleMap, null, 2)};
|
|
453
|
-
|
|
454
|
-
export const varMangleMap = ${JSON.stringify(varMangleMap, null, 2)};
|
|
455
|
-
|
|
456
|
-
export const cssVarMetrics = ${JSON.stringify(cssVarMetrics, null, 2)};
|
|
457
|
-
|
|
458
|
-
export const checksum = ${JSON.stringify(checksum)};
|
|
459
|
-
|
|
460
|
-
export default {
|
|
461
|
-
mangleMap,
|
|
462
|
-
varMangleMap,
|
|
463
|
-
cssVarMetrics,
|
|
464
|
-
checksum,
|
|
465
|
-
};
|
|
466
|
-
`;
|
|
467
|
-
}
|
|
468
|
-
function createChecksumModule(checksum) {
|
|
469
|
-
return `/**
|
|
470
|
-
* Auto-generated checksum for csszyx mangle map.
|
|
471
|
-
*
|
|
472
|
-
* @generated
|
|
473
|
-
*/
|
|
474
|
-
|
|
475
|
-
export const checksum = ${JSON.stringify(checksum)};
|
|
476
|
-
|
|
477
|
-
export default checksum;
|
|
478
|
-
`;
|
|
479
|
-
}
|
|
480
|
-
function isVirtualModule(id) {
|
|
481
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
482
|
-
}
|
|
483
|
-
function resolveVirtualModule(id) {
|
|
484
|
-
if (id === VIRTUAL_MODULE_ID) {
|
|
485
|
-
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
486
|
-
}
|
|
487
|
-
if (id === VIRTUAL_CHECKSUM_ID) {
|
|
488
|
-
return RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
489
|
-
}
|
|
490
|
-
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
491
|
-
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
492
|
-
}
|
|
493
|
-
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
494
|
-
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
495
|
-
}
|
|
496
|
-
return void 0;
|
|
497
|
-
}
|
|
498
|
-
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
499
|
-
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
500
|
-
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
501
|
-
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
502
|
-
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
503
|
-
function createMangleRuntimeModule(globalVarAliasPrefix) {
|
|
504
|
-
return `/**
|
|
505
|
-
* Auto-generated by csszyx: installs the runtime mangle map from the bundle.
|
|
506
|
-
*
|
|
507
|
-
* @generated
|
|
508
|
-
*/
|
|
509
|
-
|
|
510
|
-
const m = ${MANGLE_MAP_PLACEHOLDER};
|
|
511
|
-
const vm = ${VAR_MANGLE_MAP_PLACEHOLDER};
|
|
512
|
-
const gp = ${JSON.stringify(globalVarAliasPrefix)};
|
|
513
|
-
const checksum = "${CHECKSUM_PLACEHOLDER}";
|
|
514
|
-
|
|
515
|
-
if (typeof window !== 'undefined' && !window.__csszyx) {
|
|
516
|
-
const r = {};
|
|
517
|
-
const vr = {};
|
|
518
|
-
for (const k in m) r[m[k]] = k;
|
|
519
|
-
for (const vk in vm) {
|
|
520
|
-
const vv = vm[vk];
|
|
521
|
-
const vs = Array.isArray(vv) ? vv : [vv];
|
|
522
|
-
for (const v of vs) (vr[v] || (vr[v] = [])).push(vk);
|
|
523
|
-
}
|
|
524
|
-
window.__csszyx = {
|
|
525
|
-
mangleMap: m,
|
|
526
|
-
varMangleMap: vm,
|
|
527
|
-
checksum,
|
|
528
|
-
decode: (c) => r[c],
|
|
529
|
-
encode: (c) => m[c],
|
|
530
|
-
decodeVar: (v) => vr[v] || [],
|
|
531
|
-
encodeVar: (v) => vm[v],
|
|
532
|
-
decodeGlobalVar: (v) => {
|
|
533
|
-
const a = vr[v] || [];
|
|
534
|
-
return v.indexOf(gp) === 0 ? a[0] : undefined;
|
|
535
|
-
},
|
|
536
|
-
decodeAll: (el) => (el.className || '').split(' ').map((c) => r[c] || c),
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
export {};
|
|
541
|
-
`;
|
|
542
|
-
}
|
|
543
|
-
function createThemeGroupsModule(tokens) {
|
|
544
|
-
const payload = JSON.stringify({
|
|
545
|
-
colors: tokens.colors,
|
|
546
|
-
textSizes: tokens.textSizes,
|
|
547
|
-
fontFamilies: tokens.fontFamilies,
|
|
548
|
-
fontWeights: tokens.fontWeights
|
|
549
|
-
});
|
|
550
|
-
return [
|
|
551
|
-
"// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
|
|
552
|
-
"import { setSzcnGroups } from '@csszyx/runtime';",
|
|
553
|
-
// `set`, not `register`: this payload is the COMPLETE scanned set, so
|
|
554
|
-
// re-running it after a `@theme` edit has to drop the tokens the
|
|
555
|
-
// stylesheet lost. The source name scopes the replace, leaving an app's
|
|
556
|
-
// own hand-written registration untouched.
|
|
557
|
-
`setSzcnGroups(${payload}, 'build');`,
|
|
558
|
-
"export {};"
|
|
559
|
-
].join("\n");
|
|
560
|
-
}
|
|
561
|
-
|
|
562
540
|
const THEME_GROUPS_FILE = "theme-groups.mjs";
|
|
563
541
|
const THEME_GROUPS_FILE_MARKER = `.csszyx/${THEME_GROUPS_FILE}`;
|
|
564
542
|
const cacheByRoot = /* @__PURE__ */ new Map();
|
|
@@ -609,4 +587,4 @@ function themeGroupsSpecifier(fromFile, themeGroupsFile) {
|
|
|
609
587
|
return relative.startsWith("./") || relative.startsWith("../") ? relative : `./${relative}`;
|
|
610
588
|
}
|
|
611
589
|
|
|
612
|
-
export { CHECKSUM_PLACEHOLDER as C,
|
|
590
|
+
export { CHECKSUM_PLACEHOLDER as C, MANGLE_RUNTIME_VIRTUAL_ID as M, RESOLVED_VIRTUAL_MODULE_ID as R, THEME_GROUPS_VIRTUAL_ID as T, VAR_MANGLE_MAP_PLACEHOLDER as V, parseUtilityBlocks as a, insertAfterUseDirective as b, createMangleRuntimeModule as c, createThemeGroupsModule as d, ensureThemeGroupsFile as e, createMangleMapModule as f, RESOLVED_VIRTUAL_CHECKSUM_ID as g, hasTokens as h, injectNextRuntimeImports as i, createChecksumModule as j, RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID as k, RESOLVED_THEME_GROUPS_VIRTUAL_ID as l, mergeThemes as m, isVirtualModule as n, discoverProjectTheme as o, parseThemeBlocks as p, CENSUS_PLACEHOLDER as q, resolveVirtualModule as r, scanCustomPropertyNames as s, themeGroupsSpecifier as t, importsRuntimeHelper as u, findRuntimeImportClause as v, THEME_GROUPS_FILE_MARKER as w, runtimeHelperGroupsFromUsage as x, MANGLE_MAP_PLACEHOLDER as y };
|
|
@@ -11,6 +11,8 @@ interface NextCacheIdentity {
|
|
|
11
11
|
|
|
12
12
|
/** Files used by the Next Turbopack safelist state machine. */
|
|
13
13
|
interface NextSafelistStatePaths {
|
|
14
|
+
/** Project root the safelist and cache live under. */
|
|
15
|
+
rootDir: string;
|
|
14
16
|
cacheDir: string;
|
|
15
17
|
shardsDir: string;
|
|
16
18
|
snapshotPath: string;
|
|
@@ -11,6 +11,8 @@ interface NextCacheIdentity {
|
|
|
11
11
|
|
|
12
12
|
/** Files used by the Next Turbopack safelist state machine. */
|
|
13
13
|
interface NextSafelistStatePaths {
|
|
14
|
+
/** Project root the safelist and cache live under. */
|
|
15
|
+
rootDir: string;
|
|
14
16
|
cacheDir: string;
|
|
15
17
|
shardsDir: string;
|
|
16
18
|
snapshotPath: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const path = require('node:path');
|
|
5
|
-
const
|
|
5
|
+
const safelistSource = require('./unplugin.KnDCM-sr.cjs');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
8
|
|
|
@@ -181,14 +181,14 @@ function parseThemeBlocks(cssContent) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
return {
|
|
184
|
-
colors:
|
|
185
|
-
spacings:
|
|
186
|
-
fonts:
|
|
187
|
-
textSizes:
|
|
188
|
-
fontWeights:
|
|
189
|
-
radii:
|
|
190
|
-
shadows:
|
|
191
|
-
breakpoints:
|
|
184
|
+
colors: safelistSource.sortStrings(result.colors),
|
|
185
|
+
spacings: safelistSource.sortStrings(result.spacings),
|
|
186
|
+
fonts: safelistSource.sortStrings(result.fonts),
|
|
187
|
+
textSizes: safelistSource.sortStrings(result.textSizes),
|
|
188
|
+
fontWeights: safelistSource.sortStrings(result.fontWeights),
|
|
189
|
+
radii: safelistSource.sortStrings(result.radii),
|
|
190
|
+
shadows: safelistSource.sortStrings(result.shadows),
|
|
191
|
+
breakpoints: safelistSource.sortStrings(result.breakpoints)
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
194
|
function mergeThemes(themes) {
|
|
@@ -213,14 +213,14 @@ function mergeThemes(themes) {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
return {
|
|
216
|
-
colors:
|
|
217
|
-
spacings:
|
|
218
|
-
fonts:
|
|
219
|
-
textSizes:
|
|
220
|
-
fontWeights:
|
|
221
|
-
radii:
|
|
222
|
-
shadows:
|
|
223
|
-
breakpoints:
|
|
216
|
+
colors: safelistSource.sortStrings(merged.colors),
|
|
217
|
+
spacings: safelistSource.sortStrings(merged.spacings),
|
|
218
|
+
fonts: safelistSource.sortStrings(merged.fonts),
|
|
219
|
+
textSizes: safelistSource.sortStrings(merged.textSizes),
|
|
220
|
+
fontWeights: safelistSource.sortStrings(merged.fontWeights),
|
|
221
|
+
radii: safelistSource.sortStrings(merged.radii),
|
|
222
|
+
shadows: safelistSource.sortStrings(merged.shadows),
|
|
223
|
+
breakpoints: safelistSource.sortStrings(merged.breakpoints)
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
function hasTokens(theme) {
|
|
@@ -293,6 +293,109 @@ function leadingTriviaLength(source) {
|
|
|
293
293
|
return LEADING_WHITESPACE_RE.exec(source)?.[0].length ?? LINE_COMMENT_RE.exec(source)?.[0].length ?? BLOCK_COMMENT_RE.exec(source)?.[0].length ?? 0;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
297
|
+
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
298
|
+
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
299
|
+
const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
|
|
300
|
+
const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
|
|
301
|
+
const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
|
|
302
|
+
function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
|
|
303
|
+
return `/**
|
|
304
|
+
* Auto-generated mangle map for csszyx.
|
|
305
|
+
* This module is generated at build time and contains the mapping
|
|
306
|
+
* from original class names and CSS variable names to mangled names.
|
|
307
|
+
*
|
|
308
|
+
* @generated
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
export const mangleMap = ${JSON.stringify(mangleMap, null, 2)};
|
|
312
|
+
|
|
313
|
+
export const varMangleMap = ${JSON.stringify(varMangleMap, null, 2)};
|
|
314
|
+
|
|
315
|
+
export const cssVarMetrics = ${JSON.stringify(cssVarMetrics, null, 2)};
|
|
316
|
+
|
|
317
|
+
export const checksum = ${JSON.stringify(checksum)};
|
|
318
|
+
|
|
319
|
+
export default {
|
|
320
|
+
mangleMap,
|
|
321
|
+
varMangleMap,
|
|
322
|
+
cssVarMetrics,
|
|
323
|
+
checksum,
|
|
324
|
+
};
|
|
325
|
+
`;
|
|
326
|
+
}
|
|
327
|
+
function createChecksumModule(checksum) {
|
|
328
|
+
return `/**
|
|
329
|
+
* Auto-generated checksum for csszyx mangle map.
|
|
330
|
+
*
|
|
331
|
+
* @generated
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
export const checksum = ${JSON.stringify(checksum)};
|
|
335
|
+
|
|
336
|
+
export default checksum;
|
|
337
|
+
`;
|
|
338
|
+
}
|
|
339
|
+
function isVirtualModule(id) {
|
|
340
|
+
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
341
|
+
}
|
|
342
|
+
function resolveVirtualModule(id) {
|
|
343
|
+
if (id === VIRTUAL_MODULE_ID) {
|
|
344
|
+
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
345
|
+
}
|
|
346
|
+
if (id === VIRTUAL_CHECKSUM_ID) {
|
|
347
|
+
return RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
348
|
+
}
|
|
349
|
+
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
350
|
+
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
351
|
+
}
|
|
352
|
+
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
353
|
+
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
354
|
+
}
|
|
355
|
+
return void 0;
|
|
356
|
+
}
|
|
357
|
+
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
358
|
+
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
359
|
+
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
360
|
+
const CENSUS_PLACEHOLDER = "___CSSZYX_CENSUS___";
|
|
361
|
+
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
362
|
+
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
363
|
+
function createMangleRuntimeModule(globalVarAliasPrefix, exposeDebugGlobal = false) {
|
|
364
|
+
return `/**
|
|
365
|
+
* Auto-generated by csszyx: registers the runtime mangle map from the bundle.
|
|
366
|
+
*
|
|
367
|
+
* @generated
|
|
368
|
+
*/
|
|
369
|
+
import { installMangleRuntime } from '@csszyx/runtime/core';
|
|
370
|
+
|
|
371
|
+
installMangleRuntime({
|
|
372
|
+
mangleMap: ${MANGLE_MAP_PLACEHOLDER},
|
|
373
|
+
varMangleMap: ${VAR_MANGLE_MAP_PLACEHOLDER},
|
|
374
|
+
checksum: "${CHECKSUM_PLACEHOLDER}",
|
|
375
|
+
globalVarAliasPrefix: ${JSON.stringify(globalVarAliasPrefix)},
|
|
376
|
+
exposeDebugGlobal: ${exposeDebugGlobal},
|
|
377
|
+
});
|
|
378
|
+
`;
|
|
379
|
+
}
|
|
380
|
+
function createThemeGroupsModule(tokens) {
|
|
381
|
+
const payload = JSON.stringify({
|
|
382
|
+
colors: tokens.colors,
|
|
383
|
+
textSizes: tokens.textSizes,
|
|
384
|
+
fontFamilies: tokens.fontFamilies,
|
|
385
|
+
fontWeights: tokens.fontWeights
|
|
386
|
+
});
|
|
387
|
+
return [
|
|
388
|
+
"// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
|
|
389
|
+
"import { setSzcnGroups } from '@csszyx/runtime';",
|
|
390
|
+
// `set`, not `register`: this payload is the COMPLETE scanned set, so
|
|
391
|
+
// re-running it after a `@theme` edit has to drop the tokens the
|
|
392
|
+
// stylesheet lost. The source name scopes the replace, leaving an app's
|
|
393
|
+
// own hand-written registration untouched.
|
|
394
|
+
`setSzcnGroups(${payload}, 'build');`,
|
|
395
|
+
"export {};"
|
|
396
|
+
].join("\n");
|
|
397
|
+
}
|
|
398
|
+
|
|
296
399
|
const RUNTIME_IMPORT_CLAUSE_RE = /(?:import|export)\s+\{([^{}]*)\}\s*from\s*['"]@csszyx\/runtime['"]/g;
|
|
297
400
|
function clauseNames(clauseBody) {
|
|
298
401
|
const names = [];
|
|
@@ -441,131 +544,6 @@ function discoverProjectTheme(rootDir, extraDirs = []) {
|
|
|
441
544
|
};
|
|
442
545
|
}
|
|
443
546
|
|
|
444
|
-
const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
|
|
445
|
-
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
446
|
-
const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
|
|
447
|
-
const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
|
|
448
|
-
const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
|
|
449
|
-
const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
|
|
450
|
-
function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
|
|
451
|
-
return `/**
|
|
452
|
-
* Auto-generated mangle map for csszyx.
|
|
453
|
-
* This module is generated at build time and contains the mapping
|
|
454
|
-
* from original class names and CSS variable names to mangled names.
|
|
455
|
-
*
|
|
456
|
-
* @generated
|
|
457
|
-
*/
|
|
458
|
-
|
|
459
|
-
export const mangleMap = ${JSON.stringify(mangleMap, null, 2)};
|
|
460
|
-
|
|
461
|
-
export const varMangleMap = ${JSON.stringify(varMangleMap, null, 2)};
|
|
462
|
-
|
|
463
|
-
export const cssVarMetrics = ${JSON.stringify(cssVarMetrics, null, 2)};
|
|
464
|
-
|
|
465
|
-
export const checksum = ${JSON.stringify(checksum)};
|
|
466
|
-
|
|
467
|
-
export default {
|
|
468
|
-
mangleMap,
|
|
469
|
-
varMangleMap,
|
|
470
|
-
cssVarMetrics,
|
|
471
|
-
checksum,
|
|
472
|
-
};
|
|
473
|
-
`;
|
|
474
|
-
}
|
|
475
|
-
function createChecksumModule(checksum) {
|
|
476
|
-
return `/**
|
|
477
|
-
* Auto-generated checksum for csszyx mangle map.
|
|
478
|
-
*
|
|
479
|
-
* @generated
|
|
480
|
-
*/
|
|
481
|
-
|
|
482
|
-
export const checksum = ${JSON.stringify(checksum)};
|
|
483
|
-
|
|
484
|
-
export default checksum;
|
|
485
|
-
`;
|
|
486
|
-
}
|
|
487
|
-
function isVirtualModule(id) {
|
|
488
|
-
return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
|
|
489
|
-
}
|
|
490
|
-
function resolveVirtualModule(id) {
|
|
491
|
-
if (id === VIRTUAL_MODULE_ID) {
|
|
492
|
-
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
493
|
-
}
|
|
494
|
-
if (id === VIRTUAL_CHECKSUM_ID) {
|
|
495
|
-
return RESOLVED_VIRTUAL_CHECKSUM_ID;
|
|
496
|
-
}
|
|
497
|
-
if (id === THEME_GROUPS_VIRTUAL_ID) {
|
|
498
|
-
return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
|
|
499
|
-
}
|
|
500
|
-
if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
|
|
501
|
-
return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
|
|
502
|
-
}
|
|
503
|
-
return void 0;
|
|
504
|
-
}
|
|
505
|
-
const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
|
|
506
|
-
const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
|
|
507
|
-
const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
|
|
508
|
-
const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
|
|
509
|
-
const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
|
|
510
|
-
function createMangleRuntimeModule(globalVarAliasPrefix) {
|
|
511
|
-
return `/**
|
|
512
|
-
* Auto-generated by csszyx: installs the runtime mangle map from the bundle.
|
|
513
|
-
*
|
|
514
|
-
* @generated
|
|
515
|
-
*/
|
|
516
|
-
|
|
517
|
-
const m = ${MANGLE_MAP_PLACEHOLDER};
|
|
518
|
-
const vm = ${VAR_MANGLE_MAP_PLACEHOLDER};
|
|
519
|
-
const gp = ${JSON.stringify(globalVarAliasPrefix)};
|
|
520
|
-
const checksum = "${CHECKSUM_PLACEHOLDER}";
|
|
521
|
-
|
|
522
|
-
if (typeof window !== 'undefined' && !window.__csszyx) {
|
|
523
|
-
const r = {};
|
|
524
|
-
const vr = {};
|
|
525
|
-
for (const k in m) r[m[k]] = k;
|
|
526
|
-
for (const vk in vm) {
|
|
527
|
-
const vv = vm[vk];
|
|
528
|
-
const vs = Array.isArray(vv) ? vv : [vv];
|
|
529
|
-
for (const v of vs) (vr[v] || (vr[v] = [])).push(vk);
|
|
530
|
-
}
|
|
531
|
-
window.__csszyx = {
|
|
532
|
-
mangleMap: m,
|
|
533
|
-
varMangleMap: vm,
|
|
534
|
-
checksum,
|
|
535
|
-
decode: (c) => r[c],
|
|
536
|
-
encode: (c) => m[c],
|
|
537
|
-
decodeVar: (v) => vr[v] || [],
|
|
538
|
-
encodeVar: (v) => vm[v],
|
|
539
|
-
decodeGlobalVar: (v) => {
|
|
540
|
-
const a = vr[v] || [];
|
|
541
|
-
return v.indexOf(gp) === 0 ? a[0] : undefined;
|
|
542
|
-
},
|
|
543
|
-
decodeAll: (el) => (el.className || '').split(' ').map((c) => r[c] || c),
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
export {};
|
|
548
|
-
`;
|
|
549
|
-
}
|
|
550
|
-
function createThemeGroupsModule(tokens) {
|
|
551
|
-
const payload = JSON.stringify({
|
|
552
|
-
colors: tokens.colors,
|
|
553
|
-
textSizes: tokens.textSizes,
|
|
554
|
-
fontFamilies: tokens.fontFamilies,
|
|
555
|
-
fontWeights: tokens.fontWeights
|
|
556
|
-
});
|
|
557
|
-
return [
|
|
558
|
-
"// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
|
|
559
|
-
"import { setSzcnGroups } from '@csszyx/runtime';",
|
|
560
|
-
// `set`, not `register`: this payload is the COMPLETE scanned set, so
|
|
561
|
-
// re-running it after a `@theme` edit has to drop the tokens the
|
|
562
|
-
// stylesheet lost. The source name scopes the replace, leaving an app's
|
|
563
|
-
// own hand-written registration untouched.
|
|
564
|
-
`setSzcnGroups(${payload}, 'build');`,
|
|
565
|
-
"export {};"
|
|
566
|
-
].join("\n");
|
|
567
|
-
}
|
|
568
|
-
|
|
569
547
|
const THEME_GROUPS_FILE = "theme-groups.mjs";
|
|
570
548
|
const THEME_GROUPS_FILE_MARKER = `.csszyx/${THEME_GROUPS_FILE}`;
|
|
571
549
|
const cacheByRoot = /* @__PURE__ */ new Map();
|
|
@@ -616,6 +594,7 @@ function themeGroupsSpecifier(fromFile, themeGroupsFile) {
|
|
|
616
594
|
return relative.startsWith("./") || relative.startsWith("../") ? relative : `./${relative}`;
|
|
617
595
|
}
|
|
618
596
|
|
|
597
|
+
exports.CENSUS_PLACEHOLDER = CENSUS_PLACEHOLDER;
|
|
619
598
|
exports.CHECKSUM_PLACEHOLDER = CHECKSUM_PLACEHOLDER;
|
|
620
599
|
exports.MANGLE_MAP_PLACEHOLDER = MANGLE_MAP_PLACEHOLDER;
|
|
621
600
|
exports.MANGLE_RUNTIME_VIRTUAL_ID = MANGLE_RUNTIME_VIRTUAL_ID;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.
|
|
1
|
+
import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.C2ilavL1.cjs';
|
|
2
2
|
|
|
3
3
|
/** Options for one synchronous watcher materialization cycle. */
|
|
4
4
|
interface NextWatcherCycleOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.
|
|
1
|
+
import { a as NextSafelistMaterializeResult, b as NextSafelistStateLockOptions, A as AtomicWriteOptions } from './unplugin.C2ilavL1.mjs';
|
|
2
2
|
|
|
3
3
|
/** Options for one synchronous watcher materialization cycle. */
|
|
4
4
|
interface NextWatcherCycleOptions {
|