@yahoo/uds 3.114.0-beta.2 → 3.114.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/automated-config/dist/generated/autoVariants.cjs +3 -0
  2. package/dist/automated-config/dist/generated/autoVariants.d.cts +3 -0
  3. package/dist/automated-config/dist/generated/autoVariants.d.ts +3 -0
  4. package/dist/automated-config/dist/generated/autoVariants.js +3 -0
  5. package/dist/automated-config/dist/generated/generatedConfigs.cjs +1883 -0
  6. package/dist/automated-config/dist/generated/generatedConfigs.d.cts +175 -1
  7. package/dist/automated-config/dist/generated/generatedConfigs.d.ts +175 -1
  8. package/dist/automated-config/dist/generated/generatedConfigs.js +1882 -1
  9. package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +84 -0
  10. package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +3 -1
  11. package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +3 -1
  12. package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +84 -0
  13. package/dist/automated-config/dist/mapTextVariantFixtureToValue.cjs +1 -12
  14. package/dist/automated-config/dist/mapTextVariantFixtureToValue.js +1 -12
  15. package/dist/automated-config/dist/properties.cjs +58 -12
  16. package/dist/automated-config/dist/properties.d.cts +8 -0
  17. package/dist/automated-config/dist/properties.d.ts +8 -0
  18. package/dist/automated-config/dist/properties.js +58 -12
  19. package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
  20. package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
  21. package/dist/cli/commands/sync.cjs +7 -1
  22. package/dist/cli/commands/sync.d.cts +1 -1
  23. package/dist/cli/commands/sync.d.ts +1 -1
  24. package/dist/cli/commands/sync.js +7 -1
  25. package/dist/cli/commands/version.cjs +2 -0
  26. package/dist/cli/commands/version.d.cts +1 -1
  27. package/dist/cli/commands/version.d.ts +1 -1
  28. package/dist/cli/commands/version.js +2 -0
  29. package/dist/cli/dist/cli.cjs +1 -1
  30. package/dist/cli/dist/cli.js +1 -1
  31. package/dist/cli/dist/commands/editor-rules.cjs +2 -2
  32. package/dist/cli/dist/commands/editor-rules.js +2 -2
  33. package/dist/cli/dist/utils/rules/config.cjs +1 -1
  34. package/dist/cli/dist/utils/rules/config.js +1 -1
  35. package/dist/cli/runner.cjs +2 -11
  36. package/dist/cli/runner.js +2 -11
  37. package/dist/components/Scrim.cjs +28 -0
  38. package/dist/components/Scrim.d.cts +14 -0
  39. package/dist/components/Scrim.d.ts +14 -0
  40. package/dist/components/Scrim.js +26 -0
  41. package/dist/components/client/BottomSheet/BottomSheet.cjs +209 -0
  42. package/dist/components/client/BottomSheet/BottomSheet.d.cts +77 -0
  43. package/dist/components/client/BottomSheet/BottomSheet.d.ts +77 -0
  44. package/dist/components/client/BottomSheet/BottomSheet.js +207 -0
  45. package/dist/components/client/BottomSheet/BottomSheetContent.cjs +26 -0
  46. package/dist/components/client/BottomSheet/BottomSheetContent.d.cts +15 -0
  47. package/dist/components/client/BottomSheet/BottomSheetContent.d.ts +15 -0
  48. package/dist/components/client/BottomSheet/BottomSheetContent.js +24 -0
  49. package/dist/components/client/BottomSheet/BottomSheetDismiss.cjs +15 -0
  50. package/dist/components/client/BottomSheet/BottomSheetDismiss.d.cts +12 -0
  51. package/dist/components/client/BottomSheet/BottomSheetDismiss.d.ts +12 -0
  52. package/dist/components/client/BottomSheet/BottomSheetDismiss.js +13 -0
  53. package/dist/components/client/BottomSheet/BottomSheetHandle.cjs +30 -0
  54. package/dist/components/client/BottomSheet/BottomSheetHandle.d.cts +19 -0
  55. package/dist/components/client/BottomSheet/BottomSheetHandle.d.ts +19 -0
  56. package/dist/components/client/BottomSheet/BottomSheetHandle.js +28 -0
  57. package/dist/components/client/BottomSheet/BottomSheetHeader.cjs +42 -0
  58. package/dist/components/client/BottomSheet/BottomSheetHeader.d.cts +18 -0
  59. package/dist/components/client/BottomSheet/BottomSheetHeader.d.ts +18 -0
  60. package/dist/components/client/BottomSheet/BottomSheetHeader.js +40 -0
  61. package/dist/components/client/BottomSheet/BottomSheetProvider.cjs +21 -0
  62. package/dist/components/client/BottomSheet/BottomSheetProvider.d.cts +19 -0
  63. package/dist/components/client/BottomSheet/BottomSheetProvider.d.ts +19 -0
  64. package/dist/components/client/BottomSheet/BottomSheetProvider.js +19 -0
  65. package/dist/components/client/BottomSheet/BottomSheetTrigger.cjs +15 -0
  66. package/dist/components/client/BottomSheet/BottomSheetTrigger.d.cts +12 -0
  67. package/dist/components/client/BottomSheet/BottomSheetTrigger.d.ts +12 -0
  68. package/dist/components/client/BottomSheet/BottomSheetTrigger.js +13 -0
  69. package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.cjs +32 -0
  70. package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.cts +22 -0
  71. package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.ts +22 -0
  72. package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.js +29 -0
  73. package/dist/components/client/BottomSheet/index.cjs +22 -0
  74. package/dist/components/client/BottomSheet/index.d.cts +10 -0
  75. package/dist/components/client/BottomSheet/index.d.ts +10 -0
  76. package/dist/components/client/BottomSheet/index.js +12 -0
  77. package/dist/components/client/BottomSheet/useBottomSheetDrag.cjs +188 -0
  78. package/dist/components/client/BottomSheet/useBottomSheetDrag.d.cts +44 -0
  79. package/dist/components/client/BottomSheet/useBottomSheetDrag.d.ts +44 -0
  80. package/dist/components/client/BottomSheet/useBottomSheetDrag.js +185 -0
  81. package/dist/components/client/BottomSheet/useBottomSheetSnapModel.cjs +138 -0
  82. package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.cts +46 -0
  83. package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.ts +46 -0
  84. package/dist/components/client/BottomSheet/useBottomSheetSnapModel.js +135 -0
  85. package/dist/components/client/BottomSheet/useBottomSheetStore.cjs +34 -0
  86. package/dist/components/client/BottomSheet/useBottomSheetStore.d.cts +38 -0
  87. package/dist/components/client/BottomSheet/useBottomSheetStore.d.ts +38 -0
  88. package/dist/components/client/BottomSheet/useBottomSheetStore.js +31 -0
  89. package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.cjs +17 -0
  90. package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.cts +13 -0
  91. package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts +13 -0
  92. package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.js +15 -0
  93. package/dist/components/client/BottomSheet/useExpansionMargins.cjs +89 -0
  94. package/dist/components/client/BottomSheet/useExpansionMargins.d.cts +34 -0
  95. package/dist/components/client/BottomSheet/useExpansionMargins.d.ts +34 -0
  96. package/dist/components/client/BottomSheet/useExpansionMargins.js +87 -0
  97. package/dist/components/client/BottomSheet/useViewportHeight.cjs +32 -0
  98. package/dist/components/client/BottomSheet/useViewportHeight.d.cts +9 -0
  99. package/dist/components/client/BottomSheet/useViewportHeight.d.ts +9 -0
  100. package/dist/components/client/BottomSheet/useViewportHeight.js +30 -0
  101. package/dist/components/client/BottomSheet/useVirtualKeyboard.cjs +48 -0
  102. package/dist/components/client/BottomSheet/useVirtualKeyboard.d.cts +10 -0
  103. package/dist/components/client/BottomSheet/useVirtualKeyboard.d.ts +10 -0
  104. package/dist/components/client/BottomSheet/useVirtualKeyboard.js +46 -0
  105. package/dist/components/client/BottomSheet/utils.cjs +128 -0
  106. package/dist/components/client/BottomSheet/utils.d.cts +61 -0
  107. package/dist/components/client/BottomSheet/utils.d.ts +61 -0
  108. package/dist/components/client/BottomSheet/utils.js +118 -0
  109. package/dist/components/client/Menu/Menu.Content.cjs +1 -1
  110. package/dist/components/client/Menu/Menu.Content.js +1 -1
  111. package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
  112. package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
  113. package/dist/components/client/Menu/Menu.index.d.cts +1 -1
  114. package/dist/components/client/index.cjs +16 -0
  115. package/dist/components/client/index.d.cts +10 -1
  116. package/dist/components/client/index.d.ts +10 -1
  117. package/dist/components/client/index.js +9 -1
  118. package/dist/components/client/providers/UDSConfigProvider.cjs +10 -6
  119. package/dist/components/client/providers/UDSConfigProvider.d.cts +1 -0
  120. package/dist/components/client/providers/UDSConfigProvider.d.ts +1 -0
  121. package/dist/components/client/providers/UDSConfigProvider.js +10 -6
  122. package/dist/components/index.cjs +24 -0
  123. package/dist/components/index.d.cts +9 -1
  124. package/dist/components/index.d.ts +9 -1
  125. package/dist/components/index.js +17 -1
  126. package/dist/config/dist/index.cjs +110 -2
  127. package/dist/config/dist/index.js +110 -2
  128. package/dist/fixtures/dist/index.cjs +103 -0
  129. package/dist/fixtures/dist/index.d.cts +3 -2
  130. package/dist/fixtures/dist/index.d.ts +3 -2
  131. package/dist/fixtures/dist/index.js +103 -1
  132. package/dist/fixtures/index.cjs +1 -0
  133. package/dist/fixtures/index.d.cts +2 -2
  134. package/dist/fixtures/index.d.ts +2 -2
  135. package/dist/fixtures/index.js +2 -2
  136. package/dist/index.cjs +20 -2
  137. package/dist/index.d.cts +12 -5
  138. package/dist/index.d.ts +12 -5
  139. package/dist/index.js +11 -3
  140. package/dist/runtime/bottomSheetConfig.cjs +11 -0
  141. package/dist/runtime/bottomSheetConfig.d.cts +15 -0
  142. package/dist/runtime/bottomSheetConfig.d.ts +15 -0
  143. package/dist/runtime/bottomSheetConfig.js +9 -0
  144. package/dist/runtime/index.cjs +2 -0
  145. package/dist/runtime/index.d.cts +2 -1
  146. package/dist/runtime/index.d.ts +2 -1
  147. package/dist/runtime/index.js +2 -1
  148. package/dist/runtime/udsConfig.cjs +2 -0
  149. package/dist/runtime/udsConfig.d.cts +2 -0
  150. package/dist/runtime/udsConfig.d.ts +2 -0
  151. package/dist/runtime/udsConfig.js +2 -0
  152. package/dist/styles/styler.d.cts +33 -30
  153. package/dist/styles/styler.d.ts +33 -30
  154. package/dist/styles/variants.cjs +278 -278
  155. package/dist/styles/variants.d.cts +9 -0
  156. package/dist/styles/variants.d.ts +9 -0
  157. package/dist/styles/variants.js +278 -278
  158. package/dist/tailwind/dist/commands/generateComponentData.cjs +31 -33
  159. package/dist/tailwind/dist/commands/generateComponentData.d.ts +1 -1
  160. package/dist/tailwind/dist/commands/generateComponentData.js +31 -33
  161. package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +1 -1
  162. package/dist/tailwind/dist/commands/purge.cjs +4 -3
  163. package/dist/tailwind/dist/commands/purge.d.ts +1 -1
  164. package/dist/tailwind/dist/commands/purge.js +4 -3
  165. package/dist/tailwind/dist/index.d.cts +0 -1
  166. package/dist/tailwind/dist/index.d.ts +3 -5
  167. package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +3 -4
  168. package/dist/tailwind/dist/purger/legacy/purgeCSS.js +3 -4
  169. package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +125 -122
  170. package/dist/tailwind/dist/purger/optimized/ast/expressions.js +125 -122
  171. package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +8 -1
  172. package/dist/tailwind/dist/purger/optimized/ast/jsx.js +8 -1
  173. package/dist/tailwind/dist/purger/optimized/purge.cjs +10 -11
  174. package/dist/tailwind/dist/purger/optimized/purge.js +9 -10
  175. package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +127 -232
  176. package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +127 -232
  177. package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +262 -330
  178. package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +262 -329
  179. package/dist/tailwind/dist/purger/optimized/utils/files.cjs +3 -4
  180. package/dist/tailwind/dist/purger/optimized/utils/files.js +3 -4
  181. package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +21 -13
  182. package/dist/tailwind/dist/purger/optimized/utils/safelist.js +21 -13
  183. package/dist/tailwind/dist/tailwind/plugins/components.cjs +2 -0
  184. package/dist/tailwind/dist/tailwind/plugins/components.js +3 -1
  185. package/dist/tailwind/dist/tailwind/plugins/typography.cjs +13 -41
  186. package/dist/tailwind/dist/tailwind/plugins/typography.js +13 -41
  187. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.cjs +2 -4
  188. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.cts +1 -10
  189. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.ts +1 -10
  190. package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.js +2 -4
  191. package/dist/tailwind/dist/utils/tsMorph.cjs +1 -1
  192. package/dist/tokens/automation/configs/index.cjs +2 -0
  193. package/dist/tokens/automation/configs/index.d.cts +2 -2
  194. package/dist/tokens/automation/configs/index.d.ts +2 -2
  195. package/dist/tokens/automation/configs/index.js +2 -2
  196. package/dist/tokens/automation/index.cjs +2 -0
  197. package/dist/tokens/automation/index.d.cts +2 -2
  198. package/dist/tokens/automation/index.d.ts +2 -2
  199. package/dist/tokens/automation/index.js +2 -2
  200. package/dist/tokens/index.cjs +2 -0
  201. package/dist/tokens/index.d.cts +3 -3
  202. package/dist/tokens/index.d.ts +3 -3
  203. package/dist/tokens/index.js +2 -2
  204. package/dist/tokens/types.d.cts +2 -2
  205. package/dist/tokens/types.d.ts +2 -2
  206. package/dist/types/dist/index.d.cts +76 -1
  207. package/dist/types/dist/index.d.ts +76 -1
  208. package/dist/uds/generated/componentData.cjs +1187 -961
  209. package/dist/uds/generated/componentData.js +1111 -939
  210. package/dist/uds/generated/tailwindPurge.cjs +57 -29
  211. package/dist/uds/generated/tailwindPurge.js +57 -29
  212. package/dist/uds/package.cjs +4 -10
  213. package/dist/uds/package.js +4 -10
  214. package/package.json +4 -7
  215. package/dist/cli/dist/lib/logger.cjs +0 -66
  216. package/dist/cli/dist/lib/logger.js +0 -66
  217. package/dist/tailwind/dist/commands/css.cjs +0 -79
  218. package/dist/tailwind/dist/commands/css.d.ts +0 -3
  219. package/dist/tailwind/dist/commands/css.helpers.cjs +0 -32
  220. package/dist/tailwind/dist/commands/css.helpers.js +0 -28
  221. package/dist/tailwind/dist/commands/css.js +0 -79
  222. package/dist/tailwind/dist/css/generate.cjs +0 -120
  223. package/dist/tailwind/dist/css/generate.d.cts +0 -30
  224. package/dist/tailwind/dist/css/generate.d.ts +0 -31
  225. package/dist/tailwind/dist/css/generate.helpers.cjs +0 -112
  226. package/dist/tailwind/dist/css/generate.helpers.js +0 -100
  227. package/dist/tailwind/dist/css/generate.js +0 -115
  228. package/dist/tailwind/dist/css/postcss.cjs +0 -35
  229. package/dist/tailwind/dist/css/postcss.helpers.cjs +0 -27
  230. package/dist/tailwind/dist/css/postcss.helpers.js +0 -26
  231. package/dist/tailwind/dist/css/postcss.js +0 -35
  232. package/dist/tailwind/dist/css/runner.cjs +0 -278
  233. package/dist/tailwind/dist/css/runner.helpers.cjs +0 -26
  234. package/dist/tailwind/dist/css/runner.helpers.js +0 -23
  235. package/dist/tailwind/dist/css/runner.js +0 -275
  236. package/dist/tailwind/dist/css/theme.cjs +0 -12
  237. package/dist/tailwind/dist/css/theme.d.cts +0 -66
  238. package/dist/tailwind/dist/css/theme.d.ts +0 -66
  239. package/dist/tailwind/dist/css/theme.js +0 -11
  240. package/dist/tailwind/dist/css/utils.cjs +0 -234
  241. package/dist/tailwind/dist/css/utils.js +0 -223
  242. package/dist/tailwind/dist/utils/optimizeCSS.cjs +0 -405
  243. package/dist/tailwind/dist/utils/optimizeCSS.js +0 -403
  244. package/dist/tailwind/dist/utils/postcssPreserveVars.cjs +0 -67
  245. package/dist/tailwind/dist/utils/postcssPreserveVars.js +0 -65
  246. package/generated/componentData.json +0 -2397
  247. package/generated/tailwindPurge.ts +0 -4560
@@ -1,12 +1,9 @@
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
- let ts_morph = require("ts-morph");
5
- let node_fs = require("node:fs");
6
4
  let node_path = require("node:path");
7
5
  node_path = require_runtime.__toESM(node_path);
8
- let fast_glob = require("fast-glob");
9
- fast_glob = require_runtime.__toESM(fast_glob);
6
+ let ts_morph = require("ts-morph");
10
7
 
11
8
  //#region ../tailwind/dist/purger/optimized/utils/componentAnalyzer.js
12
9
  /*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
@@ -18,31 +15,27 @@ let knownComponents = null;
18
15
  * Map of component name -> file path
19
16
  */
20
17
  let componentPaths = null;
21
- let scannedComponentsDir = null;
22
- const scanComponentFilePaths = async (componentsDir) => (0, fast_glob.default)("**/*.tsx", {
23
- cwd: componentsDir,
24
- absolute: true
25
- });
26
18
  /**
27
19
  * Scan src/components to build a map of all component files
28
20
  */
29
- const scanComponentFiles = async (componentsDir) => {
30
- if (componentPaths && scannedComponentsDir === componentsDir) return componentPaths;
21
+ async function scanComponentFiles(componentsDir) {
22
+ if (componentPaths) return componentPaths;
31
23
  componentPaths = /* @__PURE__ */ new Map();
32
24
  knownComponents = /* @__PURE__ */ new Set();
33
- scannedComponentsDir = componentsDir;
34
- const nextComponentPaths = componentPaths;
35
- const nextKnownComponents = knownComponents;
36
- (await scanComponentFilePaths(componentsDir)).forEach((file) => {
37
- if (file.includes(".test.") || file.endsWith("index.tsx")) return;
25
+ const glob = new Bun.Glob("**/*.tsx");
26
+ for await (const file of glob.scan({
27
+ cwd: componentsDir,
28
+ absolute: true
29
+ })) {
30
+ if (file.includes(".test.") || file.endsWith("index.tsx")) continue;
38
31
  const fileName = node_path.default.basename(file, ".tsx");
39
32
  if (/^[A-Z]/.test(fileName)) {
40
- nextComponentPaths.set(fileName, file);
41
- nextKnownComponents.add(fileName);
33
+ componentPaths.set(fileName, file);
34
+ knownComponents.add(fileName);
42
35
  }
43
- });
44
- return nextComponentPaths;
45
- };
36
+ }
37
+ return componentPaths;
38
+ }
46
39
  /**
47
40
  * Analyze an object literal for variant key mappings.
48
41
  * Handles:
@@ -50,64 +43,60 @@ const scanComponentFiles = async (componentsDir) => {
50
43
  * - Nullish coalescing: { fontSize: fontSize ?? variant } -> variant maps to fontSize
51
44
  * - Conditional spreads: ...(condition ? { props } : {}) -> recursively analyze props
52
45
  */
53
- const analyzeObjectForVariantMappings = (objLiteral, styleProps, getStylesLiterals, propToVariantKeys, sourceFile) => {
54
- objLiteral.getProperties().forEach((prop) => {
55
- if (ts_morph.Node.isPropertyAssignment(prop)) {
56
- analyzeVariantPropertyAssignment(prop, styleProps, getStylesLiterals, propToVariantKeys);
57
- return;
46
+ function analyzeObjectForVariantMappings(objLiteral, styleProps, getStylesLiterals, propToVariantKeys, sourceFile) {
47
+ for (const prop of objLiteral.getProperties()) if (ts_morph.Node.isPropertyAssignment(prop)) {
48
+ const variantKey = prop.getName();
49
+ if (variantKey && !styleProps.includes(variantKey)) styleProps.push(variantKey);
50
+ const initializer = prop.getInitializer();
51
+ if (initializer && ts_morph.Node.isStringLiteral(initializer)) getStylesLiterals.set(variantKey, initializer.getLiteralValue());
52
+ if (initializer && ts_morph.Node.isIdentifier(initializer)) {
53
+ const propName = initializer.getText();
54
+ const existing = propToVariantKeys.get(propName) ?? [];
55
+ if (!existing.includes(variantKey)) {
56
+ existing.push(variantKey);
57
+ propToVariantKeys.set(propName, existing);
58
+ }
59
+ }
60
+ if (initializer && ts_morph.Node.isBinaryExpression(initializer)) {
61
+ const operatorToken = initializer.getOperatorToken();
62
+ if (operatorToken.getKind() === ts_morph.SyntaxKind.QuestionQuestionToken || operatorToken.getKind() === ts_morph.SyntaxKind.BarBarToken) {
63
+ const rightSide = initializer.getRight();
64
+ if (ts_morph.Node.isIdentifier(rightSide)) {
65
+ const fallbackPropName = rightSide.getText();
66
+ const existing = propToVariantKeys.get(fallbackPropName) ?? [];
67
+ if (!existing.includes(variantKey)) {
68
+ existing.push(variantKey);
69
+ propToVariantKeys.set(fallbackPropName, existing);
70
+ }
71
+ }
72
+ }
58
73
  }
59
- if (ts_morph.Node.isSpreadAssignment(prop)) analyzeVariantSpreadAssignment(prop, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
60
- });
61
- };
62
- const addStyleProp = (styleProps, variantKey) => {
63
- if (!styleProps.includes(variantKey)) styleProps.push(variantKey);
64
- };
65
- const addPropToVariantKeyMapping = (propToVariantKeys, propName, variantKey) => {
66
- const existing = propToVariantKeys.get(propName) ?? [];
67
- if (!existing.includes(variantKey)) propToVariantKeys.set(propName, [...existing, variantKey]);
68
- };
69
- const extractFallbackIdentifier = (initializer) => {
70
- if (!ts_morph.Node.isBinaryExpression(initializer)) return null;
71
- const operatorKind = initializer.getOperatorToken().getKind();
72
- if (!(operatorKind === ts_morph.SyntaxKind.QuestionQuestionToken || operatorKind === ts_morph.SyntaxKind.BarBarToken) || !ts_morph.Node.isIdentifier(initializer.getRight())) return null;
73
- return initializer.getRight().getText();
74
- };
75
- const analyzeVariantPropertyAssignment = (prop, styleProps, getStylesLiterals, propToVariantKeys) => {
76
- const variantKey = prop.getName();
77
- addStyleProp(styleProps, variantKey);
78
- const initializer = prop.getInitializer();
79
- if (!initializer) return;
80
- if (ts_morph.Node.isStringLiteral(initializer)) getStylesLiterals.set(variantKey, initializer.getLiteralValue());
81
- if (ts_morph.Node.isIdentifier(initializer)) addPropToVariantKeyMapping(propToVariantKeys, initializer.getText(), variantKey);
82
- const fallbackIdentifier = extractFallbackIdentifier(initializer);
83
- if (fallbackIdentifier) addPropToVariantKeyMapping(propToVariantKeys, fallbackIdentifier, variantKey);
84
- };
85
- const findVariableObjectLiteral = (sourceFile, variableName) => {
86
- const initializer = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.VariableDeclaration).find((candidate) => candidate.getName() === variableName)?.getInitializer();
87
- return initializer && ts_morph.Node.isObjectLiteralExpression(initializer) ? initializer : null;
88
- };
89
- const analyzeVariantSpreadAssignment = (prop, styleProps, getStylesLiterals, propToVariantKeys, sourceFile) => {
90
- const spreadExpr = prop.getExpression();
91
- if (ts_morph.Node.isParenthesizedExpression(spreadExpr)) {
92
- const conditionalExpr = spreadExpr.getExpression();
93
- if (ts_morph.Node.isConditionalExpression(conditionalExpr)) {
94
- const whenTrue = conditionalExpr.getWhenTrue();
95
- if (!ts_morph.Node.isObjectLiteralExpression(whenTrue)) return;
96
- analyzeObjectForVariantMappings(whenTrue, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
74
+ } else if (ts_morph.Node.isSpreadAssignment(prop)) {
75
+ const spreadExpr = prop.getExpression();
76
+ if (ts_morph.Node.isParenthesizedExpression(spreadExpr)) {
77
+ const inner = spreadExpr.getExpression();
78
+ if (ts_morph.Node.isConditionalExpression(inner)) {
79
+ const whenTrue = inner.getWhenTrue();
80
+ if (ts_morph.Node.isObjectLiteralExpression(whenTrue)) analyzeObjectForVariantMappings(whenTrue, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
81
+ }
82
+ }
83
+ if (ts_morph.Node.isIdentifier(spreadExpr)) {
84
+ const varName = spreadExpr.getText();
85
+ const varDecl = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.VariableDeclaration).find((v) => v.getName() === varName);
86
+ if (varDecl) {
87
+ const varInit = varDecl.getInitializer();
88
+ if (varInit && ts_morph.Node.isObjectLiteralExpression(varInit)) analyzeObjectForVariantMappings(varInit, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
89
+ }
97
90
  }
98
91
  }
99
- if (ts_morph.Node.isIdentifier(spreadExpr)) {
100
- const objectLiteral = findVariableObjectLiteral(sourceFile, spreadExpr.getText());
101
- if (objectLiteral) analyzeObjectForVariantMappings(objectLiteral, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
102
- }
103
- };
92
+ }
104
93
  /**
105
94
  * Analyzes a UDS component file to extract:
106
95
  * 1. Default prop values (e.g., display = 'flex')
107
96
  * 2. Props passed to getStyles()
108
97
  * 3. Internal UDS component usage
109
98
  */
110
- const analyzeComponent = (project, componentPath) => {
99
+ function analyzeComponent(project, componentPath) {
111
100
  const sourceFile = project.getSourceFile(componentPath);
112
101
  if (!sourceFile) return null;
113
102
  const componentName = node_path.default.basename(componentPath, ".tsx");
@@ -119,9 +108,98 @@ const analyzeComponent = (project, componentPath) => {
119
108
  const internalComponents = [];
120
109
  const internalComponentProps = /* @__PURE__ */ new Map();
121
110
  const propToVariantKeys = /* @__PURE__ */ new Map();
122
- collectComponentDefaultsAndProps(sourceFile, defaultProps, componentPropNames);
123
- collectGetStylesMetadata(sourceFile, styleProps, getStylesLiterals, propToVariantKeys);
124
- collectCxLiterals(sourceFile, cxLiterals);
111
+ const functions = [...sourceFile.getFunctions(), ...sourceFile.getVariableDeclarations().filter((v) => {
112
+ const init = v.getInitializer();
113
+ return init && (ts_morph.Node.isArrowFunction(init) || ts_morph.Node.isCallExpression(init));
114
+ })];
115
+ for (const fn of functions) {
116
+ if (ts_morph.Node.isVariableDeclaration(fn)) {
117
+ const init = fn.getInitializer();
118
+ if (!init) continue;
119
+ if (ts_morph.Node.isCallExpression(init)) {
120
+ const args = init.getArguments();
121
+ for (const arg of args) if (ts_morph.Node.isFunctionExpression(arg) || ts_morph.Node.isArrowFunction(arg)) {
122
+ extractDefaultsFromFunction(arg, defaultProps);
123
+ extractAllPropNames(arg, componentPropNames);
124
+ }
125
+ }
126
+ if (ts_morph.Node.isArrowFunction(init)) {
127
+ extractDefaultsFromFunction(init, defaultProps);
128
+ extractAllPropNames(init, componentPropNames);
129
+ }
130
+ }
131
+ if (ts_morph.Node.isFunctionDeclaration(fn)) {
132
+ extractDefaultsFromFunction(fn, defaultProps);
133
+ extractAllPropNames(fn, componentPropNames);
134
+ }
135
+ }
136
+ const getStylesCalls = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression).filter((call) => call.getExpression().getText() === "getStyles");
137
+ for (const call of getStylesCalls) {
138
+ const args = call.getArguments();
139
+ if (args.length > 0 && ts_morph.Node.isObjectLiteralExpression(args[0])) {
140
+ const objLiteral = args[0];
141
+ for (const prop of objLiteral.getProperties()) if (ts_morph.Node.isPropertyAssignment(prop)) {
142
+ const variantKey = prop.getName();
143
+ if (variantKey && !styleProps.includes(variantKey)) styleProps.push(variantKey);
144
+ const initializer = prop.getInitializer();
145
+ if (initializer && ts_morph.Node.isStringLiteral(initializer)) getStylesLiterals.set(variantKey, initializer.getLiteralValue());
146
+ if (initializer && ts_morph.Node.isIdentifier(initializer)) {
147
+ const propName = initializer.getText();
148
+ const existing = propToVariantKeys.get(propName) ?? [];
149
+ if (!existing.includes(variantKey)) {
150
+ existing.push(variantKey);
151
+ propToVariantKeys.set(propName, existing);
152
+ }
153
+ }
154
+ if (initializer && ts_morph.Node.isBinaryExpression(initializer)) {
155
+ const operatorToken = initializer.getOperatorToken();
156
+ if (operatorToken.getKind() === ts_morph.SyntaxKind.QuestionQuestionToken || operatorToken.getKind() === ts_morph.SyntaxKind.BarBarToken) {
157
+ const rightSide = initializer.getRight();
158
+ if (ts_morph.Node.isIdentifier(rightSide)) {
159
+ const fallbackPropName = rightSide.getText();
160
+ const existing = propToVariantKeys.get(fallbackPropName) ?? [];
161
+ if (!existing.includes(variantKey)) {
162
+ existing.push(variantKey);
163
+ propToVariantKeys.set(fallbackPropName, existing);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ if (initializer && ts_morph.Node.isConditionalExpression(initializer)) {
169
+ const whenTrue = initializer.getWhenTrue();
170
+ const whenFalse = initializer.getWhenFalse();
171
+ const extractLiterals = (node) => {
172
+ const literals = [];
173
+ if (ts_morph.Node.isStringLiteral(node)) literals.push(node.getLiteralValue());
174
+ else if (ts_morph.Node.isConditionalExpression(node)) {
175
+ literals.push(...extractLiterals(node.getWhenTrue()));
176
+ literals.push(...extractLiterals(node.getWhenFalse()));
177
+ }
178
+ return literals;
179
+ };
180
+ [...extractLiterals(whenTrue), ...extractLiterals(whenFalse)].forEach((value, index) => {
181
+ const literalKey = index === 0 ? variantKey : `${variantKey}:${index}`;
182
+ getStylesLiterals.set(literalKey, value);
183
+ });
184
+ }
185
+ } else if (ts_morph.Node.isShorthandPropertyAssignment(prop)) {
186
+ const propName = prop.getName();
187
+ if (propName && !styleProps.includes(propName)) styleProps.push(propName);
188
+ } else if (ts_morph.Node.isSpreadAssignment(prop)) {
189
+ const spreadExpr = prop.getExpression();
190
+ if (ts_morph.Node.isIdentifier(spreadExpr)) {
191
+ const varName = spreadExpr.getText();
192
+ const varDecl = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.VariableDeclaration).find((v) => v.getName() === varName);
193
+ if (varDecl) {
194
+ const varInit = varDecl.getInitializer();
195
+ if (varInit && ts_morph.Node.isObjectLiteralExpression(varInit)) analyzeObjectForVariantMappings(varInit, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
196
+ }
197
+ }
198
+ }
199
+ }
200
+ }
201
+ const cxCalls = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression).filter((call) => call.getExpression().getText() === "cx");
202
+ for (const call of cxCalls) for (const arg of call.getArguments()) extractCxStringLiterals(arg, cxLiterals);
125
203
  extractInternalComponents(sourceFile, internalComponents, internalComponentProps, propToVariantKeys, componentPropNames);
126
204
  return {
127
205
  name: componentName,
@@ -135,194 +213,96 @@ const analyzeComponent = (project, componentPath) => {
135
213
  propToVariantKeys,
136
214
  motionVarPrefixes: extractMotionVarPrefixes(sourceFile)
137
215
  };
138
- };
139
- const getComponentFunctionNodes = (sourceFile) => [...sourceFile.getFunctions(), ...sourceFile.getVariableDeclarations().filter((declaration) => {
140
- const initializer = declaration.getInitializer();
141
- return initializer && (ts_morph.Node.isArrowFunction(initializer) || ts_morph.Node.isCallExpression(initializer));
142
- })];
143
- const collectComponentDefaultsAndProps = (sourceFile, defaultProps, componentPropNames) => {
144
- getComponentFunctionNodes(sourceFile).forEach((fn) => {
145
- if (ts_morph.Node.isFunctionDeclaration(fn)) {
146
- extractDefaultsFromFunction(fn, defaultProps);
147
- extractAllPropNames(fn, componentPropNames);
148
- return;
149
- }
150
- if (!ts_morph.Node.isVariableDeclaration(fn)) return;
151
- const initializer = fn.getInitializer();
152
- if (!initializer) return;
153
- if (ts_morph.Node.isCallExpression(initializer)) initializer.getArguments().forEach((arg) => {
154
- if (ts_morph.Node.isFunctionExpression(arg) || ts_morph.Node.isArrowFunction(arg)) {
155
- extractDefaultsFromFunction(arg, defaultProps);
156
- extractAllPropNames(arg, componentPropNames);
157
- }
158
- });
159
- if (ts_morph.Node.isArrowFunction(initializer)) {
160
- extractDefaultsFromFunction(initializer, defaultProps);
161
- extractAllPropNames(initializer, componentPropNames);
162
- }
163
- });
164
- };
165
- const extractConditionalStringLiterals = (node) => {
166
- if (ts_morph.Node.isStringLiteral(node)) return [node.getLiteralValue()];
167
- if (ts_morph.Node.isConditionalExpression(node)) return [...extractConditionalStringLiterals(node.getWhenTrue()), ...extractConditionalStringLiterals(node.getWhenFalse())];
168
- return [];
169
- };
170
- const storeVariantLiteralValues = (variantKey, literalValues, getStylesLiterals) => {
171
- literalValues.forEach((value, index) => {
172
- const literalKey = index === 0 ? variantKey : `${variantKey}:${index}`;
173
- getStylesLiterals.set(literalKey, value);
174
- });
175
- };
176
- const handleGetStylesPropertyAssignment = (prop, styleProps, getStylesLiterals, propToVariantKeys) => {
177
- const variantKey = prop.getName();
178
- addStyleProp(styleProps, variantKey);
179
- const initializer = prop.getInitializer();
180
- if (!initializer) return;
181
- if (ts_morph.Node.isStringLiteral(initializer)) getStylesLiterals.set(variantKey, initializer.getLiteralValue());
182
- if (ts_morph.Node.isIdentifier(initializer)) addPropToVariantKeyMapping(propToVariantKeys, initializer.getText(), variantKey);
183
- const fallbackIdentifier = extractFallbackIdentifier(initializer);
184
- if (fallbackIdentifier) addPropToVariantKeyMapping(propToVariantKeys, fallbackIdentifier, variantKey);
185
- if (ts_morph.Node.isConditionalExpression(initializer)) storeVariantLiteralValues(variantKey, [...extractConditionalStringLiterals(initializer.getWhenTrue()), ...extractConditionalStringLiterals(initializer.getWhenFalse())], getStylesLiterals);
186
- };
187
- const handleGetStylesObjectProperty = (prop, styleProps, getStylesLiterals, propToVariantKeys, sourceFile) => {
188
- if (ts_morph.Node.isPropertyAssignment(prop)) {
189
- handleGetStylesPropertyAssignment(prop, styleProps, getStylesLiterals, propToVariantKeys);
190
- return;
191
- }
192
- if (ts_morph.Node.isShorthandPropertyAssignment(prop)) {
193
- addStyleProp(styleProps, prop.getName());
194
- return;
195
- }
196
- if (ts_morph.Node.isSpreadAssignment(prop) && ts_morph.Node.isIdentifier(prop.getExpression())) {
197
- const objectLiteral = findVariableObjectLiteral(sourceFile, prop.getExpression().getText());
198
- if (objectLiteral) analyzeObjectForVariantMappings(objectLiteral, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
199
- }
200
- };
201
- const collectGetStylesMetadata = (sourceFile, styleProps, getStylesLiterals, propToVariantKeys) => {
202
- sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression).filter((call) => call.getExpression().getText() === "getStyles").forEach((call) => {
203
- const args = call.getArguments();
204
- if (args.length === 0 || !ts_morph.Node.isObjectLiteralExpression(args[0])) return;
205
- args[0].getProperties().forEach((prop) => {
206
- handleGetStylesObjectProperty(prop, styleProps, getStylesLiterals, propToVariantKeys, sourceFile);
207
- });
208
- });
209
- };
210
- const collectCxLiterals = (sourceFile, cxLiterals) => {
211
- sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression).filter((call) => call.getExpression().getText() === "cx").forEach((call) => {
212
- call.getArguments().forEach((arg) => extractCxStringLiterals(arg, cxLiterals));
213
- });
214
- };
216
+ }
215
217
  /**
216
218
  * Extract UDS components used internally in the file and their prop values.
217
219
  * Also detects prop aliasing (e.g., columnGap={gap} means gap -> columnGap).
218
220
  */
219
- const extractInternalComponents = (sourceFile, internalComponents, internalComponentProps, propToVariantKeys, componentProps) => {
220
- collectImportedInternalComponents(sourceFile, internalComponents);
221
- collectInternalComponentUsages(sourceFile, internalComponents, internalComponentProps, propToVariantKeys, componentProps);
222
- };
223
- const isInternalUdsModule = (moduleSpec) => {
224
- return (moduleSpec.startsWith("@yahoo/uds") || moduleSpec.startsWith("../") || moduleSpec.startsWith("./")) && (moduleSpec.includes("/components/") || moduleSpec === "@yahoo/uds");
225
- };
226
- const pushUniqueComponentName = (components, name) => {
227
- if (/^[A-Z]/.test(name) && !components.includes(name)) components.push(name);
228
- };
229
- const collectImportedInternalComponents = (sourceFile, internalComponents) => {
230
- sourceFile.getImportDeclarations().forEach((importDecl) => {
231
- if (!isInternalUdsModule(importDecl.getModuleSpecifierValue())) return;
232
- importDecl.getNamedImports().forEach((namedImport) => pushUniqueComponentName(internalComponents, namedImport.getName()));
233
- });
234
- };
235
- const getOrCreateComponentPropsMap = (internalComponentProps, componentName) => {
236
- const existing = internalComponentProps.get(componentName);
237
- if (existing) return existing;
238
- const created = /* @__PURE__ */ new Map();
239
- internalComponentProps.set(componentName, created);
240
- return created;
241
- };
242
- const extractJsxAttributeLiteralValues = (attr, componentProps, propToVariantKeys) => {
243
- if (!ts_morph.Node.isJsxAttribute(attr)) return null;
244
- const propName = attr.getNameNode().getText();
245
- const initializer = attr.getInitializer();
246
- if (!initializer) return {
247
- propName,
248
- values: []
249
- };
250
- if (ts_morph.Node.isStringLiteral(initializer)) return {
251
- propName,
252
- values: [initializer.getLiteralValue()]
253
- };
254
- if (!ts_morph.Node.isJsxExpression(initializer)) return {
255
- propName,
256
- values: []
257
- };
258
- const expr = initializer.getExpression();
259
- if (expr && ts_morph.Node.isStringLiteral(expr)) return {
260
- propName,
261
- values: [expr.getLiteralValue()]
262
- };
263
- if (expr && ts_morph.Node.isIdentifier(expr)) {
264
- const identifierName = expr.getText();
265
- if (componentProps.has(identifierName) && identifierName !== propName) addPropToVariantKeyMapping(propToVariantKeys, identifierName, propName);
221
+ function extractInternalComponents(sourceFile, internalComponents, internalComponentProps, propToVariantKeys, componentProps) {
222
+ for (const importDecl of sourceFile.getImportDeclarations()) {
223
+ const moduleSpec = importDecl.getModuleSpecifierValue();
224
+ if (moduleSpec.startsWith("@yahoo/uds") || moduleSpec.startsWith("../") || moduleSpec.startsWith("./")) {
225
+ if (moduleSpec.includes("/components/") || moduleSpec === "@yahoo/uds") for (const namedImport of importDecl.getNamedImports()) {
226
+ const name = namedImport.getName();
227
+ if (/^[A-Z]/.test(name) && !internalComponents.includes(name)) internalComponents.push(name);
228
+ }
229
+ }
266
230
  }
267
- return {
268
- propName,
269
- values: []
270
- };
271
- };
272
- const collectInternalComponentUsages = (sourceFile, internalComponents, internalComponentProps, propToVariantKeys, componentProps) => {
273
- [...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxSelfClosingElement), ...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxOpeningElement)].forEach((element) => {
231
+ const jsxElements = [...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxSelfClosingElement), ...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxOpeningElement)];
232
+ for (const element of jsxElements) {
274
233
  const tagName = element.getTagNameNode().getText();
275
- if (!/^[A-Z]/.test(tagName)) return;
276
- pushUniqueComponentName(internalComponents, tagName);
277
- element.getAttributes().forEach((attr) => {
278
- const extracted = extractJsxAttributeLiteralValues(attr, componentProps, propToVariantKeys);
279
- if (!extracted || extracted.values.length === 0) return;
280
- const componentPropsMap = getOrCreateComponentPropsMap(internalComponentProps, tagName);
281
- const existingValues = componentPropsMap.get(extracted.propName) ?? [];
282
- const mergedValues = [...new Set([...existingValues, ...extracted.values])];
283
- componentPropsMap.set(extracted.propName, mergedValues);
284
- });
285
- });
286
- };
234
+ if (!/^[A-Z]/.test(tagName)) continue;
235
+ if (!internalComponents.includes(tagName)) internalComponents.push(tagName);
236
+ const attrs = element.getAttributes();
237
+ for (const attr of attrs) if (ts_morph.Node.isJsxAttribute(attr)) {
238
+ const propName = attr.getNameNode().getText();
239
+ const initializer = attr.getInitializer();
240
+ let values = [];
241
+ if (initializer) {
242
+ if (ts_morph.Node.isStringLiteral(initializer)) values = [initializer.getLiteralValue()];
243
+ else if (ts_morph.Node.isJsxExpression(initializer)) {
244
+ const expr = initializer.getExpression();
245
+ if (expr && ts_morph.Node.isStringLiteral(expr)) values = [expr.getLiteralValue()];
246
+ else if (expr && ts_morph.Node.isIdentifier(expr)) {
247
+ const identifierName = expr.getText();
248
+ if (componentProps.has(identifierName) && identifierName !== propName) {
249
+ const existing = propToVariantKeys.get(identifierName) ?? [];
250
+ if (!existing.includes(propName)) {
251
+ existing.push(propName);
252
+ propToVariantKeys.set(identifierName, existing);
253
+ }
254
+ }
255
+ }
256
+ }
257
+ }
258
+ if (values.length > 0) {
259
+ let componentPropsMap = internalComponentProps.get(tagName);
260
+ if (!componentPropsMap) {
261
+ componentPropsMap = /* @__PURE__ */ new Map();
262
+ internalComponentProps.set(tagName, componentPropsMap);
263
+ }
264
+ const existingValues = componentPropsMap.get(propName) ?? [];
265
+ for (const v of values) if (!existingValues.includes(v)) existingValues.push(v);
266
+ componentPropsMap.set(propName, existingValues);
267
+ }
268
+ }
269
+ }
270
+ }
287
271
  /**
288
272
  * Extract default prop values from a function's parameter destructuring
289
273
  */
290
- const extractDefaultsFromFunction = (fn, defaults) => {
274
+ function extractDefaultsFromFunction(fn, defaults) {
291
275
  let params = [];
292
276
  if (ts_morph.Node.isFunctionDeclaration(fn) || ts_morph.Node.isFunctionExpression(fn)) params = fn.getParameters();
293
277
  else if (ts_morph.Node.isArrowFunction(fn)) params = fn.getParameters();
294
- params.forEach((param) => {
295
- if (!ts_morph.Node.isParameterDeclaration(param)) return;
278
+ for (const param of params) {
279
+ if (!ts_morph.Node.isParameterDeclaration(param)) continue;
296
280
  const nameNode = param.getNameNode();
297
- if (!nameNode || !ts_morph.Node.isObjectBindingPattern(nameNode)) return;
298
- nameNode.getElements().forEach((element) => {
281
+ if (!nameNode || !ts_morph.Node.isObjectBindingPattern(nameNode)) continue;
282
+ for (const element of nameNode.getElements()) {
299
283
  const propName = element.getPropertyNameNode()?.getText() || element.getName();
300
284
  const initializer = element.getInitializer();
301
285
  if (initializer && ts_morph.Node.isStringLiteral(initializer)) defaults.set(propName, initializer.getLiteralValue());
302
- else if (initializer && ts_morph.Node.isIdentifier(initializer)) {
303
- const resolved = resolveIdentifierToStringLiteral(initializer);
304
- if (resolved) defaults.set(propName, resolved);
305
- }
306
- });
307
- });
308
- };
286
+ }
287
+ }
288
+ }
309
289
  /**
310
290
  * Extract ALL prop names from a function's parameter destructuring (not just defaults)
311
291
  */
312
- const extractAllPropNames = (fn, propNames) => {
292
+ function extractAllPropNames(fn, propNames) {
313
293
  let params = [];
314
294
  if (ts_morph.Node.isFunctionDeclaration(fn) || ts_morph.Node.isFunctionExpression(fn)) params = fn.getParameters();
315
295
  else if (ts_morph.Node.isArrowFunction(fn)) params = fn.getParameters();
316
- params.forEach((param) => {
317
- if (!ts_morph.Node.isParameterDeclaration(param)) return;
296
+ for (const param of params) {
297
+ if (!ts_morph.Node.isParameterDeclaration(param)) continue;
318
298
  const nameNode = param.getNameNode();
319
- if (!nameNode || !ts_morph.Node.isObjectBindingPattern(nameNode)) return;
320
- nameNode.getElements().forEach((element) => {
299
+ if (!nameNode || !ts_morph.Node.isObjectBindingPattern(nameNode)) continue;
300
+ for (const element of nameNode.getElements()) {
321
301
  const propName = element.getPropertyNameNode()?.getText() || element.getName();
322
302
  propNames.add(propName);
323
- });
324
- });
325
- };
303
+ }
304
+ }
305
+ }
326
306
  /**
327
307
  * Extract string literals from cx() call arguments.
328
308
  * Handles:
@@ -330,25 +310,22 @@ const extractAllPropNames = (fn, propNames) => {
330
310
  * - Object keys: cx({ 'class1': condition, 'class2': true })
331
311
  * - Nested calls and arrays
332
312
  */
333
- const extractCxStringLiterals = (node, literals) => {
334
- if (ts_morph.Node.isStringLiteral(node)) node.getLiteralValue().split(/\s+/).filter(Boolean).forEach((cls) => {
335
- if (!literals.includes(cls)) literals.push(cls);
336
- });
337
- else if (ts_morph.Node.isObjectLiteralExpression(node)) node.getProperties().forEach((prop) => {
338
- if (ts_morph.Node.isPropertyAssignment(prop)) {
313
+ function extractCxStringLiterals(node, literals) {
314
+ if (ts_morph.Node.isStringLiteral(node)) {
315
+ const classes = node.getLiteralValue().split(/\s+/).filter(Boolean);
316
+ for (const cls of classes) if (!literals.includes(cls)) literals.push(cls);
317
+ } else if (ts_morph.Node.isObjectLiteralExpression(node)) {
318
+ for (const prop of node.getProperties()) if (ts_morph.Node.isPropertyAssignment(prop)) {
339
319
  const nameNode = prop.getNameNode();
340
- if (ts_morph.Node.isStringLiteral(nameNode)) nameNode.getLiteralValue().split(/\s+/).filter(Boolean).forEach((cls) => {
341
- if (!literals.includes(cls)) literals.push(cls);
342
- });
343
- else if (ts_morph.Node.isIdentifier(nameNode)) {
320
+ if (ts_morph.Node.isStringLiteral(nameNode)) {
321
+ const classes = nameNode.getLiteralValue().split(/\s+/).filter(Boolean);
322
+ for (const cls of classes) if (!literals.includes(cls)) literals.push(cls);
323
+ } else if (ts_morph.Node.isIdentifier(nameNode)) {
344
324
  const cls = nameNode.getText();
345
325
  if (!literals.includes(cls)) literals.push(cls);
346
326
  }
347
327
  }
348
- });
349
- else if (ts_morph.Node.isArrayLiteralExpression(node)) node.getElements().forEach((element) => {
350
- extractCxStringLiterals(element, literals);
351
- });
328
+ } else if (ts_morph.Node.isArrayLiteralExpression(node)) for (const element of node.getElements()) extractCxStringLiterals(element, literals);
352
329
  else if (ts_morph.Node.isConditionalExpression(node)) {
353
330
  extractCxStringLiterals(node.getWhenTrue(), literals);
354
331
  extractCxStringLiterals(node.getWhenFalse(), literals);
@@ -356,54 +333,59 @@ const extractCxStringLiterals = (node, literals) => {
356
333
  extractCxStringLiterals(node.getLeft(), literals);
357
334
  extractCxStringLiterals(node.getRight(), literals);
358
335
  }
359
- };
336
+ }
360
337
  /**
361
338
  * Try to resolve an identifier to its initializer value (for const declarations)
362
339
  */
363
- const resolveIdentifierToObject = (sourceFile, identifier) => {
364
- const decl = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.VariableDeclaration).find((candidate) => candidate.getName() === identifier);
365
- if (!decl) return null;
366
- let initializer = decl.getInitializer();
367
- if (!initializer) return null;
368
- if (ts_morph.Node.isAsExpression(initializer)) initializer = initializer.getExpression();
369
- if (!ts_morph.Node.isObjectLiteralExpression(initializer)) return null;
370
- const result = {};
371
- initializer.getProperties().forEach((prop) => {
372
- if (!ts_morph.Node.isPropertyAssignment(prop)) return;
373
- const propName = prop.getName();
374
- const propInit = prop.getInitializer();
375
- if (propInit && ts_morph.Node.isStringLiteral(propInit)) result[propName] = propInit.getLiteralValue();
376
- });
377
- return result;
378
- };
340
+ function resolveIdentifierToObject(sourceFile, identifier) {
341
+ const varDecls = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.VariableDeclaration);
342
+ for (const decl of varDecls) {
343
+ if (decl.getName() !== identifier) continue;
344
+ let initializer = decl.getInitializer();
345
+ if (!initializer) continue;
346
+ if (ts_morph.Node.isAsExpression(initializer)) initializer = initializer.getExpression();
347
+ if (!ts_morph.Node.isObjectLiteralExpression(initializer)) continue;
348
+ const result = {};
349
+ for (const prop of initializer.getProperties()) {
350
+ if (!ts_morph.Node.isPropertyAssignment(prop)) continue;
351
+ const propName = prop.getName();
352
+ const propInit = prop.getInitializer();
353
+ if (propInit && ts_morph.Node.isStringLiteral(propInit)) result[propName] = propInit.getLiteralValue();
354
+ }
355
+ return result;
356
+ }
357
+ return null;
358
+ }
379
359
  /**
380
360
  * Extract motion CSS variable prefixes from SpringMotionConfig usage.
381
361
  * Returns prefixes like ['--uds-motion-bouncy-4-', '--uds-motion-smooth-3-']
382
362
  */
383
- const extractMotionVarPrefixes = (sourceFile) => {
363
+ function extractMotionVarPrefixes(sourceFile) {
384
364
  const prefixes = [];
385
- [...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxSelfClosingElement), ...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxOpeningElement)].forEach((element) => {
386
- if (element.getTagNameNode().getText() !== "SpringMotionConfig") return;
365
+ const jsxElements = [...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxSelfClosingElement), ...sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.JsxOpeningElement)];
366
+ for (const element of jsxElements) {
367
+ if (element.getTagNameNode().getText() !== "SpringMotionConfig") continue;
387
368
  const props = {
388
369
  layoutVariant: null,
389
370
  layoutSpeed: null,
390
371
  colorVariant: null,
391
372
  colorSpeed: null
392
373
  };
393
- element.getAttributes().forEach((attr) => {
374
+ const attrs = element.getAttributes();
375
+ for (const attr of attrs) {
394
376
  if (ts_morph.Node.isJsxSpreadAttribute(attr)) {
395
377
  const expr = attr.getExpression();
396
378
  if (ts_morph.Node.isIdentifier(expr)) {
397
379
  const spreadObj = resolveIdentifierToObject(sourceFile, expr.getText());
398
- if (spreadObj) Object.keys(props).forEach((key) => {
399
- if (key in spreadObj) props[key] = spreadObj[key];
400
- });
380
+ if (spreadObj) {
381
+ for (const key of Object.keys(props)) if (key in spreadObj) props[key] = spreadObj[key];
382
+ }
401
383
  }
402
- return;
384
+ continue;
403
385
  }
404
- if (!ts_morph.Node.isJsxAttribute(attr)) return;
386
+ if (!ts_morph.Node.isJsxAttribute(attr)) continue;
405
387
  const propName = attr.getNameNode().getText();
406
- if (!(propName in props)) return;
388
+ if (!(propName in props)) continue;
407
389
  const initializer = attr.getInitializer();
408
390
  if (initializer) {
409
391
  if (ts_morph.Node.isStringLiteral(initializer)) props[propName] = initializer.getLiteralValue();
@@ -412,64 +394,14 @@ const extractMotionVarPrefixes = (sourceFile) => {
412
394
  if (expr && ts_morph.Node.isStringLiteral(expr)) props[propName] = expr.getLiteralValue();
413
395
  }
414
396
  }
415
- });
397
+ }
416
398
  const layoutPrefix = `--uds-motion-${props.layoutVariant ?? require_index.SPRING_MOTION_DEFAULTS.layoutVariant}-${props.layoutSpeed ?? require_index.SPRING_MOTION_DEFAULTS.layoutSpeed}-`;
417
399
  if (!prefixes.includes(layoutPrefix)) prefixes.push(layoutPrefix);
418
400
  const colorPrefix = `--uds-motion-${props.colorVariant ?? require_index.SPRING_MOTION_DEFAULTS.colorVariant}-${props.colorSpeed ?? require_index.SPRING_MOTION_DEFAULTS.colorSpeed}-`;
419
401
  if (!prefixes.includes(colorPrefix)) prefixes.push(colorPrefix);
420
- });
402
+ }
421
403
  return prefixes;
422
- };
423
- const resolveIdentifierToStringLiteral = (identifier) => {
424
- if (!ts_morph.Node.isIdentifier(identifier)) return null;
425
- const symbol = identifier.getSymbol();
426
- if (!symbol) return resolveImportedIdentifier(identifier);
427
- const resolvedDeclarationValue = symbol.getDeclarations().reduce((resolved, declaration) => {
428
- if (resolved) return resolved;
429
- if (ts_morph.Node.isVariableDeclaration(declaration)) {
430
- let initializer = declaration.getInitializer();
431
- if (initializer && ts_morph.Node.isAsExpression(initializer)) initializer = initializer.getExpression();
432
- if (initializer && ts_morph.Node.isStringLiteral(initializer)) return initializer.getLiteralValue();
433
- }
434
- if (ts_morph.Node.isEnumMember(declaration)) {
435
- const initializer = declaration.getInitializer();
436
- if (initializer && ts_morph.Node.isStringLiteral(initializer)) return initializer.getLiteralValue();
437
- }
438
- }, void 0);
439
- if (resolvedDeclarationValue) return resolvedDeclarationValue;
440
- return resolveImportedIdentifier(identifier);
441
- };
442
- const resolveImportedIdentifier = (identifier) => {
443
- if (!ts_morph.Node.isIdentifier(identifier)) return null;
444
- const name = identifier.getText();
445
- const sourceFile = identifier.getSourceFile();
446
- const project = sourceFile.getProject();
447
- const baseDir = node_path.default.dirname(sourceFile.getFilePath());
448
- const importResolution = sourceFile.getImportDeclarations().reduce((resolvedImport, importDecl) => {
449
- if (resolvedImport) return resolvedImport;
450
- if (!importDecl.getNamedImports().find((n) => n.getName() === name)) return;
451
- const moduleSpec = importDecl.getModuleSpecifierValue();
452
- if (!moduleSpec.startsWith(".")) return;
453
- const resolvedBase = node_path.default.resolve(baseDir, moduleSpec);
454
- return [
455
- resolvedBase,
456
- `${resolvedBase}.ts`,
457
- `${resolvedBase}.tsx`
458
- ].reduce((resolvedCandidate, candidate) => {
459
- if (resolvedCandidate) return resolvedCandidate;
460
- if (!(0, node_fs.existsSync)(candidate)) return;
461
- const importedFile = project.addSourceFileAtPathIfExists(candidate);
462
- if (!importedFile) return;
463
- const varDecl = importedFile.getVariableDeclaration(name);
464
- if (!varDecl) return;
465
- let initializer = varDecl.getInitializer();
466
- if (initializer && ts_morph.Node.isAsExpression(initializer)) initializer = initializer.getExpression();
467
- return initializer && ts_morph.Node.isStringLiteral(initializer) ? initializer.getLiteralValue() : void 0;
468
- }, void 0);
469
- }, void 0);
470
- if (importResolution) return importResolution;
471
- return null;
472
- };
404
+ }
473
405
 
474
406
  //#endregion
475
407
  exports.analyzeComponent = analyzeComponent;