@yahoo/uds 3.114.0-beta.2 → 3.114.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/automated-config/dist/generated/autoVariants.cjs +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.js +3 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1883 -0
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.js +1882 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +84 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +84 -0
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.cjs +1 -12
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.js +1 -12
- package/dist/automated-config/dist/properties.cjs +58 -12
- package/dist/automated-config/dist/properties.d.cts +8 -0
- package/dist/automated-config/dist/properties.d.ts +8 -0
- package/dist/automated-config/dist/properties.js +58 -12
- 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 +7 -1
- package/dist/cli/commands/sync.d.cts +1 -1
- package/dist/cli/commands/sync.d.ts +1 -1
- package/dist/cli/commands/sync.js +7 -1
- package/dist/cli/commands/version.cjs +2 -0
- package/dist/cli/commands/version.d.cts +1 -1
- package/dist/cli/commands/version.d.ts +1 -1
- package/dist/cli/commands/version.js +2 -0
- 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/utils/rules/config.cjs +1 -1
- package/dist/cli/dist/utils/rules/config.js +1 -1
- package/dist/cli/runner.cjs +2 -11
- package/dist/cli/runner.js +2 -11
- package/dist/components/Scrim.cjs +28 -0
- package/dist/components/Scrim.d.cts +14 -0
- package/dist/components/Scrim.d.ts +14 -0
- package/dist/components/Scrim.js +26 -0
- package/dist/components/client/BottomSheet/BottomSheet.cjs +209 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.cts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.ts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.js +207 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.cjs +26 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.cts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.ts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.js +24 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.js +13 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.cjs +30 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.js +28 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.cjs +42 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.cts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.ts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.js +40 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.cjs +21 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.js +19 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.js +13 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.cjs +32 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.cts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.ts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.js +29 -0
- package/dist/components/client/BottomSheet/index.cjs +22 -0
- package/dist/components/client/BottomSheet/index.d.cts +10 -0
- package/dist/components/client/BottomSheet/index.d.ts +10 -0
- package/dist/components/client/BottomSheet/index.js +12 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.cjs +188 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.cts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.ts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.js +185 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.cjs +138 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.cts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.ts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.js +135 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.cjs +34 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.cts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.ts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.js +31 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.cjs +17 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.cts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.js +15 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.cjs +89 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.cts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.ts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.js +87 -0
- package/dist/components/client/BottomSheet/useViewportHeight.cjs +32 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.cts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.ts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.js +30 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.cjs +48 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.cts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.ts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.js +46 -0
- package/dist/components/client/BottomSheet/utils.cjs +128 -0
- package/dist/components/client/BottomSheet/utils.d.cts +61 -0
- package/dist/components/client/BottomSheet/utils.d.ts +61 -0
- package/dist/components/client/BottomSheet/utils.js +118 -0
- package/dist/components/client/Menu/Menu.Content.cjs +1 -1
- package/dist/components/client/Menu/Menu.Content.js +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/components/client/Menu/Menu.index.d.cts +1 -1
- package/dist/components/client/index.cjs +16 -0
- package/dist/components/client/index.d.cts +10 -1
- package/dist/components/client/index.d.ts +10 -1
- package/dist/components/client/index.js +9 -1
- package/dist/components/client/providers/UDSConfigProvider.cjs +10 -6
- package/dist/components/client/providers/UDSConfigProvider.d.cts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.d.ts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.js +10 -6
- package/dist/components/index.cjs +24 -0
- package/dist/components/index.d.cts +9 -1
- package/dist/components/index.d.ts +9 -1
- package/dist/components/index.js +17 -1
- package/dist/config/dist/index.cjs +110 -2
- package/dist/config/dist/index.js +110 -2
- package/dist/fixtures/dist/index.cjs +103 -0
- package/dist/fixtures/dist/index.d.cts +3 -2
- package/dist/fixtures/dist/index.d.ts +3 -2
- package/dist/fixtures/dist/index.js +103 -1
- package/dist/fixtures/index.cjs +1 -0
- package/dist/fixtures/index.d.cts +2 -2
- package/dist/fixtures/index.d.ts +2 -2
- package/dist/fixtures/index.js +2 -2
- package/dist/index.cjs +20 -2
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +11 -3
- package/dist/runtime/bottomSheetConfig.cjs +11 -0
- package/dist/runtime/bottomSheetConfig.d.cts +15 -0
- package/dist/runtime/bottomSheetConfig.d.ts +15 -0
- package/dist/runtime/bottomSheetConfig.js +9 -0
- package/dist/runtime/index.cjs +2 -0
- package/dist/runtime/index.d.cts +2 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/udsConfig.cjs +2 -0
- package/dist/runtime/udsConfig.d.cts +2 -0
- package/dist/runtime/udsConfig.d.ts +2 -0
- package/dist/runtime/udsConfig.js +2 -0
- package/dist/styles/styler.d.cts +33 -30
- package/dist/styles/styler.d.ts +33 -30
- package/dist/styles/variants.cjs +278 -278
- package/dist/styles/variants.d.cts +9 -0
- package/dist/styles/variants.d.ts +9 -0
- package/dist/styles/variants.js +278 -278
- package/dist/tailwind/dist/commands/generateComponentData.cjs +31 -33
- package/dist/tailwind/dist/commands/generateComponentData.d.ts +1 -1
- package/dist/tailwind/dist/commands/generateComponentData.js +31 -33
- package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.cjs +4 -3
- package/dist/tailwind/dist/commands/purge.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.js +4 -3
- package/dist/tailwind/dist/index.d.cts +0 -1
- package/dist/tailwind/dist/index.d.ts +3 -5
- package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +3 -4
- package/dist/tailwind/dist/purger/legacy/purgeCSS.js +3 -4
- package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +125 -122
- package/dist/tailwind/dist/purger/optimized/ast/expressions.js +125 -122
- package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +8 -1
- package/dist/tailwind/dist/purger/optimized/ast/jsx.js +8 -1
- package/dist/tailwind/dist/purger/optimized/purge.cjs +10 -11
- package/dist/tailwind/dist/purger/optimized/purge.js +9 -10
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +127 -232
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +127 -232
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +262 -330
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +262 -329
- package/dist/tailwind/dist/purger/optimized/utils/files.cjs +3 -4
- package/dist/tailwind/dist/purger/optimized/utils/files.js +3 -4
- package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +21 -13
- package/dist/tailwind/dist/purger/optimized/utils/safelist.js +21 -13
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +2 -0
- package/dist/tailwind/dist/tailwind/plugins/components.js +3 -1
- package/dist/tailwind/dist/tailwind/plugins/typography.cjs +13 -41
- package/dist/tailwind/dist/tailwind/plugins/typography.js +13 -41
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.cjs +2 -4
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.cts +1 -10
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.ts +1 -10
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.js +2 -4
- package/dist/tailwind/dist/utils/tsMorph.cjs +1 -1
- package/dist/tokens/automation/configs/index.cjs +2 -0
- package/dist/tokens/automation/configs/index.d.cts +2 -2
- package/dist/tokens/automation/configs/index.d.ts +2 -2
- package/dist/tokens/automation/configs/index.js +2 -2
- package/dist/tokens/automation/index.cjs +2 -0
- package/dist/tokens/automation/index.d.cts +2 -2
- package/dist/tokens/automation/index.d.ts +2 -2
- package/dist/tokens/automation/index.js +2 -2
- package/dist/tokens/index.cjs +2 -0
- package/dist/tokens/index.d.cts +3 -3
- package/dist/tokens/index.d.ts +3 -3
- package/dist/tokens/index.js +2 -2
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +76 -1
- package/dist/types/dist/index.d.ts +76 -1
- package/dist/uds/generated/componentData.cjs +1187 -961
- package/dist/uds/generated/componentData.js +1111 -939
- package/dist/uds/generated/tailwindPurge.cjs +57 -29
- package/dist/uds/generated/tailwindPurge.js +57 -29
- package/dist/uds/package.cjs +4 -10
- package/dist/uds/package.js +4 -10
- package/package.json +4 -7
- package/dist/cli/dist/lib/logger.cjs +0 -66
- package/dist/cli/dist/lib/logger.js +0 -66
- package/dist/tailwind/dist/commands/css.cjs +0 -79
- package/dist/tailwind/dist/commands/css.d.ts +0 -3
- package/dist/tailwind/dist/commands/css.helpers.cjs +0 -32
- package/dist/tailwind/dist/commands/css.helpers.js +0 -28
- package/dist/tailwind/dist/commands/css.js +0 -79
- package/dist/tailwind/dist/css/generate.cjs +0 -120
- package/dist/tailwind/dist/css/generate.d.cts +0 -30
- package/dist/tailwind/dist/css/generate.d.ts +0 -31
- package/dist/tailwind/dist/css/generate.helpers.cjs +0 -112
- package/dist/tailwind/dist/css/generate.helpers.js +0 -100
- package/dist/tailwind/dist/css/generate.js +0 -115
- package/dist/tailwind/dist/css/postcss.cjs +0 -35
- package/dist/tailwind/dist/css/postcss.helpers.cjs +0 -27
- package/dist/tailwind/dist/css/postcss.helpers.js +0 -26
- package/dist/tailwind/dist/css/postcss.js +0 -35
- package/dist/tailwind/dist/css/runner.cjs +0 -278
- package/dist/tailwind/dist/css/runner.helpers.cjs +0 -26
- package/dist/tailwind/dist/css/runner.helpers.js +0 -23
- package/dist/tailwind/dist/css/runner.js +0 -275
- package/dist/tailwind/dist/css/theme.cjs +0 -12
- package/dist/tailwind/dist/css/theme.d.cts +0 -66
- package/dist/tailwind/dist/css/theme.d.ts +0 -66
- package/dist/tailwind/dist/css/theme.js +0 -11
- package/dist/tailwind/dist/css/utils.cjs +0 -234
- package/dist/tailwind/dist/css/utils.js +0 -223
- package/dist/tailwind/dist/utils/optimizeCSS.cjs +0 -405
- package/dist/tailwind/dist/utils/optimizeCSS.js +0 -403
- package/dist/tailwind/dist/utils/postcssPreserveVars.cjs +0 -67
- package/dist/tailwind/dist/utils/postcssPreserveVars.js +0 -65
- package/generated/componentData.json +0 -2397
- package/generated/tailwindPurge.ts +0 -4560
|
@@ -1,275 +0,0 @@
|
|
|
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 { extractVariantDefaults, findPackageSourceDir, formatBytes, getConfigurableCssVariables, getMotionVarPrefixes, loadConfigFile, scanDirectoryForSafelist } from "./utils.js";
|
|
8
|
-
import { deduplicateSafelist, getThemeAndScaleClasses } from "../purger/optimized/utils/safelist.js";
|
|
9
|
-
import { generateCSS, generateSimpleModeCSS } from "./generate.js";
|
|
10
|
-
import { getMainCssSummaryMessage, getWatchDirectoryGroups } from "./runner.helpers.js";
|
|
11
|
-
import fs from "node:fs";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
|
|
14
|
-
//#region ../tailwind/dist/css/runner.js
|
|
15
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
16
|
-
const DEFAULT_ENTRY = "./src";
|
|
17
|
-
const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/i;
|
|
18
|
-
const getWatchDirs = (dirs) => [...new Set(dirs.filter((dir) => !dir.split(path.sep).includes("node_modules")))];
|
|
19
|
-
const watchSourceFiles = (dirs, onFileChange) => {
|
|
20
|
-
dirs.forEach((dir) => {
|
|
21
|
-
fs.watch(dir, { recursive: true }, (_eventType, filename) => {
|
|
22
|
-
if (filename && SOURCE_FILE_PATTERN.test(filename)) onFileChange();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
const createDebouncedAction = (action, delayMs) => {
|
|
27
|
-
let debounceTimer = null;
|
|
28
|
-
return () => {
|
|
29
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
30
|
-
debounceTimer = setTimeout(action, delayMs);
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const createQueuedRegenerator = (options) => {
|
|
34
|
-
let isGenerating = false;
|
|
35
|
-
let pendingRegenerate = false;
|
|
36
|
-
const regenerate = async () => {
|
|
37
|
-
if (isGenerating) {
|
|
38
|
-
pendingRegenerate = true;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
isGenerating = true;
|
|
42
|
-
try {
|
|
43
|
-
options.onStart?.();
|
|
44
|
-
const result = await options.regenerateOnce();
|
|
45
|
-
options.onSuccess?.(result);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
const message = error instanceof Error ? error.message : "CSS generation failed";
|
|
48
|
-
options.onError(message);
|
|
49
|
-
} finally {
|
|
50
|
-
isGenerating = false;
|
|
51
|
-
if (pendingRegenerate) {
|
|
52
|
-
pendingRegenerate = false;
|
|
53
|
-
await regenerate();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
return regenerate;
|
|
58
|
-
};
|
|
59
|
-
const runCssCommand = async (options, context) => {
|
|
60
|
-
if (!fs.existsSync(path.join(options.workspaceDir, String(options.themeConfigPath)))) {
|
|
61
|
-
await runSimpleMode(options, context);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
await runThemeMode(options, context);
|
|
65
|
-
};
|
|
66
|
-
const runSimpleMode = async (options, context) => {
|
|
67
|
-
const entry = typeof options.entryOption === "string" ? options.entryOption : DEFAULT_ENTRY;
|
|
68
|
-
const configPath = typeof options.configOption === "string" ? options.configOption : void 0;
|
|
69
|
-
if (!options.watch && !options.silent) spinStart("Generating CSS...");
|
|
70
|
-
try {
|
|
71
|
-
const result = await generateSimpleModeCSS({
|
|
72
|
-
workspaceDir: options.workspaceDir,
|
|
73
|
-
entry,
|
|
74
|
-
outFile: String(options.outFile),
|
|
75
|
-
variants: context.variants,
|
|
76
|
-
autoVariants: context.autoVariants,
|
|
77
|
-
componentData: context.componentData,
|
|
78
|
-
scope: options.scope,
|
|
79
|
-
configPath,
|
|
80
|
-
isWatch: options.watch,
|
|
81
|
-
silent: options.silent
|
|
82
|
-
});
|
|
83
|
-
if (options.watch) await runSimpleModeWatch(options, context, entry, configPath, result.packageDirs ?? []);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
spinStop("❌", error instanceof Error ? error.message : "CSS generation failed");
|
|
86
|
-
process.exitCode = 1;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const runSimpleModeWatch = async (options, context, entry, configPath, packageDirs) => {
|
|
90
|
-
const entryDir = path.join(options.workspaceDir, entry);
|
|
91
|
-
const watchDirs = getWatchDirs(packageDirs.length > 0 ? packageDirs : [entryDir]);
|
|
92
|
-
if (!options.silent) {
|
|
93
|
-
print("");
|
|
94
|
-
print(`${magenta("Watching for changes...")}`);
|
|
95
|
-
watchDirs.forEach((dir) => print(` ${gray("•")} ${dir}`));
|
|
96
|
-
print(`${gray("Press Ctrl+C to stop")}`);
|
|
97
|
-
print("");
|
|
98
|
-
}
|
|
99
|
-
const regenerate = createQueuedRegenerator({
|
|
100
|
-
onStart: () => {
|
|
101
|
-
if (!options.silent) print(`${gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`)} Change detected, regenerating...`);
|
|
102
|
-
},
|
|
103
|
-
regenerateOnce: async () => {
|
|
104
|
-
await generateSimpleModeCSS({
|
|
105
|
-
workspaceDir: options.workspaceDir,
|
|
106
|
-
entry,
|
|
107
|
-
outFile: String(options.outFile),
|
|
108
|
-
variants: context.variants,
|
|
109
|
-
autoVariants: context.autoVariants,
|
|
110
|
-
componentData: context.componentData,
|
|
111
|
-
scope: options.scope,
|
|
112
|
-
configPath,
|
|
113
|
-
isWatch: true,
|
|
114
|
-
silent: true
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
onSuccess: () => {
|
|
118
|
-
if (!options.silent) {
|
|
119
|
-
print(`${gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`)} ${green("CSS updated")}`);
|
|
120
|
-
print("");
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
onError: (message) => {
|
|
124
|
-
print(`Error: ${message}`);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
watchSourceFiles(watchDirs, createDebouncedAction(() => {
|
|
128
|
-
regenerate();
|
|
129
|
-
}, 100));
|
|
130
|
-
await new Promise(() => {});
|
|
131
|
-
};
|
|
132
|
-
const loadThemeModeSetup = async (options) => {
|
|
133
|
-
const themeConfigInput = await loadConfigFile(String(options.themeConfigPath));
|
|
134
|
-
if (!themeConfigInput) return null;
|
|
135
|
-
const themeContext = {
|
|
136
|
-
cwd: options.workspaceDir,
|
|
137
|
-
watch: options.watch
|
|
138
|
-
};
|
|
139
|
-
const themeConfig = typeof themeConfigInput === "function" ? await themeConfigInput(themeContext) : themeConfigInput;
|
|
140
|
-
let appConfig = defaultTokensConfig;
|
|
141
|
-
if (themeConfig.config) {
|
|
142
|
-
const loadedConfig = await loadConfigFile(themeConfig.config);
|
|
143
|
-
if (loadedConfig) appConfig = loadedConfig;
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
themeConfig,
|
|
147
|
-
colorModes: themeConfig.colorModes ?? ["dark"],
|
|
148
|
-
entry: themeConfig.entry ?? "/src/",
|
|
149
|
-
appConfig,
|
|
150
|
-
appVariantDefaults: extractVariantDefaults(appConfig),
|
|
151
|
-
effectiveSilent: options.silent || themeConfig.silent === true
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
const runThemeMode = async (options, context) => {
|
|
155
|
-
const workspaceDir = options.workspaceDir;
|
|
156
|
-
const outputPath = path.isAbsolute(options.outFile) ? options.outFile : path.join(workspaceDir, String(options.outFile));
|
|
157
|
-
let effectiveSilent = options.silent;
|
|
158
|
-
let log = createLogger({ silent: effectiveSilent });
|
|
159
|
-
log.spinStart("Loading theme configuration...");
|
|
160
|
-
try {
|
|
161
|
-
const setup = await loadThemeModeSetup(options);
|
|
162
|
-
if (!setup) {
|
|
163
|
-
log.spinStop("❌", `Theme config not found: ${options.themeConfigPath}`);
|
|
164
|
-
process.exitCode = 1;
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const { themeConfig, colorModes, entry, appConfig, appVariantDefaults } = setup;
|
|
168
|
-
effectiveSilent = setup.effectiveSilent;
|
|
169
|
-
log = createLogger({ silent: effectiveSilent });
|
|
170
|
-
if (!effectiveSilent) log.spinStop("✅", "Theme configuration loaded");
|
|
171
|
-
if (themeConfig.config && appConfig === defaultTokensConfig) log.warn(`App config not found: ${themeConfig.config}, using defaults`);
|
|
172
|
-
const packageDirs = [];
|
|
173
|
-
const generateThemeModeCSS = async (opts) => {
|
|
174
|
-
const genStartTime = performance.now();
|
|
175
|
-
const genLog = opts?.isWatch ? createLogger({ silent: true }) : log;
|
|
176
|
-
genLog.spinStart("Scanning app code...");
|
|
177
|
-
const appScanResult = await scanDirectoryForSafelist(path.join(workspaceDir, entry), colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults);
|
|
178
|
-
genLog.spinStop("✅", `Scanned ${appScanResult.filesScanned} files`);
|
|
179
|
-
genLog.spinStart("Generating main CSS...");
|
|
180
|
-
const inheritedClasses = [...appScanResult.safelist];
|
|
181
|
-
const inheritedComponents = new Set(appScanResult.components);
|
|
182
|
-
const processInheritedPackage = async (packageName) => {
|
|
183
|
-
genLog.spinStart(`Processing package: ${packageName}...`);
|
|
184
|
-
const packageDir = findPackageSourceDir(packageName);
|
|
185
|
-
if (!packageDir) {
|
|
186
|
-
genLog.spinStop("⚠️", `Package not found: ${packageName}`);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (!packageDirs.includes(packageDir)) packageDirs.push(packageDir);
|
|
190
|
-
const packageScanResult = await scanDirectoryForSafelist(packageDir, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, true);
|
|
191
|
-
inheritedClasses.push(...packageScanResult.safelist);
|
|
192
|
-
packageScanResult.components.forEach((comp) => inheritedComponents.add(comp));
|
|
193
|
-
genLog.spinStop("✅", `${packageName}: ${packageScanResult.filesScanned} files (inherit)`);
|
|
194
|
-
};
|
|
195
|
-
await (themeConfig.inherit ?? []).reduce(async (promise, packageName) => {
|
|
196
|
-
await promise;
|
|
197
|
-
await processInheritedPackage(packageName);
|
|
198
|
-
}, Promise.resolve());
|
|
199
|
-
const mainSafelist = deduplicateSafelist([...inheritedClasses, ...getThemeAndScaleClasses(colorModes)]);
|
|
200
|
-
const allMotionComponents = [...inheritedComponents];
|
|
201
|
-
const mainCssResult = await generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
|
|
202
|
-
scope: options.scope,
|
|
203
|
-
contentDir: path.join(workspaceDir, entry),
|
|
204
|
-
cssOptions: themeConfig.css,
|
|
205
|
-
safeVarPrefixes: [...getMotionVarPrefixes(context.componentData, allMotionComponents), ...getConfigurableCssVariables()]
|
|
206
|
-
});
|
|
207
|
-
const outputDir = path.dirname(outputPath);
|
|
208
|
-
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
|
|
209
|
-
fs.writeFileSync(outputPath, mainCssResult.css);
|
|
210
|
-
genLog.spinStop("✅", getMainCssSummaryMessage({
|
|
211
|
-
sizeGzipBytes: mainCssResult.sizeGzipBytes,
|
|
212
|
-
optimizationStats: mainCssResult.optimizationStats,
|
|
213
|
-
formatBytes
|
|
214
|
-
}));
|
|
215
|
-
const duration = Math.round(performance.now() - genStartTime);
|
|
216
|
-
genLog.newline();
|
|
217
|
-
genLog.print(green("CSS generation complete!"));
|
|
218
|
-
genLog.newline();
|
|
219
|
-
genLog.label("Output file:", outputPath);
|
|
220
|
-
genLog.newline();
|
|
221
|
-
genLog.print(`${magenta("Total time:")} ${duration}ms`);
|
|
222
|
-
return {
|
|
223
|
-
duration,
|
|
224
|
-
outputPath,
|
|
225
|
-
packageDirs
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
await generateThemeModeCSS();
|
|
229
|
-
if (options.watch) {
|
|
230
|
-
const entryDir = path.join(workspaceDir, entry);
|
|
231
|
-
const { watchDirs, filteredPackageDirs } = getWatchDirectoryGroups(entryDir, [entryDir, ...packageDirs]);
|
|
232
|
-
if (!effectiveSilent) {
|
|
233
|
-
log.newline();
|
|
234
|
-
log.print(`${magenta("Watching for changes...")}`);
|
|
235
|
-
log.listItem(`App: ${entryDir}`);
|
|
236
|
-
filteredPackageDirs.forEach((dir) => {
|
|
237
|
-
log.listItem(`Package: ${dir}`);
|
|
238
|
-
});
|
|
239
|
-
log.print(`${gray("Press Ctrl+C to stop")}`);
|
|
240
|
-
log.newline();
|
|
241
|
-
}
|
|
242
|
-
const regenerate = createQueuedRegenerator({
|
|
243
|
-
onStart: () => {
|
|
244
|
-
if (!effectiveSilent) {
|
|
245
|
-
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
246
|
-
log.print(`${gray(`[${timestamp}]`)} Change detected, regenerating...`);
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
regenerateOnce: async () => generateThemeModeCSS({ isWatch: true }),
|
|
250
|
-
onSuccess: (result) => {
|
|
251
|
-
if (!effectiveSilent) {
|
|
252
|
-
const updatedAt = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
253
|
-
log.print(`${gray(`[${updatedAt}]`)} ${green(`CSS updated (${result?.duration}ms)`)}`);
|
|
254
|
-
log.newline();
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
onError: (message) => {
|
|
258
|
-
log.print(message);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
watchSourceFiles(watchDirs, createDebouncedAction(() => {
|
|
262
|
-
regenerate();
|
|
263
|
-
}, themeConfig.css?.watchDebounce ?? 100));
|
|
264
|
-
await new Promise(() => {});
|
|
265
|
-
}
|
|
266
|
-
} catch (error) {
|
|
267
|
-
const message = error instanceof Error ? error.message : "CSS generation failed";
|
|
268
|
-
if (effectiveSilent) spinStop("❌", message);
|
|
269
|
-
else log.spinStop("❌", message);
|
|
270
|
-
process.exitCode = 1;
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
//#endregion
|
|
275
|
-
export { runCssCommand };
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,66 +0,0 @@
|
|
|
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 };
|
|
@@ -1,66 +0,0 @@
|
|
|
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 };
|
|
@@ -1,11 +0,0 @@
|
|
|
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 };
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
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
|
-
|
|
15
|
-
//#region ../tailwind/dist/css/utils.js
|
|
16
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
17
|
-
/**
|
|
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
|
-
* Extract variant defaults from a UniversalTokensConfig.
|
|
32
|
-
* Converts from config structure to a simpler lookup format.
|
|
33
|
-
* e.g., { button: { defaults: { size: 'md' } } } -> { Button: { size: 'md' } }
|
|
34
|
-
*/
|
|
35
|
-
const extractVariantDefaults = (config) => {
|
|
36
|
-
const componentNameMap = {
|
|
37
|
-
avatar: "Avatar",
|
|
38
|
-
badge: "Badge",
|
|
39
|
-
button: "Button",
|
|
40
|
-
checkbox: "Checkbox",
|
|
41
|
-
chip: "Chip",
|
|
42
|
-
divider: "Divider",
|
|
43
|
-
iconButton: "IconButton",
|
|
44
|
-
input: "Input",
|
|
45
|
-
link: "Link",
|
|
46
|
-
menu: "Menu",
|
|
47
|
-
radio: "Radio",
|
|
48
|
-
switch: "Switch"
|
|
49
|
-
};
|
|
50
|
-
return Object.entries(config).reduce((acc, [configKey, componentConfig]) => {
|
|
51
|
-
const pascalName = componentNameMap[configKey];
|
|
52
|
-
if (!pascalName || !componentConfig || typeof componentConfig !== "object") return acc;
|
|
53
|
-
const configWithDefaults = componentConfig;
|
|
54
|
-
return configWithDefaults.defaults ? {
|
|
55
|
-
...acc,
|
|
56
|
-
[pascalName]: configWithDefaults.defaults
|
|
57
|
-
} : acc;
|
|
58
|
-
}, {});
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
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
|
-
* Format bytes to human readable string
|
|
141
|
-
*/
|
|
142
|
-
const formatBytes = (bytes) => {
|
|
143
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
144
|
-
const kb = bytes / 1024;
|
|
145
|
-
if (kb < 1024) return `${kb.toFixed(1)} KB`;
|
|
146
|
-
return `${(kb / 1024).toFixed(2)} MB`;
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
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
|
-
* Get motion CSS variable prefixes needed by a set of components.
|
|
205
|
-
* Looks up motionVarPrefixes from componentData.json for each component.
|
|
206
|
-
*/
|
|
207
|
-
const getMotionVarPrefixes = (componentData, components) => {
|
|
208
|
-
const prefixes = components.flatMap((componentName) => {
|
|
209
|
-
return componentData[componentName]?.motionVarPrefixes ?? [];
|
|
210
|
-
});
|
|
211
|
-
return [...new Set(prefixes)];
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Collect css variable names exposed by configurable properties.
|
|
215
|
-
*/
|
|
216
|
-
const getConfigurableCssVariables = () => {
|
|
217
|
-
const udsVarPrefix = "--uds";
|
|
218
|
-
const cssVars = Object.values(require_properties.configurableProperties).flatMap(({ cssProperties }) => {
|
|
219
|
-
if (typeof cssProperties === "string") return cssProperties.startsWith(udsVarPrefix) ? [cssProperties] : [];
|
|
220
|
-
if (Array.isArray(cssProperties)) return cssProperties.filter((cssProperty) => typeof cssProperty === "string" && cssProperty.startsWith(udsVarPrefix));
|
|
221
|
-
return [];
|
|
222
|
-
});
|
|
223
|
-
return [...new Set(["--uds-button-gap", ...cssVars])];
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
//#endregion
|
|
227
|
-
exports.extractVariantDefaults = extractVariantDefaults;
|
|
228
|
-
exports.findPackageSourceDir = findPackageSourceDir;
|
|
229
|
-
exports.formatBytes = formatBytes;
|
|
230
|
-
exports.getConfigurableCssVariables = getConfigurableCssVariables;
|
|
231
|
-
exports.getMotionVarPrefixes = getMotionVarPrefixes;
|
|
232
|
-
exports.loadConfigFile = loadConfigFile;
|
|
233
|
-
exports.scaffoldThemeConfig = scaffoldThemeConfig;
|
|
234
|
-
exports.scanDirectoryForSafelist = scanDirectoryForSafelist;
|