@openrewrite/recipes-angular 1.27.0 → 1.29.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 (352) hide show
  1. package/dist/index.d.ts +37 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +227 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/libraries/cdk/find-cdk-signature-changes.d.ts +0 -2
  6. package/dist/libraries/cdk/find-cdk-signature-changes.d.ts.map +1 -1
  7. package/dist/libraries/cdk/find-cdk-signature-changes.js +2 -8
  8. package/dist/libraries/cdk/find-cdk-signature-changes.js.map +1 -1
  9. package/dist/libraries/cdk/migrate-cdk-sass-imports.d.ts.map +1 -1
  10. package/dist/libraries/cdk/migrate-cdk-sass-imports.js +4 -7
  11. package/dist/libraries/cdk/migrate-cdk-sass-imports.js.map +1 -1
  12. package/dist/libraries/cdk/migrate-cdk-stepper.js +1 -1
  13. package/dist/libraries/cdk/migrate-cdk-stepper.js.map +1 -1
  14. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.d.ts.map +1 -1
  15. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js +2 -4
  16. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js.map +1 -1
  17. package/dist/libraries/cdk/migrate-focus-trap-factory-create.d.ts.map +1 -1
  18. package/dist/libraries/cdk/migrate-focus-trap-factory-create.js +2 -1
  19. package/dist/libraries/cdk/migrate-focus-trap-factory-create.js.map +1 -1
  20. package/dist/libraries/cdk/remove-cdk-super-arguments.d.ts.map +1 -1
  21. package/dist/libraries/cdk/remove-cdk-super-arguments.js +1 -2
  22. package/dist/libraries/cdk/remove-cdk-super-arguments.js.map +1 -1
  23. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.d.ts.map +1 -1
  24. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js +5 -7
  25. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js.map +1 -1
  26. package/dist/libraries/cdk/rename-portal-template-selectors.d.ts.map +1 -1
  27. package/dist/libraries/cdk/rename-portal-template-selectors.js +3 -4
  28. package/dist/libraries/cdk/rename-portal-template-selectors.js.map +1 -1
  29. package/dist/libraries/cdk/upgrade-to-cdk.d.ts.map +1 -1
  30. package/dist/libraries/cdk/upgrade-to-cdk.js +7 -12
  31. package/dist/libraries/cdk/upgrade-to-cdk.js.map +1 -1
  32. package/dist/libraries/components/lst.d.ts +11 -0
  33. package/dist/libraries/components/lst.d.ts.map +1 -1
  34. package/dist/libraries/components/lst.js +40 -0
  35. package/dist/libraries/components/lst.js.map +1 -1
  36. package/dist/libraries/components/style-sources.d.ts +12 -0
  37. package/dist/libraries/components/style-sources.d.ts.map +1 -0
  38. package/dist/libraries/components/style-sources.js +93 -0
  39. package/dist/libraries/components/style-sources.js.map +1 -0
  40. package/dist/libraries/components/stylesheets.d.ts +13 -0
  41. package/dist/libraries/components/stylesheets.d.ts.map +1 -1
  42. package/dist/libraries/components/stylesheets.js +55 -17
  43. package/dist/libraries/components/stylesheets.js.map +1 -1
  44. package/dist/libraries/components/symbols.d.ts +4 -1
  45. package/dist/libraries/components/symbols.d.ts.map +1 -1
  46. package/dist/libraries/components/symbols.js +6 -3
  47. package/dist/libraries/components/symbols.js.map +1 -1
  48. package/dist/libraries/components/template-elements.d.ts +40 -0
  49. package/dist/libraries/components/template-elements.d.ts.map +1 -0
  50. package/dist/libraries/components/template-elements.js +96 -0
  51. package/dist/libraries/components/template-elements.js.map +1 -0
  52. package/dist/libraries/components/templates.d.ts +7 -0
  53. package/dist/libraries/components/templates.d.ts.map +1 -1
  54. package/dist/libraries/components/templates.js +59 -48
  55. package/dist/libraries/components/templates.js.map +1 -1
  56. package/dist/libraries/material/add-system-variables-prefix.d.ts +11 -0
  57. package/dist/libraries/material/add-system-variables-prefix.d.ts.map +1 -0
  58. package/dist/libraries/material/add-system-variables-prefix.js +98 -0
  59. package/dist/libraries/material/add-system-variables-prefix.js.map +1 -0
  60. package/dist/libraries/material/add-theme-base-mixins.d.ts +19 -0
  61. package/dist/libraries/material/add-theme-base-mixins.d.ts.map +1 -0
  62. package/dist/libraries/material/add-theme-base-mixins.js +176 -0
  63. package/dist/libraries/material/add-theme-base-mixins.js.map +1 -0
  64. package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts +8 -0
  65. package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts.map +1 -0
  66. package/dist/libraries/material/find-chip-input-event-without-chip-input.js +94 -0
  67. package/dist/libraries/material/find-chip-input-event-without-chip-input.js.map +1 -0
  68. package/dist/libraries/material/find-legacy-material-usage.d.ts +8 -0
  69. package/dist/libraries/material/find-legacy-material-usage.d.ts.map +1 -0
  70. package/dist/libraries/material/find-legacy-material-usage.js +95 -0
  71. package/dist/libraries/material/find-legacy-material-usage.js.map +1 -0
  72. package/dist/libraries/material/find-material-constructor-changes.d.ts +74 -0
  73. package/dist/libraries/material/find-material-constructor-changes.d.ts.map +1 -0
  74. package/dist/libraries/material/find-material-constructor-changes.js +266 -0
  75. package/dist/libraries/material/find-material-constructor-changes.js.map +1 -0
  76. package/dist/libraries/material/find-mdc-breaking-changes.d.ts +45 -0
  77. package/dist/libraries/material/find-mdc-breaking-changes.d.ts.map +1 -0
  78. package/dist/libraries/material/find-mdc-breaking-changes.js +312 -0
  79. package/dist/libraries/material/find-mdc-breaking-changes.js.map +1 -0
  80. package/dist/libraries/material/find-mixin-error-state-without-state-changes.d.ts +8 -0
  81. package/dist/libraries/material/find-mixin-error-state-without-state-changes.d.ts.map +1 -0
  82. package/dist/libraries/material/find-mixin-error-state-without-state-changes.js +125 -0
  83. package/dist/libraries/material/find-mixin-error-state-without-state-changes.js.map +1 -0
  84. package/dist/libraries/material/find-raw-palette-themes.d.ts +28 -0
  85. package/dist/libraries/material/find-raw-palette-themes.d.ts.map +1 -0
  86. package/dist/libraries/material/find-raw-palette-themes.js +122 -0
  87. package/dist/libraries/material/find-raw-palette-themes.js.map +1 -0
  88. package/dist/libraries/material/find-removed-material-apis.d.ts +20 -0
  89. package/dist/libraries/material/find-removed-material-apis.d.ts.map +1 -0
  90. package/dist/libraries/material/find-removed-material-apis.js +60 -0
  91. package/dist/libraries/material/find-removed-material-apis.js.map +1 -0
  92. package/dist/libraries/material/find-removed-material-classes.d.ts +13 -0
  93. package/dist/libraries/material/find-removed-material-classes.d.ts.map +1 -0
  94. package/dist/libraries/material/find-removed-material-classes.js +144 -0
  95. package/dist/libraries/material/find-removed-material-classes.js.map +1 -0
  96. package/dist/libraries/material/find-removed-material-members.d.ts +67 -0
  97. package/dist/libraries/material/find-removed-material-members.d.ts.map +1 -0
  98. package/dist/libraries/material/find-removed-material-members.js +167 -0
  99. package/dist/libraries/material/find-removed-material-members.js.map +1 -0
  100. package/dist/libraries/material/find-slide-toggle-drag-options.d.ts +10 -0
  101. package/dist/libraries/material/find-slide-toggle-drag-options.d.ts.map +1 -0
  102. package/dist/libraries/material/find-slide-toggle-drag-options.js +96 -0
  103. package/dist/libraries/material/find-slide-toggle-drag-options.js.map +1 -0
  104. package/dist/libraries/material/material-15-classes.d.ts +6 -0
  105. package/dist/libraries/material/material-15-classes.d.ts.map +1 -0
  106. package/dist/libraries/material/material-15-classes.js +435 -0
  107. package/dist/libraries/material/material-15-classes.js.map +1 -0
  108. package/dist/libraries/material/material-entry-points.d.ts +3 -0
  109. package/dist/libraries/material/material-entry-points.d.ts.map +1 -0
  110. package/dist/libraries/material/material-entry-points.js +201 -0
  111. package/dist/libraries/material/material-entry-points.js.map +1 -0
  112. package/dist/libraries/material/material-legacy-symbols.d.ts +2 -0
  113. package/dist/libraries/material/material-legacy-symbols.d.ts.map +1 -0
  114. package/dist/libraries/material/material-legacy-symbols.js +559 -0
  115. package/dist/libraries/material/material-legacy-symbols.js.map +1 -0
  116. package/dist/libraries/material/material-theming-api.d.ts +23 -0
  117. package/dist/libraries/material/material-theming-api.d.ts.map +1 -0
  118. package/dist/libraries/material/material-theming-api.js +446 -0
  119. package/dist/libraries/material/material-theming-api.js.map +1 -0
  120. package/dist/libraries/material/material-version.d.ts +38 -0
  121. package/dist/libraries/material/material-version.d.ts.map +1 -0
  122. package/dist/libraries/material/material-version.js +190 -0
  123. package/dist/libraries/material/material-version.js.map +1 -0
  124. package/dist/libraries/material/migrate-legacy-material.d.ts +60 -0
  125. package/dist/libraries/material/migrate-legacy-material.d.ts.map +1 -0
  126. package/dist/libraries/material/migrate-legacy-material.js +224 -0
  127. package/dist/libraries/material/migrate-legacy-material.js.map +1 -0
  128. package/dist/libraries/material/migrate-list-item-harness-content-loader.d.ts +8 -0
  129. package/dist/libraries/material/migrate-list-item-harness-content-loader.d.ts.map +1 -0
  130. package/dist/libraries/material/migrate-list-item-harness-content-loader.js +62 -0
  131. package/dist/libraries/material/migrate-list-item-harness-content-loader.js.map +1 -0
  132. package/dist/libraries/material/migrate-m2-theming-api.d.ts +12 -0
  133. package/dist/libraries/material/migrate-m2-theming-api.d.ts.map +1 -0
  134. package/dist/libraries/material/migrate-m2-theming-api.js +117 -0
  135. package/dist/libraries/material/migrate-m2-theming-api.js.map +1 -0
  136. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts +11 -0
  137. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts.map +1 -0
  138. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js +48 -0
  139. package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js.map +1 -0
  140. package/dist/libraries/material/migrate-material-15-typography.d.ts +21 -0
  141. package/dist/libraries/material/migrate-material-15-typography.d.ts.map +1 -0
  142. package/dist/libraries/material/migrate-material-15-typography.js +174 -0
  143. package/dist/libraries/material/migrate-material-15-typography.js.map +1 -0
  144. package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts +8 -0
  145. package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts.map +1 -0
  146. package/dist/libraries/material/migrate-material-secondary-entry-points.js +196 -0
  147. package/dist/libraries/material/migrate-material-secondary-entry-points.js.map +1 -0
  148. package/dist/libraries/material/migrate-material-theming-api.d.ts +18 -0
  149. package/dist/libraries/material/migrate-material-theming-api.d.ts.map +1 -0
  150. package/dist/libraries/material/migrate-material-theming-api.js +199 -0
  151. package/dist/libraries/material/migrate-material-theming-api.js.map +1 -0
  152. package/dist/libraries/material/migrate-mdc-styles.d.ts +23 -0
  153. package/dist/libraries/material/migrate-mdc-styles.d.ts.map +1 -0
  154. package/dist/libraries/material/migrate-mdc-styles.js +136 -0
  155. package/dist/libraries/material/migrate-mdc-styles.js.map +1 -0
  156. package/dist/libraries/material/migrate-mdc-templates.d.ts +18 -0
  157. package/dist/libraries/material/migrate-mdc-templates.d.ts.map +1 -0
  158. package/dist/libraries/material/migrate-mdc-templates.js +330 -0
  159. package/dist/libraries/material/migrate-mdc-templates.js.map +1 -0
  160. package/dist/libraries/material/migrate-selection-list-change-option.d.ts +8 -0
  161. package/dist/libraries/material/migrate-selection-list-change-option.d.ts.map +1 -0
  162. package/dist/libraries/material/migrate-selection-list-change-option.js +49 -0
  163. package/dist/libraries/material/migrate-selection-list-change-option.js.map +1 -0
  164. package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts +8 -0
  165. package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts.map +1 -0
  166. package/dist/libraries/material/remove-mat-stepper-document-argument.js +71 -0
  167. package/dist/libraries/material/remove-mat-stepper-document-argument.js.map +1 -0
  168. package/dist/libraries/material/remove-update-active-link-argument.d.ts +8 -0
  169. package/dist/libraries/material/remove-update-active-link-argument.d.ts.map +1 -0
  170. package/dist/libraries/material/remove-update-active-link-argument.js +53 -0
  171. package/dist/libraries/material/remove-update-active-link-argument.js.map +1 -0
  172. package/dist/libraries/material/rename-material-members.d.ts +51 -0
  173. package/dist/libraries/material/rename-material-members.d.ts.map +1 -0
  174. package/dist/libraries/material/rename-material-members.js +125 -0
  175. package/dist/libraries/material/rename-material-members.js.map +1 -0
  176. package/dist/libraries/material/rename-material-style-names.d.ts +35 -0
  177. package/dist/libraries/material/rename-material-style-names.d.ts.map +1 -0
  178. package/dist/libraries/material/rename-material-style-names.js +182 -0
  179. package/dist/libraries/material/rename-material-style-names.js.map +1 -0
  180. package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts +10 -0
  181. package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts.map +1 -0
  182. package/dist/libraries/material/rename-textarea-autosize-attributes.js +47 -0
  183. package/dist/libraries/material/rename-textarea-autosize-attributes.js.map +1 -0
  184. package/dist/libraries/material/upgrade-to-material.d.ts +74 -0
  185. package/dist/libraries/material/upgrade-to-material.d.ts.map +1 -0
  186. package/dist/libraries/material/upgrade-to-material.js +312 -0
  187. package/dist/libraries/material/upgrade-to-material.js.map +1 -0
  188. package/dist/migration/js-support.d.ts +1 -1
  189. package/dist/migration/js-support.d.ts.map +1 -1
  190. package/dist/migration/js-support.js +2 -2
  191. package/dist/migration/js-support.js.map +1 -1
  192. package/dist/migration/json-support.d.ts +11 -0
  193. package/dist/migration/json-support.d.ts.map +1 -1
  194. package/dist/migration/json-support.js +50 -0
  195. package/dist/migration/json-support.js.map +1 -1
  196. package/dist/migration/move-common-engine-to-ssr-node.d.ts +8 -0
  197. package/dist/migration/move-common-engine-to-ssr-node.d.ts.map +1 -0
  198. package/dist/migration/move-common-engine-to-ssr-node.js +68 -0
  199. package/dist/migration/move-common-engine-to-ssr-node.js.map +1 -0
  200. package/dist/migration/remove-guard-and-resolve-interfaces.d.ts +8 -0
  201. package/dist/migration/remove-guard-and-resolve-interfaces.d.ts.map +1 -0
  202. package/dist/migration/remove-guard-and-resolve-interfaces.js +117 -0
  203. package/dist/migration/remove-guard-and-resolve-interfaces.js.map +1 -0
  204. package/dist/migration/remove-show-circular-dependencies.d.ts +8 -0
  205. package/dist/migration/remove-show-circular-dependencies.d.ts.map +1 -0
  206. package/dist/migration/remove-show-circular-dependencies.js +57 -0
  207. package/dist/migration/remove-show-circular-dependencies.js.map +1 -0
  208. package/dist/migration/rename-ssr-experimental-platform.d.ts.map +1 -1
  209. package/dist/migration/rename-ssr-experimental-platform.js +10 -47
  210. package/dist/migration/rename-ssr-experimental-platform.js.map +1 -1
  211. package/dist/migration/replace-browser-target.d.ts +8 -0
  212. package/dist/migration/replace-browser-target.d.ts.map +1 -0
  213. package/dist/migration/replace-browser-target.js +62 -0
  214. package/dist/migration/replace-browser-target.js.map +1 -0
  215. package/dist/migration/replace-default-collection.d.ts +8 -0
  216. package/dist/migration/replace-default-collection.d.ts.map +1 -0
  217. package/dist/migration/replace-default-collection.js +59 -0
  218. package/dist/migration/replace-default-collection.js.map +1 -0
  219. package/dist/migration/replace-get-current-navigation.d.ts +8 -0
  220. package/dist/migration/replace-get-current-navigation.d.ts.map +1 -0
  221. package/dist/migration/replace-get-current-navigation.js +69 -0
  222. package/dist/migration/replace-get-current-navigation.js.map +1 -0
  223. package/dist/migration/replace-initializer-providers.d.ts +8 -0
  224. package/dist/migration/replace-initializer-providers.d.ts.map +1 -0
  225. package/dist/migration/replace-initializer-providers.js +169 -0
  226. package/dist/migration/replace-initializer-providers.js.map +1 -0
  227. package/dist/migration/replace-preserve-query-params.d.ts +8 -0
  228. package/dist/migration/replace-preserve-query-params.d.ts.map +1 -0
  229. package/dist/migration/replace-preserve-query-params.js +115 -0
  230. package/dist/migration/replace-preserve-query-params.js.map +1 -0
  231. package/dist/migration/replace-provide-server-routing.d.ts +8 -0
  232. package/dist/migration/replace-provide-server-routing.d.ts.map +1 -0
  233. package/dist/migration/replace-provide-server-routing.js +98 -0
  234. package/dist/migration/replace-provide-server-routing.js.map +1 -0
  235. package/dist/migration/upgrade-to-angular-10.d.ts.map +1 -1
  236. package/dist/migration/upgrade-to-angular-10.js +4 -1
  237. package/dist/migration/upgrade-to-angular-10.js.map +1 -1
  238. package/dist/migration/upgrade-to-angular-11.d.ts.map +1 -1
  239. package/dist/migration/upgrade-to-angular-11.js +13 -2
  240. package/dist/migration/upgrade-to-angular-11.js.map +1 -1
  241. package/dist/migration/upgrade-to-angular-12.d.ts.map +1 -1
  242. package/dist/migration/upgrade-to-angular-12.js +4 -1
  243. package/dist/migration/upgrade-to-angular-12.js.map +1 -1
  244. package/dist/migration/upgrade-to-angular-13.d.ts.map +1 -1
  245. package/dist/migration/upgrade-to-angular-13.js +4 -1
  246. package/dist/migration/upgrade-to-angular-13.js.map +1 -1
  247. package/dist/migration/upgrade-to-angular-14.d.ts.map +1 -1
  248. package/dist/migration/upgrade-to-angular-14.js +11 -1
  249. package/dist/migration/upgrade-to-angular-14.js.map +1 -1
  250. package/dist/migration/upgrade-to-angular-15.d.ts.map +1 -1
  251. package/dist/migration/upgrade-to-angular-15.js +4 -1
  252. package/dist/migration/upgrade-to-angular-15.js.map +1 -1
  253. package/dist/migration/upgrade-to-angular-16.d.ts.map +1 -1
  254. package/dist/migration/upgrade-to-angular-16.js +3 -0
  255. package/dist/migration/upgrade-to-angular-16.js.map +1 -1
  256. package/dist/migration/upgrade-to-angular-17.d.ts.map +1 -1
  257. package/dist/migration/upgrade-to-angular-17.js +4 -1
  258. package/dist/migration/upgrade-to-angular-17.js.map +1 -1
  259. package/dist/migration/upgrade-to-angular-18.d.ts.map +1 -1
  260. package/dist/migration/upgrade-to-angular-18.js +4 -1
  261. package/dist/migration/upgrade-to-angular-18.js.map +1 -1
  262. package/dist/migration/upgrade-to-angular-19.d.ts.map +1 -1
  263. package/dist/migration/upgrade-to-angular-19.js +14 -2
  264. package/dist/migration/upgrade-to-angular-19.js.map +1 -1
  265. package/dist/migration/upgrade-to-angular-20.d.ts.map +1 -1
  266. package/dist/migration/upgrade-to-angular-20.js +14 -1
  267. package/dist/migration/upgrade-to-angular-20.js.map +1 -1
  268. package/dist/migration/upgrade-to-angular-21.d.ts.map +1 -1
  269. package/dist/migration/upgrade-to-angular-21.js +3 -0
  270. package/dist/migration/upgrade-to-angular-21.js.map +1 -1
  271. package/dist/migration/upgrade-to-angular-8.d.ts.map +1 -1
  272. package/dist/migration/upgrade-to-angular-8.js +4 -1
  273. package/dist/migration/upgrade-to-angular-8.js.map +1 -1
  274. package/dist/migration/upgrade-to-angular-9.d.ts.map +1 -1
  275. package/dist/migration/upgrade-to-angular-9.js +4 -1
  276. package/dist/migration/upgrade-to-angular-9.js.map +1 -1
  277. package/package.json +6 -5
  278. package/src/index.ts +216 -0
  279. package/src/libraries/cdk/find-cdk-signature-changes.ts +1 -6
  280. package/src/libraries/cdk/migrate-cdk-sass-imports.ts +4 -7
  281. package/src/libraries/cdk/migrate-cdk-stepper.ts +2 -2
  282. package/src/libraries/cdk/migrate-deprecated-overlay-sass.ts +2 -4
  283. package/src/libraries/cdk/migrate-focus-trap-factory-create.ts +2 -1
  284. package/src/libraries/cdk/remove-cdk-super-arguments.ts +1 -2
  285. package/src/libraries/cdk/remove-portal-factory-resolver-arguments.ts +4 -6
  286. package/src/libraries/cdk/rename-portal-template-selectors.ts +3 -4
  287. package/src/libraries/cdk/upgrade-to-cdk.ts +7 -12
  288. package/src/libraries/components/lst.ts +29 -2
  289. package/src/libraries/components/style-sources.ts +69 -0
  290. package/src/libraries/components/stylesheets.ts +50 -10
  291. package/src/libraries/components/symbols.ts +5 -4
  292. package/src/libraries/components/template-elements.ts +118 -0
  293. package/src/libraries/components/templates.ts +48 -35
  294. package/src/libraries/material/add-system-variables-prefix.ts +87 -0
  295. package/src/libraries/material/add-theme-base-mixins.ts +159 -0
  296. package/src/libraries/material/find-chip-input-event-without-chip-input.ts +62 -0
  297. package/src/libraries/material/find-legacy-material-usage.ts +67 -0
  298. package/src/libraries/material/find-material-constructor-changes.ts +230 -0
  299. package/src/libraries/material/find-mdc-breaking-changes.ts +262 -0
  300. package/src/libraries/material/find-mixin-error-state-without-state-changes.ts +89 -0
  301. package/src/libraries/material/find-raw-palette-themes.ts +98 -0
  302. package/src/libraries/material/find-removed-material-apis.ts +54 -0
  303. package/src/libraries/material/find-removed-material-classes.ts +119 -0
  304. package/src/libraries/material/find-removed-material-members.ts +145 -0
  305. package/src/libraries/material/find-slide-toggle-drag-options.ts +66 -0
  306. package/src/libraries/material/material-15-classes.ts +435 -0
  307. package/src/libraries/material/material-entry-points.ts +198 -0
  308. package/src/libraries/material/material-legacy-symbols.ts +557 -0
  309. package/src/libraries/material/material-theming-api.ts +454 -0
  310. package/src/libraries/material/material-version.ts +174 -0
  311. package/src/libraries/material/migrate-legacy-material.ts +196 -0
  312. package/src/libraries/material/migrate-list-item-harness-content-loader.ts +39 -0
  313. package/src/libraries/material/migrate-m2-theming-api.ts +95 -0
  314. package/src/libraries/material/migrate-mat-core-to-elevation-classes.ts +35 -0
  315. package/src/libraries/material/migrate-material-15-typography.ts +145 -0
  316. package/src/libraries/material/migrate-material-secondary-entry-points.ts +186 -0
  317. package/src/libraries/material/migrate-material-theming-api.ts +197 -0
  318. package/src/libraries/material/migrate-mdc-styles.ts +110 -0
  319. package/src/libraries/material/migrate-mdc-templates.ts +292 -0
  320. package/src/libraries/material/migrate-selection-list-change-option.ts +28 -0
  321. package/src/libraries/material/remove-mat-stepper-document-argument.ts +43 -0
  322. package/src/libraries/material/remove-update-active-link-argument.ts +32 -0
  323. package/src/libraries/material/rename-material-members.ts +109 -0
  324. package/src/libraries/material/rename-material-style-names.ts +164 -0
  325. package/src/libraries/material/rename-textarea-autosize-attributes.ts +35 -0
  326. package/src/libraries/material/upgrade-to-material.ts +274 -0
  327. package/src/migration/js-support.ts +2 -2
  328. package/src/migration/json-support.ts +50 -1
  329. package/src/migration/move-common-engine-to-ssr-node.ts +46 -0
  330. package/src/migration/remove-guard-and-resolve-interfaces.ts +89 -0
  331. package/src/migration/remove-show-circular-dependencies.ts +40 -0
  332. package/src/migration/rename-ssr-experimental-platform.ts +8 -49
  333. package/src/migration/replace-browser-target.ts +45 -0
  334. package/src/migration/replace-default-collection.ts +45 -0
  335. package/src/migration/replace-get-current-navigation.ts +50 -0
  336. package/src/migration/replace-initializer-providers.ts +153 -0
  337. package/src/migration/replace-preserve-query-params.ts +88 -0
  338. package/src/migration/replace-provide-server-routing.ts +79 -0
  339. package/src/migration/upgrade-to-angular-10.ts +4 -1
  340. package/src/migration/upgrade-to-angular-11.ts +13 -2
  341. package/src/migration/upgrade-to-angular-12.ts +4 -1
  342. package/src/migration/upgrade-to-angular-13.ts +4 -1
  343. package/src/migration/upgrade-to-angular-14.ts +11 -1
  344. package/src/migration/upgrade-to-angular-15.ts +4 -1
  345. package/src/migration/upgrade-to-angular-16.ts +3 -0
  346. package/src/migration/upgrade-to-angular-17.ts +4 -1
  347. package/src/migration/upgrade-to-angular-18.ts +4 -1
  348. package/src/migration/upgrade-to-angular-19.ts +14 -2
  349. package/src/migration/upgrade-to-angular-20.ts +14 -1
  350. package/src/migration/upgrade-to-angular-21.ts +3 -0
  351. package/src/migration/upgrade-to-angular-8.ts +4 -1
  352. package/src/migration/upgrade-to-angular-9.ts +4 -1
@@ -19,19 +19,22 @@ export abstract class StylesheetRecipe extends Recipe {
19
19
  }
20
20
 
21
21
  async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
22
- const migrate = (content: string) => this.migrate(content);
23
- const acceptsPath = (sourcePath: string) => this.acceptsPath(sourcePath);
24
- return new class extends PlainTextVisitor<ExecutionContext> {
25
- override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
26
- const t = await super.visitText(text, p) as PlainText;
27
- if (!t || !acceptsPath(t.sourcePath)) return t;
28
- const updated = migrate(t.text);
29
- return updated === t.text ? t : {...t, text: updated, snippets: []};
30
- }
31
- }();
22
+ return stylesheetEditor(content => this.migrate(content), sourcePath => this.acceptsPath(sourcePath));
32
23
  }
33
24
  }
34
25
 
26
+ export function stylesheetEditor(migrate: (content: string) => string,
27
+ acceptsPath: (sourcePath: string) => boolean = isStylesheet): TreeVisitor<any, ExecutionContext> {
28
+ return new class extends PlainTextVisitor<ExecutionContext> {
29
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
30
+ const t = await super.visitText(text, p) as PlainText;
31
+ if (!t || !acceptsPath(t.sourcePath)) return t;
32
+ const updated = migrate(t.text);
33
+ return updated === t.text ? t : {...t, text: updated, snippets: []};
34
+ }
35
+ }();
36
+ }
37
+
35
38
  export function isStylesheet(sourcePath: string): boolean {
36
39
  return sourcePath.endsWith('.scss') || sourcePath.endsWith('.css');
37
40
  }
@@ -50,6 +53,43 @@ export function maskComments(content: string): string {
50
53
  return content.replace(COMMENT, '');
51
54
  }
52
55
 
56
+ function nestedParentheses(depth: number): string {
57
+ return depth === 0 ? '[^()]*' : `(?:[^()]|\\(${nestedParentheses(depth - 1)}\\))*`;
58
+ }
59
+
60
+ /** A pattern for the text between the parentheses of a Sass call, with parentheses nested up to five levels deep. */
61
+ export const SASS_ARGUMENTS = nestedParentheses(5);
62
+
63
+ /** A pattern for the end of a Sass statement, whose `;` is optional when it is the last of its block. */
64
+ export const SASS_STATEMENT_END = '(?:\\s*;|(?=\\s*(?:\\}|$)))';
65
+
66
+ /** A Sass statement with its closing `;`, which a statement that had none needs once another one follows it. */
67
+ export function withSemicolon(statement: string): string {
68
+ return statement.endsWith(';') ? statement : `${statement};`;
69
+ }
70
+
71
+ /** The offset of the `{` that opens the block around an offset of a stylesheet, or -1 at the top level. */
72
+ export function enclosingBlock(content: string, offset: number): number {
73
+ let depth = 0;
74
+ for (let i = offset - 1; i >= 0; i--) {
75
+ if (content[i] === '}') depth++;
76
+ else if (content[i] === '{' && depth-- === 0) return i;
77
+ }
78
+ return -1;
79
+ }
80
+
81
+ /** Whether the block around an offset of a stylesheet includes a mixin with these arguments. */
82
+ export function includedInBlock(content: string, mixin: string, args: string, offset: number): boolean {
83
+ const include = new RegExp(`@include\\s+${escapeRegExp(mixin)}\\s*\\(\\s*${escapeRegExp(args.trim())}\\s*\\)`, 'g');
84
+ const block = enclosingBlock(content, offset);
85
+ return [...content.matchAll(include)].some(m => enclosingBlock(content, m.index) === block);
86
+ }
87
+
53
88
  export function escapeRegExp(value: string): string {
54
89
  return value.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
55
90
  }
91
+
92
+ /** An `@include` of a mixin with its arguments. */
93
+ export function includePattern(member: string): RegExp {
94
+ return new RegExp(`([ \\t]*)@include\\s+${escapeRegExp(member)}\\s*(?:\\((${SASS_ARGUMENTS})\\))?${SASS_STATEMENT_END}`, 'g');
95
+ }
@@ -23,7 +23,7 @@ export interface RemovedSymbol {
23
23
  message: string;
24
24
  }
25
25
 
26
- /** One `ChangeImport` per renamed symbol, which also carries every reference bound to the import. */
26
+ /** One `ChangeImport` per renamed symbol, which also covers namespace-qualified references and re-exports. */
27
27
  export function renameSymbols(symbols: RenamedSymbol[]): Recipe[] {
28
28
  return symbols.map(s => new ChangeImport({
29
29
  oldModule: s.module,
@@ -93,12 +93,13 @@ export abstract class FindRemovedSymbols extends Recipe {
93
93
  }
94
94
  }
95
95
 
96
- function moduleOf(imp: JS.Import): string | undefined {
97
- const specifier = imp.moduleSpecifier?.element;
96
+ export function moduleOf(declaration: JS.Import | JS.ExportDeclaration): string | undefined {
97
+ const specifier = declaration.moduleSpecifier?.element;
98
98
  return specifier?.kind === J.Kind.Literal ? (specifier as J.Literal).value as string : undefined;
99
99
  }
100
100
 
101
- function importedName(spec: JS.ImportSpecifier): string | undefined {
101
+ /** The name taken from the module, such as `Old` in `{Old as New}`. */
102
+ export function importedName(spec: JS.ImportSpecifier | JS.ExportSpecifier): string | undefined {
102
103
  const specifier = spec.specifier;
103
104
  if (isIdentifier(specifier)) return specifier.simpleName;
104
105
  if (specifier.kind === JS.Kind.Alias) {
@@ -0,0 +1,118 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ /** An attribute of an opening tag, with offsets into the template. */
8
+ export interface TemplateAttribute {
9
+ /** The name as written, such as `[(ngModel)]` or `#slider`. */
10
+ name: string;
11
+ value?: string;
12
+ start: number;
13
+ end: number;
14
+ }
15
+
16
+ /** An element of a template, with offsets into the template. */
17
+ export interface TemplateElement {
18
+ name: string;
19
+ start: number;
20
+ /** The offset right after the `>` of the opening tag. */
21
+ openEnd: number;
22
+ attributes: TemplateAttribute[];
23
+ /** The offsets of the closing tag, absent for void and self-closing elements. */
24
+ closeStart?: number;
25
+ closeEnd?: number;
26
+ parent?: TemplateElement;
27
+ children: TemplateElement[];
28
+ }
29
+
30
+ const VOID_ELEMENTS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
31
+
32
+ /** Parses the elements of an Angular template, skipping comments and honoring quoted attribute values. */
33
+ export function parseElements(template: string): TemplateElement[] {
34
+ const elements: TemplateElement[] = [];
35
+ const open: TemplateElement[] = [];
36
+ const tag = /<!--[\s\S]*?(?:-->|$)|<\/([a-zA-Z][\w-]*)\s*>|<([a-zA-Z][\w-]*)/g;
37
+ let match: RegExpExecArray | null;
38
+ while ((match = tag.exec(template)) !== null) {
39
+ if (match[1]) {
40
+ const name = match[1].toLowerCase();
41
+ const index = open.map(e => e.name).lastIndexOf(name);
42
+ if (index > -1) {
43
+ open[index].closeStart = match.index;
44
+ open[index].closeEnd = match.index + match[0].length;
45
+ open.length = index;
46
+ }
47
+ continue;
48
+ }
49
+ if (!match[2]) continue;
50
+ const {attributes, end, selfClosing} = parseAttributes(template, match.index + match[0].length);
51
+ const parent = open[open.length - 1];
52
+ const element: TemplateElement = {
53
+ name: match[2].toLowerCase(), start: match.index, openEnd: end, attributes, parent, children: [],
54
+ };
55
+ parent?.children.push(element);
56
+ elements.push(element);
57
+ if (!selfClosing && !VOID_ELEMENTS.has(element.name)) open.push(element);
58
+ tag.lastIndex = end;
59
+ }
60
+ return elements;
61
+ }
62
+
63
+ function parseAttributes(template: string, from: number): {attributes: TemplateAttribute[], end: number, selfClosing: boolean} {
64
+ const attributes: TemplateAttribute[] = [];
65
+ const attribute = /\s*(?:(\/?>)|([^\s=/>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']+)))?|(\S))/y;
66
+ attribute.lastIndex = from;
67
+ let match: RegExpExecArray | null;
68
+ while ((match = attribute.exec(template)) !== null) {
69
+ if (match[1]) return {attributes, end: attribute.lastIndex, selfClosing: match[1] === '/>'};
70
+ if (match[2]) {
71
+ const start = attribute.lastIndex - match[0].trimStart().length;
72
+ attributes.push({name: match[2], value: match[3] ?? match[4] ?? match[5], start, end: attribute.lastIndex});
73
+ }
74
+ }
75
+ return {attributes, end: template.length, selfClosing: false};
76
+ }
77
+
78
+ /** The plain name of an attribute without binding syntax, such as `ngModel` for `[(ngModel)]`. */
79
+ export function bareName(attribute: TemplateAttribute): string {
80
+ return attribute.name.replace(/^(?:\[\(|\[|\(|bind-|on-|bindon-)/, '').replace(/(?:\)\]|\]|\))$/, '');
81
+ }
82
+
83
+ export function attributeNamed(element: TemplateElement, name: string): TemplateAttribute | undefined {
84
+ return element.attributes.find(a => bareName(a) === name);
85
+ }
86
+
87
+ /** The value of a plain attribute, or of a property binding to a single-quoted word such as `[appearance]="'fill'"`. */
88
+ export function literalValue(attribute: TemplateAttribute): string | undefined {
89
+ return attribute.name.startsWith('[') ? attribute.value?.trim().match(/^'(\w+)'$/)?.[1] : attribute.value?.trim();
90
+ }
91
+
92
+ export function descendants(element: TemplateElement): TemplateElement[] {
93
+ return element.children.flatMap(child => [child, ...descendants(child)]);
94
+ }
95
+
96
+ /** A replacement of the template text between two offsets. */
97
+ export interface TemplateEdit {
98
+ start: number;
99
+ end: number;
100
+ text: string;
101
+ }
102
+
103
+ /** Applies edits that do not overlap, keeping the order of edits that insert at the same offset. */
104
+ export function applyEdits(template: string, edits: TemplateEdit[]): string {
105
+ const sorted = edits.map((edit, i) => ({edit, i}))
106
+ .sort((a, b) => b.edit.start - a.edit.start || b.edit.end - a.edit.end || b.i - a.i)
107
+ .map(({edit}) => edit);
108
+ let result = template;
109
+ for (const {start, end, text} of sorted) result = result.slice(0, start) + text + result.slice(end);
110
+ return result;
111
+ }
112
+
113
+ /** An edit that removes an attribute together with the whitespace before it. */
114
+ export function removeAttribute(template: string, attribute: TemplateAttribute): TemplateEdit {
115
+ let start = attribute.start;
116
+ while (start > 0 && /\s/.test(template[start - 1])) start--;
117
+ return {start, end: attribute.end, text: ''};
118
+ }
@@ -4,11 +4,12 @@
4
4
  * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
5
  */
6
6
 
7
- import {Cursor, ExecutionContext, Recipe, Tree, TreeVisitor} from "@openrewrite/rewrite";
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
8
  import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
9
9
  import {JavaScriptVisitor} from "@openrewrite/rewrite/javascript";
10
- import {isIdentifier, isLiteral, J} from "@openrewrite/rewrite/java";
10
+ import {isLiteral, J} from "@openrewrite/rewrite/java";
11
11
  import {create} from "mutative";
12
+ import {inSequence, propertyName} from "./lst";
12
13
  import {escapeRegExp} from "./stylesheets";
13
14
 
14
15
  /** A directive selector or input that a major version renamed, as it appears in a template attribute. */
@@ -33,40 +34,38 @@ export abstract class RenameTemplateAttributes extends Recipe {
33
34
  protected readonly exportAs: TemplateExportAsRename[] = [];
34
35
 
35
36
  async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
36
- const migrate = (template: string) => renameTemplateAttributes(template, this.attributes, this.exportAs);
37
- const html = new class extends PlainTextVisitor<ExecutionContext> {
38
- override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
39
- const t = await super.visitText(text, p) as PlainText;
40
- if (!t || !t.sourcePath.endsWith('.html')) return t;
41
- const updated = migrate(t.text);
42
- return updated === t.text ? t : {...t, text: updated, snippets: []};
43
- }
44
- }();
45
- const inline = new class extends JavaScriptVisitor<ExecutionContext> {
46
- protected async visitPropertyAssignment(property: any, p: ExecutionContext): Promise<J | undefined> {
47
- const prop = await super.visitPropertyAssignment(property, p) as any;
48
- const name = prop?.name?.element;
49
- if (!isIdentifier(name) || name.simpleName !== 'template') return prop;
37
+ return templateAttributesEditor(this.attributes, this.exportAs);
38
+ }
39
+ }
50
40
 
51
- const initializer = prop.initializer;
52
- if (!initializer || !isLiteral(initializer) || typeof initializer.value !== 'string') return prop;
53
- const valueSource = migrate(initializer.valueSource ?? '');
54
- if (valueSource === initializer.valueSource) return prop;
41
+ export function templateAttributesEditor(attributes: TemplateAttributeRename[],
42
+ exportAs: TemplateExportAsRename[] = []): TreeVisitor<any, ExecutionContext> {
43
+ const migrate = (template: string) => renameTemplateAttributes(template, attributes, exportAs);
44
+ const html = new class extends PlainTextVisitor<ExecutionContext> {
45
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
46
+ const t = await super.visitText(text, p) as PlainText;
47
+ if (!t || !t.sourcePath.endsWith('.html')) return t;
48
+ const updated = migrate(t.text);
49
+ return updated === t.text ? t : {...t, text: updated, snippets: []};
50
+ }
51
+ }();
52
+ const inline = new class extends JavaScriptVisitor<ExecutionContext> {
53
+ protected async visitPropertyAssignment(property: any, p: ExecutionContext): Promise<J | undefined> {
54
+ const prop = await super.visitPropertyAssignment(property, p) as any;
55
+ if (propertyName(prop?.name?.element) !== 'template') return prop;
55
56
 
56
- return create(prop, (draft: any) => {
57
- draft.initializer.valueSource = valueSource;
58
- draft.initializer.value = migrate(initializer.value as string);
59
- });
60
- }
61
- }();
62
- // Each visitor returns a source file it does not accept unchanged.
63
- return new class extends TreeVisitor<any, ExecutionContext> {
64
- async visit<R extends Tree>(tree: Tree, p: ExecutionContext, parent?: Cursor): Promise<R | undefined> {
65
- const visited = await html.visit<Tree>(tree, p, parent);
66
- return visited && await inline.visit(visited, p, parent) as R | undefined;
67
- }
68
- }();
69
- }
57
+ const initializer = prop.initializer;
58
+ if (!initializer || !isLiteral(initializer) || typeof initializer.value !== 'string') return prop;
59
+ const valueSource = migrate(initializer.valueSource ?? '');
60
+ if (valueSource === initializer.valueSource) return prop;
61
+
62
+ return create(prop, (draft: any) => {
63
+ draft.initializer.valueSource = valueSource;
64
+ draft.initializer.value = migrate(initializer.value as string);
65
+ });
66
+ }
67
+ }();
68
+ return inSequence(html, inline);
70
69
  }
71
70
 
72
71
  /** Renames attributes inside opening tags and `exportAs` values of reference variables. */
@@ -94,8 +93,22 @@ function renameAttribute(attrs: string, name: string, newName: string): string {
94
93
  return mapOutsideQuotes(attrs, segment => segment.replace(pattern, `$1$2${newName}`));
95
94
  }
96
95
 
96
+ /** Quotes a migrated inline template with the delimiter of its original string literal. */
97
+ export function requote(valueSource: string, value: string): string {
98
+ const quote = valueSource[0];
99
+ let escaped = value.replace(/\\/g, '\\\\');
100
+ escaped = quote === '`' ? escaped.replace(/`/g, '\\`').replace(/\$\{/g, '\\${')
101
+ : escaped.replace(new RegExp(quote, 'g'), `\\${quote}`).replace(/\n/g, '\\n').replace(/\r/g, '\\r');
102
+ return `${quote}${escaped}${quote}`;
103
+ }
104
+
105
+ /** A template without its comments, for checks that only care about live markup. */
106
+ export function withoutHtmlComments(template: string): string {
107
+ return template.replace(/<!--[\s\S]*?(?:-->|$)/g, '');
108
+ }
109
+
97
110
  /** Calls `fn` for the attribute text of every opening tag, honoring quoted attribute values that contain `>`. */
98
- function mapOpeningTags(template: string, fn: (tagName: string, attrs: string) => string): string {
111
+ export function mapOpeningTags(template: string, fn: (tagName: string, attrs: string) => string): string {
99
112
  let result = '';
100
113
  let index = 0;
101
114
  const tagStart = /<([a-zA-Z][\w-]*)/g;
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {stylesheetEditor, withoutComments} from "../components/stylesheets";
9
+ import {MaterialVersionRecipe} from "./material-version";
10
+
11
+ const KEY = 'use-system-variables';
12
+
13
+ const PREFIX_KEY = 'system-variables-prefix';
14
+
15
+ export class AddSystemVariablesPrefix extends MaterialVersionRecipe {
16
+ readonly name = "org.openrewrite.angular.material.AddSystemVariablesPrefix";
17
+ readonly displayName = "Add an explicit `system-variables-prefix` to themes that use system variables";
18
+ readonly description = "Material 19 changed the default prefix of the CSS variables that themes with " +
19
+ "`use-system-variables: true` emit. Adds `system-variables-prefix: sys` to those theme maps so the variables " +
20
+ "keep their names. This is the system variable prefix migration of the `@angular/material` 19 `ng update`.";
21
+
22
+ protected readonly version = 19;
23
+
24
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
25
+ return stylesheetEditor(content => this.migrate(content), sourcePath => sourcePath.endsWith('.scss'));
26
+ }
27
+
28
+ protected migrate(content: string): string {
29
+ if (!content.includes('@angular/material') || !content.includes(KEY)) return content;
30
+ return withoutComments(content, addPrefix);
31
+ }
32
+ }
33
+
34
+ function addPrefix(content: string): string {
35
+ const insertions: {at: number, text: string}[] = [];
36
+ let index = content.indexOf(KEY);
37
+ while (index > -1) {
38
+ const colon = content.indexOf(':', index);
39
+ const valueEnd = colon === -1 ? -1 : endOfValue(content, colon);
40
+ if (valueEnd === -1) {
41
+ index = content.indexOf(KEY, index + KEY.length);
42
+ continue;
43
+ }
44
+ if (content.slice(colon + 1, valueEnd).trim() === 'true' && !hasPrefix(content, index)) {
45
+ insertions.push(prefixAfterValue(content, index, valueEnd));
46
+ }
47
+ index = content.indexOf(KEY, valueEnd);
48
+ }
49
+ let migrated = content;
50
+ for (const {at, text} of insertions.reverse()) migrated = migrated.slice(0, at) + text + migrated.slice(at);
51
+ return migrated;
52
+ }
53
+
54
+ function endOfValue(content: string, from: number): number {
55
+ for (let i = from + 1; i < content.length; i++) {
56
+ if (content[i] === ',' || content[i] === '\n' || content[i] === ')') return i;
57
+ }
58
+ return -1;
59
+ }
60
+
61
+ /** The prefix entry to insert after the value of the key, on a line of its own when the map spans lines. */
62
+ function prefixAfterValue(content: string, keyIndex: number, valueEnd: number): {at: number, text: string} {
63
+ const entry = `${PREFIX_KEY}: sys`;
64
+ const lineStart = content.lastIndexOf('\n', keyIndex) + 1;
65
+ const indent = content.slice(lineStart, keyIndex);
66
+ const multiline = /^\s*$/.test(indent);
67
+ const newline = content[valueEnd - 1] === '\r' ? '\r\n' : '\n';
68
+ if (content[valueEnd] === ',') {
69
+ const restOfLine = content.slice(valueEnd + 1).match(/^[ \t]*\r?(?:\n|$)/);
70
+ return restOfLine && multiline ?
71
+ {at: valueEnd + 1, text: `${newline}${indent}${entry},`} :
72
+ {at: valueEnd + 1, text: ` ${entry},`};
73
+ }
74
+ if (content[valueEnd] === '\n') {
75
+ const at = newline === '\r\n' ? valueEnd - 1 : valueEnd;
76
+ return {at, text: `,${newline}${indent}${entry}`};
77
+ }
78
+ return {at: valueEnd, text: `, ${entry}`};
79
+ }
80
+
81
+ /** Whether the map that enables system variables already sets their prefix. */
82
+ function hasPrefix(content: string, keyIndex: number): boolean {
83
+ const mapEnd = content.indexOf(')', keyIndex);
84
+ if (mapEnd === -1) return false;
85
+ const mapStart = content.lastIndexOf('(', keyIndex);
86
+ return mapStart > -1 && content.slice(mapStart, mapEnd).includes(PREFIX_KEY);
87
+ }
@@ -0,0 +1,159 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {Cursor, ExecutionContext, foundSearchResult, ScanningRecipe, Tree, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
9
+ import {escapeRegExp, includePattern, maskComments, withoutComments, withSemicolon} from "../components/stylesheets";
10
+ import {beforeMaterialVersion, materialMajorScanner, materialNamespaces} from "./material-version";
11
+ import {withMdcMixins} from "./migrate-legacy-material";
12
+ import {hasSearchResult} from "../components/lst";
13
+ import {migrateThemingApi} from "./migrate-material-theming-api";
14
+
15
+ /** The comment that the `@angular/material` 17 `ng update` puts above the base mixins it adds. */
16
+ const PREAMBLE = `
17
+ // The following mixins include base theme styles that are only needed once per application. These
18
+ // theme styles do not depend on the color, typography, or density settings in your theme. However,
19
+ // these styles may differ depending on the theme's design system. Currently all themes use the
20
+ // Material 2 design system, but in the future it may be possible to create theme based on other
21
+ // design systems, such as Material 3.
22
+ //
23
+ // Please note: you do not need to include the 'base' mixins, if you include the corresponding
24
+ // 'theme' mixin elsewhere in your Sass. The full 'theme' mixins already include the base styles.
25
+ //
26
+ // To learn more about "base" theme styles visit our theming guide:
27
+ // https://material.angular.io/guide/theming#theming-dimensions
28
+ //
29
+ // TODO(v17): Please move these @include statements to the preferred place in your Sass, and pass
30
+ // your theme to them. This will ensure the correct values for your app are included.`.split('\n');
31
+
32
+ interface MixinSet {
33
+ theme: string;
34
+ color: string;
35
+ typography: string;
36
+ density: string;
37
+ base: string;
38
+ }
39
+
40
+ const MIXIN_SETS: MixinSet[] = [
41
+ {theme: 'all-component-themes', color: 'all-component-colors', typography: 'all-component-typographies',
42
+ density: 'all-component-densities', base: 'all-component-bases'},
43
+ ...['core', 'card', 'progress-bar', 'tooltip', 'form-field', 'input', 'select', 'autocomplete', 'dialog', 'chips',
44
+ 'slide-toggle', 'radio', 'slider', 'menu', 'list', 'paginator', 'tabs', 'checkbox', 'button', 'icon-button',
45
+ 'fab', 'snack-bar', 'table', 'progress-spinner', 'badge', 'bottom-sheet', 'button-toggle', 'datepicker',
46
+ 'divider', 'expansion', 'grid-list', 'icon', 'sidenav', 'stepper', 'sort', 'toolbar', 'tree']
47
+ .map(c => ({theme: `${c}-theme`, color: `${c}-color`, typography: `${c}-typography`, density: `${c}-density`, base: `${c}-base`})),
48
+ ];
49
+
50
+ interface Accumulator {
51
+ majors: Map<string, number>;
52
+ found: Set<string>;
53
+ missing: Set<string>;
54
+ /** The arguments that stylesheets pass to color, typography and density mixins. */
55
+ themes: Set<string>;
56
+ }
57
+
58
+ function includes(content: string, ns: string, mixin: string): string[] {
59
+ return [...content.matchAll(includePattern(`${ns}${mixin}`))].map(m => (m[2] ?? '').split(',')[0].trim());
60
+ }
61
+
62
+ export class AddThemeBaseMixins extends ScanningRecipe<Accumulator> {
63
+ readonly name = "org.openrewrite.angular.material.AddThemeBaseMixins";
64
+ readonly displayName = "Add the theme base mixins of Angular Material 17";
65
+ readonly description = "Material 17 moved the base styles of each component out of its color, typography and " +
66
+ "density mixins into a `base` mixin. Where a project includes such a partial mixin, such as " +
67
+ "`mat.button-color`, without the full `theme` mixin, adds the missing `base` mixins after `mat.core()`, or " +
68
+ "marks `mat.core()` when no theme is in scope.";
69
+
70
+ initialValue(_ctx: ExecutionContext): Accumulator {
71
+ return {majors: new Map(), found: new Set(), missing: new Set(), themes: new Set()};
72
+ }
73
+
74
+ async scanner(acc: Accumulator): Promise<TreeVisitor<any, ExecutionContext>> {
75
+ const packageJson = materialMajorScanner((directory, major) => acc.majors.set(directory, major));
76
+ const stylesheets = new class extends PlainTextVisitor<ExecutionContext> {
77
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
78
+ if (!text.sourcePath.endsWith('.scss')) return text;
79
+ // A project on Material 11 or older reaches 17 in one run, so its themes still `@import` the theming API.
80
+ // Without the declared names, a project's own mixin named like a legacy one can add a base mixin it doesn't need.
81
+ const content = withMdcMixins(migrateThemingApi(maskComments(text.text), new Set()));
82
+ for (const ns of materialNamespaces(content)) {
83
+ for (const set of MIXIN_SETS) {
84
+ if (includes(content, ns, set.theme).length > 0 || includes(content, ns, set.base).length > 0) {
85
+ acc.found.add(set.base);
86
+ acc.missing.delete(set.base);
87
+ continue;
88
+ }
89
+ const partial = [set.color, set.typography, set.density].flatMap(m => includes(content, ns, m));
90
+ if (partial.length === 0) continue;
91
+ partial.forEach(theme => acc.themes.add(theme));
92
+ if (!acc.found.has(set.base)) acc.missing.add(set.base);
93
+ }
94
+ }
95
+ return text;
96
+ }
97
+ }();
98
+ return new class extends TreeVisitor<any, ExecutionContext> {
99
+ async visit<R extends Tree>(tree: Tree, p: ExecutionContext, parent?: Cursor): Promise<R | undefined> {
100
+ await packageJson.visit(tree, p, parent);
101
+ return await stylesheets.visit(tree, p, parent) as R | undefined;
102
+ }
103
+ }();
104
+ }
105
+
106
+ async editorWithData(acc: Accumulator): Promise<TreeVisitor<any, ExecutionContext>> {
107
+ const missing = acc.found.has('all-component-bases') ? new Set<string>()
108
+ : acc.missing.has('all-component-bases') ? new Set(['all-component-bases']) : acc.missing;
109
+ const theme = acc.themes.size === 1 ? [...acc.themes][0] : undefined;
110
+ return new class extends PlainTextVisitor<ExecutionContext> {
111
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
112
+ const t = await super.visitText(text, p) as PlainText;
113
+ if (!t || missing.size === 0 || !t.sourcePath.endsWith('.scss') || !beforeMaterialVersion(acc.majors, t.sourcePath, 17)) return t;
114
+ const mixins = [...missing].sort();
115
+ const updated = withoutComments(t.text, content => addBaseMixins(content, mixins, theme));
116
+ if (updated !== t.text) return {...t, text: updated, snippets: []};
117
+ const ns = materialNamespaces(maskComments(t.text)).find(n => includePattern(`${n}core`).test(maskComments(t.text)));
118
+ if (ns === undefined || hasSearchResult(t, "Material 17 moved the base styles")) return t;
119
+ return foundSearchResult(t, "Material 17 moved the base styles of the components out of their color, " +
120
+ "typography and density mixins, which the stylesheets of this project include without the full theme " +
121
+ `mixin. Include ${mixins.map(m => `\`${ns}${m}($theme)\``).join(', ')} once with your theme.`);
122
+ }
123
+ }();
124
+ }
125
+ }
126
+
127
+ export function addBaseMixins(content: string, mixins: string[], theme: string | undefined): string {
128
+ let migrated = content;
129
+ for (const ns of materialNamespaces(content)) {
130
+ const declaration = theme?.startsWith('$') ? declarationEnd(migrated, theme) : -1;
131
+ migrated = migrated.replace(includePattern(`${ns}core`), (include, indent: string, _args, offset: number) => {
132
+ const lines = (argument: string) => [
133
+ ...PREAMBLE.map(line => line === '' ? '' : `${indent}${line}`),
134
+ ...mixins.map(mixin => `${indent}@include ${ns}${mixin}(${argument});`),
135
+ ].join('\n');
136
+ if (declaration === -1) return include;
137
+ if (declaration < offset) return `${withSemicolon(include)}\n${lines(theme!)}`;
138
+ return include;
139
+ });
140
+ if (declaration > -1 && !migrated.includes(`${ns}${mixins[0]}(${theme})`)) {
141
+ const at = declarationEnd(migrated, theme!);
142
+ migrated = `${migrated.slice(0, at)}\n${PREAMBLE.join('\n')}\n${mixins.map(m => `@include ${ns}${m}(${theme});`).join('\n')}${migrated.slice(at)}`;
143
+ }
144
+ }
145
+ return migrated;
146
+ }
147
+
148
+ /** The index after the `;` that ends the top-level declaration of a variable, or `-1` if the stylesheet does not declare it. */
149
+ function declarationEnd(content: string, variable: string): number {
150
+ const match = new RegExp(`^${escapeRegExp(variable)}\\s*:`, 'm').exec(content);
151
+ if (!match) return -1;
152
+ let depth = 0;
153
+ for (let i = match.index + match[0].length; i < content.length; i++) {
154
+ if (content[i] === '(') depth++;
155
+ else if (content[i] === ')') depth--;
156
+ else if (content[i] === ';' && depth === 0) return i + 1;
157
+ }
158
+ return -1;
159
+ }
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
9
+ import {isIdentifier, J} from "@openrewrite/rewrite/java";
10
+ import {importedNames} from "../components/symbols";
11
+
12
+ export class FindChipInputEventWithoutChipInput extends Recipe {
13
+ readonly name = "org.openrewrite.angular.material.FindChipInputEventWithoutChipInput";
14
+ readonly displayName = "Find `MatChipInputEvent` objects without `chipInput`";
15
+ readonly description = "Material 14 made `MatChipInputEvent.chipInput` required. Finds object literals declared or " +
16
+ "cast as a `MatChipInputEvent`, as tests often build them, that do not set `chipInput`.";
17
+
18
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
19
+ return new class extends JavaScriptVisitor<ExecutionContext> {
20
+ private chipInputEvent = new Map<string, string>();
21
+
22
+ protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
23
+ this.chipInputEvent = importedNames(cu, '@angular/material/chips', ['MatChipInputEvent']);
24
+ return this.chipInputEvent.size === 0 ? cu : super.visitJsCompilationUnit(cu, p);
25
+ }
26
+
27
+ protected async visitNewClass(newClass: J.NewClass, p: ExecutionContext): Promise<J | undefined> {
28
+ const n = await super.visitNewClass(newClass, p) as J.NewClass;
29
+ if (n.class || !n.body) return n;
30
+ const declared = this.declaredType();
31
+ if (!declared || !isIdentifier(declared) || !this.chipInputEvent.has(declared.simpleName)) return n;
32
+ const keys = n.body.statements.map(s => s.element);
33
+ if (keys.some(k => k.kind === JS.Kind.Spread || propertyName(k) === 'chipInput')) return n;
34
+ return foundSearchResult(n, "`MatChipInputEvent.chipInput` is required as of @angular/material 14. Set it " +
35
+ "to the `MatChipInput` that emitted the event.");
36
+ }
37
+
38
+ /** The type an object literal is declared or cast as, from the closest enclosing declaration or cast. */
39
+ private declaredType(): J | undefined {
40
+ const parent = this.cursor.parentTree()?.value;
41
+ if (parent?.kind === J.Kind.NamedVariable) {
42
+ const declarations = this.cursor.parentTree()?.parentTree()?.value as J.VariableDeclarations | undefined;
43
+ return typeName(declarations?.typeExpression);
44
+ }
45
+ if (parent?.kind === JS.Kind.As) return typeName((parent as JS.As).right);
46
+ if (parent?.kind === J.Kind.TypeCast) return typeName((parent as J.TypeCast).class.tree.element);
47
+ return undefined;
48
+ }
49
+ }();
50
+ }
51
+ }
52
+
53
+ function typeName(typeTree: J | undefined): J | undefined {
54
+ return typeTree?.kind === JS.Kind.TypeInfo ? (typeTree as JS.TypeInfo).typeIdentifier : typeTree;
55
+ }
56
+
57
+ function propertyName(member: J): string | undefined {
58
+ if (isIdentifier(member)) return member.simpleName;
59
+ if (member.kind !== JS.Kind.PropertyAssignment) return undefined;
60
+ const name = (member as JS.PropertyAssignment).name.element;
61
+ return isIdentifier(name) ? name.simpleName : undefined;
62
+ }