@yahoo/uds 3.134.0 → 3.134.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cli/dist/lib/args.cjs +7 -3
  2. package/dist/cli/dist/lib/args.js +7 -3
  3. package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
  4. package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
  5. package/dist/components/client/Toast/UDSToastConfigProvider.d.cts +1 -1
  6. package/dist/components/client/Toast/UDSToastConfigProvider.d.ts +1 -1
  7. package/dist/index.d.cts +2 -2
  8. package/dist/index.d.ts +2 -2
  9. package/dist/styles/styler.d.cts +21 -21
  10. package/dist/styles/styler.d.ts +21 -21
  11. package/dist/tailwind/dist/commands/css.cjs +1 -0
  12. package/dist/tailwind/dist/commands/css.d.cts.map +1 -1
  13. package/dist/tailwind/dist/commands/css.d.ts.map +1 -1
  14. package/dist/tailwind/dist/commands/css.helpers.cjs +8 -1
  15. package/dist/tailwind/dist/commands/css.helpers.js +8 -1
  16. package/dist/tailwind/dist/commands/css.helpers.js.map +1 -1
  17. package/dist/tailwind/dist/commands/css.js +1 -0
  18. package/dist/tailwind/dist/commands/css.js.map +1 -1
  19. package/dist/tailwind/dist/css/generate.cjs +7 -4
  20. package/dist/tailwind/dist/css/generate.d.cts.map +1 -1
  21. package/dist/tailwind/dist/css/generate.d.ts.map +1 -1
  22. package/dist/tailwind/dist/css/generate.js +7 -4
  23. package/dist/tailwind/dist/css/generate.js.map +1 -1
  24. package/dist/tailwind/dist/css/nodeUtils.cjs +19 -8
  25. package/dist/tailwind/dist/css/nodeUtils.js +19 -8
  26. package/dist/tailwind/dist/css/nodeUtils.js.map +1 -1
  27. package/dist/tailwind/dist/css/perf.cjs +92 -0
  28. package/dist/tailwind/dist/css/perf.js +89 -0
  29. package/dist/tailwind/dist/css/perf.js.map +1 -0
  30. package/dist/tailwind/dist/css/purgeWorker.cjs +47 -0
  31. package/dist/tailwind/dist/css/purgeWorker.d.cts +2 -0
  32. package/dist/tailwind/dist/css/purgeWorker.d.ts +2 -0
  33. package/dist/tailwind/dist/css/purgeWorker.js +48 -0
  34. package/dist/tailwind/dist/css/purgeWorker.js.map +1 -0
  35. package/dist/tailwind/dist/css/runner.cjs +158 -145
  36. package/dist/tailwind/dist/css/runner.js +158 -145
  37. package/dist/tailwind/dist/css/runner.js.map +1 -1
  38. package/dist/tailwind/dist/css/theme.d.cts +1 -1
  39. package/dist/tailwind/dist/css/theme.d.ts +1 -1
  40. package/dist/tailwind/dist/css/workerPool.cjs +89 -0
  41. package/dist/tailwind/dist/css/workerPool.js +90 -0
  42. package/dist/tailwind/dist/css/workerPool.js.map +1 -0
  43. package/dist/tailwind/dist/index.d.cts +2 -2
  44. package/dist/tailwind/dist/index.d.ts +2 -2
  45. package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +95 -15
  46. package/dist/tailwind/dist/purger/optimized/ast/expressions.js +95 -15
  47. package/dist/tailwind/dist/purger/optimized/ast/expressions.js.map +1 -1
  48. package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +38 -14
  49. package/dist/tailwind/dist/purger/optimized/purgeFromCode.d.cts.map +1 -1
  50. package/dist/tailwind/dist/purger/optimized/purgeFromCode.d.ts.map +1 -1
  51. package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +39 -15
  52. package/dist/tailwind/dist/purger/optimized/purgeFromCode.js.map +1 -1
  53. package/dist/tailwind/dist/purger/optimized/types.d.cts +10 -0
  54. package/dist/tailwind/dist/purger/optimized/types.d.cts.map +1 -1
  55. package/dist/tailwind/dist/purger/optimized/types.d.ts +10 -0
  56. package/dist/tailwind/dist/purger/optimized/types.d.ts.map +1 -1
  57. package/dist/uds/generated/componentData.cjs +271 -271
  58. package/dist/uds/generated/componentData.js +271 -271
  59. package/generated/componentData.json +361 -361
  60. package/package.json +1 -1
  61. package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +0 -16
  62. package/dist/tailwind/dist/purger/optimized/ast/jsx.js +0 -17
  63. package/dist/tailwind/dist/purger/optimized/ast/jsx.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
2
+ import { performance } from "node:perf_hooks";
3
+ //#region src/css/perf.ts
4
+ const PERF_PREFIX = "uds:css:";
5
+ const isPerfEnabled = () => process.env.UDS_PERF === "1";
6
+ const memorySnapshots = [];
7
+ const captureMemory = (label) => {
8
+ if (!isPerfEnabled()) return;
9
+ const mem = process.memoryUsage();
10
+ memorySnapshots.push({
11
+ label,
12
+ rss: mem.rss,
13
+ heapUsed: mem.heapUsed,
14
+ heapTotal: mem.heapTotal,
15
+ external: mem.external,
16
+ timestamp: performance.now()
17
+ });
18
+ };
19
+ const measureAsync = async (name, fn, detail) => {
20
+ if (!isPerfEnabled()) return fn();
21
+ const markName = `${PERF_PREFIX}${name}`;
22
+ const startMark = `${markName}:start`;
23
+ const endMark = `${markName}:end`;
24
+ performance.mark(startMark, { detail });
25
+ const result = await fn();
26
+ performance.mark(endMark);
27
+ performance.measure(markName, startMark, endMark);
28
+ return result;
29
+ };
30
+ const collectTimings = () => {
31
+ return performance.getEntriesByType("measure").filter((entry) => entry.name.startsWith(PERF_PREFIX)).map((entry) => ({
32
+ name: entry.name.slice(8),
33
+ durationMs: Math.round(entry.duration * 100) / 100,
34
+ startTime: Math.round(entry.startTime * 100) / 100,
35
+ detail: entry.detail
36
+ }));
37
+ };
38
+ const collectPerfData = () => ({
39
+ timings: collectTimings(),
40
+ memory: [...memorySnapshots]
41
+ });
42
+ const clearTimings = () => {
43
+ performance.clearMarks();
44
+ performance.clearMeasures();
45
+ memorySnapshots.length = 0;
46
+ };
47
+ const formatMs = (ms) => {
48
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
49
+ return `${(ms / 1e3).toFixed(1)}s`;
50
+ };
51
+ const formatMemoryMB = (bytes) => `${(bytes / 1024 / 1024).toFixed(0)} MB`;
52
+ const formatTimingTree = (timings, totalMs) => {
53
+ const lines = [];
54
+ const grouped = /* @__PURE__ */ new Map();
55
+ for (const entry of timings) {
56
+ const group = entry.name.split(":")[0] ?? "other";
57
+ const existing = grouped.get(group) ?? [];
58
+ existing.push(entry);
59
+ grouped.set(group, existing);
60
+ }
61
+ for (const [group, entries] of grouped) {
62
+ const topLevel = entries.filter((e) => e.name === group || e.name.split(":").length === 1).sort((a, b) => b.durationMs - a.durationMs)[0];
63
+ const subEntries = entries.filter((e) => e.name !== group && e.name.startsWith(`${group}:`));
64
+ if (topLevel) {
65
+ const pct = totalMs > 0 ? (topLevel.durationMs / totalMs * 100).toFixed(1) : "0.0";
66
+ lines.push(` ${group}: ${formatMs(topLevel.durationMs)} (${pct}%)`);
67
+ }
68
+ for (const sub of subEntries.sort((a, b) => b.durationMs - a.durationMs)) {
69
+ const subName = sub.name.slice(group.length + 1);
70
+ lines.push(` ├─ ${subName}: ${formatMs(sub.durationMs)}`);
71
+ }
72
+ }
73
+ return lines.join("\n");
74
+ };
75
+ const printPerfSummary = (totalMs) => {
76
+ if (!isPerfEnabled()) return;
77
+ const data = collectPerfData();
78
+ console.log("\n\x1B[35mPhase breakdown:\x1B[0m");
79
+ console.log(formatTimingTree(data.timings, totalMs));
80
+ if (data.memory.length > 0) {
81
+ const peak = data.memory.reduce((max, snap) => snap.rss > max.rss ? snap : max, data.memory[0]);
82
+ console.log(` Peak memory: ${formatMemoryMB(peak.rss)} RSS, ${formatMemoryMB(peak.heapUsed)} heap`);
83
+ }
84
+ console.log("");
85
+ };
86
+ //#endregion
87
+ export { captureMemory, clearTimings, isPerfEnabled, measureAsync, printPerfSummary };
88
+
89
+ //# sourceMappingURL=perf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perf.js","names":[],"sources":["../../src/css/perf.ts"],"sourcesContent":["import { performance } from 'node:perf_hooks';\n\nconst PERF_PREFIX = 'uds:css:';\n\nconst isPerfEnabled = (): boolean => process.env.UDS_PERF === '1';\n\n// --- Types ---\n\ntype MemorySnapshot = {\n label: string;\n rss: number;\n heapUsed: number;\n heapTotal: number;\n external: number;\n timestamp: number;\n};\n\ntype TimingEntry = {\n name: string;\n durationMs: number;\n startTime: number;\n detail?: unknown;\n};\n\ntype PerfData = {\n timings: TimingEntry[];\n memory: MemorySnapshot[];\n};\n\n// --- Memory tracking ---\n\nconst memorySnapshots: MemorySnapshot[] = [];\n\nconst captureMemory = (label: string): void => {\n if (!isPerfEnabled()) {\n return;\n }\n\n const mem = process.memoryUsage();\n memorySnapshots.push({\n label,\n rss: mem.rss,\n heapUsed: mem.heapUsed,\n heapTotal: mem.heapTotal,\n external: mem.external,\n timestamp: performance.now(),\n });\n};\n\n// --- Synchronous measurement ---\n\nconst measureSync = <T>(name: string, fn: () => T, detail?: unknown): T => {\n if (!isPerfEnabled()) {\n return fn();\n }\n\n const markName = `${PERF_PREFIX}${name}`;\n const startMark = `${markName}:start`;\n const endMark = `${markName}:end`;\n\n performance.mark(startMark, { detail });\n const result = fn();\n performance.mark(endMark);\n performance.measure(markName, startMark, endMark);\n\n return result;\n};\n\n// --- Asynchronous measurement ---\n\nconst measureAsync = async <T>(\n name: string,\n fn: () => Promise<T>,\n detail?: unknown,\n): Promise<T> => {\n if (!isPerfEnabled()) {\n return fn();\n }\n\n const markName = `${PERF_PREFIX}${name}`;\n const startMark = `${markName}:start`;\n const endMark = `${markName}:end`;\n\n performance.mark(startMark, { detail });\n const result = await fn();\n performance.mark(endMark);\n performance.measure(markName, startMark, endMark);\n\n return result;\n};\n\n// --- Collecting results ---\n\nconst collectTimings = (): TimingEntry[] => {\n return performance\n .getEntriesByType('measure')\n .filter((entry) => entry.name.startsWith(PERF_PREFIX))\n .map((entry) => ({\n name: entry.name.slice(PERF_PREFIX.length),\n durationMs: Math.round(entry.duration * 100) / 100,\n startTime: Math.round(entry.startTime * 100) / 100,\n detail: (entry as PerformanceMeasure).detail,\n }));\n};\n\nconst collectPerfData = (): PerfData => ({\n timings: collectTimings(),\n memory: [...memorySnapshots],\n});\n\nconst clearTimings = (): void => {\n performance.clearMarks();\n performance.clearMeasures();\n memorySnapshots.length = 0;\n};\n\n// --- Formatting ---\n\nconst formatMs = (ms: number): string => {\n if (ms < 1000) {\n return `${Math.round(ms)}ms`;\n }\n\n return `${(ms / 1000).toFixed(1)}s`;\n};\n\nconst formatMemoryMB = (bytes: number): string => `${(bytes / 1024 / 1024).toFixed(0)} MB`;\n\nconst formatTimingTree = (timings: TimingEntry[], totalMs: number): string => {\n const lines: string[] = [];\n const grouped = new Map<string, TimingEntry[]>();\n\n // Group by first segment (e.g., \"scan\", \"gen\", \"opt\")\n for (const entry of timings) {\n const segments = entry.name.split(':');\n const group = segments[0] ?? 'other';\n const existing = grouped.get(group) ?? [];\n existing.push(entry);\n grouped.set(group, existing);\n }\n\n for (const [group, entries] of grouped) {\n // Find the top-level entry for this group (shortest name)\n const topLevel = entries\n .filter((e) => e.name === group || e.name.split(':').length === 1)\n .sort((a, b) => b.durationMs - a.durationMs)[0];\n\n const subEntries = entries.filter((e) => e.name !== group && e.name.startsWith(`${group}:`));\n\n if (topLevel) {\n const pct = totalMs > 0 ? ((topLevel.durationMs / totalMs) * 100).toFixed(1) : '0.0';\n lines.push(` ${group}: ${formatMs(topLevel.durationMs)} (${pct}%)`);\n }\n\n for (const sub of subEntries.sort((a, b) => b.durationMs - a.durationMs)) {\n const subName = sub.name.slice(group.length + 1);\n lines.push(` ├─ ${subName}: ${formatMs(sub.durationMs)}`);\n }\n }\n\n return lines.join('\\n');\n};\n\nconst printPerfSummary = (totalMs: number): void => {\n if (!isPerfEnabled()) {\n return;\n }\n\n const data = collectPerfData();\n\n console.log('\\n\\x1b[35mPhase breakdown:\\x1b[0m');\n console.log(formatTimingTree(data.timings, totalMs));\n\n if (data.memory.length > 0) {\n const peak = data.memory.reduce(\n (max, snap) => (snap.rss > max.rss ? snap : max),\n data.memory[0]!,\n );\n console.log(\n ` Peak memory: ${formatMemoryMB(peak.rss)} RSS, ${formatMemoryMB(peak.heapUsed)} heap`,\n );\n }\n\n console.log('');\n};\n\nexport {\n captureMemory,\n clearTimings,\n collectPerfData,\n collectTimings,\n formatMemoryMB,\n formatMs,\n formatTimingTree,\n isPerfEnabled,\n measureAsync,\n measureSync,\n PERF_PREFIX,\n printPerfSummary,\n};\n\nexport type { MemorySnapshot, PerfData, TimingEntry };\n"],"mappings":"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"}
@@ -0,0 +1,47 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_purgeFromCode = require("../purger/optimized/purgeFromCode.cjs");
4
+ let node_worker_threads = require("node:worker_threads");
5
+ //#region src/css/purgeWorker.ts
6
+ let sharedConfig = null;
7
+ node_worker_threads.parentPort?.on("message", async (msg) => {
8
+ if (msg.type === "init") {
9
+ sharedConfig = msg.config;
10
+ node_worker_threads.parentPort?.postMessage({ type: "ready" });
11
+ return;
12
+ }
13
+ if (msg.type === "task") {
14
+ if (!sharedConfig) {
15
+ node_worker_threads.parentPort?.postMessage({
16
+ type: "error",
17
+ id: msg.id,
18
+ error: "Worker not initialized"
19
+ });
20
+ return;
21
+ }
22
+ try {
23
+ const result = await require_purgeFromCode.purgeFromCodeOptimized(msg.code, {
24
+ ...sharedConfig,
25
+ colorModes: msg.colorModes,
26
+ variantDefaults: msg.variantDefaults,
27
+ runtimeConfigValues: msg.runtimeConfigValues,
28
+ includeAllClassNamePrimitives: msg.includeAllClassNamePrimitives,
29
+ filePath: msg.filePath
30
+ });
31
+ node_worker_threads.parentPort?.postMessage({
32
+ type: "result",
33
+ id: msg.id,
34
+ result
35
+ });
36
+ } catch (error) {
37
+ node_worker_threads.parentPort?.postMessage({
38
+ type: "error",
39
+ id: msg.id,
40
+ error: error instanceof Error ? error.message : String(error)
41
+ });
42
+ }
43
+ return;
44
+ }
45
+ if (msg.type === "done") process.exit(0);
46
+ });
47
+ //#endregion
@@ -0,0 +1,2 @@
1
+
2
+ export { };
@@ -0,0 +1,2 @@
1
+
2
+ export { };
@@ -0,0 +1,48 @@
1
+ /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
2
+ import { purgeFromCodeOptimized } from "../purger/optimized/purgeFromCode.js";
3
+ import { parentPort } from "node:worker_threads";
4
+ //#region src/css/purgeWorker.ts
5
+ let sharedConfig = null;
6
+ parentPort?.on("message", async (msg) => {
7
+ if (msg.type === "init") {
8
+ sharedConfig = msg.config;
9
+ parentPort?.postMessage({ type: "ready" });
10
+ return;
11
+ }
12
+ if (msg.type === "task") {
13
+ if (!sharedConfig) {
14
+ parentPort?.postMessage({
15
+ type: "error",
16
+ id: msg.id,
17
+ error: "Worker not initialized"
18
+ });
19
+ return;
20
+ }
21
+ try {
22
+ const result = await purgeFromCodeOptimized(msg.code, {
23
+ ...sharedConfig,
24
+ colorModes: msg.colorModes,
25
+ variantDefaults: msg.variantDefaults,
26
+ runtimeConfigValues: msg.runtimeConfigValues,
27
+ includeAllClassNamePrimitives: msg.includeAllClassNamePrimitives,
28
+ filePath: msg.filePath
29
+ });
30
+ parentPort?.postMessage({
31
+ type: "result",
32
+ id: msg.id,
33
+ result
34
+ });
35
+ } catch (error) {
36
+ parentPort?.postMessage({
37
+ type: "error",
38
+ id: msg.id,
39
+ error: error instanceof Error ? error.message : String(error)
40
+ });
41
+ }
42
+ return;
43
+ }
44
+ if (msg.type === "done") process.exit(0);
45
+ });
46
+ //#endregion
47
+
48
+ //# sourceMappingURL=purgeWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purgeWorker.js","names":[],"sources":["../../src/css/purgeWorker.ts"],"sourcesContent":["import { parentPort } from 'node:worker_threads';\n\nimport type { PurgeFromCodeOptions } from '../purger/optimized/purgeFromCode';\nimport { purgeFromCodeOptimized } from '../purger/optimized/purgeFromCode';\n\ntype SharedConfig = Pick<PurgeFromCodeOptions, 'variants' | 'autoVariants' | 'componentData'>;\n\ntype InitMessage = {\n type: 'init';\n config: SharedConfig;\n};\n\ntype TaskMessage = {\n type: 'task';\n id: number;\n code: string;\n filePath: string;\n colorModes?: ('dark' | 'light')[];\n variantDefaults?: PurgeFromCodeOptions['variantDefaults'];\n runtimeConfigValues?: PurgeFromCodeOptions['runtimeConfigValues'];\n includeAllClassNamePrimitives?: boolean;\n};\n\ntype DoneMessage = {\n type: 'done';\n};\n\ntype WorkerMessage = DoneMessage | InitMessage | TaskMessage;\n\nlet sharedConfig: SharedConfig | null = null;\n\nparentPort?.on('message', async (msg: WorkerMessage) => {\n if (msg.type === 'init') {\n sharedConfig = msg.config;\n parentPort?.postMessage({ type: 'ready' });\n return;\n }\n\n if (msg.type === 'task') {\n if (!sharedConfig) {\n parentPort?.postMessage({ type: 'error', id: msg.id, error: 'Worker not initialized' });\n return;\n }\n\n try {\n const result = await purgeFromCodeOptimized(msg.code, {\n ...sharedConfig,\n colorModes: msg.colorModes,\n variantDefaults: msg.variantDefaults,\n runtimeConfigValues: msg.runtimeConfigValues,\n includeAllClassNamePrimitives: msg.includeAllClassNamePrimitives,\n filePath: msg.filePath,\n });\n parentPort?.postMessage({ type: 'result', id: msg.id, result });\n } catch (error) {\n parentPort?.postMessage({\n type: 'error',\n id: msg.id,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n return;\n }\n\n if (msg.type === 'done') {\n process.exit(0);\n }\n});\n"],"mappings":";;;;AA6BA,IAAI,eAAoC;AAExC,YAAY,GAAG,WAAW,OAAO,QAAuB;AACtD,KAAI,IAAI,SAAS,QAAQ;AACvB,iBAAe,IAAI;AACnB,cAAY,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1C;;AAGF,KAAI,IAAI,SAAS,QAAQ;AACvB,MAAI,CAAC,cAAc;AACjB,eAAY,YAAY;IAAE,MAAM;IAAS,IAAI,IAAI;IAAI,OAAO;IAA0B,CAAC;AACvF;;AAGF,MAAI;GACF,MAAM,SAAS,MAAM,uBAAuB,IAAI,MAAM;IACpD,GAAG;IACH,YAAY,IAAI;IAChB,iBAAiB,IAAI;IACrB,qBAAqB,IAAI;IACzB,+BAA+B,IAAI;IACnC,UAAU,IAAI;IACf,CAAC;AACF,eAAY,YAAY;IAAE,MAAM;IAAU,IAAI,IAAI;IAAI;IAAQ,CAAC;WACxD,OAAO;AACd,eAAY,YAAY;IACtB,MAAM;IACN,IAAI,IAAI;IACR,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;;AAEJ;;AAGF,KAAI,IAAI,SAAS,OACf,SAAQ,KAAK,EAAE;EAEjB"}
@@ -4,6 +4,7 @@ const require_colors = require("../cli/dist/lib/colors.cjs");
4
4
  const require_print = require("../cli/dist/lib/print.cjs");
5
5
  const require_spinner = require("../cli/dist/lib/spinner.cjs");
6
6
  const require_logger = require("../cli/dist/lib/logger.cjs");
7
+ const require_perf = require("./perf.cjs");
7
8
  const require_entryPoints = require("../utils/entryPoints.cjs");
8
9
  const require_nodeUtils = require("./nodeUtils.cjs");
9
10
  const require_index = require("../config/dist/index.cjs");
@@ -12,6 +13,7 @@ const require_runner_helpers = require("./runner.helpers.cjs");
12
13
  const require_utils = require("./utils.cjs");
13
14
  const require_generate_helpers = require("./generate.helpers.cjs");
14
15
  const require_generate = require("./generate.cjs");
16
+ const require_workerPool = require("./workerPool.cjs");
15
17
  let node_fs = require("node:fs");
16
18
  node_fs = require_runtime.__toESM(node_fs, 1);
17
19
  //#region src/css/runner.ts
@@ -249,170 +251,181 @@ const runThemeMode = async (options, context) => {
249
251
  if (themeConfig.config && appConfig === require_index.defaultTokensConfig) log.warn(`App config not found: ${themeConfig.config}, using defaults`);
250
252
  const packageDirs = [];
251
253
  const generateThemeModeCSS = async (opts) => {
254
+ require_perf.clearTimings();
255
+ require_perf.captureMemory("start");
252
256
  const genStartTime = performance.now();
253
257
  const genLog = opts?.isWatch ? require_logger.createLogger({ silent: true }) : log;
254
258
  const scopedCssOutputs = [];
255
- genLog.spinStart("Scanning app code...");
256
- const appScanResult = await require_nodeUtils.scanDirectoriesForSafelist(entryDirs, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, runtimeConfigValues);
257
- genLog.spinStop("✅", require_runner_helpers.getScanSummaryMessage({
258
- label: "app",
259
- filesScanned: appScanResult.filesScanned,
260
- filesWithComponents: appScanResult.filesWithComponents,
261
- componentCount: appScanResult.components.length,
262
- mode: "app"
263
- }));
264
- if (options.verbose) printVerboseScanFiles(genLog, workspaceDir, appScanResult.filePaths);
265
- genLog.spinStart("Generating main CSS...");
266
- const inheritedClasses = [...appScanResult.safelist];
267
- const inheritedComponents = new Set(appScanResult.components);
268
- const scopedPackageTargets = [];
269
- const processInheritedPackage = async (packageName) => {
270
- genLog.spinStart(`Processing package: ${packageName}...`);
271
- const packageDir = require_nodeUtils.findPackageSourceDir(packageName);
272
- if (!packageDir) {
273
- genLog.spinStop("⚠️", `Package not found: ${packageName}`);
274
- return;
275
- }
276
- if (!packageDirs.includes(packageDir)) packageDirs.push(packageDir);
277
- const packageScanResult = await require_nodeUtils.scanDirectoryForSafelist(packageDir, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, runtimeConfigValues, true);
278
- inheritedClasses.push(...packageScanResult.safelist);
279
- packageScanResult.components.forEach((comp) => inheritedComponents.add(comp));
259
+ const pool = await require_workerPool.createWorkerPool({
260
+ variants: context.variants,
261
+ autoVariants: context.autoVariants,
262
+ componentData: context.componentData
263
+ }, options.workers);
264
+ try {
265
+ genLog.spinStart(`Scanning app and packages... (${pool.workerCount} worker${pool.workerCount === 1 ? "" : "s"})`);
266
+ const scopedPackageTargets = [];
267
+ const processInheritedPackage = async (packageName) => {
268
+ const packageDir = require_nodeUtils.findPackageSourceDir(packageName);
269
+ if (!packageDir) return {
270
+ packageName,
271
+ status: "not-found"
272
+ };
273
+ if (!packageDirs.includes(packageDir)) packageDirs.push(packageDir);
274
+ return {
275
+ packageName,
276
+ status: "ok",
277
+ scanResult: await require_nodeUtils.scanDirectoryForSafelist(packageDir, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, runtimeConfigValues, true, pool)
278
+ };
279
+ };
280
+ const processScopedPackage = async (packageName, scopedPackageValue) => {
281
+ const scopedPackageConfig = normalizeScopedPackageConfig(scopedPackageValue);
282
+ const packageRoot = require_nodeUtils.findPackageRoot(packageName);
283
+ const packageDir = require_nodeUtils.findPackageSourceDir(packageName);
284
+ if (!packageRoot || !packageDir) return;
285
+ const scopeClass = require_nodeUtils.getPackageUdsScope(packageName);
286
+ if (!scopeClass) return;
287
+ const entryDirs = resolveScopedEntryDirs(packageRoot, packageDir, scopedPackageConfig.entry);
288
+ entryDirs.forEach((entryDir) => {
289
+ if (!packageDirs.includes(entryDir)) packageDirs.push(entryDir);
290
+ });
291
+ scopedPackageTargets.push({
292
+ packageName,
293
+ packageRoot,
294
+ packageDir,
295
+ entryDirs,
296
+ scopeClass,
297
+ config: scopedPackageConfig
298
+ });
299
+ };
300
+ const [appScanResult, inheritedResults] = await Promise.all([
301
+ require_perf.measureAsync("scan", () => require_nodeUtils.scanDirectoriesForSafelist(entryDirs, colorModes, context.variants, context.autoVariants, context.componentData, appVariantDefaults, runtimeConfigValues, false, pool)),
302
+ Promise.all((themeConfig.inherit ?? []).map((packageName) => require_perf.measureAsync(`scan:inherit:${packageName}`, () => processInheritedPackage(packageName)))),
303
+ Promise.all(Object.entries(themeConfig.scoped ?? {}).map(([packageName, scopedPackageConfig]) => processScopedPackage(packageName, scopedPackageConfig)))
304
+ ]);
280
305
  genLog.spinStop("✅", require_runner_helpers.getScanSummaryMessage({
281
- label: packageName,
282
- filesScanned: packageScanResult.filesScanned,
283
- filesWithComponents: packageScanResult.filesWithComponents,
284
- componentCount: packageScanResult.components.length,
285
- mode: "inherit"
306
+ label: "app",
307
+ filesScanned: appScanResult.filesScanned,
308
+ filesWithComponents: appScanResult.filesWithComponents,
309
+ componentCount: appScanResult.components.length,
310
+ mode: "app"
286
311
  }));
287
- if (options.verbose) printVerboseScanFiles(genLog, workspaceDir, packageScanResult.filePaths);
288
- };
289
- const processScopedPackage = async (packageName, scopedPackageValue) => {
290
- genLog.spinStart(`Processing scoped package: ${packageName}...`);
291
- const scopedPackageConfig = normalizeScopedPackageConfig(scopedPackageValue);
292
- const packageRoot = require_nodeUtils.findPackageRoot(packageName);
293
- const packageDir = require_nodeUtils.findPackageSourceDir(packageName);
294
- if (!packageRoot || !packageDir) {
295
- genLog.spinStop("⚠️", `Scoped package not found: ${packageName}`);
296
- return;
312
+ if (options.verbose) printVerboseScanFiles(genLog, workspaceDir, appScanResult.filePaths);
313
+ for (const result of inheritedResults) if (result.status === "not-found") genLog.spinStop("⚠️", `Package not found: ${result.packageName}`);
314
+ else {
315
+ genLog.spinStop("✅", require_runner_helpers.getScanSummaryMessage({
316
+ label: result.packageName,
317
+ filesScanned: result.scanResult.filesScanned,
318
+ filesWithComponents: result.scanResult.filesWithComponents,
319
+ componentCount: result.scanResult.components.length,
320
+ mode: "inherit"
321
+ }));
322
+ if (options.verbose) printVerboseScanFiles(genLog, workspaceDir, result.scanResult.filePaths);
297
323
  }
298
- const scopeClass = require_nodeUtils.getPackageUdsScope(packageName);
299
- if (!scopeClass) {
300
- genLog.spinStop("⚠️", `Scoped package missing package.json uds.scope: ${packageName}`);
301
- return;
324
+ const inheritedClasses = [...appScanResult.safelist];
325
+ const inheritedComponents = new Set(appScanResult.components);
326
+ for (const result of inheritedResults) if (result.status === "ok") {
327
+ inheritedClasses.push(...result.scanResult.safelist);
328
+ result.scanResult.components.forEach((comp) => inheritedComponents.add(comp));
302
329
  }
303
- const entryDirs = resolveScopedEntryDirs(packageRoot, packageDir, scopedPackageConfig.entry);
304
- entryDirs.forEach((entryDir) => {
305
- if (!packageDirs.includes(entryDir)) packageDirs.push(entryDir);
306
- });
307
- scopedPackageTargets.push({
308
- packageName,
309
- packageRoot,
310
- packageDir,
311
- entryDirs,
312
- scopeClass,
313
- config: scopedPackageConfig
314
- });
315
- };
316
- await (themeConfig.inherit ?? []).reduce(async (promise, packageName) => {
317
- await promise;
318
- await processInheritedPackage(packageName);
319
- }, Promise.resolve());
320
- await Object.entries(themeConfig.scoped ?? {}).reduce(async (promise, [packageName, scopedPackageConfig]) => {
321
- await promise;
322
- await processScopedPackage(packageName, scopedPackageConfig);
323
- }, Promise.resolve());
324
- const mainSafelist = require_safelist.deduplicateSafelist([
325
- ...inheritedClasses,
326
- ...require_safelist.getThemeAndScaleClasses(colorModes),
327
- ...require_safelist.getInternalSafelistClasses()
328
- ]);
329
- const allMotionComponents = [...inheritedComponents];
330
- const mainCssResult = await require_generate.generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
331
- scope: options.scope,
332
- contentDir: entryDirs,
333
- cssOptions: themeConfig.css,
334
- safeVarPrefixes: [
335
- ...require_utils.getMotionVarPrefixes(context.componentData, allMotionComponents),
336
- ...require_utils.getConfigurableCssVariables(),
337
- ...require_generate_helpers.getPruneVarSafelist(themeConfig.css)
338
- ]
339
- });
340
- ensureOutputDirectory(outputPath);
341
- node_fs.default.writeFileSync(outputPath, mainCssResult.css);
342
- for (const scopedPackageTarget of scopedPackageTargets) {
343
- const packageConfig = await require_nodeUtils.loadConfigFile(isAbsolutePath(scopedPackageTarget.config.config) ? scopedPackageTarget.config.config : joinPath(scopedPackageTarget.packageRoot, scopedPackageTarget.config.config)) ?? require_index.defaultTokensConfig;
344
- const packageVariantDefaults = require_utils.extractVariantDefaults(packageConfig);
345
- const packageRuntimeConfigValues = require_utils.extractRuntimeConfigValues(packageConfig);
346
- const packageScanResult = await require_nodeUtils.scanDirectoriesForSafelist(scopedPackageTarget.entryDirs, colorModes, context.variants, context.autoVariants, context.componentData, packageVariantDefaults, packageRuntimeConfigValues, true);
347
- genLog.spinStop("✅", require_runner_helpers.getScanSummaryMessage({
348
- label: scopedPackageTarget.packageName,
349
- filesScanned: packageScanResult.filesScanned,
350
- filesWithComponents: packageScanResult.filesWithComponents,
351
- componentCount: packageScanResult.components.length,
352
- mode: "scoped"
353
- }));
354
- if (options.verbose) printVerboseScanFiles(genLog, workspaceDir, packageScanResult.filePaths);
355
- const packageSafelist = require_safelist.deduplicateSafelist([
356
- ...packageScanResult.safelist,
330
+ genLog.spinStart("Generating main CSS...");
331
+ const mainSafelist = require_safelist.deduplicateSafelist([
332
+ ...inheritedClasses,
357
333
  ...require_safelist.getThemeAndScaleClasses(colorModes),
358
334
  ...require_safelist.getInternalSafelistClasses()
359
335
  ]);
360
- const scopedCssResult = await require_generate.generateCSS([...themeConfig.css?.safelist ?? [], ...packageSafelist], packageConfig, {
361
- scope: scopedPackageTarget.scopeClass,
362
- contentDir: scopedPackageTarget.entryDirs,
336
+ const allMotionComponents = [...inheritedComponents];
337
+ require_perf.captureMemory("before-gen");
338
+ const mainCssResult = await require_perf.measureAsync("gen", () => require_generate.generateCSS([...themeConfig.css?.safelist ?? [], ...mainSafelist], appConfig, {
339
+ scope: options.scope,
340
+ contentDir: entryDirs,
363
341
  cssOptions: themeConfig.css,
364
- referenceCss: themeConfig.css?.optimization?.deduplicateScopedCss === false ? void 0 : mainCssResult.css,
365
342
  safeVarPrefixes: [
366
- ...require_utils.getMotionVarPrefixes(context.componentData, [...packageScanResult.components]),
343
+ ...require_utils.getMotionVarPrefixes(context.componentData, allMotionComponents),
367
344
  ...require_utils.getConfigurableCssVariables(),
368
345
  ...require_generate_helpers.getPruneVarSafelist(themeConfig.css)
369
346
  ]
370
- });
371
- const scopedOutputPath = resolveOutputPath(workspaceDir, getScopedPackageOutputPath(scopedPackageTarget.packageName, scopedPackageTarget.config.outFile));
372
- ensureOutputDirectory(scopedOutputPath);
373
- node_fs.default.writeFileSync(scopedOutputPath, scopedCssResult.css);
374
- scopedCssOutputs.push({
375
- label: scopedPackageTarget.packageName,
376
- outputPath: scopedOutputPath,
377
- sizeGzipBytes: scopedCssResult.sizeGzipBytes,
378
- optimizationStats: scopedCssResult.optimizationStats
379
- });
380
- }
381
- const mainCssSummary = require_runner_helpers.getMainCssSummaryMessage({
382
- sizeGzipBytes: mainCssResult.sizeGzipBytes,
383
- optimizationStats: mainCssResult.optimizationStats,
384
- formatBytes: require_utils.formatBytes
385
- });
386
- genLog.spinStop("✅", mainCssSummary.summaryLine);
387
- mainCssSummary.detailLines.forEach((detailLine) => {
388
- genLog.print(detailLine);
389
- });
390
- scopedCssOutputs.forEach((scopedCssOutput) => {
391
- const scopedCssSummary = require_runner_helpers.getScopedCssSummaryMessage(scopedCssOutput.label, {
392
- sizeGzipBytes: scopedCssOutput.sizeGzipBytes,
393
- optimizationStats: scopedCssOutput.optimizationStats,
347
+ }));
348
+ require_perf.captureMemory("after-gen");
349
+ ensureOutputDirectory(outputPath);
350
+ node_fs.default.writeFileSync(outputPath, mainCssResult.css);
351
+ for (const scopedPackageTarget of scopedPackageTargets) {
352
+ const packageConfig = await require_nodeUtils.loadConfigFile(isAbsolutePath(scopedPackageTarget.config.config) ? scopedPackageTarget.config.config : joinPath(scopedPackageTarget.packageRoot, scopedPackageTarget.config.config)) ?? require_index.defaultTokensConfig;
353
+ const packageVariantDefaults = require_utils.extractVariantDefaults(packageConfig);
354
+ const packageRuntimeConfigValues = require_utils.extractRuntimeConfigValues(packageConfig);
355
+ const packageScanResult = await require_nodeUtils.scanDirectoriesForSafelist(scopedPackageTarget.entryDirs, colorModes, context.variants, context.autoVariants, context.componentData, packageVariantDefaults, packageRuntimeConfigValues, true, pool);
356
+ genLog.spinStop("✅", require_runner_helpers.getScanSummaryMessage({
357
+ label: scopedPackageTarget.packageName,
358
+ filesScanned: packageScanResult.filesScanned,
359
+ filesWithComponents: packageScanResult.filesWithComponents,
360
+ componentCount: packageScanResult.components.length,
361
+ mode: "scoped"
362
+ }));
363
+ if (options.verbose) printVerboseScanFiles(genLog, workspaceDir, packageScanResult.filePaths);
364
+ const packageSafelist = require_safelist.deduplicateSafelist([
365
+ ...packageScanResult.safelist,
366
+ ...require_safelist.getThemeAndScaleClasses(colorModes),
367
+ ...require_safelist.getInternalSafelistClasses()
368
+ ]);
369
+ const scopedCssResult = await require_generate.generateCSS([...themeConfig.css?.safelist ?? [], ...packageSafelist], packageConfig, {
370
+ scope: scopedPackageTarget.scopeClass,
371
+ contentDir: scopedPackageTarget.entryDirs,
372
+ cssOptions: themeConfig.css,
373
+ referenceCss: themeConfig.css?.optimization?.deduplicateScopedCss === false ? void 0 : mainCssResult.css,
374
+ safeVarPrefixes: [
375
+ ...require_utils.getMotionVarPrefixes(context.componentData, [...packageScanResult.components]),
376
+ ...require_utils.getConfigurableCssVariables(),
377
+ ...require_generate_helpers.getPruneVarSafelist(themeConfig.css)
378
+ ]
379
+ });
380
+ const scopedOutputPath = resolveOutputPath(workspaceDir, getScopedPackageOutputPath(scopedPackageTarget.packageName, scopedPackageTarget.config.outFile));
381
+ ensureOutputDirectory(scopedOutputPath);
382
+ node_fs.default.writeFileSync(scopedOutputPath, scopedCssResult.css);
383
+ scopedCssOutputs.push({
384
+ label: scopedPackageTarget.packageName,
385
+ outputPath: scopedOutputPath,
386
+ sizeGzipBytes: scopedCssResult.sizeGzipBytes,
387
+ optimizationStats: scopedCssResult.optimizationStats
388
+ });
389
+ }
390
+ const mainCssSummary = require_runner_helpers.getMainCssSummaryMessage({
391
+ sizeGzipBytes: mainCssResult.sizeGzipBytes,
392
+ optimizationStats: mainCssResult.optimizationStats,
394
393
  formatBytes: require_utils.formatBytes
395
394
  });
396
- genLog.spinStop("✅", scopedCssSummary.summaryLine);
397
- scopedCssSummary.detailLines.forEach((detailLine) => {
395
+ genLog.spinStop("✅", mainCssSummary.summaryLine);
396
+ mainCssSummary.detailLines.forEach((detailLine) => {
398
397
  genLog.print(detailLine);
399
398
  });
400
- });
401
- const duration = Math.round(performance.now() - genStartTime);
402
- const outputFileSection = require_runner_helpers.getOutputFileSection(workspaceDir, [outputPath, ...scopedCssOutputs.map((scopedCssOutput) => scopedCssOutput.outputPath)]);
403
- genLog.newline();
404
- genLog.print(outputFileSection.label);
405
- outputFileSection.paths.forEach((filePath) => {
406
- genLog.listItem(filePath);
407
- });
408
- genLog.newline();
409
- genLog.print(`${require_colors.magenta("Total time:")} ${require_runner_helpers.formatCssDuration(duration)}`);
410
- return {
411
- duration,
412
- outputPath,
413
- outputPaths: outputFileSection.paths,
414
- packageDirs
415
- };
399
+ scopedCssOutputs.forEach((scopedCssOutput) => {
400
+ const scopedCssSummary = require_runner_helpers.getScopedCssSummaryMessage(scopedCssOutput.label, {
401
+ sizeGzipBytes: scopedCssOutput.sizeGzipBytes,
402
+ optimizationStats: scopedCssOutput.optimizationStats,
403
+ formatBytes: require_utils.formatBytes
404
+ });
405
+ genLog.spinStop("✅", scopedCssSummary.summaryLine);
406
+ scopedCssSummary.detailLines.forEach((detailLine) => {
407
+ genLog.print(detailLine);
408
+ });
409
+ });
410
+ const duration = Math.round(performance.now() - genStartTime);
411
+ const outputFileSection = require_runner_helpers.getOutputFileSection(workspaceDir, [outputPath, ...scopedCssOutputs.map((scopedCssOutput) => scopedCssOutput.outputPath)]);
412
+ genLog.newline();
413
+ genLog.print(outputFileSection.label);
414
+ outputFileSection.paths.forEach((filePath) => {
415
+ genLog.listItem(filePath);
416
+ });
417
+ genLog.newline();
418
+ genLog.print(`${require_colors.magenta("Total time:")} ${require_runner_helpers.formatCssDuration(duration)}`);
419
+ require_perf.printPerfSummary(duration);
420
+ return {
421
+ duration,
422
+ outputPath,
423
+ outputPaths: outputFileSection.paths,
424
+ packageDirs
425
+ };
426
+ } finally {
427
+ await pool.destroy();
428
+ }
416
429
  };
417
430
  await generateThemeModeCSS();
418
431
  if (options.watch) {