@yahoo/uds 3.114.0-beta.3 → 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.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 +20 -17
- package/dist/styles/styler.d.ts +24 -21
- 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 -238
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +127 -238
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +261 -353
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +261 -352
- 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/tailwind/utils/getFontStyles.d.cts +1 -1
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.ts +1 -1
- package/dist/tailwind/dist/tailwind/utils/getShadowStyles.d.cts +4 -4
- package/dist/tailwind/dist/tailwind/utils/getShadowStyles.d.ts +4 -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 +1195 -990
- package/dist/uds/generated/componentData.js +1130 -979
- 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 -2417
- package/generated/tailwindPurge.ts +0 -4560
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
import { formatBytes } from "./utils.js";
|
|
3
|
-
import { tailwindPlugin } from "../plugin.js";
|
|
4
|
-
import { optimizeCSS } from "../utils/optimizeCSS.js";
|
|
5
|
-
import { preserveVars, preserveVarsCleanup } from "../utils/postcssPreserveVars.js";
|
|
6
|
-
import { fixScopedColorModeSelectorsPlugin } from "./postcss.js";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import postcss from "postcss";
|
|
9
|
-
import autoprefixer from "autoprefixer";
|
|
10
|
-
import pruneVar from "postcss-prune-var";
|
|
11
|
-
import postcssScope from "postcss-scope";
|
|
12
|
-
import tailwindcss from "tailwindcss";
|
|
13
|
-
|
|
14
|
-
//#region ../tailwind/dist/css/generate.helpers.js
|
|
15
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
16
|
-
const getCssFeatureFlags = (cssOptions) => {
|
|
17
|
-
const optimizationConfig = cssOptions?.optimization;
|
|
18
|
-
const shouldOptimize = optimizationConfig?.enabled !== false;
|
|
19
|
-
return {
|
|
20
|
-
enablePreflight: cssOptions?.preflight !== false,
|
|
21
|
-
enableFontFaceDeclarations: cssOptions?.fontFaceDeclarations !== false,
|
|
22
|
-
shouldOptimize,
|
|
23
|
-
shouldPruneVars: shouldOptimize && optimizationConfig?.pruneVars !== false
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const getContentGlobs = (contentDir) => [path.join(contentDir, "**/*.{js,jsx,ts,tsx}")];
|
|
27
|
-
const createTailwindPlugin = (options) => {
|
|
28
|
-
return tailwindcss({
|
|
29
|
-
content: getContentGlobs(options.contentDir),
|
|
30
|
-
safelist: options.safelist,
|
|
31
|
-
corePlugins: { preflight: options.enablePreflight },
|
|
32
|
-
plugins: [tailwindPlugin({
|
|
33
|
-
config: options.config,
|
|
34
|
-
disableFontFaceDeclarations: !options.enableFontFaceDeclarations,
|
|
35
|
-
ignorePluginSafelists: true
|
|
36
|
-
})]
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
const getPruneVarPlugins = (safeVarPrefixes) => {
|
|
40
|
-
if (safeVarPrefixes.length === 0) return [pruneVar()];
|
|
41
|
-
return [
|
|
42
|
-
preserveVars({ preserve: safeVarPrefixes }),
|
|
43
|
-
pruneVar(),
|
|
44
|
-
preserveVarsCleanup()
|
|
45
|
-
];
|
|
46
|
-
};
|
|
47
|
-
const buildPostcssPlugins = (options) => {
|
|
48
|
-
const plugins = [options.tailwindPlugin, autoprefixer()];
|
|
49
|
-
if (options.shouldPruneVars) plugins.push(...getPruneVarPlugins(options.safeVarPrefixes));
|
|
50
|
-
if (options.scopeClass) plugins.push(postcssScope(options.scopeClass));
|
|
51
|
-
return plugins;
|
|
52
|
-
};
|
|
53
|
-
const applyScopedColorModeFix = async (css, scopeClass) => {
|
|
54
|
-
if (!scopeClass) return css;
|
|
55
|
-
return (await postcss([fixScopedColorModeSelectorsPlugin(scopeClass)]).process(css, { from: void 0 })).css;
|
|
56
|
-
};
|
|
57
|
-
const optimizeGeneratedCss = async (options) => {
|
|
58
|
-
if (!options.shouldOptimize) return { css: options.css };
|
|
59
|
-
const optimizationOptions = {
|
|
60
|
-
removeUnusedFonts: options.optimizationConfig?.removeUnusedFonts,
|
|
61
|
-
removeEmptyRules: options.optimizationConfig?.removeEmptyRules,
|
|
62
|
-
aggregateDuplicateSelectors: options.optimizationConfig?.aggregateDuplicateSelectors,
|
|
63
|
-
referenceCss: options.referenceCss,
|
|
64
|
-
scopeClass: options.scopeClass
|
|
65
|
-
};
|
|
66
|
-
const optimized = await optimizeCSS(options.css, optimizationOptions);
|
|
67
|
-
return {
|
|
68
|
-
css: optimized.css,
|
|
69
|
-
optimizationStats: {
|
|
70
|
-
originalSize: optimized.stats.originalSize,
|
|
71
|
-
originalSizeGzip: optimized.stats.originalSizeGzip,
|
|
72
|
-
fontFacesRemoved: optimized.stats.fontFacesRemoved,
|
|
73
|
-
emptyRulesRemoved: optimized.stats.emptyRulesRemoved,
|
|
74
|
-
validationErrors: optimized.validation.errors
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const printSimpleModeStats = (options) => {
|
|
79
|
-
const { print, magenta, cyan, yellow } = options;
|
|
80
|
-
print("");
|
|
81
|
-
print(`${magenta("Output:")} ${cyan(options.outputPath)}`);
|
|
82
|
-
print(`${magenta("Stats:")}`);
|
|
83
|
-
print(` Files scanned: ${options.totalFilesScanned}`);
|
|
84
|
-
print(` Classes: ${options.classCount}`);
|
|
85
|
-
print(` Size: ${formatBytes(options.sizeBytes)} (${formatBytes(options.sizeGzipBytes)} gzipped)`);
|
|
86
|
-
const optimizationStats = options.optimizationStats;
|
|
87
|
-
if (optimizationStats) {
|
|
88
|
-
const savedBytesGzip = optimizationStats.originalSizeGzip - options.sizeGzipBytes;
|
|
89
|
-
if (savedBytesGzip > 0) print(` Optimized: saved ${formatBytes(savedBytesGzip)} gzip (${optimizationStats.fontFacesRemoved} unused @font-face, ${optimizationStats.emptyRulesRemoved} empty rules removed)`);
|
|
90
|
-
if (optimizationStats.validationErrors.length > 0) {
|
|
91
|
-
print(` ${yellow("Validation warnings:")}`);
|
|
92
|
-
optimizationStats.validationErrors.forEach((error) => print(` ${yellow("•")} ${error}`));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
print(` Time: ${options.duration}ms`);
|
|
96
|
-
if (options.scope) print(` Scope: ${cyan(options.scope)}`);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
//#endregion
|
|
100
|
-
export { applyScopedColorModeFix, buildPostcssPlugins, createTailwindPlugin, getCssFeatureFlags, optimizeGeneratedCss, printSimpleModeStats };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
import { defaultTokensConfig } from "../../../config/dist/index.js";
|
|
3
|
-
import { cyan, magenta, yellow } from "../../../cli/dist/lib/colors.js";
|
|
4
|
-
import { print } from "../../../cli/dist/lib/print.js";
|
|
5
|
-
import { spinStop } from "../../../cli/dist/lib/spinner.js";
|
|
6
|
-
import { extractVariantDefaults, getConfigurableCssVariables, getMotionVarPrefixes, loadConfigFile, scanDirectoryForSafelist } from "./utils.js";
|
|
7
|
-
import { deduplicateSafelist, getThemeAndScaleClasses } from "../purger/optimized/utils/safelist.js";
|
|
8
|
-
import { applyScopedColorModeFix, buildPostcssPlugins, createTailwindPlugin, getCssFeatureFlags, optimizeGeneratedCss, printSimpleModeStats } from "./generate.helpers.js";
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import { gzipSync } from "node:zlib";
|
|
12
|
-
import postcss from "postcss";
|
|
13
|
-
|
|
14
|
-
//#region ../tailwind/dist/css/generate.js
|
|
15
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
16
|
-
const normalizeScope = (scope) => {
|
|
17
|
-
const trimmedScope = scope?.trim();
|
|
18
|
-
return trimmedScope ? trimmedScope : void 0;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Generate CSS from a safelist using Tailwind + PostCSS
|
|
22
|
-
* @param safelist - UDS component classes to include
|
|
23
|
-
* @param config - Token configuration
|
|
24
|
-
* @param options - Additional options
|
|
25
|
-
*/
|
|
26
|
-
const generateCSS = async (safelist, config, options) => {
|
|
27
|
-
const sourceCSS = "@tailwind base; @tailwind components; @tailwind utilities";
|
|
28
|
-
const contentDir = options?.contentDir ?? path.join(process.cwd(), "src");
|
|
29
|
-
const cssFlags = getCssFeatureFlags(options?.cssOptions);
|
|
30
|
-
const optimizationConfig = options?.cssOptions?.optimization;
|
|
31
|
-
const scopeClass = normalizeScope(options?.scope) ?? normalizeScope(options?.cssOptions?.scope);
|
|
32
|
-
let css = await applyScopedColorModeFix((await postcss(buildPostcssPlugins({
|
|
33
|
-
tailwindPlugin: createTailwindPlugin({
|
|
34
|
-
contentDir,
|
|
35
|
-
safelist,
|
|
36
|
-
config,
|
|
37
|
-
enablePreflight: cssFlags.enablePreflight,
|
|
38
|
-
enableFontFaceDeclarations: cssFlags.enableFontFaceDeclarations
|
|
39
|
-
}),
|
|
40
|
-
shouldPruneVars: cssFlags.shouldPruneVars,
|
|
41
|
-
safeVarPrefixes: options?.safeVarPrefixes ?? [],
|
|
42
|
-
scopeClass
|
|
43
|
-
})).process(sourceCSS, { from: void 0 })).css, scopeClass);
|
|
44
|
-
const optimizedCss = await optimizeGeneratedCss({
|
|
45
|
-
css,
|
|
46
|
-
shouldOptimize: cssFlags.shouldOptimize,
|
|
47
|
-
optimizationConfig,
|
|
48
|
-
referenceCss: options?.referenceCss,
|
|
49
|
-
scopeClass
|
|
50
|
-
});
|
|
51
|
-
css = optimizedCss.css;
|
|
52
|
-
const sizeBytes = Buffer.byteLength(css, "utf8");
|
|
53
|
-
const sizeGzipBytes = gzipSync(css).length;
|
|
54
|
-
return {
|
|
55
|
-
css,
|
|
56
|
-
sizeBytes,
|
|
57
|
-
sizeGzipBytes,
|
|
58
|
-
classCount: safelist.length,
|
|
59
|
-
optimizationStats: optimizedCss.optimizationStats
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Generate CSS in simple mode (no uds.theme.ts)
|
|
64
|
-
*/
|
|
65
|
-
const generateSimpleModeCSS = async (options) => {
|
|
66
|
-
const isWatch = options.isWatch === true;
|
|
67
|
-
const shouldLogStats = !(options.silent === true) && !isWatch;
|
|
68
|
-
const startTime = performance.now();
|
|
69
|
-
const colorModes = ["dark"];
|
|
70
|
-
let tokensConfig = defaultTokensConfig;
|
|
71
|
-
if (options.configPath) {
|
|
72
|
-
const loadedConfig = await loadConfigFile(options.configPath);
|
|
73
|
-
if (loadedConfig) tokensConfig = loadedConfig;
|
|
74
|
-
else if (shouldLogStats) spinStop("⚠️", `Config file not found: ${options.configPath}, using defaults`);
|
|
75
|
-
}
|
|
76
|
-
const variantDefaults = extractVariantDefaults(tokensConfig);
|
|
77
|
-
const entryDir = path.join(options.workspaceDir, options.entry);
|
|
78
|
-
const scanResult = await scanDirectoryForSafelist(entryDir, colorModes, options.variants, options.autoVariants, options.componentData, variantDefaults);
|
|
79
|
-
const totalFilesScanned = scanResult.filesScanned;
|
|
80
|
-
const allClasses = [...scanResult.safelist];
|
|
81
|
-
const allComponents = new Set(scanResult.components);
|
|
82
|
-
const packageDirs = [entryDir];
|
|
83
|
-
const cssResult = await generateCSS(deduplicateSafelist([...allClasses, ...getThemeAndScaleClasses(colorModes)]), tokensConfig, {
|
|
84
|
-
scope: options.scope,
|
|
85
|
-
contentDir: entryDir,
|
|
86
|
-
safeVarPrefixes: [...getMotionVarPrefixes(options.componentData, [...allComponents]), ...getConfigurableCssVariables()]
|
|
87
|
-
});
|
|
88
|
-
const outputPath = path.isAbsolute(options.outFile) ? options.outFile : path.join(options.workspaceDir, options.outFile);
|
|
89
|
-
const outputDir = path.dirname(outputPath);
|
|
90
|
-
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
|
|
91
|
-
fs.writeFileSync(outputPath, cssResult.css);
|
|
92
|
-
const duration = Math.round(performance.now() - startTime);
|
|
93
|
-
if (shouldLogStats) printSimpleModeStats({
|
|
94
|
-
outputPath,
|
|
95
|
-
totalFilesScanned,
|
|
96
|
-
classCount: cssResult.classCount,
|
|
97
|
-
sizeBytes: cssResult.sizeBytes,
|
|
98
|
-
sizeGzipBytes: cssResult.sizeGzipBytes,
|
|
99
|
-
duration,
|
|
100
|
-
scope: options.scope,
|
|
101
|
-
optimizationStats: cssResult.optimizationStats,
|
|
102
|
-
print,
|
|
103
|
-
magenta,
|
|
104
|
-
cyan,
|
|
105
|
-
yellow
|
|
106
|
-
});
|
|
107
|
-
return {
|
|
108
|
-
success: true,
|
|
109
|
-
outputPath,
|
|
110
|
-
packageDirs
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
export { generateCSS, generateSimpleModeCSS };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
const require_postcss_helpers = require('./postcss.helpers.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../tailwind/dist/css/postcss.js
|
|
5
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
6
|
-
/**
|
|
7
|
-
* PostCSS plugin to fix color mode selectors for scoped CSS.
|
|
8
|
-
*
|
|
9
|
-
* postcss-scope converts selectors like:
|
|
10
|
-
* `.uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo`
|
|
11
|
-
*
|
|
12
|
-
* But the color mode class is typically on <html> or <body>, which is an
|
|
13
|
-
* ANCESTOR of the scope, not a descendant. This plugin adds alternative
|
|
14
|
-
* selectors so color modes work correctly:
|
|
15
|
-
*
|
|
16
|
-
* `.scope .uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo, .uds-color-mode-dark .scope .foo`
|
|
17
|
-
*
|
|
18
|
-
* This ensures styles apply whether the color mode class is inside or outside the scope.
|
|
19
|
-
*/
|
|
20
|
-
const fixScopedColorModeSelectorsPlugin = (scopeClass) => {
|
|
21
|
-
const colorModePattern = /\.(uds-color-mode-(?:dark|light))/;
|
|
22
|
-
return {
|
|
23
|
-
postcssPlugin: "fix-scoped-color-mode-selectors",
|
|
24
|
-
Once(root) {
|
|
25
|
-
root.walkRules((rule) => {
|
|
26
|
-
if (!rule.selector.includes(scopeClass) || !colorModePattern.test(rule.selector)) return;
|
|
27
|
-
const nextSelector = require_postcss_helpers.buildScopedColorModeSelectorList(rule.selector, scopeClass);
|
|
28
|
-
if (nextSelector !== rule.selector) rule.selector = nextSelector;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.fixScopedColorModeSelectorsPlugin = fixScopedColorModeSelectorsPlugin;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
|
|
3
|
-
//#region ../tailwind/dist/css/postcss.helpers.js
|
|
4
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
5
|
-
const COLOR_MODE_RE = /^(\.(uds-color-mode-(?:dark|light)))(\s+.+)?$/;
|
|
6
|
-
const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7
|
-
const getScopedColorModeAlternativeSelector = (selector, scopeClass) => {
|
|
8
|
-
const scopeMatch = selector.match(new RegExp(`^(${escapeForRegExp(scopeClass)})\\s+(.+)$`));
|
|
9
|
-
if (!scopeMatch) return null;
|
|
10
|
-
const colorModeMatch = scopeMatch[2].match(COLOR_MODE_RE);
|
|
11
|
-
if (!colorModeMatch) return null;
|
|
12
|
-
return `${colorModeMatch[1]} ${scopeClass}${colorModeMatch[3] ?? ""}`;
|
|
13
|
-
};
|
|
14
|
-
const buildScopedColorModeSelectorList = (ruleSelector, scopeClass) => {
|
|
15
|
-
const selectors = ruleSelector.split(",").map((value) => value.trim());
|
|
16
|
-
return selectors.reduce((acc, selector) => {
|
|
17
|
-
const altSelector = getScopedColorModeAlternativeSelector(selector, scopeClass);
|
|
18
|
-
return altSelector && !selectors.includes(altSelector) && !acc.includes(altSelector) ? [
|
|
19
|
-
...acc,
|
|
20
|
-
selector,
|
|
21
|
-
altSelector
|
|
22
|
-
] : [...acc, selector];
|
|
23
|
-
}, []).join(", ");
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.buildScopedColorModeSelectorList = buildScopedColorModeSelectorList;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
//#region ../tailwind/dist/css/postcss.helpers.js
|
|
3
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
4
|
-
const COLOR_MODE_RE = /^(\.(uds-color-mode-(?:dark|light)))(\s+.+)?$/;
|
|
5
|
-
const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6
|
-
const getScopedColorModeAlternativeSelector = (selector, scopeClass) => {
|
|
7
|
-
const scopeMatch = selector.match(new RegExp(`^(${escapeForRegExp(scopeClass)})\\s+(.+)$`));
|
|
8
|
-
if (!scopeMatch) return null;
|
|
9
|
-
const colorModeMatch = scopeMatch[2].match(COLOR_MODE_RE);
|
|
10
|
-
if (!colorModeMatch) return null;
|
|
11
|
-
return `${colorModeMatch[1]} ${scopeClass}${colorModeMatch[3] ?? ""}`;
|
|
12
|
-
};
|
|
13
|
-
const buildScopedColorModeSelectorList = (ruleSelector, scopeClass) => {
|
|
14
|
-
const selectors = ruleSelector.split(",").map((value) => value.trim());
|
|
15
|
-
return selectors.reduce((acc, selector) => {
|
|
16
|
-
const altSelector = getScopedColorModeAlternativeSelector(selector, scopeClass);
|
|
17
|
-
return altSelector && !selectors.includes(altSelector) && !acc.includes(altSelector) ? [
|
|
18
|
-
...acc,
|
|
19
|
-
selector,
|
|
20
|
-
altSelector
|
|
21
|
-
] : [...acc, selector];
|
|
22
|
-
}, []).join(", ");
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { buildScopedColorModeSelectorList };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
import { buildScopedColorModeSelectorList } from "./postcss.helpers.js";
|
|
3
|
-
|
|
4
|
-
//#region ../tailwind/dist/css/postcss.js
|
|
5
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
6
|
-
/**
|
|
7
|
-
* PostCSS plugin to fix color mode selectors for scoped CSS.
|
|
8
|
-
*
|
|
9
|
-
* postcss-scope converts selectors like:
|
|
10
|
-
* `.uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo`
|
|
11
|
-
*
|
|
12
|
-
* But the color mode class is typically on <html> or <body>, which is an
|
|
13
|
-
* ANCESTOR of the scope, not a descendant. This plugin adds alternative
|
|
14
|
-
* selectors so color modes work correctly:
|
|
15
|
-
*
|
|
16
|
-
* `.scope .uds-color-mode-dark .foo` → `.scope .uds-color-mode-dark .foo, .uds-color-mode-dark .scope .foo`
|
|
17
|
-
*
|
|
18
|
-
* This ensures styles apply whether the color mode class is inside or outside the scope.
|
|
19
|
-
*/
|
|
20
|
-
const fixScopedColorModeSelectorsPlugin = (scopeClass) => {
|
|
21
|
-
const colorModePattern = /\.(uds-color-mode-(?:dark|light))/;
|
|
22
|
-
return {
|
|
23
|
-
postcssPlugin: "fix-scoped-color-mode-selectors",
|
|
24
|
-
Once(root) {
|
|
25
|
-
root.walkRules((rule) => {
|
|
26
|
-
if (!rule.selector.includes(scopeClass) || !colorModePattern.test(rule.selector)) return;
|
|
27
|
-
const nextSelector = buildScopedColorModeSelectorList(rule.selector, scopeClass);
|
|
28
|
-
if (nextSelector !== rule.selector) rule.selector = nextSelector;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { fixScopedColorModeSelectorsPlugin };
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_index = require('../../../config/dist/index.cjs');
|
|
4
|
-
const require_colors = require('../../../cli/dist/lib/colors.cjs');
|
|
5
|
-
const require_print = require('../../../cli/dist/lib/print.cjs');
|
|
6
|
-
const require_spinner = require('../../../cli/dist/lib/spinner.cjs');
|
|
7
|
-
const require_logger = require('../../../cli/dist/lib/logger.cjs');
|
|
8
|
-
const require_utils = require('./utils.cjs');
|
|
9
|
-
const require_safelist = require('../purger/optimized/utils/safelist.cjs');
|
|
10
|
-
const require_generate = require('./generate.cjs');
|
|
11
|
-
const require_runner_helpers = require('./runner.helpers.cjs');
|
|
12
|
-
let node_fs = require("node:fs");
|
|
13
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
14
|
-
let node_path = require("node:path");
|
|
15
|
-
node_path = require_runtime.__toESM(node_path);
|
|
16
|
-
|
|
17
|
-
//#region ../tailwind/dist/css/runner.js
|
|
18
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
19
|
-
const DEFAULT_ENTRY = "./src";
|
|
20
|
-
const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/i;
|
|
21
|
-
const getWatchDirs = (dirs) => [...new Set(dirs.filter((dir) => !dir.split(node_path.default.sep).includes("node_modules")))];
|
|
22
|
-
const watchSourceFiles = (dirs, onFileChange) => {
|
|
23
|
-
dirs.forEach((dir) => {
|
|
24
|
-
node_fs.default.watch(dir, { recursive: true }, (_eventType, filename) => {
|
|
25
|
-
if (filename && SOURCE_FILE_PATTERN.test(filename)) onFileChange();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const createDebouncedAction = (action, delayMs) => {
|
|
30
|
-
let debounceTimer = null;
|
|
31
|
-
return () => {
|
|
32
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
33
|
-
debounceTimer = setTimeout(action, delayMs);
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const createQueuedRegenerator = (options) => {
|
|
37
|
-
let isGenerating = false;
|
|
38
|
-
let pendingRegenerate = false;
|
|
39
|
-
const regenerate = async () => {
|
|
40
|
-
if (isGenerating) {
|
|
41
|
-
pendingRegenerate = true;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
isGenerating = true;
|
|
45
|
-
try {
|
|
46
|
-
options.onStart?.();
|
|
47
|
-
const result = await options.regenerateOnce();
|
|
48
|
-
options.onSuccess?.(result);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
const message = error instanceof Error ? error.message : "CSS generation failed";
|
|
51
|
-
options.onError(message);
|
|
52
|
-
} finally {
|
|
53
|
-
isGenerating = false;
|
|
54
|
-
if (pendingRegenerate) {
|
|
55
|
-
pendingRegenerate = false;
|
|
56
|
-
await regenerate();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
return regenerate;
|
|
61
|
-
};
|
|
62
|
-
const runCssCommand = async (options, context) => {
|
|
63
|
-
if (!node_fs.default.existsSync(node_path.default.join(options.workspaceDir, String(options.themeConfigPath)))) {
|
|
64
|
-
await runSimpleMode(options, context);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
await runThemeMode(options, context);
|
|
68
|
-
};
|
|
69
|
-
const runSimpleMode = async (options, context) => {
|
|
70
|
-
const entry = typeof options.entryOption === "string" ? options.entryOption : DEFAULT_ENTRY;
|
|
71
|
-
const configPath = typeof options.configOption === "string" ? options.configOption : void 0;
|
|
72
|
-
if (!options.watch && !options.silent) require_spinner.spinStart("Generating CSS...");
|
|
73
|
-
try {
|
|
74
|
-
const result = await require_generate.generateSimpleModeCSS({
|
|
75
|
-
workspaceDir: options.workspaceDir,
|
|
76
|
-
entry,
|
|
77
|
-
outFile: String(options.outFile),
|
|
78
|
-
variants: context.variants,
|
|
79
|
-
autoVariants: context.autoVariants,
|
|
80
|
-
componentData: context.componentData,
|
|
81
|
-
scope: options.scope,
|
|
82
|
-
configPath,
|
|
83
|
-
isWatch: options.watch,
|
|
84
|
-
silent: options.silent
|
|
85
|
-
});
|
|
86
|
-
if (options.watch) await runSimpleModeWatch(options, context, entry, configPath, result.packageDirs ?? []);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
require_spinner.spinStop("❌", error instanceof Error ? error.message : "CSS generation failed");
|
|
89
|
-
process.exitCode = 1;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const runSimpleModeWatch = async (options, context, entry, configPath, packageDirs) => {
|
|
93
|
-
const entryDir = node_path.default.join(options.workspaceDir, entry);
|
|
94
|
-
const watchDirs = getWatchDirs(packageDirs.length > 0 ? packageDirs : [entryDir]);
|
|
95
|
-
if (!options.silent) {
|
|
96
|
-
require_print.print("");
|
|
97
|
-
require_print.print(`${require_colors.magenta("Watching for changes...")}`);
|
|
98
|
-
watchDirs.forEach((dir) => require_print.print(` ${require_colors.gray("•")} ${dir}`));
|
|
99
|
-
require_print.print(`${require_colors.gray("Press Ctrl+C to stop")}`);
|
|
100
|
-
require_print.print("");
|
|
101
|
-
}
|
|
102
|
-
const regenerate = createQueuedRegenerator({
|
|
103
|
-
onStart: () => {
|
|
104
|
-
if (!options.silent) require_print.print(`${require_colors.gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`)} Change detected, regenerating...`);
|
|
105
|
-
},
|
|
106
|
-
regenerateOnce: async () => {
|
|
107
|
-
await require_generate.generateSimpleModeCSS({
|
|
108
|
-
workspaceDir: options.workspaceDir,
|
|
109
|
-
entry,
|
|
110
|
-
outFile: String(options.outFile),
|
|
111
|
-
variants: context.variants,
|
|
112
|
-
autoVariants: context.autoVariants,
|
|
113
|
-
componentData: context.componentData,
|
|
114
|
-
scope: options.scope,
|
|
115
|
-
configPath,
|
|
116
|
-
isWatch: true,
|
|
117
|
-
silent: true
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
onSuccess: () => {
|
|
121
|
-
if (!options.silent) {
|
|
122
|
-
require_print.print(`${require_colors.gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}]`)} ${require_colors.green("CSS updated")}`);
|
|
123
|
-
require_print.print("");
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
onError: (message) => {
|
|
127
|
-
require_print.print(`Error: ${message}`);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
watchSourceFiles(watchDirs, createDebouncedAction(() => {
|
|
131
|
-
regenerate();
|
|
132
|
-
}, 100));
|
|
133
|
-
await new Promise(() => {});
|
|
134
|
-
};
|
|
135
|
-
const loadThemeModeSetup = async (options) => {
|
|
136
|
-
const themeConfigInput = await require_utils.loadConfigFile(String(options.themeConfigPath));
|
|
137
|
-
if (!themeConfigInput) return null;
|
|
138
|
-
const themeContext = {
|
|
139
|
-
cwd: options.workspaceDir,
|
|
140
|
-
watch: options.watch
|
|
141
|
-
};
|
|
142
|
-
const themeConfig = typeof themeConfigInput === "function" ? await themeConfigInput(themeContext) : themeConfigInput;
|
|
143
|
-
let appConfig = require_index.defaultTokensConfig;
|
|
144
|
-
if (themeConfig.config) {
|
|
145
|
-
const loadedConfig = await require_utils.loadConfigFile(themeConfig.config);
|
|
146
|
-
if (loadedConfig) appConfig = loadedConfig;
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
themeConfig,
|
|
150
|
-
colorModes: themeConfig.colorModes ?? ["dark"],
|
|
151
|
-
entry: themeConfig.entry ?? "/src/",
|
|
152
|
-
appConfig,
|
|
153
|
-
appVariantDefaults: require_utils.extractVariantDefaults(appConfig),
|
|
154
|
-
effectiveSilent: options.silent || themeConfig.silent === true
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
const runThemeMode = async (options, context) => {
|
|
158
|
-
const workspaceDir = options.workspaceDir;
|
|
159
|
-
const outputPath = node_path.default.isAbsolute(options.outFile) ? options.outFile : node_path.default.join(workspaceDir, String(options.outFile));
|
|
160
|
-
let effectiveSilent = options.silent;
|
|
161
|
-
let log = require_logger.createLogger({ silent: effectiveSilent });
|
|
162
|
-
log.spinStart("Loading theme configuration...");
|
|
163
|
-
try {
|
|
164
|
-
const setup = await loadThemeModeSetup(options);
|
|
165
|
-
if (!setup) {
|
|
166
|
-
log.spinStop("❌", `Theme config not found: ${options.themeConfigPath}`);
|
|
167
|
-
process.exitCode = 1;
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const { themeConfig, colorModes, entry, appConfig, appVariantDefaults } = setup;
|
|
171
|
-
effectiveSilent = setup.effectiveSilent;
|
|
172
|
-
log = require_logger.createLogger({ silent: effectiveSilent });
|
|
173
|
-
if (!effectiveSilent) log.spinStop("✅", "Theme configuration loaded");
|
|
174
|
-
if (themeConfig.config && appConfig === require_index.defaultTokensConfig) log.warn(`App config not found: ${themeConfig.config}, using defaults`);
|
|
175
|
-
const packageDirs = [];
|
|
176
|
-
const generateThemeModeCSS = async (opts) => {
|
|
177
|
-
const genStartTime = performance.now();
|
|
178
|
-
const genLog = opts?.isWatch ? require_logger.createLogger({ silent: true }) : log;
|
|
179
|
-
genLog.spinStart("Scanning app code...");
|
|
180
|
-
const appScanResult = await require_utils.scanDirectoryForSafelist(node_path.default.join(workspaceDir, entry), colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults);
|
|
181
|
-
genLog.spinStop("✅", `Scanned ${appScanResult.filesScanned} files`);
|
|
182
|
-
genLog.spinStart("Generating main CSS...");
|
|
183
|
-
const inheritedClasses = [...appScanResult.safelist];
|
|
184
|
-
const inheritedComponents = new Set(appScanResult.components);
|
|
185
|
-
const processInheritedPackage = async (packageName) => {
|
|
186
|
-
genLog.spinStart(`Processing package: ${packageName}...`);
|
|
187
|
-
const packageDir = require_utils.findPackageSourceDir(packageName);
|
|
188
|
-
if (!packageDir) {
|
|
189
|
-
genLog.spinStop("⚠️", `Package not found: ${packageName}`);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (!packageDirs.includes(packageDir)) packageDirs.push(packageDir);
|
|
193
|
-
const packageScanResult = await require_utils.scanDirectoryForSafelist(packageDir, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, true);
|
|
194
|
-
inheritedClasses.push(...packageScanResult.safelist);
|
|
195
|
-
packageScanResult.components.forEach((comp) => inheritedComponents.add(comp));
|
|
196
|
-
genLog.spinStop("✅", `${packageName}: ${packageScanResult.filesScanned} files (inherit)`);
|
|
197
|
-
};
|
|
198
|
-
await (themeConfig.inherit ?? []).reduce(async (promise, packageName) => {
|
|
199
|
-
await promise;
|
|
200
|
-
await processInheritedPackage(packageName);
|
|
201
|
-
}, Promise.resolve());
|
|
202
|
-
const mainSafelist = require_safelist.deduplicateSafelist([...inheritedClasses, ...require_safelist.getThemeAndScaleClasses(colorModes)]);
|
|
203
|
-
const allMotionComponents = [...inheritedComponents];
|
|
204
|
-
const mainCssResult = await require_generate.generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
|
|
205
|
-
scope: options.scope,
|
|
206
|
-
contentDir: node_path.default.join(workspaceDir, entry),
|
|
207
|
-
cssOptions: themeConfig.css,
|
|
208
|
-
safeVarPrefixes: [...require_utils.getMotionVarPrefixes(context.componentData, allMotionComponents), ...require_utils.getConfigurableCssVariables()]
|
|
209
|
-
});
|
|
210
|
-
const outputDir = node_path.default.dirname(outputPath);
|
|
211
|
-
if (!node_fs.default.existsSync(outputDir)) node_fs.default.mkdirSync(outputDir, { recursive: true });
|
|
212
|
-
node_fs.default.writeFileSync(outputPath, mainCssResult.css);
|
|
213
|
-
genLog.spinStop("✅", require_runner_helpers.getMainCssSummaryMessage({
|
|
214
|
-
sizeGzipBytes: mainCssResult.sizeGzipBytes,
|
|
215
|
-
optimizationStats: mainCssResult.optimizationStats,
|
|
216
|
-
formatBytes: require_utils.formatBytes
|
|
217
|
-
}));
|
|
218
|
-
const duration = Math.round(performance.now() - genStartTime);
|
|
219
|
-
genLog.newline();
|
|
220
|
-
genLog.print(require_colors.green("CSS generation complete!"));
|
|
221
|
-
genLog.newline();
|
|
222
|
-
genLog.label("Output file:", outputPath);
|
|
223
|
-
genLog.newline();
|
|
224
|
-
genLog.print(`${require_colors.magenta("Total time:")} ${duration}ms`);
|
|
225
|
-
return {
|
|
226
|
-
duration,
|
|
227
|
-
outputPath,
|
|
228
|
-
packageDirs
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
await generateThemeModeCSS();
|
|
232
|
-
if (options.watch) {
|
|
233
|
-
const entryDir = node_path.default.join(workspaceDir, entry);
|
|
234
|
-
const { watchDirs, filteredPackageDirs } = require_runner_helpers.getWatchDirectoryGroups(entryDir, [entryDir, ...packageDirs]);
|
|
235
|
-
if (!effectiveSilent) {
|
|
236
|
-
log.newline();
|
|
237
|
-
log.print(`${require_colors.magenta("Watching for changes...")}`);
|
|
238
|
-
log.listItem(`App: ${entryDir}`);
|
|
239
|
-
filteredPackageDirs.forEach((dir) => {
|
|
240
|
-
log.listItem(`Package: ${dir}`);
|
|
241
|
-
});
|
|
242
|
-
log.print(`${require_colors.gray("Press Ctrl+C to stop")}`);
|
|
243
|
-
log.newline();
|
|
244
|
-
}
|
|
245
|
-
const regenerate = createQueuedRegenerator({
|
|
246
|
-
onStart: () => {
|
|
247
|
-
if (!effectiveSilent) {
|
|
248
|
-
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
249
|
-
log.print(`${require_colors.gray(`[${timestamp}]`)} Change detected, regenerating...`);
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
regenerateOnce: async () => generateThemeModeCSS({ isWatch: true }),
|
|
253
|
-
onSuccess: (result) => {
|
|
254
|
-
if (!effectiveSilent) {
|
|
255
|
-
const updatedAt = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
256
|
-
log.print(`${require_colors.gray(`[${updatedAt}]`)} ${require_colors.green(`CSS updated (${result?.duration}ms)`)}`);
|
|
257
|
-
log.newline();
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
onError: (message) => {
|
|
261
|
-
log.print(message);
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
watchSourceFiles(watchDirs, createDebouncedAction(() => {
|
|
265
|
-
regenerate();
|
|
266
|
-
}, themeConfig.css?.watchDebounce ?? 100));
|
|
267
|
-
await new Promise(() => {});
|
|
268
|
-
}
|
|
269
|
-
} catch (error) {
|
|
270
|
-
const message = error instanceof Error ? error.message : "CSS generation failed";
|
|
271
|
-
if (effectiveSilent) require_spinner.spinStop("❌", message);
|
|
272
|
-
else log.spinStop("❌", message);
|
|
273
|
-
process.exitCode = 1;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
//#endregion
|
|
278
|
-
exports.runCssCommand = runCssCommand;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let node_path = require("node:path");
|
|
4
|
-
node_path = require_runtime.__toESM(node_path);
|
|
5
|
-
|
|
6
|
-
//#region ../tailwind/dist/css/runner.helpers.js
|
|
7
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
8
|
-
const getMainCssSummaryMessage = (options) => {
|
|
9
|
-
const { optimizationStats, sizeGzipBytes, formatBytes } = options;
|
|
10
|
-
if (!optimizationStats) return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip`;
|
|
11
|
-
const { originalSizeGzip, fontFacesRemoved, emptyRulesRemoved } = optimizationStats;
|
|
12
|
-
const savedBytesGzip = originalSizeGzip - sizeGzipBytes;
|
|
13
|
-
if (savedBytesGzip <= 0) return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip`;
|
|
14
|
-
return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip)(optimized: saved ${formatBytes(savedBytesGzip)} gzip, ${fontFacesRemoved} unused @font-face, ${emptyRulesRemoved} empty rules removed)`;
|
|
15
|
-
};
|
|
16
|
-
const getWatchDirectoryGroups = (entryDir, dirs) => {
|
|
17
|
-
const watchDirs = [...new Set(dirs.filter((dir) => !dir.split(node_path.default.sep).includes("node_modules")))];
|
|
18
|
-
return {
|
|
19
|
-
watchDirs,
|
|
20
|
-
filteredPackageDirs: watchDirs.filter((dir) => dir !== entryDir)
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.getMainCssSummaryMessage = getMainCssSummaryMessage;
|
|
26
|
-
exports.getWatchDirectoryGroups = getWatchDirectoryGroups;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
//#region ../tailwind/dist/css/runner.helpers.js
|
|
5
|
-
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
6
|
-
const getMainCssSummaryMessage = (options) => {
|
|
7
|
-
const { optimizationStats, sizeGzipBytes, formatBytes } = options;
|
|
8
|
-
if (!optimizationStats) return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip`;
|
|
9
|
-
const { originalSizeGzip, fontFacesRemoved, emptyRulesRemoved } = optimizationStats;
|
|
10
|
-
const savedBytesGzip = originalSizeGzip - sizeGzipBytes;
|
|
11
|
-
if (savedBytesGzip <= 0) return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip`;
|
|
12
|
-
return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip)(optimized: saved ${formatBytes(savedBytesGzip)} gzip, ${fontFacesRemoved} unused @font-face, ${emptyRulesRemoved} empty rules removed)`;
|
|
13
|
-
};
|
|
14
|
-
const getWatchDirectoryGroups = (entryDir, dirs) => {
|
|
15
|
-
const watchDirs = [...new Set(dirs.filter((dir) => !dir.split(path.sep).includes("node_modules")))];
|
|
16
|
-
return {
|
|
17
|
-
watchDirs,
|
|
18
|
-
filteredPackageDirs: watchDirs.filter((dir) => dir !== entryDir)
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
export { getMainCssSummaryMessage, getWatchDirectoryGroups };
|