@yahoo/uds 3.113.0 → 3.114.0-beta.2
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/automated-config/dist/mapTextVariantFixtureToValue.cjs +12 -1
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.js +12 -1
- package/dist/automated-config/dist/properties.cjs +1 -1
- package/dist/automated-config/dist/properties.js +1 -1
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
- package/dist/cli/commands/sync.cjs +1 -3
- package/dist/cli/commands/sync.d.cts +1 -1
- package/dist/cli/commands/sync.d.ts +1 -1
- package/dist/cli/commands/sync.js +1 -3
- package/dist/cli/commands/version.cjs +0 -2
- package/dist/cli/commands/version.d.cts +1 -1
- package/dist/cli/commands/version.d.ts +1 -1
- package/dist/cli/commands/version.js +0 -2
- package/dist/cli/dist/cli.cjs +1 -1
- package/dist/cli/dist/cli.js +1 -1
- package/dist/cli/dist/commands/editor-rules.cjs +2 -2
- package/dist/cli/dist/commands/editor-rules.js +2 -2
- package/dist/cli/dist/lib/logger.cjs +66 -0
- package/dist/cli/dist/lib/logger.js +66 -0
- package/dist/cli/dist/utils/rules/config.cjs +1 -1
- package/dist/cli/dist/utils/rules/config.js +1 -1
- package/dist/cli/runner.cjs +11 -2
- package/dist/cli/runner.js +11 -2
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/styles/styler.d.cts +41 -41
- package/dist/styles/styler.d.ts +41 -41
- package/dist/styles/variants.cjs +278 -278
- package/dist/styles/variants.js +278 -278
- package/dist/tailwind/dist/commands/css.cjs +79 -0
- package/dist/tailwind/dist/commands/css.d.ts +3 -0
- package/dist/tailwind/dist/commands/css.helpers.cjs +32 -0
- package/dist/tailwind/dist/commands/css.helpers.js +28 -0
- package/dist/tailwind/dist/commands/css.js +79 -0
- package/dist/tailwind/dist/commands/generateComponentData.cjs +33 -31
- package/dist/tailwind/dist/commands/generateComponentData.d.ts +1 -1
- package/dist/tailwind/dist/commands/generateComponentData.js +33 -31
- package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.cjs +3 -4
- package/dist/tailwind/dist/commands/purge.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.js +3 -4
- package/dist/tailwind/dist/css/generate.cjs +120 -0
- package/dist/tailwind/dist/css/generate.d.cts +30 -0
- package/dist/tailwind/dist/css/generate.d.ts +31 -0
- package/dist/tailwind/dist/css/generate.helpers.cjs +112 -0
- package/dist/tailwind/dist/css/generate.helpers.js +100 -0
- package/dist/tailwind/dist/css/generate.js +115 -0
- package/dist/tailwind/dist/css/postcss.cjs +35 -0
- package/dist/tailwind/dist/css/postcss.helpers.cjs +27 -0
- package/dist/tailwind/dist/css/postcss.helpers.js +26 -0
- package/dist/tailwind/dist/css/postcss.js +35 -0
- package/dist/tailwind/dist/css/runner.cjs +278 -0
- package/dist/tailwind/dist/css/runner.helpers.cjs +26 -0
- package/dist/tailwind/dist/css/runner.helpers.js +23 -0
- package/dist/tailwind/dist/css/runner.js +275 -0
- package/dist/tailwind/dist/css/theme.cjs +12 -0
- package/dist/tailwind/dist/css/theme.d.cts +66 -0
- package/dist/tailwind/dist/css/theme.d.ts +66 -0
- package/dist/tailwind/dist/css/theme.js +11 -0
- package/dist/tailwind/dist/css/utils.cjs +234 -0
- package/dist/tailwind/dist/css/utils.js +223 -0
- package/dist/tailwind/dist/index.d.cts +1 -0
- package/dist/tailwind/dist/index.d.ts +5 -3
- package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +4 -3
- package/dist/tailwind/dist/purger/legacy/purgeCSS.js +4 -3
- package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +122 -125
- package/dist/tailwind/dist/purger/optimized/ast/expressions.js +122 -125
- package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +1 -8
- package/dist/tailwind/dist/purger/optimized/ast/jsx.js +1 -8
- package/dist/tailwind/dist/purger/optimized/purge.cjs +11 -10
- package/dist/tailwind/dist/purger/optimized/purge.js +10 -9
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +232 -127
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +232 -127
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +330 -262
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +329 -262
- package/dist/tailwind/dist/purger/optimized/utils/files.cjs +4 -3
- package/dist/tailwind/dist/purger/optimized/utils/files.js +4 -3
- package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +13 -21
- package/dist/tailwind/dist/purger/optimized/utils/safelist.js +13 -21
- package/dist/tailwind/dist/tailwind/plugins/typography.cjs +41 -13
- package/dist/tailwind/dist/tailwind/plugins/typography.js +41 -13
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.cjs +4 -2
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.cts +10 -1
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.ts +10 -1
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.js +4 -2
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.cts +1 -1
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.ts +1 -1
- package/dist/tailwind/dist/utils/optimizeCSS.cjs +405 -0
- package/dist/tailwind/dist/utils/optimizeCSS.js +403 -0
- package/dist/tailwind/dist/utils/postcssPreserveVars.cjs +67 -0
- package/dist/tailwind/dist/utils/postcssPreserveVars.js +65 -0
- package/dist/tailwind/dist/utils/tsMorph.cjs +1 -1
- package/dist/uds/generated/componentData.cjs +943 -928
- package/dist/uds/generated/componentData.js +943 -928
- package/dist/uds/package.cjs +10 -4
- package/dist/uds/package.js +10 -4
- package/generated/componentData.json +2397 -0
- package/generated/tailwindPurge.ts +4560 -0
- package/package.json +7 -4
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_utils = require('./utils.cjs');
|
|
4
|
+
const require_plugin = require('../plugin.cjs');
|
|
5
|
+
const require_optimizeCSS = require('../utils/optimizeCSS.cjs');
|
|
6
|
+
const require_postcssPreserveVars = require('../utils/postcssPreserveVars.cjs');
|
|
7
|
+
const require_postcss = require('./postcss.cjs');
|
|
8
|
+
let node_path = require("node:path");
|
|
9
|
+
node_path = require_runtime.__toESM(node_path);
|
|
10
|
+
let postcss = require("postcss");
|
|
11
|
+
postcss = require_runtime.__toESM(postcss);
|
|
12
|
+
let autoprefixer = require("autoprefixer");
|
|
13
|
+
autoprefixer = require_runtime.__toESM(autoprefixer);
|
|
14
|
+
let postcss_prune_var = require("postcss-prune-var");
|
|
15
|
+
postcss_prune_var = require_runtime.__toESM(postcss_prune_var);
|
|
16
|
+
let postcss_scope = require("postcss-scope");
|
|
17
|
+
postcss_scope = require_runtime.__toESM(postcss_scope);
|
|
18
|
+
let tailwindcss = require("tailwindcss");
|
|
19
|
+
tailwindcss = require_runtime.__toESM(tailwindcss);
|
|
20
|
+
|
|
21
|
+
//#region ../tailwind/dist/css/generate.helpers.js
|
|
22
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
23
|
+
const getCssFeatureFlags = (cssOptions) => {
|
|
24
|
+
const optimizationConfig = cssOptions?.optimization;
|
|
25
|
+
const shouldOptimize = optimizationConfig?.enabled !== false;
|
|
26
|
+
return {
|
|
27
|
+
enablePreflight: cssOptions?.preflight !== false,
|
|
28
|
+
enableFontFaceDeclarations: cssOptions?.fontFaceDeclarations !== false,
|
|
29
|
+
shouldOptimize,
|
|
30
|
+
shouldPruneVars: shouldOptimize && optimizationConfig?.pruneVars !== false
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getContentGlobs = (contentDir) => [node_path.default.join(contentDir, "**/*.{js,jsx,ts,tsx}")];
|
|
34
|
+
const createTailwindPlugin = (options) => {
|
|
35
|
+
return (0, tailwindcss.default)({
|
|
36
|
+
content: getContentGlobs(options.contentDir),
|
|
37
|
+
safelist: options.safelist,
|
|
38
|
+
corePlugins: { preflight: options.enablePreflight },
|
|
39
|
+
plugins: [require_plugin.tailwindPlugin({
|
|
40
|
+
config: options.config,
|
|
41
|
+
disableFontFaceDeclarations: !options.enableFontFaceDeclarations,
|
|
42
|
+
ignorePluginSafelists: true
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const getPruneVarPlugins = (safeVarPrefixes) => {
|
|
47
|
+
if (safeVarPrefixes.length === 0) return [(0, postcss_prune_var.default)()];
|
|
48
|
+
return [
|
|
49
|
+
require_postcssPreserveVars.preserveVars({ preserve: safeVarPrefixes }),
|
|
50
|
+
(0, postcss_prune_var.default)(),
|
|
51
|
+
require_postcssPreserveVars.preserveVarsCleanup()
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
const buildPostcssPlugins = (options) => {
|
|
55
|
+
const plugins = [options.tailwindPlugin, (0, autoprefixer.default)()];
|
|
56
|
+
if (options.shouldPruneVars) plugins.push(...getPruneVarPlugins(options.safeVarPrefixes));
|
|
57
|
+
if (options.scopeClass) plugins.push((0, postcss_scope.default)(options.scopeClass));
|
|
58
|
+
return plugins;
|
|
59
|
+
};
|
|
60
|
+
const applyScopedColorModeFix = async (css, scopeClass) => {
|
|
61
|
+
if (!scopeClass) return css;
|
|
62
|
+
return (await (0, postcss.default)([require_postcss.fixScopedColorModeSelectorsPlugin(scopeClass)]).process(css, { from: void 0 })).css;
|
|
63
|
+
};
|
|
64
|
+
const optimizeGeneratedCss = async (options) => {
|
|
65
|
+
if (!options.shouldOptimize) return { css: options.css };
|
|
66
|
+
const optimizationOptions = {
|
|
67
|
+
removeUnusedFonts: options.optimizationConfig?.removeUnusedFonts,
|
|
68
|
+
removeEmptyRules: options.optimizationConfig?.removeEmptyRules,
|
|
69
|
+
aggregateDuplicateSelectors: options.optimizationConfig?.aggregateDuplicateSelectors,
|
|
70
|
+
referenceCss: options.referenceCss,
|
|
71
|
+
scopeClass: options.scopeClass
|
|
72
|
+
};
|
|
73
|
+
const optimized = await require_optimizeCSS.optimizeCSS(options.css, optimizationOptions);
|
|
74
|
+
return {
|
|
75
|
+
css: optimized.css,
|
|
76
|
+
optimizationStats: {
|
|
77
|
+
originalSize: optimized.stats.originalSize,
|
|
78
|
+
originalSizeGzip: optimized.stats.originalSizeGzip,
|
|
79
|
+
fontFacesRemoved: optimized.stats.fontFacesRemoved,
|
|
80
|
+
emptyRulesRemoved: optimized.stats.emptyRulesRemoved,
|
|
81
|
+
validationErrors: optimized.validation.errors
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const printSimpleModeStats = (options) => {
|
|
86
|
+
const { print, magenta, cyan, yellow } = options;
|
|
87
|
+
print("");
|
|
88
|
+
print(`${magenta("Output:")} ${cyan(options.outputPath)}`);
|
|
89
|
+
print(`${magenta("Stats:")}`);
|
|
90
|
+
print(` Files scanned: ${options.totalFilesScanned}`);
|
|
91
|
+
print(` Classes: ${options.classCount}`);
|
|
92
|
+
print(` Size: ${require_utils.formatBytes(options.sizeBytes)} (${require_utils.formatBytes(options.sizeGzipBytes)} gzipped)`);
|
|
93
|
+
const optimizationStats = options.optimizationStats;
|
|
94
|
+
if (optimizationStats) {
|
|
95
|
+
const savedBytesGzip = optimizationStats.originalSizeGzip - options.sizeGzipBytes;
|
|
96
|
+
if (savedBytesGzip > 0) print(` Optimized: saved ${require_utils.formatBytes(savedBytesGzip)} gzip (${optimizationStats.fontFacesRemoved} unused @font-face, ${optimizationStats.emptyRulesRemoved} empty rules removed)`);
|
|
97
|
+
if (optimizationStats.validationErrors.length > 0) {
|
|
98
|
+
print(` ${yellow("Validation warnings:")}`);
|
|
99
|
+
optimizationStats.validationErrors.forEach((error) => print(` ${yellow("•")} ${error}`));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
print(` Time: ${options.duration}ms`);
|
|
103
|
+
if (options.scope) print(` Scope: ${cyan(options.scope)}`);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
exports.applyScopedColorModeFix = applyScopedColorModeFix;
|
|
108
|
+
exports.buildPostcssPlugins = buildPostcssPlugins;
|
|
109
|
+
exports.createTailwindPlugin = createTailwindPlugin;
|
|
110
|
+
exports.getCssFeatureFlags = getCssFeatureFlags;
|
|
111
|
+
exports.optimizeGeneratedCss = optimizeGeneratedCss;
|
|
112
|
+
exports.printSimpleModeStats = printSimpleModeStats;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
import { formatBytes } from "./utils.js";
|
|
3
|
+
import { tailwindPlugin } from "../plugin.js";
|
|
4
|
+
import { optimizeCSS } from "../utils/optimizeCSS.js";
|
|
5
|
+
import { preserveVars, preserveVarsCleanup } from "../utils/postcssPreserveVars.js";
|
|
6
|
+
import { fixScopedColorModeSelectorsPlugin } from "./postcss.js";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import postcss from "postcss";
|
|
9
|
+
import autoprefixer from "autoprefixer";
|
|
10
|
+
import pruneVar from "postcss-prune-var";
|
|
11
|
+
import postcssScope from "postcss-scope";
|
|
12
|
+
import tailwindcss from "tailwindcss";
|
|
13
|
+
|
|
14
|
+
//#region ../tailwind/dist/css/generate.helpers.js
|
|
15
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
16
|
+
const getCssFeatureFlags = (cssOptions) => {
|
|
17
|
+
const optimizationConfig = cssOptions?.optimization;
|
|
18
|
+
const shouldOptimize = optimizationConfig?.enabled !== false;
|
|
19
|
+
return {
|
|
20
|
+
enablePreflight: cssOptions?.preflight !== false,
|
|
21
|
+
enableFontFaceDeclarations: cssOptions?.fontFaceDeclarations !== false,
|
|
22
|
+
shouldOptimize,
|
|
23
|
+
shouldPruneVars: shouldOptimize && optimizationConfig?.pruneVars !== false
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const getContentGlobs = (contentDir) => [path.join(contentDir, "**/*.{js,jsx,ts,tsx}")];
|
|
27
|
+
const createTailwindPlugin = (options) => {
|
|
28
|
+
return tailwindcss({
|
|
29
|
+
content: getContentGlobs(options.contentDir),
|
|
30
|
+
safelist: options.safelist,
|
|
31
|
+
corePlugins: { preflight: options.enablePreflight },
|
|
32
|
+
plugins: [tailwindPlugin({
|
|
33
|
+
config: options.config,
|
|
34
|
+
disableFontFaceDeclarations: !options.enableFontFaceDeclarations,
|
|
35
|
+
ignorePluginSafelists: true
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const getPruneVarPlugins = (safeVarPrefixes) => {
|
|
40
|
+
if (safeVarPrefixes.length === 0) return [pruneVar()];
|
|
41
|
+
return [
|
|
42
|
+
preserveVars({ preserve: safeVarPrefixes }),
|
|
43
|
+
pruneVar(),
|
|
44
|
+
preserveVarsCleanup()
|
|
45
|
+
];
|
|
46
|
+
};
|
|
47
|
+
const buildPostcssPlugins = (options) => {
|
|
48
|
+
const plugins = [options.tailwindPlugin, autoprefixer()];
|
|
49
|
+
if (options.shouldPruneVars) plugins.push(...getPruneVarPlugins(options.safeVarPrefixes));
|
|
50
|
+
if (options.scopeClass) plugins.push(postcssScope(options.scopeClass));
|
|
51
|
+
return plugins;
|
|
52
|
+
};
|
|
53
|
+
const applyScopedColorModeFix = async (css, scopeClass) => {
|
|
54
|
+
if (!scopeClass) return css;
|
|
55
|
+
return (await postcss([fixScopedColorModeSelectorsPlugin(scopeClass)]).process(css, { from: void 0 })).css;
|
|
56
|
+
};
|
|
57
|
+
const optimizeGeneratedCss = async (options) => {
|
|
58
|
+
if (!options.shouldOptimize) return { css: options.css };
|
|
59
|
+
const optimizationOptions = {
|
|
60
|
+
removeUnusedFonts: options.optimizationConfig?.removeUnusedFonts,
|
|
61
|
+
removeEmptyRules: options.optimizationConfig?.removeEmptyRules,
|
|
62
|
+
aggregateDuplicateSelectors: options.optimizationConfig?.aggregateDuplicateSelectors,
|
|
63
|
+
referenceCss: options.referenceCss,
|
|
64
|
+
scopeClass: options.scopeClass
|
|
65
|
+
};
|
|
66
|
+
const optimized = await optimizeCSS(options.css, optimizationOptions);
|
|
67
|
+
return {
|
|
68
|
+
css: optimized.css,
|
|
69
|
+
optimizationStats: {
|
|
70
|
+
originalSize: optimized.stats.originalSize,
|
|
71
|
+
originalSizeGzip: optimized.stats.originalSizeGzip,
|
|
72
|
+
fontFacesRemoved: optimized.stats.fontFacesRemoved,
|
|
73
|
+
emptyRulesRemoved: optimized.stats.emptyRulesRemoved,
|
|
74
|
+
validationErrors: optimized.validation.errors
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const printSimpleModeStats = (options) => {
|
|
79
|
+
const { print, magenta, cyan, yellow } = options;
|
|
80
|
+
print("");
|
|
81
|
+
print(`${magenta("Output:")} ${cyan(options.outputPath)}`);
|
|
82
|
+
print(`${magenta("Stats:")}`);
|
|
83
|
+
print(` Files scanned: ${options.totalFilesScanned}`);
|
|
84
|
+
print(` Classes: ${options.classCount}`);
|
|
85
|
+
print(` Size: ${formatBytes(options.sizeBytes)} (${formatBytes(options.sizeGzipBytes)} gzipped)`);
|
|
86
|
+
const optimizationStats = options.optimizationStats;
|
|
87
|
+
if (optimizationStats) {
|
|
88
|
+
const savedBytesGzip = optimizationStats.originalSizeGzip - options.sizeGzipBytes;
|
|
89
|
+
if (savedBytesGzip > 0) print(` Optimized: saved ${formatBytes(savedBytesGzip)} gzip (${optimizationStats.fontFacesRemoved} unused @font-face, ${optimizationStats.emptyRulesRemoved} empty rules removed)`);
|
|
90
|
+
if (optimizationStats.validationErrors.length > 0) {
|
|
91
|
+
print(` ${yellow("Validation warnings:")}`);
|
|
92
|
+
optimizationStats.validationErrors.forEach((error) => print(` ${yellow("•")} ${error}`));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
print(` Time: ${options.duration}ms`);
|
|
96
|
+
if (options.scope) print(` Scope: ${cyan(options.scope)}`);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { applyScopedColorModeFix, buildPostcssPlugins, createTailwindPlugin, getCssFeatureFlags, optimizeGeneratedCss, printSimpleModeStats };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
import { defaultTokensConfig } from "../../../config/dist/index.js";
|
|
3
|
+
import { cyan, magenta, yellow } from "../../../cli/dist/lib/colors.js";
|
|
4
|
+
import { print } from "../../../cli/dist/lib/print.js";
|
|
5
|
+
import { spinStop } from "../../../cli/dist/lib/spinner.js";
|
|
6
|
+
import { extractVariantDefaults, getConfigurableCssVariables, getMotionVarPrefixes, loadConfigFile, scanDirectoryForSafelist } from "./utils.js";
|
|
7
|
+
import { deduplicateSafelist, getThemeAndScaleClasses } from "../purger/optimized/utils/safelist.js";
|
|
8
|
+
import { applyScopedColorModeFix, buildPostcssPlugins, createTailwindPlugin, getCssFeatureFlags, optimizeGeneratedCss, printSimpleModeStats } from "./generate.helpers.js";
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { gzipSync } from "node:zlib";
|
|
12
|
+
import postcss from "postcss";
|
|
13
|
+
|
|
14
|
+
//#region ../tailwind/dist/css/generate.js
|
|
15
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
16
|
+
const normalizeScope = (scope) => {
|
|
17
|
+
const trimmedScope = scope?.trim();
|
|
18
|
+
return trimmedScope ? trimmedScope : void 0;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Generate CSS from a safelist using Tailwind + PostCSS
|
|
22
|
+
* @param safelist - UDS component classes to include
|
|
23
|
+
* @param config - Token configuration
|
|
24
|
+
* @param options - Additional options
|
|
25
|
+
*/
|
|
26
|
+
const generateCSS = async (safelist, config, options) => {
|
|
27
|
+
const sourceCSS = "@tailwind base; @tailwind components; @tailwind utilities";
|
|
28
|
+
const contentDir = options?.contentDir ?? path.join(process.cwd(), "src");
|
|
29
|
+
const cssFlags = getCssFeatureFlags(options?.cssOptions);
|
|
30
|
+
const optimizationConfig = options?.cssOptions?.optimization;
|
|
31
|
+
const scopeClass = normalizeScope(options?.scope) ?? normalizeScope(options?.cssOptions?.scope);
|
|
32
|
+
let css = await applyScopedColorModeFix((await postcss(buildPostcssPlugins({
|
|
33
|
+
tailwindPlugin: createTailwindPlugin({
|
|
34
|
+
contentDir,
|
|
35
|
+
safelist,
|
|
36
|
+
config,
|
|
37
|
+
enablePreflight: cssFlags.enablePreflight,
|
|
38
|
+
enableFontFaceDeclarations: cssFlags.enableFontFaceDeclarations
|
|
39
|
+
}),
|
|
40
|
+
shouldPruneVars: cssFlags.shouldPruneVars,
|
|
41
|
+
safeVarPrefixes: options?.safeVarPrefixes ?? [],
|
|
42
|
+
scopeClass
|
|
43
|
+
})).process(sourceCSS, { from: void 0 })).css, scopeClass);
|
|
44
|
+
const optimizedCss = await optimizeGeneratedCss({
|
|
45
|
+
css,
|
|
46
|
+
shouldOptimize: cssFlags.shouldOptimize,
|
|
47
|
+
optimizationConfig,
|
|
48
|
+
referenceCss: options?.referenceCss,
|
|
49
|
+
scopeClass
|
|
50
|
+
});
|
|
51
|
+
css = optimizedCss.css;
|
|
52
|
+
const sizeBytes = Buffer.byteLength(css, "utf8");
|
|
53
|
+
const sizeGzipBytes = gzipSync(css).length;
|
|
54
|
+
return {
|
|
55
|
+
css,
|
|
56
|
+
sizeBytes,
|
|
57
|
+
sizeGzipBytes,
|
|
58
|
+
classCount: safelist.length,
|
|
59
|
+
optimizationStats: optimizedCss.optimizationStats
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Generate CSS in simple mode (no uds.theme.ts)
|
|
64
|
+
*/
|
|
65
|
+
const generateSimpleModeCSS = async (options) => {
|
|
66
|
+
const isWatch = options.isWatch === true;
|
|
67
|
+
const shouldLogStats = !(options.silent === true) && !isWatch;
|
|
68
|
+
const startTime = performance.now();
|
|
69
|
+
const colorModes = ["dark"];
|
|
70
|
+
let tokensConfig = defaultTokensConfig;
|
|
71
|
+
if (options.configPath) {
|
|
72
|
+
const loadedConfig = await loadConfigFile(options.configPath);
|
|
73
|
+
if (loadedConfig) tokensConfig = loadedConfig;
|
|
74
|
+
else if (shouldLogStats) spinStop("⚠️", `Config file not found: ${options.configPath}, using defaults`);
|
|
75
|
+
}
|
|
76
|
+
const variantDefaults = extractVariantDefaults(tokensConfig);
|
|
77
|
+
const entryDir = path.join(options.workspaceDir, options.entry);
|
|
78
|
+
const scanResult = await scanDirectoryForSafelist(entryDir, colorModes, options.variants, options.autoVariants, options.componentData, variantDefaults);
|
|
79
|
+
const totalFilesScanned = scanResult.filesScanned;
|
|
80
|
+
const allClasses = [...scanResult.safelist];
|
|
81
|
+
const allComponents = new Set(scanResult.components);
|
|
82
|
+
const packageDirs = [entryDir];
|
|
83
|
+
const cssResult = await generateCSS(deduplicateSafelist([...allClasses, ...getThemeAndScaleClasses(colorModes)]), tokensConfig, {
|
|
84
|
+
scope: options.scope,
|
|
85
|
+
contentDir: entryDir,
|
|
86
|
+
safeVarPrefixes: [...getMotionVarPrefixes(options.componentData, [...allComponents]), ...getConfigurableCssVariables()]
|
|
87
|
+
});
|
|
88
|
+
const outputPath = path.isAbsolute(options.outFile) ? options.outFile : path.join(options.workspaceDir, options.outFile);
|
|
89
|
+
const outputDir = path.dirname(outputPath);
|
|
90
|
+
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
|
|
91
|
+
fs.writeFileSync(outputPath, cssResult.css);
|
|
92
|
+
const duration = Math.round(performance.now() - startTime);
|
|
93
|
+
if (shouldLogStats) printSimpleModeStats({
|
|
94
|
+
outputPath,
|
|
95
|
+
totalFilesScanned,
|
|
96
|
+
classCount: cssResult.classCount,
|
|
97
|
+
sizeBytes: cssResult.sizeBytes,
|
|
98
|
+
sizeGzipBytes: cssResult.sizeGzipBytes,
|
|
99
|
+
duration,
|
|
100
|
+
scope: options.scope,
|
|
101
|
+
optimizationStats: cssResult.optimizationStats,
|
|
102
|
+
print,
|
|
103
|
+
magenta,
|
|
104
|
+
cyan,
|
|
105
|
+
yellow
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
success: true,
|
|
109
|
+
outputPath,
|
|
110
|
+
packageDirs
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { generateCSS, generateSimpleModeCSS };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
const require_postcss_helpers = require('./postcss.helpers.cjs');
|
|
3
|
+
|
|
4
|
+
//#region ../tailwind/dist/css/postcss.js
|
|
5
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
6
|
+
/**
|
|
7
|
+
* PostCSS plugin to fix color mode selectors for scoped CSS.
|
|
8
|
+
*
|
|
9
|
+
* postcss-scope converts selectors like:
|
|
10
|
+
* `.uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo`
|
|
11
|
+
*
|
|
12
|
+
* But the color mode class is typically on <html> or <body>, which is an
|
|
13
|
+
* ANCESTOR of the scope, not a descendant. This plugin adds alternative
|
|
14
|
+
* selectors so color modes work correctly:
|
|
15
|
+
*
|
|
16
|
+
* `.scope .uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo, .uds-color-mode-dark .scope .foo`
|
|
17
|
+
*
|
|
18
|
+
* This ensures styles apply whether the color mode class is inside or outside the scope.
|
|
19
|
+
*/
|
|
20
|
+
const fixScopedColorModeSelectorsPlugin = (scopeClass) => {
|
|
21
|
+
const colorModePattern = /\.(uds-color-mode-(?:dark|light))/;
|
|
22
|
+
return {
|
|
23
|
+
postcssPlugin: "fix-scoped-color-mode-selectors",
|
|
24
|
+
Once(root) {
|
|
25
|
+
root.walkRules((rule) => {
|
|
26
|
+
if (!rule.selector.includes(scopeClass) || !colorModePattern.test(rule.selector)) return;
|
|
27
|
+
const nextSelector = require_postcss_helpers.buildScopedColorModeSelectorList(rule.selector, scopeClass);
|
|
28
|
+
if (nextSelector !== rule.selector) rule.selector = nextSelector;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.fixScopedColorModeSelectorsPlugin = fixScopedColorModeSelectorsPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
|
|
3
|
+
//#region ../tailwind/dist/css/postcss.helpers.js
|
|
4
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
5
|
+
const COLOR_MODE_RE = /^(\.(uds-color-mode-(?:dark|light)))(\s+.+)?$/;
|
|
6
|
+
const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7
|
+
const getScopedColorModeAlternativeSelector = (selector, scopeClass) => {
|
|
8
|
+
const scopeMatch = selector.match(new RegExp(`^(${escapeForRegExp(scopeClass)})\\s+(.+)$`));
|
|
9
|
+
if (!scopeMatch) return null;
|
|
10
|
+
const colorModeMatch = scopeMatch[2].match(COLOR_MODE_RE);
|
|
11
|
+
if (!colorModeMatch) return null;
|
|
12
|
+
return `${colorModeMatch[1]} ${scopeClass}${colorModeMatch[3] ?? ""}`;
|
|
13
|
+
};
|
|
14
|
+
const buildScopedColorModeSelectorList = (ruleSelector, scopeClass) => {
|
|
15
|
+
const selectors = ruleSelector.split(",").map((value) => value.trim());
|
|
16
|
+
return selectors.reduce((acc, selector) => {
|
|
17
|
+
const altSelector = getScopedColorModeAlternativeSelector(selector, scopeClass);
|
|
18
|
+
return altSelector && !selectors.includes(altSelector) && !acc.includes(altSelector) ? [
|
|
19
|
+
...acc,
|
|
20
|
+
selector,
|
|
21
|
+
altSelector
|
|
22
|
+
] : [...acc, selector];
|
|
23
|
+
}, []).join(", ");
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.buildScopedColorModeSelectorList = buildScopedColorModeSelectorList;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
//#region ../tailwind/dist/css/postcss.helpers.js
|
|
3
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
4
|
+
const COLOR_MODE_RE = /^(\.(uds-color-mode-(?:dark|light)))(\s+.+)?$/;
|
|
5
|
+
const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6
|
+
const getScopedColorModeAlternativeSelector = (selector, scopeClass) => {
|
|
7
|
+
const scopeMatch = selector.match(new RegExp(`^(${escapeForRegExp(scopeClass)})\\s+(.+)$`));
|
|
8
|
+
if (!scopeMatch) return null;
|
|
9
|
+
const colorModeMatch = scopeMatch[2].match(COLOR_MODE_RE);
|
|
10
|
+
if (!colorModeMatch) return null;
|
|
11
|
+
return `${colorModeMatch[1]} ${scopeClass}${colorModeMatch[3] ?? ""}`;
|
|
12
|
+
};
|
|
13
|
+
const buildScopedColorModeSelectorList = (ruleSelector, scopeClass) => {
|
|
14
|
+
const selectors = ruleSelector.split(",").map((value) => value.trim());
|
|
15
|
+
return selectors.reduce((acc, selector) => {
|
|
16
|
+
const altSelector = getScopedColorModeAlternativeSelector(selector, scopeClass);
|
|
17
|
+
return altSelector && !selectors.includes(altSelector) && !acc.includes(altSelector) ? [
|
|
18
|
+
...acc,
|
|
19
|
+
selector,
|
|
20
|
+
altSelector
|
|
21
|
+
] : [...acc, selector];
|
|
22
|
+
}, []).join(", ");
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { buildScopedColorModeSelectorList };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
import { buildScopedColorModeSelectorList } from "./postcss.helpers.js";
|
|
3
|
+
|
|
4
|
+
//#region ../tailwind/dist/css/postcss.js
|
|
5
|
+
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
6
|
+
/**
|
|
7
|
+
* PostCSS plugin to fix color mode selectors for scoped CSS.
|
|
8
|
+
*
|
|
9
|
+
* postcss-scope converts selectors like:
|
|
10
|
+
* `.uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo`
|
|
11
|
+
*
|
|
12
|
+
* But the color mode class is typically on <html> or <body>, which is an
|
|
13
|
+
* ANCESTOR of the scope, not a descendant. This plugin adds alternative
|
|
14
|
+
* selectors so color modes work correctly:
|
|
15
|
+
*
|
|
16
|
+
* `.scope .uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo, .uds-color-mode-dark .scope .foo`
|
|
17
|
+
*
|
|
18
|
+
* This ensures styles apply whether the color mode class is inside or outside the scope.
|
|
19
|
+
*/
|
|
20
|
+
const fixScopedColorModeSelectorsPlugin = (scopeClass) => {
|
|
21
|
+
const colorModePattern = /\.(uds-color-mode-(?:dark|light))/;
|
|
22
|
+
return {
|
|
23
|
+
postcssPlugin: "fix-scoped-color-mode-selectors",
|
|
24
|
+
Once(root) {
|
|
25
|
+
root.walkRules((rule) => {
|
|
26
|
+
if (!rule.selector.includes(scopeClass) || !colorModePattern.test(rule.selector)) return;
|
|
27
|
+
const nextSelector = buildScopedColorModeSelectorList(rule.selector, scopeClass);
|
|
28
|
+
if (nextSelector !== rule.selector) rule.selector = nextSelector;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { fixScopedColorModeSelectorsPlugin };
|