@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
@@ -0,0 +1,196 @@
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, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS, maybeRebind} from "@openrewrite/rewrite/javascript";
9
+ import {J} from "@openrewrite/rewrite/java";
10
+ import {enclosingBlock, escapeRegExp, includedInBlock, SASS_ARGUMENTS, SASS_STATEMENT_END, withoutComments} from "../components/stylesheets";
11
+ import {importedName, moduleOf} from "../components/symbols";
12
+ import {materialNamespaces, MaterialProjects, usesLegacyComponents} from "./material-version";
13
+ import {LEGACY_SYMBOLS} from "./material-legacy-symbols";
14
+ import {MDC_CLASS_RENAMES, RENAMED_TYPOGRAPHY_CLASSES} from "./material-15-classes";
15
+ import {renameConfigArguments, renameTypographyLevels} from "./migrate-material-15-typography";
16
+ import {COMPANION_MIXINS, MigrateMdcStyles, renameClassSelectors} from "./migrate-mdc-styles";
17
+ import {MigrateMdcTemplates} from "./migrate-mdc-templates";
18
+ import {FindMdcTemplateChanges, MATERIAL_15_MEMBERS} from "./find-mdc-breaking-changes";
19
+ import {FindRemovedMaterialClasses} from "./find-removed-material-classes";
20
+ import {FindRemovedMaterialMembers} from "./find-removed-material-members";
21
+
22
+ /** Hints for the exports of the `legacy-*` entry points that the MDC-based entry points of Material 17 lack. */
23
+ export const UNMAPPED_LEGACY_HINTS: Record<string, string> = {
24
+ MatLegacyChipList: "Use `MatChipListbox`, or `MatChipGrid` for chips with a text input.",
25
+ MatLegacyChipListChange: "Use `MatChipListboxChange`, or the `change` event of `MatChipGrid`.",
26
+ MatLegacyChipListHarness: "Use `MatChipListboxHarness`, or `MatChipGridHarness` for chips with a text input.",
27
+ LegacyChipListHarnessFilters: "Use `ChipListboxHarnessFilters` or `ChipGridHarnessFilters`.",
28
+ MAT_LEGACY_DIALOG_SCROLL_STRATEGY_FACTORY: "Provide `MAT_DIALOG_SCROLL_STRATEGY` instead.",
29
+ MatLegacyPlaceholder: "Use `<mat-label>` or the `placeholder` of the input instead.",
30
+ MatLegacyListAvatarCssMatStyler: "Use the `matListItemAvatar` directive instead.",
31
+ MatLegacyListIconCssMatStyler: "Use the `matListItemIcon` directive instead.",
32
+ MAT_LEGACY_SLIDER_VALUE_ACCESSOR: "The `<input matSliderThumb>` inside the slider is the form control now.",
33
+ MatLegacyTableDataSourcePageEvent: "Use `PageEvent` from `@angular/material/paginator` instead.",
34
+ MatLegacyTableDataSourcePaginator: "Use `MatPaginator` from `@angular/material/paginator` instead.",
35
+ };
36
+
37
+ /** The MDC-based entry point that replaces a `legacy-*` entry point. */
38
+ function mdcModule(legacyModule: string): string {
39
+ return legacyModule.replace('/legacy-', '/');
40
+ }
41
+
42
+ export class MigrateLegacyMaterialImports extends Recipe {
43
+ readonly name = "org.openrewrite.angular.material.MigrateLegacyMaterialImports";
44
+ readonly displayName = "Move legacy Angular Material imports to the MDC components";
45
+ readonly description = "Material 17 removed the `@angular/material/legacy-*` entry points. Moves each imported " +
46
+ "symbol to the MDC-based entry point, such as `MatLegacyButtonModule` from `@angular/material/legacy-button` " +
47
+ "to `MatButtonModule` from `@angular/material/button`.";
48
+
49
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
50
+ return new class extends JavaScriptVisitor<ExecutionContext> {
51
+ protected async visitImportDeclaration(jsImport: JS.Import, p: ExecutionContext): Promise<J | undefined> {
52
+ const imp = await super.visitImportDeclaration(jsImport, p) as JS.Import;
53
+ const module = moduleOf(imp);
54
+ const symbols = module === undefined ? undefined : LEGACY_SYMBOLS[module];
55
+ const namedBindings = imp?.importClause?.namedBindings;
56
+ if (!symbols || namedBindings?.kind !== JS.Kind.NamedImports) return imp;
57
+ for (const element of (namedBindings as JS.NamedImports).elements.elements) {
58
+ const member = importedName(element.element as JS.ImportSpecifier);
59
+ const newMember = member === undefined ? undefined : symbols[member];
60
+ if (!newMember) continue;
61
+ maybeRebind(this, {from: {module: module!, member}, to: {module: mdcModule(module!), member: newMember}});
62
+ }
63
+ return imp;
64
+ }
65
+ }();
66
+ }
67
+ }
68
+
69
+ /** The MDC-based mixin that replaces a mixin of the legacy components, or `undefined` for other mixins. */
70
+ function mdcMixin(name: string): string | undefined {
71
+ if (name === 'private-all-legacy-component-densities') return 'all-component-densities';
72
+ if (name.startsWith('all-legacy-component-')) return `all-component-${name.slice('all-legacy-component-'.length)}`;
73
+ if (name.startsWith('legacy-')) return name.slice('legacy-'.length);
74
+ return undefined;
75
+ }
76
+
77
+ /**
78
+ * Replaces the includes of legacy component mixins with the MDC-based mixins and the themes of the components the MDC
79
+ * components rely on, such as `mat.fab-theme` and `mat.icon-button-theme` for `mat.legacy-button-theme`, skipping
80
+ * includes that the block around them already has.
81
+ */
82
+ function migrateLegacyIncludes(content: string, ns: string): string {
83
+ const include = new RegExp(`([ \\t]*)@include\\s+${escapeRegExp(ns)}((?:all-legacy-component-|private-all-legacy-component-|legacy-)[\\w-]+)` +
84
+ `\\s*(?:\\((${SASS_ARGUMENTS})\\))?${SASS_STATEMENT_END}(\\r?\\n)?`, 'g');
85
+ const added = new Set<string>();
86
+ return content.replace(include, (whole, indent: string, name: string, args: string | undefined, newline: string | undefined, offset: number) => {
87
+ const target = mdcMixin(name);
88
+ if (target === undefined) return whole;
89
+ const argumentList = (args ?? '').trim();
90
+ const companion = target.match(/^(.*)-(theme|color|typography)$/);
91
+ const key = (mixin: string) => `${enclosingBlock(content, offset)}:${mixin}(${argumentList})`;
92
+ const mixins = [target, ...(companion ? (COMPANION_MIXINS[companion[1]] ?? []).map(c => `${c}-${companion[2]}`) : [])]
93
+ .filter(mixin => !includedInBlock(content, ns + mixin, argumentList, offset) && !added.has(key(mixin)));
94
+ mixins.forEach(mixin => added.add(key(mixin)));
95
+ return mixins.map(mixin => `${indent}@include ${ns}${mixin}(${argumentList});`).join('\n') + (mixins.length > 0 ? newline ?? '' : '');
96
+ });
97
+ }
98
+
99
+ /** Renames `define-legacy-typography-config` to `define-typography-config` with the levels of the 2018 type scale. */
100
+ function migrateLegacyTypographyConfig(content: string, ns: string): string {
101
+ const config = new RegExp(`${escapeRegExp(ns)}define-legacy-typography-config\\((${SASS_ARGUMENTS})\\)`, 'g');
102
+ return content.replace(config, (_call, args: string) => `${ns}define-typography-config(${renameConfigArguments(args)})`);
103
+ }
104
+
105
+ const OLD_ONLY_TYPOGRAPHY_CLASSES = Object.keys(RENAMED_TYPOGRAPHY_CLASSES).filter(c => !c.startsWith('mat-body-'));
106
+
107
+ /**
108
+ * Moves a stylesheet of a project on the legacy components to the MDC-based components, as the `mdc-migration`
109
+ * schematic does: legacy mixins, the legacy typography config and its levels, and the class selectors the MDC components renamed.
110
+ */
111
+ export function migrateLegacyStyles(content: string): string {
112
+ if (!content.includes('mat-') && !content.includes('@angular/material')) return content;
113
+ return withoutComments(content, masked => {
114
+ let migrated = masked;
115
+ for (const ns of materialNamespaces(masked)) {
116
+ migrated = migrateLegacyTypographyConfig(migrateLegacyIncludes(migrated, ns), ns);
117
+ }
118
+ migrated = renameTypographyLevels(migrated);
119
+ const usesOldTypography = OLD_ONLY_TYPOGRAPHY_CLASSES.some(c => new RegExp(`\\.${c}(?![\\w-])`).test(migrated));
120
+ return renameClassSelectors(migrated, usesOldTypography ? {...MDC_CLASS_RENAMES, ...RENAMED_TYPOGRAPHY_CLASSES} : MDC_CLASS_RENAMES);
121
+ });
122
+ }
123
+
124
+ /** The mixin includes of a stylesheet as they read once the legacy mixins are replaced, for recipes that scan them. */
125
+ export function withMdcMixins(content: string): string {
126
+ let migrated = content;
127
+ for (const ns of materialNamespaces(content)) migrated = migrateLegacyIncludes(migrated, ns);
128
+ return migrated;
129
+ }
130
+
131
+ const LEGACY_GATE = "in projects that still use the `legacy-*` components of Material 15 and 16, which Material 17 removed";
132
+
133
+ export class MigrateLegacyMaterialTemplates extends MigrateMdcTemplates {
134
+ readonly name = "org.openrewrite.angular.material.MigrateLegacyMaterialTemplates";
135
+ readonly displayName = "Move legacy Angular Material templates to the MDC components";
136
+ readonly description = "Applies the template changes of `MigrateMdcTemplates` " + LEGACY_GATE + ": chips, " +
137
+ "slider, form field appearances and typography classes.";
138
+
139
+ protected appliesTo(projects: MaterialProjects, sourcePath: string): boolean {
140
+ return usesLegacyComponents(projects, sourcePath);
141
+ }
142
+ }
143
+
144
+ export class MigrateLegacyMaterialStyles extends MigrateMdcStyles {
145
+ readonly name = "org.openrewrite.angular.material.MigrateLegacyMaterialStyles";
146
+ readonly displayName = "Move legacy Angular Material styles to the MDC components";
147
+ readonly description = "Moves stylesheets and inline `styles` to the MDC-based components " + LEGACY_GATE + ", such as " +
148
+ "`mat.legacy-button-theme` to `mat.button-theme` and `.mat-form-field` to " +
149
+ "`.mat-mdc-form-field`.";
150
+
151
+ protected appliesTo(projects: MaterialProjects, sourcePath: string): boolean {
152
+ return usesLegacyComponents(projects, sourcePath);
153
+ }
154
+
155
+ protected migrate(content: string): string {
156
+ return migrateLegacyStyles(content);
157
+ }
158
+ }
159
+
160
+ export class FindLegacyMdcTemplateChanges extends FindMdcTemplateChanges {
161
+ readonly name = "org.openrewrite.angular.material.FindLegacyMdcTemplateChanges";
162
+ readonly displayName = "Find legacy Angular Material templates affected by the MDC components";
163
+ readonly description = "Finds the template APIs that `FindMdcTemplateChanges` finds " + LEGACY_GATE + ".";
164
+
165
+ protected appliesTo(projects: MaterialProjects, sourcePath: string): boolean {
166
+ return usesLegacyComponents(projects, sourcePath);
167
+ }
168
+ }
169
+
170
+ export class FindLegacyMaterialClasses extends FindRemovedMaterialClasses {
171
+ readonly name = "org.openrewrite.angular.material.FindLegacyMaterialClasses";
172
+ readonly displayName = "Find styles targeting legacy Angular Material classes";
173
+ readonly description = "Finds the classes that `FindRemovedMaterialClasses` finds " + LEGACY_GATE + ", since " +
174
+ "the MDC-based components no longer apply them.";
175
+
176
+ protected appliesTo(projects: MaterialProjects, sourcePath: string): boolean {
177
+ return usesLegacyComponents(projects, sourcePath);
178
+ }
179
+ }
180
+
181
+ export class FindLegacyMaterialMembers extends FindRemovedMaterialMembers {
182
+ readonly name = "org.openrewrite.angular.material.FindLegacyMaterialMembers";
183
+ readonly displayName = "Find legacy Angular Material members the MDC components lack";
184
+ readonly description = "Finds the members that `FindRemovedMaterial15Members` finds, on the legacy components " +
185
+ "as well as the MDC-based ones, " + LEGACY_GATE + ".";
186
+
187
+ protected readonly version = 17;
188
+ protected readonly members = MATERIAL_15_MEMBERS.map(member => ({
189
+ ...member,
190
+ classNames: member.classNames.flatMap(c => [c, c.replace(/^(_?)Mat/, '$1MatLegacy')]),
191
+ }));
192
+
193
+ protected appliesTo(projects: MaterialProjects, sourcePath: string): boolean {
194
+ return usesLegacyComponents(projects, sourcePath);
195
+ }
196
+ }
@@ -0,0 +1,39 @@
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, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, maybeAddImport, Template} from "@openrewrite/rewrite/javascript";
9
+ import {J} from "@openrewrite/rewrite/java";
10
+ import {isMaterialClass} from "./rename-material-members";
11
+
12
+ export class MigrateListItemHarnessContentLoader extends Recipe {
13
+ readonly name = "org.openrewrite.angular.material.MigrateListItemHarnessContentLoader";
14
+ readonly displayName = "Replace `getHarnessLoaderForContent` of the list item harnesses";
15
+ readonly description = "Material 14 removed `getHarnessLoaderForContent` from the list item harnesses. Replaces " +
16
+ "calls of it with `getChildLoader(MatListItemSection.CONTENT)`.";
17
+
18
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
19
+ return new class extends JavaScriptVisitor<ExecutionContext> {
20
+ protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
21
+ const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
22
+ const select = m.select?.element;
23
+ if (m.name.simpleName !== 'getHarnessLoaderForContent' || !select) return m;
24
+ if (!isMaterialClass(m.methodType?.declaringType, 'MatListItemHarnessBase')) return m;
25
+ const section = maybeAddImport(this, {
26
+ module: '@angular/material/list/testing',
27
+ member: 'MatListItemSection',
28
+ onlyIfReferenced: false,
29
+ }) ?? 'MatListItemSection';
30
+ const replaced = await Template.builder()
31
+ .param(select)
32
+ .code(`.getChildLoader(${section}.CONTENT)`)
33
+ .build()
34
+ .apply(m, this.cursor);
35
+ return replaced && {...replaced, prefix: m.prefix} as J;
36
+ }
37
+ }();
38
+ }
39
+ }
@@ -0,0 +1,95 @@
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, ScanningRecipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
9
+ import {escapeRegExp, withoutComments} from "../components/stylesheets";
10
+ import {beforeMaterialVersion, materialMajorScanner} from "./material-version";
11
+ import {materialNamespaces} from "./material-version";
12
+
13
+ /** M2 theming functions that Material 18 renamed with an `m2-` prefix, from the `@angular/material` 18 `ng update`. */
14
+ const RENAMED_FUNCTIONS = [
15
+ 'define-light-theme', 'define-dark-theme', 'define-palette', 'get-contrast-color-from-palette',
16
+ 'get-color-from-palette', 'get-color-config', 'get-typography-config', 'get-density-config',
17
+ 'define-typography-level', 'define-rem-typography-config', 'define-typography-config',
18
+ 'define-legacy-typography-config', 'typography-level', 'font-size', 'line-height', 'font-weight',
19
+ 'letter-spacing', 'font-family',
20
+ ];
21
+
22
+ /** M2 palettes that Material 18 renamed with an `m2-` prefix, some of whose old names are M3 palettes now. */
23
+ const RENAMED_VARIABLES = [
24
+ 'red-palette', 'pink-palette', 'indigo-palette', 'purple-palette', 'deep-purple-palette', 'blue-palette',
25
+ 'light-blue-palette', 'cyan-palette', 'teal-palette', 'green-palette', 'light-green-palette', 'lime-palette',
26
+ 'yellow-palette', 'amber-palette', 'orange-palette', 'deep-orange-palette', 'brown-palette', 'grey-palette',
27
+ 'gray-palette', 'blue-grey-palette', 'blue-gray-palette', 'light-theme-background-palette',
28
+ 'dark-theme-background-palette', 'light-theme-foreground-palette', 'dark-theme-foreground-palette',
29
+ ];
30
+
31
+ /** M3 APIs that moved from `@angular/material-experimental` to `@angular/material` in Material 18. */
32
+ const M3_FUNCTIONS = ['define-theme', 'define-colors', 'define-typography', 'define-density'];
33
+
34
+ const M3_VARIABLES = [
35
+ 'red-palette', 'green-palette', 'blue-palette', 'yellow-palette', 'cyan-palette', 'magenta-palette',
36
+ 'orange-palette', 'chartreuse-palette', 'azure-palette', 'violet-palette', 'rose-palette',
37
+ ];
38
+
39
+ function renameFunction(content: string, oldNs: string, name: string, newNs: string, newName: string): string {
40
+ return content.replace(new RegExp(`(?<![\\w.$-])${escapeRegExp(oldNs + name)}\\(`, 'g'), `${newNs}${newName}(`);
41
+ }
42
+
43
+ function renameVariable(content: string, oldNs: string, name: string, newNs: string, newName: string): string {
44
+ return content.replace(new RegExp(`(?<![\\w.-])${escapeRegExp(oldNs)}\\$${escapeRegExp(name)}(?![\\w-]|\\s*:)`, 'g'), `${newNs}$${newName}`);
45
+ }
46
+
47
+ /** Moves the M2 theming API of a comment-masked stylesheet to its `m2-` names and the M3 API to the stable module. */
48
+ export function migrateM2ThemingApi(content: string): string {
49
+ const stable = materialNamespaces(content);
50
+ const experimental = [...content.matchAll(/@use\s+(['"])~?@angular\/material-experimental\1(?:\s+as\s+([\w-]+|\*))?/g)]
51
+ .map(m => m[2] === '*' ? '' : `${m[2] ?? 'material-experimental'}.`);
52
+ let migrated = content;
53
+ for (const ns of stable) {
54
+ for (const name of RENAMED_FUNCTIONS) migrated = renameFunction(migrated, ns, name, ns, `m2-${name}`);
55
+ for (const name of RENAMED_VARIABLES) migrated = renameVariable(migrated, ns, name, ns, `m2-${name}`);
56
+ }
57
+ if (experimental.length === 0) return migrated;
58
+ const before = migrated;
59
+ const target = stable[0] ?? 'mat.';
60
+ for (const ns of experimental) {
61
+ migrated = migrated.replace(new RegExp(`@include(\\s+)${escapeRegExp(ns)}color-variants-back-compat(?![\\w-])`, 'g'),
62
+ `@include$1${target}color-variants-backwards-compatibility`);
63
+ for (const name of M3_FUNCTIONS) migrated = renameFunction(migrated, ns, name, target, name);
64
+ for (const name of M3_VARIABLES) migrated = renameVariable(migrated, ns, `m3-${name}`, target, name);
65
+ }
66
+ return stable.length === 0 && migrated !== before ? `@use '@angular/material' as mat;\n${migrated}` : migrated;
67
+ }
68
+
69
+ export class MigrateM2ThemingApi extends ScanningRecipe<Map<string, number>> {
70
+ readonly name = "org.openrewrite.angular.material.MigrateM2ThemingApi";
71
+ readonly displayName = "Rename the M2 theming API of Angular Material 18";
72
+ readonly description = "Material 18 made Material 3 the default and gave the Material 2 theming functions and " +
73
+ "palettes an `m2-` prefix. Renames them, such as `mat.define-palette` to `mat.m2-define-palette`, and moves " +
74
+ "the M3 APIs of `@angular/material-experimental` to `@angular/material`.";
75
+
76
+ initialValue(_ctx: ExecutionContext): Map<string, number> {
77
+ return new Map();
78
+ }
79
+
80
+ async scanner(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>> {
81
+ return materialMajorScanner((directory, major) => majors.set(directory, major));
82
+ }
83
+
84
+ async editorWithData(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>> {
85
+ return new class extends PlainTextVisitor<ExecutionContext> {
86
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
87
+ const t = await super.visitText(text, p) as PlainText;
88
+ if (!t || !t.sourcePath.endsWith('.scss') || !t.text.includes('@angular/material')) return t;
89
+ if (!beforeMaterialVersion(majors, t.sourcePath, 18)) return t;
90
+ const updated = withoutComments(t.text, migrateM2ThemingApi);
91
+ return updated === t.text ? t : {...t, text: updated, snippets: []};
92
+ }
93
+ }();
94
+ }
95
+ }
@@ -0,0 +1,35 @@
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 {includePattern, stylesheetEditor, withoutComments} from "../components/stylesheets";
9
+ import {MaterialVersionRecipe, materialNamespaces} from "./material-version";
10
+
11
+ export class MigrateMatCoreToElevationClasses extends MaterialVersionRecipe {
12
+ readonly name = "org.openrewrite.angular.material.MigrateMatCoreToElevationClasses";
13
+ readonly displayName = "Replace `mat.core()` with `mat.elevation-classes()` and `mat.app-background()`";
14
+ readonly description = "Material 19 deprecated `mat.core()`. Replaces `@include mat.core()` with the two mixins " +
15
+ "that it still emitted, `mat.elevation-classes()` and `mat.app-background()`. This is the `mat.core` migration " +
16
+ "of the `@angular/material` 19 `ng update`.";
17
+
18
+ protected readonly version = 19;
19
+
20
+ protected async editorBeforeVersion(): Promise<TreeVisitor<any, ExecutionContext>> {
21
+ return stylesheetEditor(content => this.migrate(content), sourcePath => sourcePath.endsWith('.scss'));
22
+ }
23
+
24
+ protected migrate(content: string): string {
25
+ if (!content.includes('@angular/material')) return content;
26
+ return withoutComments(content, masked => {
27
+ let migrated = masked;
28
+ for (const ns of materialNamespaces(masked)) {
29
+ migrated = migrated.replace(includePattern(`${ns}core`), (_include, indent: string) =>
30
+ `${indent}@include ${ns}elevation-classes();\n${indent}@include ${ns}app-background();`);
31
+ }
32
+ return migrated;
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,145 @@
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, ScanningRecipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
9
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
10
+ import {J} from "@openrewrite/rewrite/java";
11
+ import {migrateInlineStyle} from "../components/style-sources";
12
+ import {escapeRegExp, includePattern, maskComments, SASS_ARGUMENTS, withoutComments} from "../components/stylesheets";
13
+ import {beforeMaterialVersion, materialMajorScanner, materialNamespaces} from "./material-version";
14
+ import {RENAMED_TYPOGRAPHY_CLASSES} from "./material-15-classes";
15
+ import {hasSearchResult, inSequence} from "../components/lst";
16
+
17
+ /**
18
+ * Splits `mat.core($config)` into `mat.all-component-typographies($config)` and `mat.core()`, and adds the default
19
+ * typography to a plain `mat.core()`, since `core` stopped including component typography in Material 15.
20
+ */
21
+ export function migrateCoreTypography(content: string): string {
22
+ let migrated = content;
23
+ for (const ns of materialNamespaces(content)) {
24
+ const hasTypographies = new RegExp(`@include\\s+${escapeRegExp(ns)}all-component-typographies\\b`).test(content);
25
+ migrated = migrated.replace(includePattern(`${ns}core`), (include, indent: string, args: string | undefined) => {
26
+ const config = args?.trim() ?? '';
27
+ if (config === '' && hasTypographies) return include;
28
+ return `${indent}@include ${ns}all-component-typographies(${config});\n${indent}@include ${ns}core();`;
29
+ });
30
+ }
31
+ return migrated;
32
+ }
33
+
34
+ const SETS_AMBIGUOUS_LEVELS = "This stylesheet sets `$body-1` or `$body-2` in a typography config";
35
+ const BUILDS_PRE_15_CONFIG = "This stylesheet builds a typography config with the levels of the pre-15 type scale";
36
+
37
+ export class MigrateMaterial15Typography extends ScanningRecipe<Map<string, number>> {
38
+ readonly name = "org.openrewrite.angular.material.MigrateMaterial15Typography";
39
+ readonly displayName = "Migrate the typography of Angular Material 15";
40
+ readonly description = "Material 15 removed the typography config parameter of `mat.core()` and moved " +
41
+ "typography to the 2018 type scale. Includes `mat.all-component-typographies()` where `mat.core()` emitted " +
42
+ "the typography, and renames the type scale levels, such as `title` to `headline-6`.";
43
+
44
+ initialValue(_ctx: ExecutionContext): Map<string, number> {
45
+ return new Map();
46
+ }
47
+
48
+ async scanner(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>> {
49
+ return materialMajorScanner((directory, major) => majors.set(directory, major));
50
+ }
51
+
52
+ async editorWithData(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>> {
53
+ const migrate = (content: string) => withoutComments(content, masked => renameTypographyLevels(migrateCoreTypography(masked)));
54
+ const files = new class extends PlainTextVisitor<ExecutionContext> {
55
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
56
+ const t = await super.visitText(text, p) as PlainText;
57
+ if (!t || !t.sourcePath.endsWith('.scss') || !beforeMaterialVersion(majors, t.sourcePath, 15)) return t;
58
+ const updated = migrate(t.text);
59
+ const migrated = updated === t.text ? t : {...t, text: updated, snippets: []};
60
+ if (hasSearchResult(migrated, SETS_AMBIGUOUS_LEVELS) || hasSearchResult(migrated, BUILDS_PRE_15_CONFIG)) return migrated;
61
+ if (setsAmbiguousBodyLevels(maskComments(t.text))) {
62
+ return foundSearchResult(migrated, SETS_AMBIGUOUS_LEVELS + ", which " +
63
+ "exist in both type scales with different meanings. If the config was written for the pre-15 type scale, " +
64
+ "rename `body-2` to `subtitle-2` and then `body-1` to `body-2`.");
65
+ }
66
+ const oldLevels = customOldLevels(maskComments(updated));
67
+ if (oldLevels.length < 2) return migrated;
68
+ return foundSearchResult(migrated, `${BUILDS_PRE_15_CONFIG}, such as ${oldLevels.slice(0, 3).map(l => `\`${l}\``).join(', ')}, which Material 15 ` +
69
+ "typography no longer reads. Rename them to the 2018 levels, such as `display-4` to `headline-1`, " +
70
+ "`title` to `headline-6`, `subheading-1` to `body-1` and `body-1` to `body-2`, with `input` merged into " +
71
+ "`body-1`, or create the config with `mat.define-typography-config`.");
72
+ }
73
+ }();
74
+ const literals = new class extends JavaScriptVisitor<ExecutionContext> {
75
+ protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
76
+ return beforeMaterialVersion(majors, cu.sourcePath, 15) ? super.visitJsCompilationUnit(cu, p) : cu;
77
+ }
78
+
79
+ protected async visitLiteral(literal: J.Literal, p: ExecutionContext): Promise<J | undefined> {
80
+ return migrateInlineStyle(await super.visitLiteral(literal, p) as J.Literal, this.cursor, migrate);
81
+ }
82
+ }();
83
+ return inSequence(files, literals);
84
+ }
85
+ }
86
+
87
+ /** Typography levels that Material 15 renamed to the 2018 type scale, from the `mdc-migration` schematic. */
88
+ const RENAMED_LEVELS: Record<string, string> = Object.fromEntries(
89
+ Object.entries(RENAMED_TYPOGRAPHY_CLASSES).map(([from, to]) => [from.slice('mat-'.length), to.slice('mat-'.length)]));
90
+
91
+ const LEVEL_FUNCTIONS = ['typography-level', 'font-size', 'line-height', 'font-weight', 'letter-spacing', 'font-family'];
92
+
93
+ /** Level names that only the pre-15 type scale has, so their presence tells that a stylesheet is not migrated yet. */
94
+ const OLD_ONLY_LEVELS = ['display-4', 'display-3', 'display-2', 'display-1', 'headline', 'title', 'subheading-2', 'subheading-1', 'input'];
95
+
96
+ /** The comment that replaces a level the 2018 type scale has no place for, which still names that level. */
97
+ const CONFIG_COMMENT = /\/\*[\s\S]*?\*\//g;
98
+
99
+ /**
100
+ * Renames the levels of typography configs and the level arguments of the typography functions all at once, but only
101
+ * in a stylesheet that still uses a level name of the old type scale, since `body-1` and `body-2` exist in both.
102
+ */
103
+ export function renameTypographyLevels(content: string): string {
104
+ let migrated = content;
105
+ for (const ns of materialNamespaces(content)) {
106
+ const config = new RegExp(`${escapeRegExp(ns)}define-typography-config\\((${SASS_ARGUMENTS})\\)`, 'g');
107
+ const functions = new RegExp(`(${escapeRegExp(ns)}(?:${LEVEL_FUNCTIONS.map(escapeRegExp).join('|')})\\(\\s*[^,()]+,\\s*)(['"]?)([\\w-]+)\\2(\\s*\\))`, 'g');
108
+ const usesOldLevels = [...content.matchAll(config)].some(m => [...m[1].replace(CONFIG_COMMENT, '').matchAll(/\$([\w-]+)\s*:/g)].some(a => OLD_ONLY_LEVELS.includes(a[1])))
109
+ || [...content.matchAll(functions)].some(m => OLD_ONLY_LEVELS.includes(m[3]));
110
+ if (!usesOldLevels) continue;
111
+ migrated = migrated.replace(config, (_call, args: string) => `${ns}define-typography-config(${renameConfigArguments(args)})`);
112
+ migrated = migrated.replace(functions, (call, head: string, quote: string, level: string, tail: string) => {
113
+ const renamed = level === 'input' ? 'body-1' : RENAMED_LEVELS[level];
114
+ return renamed ? `${head}${quote}${renamed}${quote}${tail}` : call;
115
+ });
116
+ }
117
+ return migrated;
118
+ }
119
+
120
+ /** Whether a typography config sets levels that exist in both type scales and none that tells which scale it is written for. */
121
+ function setsAmbiguousBodyLevels(content: string): boolean {
122
+ if (renameTypographyLevels(content) !== content) return false;
123
+ return materialNamespaces(content).some(ns => [...content.matchAll(new RegExp(`${escapeRegExp(ns)}define-typography-config\\((${SASS_ARGUMENTS})\\)`, 'g'))]
124
+ .some(config => /\$body-[12]\s*:/.test(config[1]) && !/\$(?:headline-[1-6]|subtitle-[12]|overline)\s*:/.test(config[1])));
125
+ }
126
+
127
+ export function renameConfigArguments(args: string): string {
128
+ const levels = [...args.replace(CONFIG_COMMENT, '').matchAll(/\$([\w-]+)\s*:/g)].map(m => m[1]);
129
+ const mergeInput = !levels.includes('subheading-1');
130
+ return args.replace(new RegExp(`${CONFIG_COMMENT.source}|(^|[\\s,(])\\$([\\w-]+)(\\s*:\\s*)((?:[^,()]|\\(${SASS_ARGUMENTS}\\))*)(,?)`, 'g'),
131
+ (arg, before: string, level: string | undefined, colon: string, value: string, comma: string) => {
132
+ if (level === undefined) return arg;
133
+ if (level === 'input') {
134
+ return mergeInput ? `${before}$body-1${colon}${value}${comma}`
135
+ : `${before}/* TODO(mdc-migration): No longer supported. Use \`body-1\` instead. $input${colon}${value.trimEnd()} */`;
136
+ }
137
+ return level in RENAMED_LEVELS ? `${before}$${RENAMED_LEVELS[level]}${colon}${value}${comma}` : arg;
138
+ });
139
+ }
140
+
141
+ /** Pre-15 level names that a typography stylesheet still uses as map keys or parameters. */
142
+ function customOldLevels(content: string): string[] {
143
+ if (!/typography/.test(content)) return [];
144
+ return [...new Set([...content.matchAll(/(?:^|[\s,(])\$?(display-[1-4]|subheading-[12]|headline|title|input)\s*:/g)].map(m => m[1]))];
145
+ }