@yahoo/uds 3.115.0-beta.1 → 3.115.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/dist/cli/commands/sync.cjs +2 -2
- package/dist/cli/commands/sync.js +2 -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 +3 -3
- package/dist/cli/dist/commands/editor-rules.js +3 -3
- 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 +2 -2
- package/dist/cli/runner.js +2 -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/styles/styler.d.cts +1 -1
- package/dist/styles/styler.d.ts +1 -1
- package/dist/tailwind/dist/commands/css.cjs +2 -2
- package/dist/tailwind/dist/commands/css.js +1 -1
- package/dist/tailwind/dist/css/generate.cjs +6 -5
- package/dist/tailwind/dist/css/generate.js +3 -2
- package/dist/tailwind/dist/css/nodeUtils.cjs +156 -0
- package/dist/tailwind/dist/css/nodeUtils.js +149 -0
- package/dist/tailwind/dist/css/runner.cjs +9 -8
- package/dist/tailwind/dist/css/runner.js +3 -2
- package/dist/tailwind/dist/css/utils.cjs +1 -163
- package/dist/tailwind/dist/css/utils.js +1 -155
- package/dist/tailwind/dist/index.d.ts +0 -4
- package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +2 -2
- package/dist/tailwind/dist/purger/legacy/purgeCSS.js +2 -2
- package/dist/tailwind/dist/purger/optimized/purge.cjs +2 -2
- package/dist/tailwind/dist/purger/optimized/purge.js +1 -1
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +2 -2
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +2 -2
- package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +1 -1
- package/dist/tailwind/dist/purger/optimized/utils/safelist.js +1 -1
- package/dist/tailwind/dist/tailwind/components/getResponsiveTextStyles.cjs +1 -1
- package/dist/tailwind/dist/tailwind/components/getResponsiveTextStyles.js +1 -1
- package/dist/tailwind/dist/tailwind/plugins/breakpoints.cjs +1 -1
- package/dist/tailwind/dist/tailwind/plugins/breakpoints.js +1 -1
- package/dist/uds/generated/componentData.cjs +107 -107
- package/dist/uds/generated/componentData.js +107 -107
- package/generated/componentData.json +142 -142
- package/package.json +1 -1
- package/dist/tailwind/dist/commands/css.d.ts +0 -3
- package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +0 -3
- package/dist/tailwind/dist/commands/purge.d.ts +0 -4
- package/dist/tailwind/dist/purger/legacy/purgeCSS.d.ts +0 -2
|
@@ -5,14 +5,15 @@ const require_colors = require('../../../cli/dist/lib/colors.cjs');
|
|
|
5
5
|
const require_print = require('../../../cli/dist/lib/print.cjs');
|
|
6
6
|
const require_spinner = require('../../../cli/dist/lib/spinner.cjs');
|
|
7
7
|
const require_logger = require('../../../cli/dist/lib/logger.cjs');
|
|
8
|
-
const
|
|
8
|
+
const require_nodeUtils = require('./nodeUtils.cjs');
|
|
9
9
|
const require_safelist = require('../purger/optimized/utils/safelist.cjs');
|
|
10
|
+
const require_utils = require('./utils.cjs');
|
|
10
11
|
const require_generate = require('./generate.cjs');
|
|
11
12
|
const require_runner_helpers = require('./runner.helpers.cjs');
|
|
12
|
-
let node_fs = require("node:fs");
|
|
13
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
14
13
|
let node_path = require("node:path");
|
|
15
14
|
node_path = require_runtime.__toESM(node_path);
|
|
15
|
+
let node_fs = require("node:fs");
|
|
16
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
16
17
|
|
|
17
18
|
//#region ../tailwind/dist/css/runner.js
|
|
18
19
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -133,7 +134,7 @@ const runSimpleModeWatch = async (options, context, entry, configPath, packageDi
|
|
|
133
134
|
await new Promise(() => {});
|
|
134
135
|
};
|
|
135
136
|
const loadThemeModeSetup = async (options) => {
|
|
136
|
-
const themeConfigInput = await
|
|
137
|
+
const themeConfigInput = await require_nodeUtils.loadConfigFile(String(options.themeConfigPath));
|
|
137
138
|
if (!themeConfigInput) return null;
|
|
138
139
|
const themeContext = {
|
|
139
140
|
cwd: options.workspaceDir,
|
|
@@ -142,7 +143,7 @@ const loadThemeModeSetup = async (options) => {
|
|
|
142
143
|
const themeConfig = typeof themeConfigInput === "function" ? await themeConfigInput(themeContext) : themeConfigInput;
|
|
143
144
|
let appConfig = require_index.defaultTokensConfig;
|
|
144
145
|
if (themeConfig.config) {
|
|
145
|
-
const loadedConfig = await
|
|
146
|
+
const loadedConfig = await require_nodeUtils.loadConfigFile(themeConfig.config);
|
|
146
147
|
if (loadedConfig) appConfig = loadedConfig;
|
|
147
148
|
}
|
|
148
149
|
return {
|
|
@@ -177,20 +178,20 @@ const runThemeMode = async (options, context) => {
|
|
|
177
178
|
const genStartTime = performance.now();
|
|
178
179
|
const genLog = opts?.isWatch ? require_logger.createLogger({ silent: true }) : log;
|
|
179
180
|
genLog.spinStart("Scanning app code...");
|
|
180
|
-
const appScanResult = await
|
|
181
|
+
const appScanResult = await require_nodeUtils.scanDirectoryForSafelist(node_path.default.join(workspaceDir, entry), colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults);
|
|
181
182
|
genLog.spinStop("✅", `Scanned ${appScanResult.filesScanned} files`);
|
|
182
183
|
genLog.spinStart("Generating main CSS...");
|
|
183
184
|
const inheritedClasses = [...appScanResult.safelist];
|
|
184
185
|
const inheritedComponents = new Set(appScanResult.components);
|
|
185
186
|
const processInheritedPackage = async (packageName) => {
|
|
186
187
|
genLog.spinStart(`Processing package: ${packageName}...`);
|
|
187
|
-
const packageDir =
|
|
188
|
+
const packageDir = require_nodeUtils.findPackageSourceDir(packageName);
|
|
188
189
|
if (!packageDir) {
|
|
189
190
|
genLog.spinStop("⚠️", `Package not found: ${packageName}`);
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
192
193
|
if (!packageDirs.includes(packageDir)) packageDirs.push(packageDir);
|
|
193
|
-
const packageScanResult = await
|
|
194
|
+
const packageScanResult = await require_nodeUtils.scanDirectoryForSafelist(packageDir, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, true);
|
|
194
195
|
inheritedClasses.push(...packageScanResult.safelist);
|
|
195
196
|
packageScanResult.components.forEach((comp) => inheritedComponents.add(comp));
|
|
196
197
|
genLog.spinStop("✅", `${packageName}: ${packageScanResult.filesScanned} files (inherit)`);
|
|
@@ -4,12 +4,13 @@ import { gray, green, magenta } from "../../../cli/dist/lib/colors.js";
|
|
|
4
4
|
import { print } from "../../../cli/dist/lib/print.js";
|
|
5
5
|
import { spinStart, spinStop } from "../../../cli/dist/lib/spinner.js";
|
|
6
6
|
import { createLogger } from "../../../cli/dist/lib/logger.js";
|
|
7
|
-
import {
|
|
7
|
+
import { findPackageSourceDir, loadConfigFile, scanDirectoryForSafelist } from "./nodeUtils.js";
|
|
8
8
|
import { deduplicateSafelist, getThemeAndScaleClasses } from "../purger/optimized/utils/safelist.js";
|
|
9
|
+
import { extractVariantDefaults, formatBytes, getConfigurableCssVariables, getMotionVarPrefixes } from "./utils.js";
|
|
9
10
|
import { generateCSS, generateSimpleModeCSS } from "./generate.js";
|
|
10
11
|
import { getMainCssSummaryMessage, getWatchDirectoryGroups } from "./runner.helpers.js";
|
|
11
|
-
import fs from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
|
+
import fs from "node:fs";
|
|
13
14
|
|
|
14
15
|
//#region ../tailwind/dist/css/runner.js
|
|
15
16
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_properties = require('../../../automated-config/dist/properties.cjs');
|
|
4
|
-
const require_purgeFromCode = require('../purger/optimized/purgeFromCode.cjs');
|
|
5
|
-
const require_colors = require('../../../cli/dist/lib/colors.cjs');
|
|
6
|
-
const require_print = require('../../../cli/dist/lib/print.cjs');
|
|
7
|
-
let node_fs = require("node:fs");
|
|
8
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
9
|
-
let node_path = require("node:path");
|
|
10
|
-
node_path = require_runtime.__toESM(node_path);
|
|
11
|
-
let fast_glob = require("fast-glob");
|
|
12
|
-
fast_glob = require_runtime.__toESM(fast_glob);
|
|
13
|
-
let node_module = require("node:module");
|
|
14
3
|
|
|
15
4
|
//#region ../tailwind/dist/css/utils.js
|
|
16
5
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
17
6
|
/**
|
|
18
|
-
* Load a TypeScript/JavaScript config file dynamically
|
|
19
|
-
*/
|
|
20
|
-
const loadConfigFile = async (configPath) => {
|
|
21
|
-
const absolutePath = node_path.default.isAbsolute(configPath) ? configPath : node_path.default.join(process.cwd(), configPath);
|
|
22
|
-
if (!node_fs.default.existsSync(absolutePath)) return null;
|
|
23
|
-
try {
|
|
24
|
-
const module = await import(absolutePath);
|
|
25
|
-
return module.default ?? module.config ?? module;
|
|
26
|
-
} catch (error) {
|
|
27
|
-
throw new Error(`Failed to load config file: ${absolutePath}\n${error instanceof Error ? error.message : "Unknown error"}`);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
7
|
* Extract variant defaults from a UniversalTokensConfig.
|
|
32
8
|
* Converts from config structure to a simpler lookup format.
|
|
33
9
|
* e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
|
|
@@ -58,85 +34,6 @@ const extractVariantDefaults = (config) => {
|
|
|
58
34
|
}, {});
|
|
59
35
|
};
|
|
60
36
|
/**
|
|
61
|
-
* Scan directory for JSX/TSX files and extract safelist
|
|
62
|
-
*/
|
|
63
|
-
const scanDirectoryForSafelist = async (dir, colorModes, variants, autoVariants, componentData, variantDefaults, includeAllClassNamePrimitives = false) => {
|
|
64
|
-
const files = await (0, fast_glob.default)("**/*.{js,jsx,ts,tsx}", {
|
|
65
|
-
cwd: dir,
|
|
66
|
-
absolute: true,
|
|
67
|
-
ignore: ["**/node_modules/**"]
|
|
68
|
-
});
|
|
69
|
-
const results = await Promise.all(files.map(async (filePath) => {
|
|
70
|
-
return require_purgeFromCode.purgeFromCodeOptimized(node_fs.default.readFileSync(filePath, "utf-8"), {
|
|
71
|
-
colorModes,
|
|
72
|
-
variantDefaults,
|
|
73
|
-
variants,
|
|
74
|
-
autoVariants,
|
|
75
|
-
componentData,
|
|
76
|
-
includeAllClassNamePrimitives
|
|
77
|
-
});
|
|
78
|
-
}));
|
|
79
|
-
return {
|
|
80
|
-
safelist: results.flatMap((result) => result.safelist),
|
|
81
|
-
components: [...new Set(results.flatMap((result) => result.components))],
|
|
82
|
-
filesScanned: files.length
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Find a package's source directory in node_modules
|
|
87
|
-
*/
|
|
88
|
-
const findMonorepoRoot = (startDir) => {
|
|
89
|
-
const findUp = (currentDir) => {
|
|
90
|
-
if (node_fs.default.existsSync(node_path.default.join(currentDir, "packages"))) return currentDir;
|
|
91
|
-
const parentDir = node_path.default.dirname(currentDir);
|
|
92
|
-
return parentDir === currentDir ? null : findUp(parentDir);
|
|
93
|
-
};
|
|
94
|
-
return findUp(startDir);
|
|
95
|
-
};
|
|
96
|
-
const resolvePackageRoot = (workspaceDir, packageName) => {
|
|
97
|
-
const require = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
98
|
-
try {
|
|
99
|
-
const resolvedPackageJson = require.resolve(node_path.default.join(packageName, "package.json"), { paths: [workspaceDir] });
|
|
100
|
-
return node_path.default.dirname(resolvedPackageJson);
|
|
101
|
-
} catch {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const findPackageRootInMonorepo = (monorepoRoot, packageName) => {
|
|
106
|
-
const matchingPath = fast_glob.default.sync("packages/**/package.json", {
|
|
107
|
-
cwd: monorepoRoot,
|
|
108
|
-
absolute: true,
|
|
109
|
-
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
110
|
-
}).find((pkgJsonPath) => {
|
|
111
|
-
try {
|
|
112
|
-
return JSON.parse(node_fs.default.readFileSync(pkgJsonPath, "utf8")).name === packageName;
|
|
113
|
-
} catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return matchingPath ? node_path.default.dirname(matchingPath) : null;
|
|
118
|
-
};
|
|
119
|
-
const buildPackageSourceCandidates = (workspaceDir, packageName, packageRoot) => {
|
|
120
|
-
return [
|
|
121
|
-
packageRoot ? node_path.default.join(packageRoot, "src") : null,
|
|
122
|
-
packageRoot ? node_path.default.join(packageRoot, "lib") : null,
|
|
123
|
-
packageRoot ? node_path.default.join(packageRoot, "dist") : null,
|
|
124
|
-
packageRoot,
|
|
125
|
-
node_path.default.join(workspaceDir, "node_modules", packageName, "src"),
|
|
126
|
-
node_path.default.join(workspaceDir, "node_modules", packageName, "lib"),
|
|
127
|
-
node_path.default.join(workspaceDir, "node_modules", packageName, "dist"),
|
|
128
|
-
node_path.default.join(workspaceDir, "node_modules", packageName)
|
|
129
|
-
].filter(Boolean);
|
|
130
|
-
};
|
|
131
|
-
const getFirstExistingPath = (candidates) => candidates.find((candidate) => node_fs.default.existsSync(candidate)) ?? null;
|
|
132
|
-
const findPackageSourceDir = (packageName) => {
|
|
133
|
-
const workspaceDir = process.cwd();
|
|
134
|
-
const monorepoRoot = findMonorepoRoot(workspaceDir);
|
|
135
|
-
let packageRoot = resolvePackageRoot(workspaceDir, packageName);
|
|
136
|
-
if (!packageRoot && monorepoRoot) packageRoot = findPackageRootInMonorepo(monorepoRoot, packageName);
|
|
137
|
-
return getFirstExistingPath(buildPackageSourceCandidates(workspaceDir, packageName, packageRoot));
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
37
|
* Format bytes to human readable string
|
|
141
38
|
*/
|
|
142
39
|
const formatBytes = (bytes) => {
|
|
@@ -146,61 +43,6 @@ const formatBytes = (bytes) => {
|
|
|
146
43
|
return `${(kb / 1024).toFixed(2)} MB`;
|
|
147
44
|
};
|
|
148
45
|
/**
|
|
149
|
-
* Generate a uds.theme.ts scaffold file
|
|
150
|
-
*/
|
|
151
|
-
const scaffoldThemeConfig = async (options) => {
|
|
152
|
-
const workspaceDir = process.cwd();
|
|
153
|
-
const outputPath = options.outputPath ?? "uds.theme.ts";
|
|
154
|
-
const absoluteOutputPath = node_path.default.isAbsolute(outputPath) ? outputPath : node_path.default.join(workspaceDir, outputPath);
|
|
155
|
-
if (node_fs.default.existsSync(absoluteOutputPath) && !options.force) {
|
|
156
|
-
require_print.print(require_colors.red(`Error: ${outputPath} already exists. Use --force to overwrite.`));
|
|
157
|
-
process.exitCode = 1;
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const template = `import { defineTheme } from '@yahoo/uds';
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* UDS Theme Configuration
|
|
164
|
-
*
|
|
165
|
-
* This file configures CSS generation for your app and shared packages.
|
|
166
|
-
* Run \`uds css\` to generate optimized CSS.
|
|
167
|
-
*/
|
|
168
|
-
export default defineTheme({
|
|
169
|
-
// Path to your uds.config.ts file
|
|
170
|
-
config: '${options.configPath ?? "./uds.config.ts"}',
|
|
171
|
-
|
|
172
|
-
// Entry directory for scanning your app code
|
|
173
|
-
entry: '${options.entry ?? "./src"}',
|
|
174
|
-
|
|
175
|
-
// Color modes to include (light mode is always in :root)
|
|
176
|
-
colorModes: ['dark'],
|
|
177
|
-
|
|
178
|
-
// Packages that inherit your app's theme (merged into main uds.css)
|
|
179
|
-
// inherit: ['@your-org/shared-ui'],
|
|
180
|
-
|
|
181
|
-
// CSS generation options (all optional)
|
|
182
|
-
// css: {
|
|
183
|
-
// safelist: [],
|
|
184
|
-
// preflight: true,
|
|
185
|
-
// fontFaceDeclarations: true,
|
|
186
|
-
// optimization: {
|
|
187
|
-
// removeUnusedFonts: false,
|
|
188
|
-
// removeEmptyRules: true,
|
|
189
|
-
// deduplicateScopedCss: true
|
|
190
|
-
// }
|
|
191
|
-
// }
|
|
192
|
-
});
|
|
193
|
-
`;
|
|
194
|
-
node_fs.default.writeFileSync(absoluteOutputPath, template);
|
|
195
|
-
require_print.print("");
|
|
196
|
-
require_print.print(require_colors.green("✅ Created uds.theme.ts"));
|
|
197
|
-
require_print.print("");
|
|
198
|
-
require_print.print(`${require_colors.magenta("Next steps:")}`);
|
|
199
|
-
require_print.print(` 1. Review and customize ${require_colors.cyan(outputPath)}`);
|
|
200
|
-
require_print.print(` 2. Run ${require_colors.cyan("uds css")} to generate CSS`);
|
|
201
|
-
require_print.print("");
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
46
|
* Get motion CSS variable prefixes needed by a set of components.
|
|
205
47
|
* Looks up motionVarPrefixes from componentData.json for each component.
|
|
206
48
|
*/
|
|
@@ -225,10 +67,6 @@ const getConfigurableCssVariables = () => {
|
|
|
225
67
|
|
|
226
68
|
//#endregion
|
|
227
69
|
exports.extractVariantDefaults = extractVariantDefaults;
|
|
228
|
-
exports.findPackageSourceDir = findPackageSourceDir;
|
|
229
70
|
exports.formatBytes = formatBytes;
|
|
230
71
|
exports.getConfigurableCssVariables = getConfigurableCssVariables;
|
|
231
|
-
exports.getMotionVarPrefixes = getMotionVarPrefixes;
|
|
232
|
-
exports.loadConfigFile = loadConfigFile;
|
|
233
|
-
exports.scaffoldThemeConfig = scaffoldThemeConfig;
|
|
234
|
-
exports.scanDirectoryForSafelist = scanDirectoryForSafelist;
|
|
72
|
+
exports.getMotionVarPrefixes = getMotionVarPrefixes;
|
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { configurableProperties } from "../../../automated-config/dist/properties.js";
|
|
3
|
-
import { purgeFromCodeOptimized } from "../purger/optimized/purgeFromCode.js";
|
|
4
|
-
import { cyan, green, magenta, red } from "../../../cli/dist/lib/colors.js";
|
|
5
|
-
import { print } from "../../../cli/dist/lib/print.js";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import fg from "fast-glob";
|
|
9
|
-
import { createRequire } from "node:module";
|
|
10
3
|
|
|
11
4
|
//#region ../tailwind/dist/css/utils.js
|
|
12
5
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
13
6
|
/**
|
|
14
|
-
* Load a TypeScript/JavaScript config file dynamically
|
|
15
|
-
*/
|
|
16
|
-
const loadConfigFile = async (configPath) => {
|
|
17
|
-
const absolutePath = path.isAbsolute(configPath) ? configPath : path.join(process.cwd(), configPath);
|
|
18
|
-
if (!fs.existsSync(absolutePath)) return null;
|
|
19
|
-
try {
|
|
20
|
-
const module = await import(absolutePath);
|
|
21
|
-
return module.default ?? module.config ?? module;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
throw new Error(`Failed to load config file: ${absolutePath}\n${error instanceof Error ? error.message : "Unknown error"}`);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
7
|
* Extract variant defaults from a UniversalTokensConfig.
|
|
28
8
|
* Converts from config structure to a simpler lookup format.
|
|
29
9
|
* e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
|
|
@@ -54,85 +34,6 @@ const extractVariantDefaults = (config) => {
|
|
|
54
34
|
}, {});
|
|
55
35
|
};
|
|
56
36
|
/**
|
|
57
|
-
* Scan directory for JSX/TSX files and extract safelist
|
|
58
|
-
*/
|
|
59
|
-
const scanDirectoryForSafelist = async (dir, colorModes, variants, autoVariants, componentData, variantDefaults, includeAllClassNamePrimitives = false) => {
|
|
60
|
-
const files = await fg("**/*.{js,jsx,ts,tsx}", {
|
|
61
|
-
cwd: dir,
|
|
62
|
-
absolute: true,
|
|
63
|
-
ignore: ["**/node_modules/**"]
|
|
64
|
-
});
|
|
65
|
-
const results = await Promise.all(files.map(async (filePath) => {
|
|
66
|
-
return purgeFromCodeOptimized(fs.readFileSync(filePath, "utf-8"), {
|
|
67
|
-
colorModes,
|
|
68
|
-
variantDefaults,
|
|
69
|
-
variants,
|
|
70
|
-
autoVariants,
|
|
71
|
-
componentData,
|
|
72
|
-
includeAllClassNamePrimitives
|
|
73
|
-
});
|
|
74
|
-
}));
|
|
75
|
-
return {
|
|
76
|
-
safelist: results.flatMap((result) => result.safelist),
|
|
77
|
-
components: [...new Set(results.flatMap((result) => result.components))],
|
|
78
|
-
filesScanned: files.length
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Find a package's source directory in node_modules
|
|
83
|
-
*/
|
|
84
|
-
const findMonorepoRoot = (startDir) => {
|
|
85
|
-
const findUp = (currentDir) => {
|
|
86
|
-
if (fs.existsSync(path.join(currentDir, "packages"))) return currentDir;
|
|
87
|
-
const parentDir = path.dirname(currentDir);
|
|
88
|
-
return parentDir === currentDir ? null : findUp(parentDir);
|
|
89
|
-
};
|
|
90
|
-
return findUp(startDir);
|
|
91
|
-
};
|
|
92
|
-
const resolvePackageRoot = (workspaceDir, packageName) => {
|
|
93
|
-
const require = createRequire(import.meta.url);
|
|
94
|
-
try {
|
|
95
|
-
const resolvedPackageJson = require.resolve(path.join(packageName, "package.json"), { paths: [workspaceDir] });
|
|
96
|
-
return path.dirname(resolvedPackageJson);
|
|
97
|
-
} catch {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const findPackageRootInMonorepo = (monorepoRoot, packageName) => {
|
|
102
|
-
const matchingPath = fg.sync("packages/**/package.json", {
|
|
103
|
-
cwd: monorepoRoot,
|
|
104
|
-
absolute: true,
|
|
105
|
-
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
106
|
-
}).find((pkgJsonPath) => {
|
|
107
|
-
try {
|
|
108
|
-
return JSON.parse(fs.readFileSync(pkgJsonPath, "utf8")).name === packageName;
|
|
109
|
-
} catch {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
return matchingPath ? path.dirname(matchingPath) : null;
|
|
114
|
-
};
|
|
115
|
-
const buildPackageSourceCandidates = (workspaceDir, packageName, packageRoot) => {
|
|
116
|
-
return [
|
|
117
|
-
packageRoot ? path.join(packageRoot, "src") : null,
|
|
118
|
-
packageRoot ? path.join(packageRoot, "lib") : null,
|
|
119
|
-
packageRoot ? path.join(packageRoot, "dist") : null,
|
|
120
|
-
packageRoot,
|
|
121
|
-
path.join(workspaceDir, "node_modules", packageName, "src"),
|
|
122
|
-
path.join(workspaceDir, "node_modules", packageName, "lib"),
|
|
123
|
-
path.join(workspaceDir, "node_modules", packageName, "dist"),
|
|
124
|
-
path.join(workspaceDir, "node_modules", packageName)
|
|
125
|
-
].filter(Boolean);
|
|
126
|
-
};
|
|
127
|
-
const getFirstExistingPath = (candidates) => candidates.find((candidate) => fs.existsSync(candidate)) ?? null;
|
|
128
|
-
const findPackageSourceDir = (packageName) => {
|
|
129
|
-
const workspaceDir = process.cwd();
|
|
130
|
-
const monorepoRoot = findMonorepoRoot(workspaceDir);
|
|
131
|
-
let packageRoot = resolvePackageRoot(workspaceDir, packageName);
|
|
132
|
-
if (!packageRoot && monorepoRoot) packageRoot = findPackageRootInMonorepo(monorepoRoot, packageName);
|
|
133
|
-
return getFirstExistingPath(buildPackageSourceCandidates(workspaceDir, packageName, packageRoot));
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
37
|
* Format bytes to human readable string
|
|
137
38
|
*/
|
|
138
39
|
const formatBytes = (bytes) => {
|
|
@@ -142,61 +43,6 @@ const formatBytes = (bytes) => {
|
|
|
142
43
|
return `${(kb / 1024).toFixed(2)} MB`;
|
|
143
44
|
};
|
|
144
45
|
/**
|
|
145
|
-
* Generate a uds.theme.ts scaffold file
|
|
146
|
-
*/
|
|
147
|
-
const scaffoldThemeConfig = async (options) => {
|
|
148
|
-
const workspaceDir = process.cwd();
|
|
149
|
-
const outputPath = options.outputPath ?? "uds.theme.ts";
|
|
150
|
-
const absoluteOutputPath = path.isAbsolute(outputPath) ? outputPath : path.join(workspaceDir, outputPath);
|
|
151
|
-
if (fs.existsSync(absoluteOutputPath) && !options.force) {
|
|
152
|
-
print(red(`Error: ${outputPath} already exists. Use --force to overwrite.`));
|
|
153
|
-
process.exitCode = 1;
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const template = `import { defineTheme } from '@yahoo/uds';
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* UDS Theme Configuration
|
|
160
|
-
*
|
|
161
|
-
* This file configures CSS generation for your app and shared packages.
|
|
162
|
-
* Run \`uds css\` to generate optimized CSS.
|
|
163
|
-
*/
|
|
164
|
-
export default defineTheme({
|
|
165
|
-
// Path to your uds.config.ts file
|
|
166
|
-
config: '${options.configPath ?? "./uds.config.ts"}',
|
|
167
|
-
|
|
168
|
-
// Entry directory for scanning your app code
|
|
169
|
-
entry: '${options.entry ?? "./src"}',
|
|
170
|
-
|
|
171
|
-
// Color modes to include (light mode is always in :root)
|
|
172
|
-
colorModes: ['dark'],
|
|
173
|
-
|
|
174
|
-
// Packages that inherit your app's theme (merged into main uds.css)
|
|
175
|
-
// inherit: ['@your-org/shared-ui'],
|
|
176
|
-
|
|
177
|
-
// CSS generation options (all optional)
|
|
178
|
-
// css: {
|
|
179
|
-
// safelist: [],
|
|
180
|
-
// preflight: true,
|
|
181
|
-
// fontFaceDeclarations: true,
|
|
182
|
-
// optimization: {
|
|
183
|
-
// removeUnusedFonts: false,
|
|
184
|
-
// removeEmptyRules: true,
|
|
185
|
-
// deduplicateScopedCss: true
|
|
186
|
-
// }
|
|
187
|
-
// }
|
|
188
|
-
});
|
|
189
|
-
`;
|
|
190
|
-
fs.writeFileSync(absoluteOutputPath, template);
|
|
191
|
-
print("");
|
|
192
|
-
print(green("✅ Created uds.theme.ts"));
|
|
193
|
-
print("");
|
|
194
|
-
print(`${magenta("Next steps:")}`);
|
|
195
|
-
print(` 1. Review and customize ${cyan(outputPath)}`);
|
|
196
|
-
print(` 2. Run ${cyan("uds css")} to generate CSS`);
|
|
197
|
-
print("");
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
46
|
* Get motion CSS variable prefixes needed by a set of components.
|
|
201
47
|
* Looks up motionVarPrefixes from componentData.json for each component.
|
|
202
48
|
*/
|
|
@@ -220,4 +66,4 @@ const getConfigurableCssVariables = () => {
|
|
|
220
66
|
};
|
|
221
67
|
|
|
222
68
|
//#endregion
|
|
223
|
-
export { extractVariantDefaults,
|
|
69
|
+
export { extractVariantDefaults, formatBytes, getConfigurableCssVariables, getMotionVarPrefixes };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import "./commands/generateComponentData.js";
|
|
3
|
-
import "./commands/css.js";
|
|
4
|
-
import "./commands/generatePurgeCSSData.js";
|
|
5
|
-
import "./commands/purge.js";
|
|
6
2
|
import { defineTheme } from "./css/theme.js";
|
|
7
3
|
import "./tailwind/components/getResponsiveTextStyles.js";
|
|
8
4
|
import { WebTokens, parseTokens } from "./utils/parseTokens.js";
|
|
@@ -4,10 +4,10 @@ const require_index = require('../../../../css-tokens/dist/index.cjs');
|
|
|
4
4
|
const require_print = require('../../../../cli/dist/lib/print.cjs');
|
|
5
5
|
const require_spinner = require('../../../../cli/dist/lib/spinner.cjs');
|
|
6
6
|
const require_tsMorph = require('../../utils/tsMorph.cjs');
|
|
7
|
-
let ts_morph = require("ts-morph");
|
|
8
|
-
let node_fs = require("node:fs");
|
|
9
7
|
let node_path = require("node:path");
|
|
10
8
|
node_path = require_runtime.__toESM(node_path);
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
let ts_morph = require("ts-morph");
|
|
11
11
|
let fast_glob = require("fast-glob");
|
|
12
12
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
13
13
|
|
|
@@ -3,9 +3,9 @@ import { DARK_COLOR_MODE_CLASSNAME, LARGE_SCALE_MODE_CLASSNAME, LIGHT_COLOR_MODE
|
|
|
3
3
|
import { print } from "../../../../cli/dist/lib/print.js";
|
|
4
4
|
import { spinStart, spinStop } from "../../../../cli/dist/lib/spinner.js";
|
|
5
5
|
import { findReferencesAsJsxElements, getUsedPropsInReference } from "../../utils/tsMorph.js";
|
|
6
|
-
import { Node, Project, SyntaxKind, ts } from "ts-morph";
|
|
7
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
8
6
|
import path from "node:path";
|
|
7
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { Node, Project, SyntaxKind, ts } from "ts-morph";
|
|
9
9
|
import fg from "fast-glob";
|
|
10
10
|
|
|
11
11
|
//#region ../tailwind/dist/purger/legacy/purgeCSS.js
|
|
@@ -3,10 +3,10 @@ const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_purgeFromCode = require('./purgeFromCode.cjs');
|
|
4
4
|
const require_safelist = require('./utils/safelist.cjs');
|
|
5
5
|
const require_files = require('./utils/files.cjs');
|
|
6
|
-
let node_fs = require("node:fs");
|
|
7
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
8
6
|
let node_path = require("node:path");
|
|
9
7
|
node_path = require_runtime.__toESM(node_path);
|
|
8
|
+
let node_fs = require("node:fs");
|
|
9
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
10
10
|
|
|
11
11
|
//#region ../tailwind/dist/purger/optimized/purge.js
|
|
12
12
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { purgeFromCodeOptimized } from "./purgeFromCode.js";
|
|
3
3
|
import { deduplicateSafelist, getThemeAndScaleClasses, saveSafelistToFile } from "./utils/safelist.js";
|
|
4
4
|
import { scanForFiles } from "./utils/files.js";
|
|
5
|
-
import fs from "node:fs";
|
|
6
5
|
import path from "node:path";
|
|
6
|
+
import fs from "node:fs";
|
|
7
7
|
|
|
8
8
|
//#region ../tailwind/dist/purger/optimized/purge.js
|
|
9
9
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_runtime = require('../../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_index = require('../../../../../motion-tokens/dist/index.cjs');
|
|
4
|
-
let ts_morph = require("ts-morph");
|
|
5
|
-
let node_fs = require("node:fs");
|
|
6
4
|
let node_path = require("node:path");
|
|
7
5
|
node_path = require_runtime.__toESM(node_path);
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
|
+
let ts_morph = require("ts-morph");
|
|
8
8
|
let fast_glob = require("fast-glob");
|
|
9
9
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { SPRING_MOTION_DEFAULTS } from "../../../../../motion-tokens/dist/index.js";
|
|
3
|
-
import { Node, SyntaxKind } from "ts-morph";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
3
|
import path from "node:path";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { Node, SyntaxKind } from "ts-morph";
|
|
6
6
|
import fg from "fast-glob";
|
|
7
7
|
|
|
8
8
|
//#region ../tailwind/dist/purger/optimized/utils/componentAnalyzer.js
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_runtime = require('../../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_index = require('../../../../../css-tokens/dist/index.cjs');
|
|
4
|
-
let node_fs = require("node:fs");
|
|
5
4
|
let node_path = require("node:path");
|
|
6
5
|
node_path = require_runtime.__toESM(node_path);
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
7
|
|
|
8
8
|
//#region ../tailwind/dist/purger/optimized/utils/safelist.js
|
|
9
9
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { DARK_COLOR_MODE_CLASSNAME, LIGHT_COLOR_MODE_CLASSNAME } from "../../../../../css-tokens/dist/index.js";
|
|
3
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
4
3
|
import path from "node:path";
|
|
4
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
5
5
|
|
|
6
6
|
//#region ../tailwind/dist/purger/optimized/utils/safelist.js
|
|
7
7
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_index = require('../../../../fixtures/dist/index.cjs');
|
|
4
4
|
const require_index$1 = require('../../../../css-tokens/dist/index.cjs');
|
|
5
|
-
const require_entries = require('../../utils/entries.cjs');
|
|
6
5
|
const require_assertUnreachable = require('../../utils/assertUnreachable.cjs');
|
|
6
|
+
const require_entries = require('../../utils/entries.cjs');
|
|
7
7
|
let lodash_es = require("lodash-es");
|
|
8
8
|
|
|
9
9
|
//#region ../tailwind/dist/tailwind/components/getResponsiveTextStyles.js
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { textVariants } from "../../../../fixtures/dist/index.js";
|
|
3
3
|
import { FONT_FAMILY_PREFIX, FONT_SIZE_PREFIX, FONT_SLANT_PREFIX, FONT_WEIGHT_PREFIX, FONT_WIDTH_PREFIX, LETTER_SPACING_PREFIX, LINE_HEIGHT_PREFIX, TEXT_RESPONSIVE_BREAKPOINT_CLASSNAMES, TEXT_RESPONSIVE_CLASSNAME, TEXT_TRANSFORM_PREFIX } from "../../../../css-tokens/dist/index.js";
|
|
4
|
-
import { entries as entries$1 } from "../../utils/entries.js";
|
|
5
4
|
import { assertUnreachable } from "../../utils/assertUnreachable.js";
|
|
5
|
+
import { entries as entries$1 } from "../../utils/entries.js";
|
|
6
6
|
import { isString } from "lodash-es";
|
|
7
7
|
|
|
8
8
|
//#region ../tailwind/dist/tailwind/components/getResponsiveTextStyles.js
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_assertUnreachable = require('../../utils/assertUnreachable.cjs');
|
|
3
4
|
const require_entries = require('../../utils/entries.cjs');
|
|
4
5
|
const require_mapValues = require('../../utils/mapValues.cjs');
|
|
5
|
-
const require_assertUnreachable = require('../../utils/assertUnreachable.cjs');
|
|
6
6
|
const require_composeTailwindPlugins = require('../utils/composeTailwindPlugins.cjs');
|
|
7
7
|
let tailwindcss_plugin_js = require("tailwindcss/plugin.js");
|
|
8
8
|
tailwindcss_plugin_js = require_runtime.__toESM(tailwindcss_plugin_js);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
import { assertUnreachable } from "../../utils/assertUnreachable.js";
|
|
2
3
|
import { entries } from "../../utils/entries.js";
|
|
3
4
|
import { mapValues } from "../../utils/mapValues.js";
|
|
4
|
-
import { assertUnreachable } from "../../utils/assertUnreachable.js";
|
|
5
5
|
import { shouldNotMergeTokensIntoTailwindTheme } from "../utils/composeTailwindPlugins.js";
|
|
6
6
|
import plugin from "tailwindcss/plugin.js";
|
|
7
7
|
|