@yahoo/uds 3.116.0-beta.3 → 3.116.1
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 +0 -10
- package/dist/automated-config/dist/generated/autoVariants.d.cts +0 -10
- package/dist/automated-config/dist/generated/autoVariants.d.ts +0 -10
- package/dist/automated-config/dist/generated/autoVariants.js +0 -10
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +0 -1842
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +1 -194
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +1 -194
- package/dist/automated-config/dist/generated/generatedConfigs.js +1 -1842
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +0 -78
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +1 -2
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +1 -2
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +0 -78
- package/dist/cli/commands/sync.cjs +0 -6
- package/dist/cli/commands/sync.js +0 -6
- 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/Toast/Toast.cjs +3 -3
- package/dist/components/client/Toast/Toast.d.cts +1 -1
- package/dist/components/client/Toast/Toast.d.ts +1 -1
- package/dist/components/client/Toast/Toast.js +3 -3
- package/dist/components/client/Toast/index.d.cts +1 -1
- package/dist/components/client/Toast/index.d.ts +1 -1
- package/dist/components/client/Tooltip/Tooltip.cjs +6 -6
- package/dist/components/client/Tooltip/Tooltip.d.cts +1 -1
- package/dist/components/client/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/client/Tooltip/Tooltip.js +6 -6
- package/dist/components/client/Tooltip/TooltipContent.cjs +96 -33
- package/dist/components/client/Tooltip/TooltipContent.js +97 -34
- package/dist/components/client/Tooltip/tooltipContext.cjs +1 -0
- package/dist/components/client/Tooltip/tooltipContext.d.cts +2 -1
- package/dist/components/client/Tooltip/tooltipContext.d.ts +2 -1
- package/dist/components/client/Tooltip/tooltipContext.js +1 -0
- package/dist/components/client/Tooltip/useTooltipContent.cjs +186 -0
- package/dist/components/client/Tooltip/useTooltipContent.d.cts +66 -0
- package/dist/components/client/Tooltip/useTooltipContent.d.ts +66 -0
- package/dist/{hooks/useSvgFloatingContent.js → components/client/Tooltip/useTooltipContent.js} +44 -94
- package/dist/components/client/Tooltip/util.cjs +248 -0
- package/dist/{utils/svgFloatingContentUtils.d.cts → components/client/Tooltip/util.d.cts} +62 -25
- package/dist/{utils/svgFloatingContentUtils.d.ts → components/client/Tooltip/util.d.ts} +62 -25
- package/dist/components/client/Tooltip/util.js +240 -0
- package/dist/components/client/index.cjs +0 -8
- package/dist/components/client/index.d.cts +5 -10
- package/dist/components/client/index.d.ts +5 -10
- package/dist/components/client/index.js +1 -5
- package/dist/components/client/providers/UDSConfigProvider.cjs +2 -6
- package/dist/components/client/providers/UDSConfigProvider.d.cts +1 -2
- package/dist/components/client/providers/UDSConfigProvider.d.ts +1 -2
- package/dist/components/client/providers/UDSConfigProvider.js +2 -6
- package/dist/components/experimental/client/{ExperimentalPopover.cjs → Popover.cjs} +1 -10
- package/dist/components/experimental/client/Popover.d.cts +29 -0
- package/dist/components/experimental/client/Popover.d.ts +29 -0
- package/dist/components/experimental/client/{ExperimentalPopover.js → Popover.js} +1 -10
- package/dist/components/experimental/client/index.cjs +10 -10
- package/dist/components/experimental/client/index.d.cts +2 -2
- package/dist/components/experimental/client/index.d.ts +2 -2
- package/dist/components/experimental/client/index.js +1 -1
- package/dist/components/experimental/index.cjs +19 -19
- package/dist/components/experimental/index.d.cts +2 -2
- package/dist/components/experimental/index.d.ts +2 -2
- package/dist/components/experimental/index.js +1 -1
- package/dist/components/index.cjs +0 -12
- package/dist/components/index.d.cts +5 -9
- package/dist/components/index.d.ts +5 -9
- package/dist/components/index.js +1 -9
- package/dist/config/dist/index.cjs +1 -79
- package/dist/config/dist/index.js +1 -79
- package/dist/index.cjs +10 -21
- package/dist/index.d.cts +10 -15
- package/dist/index.d.ts +10 -15
- package/dist/index.js +11 -16
- package/dist/runtime/index.cjs +0 -2
- package/dist/runtime/index.d.cts +2 -3
- package/dist/runtime/index.d.ts +2 -3
- package/dist/runtime/index.js +1 -2
- package/dist/runtime/udsConfig.cjs +1 -3
- package/dist/runtime/udsConfig.d.cts +1 -3
- package/dist/runtime/udsConfig.d.ts +1 -3
- package/dist/runtime/udsConfig.js +1 -3
- package/dist/styles/styler.d.cts +44 -54
- package/dist/styles/styler.d.ts +44 -54
- package/dist/styles/variants.d.cts +0 -30
- package/dist/styles/variants.d.ts +0 -30
- package/dist/tailwind/dist/commands/css.helpers.cjs +6 -2
- package/dist/tailwind/dist/commands/css.helpers.js +6 -2
- package/dist/tailwind/dist/commands/generateComponentData.cjs +2 -0
- package/dist/tailwind/dist/commands/generateComponentData.js +3 -1
- package/dist/tailwind/dist/commands/generatePurgeCSSData.cjs +3 -8
- package/dist/tailwind/dist/commands/generatePurgeCSSData.js +3 -8
- package/dist/tailwind/dist/commands/purge.cjs +2 -2
- package/dist/tailwind/dist/commands/purge.js +2 -2
- package/dist/tailwind/dist/css/generate.cjs +6 -4
- package/dist/tailwind/dist/css/generate.helpers.cjs +4 -1
- package/dist/tailwind/dist/css/generate.helpers.js +4 -1
- package/dist/tailwind/dist/css/generate.js +7 -5
- package/dist/tailwind/dist/css/nodeUtils.cjs +30 -2
- package/dist/tailwind/dist/css/nodeUtils.js +30 -3
- package/dist/tailwind/dist/css/postcss.cjs +1 -1
- package/dist/tailwind/dist/css/postcss.helpers.cjs +8 -6
- package/dist/tailwind/dist/css/postcss.helpers.js +8 -6
- package/dist/tailwind/dist/css/postcss.js +1 -1
- package/dist/tailwind/dist/css/runner.cjs +52 -19
- package/dist/tailwind/dist/css/runner.helpers.cjs +2 -2
- package/dist/tailwind/dist/css/runner.helpers.js +2 -2
- package/dist/tailwind/dist/css/runner.js +53 -20
- package/dist/tailwind/dist/css/theme.d.cts +2 -2
- package/dist/tailwind/dist/css/theme.d.ts +2 -2
- package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +19 -8
- package/dist/tailwind/dist/purger/legacy/purgeCSS.js +19 -8
- package/dist/tailwind/dist/purger/optimized/purge.cjs +2 -1
- package/dist/tailwind/dist/purger/optimized/purge.js +2 -1
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +22 -2
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +22 -2
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +5 -4
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +5 -4
- package/dist/tailwind/dist/purger/optimized/utils/files.cjs +12 -10
- package/dist/tailwind/dist/purger/optimized/utils/files.js +12 -9
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +0 -1
- package/dist/tailwind/dist/tailwind/plugins/components.js +1 -2
- package/dist/tailwind/dist/tailwind/plugins/getTailwindAsUdsColors.cjs +294 -10
- package/dist/tailwind/dist/tailwind/plugins/getTailwindAsUdsColors.js +294 -9
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.cts +1 -1
- package/dist/tailwind/dist/tailwind/utils/getFontStyles.d.ts +1 -1
- package/dist/tailwind/dist/utils/entryPoints.cjs +63 -0
- package/dist/tailwind/dist/utils/entryPoints.js +55 -0
- package/dist/tokens/automation/configs/index.cjs +0 -1
- 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 +0 -1
- 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 +1 -2
- package/dist/tokens/index.d.cts +3 -3
- package/dist/tokens/index.d.ts +3 -3
- package/dist/tokens/index.js +3 -3
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +1 -51
- package/dist/types/dist/index.d.ts +1 -51
- package/dist/uds/generated/componentData.cjs +149 -293
- package/dist/uds/generated/componentData.js +144 -258
- package/dist/uds/generated/tailwindPurge.cjs +222 -249
- package/dist/uds/generated/tailwindPurge.js +222 -249
- package/dist/uds/package.cjs +2 -2
- package/dist/uds/package.js +2 -2
- package/generated/componentData.json +161 -309
- package/generated/tailwindPurge.ts +5 -4604
- package/package.json +3 -3
- package/dist/components/SvgFloatingOverlay.cjs +0 -122
- package/dist/components/SvgFloatingOverlay.d.cts +0 -42
- package/dist/components/SvgFloatingOverlay.d.ts +0 -42
- package/dist/components/SvgFloatingOverlay.js +0 -120
- package/dist/components/client/Popover/Popover.cjs +0 -96
- package/dist/components/client/Popover/Popover.d.cts +0 -55
- package/dist/components/client/Popover/Popover.d.ts +0 -55
- package/dist/components/client/Popover/Popover.js +0 -94
- package/dist/components/client/Popover/PopoverContent.cjs +0 -174
- package/dist/components/client/Popover/PopoverContent.d.cts +0 -26
- package/dist/components/client/Popover/PopoverContent.d.ts +0 -26
- package/dist/components/client/Popover/PopoverContent.js +0 -172
- package/dist/components/client/Popover/PopoverContext.cjs +0 -11
- package/dist/components/client/Popover/PopoverContext.d.cts +0 -21
- package/dist/components/client/Popover/PopoverContext.d.ts +0 -21
- package/dist/components/client/Popover/PopoverContext.js +0 -9
- package/dist/components/client/Popover/PopoverTrigger.cjs +0 -26
- package/dist/components/client/Popover/PopoverTrigger.d.cts +0 -14
- package/dist/components/client/Popover/PopoverTrigger.d.ts +0 -14
- package/dist/components/client/Popover/PopoverTrigger.js +0 -24
- package/dist/components/client/Popover/UDSPopoverConfigProvider.cjs +0 -40
- package/dist/components/client/Popover/UDSPopoverConfigProvider.d.cts +0 -28
- package/dist/components/client/Popover/UDSPopoverConfigProvider.d.ts +0 -28
- package/dist/components/client/Popover/UDSPopoverConfigProvider.js +0 -37
- package/dist/components/client/Popover/index.cjs +0 -12
- package/dist/components/client/Popover/index.d.cts +0 -7
- package/dist/components/client/Popover/index.d.ts +0 -7
- package/dist/components/client/Popover/index.js +0 -8
- package/dist/components/experimental/client/ExperimentalPopover.d.cts +0 -40
- package/dist/components/experimental/client/ExperimentalPopover.d.ts +0 -40
- package/dist/hooks/useSvgFloatingContent.cjs +0 -236
- package/dist/hooks/useSvgFloatingContent.d.cts +0 -74
- package/dist/hooks/useSvgFloatingContent.d.ts +0 -74
- package/dist/runtime/popoverConfig.cjs +0 -41
- package/dist/runtime/popoverConfig.d.cts +0 -24
- package/dist/runtime/popoverConfig.d.ts +0 -24
- package/dist/runtime/popoverConfig.js +0 -40
- package/dist/tailwind/dist/.prettierrc.cjs +0 -13
- package/dist/tailwind/dist/.prettierrc.js +0 -12
- package/dist/utils/parseShadow.cjs +0 -120
- package/dist/utils/parseShadow.d.cts +0 -33
- package/dist/utils/parseShadow.d.ts +0 -33
- package/dist/utils/parseShadow.js +0 -118
- package/dist/utils/svgFloatingContentUtils.cjs +0 -121
- package/dist/utils/svgFloatingContentUtils.js +0 -117
|
@@ -3,6 +3,7 @@ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_index = require('../../../config/dist/index.cjs');
|
|
4
4
|
const require_colors = require('../../../cli/dist/lib/colors.cjs');
|
|
5
5
|
const require_print = require('../../../cli/dist/lib/print.cjs');
|
|
6
|
+
const require_entryPoints = require('../utils/entryPoints.cjs');
|
|
6
7
|
const require_spinner = require('../../../cli/dist/lib/spinner.cjs');
|
|
7
8
|
const require_logger = require('../../../cli/dist/lib/logger.cjs');
|
|
8
9
|
const require_nodeUtils = require('./nodeUtils.cjs');
|
|
@@ -17,13 +18,34 @@ node_fs = require_runtime.__toESM(node_fs);
|
|
|
17
18
|
|
|
18
19
|
//#region ../tailwind/dist/css/runner.js
|
|
19
20
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
20
|
-
const DEFAULT_ENTRY = "./src";
|
|
21
21
|
const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/i;
|
|
22
22
|
const getWatchDirs = (dirs) => [...new Set(dirs.filter((dir) => !dir.split(node_path.default.sep).includes("node_modules")))];
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const isCoveredByRecursiveWatch = (watchPath, targetPath) => targetPath === watchPath || targetPath.startsWith(`${watchPath}${node_path.default.sep}`);
|
|
24
|
+
const getEntryWatchTargets = (entries) => {
|
|
25
|
+
const directoryTargets = getWatchDirs(entries.filter((entry) => entry.kind === "directory").map((entry) => entry.absolutePath)).map((watchPath) => ({
|
|
26
|
+
watchPath,
|
|
27
|
+
recursive: true
|
|
28
|
+
}));
|
|
29
|
+
const fileNamesByDirectory = /* @__PURE__ */ new Map();
|
|
30
|
+
entries.filter((entry) => entry.kind === "file" && typeof entry.fileName === "string").forEach((entry) => {
|
|
31
|
+
if (directoryTargets.some((target) => isCoveredByRecursiveWatch(target.watchPath, entry.absolutePath))) return;
|
|
32
|
+
const fileNames = fileNamesByDirectory.get(entry.watchDirectory) ?? /* @__PURE__ */ new Set();
|
|
33
|
+
fileNames.add(entry.fileName);
|
|
34
|
+
fileNamesByDirectory.set(entry.watchDirectory, fileNames);
|
|
35
|
+
});
|
|
36
|
+
const fileTargets = [...fileNamesByDirectory.entries()].map(([watchPath, fileNames]) => ({
|
|
37
|
+
watchPath,
|
|
38
|
+
recursive: false,
|
|
39
|
+
fileNames: [...fileNames]
|
|
40
|
+
}));
|
|
41
|
+
return [...directoryTargets, ...fileTargets];
|
|
42
|
+
};
|
|
43
|
+
const watchSourceFiles = (targets, onFileChange) => {
|
|
44
|
+
targets.forEach((target) => {
|
|
45
|
+
node_fs.default.watch(target.watchPath, { recursive: target.recursive }, (_eventType, filename) => {
|
|
46
|
+
if (!filename || !SOURCE_FILE_PATTERN.test(filename)) return;
|
|
47
|
+
if (target.fileNames && !target.fileNames.includes(node_path.default.basename(String(filename)))) return;
|
|
48
|
+
onFileChange();
|
|
27
49
|
});
|
|
28
50
|
});
|
|
29
51
|
};
|
|
@@ -68,7 +90,7 @@ const runCssCommand = async (options, context) => {
|
|
|
68
90
|
await runThemeMode(options, context);
|
|
69
91
|
};
|
|
70
92
|
const runSimpleMode = async (options, context) => {
|
|
71
|
-
const entry =
|
|
93
|
+
const entry = options.entryOption ?? require_entryPoints.DEFAULT_ENTRY;
|
|
72
94
|
const configPath = typeof options.configOption === "string" ? options.configOption : void 0;
|
|
73
95
|
if (!options.watch && !options.silent) require_spinner.spinStart("Generating CSS...");
|
|
74
96
|
try {
|
|
@@ -91,12 +113,16 @@ const runSimpleMode = async (options, context) => {
|
|
|
91
113
|
}
|
|
92
114
|
};
|
|
93
115
|
const runSimpleModeWatch = async (options, context, entry, configPath, packageDirs) => {
|
|
94
|
-
const
|
|
95
|
-
const
|
|
116
|
+
const entryWatchTargets = getEntryWatchTargets(require_entryPoints.resolveEntryPaths(entry, options.workspaceDir));
|
|
117
|
+
const fallbackTargets = getWatchDirs(packageDirs).map((watchPath) => ({
|
|
118
|
+
watchPath,
|
|
119
|
+
recursive: true
|
|
120
|
+
}));
|
|
121
|
+
const watchTargets = packageDirs.length > 0 ? fallbackTargets : entryWatchTargets;
|
|
96
122
|
if (!options.silent) {
|
|
97
123
|
require_print.print("");
|
|
98
124
|
require_print.print(`${require_colors.magenta("Watching for changes...")}`);
|
|
99
|
-
|
|
125
|
+
watchTargets.forEach((target) => require_print.print(` ${require_colors.gray("•")} ${target.watchPath}`));
|
|
100
126
|
require_print.print(`${require_colors.gray("Press Ctrl+C to stop")}`);
|
|
101
127
|
require_print.print("");
|
|
102
128
|
}
|
|
@@ -128,7 +154,7 @@ const runSimpleModeWatch = async (options, context, entry, configPath, packageDi
|
|
|
128
154
|
require_print.print(`Error: ${message}`);
|
|
129
155
|
}
|
|
130
156
|
});
|
|
131
|
-
watchSourceFiles(
|
|
157
|
+
watchSourceFiles(watchTargets, createDebouncedAction(() => {
|
|
132
158
|
regenerate();
|
|
133
159
|
}, 100));
|
|
134
160
|
await new Promise(() => {});
|
|
@@ -149,7 +175,7 @@ const loadThemeModeSetup = async (options) => {
|
|
|
149
175
|
return {
|
|
150
176
|
themeConfig,
|
|
151
177
|
colorModes: themeConfig.colorModes ?? ["dark"],
|
|
152
|
-
|
|
178
|
+
entries: require_entryPoints.resolveEntryPaths(themeConfig.entry, options.workspaceDir),
|
|
153
179
|
appConfig,
|
|
154
180
|
appVariantDefaults: require_utils.extractVariantDefaults(appConfig),
|
|
155
181
|
effectiveSilent: options.silent || themeConfig.silent === true
|
|
@@ -168,9 +194,10 @@ const runThemeMode = async (options, context) => {
|
|
|
168
194
|
process.exitCode = 1;
|
|
169
195
|
return;
|
|
170
196
|
}
|
|
171
|
-
const { themeConfig, colorModes,
|
|
197
|
+
const { themeConfig, colorModes, entries, appConfig, appVariantDefaults } = setup;
|
|
172
198
|
effectiveSilent = setup.effectiveSilent;
|
|
173
199
|
log = require_logger.createLogger({ silent: effectiveSilent });
|
|
200
|
+
const entryDirs = entries.map((entry) => entry.absolutePath);
|
|
174
201
|
if (!effectiveSilent) log.spinStop("✅", "Theme configuration loaded");
|
|
175
202
|
if (themeConfig.config && appConfig === require_index.defaultTokensConfig) log.warn(`App config not found: ${themeConfig.config}, using defaults`);
|
|
176
203
|
const packageDirs = [];
|
|
@@ -178,7 +205,7 @@ const runThemeMode = async (options, context) => {
|
|
|
178
205
|
const genStartTime = performance.now();
|
|
179
206
|
const genLog = opts?.isWatch ? require_logger.createLogger({ silent: true }) : log;
|
|
180
207
|
genLog.spinStart("Scanning app code...");
|
|
181
|
-
const appScanResult = await require_nodeUtils.
|
|
208
|
+
const appScanResult = await require_nodeUtils.scanDirectoriesForSafelist(entryDirs, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults);
|
|
182
209
|
genLog.spinStop("✅", `Scanned ${appScanResult.filesScanned} files`);
|
|
183
210
|
genLog.spinStart("Generating main CSS...");
|
|
184
211
|
const inheritedClasses = [...appScanResult.safelist];
|
|
@@ -204,7 +231,7 @@ const runThemeMode = async (options, context) => {
|
|
|
204
231
|
const allMotionComponents = [...inheritedComponents];
|
|
205
232
|
const mainCssResult = await require_generate.generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
|
|
206
233
|
scope: options.scope,
|
|
207
|
-
contentDir:
|
|
234
|
+
contentDir: entryDirs,
|
|
208
235
|
cssOptions: themeConfig.css,
|
|
209
236
|
safeVarPrefixes: [...require_utils.getMotionVarPrefixes(context.componentData, allMotionComponents), ...require_utils.getConfigurableCssVariables()]
|
|
210
237
|
});
|
|
@@ -231,12 +258,14 @@ const runThemeMode = async (options, context) => {
|
|
|
231
258
|
};
|
|
232
259
|
await generateThemeModeCSS();
|
|
233
260
|
if (options.watch) {
|
|
234
|
-
const
|
|
235
|
-
const {
|
|
261
|
+
const entryWatchTargets = getEntryWatchTargets(entries);
|
|
262
|
+
const { filteredPackageDirs } = require_runner_helpers.getWatchDirectoryGroups(getWatchDirs(entryWatchTargets.map((target) => target.watchPath)), [...entryDirs, ...packageDirs]);
|
|
236
263
|
if (!effectiveSilent) {
|
|
237
264
|
log.newline();
|
|
238
265
|
log.print(`${require_colors.magenta("Watching for changes...")}`);
|
|
239
|
-
|
|
266
|
+
entryDirs.forEach((entryDir) => {
|
|
267
|
+
log.listItem(`App: ${entryDir}`);
|
|
268
|
+
});
|
|
240
269
|
filteredPackageDirs.forEach((dir) => {
|
|
241
270
|
log.listItem(`Package: ${dir}`);
|
|
242
271
|
});
|
|
@@ -262,9 +291,13 @@ const runThemeMode = async (options, context) => {
|
|
|
262
291
|
log.print(message);
|
|
263
292
|
}
|
|
264
293
|
});
|
|
265
|
-
|
|
294
|
+
const watchDebounce = themeConfig.css?.watchDebounce ?? 100;
|
|
295
|
+
watchSourceFiles([...entryWatchTargets, ...filteredPackageDirs.filter((packageDir) => !entryWatchTargets.some((target) => isCoveredByRecursiveWatch(target.watchPath, packageDir))).map((watchPath) => ({
|
|
296
|
+
watchPath,
|
|
297
|
+
recursive: true
|
|
298
|
+
}))], createDebouncedAction(() => {
|
|
266
299
|
regenerate();
|
|
267
|
-
},
|
|
300
|
+
}, watchDebounce));
|
|
268
301
|
await new Promise(() => {});
|
|
269
302
|
}
|
|
270
303
|
} catch (error) {
|
|
@@ -13,11 +13,11 @@ const getMainCssSummaryMessage = (options) => {
|
|
|
13
13
|
if (savedBytesGzip <= 0) return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip`;
|
|
14
14
|
return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip)(optimized: saved ${formatBytes(savedBytesGzip)} gzip, ${fontFacesRemoved} unused @font-face, ${emptyRulesRemoved} empty rules removed)`;
|
|
15
15
|
};
|
|
16
|
-
const getWatchDirectoryGroups = (
|
|
16
|
+
const getWatchDirectoryGroups = (entryDirs, dirs) => {
|
|
17
17
|
const watchDirs = [...new Set(dirs.filter((dir) => !dir.split(node_path.default.sep).includes("node_modules")))];
|
|
18
18
|
return {
|
|
19
19
|
watchDirs,
|
|
20
|
-
filteredPackageDirs: watchDirs.filter((dir) => dir
|
|
20
|
+
filteredPackageDirs: watchDirs.filter((dir) => !entryDirs.includes(dir))
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -11,11 +11,11 @@ const getMainCssSummaryMessage = (options) => {
|
|
|
11
11
|
if (savedBytesGzip <= 0) return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip`;
|
|
12
12
|
return `Main CSS: ${formatBytes(sizeGzipBytes)} gzip)(optimized: saved ${formatBytes(savedBytesGzip)} gzip, ${fontFacesRemoved} unused @font-face, ${emptyRulesRemoved} empty rules removed)`;
|
|
13
13
|
};
|
|
14
|
-
const getWatchDirectoryGroups = (
|
|
14
|
+
const getWatchDirectoryGroups = (entryDirs, dirs) => {
|
|
15
15
|
const watchDirs = [...new Set(dirs.filter((dir) => !dir.split(path.sep).includes("node_modules")))];
|
|
16
16
|
return {
|
|
17
17
|
watchDirs,
|
|
18
|
-
filteredPackageDirs: watchDirs.filter((dir) => dir
|
|
18
|
+
filteredPackageDirs: watchDirs.filter((dir) => !entryDirs.includes(dir))
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { defaultTokensConfig } from "../../../config/dist/index.js";
|
|
3
3
|
import { gray, green, magenta } from "../../../cli/dist/lib/colors.js";
|
|
4
4
|
import { print } from "../../../cli/dist/lib/print.js";
|
|
5
|
+
import { DEFAULT_ENTRY, resolveEntryPaths } from "../utils/entryPoints.js";
|
|
5
6
|
import { spinStart, spinStop } from "../../../cli/dist/lib/spinner.js";
|
|
6
7
|
import { createLogger } from "../../../cli/dist/lib/logger.js";
|
|
7
|
-
import { findPackageSourceDir, loadConfigFile, scanDirectoryForSafelist } from "./nodeUtils.js";
|
|
8
|
+
import { findPackageSourceDir, loadConfigFile, scanDirectoriesForSafelist, scanDirectoryForSafelist } from "./nodeUtils.js";
|
|
8
9
|
import { deduplicateSafelist, getThemeAndScaleClasses } from "../purger/optimized/utils/safelist.js";
|
|
9
10
|
import { extractVariantDefaults, formatBytes, getConfigurableCssVariables, getMotionVarPrefixes } from "./utils.js";
|
|
10
11
|
import { generateCSS, generateSimpleModeCSS } from "./generate.js";
|
|
@@ -14,13 +15,34 @@ import fs from "node:fs";
|
|
|
14
15
|
|
|
15
16
|
//#region ../tailwind/dist/css/runner.js
|
|
16
17
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
17
|
-
const DEFAULT_ENTRY = "./src";
|
|
18
18
|
const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/i;
|
|
19
19
|
const getWatchDirs = (dirs) => [...new Set(dirs.filter((dir) => !dir.split(path.sep).includes("node_modules")))];
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const isCoveredByRecursiveWatch = (watchPath, targetPath) => targetPath === watchPath || targetPath.startsWith(`${watchPath}${path.sep}`);
|
|
21
|
+
const getEntryWatchTargets = (entries) => {
|
|
22
|
+
const directoryTargets = getWatchDirs(entries.filter((entry) => entry.kind === "directory").map((entry) => entry.absolutePath)).map((watchPath) => ({
|
|
23
|
+
watchPath,
|
|
24
|
+
recursive: true
|
|
25
|
+
}));
|
|
26
|
+
const fileNamesByDirectory = /* @__PURE__ */ new Map();
|
|
27
|
+
entries.filter((entry) => entry.kind === "file" && typeof entry.fileName === "string").forEach((entry) => {
|
|
28
|
+
if (directoryTargets.some((target) => isCoveredByRecursiveWatch(target.watchPath, entry.absolutePath))) return;
|
|
29
|
+
const fileNames = fileNamesByDirectory.get(entry.watchDirectory) ?? /* @__PURE__ */ new Set();
|
|
30
|
+
fileNames.add(entry.fileName);
|
|
31
|
+
fileNamesByDirectory.set(entry.watchDirectory, fileNames);
|
|
32
|
+
});
|
|
33
|
+
const fileTargets = [...fileNamesByDirectory.entries()].map(([watchPath, fileNames]) => ({
|
|
34
|
+
watchPath,
|
|
35
|
+
recursive: false,
|
|
36
|
+
fileNames: [...fileNames]
|
|
37
|
+
}));
|
|
38
|
+
return [...directoryTargets, ...fileTargets];
|
|
39
|
+
};
|
|
40
|
+
const watchSourceFiles = (targets, onFileChange) => {
|
|
41
|
+
targets.forEach((target) => {
|
|
42
|
+
fs.watch(target.watchPath, { recursive: target.recursive }, (_eventType, filename) => {
|
|
43
|
+
if (!filename || !SOURCE_FILE_PATTERN.test(filename)) return;
|
|
44
|
+
if (target.fileNames && !target.fileNames.includes(path.basename(String(filename)))) return;
|
|
45
|
+
onFileChange();
|
|
24
46
|
});
|
|
25
47
|
});
|
|
26
48
|
};
|
|
@@ -65,7 +87,7 @@ const runCssCommand = async (options, context) => {
|
|
|
65
87
|
await runThemeMode(options, context);
|
|
66
88
|
};
|
|
67
89
|
const runSimpleMode = async (options, context) => {
|
|
68
|
-
const entry =
|
|
90
|
+
const entry = options.entryOption ?? DEFAULT_ENTRY;
|
|
69
91
|
const configPath = typeof options.configOption === "string" ? options.configOption : void 0;
|
|
70
92
|
if (!options.watch && !options.silent) spinStart("Generating CSS...");
|
|
71
93
|
try {
|
|
@@ -88,12 +110,16 @@ const runSimpleMode = async (options, context) => {
|
|
|
88
110
|
}
|
|
89
111
|
};
|
|
90
112
|
const runSimpleModeWatch = async (options, context, entry, configPath, packageDirs) => {
|
|
91
|
-
const
|
|
92
|
-
const
|
|
113
|
+
const entryWatchTargets = getEntryWatchTargets(resolveEntryPaths(entry, options.workspaceDir));
|
|
114
|
+
const fallbackTargets = getWatchDirs(packageDirs).map((watchPath) => ({
|
|
115
|
+
watchPath,
|
|
116
|
+
recursive: true
|
|
117
|
+
}));
|
|
118
|
+
const watchTargets = packageDirs.length > 0 ? fallbackTargets : entryWatchTargets;
|
|
93
119
|
if (!options.silent) {
|
|
94
120
|
print("");
|
|
95
121
|
print(`${magenta("Watching for changes...")}`);
|
|
96
|
-
|
|
122
|
+
watchTargets.forEach((target) => print(` ${gray("•")} ${target.watchPath}`));
|
|
97
123
|
print(`${gray("Press Ctrl+C to stop")}`);
|
|
98
124
|
print("");
|
|
99
125
|
}
|
|
@@ -125,7 +151,7 @@ const runSimpleModeWatch = async (options, context, entry, configPath, packageDi
|
|
|
125
151
|
print(`Error: ${message}`);
|
|
126
152
|
}
|
|
127
153
|
});
|
|
128
|
-
watchSourceFiles(
|
|
154
|
+
watchSourceFiles(watchTargets, createDebouncedAction(() => {
|
|
129
155
|
regenerate();
|
|
130
156
|
}, 100));
|
|
131
157
|
await new Promise(() => {});
|
|
@@ -146,7 +172,7 @@ const loadThemeModeSetup = async (options) => {
|
|
|
146
172
|
return {
|
|
147
173
|
themeConfig,
|
|
148
174
|
colorModes: themeConfig.colorModes ?? ["dark"],
|
|
149
|
-
|
|
175
|
+
entries: resolveEntryPaths(themeConfig.entry, options.workspaceDir),
|
|
150
176
|
appConfig,
|
|
151
177
|
appVariantDefaults: extractVariantDefaults(appConfig),
|
|
152
178
|
effectiveSilent: options.silent || themeConfig.silent === true
|
|
@@ -165,9 +191,10 @@ const runThemeMode = async (options, context) => {
|
|
|
165
191
|
process.exitCode = 1;
|
|
166
192
|
return;
|
|
167
193
|
}
|
|
168
|
-
const { themeConfig, colorModes,
|
|
194
|
+
const { themeConfig, colorModes, entries, appConfig, appVariantDefaults } = setup;
|
|
169
195
|
effectiveSilent = setup.effectiveSilent;
|
|
170
196
|
log = createLogger({ silent: effectiveSilent });
|
|
197
|
+
const entryDirs = entries.map((entry) => entry.absolutePath);
|
|
171
198
|
if (!effectiveSilent) log.spinStop("✅", "Theme configuration loaded");
|
|
172
199
|
if (themeConfig.config && appConfig === defaultTokensConfig) log.warn(`App config not found: ${themeConfig.config}, using defaults`);
|
|
173
200
|
const packageDirs = [];
|
|
@@ -175,7 +202,7 @@ const runThemeMode = async (options, context) => {
|
|
|
175
202
|
const genStartTime = performance.now();
|
|
176
203
|
const genLog = opts?.isWatch ? createLogger({ silent: true }) : log;
|
|
177
204
|
genLog.spinStart("Scanning app code...");
|
|
178
|
-
const appScanResult = await
|
|
205
|
+
const appScanResult = await scanDirectoriesForSafelist(entryDirs, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults);
|
|
179
206
|
genLog.spinStop("✅", `Scanned ${appScanResult.filesScanned} files`);
|
|
180
207
|
genLog.spinStart("Generating main CSS...");
|
|
181
208
|
const inheritedClasses = [...appScanResult.safelist];
|
|
@@ -201,7 +228,7 @@ const runThemeMode = async (options, context) => {
|
|
|
201
228
|
const allMotionComponents = [...inheritedComponents];
|
|
202
229
|
const mainCssResult = await generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
|
|
203
230
|
scope: options.scope,
|
|
204
|
-
contentDir:
|
|
231
|
+
contentDir: entryDirs,
|
|
205
232
|
cssOptions: themeConfig.css,
|
|
206
233
|
safeVarPrefixes: [...getMotionVarPrefixes(context.componentData, allMotionComponents), ...getConfigurableCssVariables()]
|
|
207
234
|
});
|
|
@@ -228,12 +255,14 @@ const runThemeMode = async (options, context) => {
|
|
|
228
255
|
};
|
|
229
256
|
await generateThemeModeCSS();
|
|
230
257
|
if (options.watch) {
|
|
231
|
-
const
|
|
232
|
-
const {
|
|
258
|
+
const entryWatchTargets = getEntryWatchTargets(entries);
|
|
259
|
+
const { filteredPackageDirs } = getWatchDirectoryGroups(getWatchDirs(entryWatchTargets.map((target) => target.watchPath)), [...entryDirs, ...packageDirs]);
|
|
233
260
|
if (!effectiveSilent) {
|
|
234
261
|
log.newline();
|
|
235
262
|
log.print(`${magenta("Watching for changes...")}`);
|
|
236
|
-
|
|
263
|
+
entryDirs.forEach((entryDir) => {
|
|
264
|
+
log.listItem(`App: ${entryDir}`);
|
|
265
|
+
});
|
|
237
266
|
filteredPackageDirs.forEach((dir) => {
|
|
238
267
|
log.listItem(`Package: ${dir}`);
|
|
239
268
|
});
|
|
@@ -259,9 +288,13 @@ const runThemeMode = async (options, context) => {
|
|
|
259
288
|
log.print(message);
|
|
260
289
|
}
|
|
261
290
|
});
|
|
262
|
-
|
|
291
|
+
const watchDebounce = themeConfig.css?.watchDebounce ?? 100;
|
|
292
|
+
watchSourceFiles([...entryWatchTargets, ...filteredPackageDirs.filter((packageDir) => !entryWatchTargets.some((target) => isCoveredByRecursiveWatch(target.watchPath, packageDir))).map((watchPath) => ({
|
|
293
|
+
watchPath,
|
|
294
|
+
recursive: true
|
|
295
|
+
}))], createDebouncedAction(() => {
|
|
263
296
|
regenerate();
|
|
264
|
-
},
|
|
297
|
+
}, watchDebounce));
|
|
265
298
|
await new Promise(() => {});
|
|
266
299
|
}
|
|
267
300
|
} catch (error) {
|
|
@@ -39,8 +39,8 @@ interface UDSCSSOptimizationOptions {
|
|
|
39
39
|
interface UDSThemeConfig {
|
|
40
40
|
/** Path to app's uds.config (relative to project root) */
|
|
41
41
|
config?: string;
|
|
42
|
-
/** Entry directory
|
|
43
|
-
entry?: string;
|
|
42
|
+
/** Entry directory path or .tsx file path, or a list of those paths (default: './src') */
|
|
43
|
+
entry?: string | string[];
|
|
44
44
|
/** Suppress log output during generation (default: false) */
|
|
45
45
|
silent?: boolean;
|
|
46
46
|
/**
|
|
@@ -39,8 +39,8 @@ interface UDSCSSOptimizationOptions {
|
|
|
39
39
|
interface UDSThemeConfig {
|
|
40
40
|
/** Path to app's uds.config (relative to project root) */
|
|
41
41
|
config?: string;
|
|
42
|
-
/** Entry directory
|
|
43
|
-
entry?: string;
|
|
42
|
+
/** Entry directory path or .tsx file path, or a list of those paths (default: './src') */
|
|
43
|
+
entry?: string | string[];
|
|
44
44
|
/** Suppress log output during generation (default: false) */
|
|
45
45
|
silent?: boolean;
|
|
46
46
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_index = require('../../../../css-tokens/dist/index.cjs');
|
|
4
4
|
const require_print = require('../../../../cli/dist/lib/print.cjs');
|
|
5
|
+
const require_entryPoints = require('../../utils/entryPoints.cjs');
|
|
5
6
|
const require_spinner = require('../../../../cli/dist/lib/spinner.cjs');
|
|
6
7
|
const require_tsMorph = require('../../utils/tsMorph.cjs');
|
|
7
8
|
let node_path = require("node:path");
|
|
@@ -30,13 +31,17 @@ const getFiles = async (entry) => {
|
|
|
30
31
|
try {
|
|
31
32
|
const workspaceDir = process.env.PWD || process.cwd();
|
|
32
33
|
if (!workspaceDir) throw new Error("Workspace directory not found.");
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const files = await Promise.all(require_entryPoints.resolveEntryPaths(entry, workspaceDir, require_entryPoints.DEFAULT_ENTRY).map((entryPath) => {
|
|
35
|
+
if (entryPath.kind === "file") return [entryPath.absolutePath];
|
|
36
|
+
return (0, fast_glob.default)(["**/*.jsx", "**/*.tsx"], {
|
|
37
|
+
cwd: entryPath.absolutePath,
|
|
38
|
+
absolute: true,
|
|
39
|
+
ignore: ["**/node_modules/**"]
|
|
40
|
+
});
|
|
41
|
+
}));
|
|
42
|
+
return [...new Set(files.flat())];
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw error instanceof Error ? error : /* @__PURE__ */ new Error(`Couldn't find the entry directory: ${entry}. Please make sure it exists.`);
|
|
40
45
|
}
|
|
41
46
|
};
|
|
42
47
|
/**
|
|
@@ -219,7 +224,13 @@ const scanGetStylesReferences = (project, variants, packageJson) => {
|
|
|
219
224
|
}
|
|
220
225
|
return usedProps;
|
|
221
226
|
};
|
|
222
|
-
|
|
227
|
+
const applyPurgeDefaults = (options = {}) => ({
|
|
228
|
+
config: options.config ?? process.env.UDS_OUT_FILE ?? "./uds.config.ts",
|
|
229
|
+
output: options.output ?? "dist/safelist.ts",
|
|
230
|
+
entry: options.entry ?? require_entryPoints.DEFAULT_ENTRY
|
|
231
|
+
});
|
|
232
|
+
async function purge(variants, packageJson, generatedPurgeCssData, options = {}) {
|
|
233
|
+
const { config: configPath, output, entry } = applyPurgeDefaults(options);
|
|
223
234
|
const workspaceDir = process.env.PWD || process.cwd();
|
|
224
235
|
if (!workspaceDir) throw new Error("Workspace directory not found.");
|
|
225
236
|
const project = new ts_morph.Project({ tsConfigFilePath: node_path.default.join(workspaceDir, "/tsconfig.json") });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { DARK_COLOR_MODE_CLASSNAME, LARGE_SCALE_MODE_CLASSNAME, LIGHT_COLOR_MODE_CLASSNAME, MEDIUM_SCALE_MODE_CLASSNAME, SMALL_SCALE_MODE_CLASSNAME, XLARGE_SCALE_MODE_CLASSNAME, XSMALL_SCALE_MODE_CLASSNAME, XXLARGE_SCALE_MODE_CLASSNAME, XXXLARGE_SCALE_MODE_CLASSNAME } from "../../../../css-tokens/dist/index.js";
|
|
3
3
|
import { print } from "../../../../cli/dist/lib/print.js";
|
|
4
|
+
import { DEFAULT_ENTRY, resolveEntryPaths } from "../../utils/entryPoints.js";
|
|
4
5
|
import { spinStart, spinStop } from "../../../../cli/dist/lib/spinner.js";
|
|
5
6
|
import { findReferencesAsJsxElements, getUsedPropsInReference } from "../../utils/tsMorph.js";
|
|
6
7
|
import path from "node:path";
|
|
@@ -27,13 +28,17 @@ const getFiles = async (entry) => {
|
|
|
27
28
|
try {
|
|
28
29
|
const workspaceDir = process.env.PWD || process.cwd();
|
|
29
30
|
if (!workspaceDir) throw new Error("Workspace directory not found.");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const files = await Promise.all(resolveEntryPaths(entry, workspaceDir, DEFAULT_ENTRY).map((entryPath) => {
|
|
32
|
+
if (entryPath.kind === "file") return [entryPath.absolutePath];
|
|
33
|
+
return fg(["**/*.jsx", "**/*.tsx"], {
|
|
34
|
+
cwd: entryPath.absolutePath,
|
|
35
|
+
absolute: true,
|
|
36
|
+
ignore: ["**/node_modules/**"]
|
|
37
|
+
});
|
|
38
|
+
}));
|
|
39
|
+
return [...new Set(files.flat())];
|
|
40
|
+
} catch (error) {
|
|
41
|
+
throw error instanceof Error ? error : /* @__PURE__ */ new Error(`Couldn't find the entry directory: ${entry}. Please make sure it exists.`);
|
|
37
42
|
}
|
|
38
43
|
};
|
|
39
44
|
/**
|
|
@@ -216,7 +221,13 @@ const scanGetStylesReferences = (project, variants, packageJson) => {
|
|
|
216
221
|
}
|
|
217
222
|
return usedProps;
|
|
218
223
|
};
|
|
219
|
-
|
|
224
|
+
const applyPurgeDefaults = (options = {}) => ({
|
|
225
|
+
config: options.config ?? process.env.UDS_OUT_FILE ?? "./uds.config.ts",
|
|
226
|
+
output: options.output ?? "dist/safelist.ts",
|
|
227
|
+
entry: options.entry ?? DEFAULT_ENTRY
|
|
228
|
+
});
|
|
229
|
+
async function purge(variants, packageJson, generatedPurgeCssData, options = {}) {
|
|
230
|
+
const { config: configPath, output, entry } = applyPurgeDefaults(options);
|
|
220
231
|
const workspaceDir = process.env.PWD || process.cwd();
|
|
221
232
|
if (!workspaceDir) throw new Error("Workspace directory not found.");
|
|
222
233
|
const project = new Project({ tsConfigFilePath: path.join(workspaceDir, "/tsconfig.json") });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_purgeFromCode = require('./purgeFromCode.cjs');
|
|
4
|
+
const require_entryPoints = require('../../utils/entryPoints.cjs');
|
|
4
5
|
const require_safelist = require('./utils/safelist.cjs');
|
|
5
6
|
const require_files = require('./utils/files.cjs');
|
|
6
7
|
let node_path = require("node:path");
|
|
@@ -24,7 +25,7 @@ const clearWarnings = () => {
|
|
|
24
25
|
* between CLI and playground.
|
|
25
26
|
*/
|
|
26
27
|
const purgeOptimized = async (options) => {
|
|
27
|
-
const { entry =
|
|
28
|
+
const { entry = require_entryPoints.DEFAULT_ENTRY, output = "dist/safelist.ts", colorModes = ["dark"], variants, autoVariants, componentData } = options;
|
|
28
29
|
const startTime = performance.now();
|
|
29
30
|
clearWarnings();
|
|
30
31
|
const workspaceDir = process.env.PWD ?? process.cwd();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { purgeFromCodeOptimized } from "./purgeFromCode.js";
|
|
3
|
+
import { DEFAULT_ENTRY } from "../../utils/entryPoints.js";
|
|
3
4
|
import { deduplicateSafelist, getThemeAndScaleClasses, saveSafelistToFile } from "./utils/safelist.js";
|
|
4
5
|
import { scanForFiles } from "./utils/files.js";
|
|
5
6
|
import path from "node:path";
|
|
@@ -21,7 +22,7 @@ const clearWarnings = () => {
|
|
|
21
22
|
* between CLI and playground.
|
|
22
23
|
*/
|
|
23
24
|
const purgeOptimized = async (options) => {
|
|
24
|
-
const { entry =
|
|
25
|
+
const { entry = DEFAULT_ENTRY, output = "dist/safelist.ts", colorModes = ["dark"], variants, autoVariants, componentData } = options;
|
|
25
26
|
const startTime = performance.now();
|
|
26
27
|
clearWarnings();
|
|
27
28
|
const workspaceDir = process.env.PWD ?? process.cwd();
|
|
@@ -266,12 +266,32 @@ const purgeFromCodeOptimized = async (code, options) => {
|
|
|
266
266
|
*/
|
|
267
267
|
const findComponentReferences = (sourceFile, componentName) => {
|
|
268
268
|
const references = [];
|
|
269
|
+
const seenTags = /* @__PURE__ */ new Set();
|
|
270
|
+
const collectMatchingTags = (localName) => {
|
|
271
|
+
sourceFile.getDescendants().filter((node) => ts_morph.Node.isJsxOpeningElement(node) || ts_morph.Node.isJsxSelfClosingElement(node)).forEach((node) => {
|
|
272
|
+
const tagName = node.getTagNameNode().getText();
|
|
273
|
+
if (tagName === localName || tagName.startsWith(`${localName}.`)) {
|
|
274
|
+
const key = `${tagName}:${node.getStart()}`;
|
|
275
|
+
if (!seenTags.has(key)) {
|
|
276
|
+
seenTags.add(key);
|
|
277
|
+
references.push(node);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
};
|
|
269
282
|
sourceFile.getImportDeclarations().forEach((importDecl) => {
|
|
270
283
|
if (!isUdsComponentModule(getModuleSpecifierValue(importDecl))) return;
|
|
271
284
|
importDecl.getNamedImports().forEach((namedImport) => {
|
|
272
285
|
if (namedImport.getName() === componentName) {
|
|
273
|
-
const
|
|
274
|
-
|
|
286
|
+
const localName = namedImport.getAliasNode()?.getText() ?? componentName;
|
|
287
|
+
require_jsx.findJsxReferences(namedImport.getFirstDescendantByKindOrThrow(ts_morph.ts.SyntaxKind.Identifier)).forEach((reference) => {
|
|
288
|
+
const key = `${reference.getTagNameNode().getText()}:${reference.getStart()}`;
|
|
289
|
+
if (!seenTags.has(key)) {
|
|
290
|
+
seenTags.add(key);
|
|
291
|
+
references.push(reference);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
collectMatchingTags(localName);
|
|
275
295
|
}
|
|
276
296
|
});
|
|
277
297
|
});
|
|
@@ -265,12 +265,32 @@ const purgeFromCodeOptimized = async (code, options) => {
|
|
|
265
265
|
*/
|
|
266
266
|
const findComponentReferences = (sourceFile, componentName) => {
|
|
267
267
|
const references = [];
|
|
268
|
+
const seenTags = /* @__PURE__ */ new Set();
|
|
269
|
+
const collectMatchingTags = (localName) => {
|
|
270
|
+
sourceFile.getDescendants().filter((node) => Node.isJsxOpeningElement(node) || Node.isJsxSelfClosingElement(node)).forEach((node) => {
|
|
271
|
+
const tagName = node.getTagNameNode().getText();
|
|
272
|
+
if (tagName === localName || tagName.startsWith(`${localName}.`)) {
|
|
273
|
+
const key = `${tagName}:${node.getStart()}`;
|
|
274
|
+
if (!seenTags.has(key)) {
|
|
275
|
+
seenTags.add(key);
|
|
276
|
+
references.push(node);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
};
|
|
268
281
|
sourceFile.getImportDeclarations().forEach((importDecl) => {
|
|
269
282
|
if (!isUdsComponentModule(getModuleSpecifierValue(importDecl))) return;
|
|
270
283
|
importDecl.getNamedImports().forEach((namedImport) => {
|
|
271
284
|
if (namedImport.getName() === componentName) {
|
|
272
|
-
const
|
|
273
|
-
|
|
285
|
+
const localName = namedImport.getAliasNode()?.getText() ?? componentName;
|
|
286
|
+
findJsxReferences(namedImport.getFirstDescendantByKindOrThrow(ts.SyntaxKind.Identifier)).forEach((reference) => {
|
|
287
|
+
const key = `${reference.getTagNameNode().getText()}:${reference.getStart()}`;
|
|
288
|
+
if (!seenTags.has(key)) {
|
|
289
|
+
seenTags.add(key);
|
|
290
|
+
references.push(reference);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
collectMatchingTags(localName);
|
|
274
294
|
}
|
|
275
295
|
});
|
|
276
296
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_runtime = require('../../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_index = require('../../../../../motion-tokens/dist/index.cjs');
|
|
4
|
+
const require_entryPoints = require('../../../utils/entryPoints.cjs');
|
|
4
5
|
let node_path = require("node:path");
|
|
5
6
|
node_path = require_runtime.__toESM(node_path);
|
|
6
7
|
let node_fs = require("node:fs");
|
|
@@ -19,7 +20,7 @@ let knownComponents = null;
|
|
|
19
20
|
*/
|
|
20
21
|
let componentPaths = null;
|
|
21
22
|
let scannedComponentsDir = null;
|
|
22
|
-
const scanComponentFilePaths = async (componentsDir) => (0, fast_glob.default)(
|
|
23
|
+
const scanComponentFilePaths = async (componentsDir) => (0, fast_glob.default)(require_entryPoints.getAllowedEntryFileGlobPatterns(), {
|
|
23
24
|
cwd: componentsDir,
|
|
24
25
|
absolute: true
|
|
25
26
|
});
|
|
@@ -34,8 +35,8 @@ const scanComponentFiles = async (componentsDir) => {
|
|
|
34
35
|
const nextComponentPaths = componentPaths;
|
|
35
36
|
const nextKnownComponents = knownComponents;
|
|
36
37
|
(await scanComponentFilePaths(componentsDir)).forEach((file) => {
|
|
37
|
-
if (file.includes(".test.") ||
|
|
38
|
-
const fileName = node_path.default.basename(file
|
|
38
|
+
if (file.includes(".test.") || node_path.default.basename(require_entryPoints.stripAllowedEntryFileExtension(file)) === "index") return;
|
|
39
|
+
const fileName = node_path.default.basename(require_entryPoints.stripAllowedEntryFileExtension(file));
|
|
39
40
|
if (/^[A-Z]/.test(fileName)) {
|
|
40
41
|
nextComponentPaths.set(fileName, file);
|
|
41
42
|
nextKnownComponents.add(fileName);
|
|
@@ -110,7 +111,7 @@ const analyzeVariantSpreadAssignment = (prop, styleProps, getStylesLiterals, pro
|
|
|
110
111
|
const analyzeComponent = (project, componentPath) => {
|
|
111
112
|
const sourceFile = project.getSourceFile(componentPath);
|
|
112
113
|
if (!sourceFile) return null;
|
|
113
|
-
const componentName = node_path.default.basename(componentPath
|
|
114
|
+
const componentName = node_path.default.basename(require_entryPoints.stripAllowedEntryFileExtension(componentPath));
|
|
114
115
|
const defaultProps = /* @__PURE__ */ new Map();
|
|
115
116
|
const componentPropNames = /* @__PURE__ */ new Set();
|
|
116
117
|
const styleProps = [];
|