@yahoo/uds 3.114.0 → 3.115.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.
Files changed (102) hide show
  1. package/dist/automated-config/dist/mapTextVariantFixtureToValue.cjs +12 -1
  2. package/dist/automated-config/dist/mapTextVariantFixtureToValue.js +12 -1
  3. package/dist/automated-config/dist/properties.cjs +1 -1
  4. package/dist/automated-config/dist/properties.js +1 -1
  5. package/dist/cli/commands/sync.cjs +1 -3
  6. package/dist/cli/commands/sync.d.cts +1 -1
  7. package/dist/cli/commands/sync.d.ts +1 -1
  8. package/dist/cli/commands/sync.js +1 -3
  9. package/dist/cli/commands/version.cjs +0 -2
  10. package/dist/cli/commands/version.d.cts +1 -1
  11. package/dist/cli/commands/version.d.ts +1 -1
  12. package/dist/cli/commands/version.js +0 -2
  13. package/dist/cli/dist/commands/editor-rules.cjs +1 -1
  14. package/dist/cli/dist/commands/editor-rules.js +1 -1
  15. package/dist/cli/dist/lib/logger.cjs +66 -0
  16. package/dist/cli/dist/lib/logger.js +66 -0
  17. package/dist/cli/runner.cjs +9 -0
  18. package/dist/cli/runner.js +9 -0
  19. package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
  20. package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
  21. package/dist/index.cjs +2 -0
  22. package/dist/index.d.cts +3 -1
  23. package/dist/index.d.ts +3 -1
  24. package/dist/index.js +2 -1
  25. package/dist/styles/styler.d.cts +29 -29
  26. package/dist/styles/styler.d.ts +29 -29
  27. package/dist/styles/variants.cjs +278 -278
  28. package/dist/styles/variants.js +278 -278
  29. package/dist/tailwind/dist/commands/css.cjs +79 -0
  30. package/dist/tailwind/dist/commands/css.helpers.cjs +32 -0
  31. package/dist/tailwind/dist/commands/css.helpers.js +28 -0
  32. package/dist/tailwind/dist/commands/css.js +79 -0
  33. package/dist/tailwind/dist/commands/generateComponentData.cjs +33 -31
  34. package/dist/tailwind/dist/commands/generateComponentData.d.ts +1 -1
  35. package/dist/tailwind/dist/commands/generateComponentData.js +33 -31
  36. package/dist/tailwind/dist/commands/purge.cjs +3 -4
  37. package/dist/tailwind/dist/commands/purge.js +3 -4
  38. package/dist/tailwind/dist/css/generate.cjs +121 -0
  39. package/dist/tailwind/dist/css/generate.d.cts +30 -0
  40. package/dist/tailwind/dist/css/generate.d.ts +31 -0
  41. package/dist/tailwind/dist/css/generate.helpers.cjs +112 -0
  42. package/dist/tailwind/dist/css/generate.helpers.js +100 -0
  43. package/dist/tailwind/dist/css/generate.js +116 -0
  44. package/dist/tailwind/dist/css/nodeUtils.cjs +156 -0
  45. package/dist/tailwind/dist/css/nodeUtils.js +149 -0
  46. package/dist/tailwind/dist/css/postcss.cjs +35 -0
  47. package/dist/tailwind/dist/css/postcss.helpers.cjs +27 -0
  48. package/dist/tailwind/dist/css/postcss.helpers.js +26 -0
  49. package/dist/tailwind/dist/css/postcss.js +35 -0
  50. package/dist/tailwind/dist/css/runner.cjs +279 -0
  51. package/dist/tailwind/dist/css/runner.helpers.cjs +26 -0
  52. package/dist/tailwind/dist/css/runner.helpers.js +23 -0
  53. package/dist/tailwind/dist/css/runner.js +276 -0
  54. package/dist/tailwind/dist/css/theme.cjs +12 -0
  55. package/dist/tailwind/dist/css/theme.d.cts +66 -0
  56. package/dist/tailwind/dist/css/theme.d.ts +66 -0
  57. package/dist/tailwind/dist/css/theme.js +11 -0
  58. package/dist/tailwind/dist/css/utils.cjs +72 -0
  59. package/dist/tailwind/dist/css/utils.js +69 -0
  60. package/dist/tailwind/dist/index.d.cts +1 -0
  61. package/dist/tailwind/dist/index.d.ts +2 -4
  62. package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +2 -1
  63. package/dist/tailwind/dist/purger/legacy/purgeCSS.js +2 -1
  64. package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +122 -125
  65. package/dist/tailwind/dist/purger/optimized/ast/expressions.js +122 -125
  66. package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +1 -8
  67. package/dist/tailwind/dist/purger/optimized/ast/jsx.js +1 -8
  68. package/dist/tailwind/dist/purger/optimized/purge.cjs +9 -8
  69. package/dist/tailwind/dist/purger/optimized/purge.js +9 -8
  70. package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +238 -127
  71. package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +238 -127
  72. package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +352 -260
  73. package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +351 -260
  74. package/dist/tailwind/dist/purger/optimized/utils/files.cjs +4 -3
  75. package/dist/tailwind/dist/purger/optimized/utils/files.js +4 -3
  76. package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +12 -20
  77. package/dist/tailwind/dist/purger/optimized/utils/safelist.js +12 -20
  78. package/dist/tailwind/dist/tailwind/components/getResponsiveTextStyles.cjs +1 -1
  79. package/dist/tailwind/dist/tailwind/components/getResponsiveTextStyles.js +1 -1
  80. package/dist/tailwind/dist/tailwind/plugins/breakpoints.cjs +1 -1
  81. package/dist/tailwind/dist/tailwind/plugins/breakpoints.js +1 -1
  82. package/dist/tailwind/dist/tailwind/plugins/typography.cjs +41 -13
  83. package/dist/tailwind/dist/tailwind/plugins/typography.js +41 -13
  84. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.cjs +4 -2
  85. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.cts +10 -1
  86. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.ts +10 -1
  87. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.js +4 -2
  88. package/dist/tailwind/dist/utils/optimizeCSS.cjs +405 -0
  89. package/dist/tailwind/dist/utils/optimizeCSS.js +403 -0
  90. package/dist/tailwind/dist/utils/postcssPreserveVars.cjs +67 -0
  91. package/dist/tailwind/dist/utils/postcssPreserveVars.js +65 -0
  92. package/dist/tailwind/dist/utils/tsMorph.cjs +1 -1
  93. package/dist/uds/generated/componentData.cjs +1218 -1182
  94. package/dist/uds/generated/componentData.js +1218 -1182
  95. package/dist/uds/package.cjs +10 -4
  96. package/dist/uds/package.js +10 -4
  97. package/generated/componentData.json +2683 -0
  98. package/generated/tailwindPurge.ts +4591 -0
  99. package/package.json +7 -4
  100. package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +0 -3
  101. package/dist/tailwind/dist/commands/purge.d.ts +0 -4
  102. package/dist/tailwind/dist/purger/legacy/purgeCSS.d.ts +0 -2
@@ -0,0 +1,276 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ import { defaultTokensConfig } from "../../../config/dist/index.js";
3
+ import { gray, green, magenta } from "../../../cli/dist/lib/colors.js";
4
+ import { print } from "../../../cli/dist/lib/print.js";
5
+ import { spinStart, spinStop } from "../../../cli/dist/lib/spinner.js";
6
+ import { createLogger } from "../../../cli/dist/lib/logger.js";
7
+ import { findPackageSourceDir, loadConfigFile, scanDirectoryForSafelist } from "./nodeUtils.js";
8
+ import { deduplicateSafelist, getThemeAndScaleClasses } from "../purger/optimized/utils/safelist.js";
9
+ import { extractVariantDefaults, formatBytes, getConfigurableCssVariables, getMotionVarPrefixes } from "./utils.js";
10
+ import { generateCSS, generateSimpleModeCSS } from "./generate.js";
11
+ import { getMainCssSummaryMessage, getWatchDirectoryGroups } from "./runner.helpers.js";
12
+ import path from "node:path";
13
+ import fs from "node:fs";
14
+
15
+ //#region ../tailwind/dist/css/runner.js
16
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
17
+ const DEFAULT_ENTRY = "./src";
18
+ const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/i;
19
+ const getWatchDirs = (dirs) => [...new Set(dirs.filter((dir) => !dir.split(path.sep).includes("node_modules")))];
20
+ const watchSourceFiles = (dirs, onFileChange) => {
21
+ dirs.forEach((dir) => {
22
+ fs.watch(dir, { recursive: true }, (_eventType, filename) => {
23
+ if (filename && SOURCE_FILE_PATTERN.test(filename)) onFileChange();
24
+ });
25
+ });
26
+ };
27
+ const createDebouncedAction = (action, delayMs) => {
28
+ let debounceTimer = null;
29
+ return () => {
30
+ if (debounceTimer) clearTimeout(debounceTimer);
31
+ debounceTimer = setTimeout(action, delayMs);
32
+ };
33
+ };
34
+ const createQueuedRegenerator = (options) => {
35
+ let isGenerating = false;
36
+ let pendingRegenerate = false;
37
+ const regenerate = async () => {
38
+ if (isGenerating) {
39
+ pendingRegenerate = true;
40
+ return;
41
+ }
42
+ isGenerating = true;
43
+ try {
44
+ options.onStart?.();
45
+ const result = await options.regenerateOnce();
46
+ options.onSuccess?.(result);
47
+ } catch (error) {
48
+ const message = error instanceof Error ? error.message : "CSS generation failed";
49
+ options.onError(message);
50
+ } finally {
51
+ isGenerating = false;
52
+ if (pendingRegenerate) {
53
+ pendingRegenerate = false;
54
+ await regenerate();
55
+ }
56
+ }
57
+ };
58
+ return regenerate;
59
+ };
60
+ const runCssCommand = async (options, context) => {
61
+ if (!fs.existsSync(path.join(options.workspaceDir, String(options.themeConfigPath)))) {
62
+ await runSimpleMode(options, context);
63
+ return;
64
+ }
65
+ await runThemeMode(options, context);
66
+ };
67
+ const runSimpleMode = async (options, context) => {
68
+ const entry = typeof options.entryOption === "string" ? options.entryOption : DEFAULT_ENTRY;
69
+ const configPath = typeof options.configOption === "string" ? options.configOption : void 0;
70
+ if (!options.watch && !options.silent) spinStart("Generating CSS...");
71
+ try {
72
+ const result = await generateSimpleModeCSS({
73
+ workspaceDir: options.workspaceDir,
74
+ entry,
75
+ outFile: String(options.outFile),
76
+ variants: context.variants,
77
+ autoVariants: context.autoVariants,
78
+ componentData: context.componentData,
79
+ scope: options.scope,
80
+ configPath,
81
+ isWatch: options.watch,
82
+ silent: options.silent
83
+ });
84
+ if (options.watch) await runSimpleModeWatch(options, context, entry, configPath, result.packageDirs ?? []);
85
+ } catch (error) {
86
+ spinStop("❌", error instanceof Error ? error.message : "CSS generation failed");
87
+ process.exitCode = 1;
88
+ }
89
+ };
90
+ const runSimpleModeWatch = async (options, context, entry, configPath, packageDirs) => {
91
+ const entryDir = path.join(options.workspaceDir, entry);
92
+ const watchDirs = getWatchDirs(packageDirs.length > 0 ? packageDirs : [entryDir]);
93
+ if (!options.silent) {
94
+ print("");
95
+ print(`${magenta("Watching for changes...")}`);
96
+ watchDirs.forEach((dir) => print(` ${gray("•")} ${dir}`));
97
+ print(`${gray("Press Ctrl+C to stop")}`);
98
+ print("");
99
+ }
100
+ const regenerate = createQueuedRegenerator({
101
+ onStart: () => {
102
+ if (!options.silent) print(`${gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`)} Change detected, regenerating...`);
103
+ },
104
+ regenerateOnce: async () => {
105
+ await generateSimpleModeCSS({
106
+ workspaceDir: options.workspaceDir,
107
+ entry,
108
+ outFile: String(options.outFile),
109
+ variants: context.variants,
110
+ autoVariants: context.autoVariants,
111
+ componentData: context.componentData,
112
+ scope: options.scope,
113
+ configPath,
114
+ isWatch: true,
115
+ silent: true
116
+ });
117
+ },
118
+ onSuccess: () => {
119
+ if (!options.silent) {
120
+ print(`${gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`)} ${green("CSS updated")}`);
121
+ print("");
122
+ }
123
+ },
124
+ onError: (message) => {
125
+ print(`Error: ${message}`);
126
+ }
127
+ });
128
+ watchSourceFiles(watchDirs, createDebouncedAction(() => {
129
+ regenerate();
130
+ }, 100));
131
+ await new Promise(() => {});
132
+ };
133
+ const loadThemeModeSetup = async (options) => {
134
+ const themeConfigInput = await loadConfigFile(String(options.themeConfigPath));
135
+ if (!themeConfigInput) return null;
136
+ const themeContext = {
137
+ cwd: options.workspaceDir,
138
+ watch: options.watch
139
+ };
140
+ const themeConfig = typeof themeConfigInput === "function" ? await themeConfigInput(themeContext) : themeConfigInput;
141
+ let appConfig = defaultTokensConfig;
142
+ if (themeConfig.config) {
143
+ const loadedConfig = await loadConfigFile(themeConfig.config);
144
+ if (loadedConfig) appConfig = loadedConfig;
145
+ }
146
+ return {
147
+ themeConfig,
148
+ colorModes: themeConfig.colorModes ?? ["dark"],
149
+ entry: themeConfig.entry ?? "/src/",
150
+ appConfig,
151
+ appVariantDefaults: extractVariantDefaults(appConfig),
152
+ effectiveSilent: options.silent || themeConfig.silent === true
153
+ };
154
+ };
155
+ const runThemeMode = async (options, context) => {
156
+ const workspaceDir = options.workspaceDir;
157
+ const outputPath = path.isAbsolute(options.outFile) ? options.outFile : path.join(workspaceDir, String(options.outFile));
158
+ let effectiveSilent = options.silent;
159
+ let log = createLogger({ silent: effectiveSilent });
160
+ log.spinStart("Loading theme configuration...");
161
+ try {
162
+ const setup = await loadThemeModeSetup(options);
163
+ if (!setup) {
164
+ log.spinStop("❌", `Theme config not found: ${options.themeConfigPath}`);
165
+ process.exitCode = 1;
166
+ return;
167
+ }
168
+ const { themeConfig, colorModes, entry, appConfig, appVariantDefaults } = setup;
169
+ effectiveSilent = setup.effectiveSilent;
170
+ log = createLogger({ silent: effectiveSilent });
171
+ if (!effectiveSilent) log.spinStop("✅", "Theme configuration loaded");
172
+ if (themeConfig.config && appConfig === defaultTokensConfig) log.warn(`App config not found: ${themeConfig.config}, using defaults`);
173
+ const packageDirs = [];
174
+ const generateThemeModeCSS = async (opts) => {
175
+ const genStartTime = performance.now();
176
+ const genLog = opts?.isWatch ? createLogger({ silent: true }) : log;
177
+ genLog.spinStart("Scanning app code...");
178
+ const appScanResult = await scanDirectoryForSafelist(path.join(workspaceDir, entry), colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults);
179
+ genLog.spinStop("✅", `Scanned ${appScanResult.filesScanned} files`);
180
+ genLog.spinStart("Generating main CSS...");
181
+ const inheritedClasses = [...appScanResult.safelist];
182
+ const inheritedComponents = new Set(appScanResult.components);
183
+ const processInheritedPackage = async (packageName) => {
184
+ genLog.spinStart(`Processing package: ${packageName}...`);
185
+ const packageDir = findPackageSourceDir(packageName);
186
+ if (!packageDir) {
187
+ genLog.spinStop("⚠️", `Package not found: ${packageName}`);
188
+ return;
189
+ }
190
+ if (!packageDirs.includes(packageDir)) packageDirs.push(packageDir);
191
+ const packageScanResult = await scanDirectoryForSafelist(packageDir, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, true);
192
+ inheritedClasses.push(...packageScanResult.safelist);
193
+ packageScanResult.components.forEach((comp) => inheritedComponents.add(comp));
194
+ genLog.spinStop("✅", `${packageName}: ${packageScanResult.filesScanned} files (inherit)`);
195
+ };
196
+ await (themeConfig.inherit ?? []).reduce(async (promise, packageName) => {
197
+ await promise;
198
+ await processInheritedPackage(packageName);
199
+ }, Promise.resolve());
200
+ const mainSafelist = deduplicateSafelist([...inheritedClasses, ...getThemeAndScaleClasses(colorModes)]);
201
+ const allMotionComponents = [...inheritedComponents];
202
+ const mainCssResult = await generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
203
+ scope: options.scope,
204
+ contentDir: path.join(workspaceDir, entry),
205
+ cssOptions: themeConfig.css,
206
+ safeVarPrefixes: [...getMotionVarPrefixes(context.componentData, allMotionComponents), ...getConfigurableCssVariables()]
207
+ });
208
+ const outputDir = path.dirname(outputPath);
209
+ if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
210
+ fs.writeFileSync(outputPath, mainCssResult.css);
211
+ genLog.spinStop("✅", getMainCssSummaryMessage({
212
+ sizeGzipBytes: mainCssResult.sizeGzipBytes,
213
+ optimizationStats: mainCssResult.optimizationStats,
214
+ formatBytes
215
+ }));
216
+ const duration = Math.round(performance.now() - genStartTime);
217
+ genLog.newline();
218
+ genLog.print(green("CSS generation complete!"));
219
+ genLog.newline();
220
+ genLog.label("Output file:", outputPath);
221
+ genLog.newline();
222
+ genLog.print(`${magenta("Total time:")} ${duration}ms`);
223
+ return {
224
+ duration,
225
+ outputPath,
226
+ packageDirs
227
+ };
228
+ };
229
+ await generateThemeModeCSS();
230
+ if (options.watch) {
231
+ const entryDir = path.join(workspaceDir, entry);
232
+ const { watchDirs, filteredPackageDirs } = getWatchDirectoryGroups(entryDir, [entryDir, ...packageDirs]);
233
+ if (!effectiveSilent) {
234
+ log.newline();
235
+ log.print(`${magenta("Watching for changes...")}`);
236
+ log.listItem(`App: ${entryDir}`);
237
+ filteredPackageDirs.forEach((dir) => {
238
+ log.listItem(`Package: ${dir}`);
239
+ });
240
+ log.print(`${gray("Press Ctrl+C to stop")}`);
241
+ log.newline();
242
+ }
243
+ const regenerate = createQueuedRegenerator({
244
+ onStart: () => {
245
+ if (!effectiveSilent) {
246
+ const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString();
247
+ log.print(`${gray(`[${timestamp}]`)} Change detected, regenerating...`);
248
+ }
249
+ },
250
+ regenerateOnce: async () => generateThemeModeCSS({ isWatch: true }),
251
+ onSuccess: (result) => {
252
+ if (!effectiveSilent) {
253
+ const updatedAt = (/* @__PURE__ */ new Date()).toLocaleTimeString();
254
+ log.print(`${gray(`[${updatedAt}]`)} ${green(`CSS updated (${result?.duration}ms)`)}`);
255
+ log.newline();
256
+ }
257
+ },
258
+ onError: (message) => {
259
+ log.print(message);
260
+ }
261
+ });
262
+ watchSourceFiles(watchDirs, createDebouncedAction(() => {
263
+ regenerate();
264
+ }, themeConfig.css?.watchDebounce ?? 100));
265
+ await new Promise(() => {});
266
+ }
267
+ } catch (error) {
268
+ const message = error instanceof Error ? error.message : "CSS generation failed";
269
+ if (effectiveSilent) spinStop("❌", message);
270
+ else log.spinStop("❌", message);
271
+ process.exitCode = 1;
272
+ }
273
+ };
274
+
275
+ //#endregion
276
+ export { runCssCommand };
@@ -0,0 +1,12 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+
3
+ //#region ../tailwind/dist/css/theme.js
4
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
5
+ /**
6
+ * Helper function to define theme configuration with full type support.
7
+ * Supports both static config objects and dynamic functions.
8
+ */
9
+ const defineTheme = (config) => config;
10
+
11
+ //#endregion
12
+ exports.defineTheme = defineTheme;
@@ -0,0 +1,66 @@
1
+
2
+ import { UDSCSSOptions } from "./generate.cjs";
3
+
4
+ //#region ../tailwind/dist/css/theme.d.ts
5
+ //#region src/css/theme.d.ts
6
+ /**
7
+ * Context passed to theme config function
8
+ */
9
+ interface UDSThemeContext {
10
+ /** Current working directory */
11
+ cwd: string;
12
+ /** Whether the CLI is running in watch mode */
13
+ watch?: boolean;
14
+ }
15
+ /**
16
+ * CSS optimization options for uds.theme.ts
17
+ */
18
+ interface UDSCSSOptimizationOptions {
19
+ /** Enable all CSS optimizations (default: true) */
20
+ enabled?: boolean;
21
+ /** Remove @font-face declarations for fonts not used in the CSS (default: false) */
22
+ removeUnusedFonts?: boolean;
23
+ /** Remove empty CSS rules (default: true) */
24
+ removeEmptyRules?: boolean;
25
+ /** Aggregate duplicate selectors (default: true) */
26
+ aggregateDuplicateSelectors?: boolean;
27
+ /**
28
+ * Remove duplicate content from scoped CSS that already exists in main CSS (default: true)
29
+ * Currently deduplicates @font-face declarations. Reduces bundle size when scoped packages
30
+ * share fonts with the main app.
31
+ */
32
+ deduplicateScopedCss?: boolean;
33
+ /** Prune unused CSS variables (default: true) */
34
+ pruneVars?: boolean;
35
+ }
36
+ /**
37
+ * Theme configuration structure for uds.theme.ts
38
+ */
39
+ interface UDSThemeConfig {
40
+ /** Path to app's uds.config (relative to project root) */
41
+ config?: string;
42
+ /** Entry directory for app code scanning (default: '/src/') */
43
+ entry?: string;
44
+ /** Suppress log output during generation (default: false) */
45
+ silent?: boolean;
46
+ /**
47
+ * Packages that inherit the app's theme configuration.
48
+ * These packages' styles are merged into the main uds.css file.
49
+ */
50
+ inherit?: string[];
51
+ /** Color modes to include (default: ['dark']) - light mode is always in :root */
52
+ colorModes?: ('dark' | 'light')[];
53
+ /** CSS generation options */
54
+ css?: UDSCSSOptions;
55
+ }
56
+ /**
57
+ * Theme config can be an object or a function that receives context
58
+ */
59
+ type UDSThemeConfigInput = UDSThemeConfig | ((ctx: UDSThemeContext) => UDSThemeConfig | Promise<UDSThemeConfig>);
60
+ /**
61
+ * Helper function to define theme configuration with full type support.
62
+ * Supports both static config objects and dynamic functions.
63
+ */
64
+ declare const defineTheme: (config: UDSThemeConfigInput) => UDSThemeConfigInput; //#endregion
65
+ //#endregion
66
+ export { type UDSCSSOptimizationOptions, defineTheme };
@@ -0,0 +1,66 @@
1
+
2
+ import { UDSCSSOptions } from "./generate.js";
3
+
4
+ //#region ../tailwind/dist/css/theme.d.ts
5
+ //#region src/css/theme.d.ts
6
+ /**
7
+ * Context passed to theme config function
8
+ */
9
+ interface UDSThemeContext {
10
+ /** Current working directory */
11
+ cwd: string;
12
+ /** Whether the CLI is running in watch mode */
13
+ watch?: boolean;
14
+ }
15
+ /**
16
+ * CSS optimization options for uds.theme.ts
17
+ */
18
+ interface UDSCSSOptimizationOptions {
19
+ /** Enable all CSS optimizations (default: true) */
20
+ enabled?: boolean;
21
+ /** Remove @font-face declarations for fonts not used in the CSS (default: false) */
22
+ removeUnusedFonts?: boolean;
23
+ /** Remove empty CSS rules (default: true) */
24
+ removeEmptyRules?: boolean;
25
+ /** Aggregate duplicate selectors (default: true) */
26
+ aggregateDuplicateSelectors?: boolean;
27
+ /**
28
+ * Remove duplicate content from scoped CSS that already exists in main CSS (default: true)
29
+ * Currently deduplicates @font-face declarations. Reduces bundle size when scoped packages
30
+ * share fonts with the main app.
31
+ */
32
+ deduplicateScopedCss?: boolean;
33
+ /** Prune unused CSS variables (default: true) */
34
+ pruneVars?: boolean;
35
+ }
36
+ /**
37
+ * Theme configuration structure for uds.theme.ts
38
+ */
39
+ interface UDSThemeConfig {
40
+ /** Path to app's uds.config (relative to project root) */
41
+ config?: string;
42
+ /** Entry directory for app code scanning (default: '/src/') */
43
+ entry?: string;
44
+ /** Suppress log output during generation (default: false) */
45
+ silent?: boolean;
46
+ /**
47
+ * Packages that inherit the app's theme configuration.
48
+ * These packages' styles are merged into the main uds.css file.
49
+ */
50
+ inherit?: string[];
51
+ /** Color modes to include (default: ['dark']) - light mode is always in :root */
52
+ colorModes?: ('dark' | 'light')[];
53
+ /** CSS generation options */
54
+ css?: UDSCSSOptions;
55
+ }
56
+ /**
57
+ * Theme config can be an object or a function that receives context
58
+ */
59
+ type UDSThemeConfigInput = UDSThemeConfig | ((ctx: UDSThemeContext) => UDSThemeConfig | Promise<UDSThemeConfig>);
60
+ /**
61
+ * Helper function to define theme configuration with full type support.
62
+ * Supports both static config objects and dynamic functions.
63
+ */
64
+ declare const defineTheme: (config: UDSThemeConfigInput) => UDSThemeConfigInput; //#endregion
65
+ //#endregion
66
+ export { type UDSCSSOptimizationOptions, defineTheme };
@@ -0,0 +1,11 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ //#region ../tailwind/dist/css/theme.js
3
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
4
+ /**
5
+ * Helper function to define theme configuration with full type support.
6
+ * Supports both static config objects and dynamic functions.
7
+ */
8
+ const defineTheme = (config) => config;
9
+
10
+ //#endregion
11
+ export { defineTheme };
@@ -0,0 +1,72 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ const require_properties = require('../../../automated-config/dist/properties.cjs');
3
+
4
+ //#region ../tailwind/dist/css/utils.js
5
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
6
+ /**
7
+ * Extract variant defaults from a UniversalTokensConfig.
8
+ * Converts from config structure to a simpler lookup format.
9
+ * e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
10
+ */
11
+ const extractVariantDefaults = (config) => {
12
+ const componentNameMap = {
13
+ avatar: "Avatar",
14
+ badge: "Badge",
15
+ button: "Button",
16
+ checkbox: "Checkbox",
17
+ chip: "Chip",
18
+ divider: "Divider",
19
+ iconButton: "IconButton",
20
+ input: "Input",
21
+ link: "Link",
22
+ menu: "Menu",
23
+ radio: "Radio",
24
+ switch: "Switch"
25
+ };
26
+ return Object.entries(config).reduce((acc, [configKey, componentConfig]) => {
27
+ const pascalName = componentNameMap[configKey];
28
+ if (!pascalName || !componentConfig || typeof componentConfig !== "object") return acc;
29
+ const configWithDefaults = componentConfig;
30
+ return configWithDefaults.defaults ? {
31
+ ...acc,
32
+ [pascalName]: configWithDefaults.defaults
33
+ } : acc;
34
+ }, {});
35
+ };
36
+ /**
37
+ * Format bytes to human readable string
38
+ */
39
+ const formatBytes = (bytes) => {
40
+ if (bytes < 1024) return `${bytes} B`;
41
+ const kb = bytes / 1024;
42
+ if (kb < 1024) return `${kb.toFixed(1)} KB`;
43
+ return `${(kb / 1024).toFixed(2)} MB`;
44
+ };
45
+ /**
46
+ * Get motion CSS variable prefixes needed by a set of components.
47
+ * Looks up motionVarPrefixes from componentData.json for each component.
48
+ */
49
+ const getMotionVarPrefixes = (componentData, components) => {
50
+ const prefixes = components.flatMap((componentName) => {
51
+ return componentData[componentName]?.motionVarPrefixes ?? [];
52
+ });
53
+ return [...new Set(prefixes)];
54
+ };
55
+ /**
56
+ * Collect css variable names exposed by configurable properties.
57
+ */
58
+ const getConfigurableCssVariables = () => {
59
+ const udsVarPrefix = "--uds";
60
+ const cssVars = Object.values(require_properties.configurableProperties).flatMap(({ cssProperties }) => {
61
+ if (typeof cssProperties === "string") return cssProperties.startsWith(udsVarPrefix) ? [cssProperties] : [];
62
+ if (Array.isArray(cssProperties)) return cssProperties.filter((cssProperty) => typeof cssProperty === "string" && cssProperty.startsWith(udsVarPrefix));
63
+ return [];
64
+ });
65
+ return [...new Set(["--uds-button-gap", ...cssVars])];
66
+ };
67
+
68
+ //#endregion
69
+ exports.extractVariantDefaults = extractVariantDefaults;
70
+ exports.formatBytes = formatBytes;
71
+ exports.getConfigurableCssVariables = getConfigurableCssVariables;
72
+ exports.getMotionVarPrefixes = getMotionVarPrefixes;
@@ -0,0 +1,69 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ import { configurableProperties } from "../../../automated-config/dist/properties.js";
3
+
4
+ //#region ../tailwind/dist/css/utils.js
5
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
6
+ /**
7
+ * Extract variant defaults from a UniversalTokensConfig.
8
+ * Converts from config structure to a simpler lookup format.
9
+ * e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
10
+ */
11
+ const extractVariantDefaults = (config) => {
12
+ const componentNameMap = {
13
+ avatar: "Avatar",
14
+ badge: "Badge",
15
+ button: "Button",
16
+ checkbox: "Checkbox",
17
+ chip: "Chip",
18
+ divider: "Divider",
19
+ iconButton: "IconButton",
20
+ input: "Input",
21
+ link: "Link",
22
+ menu: "Menu",
23
+ radio: "Radio",
24
+ switch: "Switch"
25
+ };
26
+ return Object.entries(config).reduce((acc, [configKey, componentConfig]) => {
27
+ const pascalName = componentNameMap[configKey];
28
+ if (!pascalName || !componentConfig || typeof componentConfig !== "object") return acc;
29
+ const configWithDefaults = componentConfig;
30
+ return configWithDefaults.defaults ? {
31
+ ...acc,
32
+ [pascalName]: configWithDefaults.defaults
33
+ } : acc;
34
+ }, {});
35
+ };
36
+ /**
37
+ * Format bytes to human readable string
38
+ */
39
+ const formatBytes = (bytes) => {
40
+ if (bytes < 1024) return `${bytes} B`;
41
+ const kb = bytes / 1024;
42
+ if (kb < 1024) return `${kb.toFixed(1)} KB`;
43
+ return `${(kb / 1024).toFixed(2)} MB`;
44
+ };
45
+ /**
46
+ * Get motion CSS variable prefixes needed by a set of components.
47
+ * Looks up motionVarPrefixes from componentData.json for each component.
48
+ */
49
+ const getMotionVarPrefixes = (componentData, components) => {
50
+ const prefixes = components.flatMap((componentName) => {
51
+ return componentData[componentName]?.motionVarPrefixes ?? [];
52
+ });
53
+ return [...new Set(prefixes)];
54
+ };
55
+ /**
56
+ * Collect css variable names exposed by configurable properties.
57
+ */
58
+ const getConfigurableCssVariables = () => {
59
+ const udsVarPrefix = "--uds";
60
+ const cssVars = Object.values(configurableProperties).flatMap(({ cssProperties }) => {
61
+ if (typeof cssProperties === "string") return cssProperties.startsWith(udsVarPrefix) ? [cssProperties] : [];
62
+ if (Array.isArray(cssProperties)) return cssProperties.filter((cssProperty) => typeof cssProperty === "string" && cssProperty.startsWith(udsVarPrefix));
63
+ return [];
64
+ });
65
+ return [...new Set(["--uds-button-gap", ...cssVars])];
66
+ };
67
+
68
+ //#endregion
69
+ export { extractVariantDefaults, formatBytes, getConfigurableCssVariables, getMotionVarPrefixes };
@@ -1,3 +1,4 @@
1
1
 
2
+ import { defineTheme } from "./css/theme.cjs";
2
3
  import "./tailwind/components/getResponsiveTextStyles.cjs";
3
4
  import { WebTokens, parseTokens } from "./utils/parseTokens.cjs";
@@ -1,6 +1,4 @@
1
1
 
2
+ import { defineTheme } from "./css/theme.js";
2
3
  import "./tailwind/components/getResponsiveTextStyles.js";
3
- import { WebTokens, parseTokens } from "./utils/parseTokens.js";
4
- import "./commands/generateComponentData.js";
5
- import "./commands/generatePurgeCSSData.js";
6
- import "./commands/purge.js";
4
+ import { WebTokens, parseTokens } from "./utils/parseTokens.js";
@@ -32,7 +32,8 @@ const getFiles = async (entry) => {
32
32
  if (!workspaceDir) throw new Error("Workspace directory not found.");
33
33
  return await (0, fast_glob.default)(["**/*.jsx", "**/*.tsx"], {
34
34
  cwd: node_path.default.join(workspaceDir, entry),
35
- absolute: true
35
+ absolute: true,
36
+ ignore: ["**/node_modules/**"]
36
37
  });
37
38
  } catch {
38
39
  throw new Error(`Couldn't find the entry directory: ${entry}. Please make sure it exists.`);
@@ -29,7 +29,8 @@ const getFiles = async (entry) => {
29
29
  if (!workspaceDir) throw new Error("Workspace directory not found.");
30
30
  return await fg(["**/*.jsx", "**/*.tsx"], {
31
31
  cwd: path.join(workspaceDir, entry),
32
- absolute: true
32
+ absolute: true,
33
+ ignore: ["**/node_modules/**"]
33
34
  });
34
35
  } catch {
35
36
  throw new Error(`Couldn't find the entry directory: ${entry}. Please make sure it exists.`);