@openrewrite/recipes-react 0.20.0 → 0.22.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 (276) hide show
  1. package/dist/i18n/translate-hard-coded-strings.d.ts +67 -0
  2. package/dist/i18n/translate-hard-coded-strings.d.ts.map +1 -0
  3. package/dist/i18n/translate-hard-coded-strings.js +439 -0
  4. package/dist/i18n/translate-hard-coded-strings.js.map +1 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +37 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/mui/adapt-v4-theme.d.ts +8 -0
  10. package/dist/mui/adapt-v4-theme.d.ts.map +1 -0
  11. package/dist/mui/adapt-v4-theme.js +65 -0
  12. package/dist/mui/adapt-v4-theme.js.map +1 -0
  13. package/dist/mui/add-component-prop.d.ts +18 -0
  14. package/dist/mui/add-component-prop.d.ts.map +1 -0
  15. package/dist/mui/add-component-prop.js +53 -0
  16. package/dist/mui/add-component-prop.js.map +1 -0
  17. package/dist/mui/add-emotion-prepend.d.ts +8 -0
  18. package/dist/mui/add-emotion-prepend.d.ts.map +1 -0
  19. package/dist/mui/add-emotion-prepend.js +71 -0
  20. package/dist/mui/add-emotion-prepend.js.map +1 -0
  21. package/dist/mui/change-module-specifier.d.ts +14 -0
  22. package/dist/mui/change-module-specifier.d.ts.map +1 -0
  23. package/dist/mui/change-module-specifier.js +95 -0
  24. package/dist/mui/change-module-specifier.js.map +1 -0
  25. package/dist/mui/convert-mui-imports.d.ts +14 -0
  26. package/dist/mui/convert-mui-imports.d.ts.map +1 -0
  27. package/dist/mui/convert-mui-imports.js +195 -0
  28. package/dist/mui/convert-mui-imports.js.map +1 -0
  29. package/dist/mui/convert-prop-to-sx.d.ts +22 -0
  30. package/dist/mui/convert-prop-to-sx.d.ts.map +1 -0
  31. package/dist/mui/convert-prop-to-sx.js +99 -0
  32. package/dist/mui/convert-prop-to-sx.js.map +1 -0
  33. package/dist/mui/index.d.ts +32 -0
  34. package/dist/mui/index.d.ts.map +1 -0
  35. package/dist/mui/index.js +67 -0
  36. package/dist/mui/index.js.map +1 -0
  37. package/dist/mui/jsx-attributes.d.ts +27 -0
  38. package/dist/mui/jsx-attributes.d.ts.map +1 -0
  39. package/dist/mui/jsx-attributes.js +140 -0
  40. package/dist/mui/jsx-attributes.js.map +1 -0
  41. package/dist/mui/mark-manual-migration.d.ts +16 -0
  42. package/dist/mui/mark-manual-migration.d.ts.map +1 -0
  43. package/dist/mui/mark-manual-migration.js +73 -0
  44. package/dist/mui/mark-manual-migration.js.map +1 -0
  45. package/dist/mui/mark-palette-mode-usage.d.ts +12 -0
  46. package/dist/mui/mark-palette-mode-usage.d.ts.map +1 -0
  47. package/dist/mui/mark-palette-mode-usage.js +50 -0
  48. package/dist/mui/mark-palette-mode-usage.js.map +1 -0
  49. package/dist/mui/move-component-prop-to-slot.d.ts +22 -0
  50. package/dist/mui/move-component-prop-to-slot.d.ts.map +1 -0
  51. package/dist/mui/move-component-prop-to-slot.js +87 -0
  52. package/dist/mui/move-component-prop-to-slot.js.map +1 -0
  53. package/dist/mui/move-primary-text-to-children.d.ts +12 -0
  54. package/dist/mui/move-primary-text-to-children.d.ts.map +1 -0
  55. package/dist/mui/move-primary-text-to-children.js +52 -0
  56. package/dist/mui/move-primary-text-to-children.js.map +1 -0
  57. package/dist/mui/move-system-props-to-sx.d.ts +16 -0
  58. package/dist/mui/move-system-props-to-sx.d.ts.map +1 -0
  59. package/dist/mui/move-system-props-to-sx.js +122 -0
  60. package/dist/mui/move-system-props-to-sx.js.map +1 -0
  61. package/dist/mui/mui-components.d.ts +8 -0
  62. package/dist/mui/mui-components.d.ts.map +1 -0
  63. package/dist/mui/mui-components.js +41 -0
  64. package/dist/mui/mui-components.js.map +1 -0
  65. package/dist/mui/mui-tag-visitor.d.ts +5 -0
  66. package/dist/mui/mui-tag-visitor.d.ts.map +1 -0
  67. package/dist/mui/mui-tag-visitor.js +54 -0
  68. package/dist/mui/mui-tag-visitor.js.map +1 -0
  69. package/dist/mui/pre-v5-recipe.d.ts +14 -0
  70. package/dist/mui/pre-v5-recipe.d.ts.map +1 -0
  71. package/dist/mui/pre-v5-recipe.js +88 -0
  72. package/dist/mui/pre-v5-recipe.js.map +1 -0
  73. package/dist/mui/remove-component-prop.d.ts +18 -0
  74. package/dist/mui/remove-component-prop.d.ts.map +1 -0
  75. package/dist/mui/remove-component-prop.js +55 -0
  76. package/dist/mui/remove-component-prop.js.map +1 -0
  77. package/dist/mui/remove-root-ref.d.ts +8 -0
  78. package/dist/mui/remove-root-ref.d.ts.map +1 -0
  79. package/dist/mui/remove-root-ref.js +61 -0
  80. package/dist/mui/remove-root-ref.js.map +1 -0
  81. package/dist/mui/remove-spacing-px-suffix.d.ts +8 -0
  82. package/dist/mui/remove-spacing-px-suffix.d.ts.map +1 -0
  83. package/dist/mui/remove-spacing-px-suffix.js +62 -0
  84. package/dist/mui/remove-spacing-px-suffix.js.map +1 -0
  85. package/dist/mui/rename-component-prop.d.ts +20 -0
  86. package/dist/mui/rename-component-prop.d.ts.map +1 -0
  87. package/dist/mui/rename-component-prop.js +66 -0
  88. package/dist/mui/rename-component-prop.js.map +1 -0
  89. package/dist/mui/rename-joy-css-variables.d.ts +8 -0
  90. package/dist/mui/rename-joy-css-variables.d.ts.map +1 -0
  91. package/dist/mui/rename-joy-css-variables.js +51 -0
  92. package/dist/mui/rename-joy-css-variables.js.map +1 -0
  93. package/dist/mui/rename-theme-palette-type.d.ts +8 -0
  94. package/dist/mui/rename-theme-palette-type.d.ts.map +1 -0
  95. package/dist/mui/rename-theme-palette-type.js +61 -0
  96. package/dist/mui/rename-theme-palette-type.js.map +1 -0
  97. package/dist/mui/replace-box-border-radius.d.ts +10 -0
  98. package/dist/mui/replace-box-border-radius.d.ts.map +1 -0
  99. package/dist/mui/replace-box-border-radius.js +50 -0
  100. package/dist/mui/replace-box-border-radius.js.map +1 -0
  101. package/dist/mui/replace-breakpoints-width.d.ts +8 -0
  102. package/dist/mui/replace-breakpoints-width.d.ts.map +1 -0
  103. package/dist/mui/replace-breakpoints-width.js +46 -0
  104. package/dist/mui/replace-breakpoints-width.js.map +1 -0
  105. package/dist/mui/replace-component-class.d.ts +18 -0
  106. package/dist/mui/replace-component-class.d.ts.map +1 -0
  107. package/dist/mui/replace-component-class.js +126 -0
  108. package/dist/mui/replace-component-class.js.map +1 -0
  109. package/dist/mui/replace-components-with-slots.d.ts +14 -0
  110. package/dist/mui/replace-components-with-slots.d.ts.map +1 -0
  111. package/dist/mui/replace-components-with-slots.js +69 -0
  112. package/dist/mui/replace-components-with-slots.js.map +1 -0
  113. package/dist/mui/replace-import-paths.d.ts +14 -0
  114. package/dist/mui/replace-import-paths.d.ts.map +1 -0
  115. package/dist/mui/replace-import-paths.js +101 -0
  116. package/dist/mui/replace-import-paths.js.map +1 -0
  117. package/dist/mui/replace-in-string-literals.d.ts +15 -0
  118. package/dist/mui/replace-in-string-literals.d.ts.map +1 -0
  119. package/dist/mui/replace-in-string-literals.js +62 -0
  120. package/dist/mui/replace-in-string-literals.js.map +1 -0
  121. package/dist/mui/replace-list-item-button-prop.d.ts +12 -0
  122. package/dist/mui/replace-list-item-button-prop.d.ts.map +1 -0
  123. package/dist/mui/replace-list-item-button-prop.js +80 -0
  124. package/dist/mui/replace-list-item-button-prop.js.map +1 -0
  125. package/dist/mui/replace-tabs-scroll-buttons.d.ts +8 -0
  126. package/dist/mui/replace-tabs-scroll-buttons.d.ts.map +1 -0
  127. package/dist/mui/replace-tabs-scroll-buttons.js +41 -0
  128. package/dist/mui/replace-tabs-scroll-buttons.js.map +1 -0
  129. package/dist/mui/replace-theme-color-functions.d.ts +8 -0
  130. package/dist/mui/replace-theme-color-functions.d.ts.map +1 -0
  131. package/dist/mui/replace-theme-color-functions.js +72 -0
  132. package/dist/mui/replace-theme-color-functions.js.map +1 -0
  133. package/dist/mui/replace-theme-spacing-unit.d.ts +8 -0
  134. package/dist/mui/replace-theme-spacing-unit.d.ts.map +1 -0
  135. package/dist/mui/replace-theme-spacing-unit.js +77 -0
  136. package/dist/mui/replace-theme-spacing-unit.js.map +1 -0
  137. package/dist/mui/replace-typography-round.d.ts +8 -0
  138. package/dist/mui/replace-typography-round.d.ts.map +1 -0
  139. package/dist/mui/replace-typography-round.js +44 -0
  140. package/dist/mui/replace-typography-round.js.map +1 -0
  141. package/dist/mui/shift-hidden-down-props.d.ts +10 -0
  142. package/dist/mui/shift-hidden-down-props.d.ts.map +1 -0
  143. package/dist/mui/shift-hidden-down-props.js +49 -0
  144. package/dist/mui/shift-hidden-down-props.js.map +1 -0
  145. package/dist/mui/theme-access.d.ts +5 -0
  146. package/dist/mui/theme-access.d.ts.map +1 -0
  147. package/dist/mui/theme-access.js +21 -0
  148. package/dist/mui/theme-access.js.map +1 -0
  149. package/dist/mui/update-theme-breakpoints.d.ts +10 -0
  150. package/dist/mui/update-theme-breakpoints.d.ts.map +1 -0
  151. package/dist/mui/update-theme-breakpoints.js +58 -0
  152. package/dist/mui/update-theme-breakpoints.js.map +1 -0
  153. package/dist/mui/upgrade-grid-props.d.ts +16 -0
  154. package/dist/mui/upgrade-grid-props.d.ts.map +1 -0
  155. package/dist/mui/upgrade-grid-props.js +90 -0
  156. package/dist/mui/upgrade-grid-props.js.map +1 -0
  157. package/dist/search/find-enzyme-usage.d.ts +8 -0
  158. package/dist/search/find-enzyme-usage.d.ts.map +1 -1
  159. package/dist/search/find-enzyme-usage.js +119 -8
  160. package/dist/search/find-enzyme-usage.js.map +1 -1
  161. package/dist/search/find-hard-coded-strings.d.ts +110 -0
  162. package/dist/search/find-hard-coded-strings.d.ts.map +1 -0
  163. package/dist/search/find-hard-coded-strings.js +987 -0
  164. package/dist/search/find-hard-coded-strings.js.map +1 -0
  165. package/dist/search/find-missing-use-client-directive.d.ts +2 -0
  166. package/dist/search/find-missing-use-client-directive.d.ts.map +1 -1
  167. package/dist/search/find-missing-use-client-directive.js +1 -0
  168. package/dist/search/find-missing-use-client-directive.js.map +1 -1
  169. package/dist/testing/enzyme-host-components.d.ts +12 -0
  170. package/dist/testing/enzyme-host-components.d.ts.map +1 -1
  171. package/dist/testing/enzyme-host-components.js +100 -0
  172. package/dist/testing/enzyme-host-components.js.map +1 -1
  173. package/dist/testing/enzyme-portals.d.ts +3 -5
  174. package/dist/testing/enzyme-portals.d.ts.map +1 -1
  175. package/dist/testing/enzyme-portals.js +8 -39
  176. package/dist/testing/enzyme-portals.js.map +1 -1
  177. package/dist/testing/enzyme-render-blockers.d.ts +19 -0
  178. package/dist/testing/enzyme-render-blockers.d.ts.map +1 -0
  179. package/dist/testing/enzyme-render-blockers.js +275 -0
  180. package/dist/testing/enzyme-render-blockers.js.map +1 -0
  181. package/dist/testing/enzyme-to-react-testing-library.d.ts +17 -3
  182. package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
  183. package/dist/testing/enzyme-to-react-testing-library.js +237 -27
  184. package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
  185. package/dist/testing/enzyme-usage.d.ts +9 -0
  186. package/dist/testing/enzyme-usage.d.ts.map +1 -1
  187. package/dist/testing/enzyme-usage.js +36 -3
  188. package/dist/testing/enzyme-usage.js.map +1 -1
  189. package/dist/testing/enzyme-wrapper-scope.d.ts +8 -1
  190. package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
  191. package/dist/testing/enzyme-wrapper-scope.js +26 -5
  192. package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
  193. package/dist/util/json-and-javascript.d.ts +4 -0
  194. package/dist/util/json-and-javascript.d.ts.map +1 -0
  195. package/dist/util/json-and-javascript.js +37 -0
  196. package/dist/util/json-and-javascript.js.map +1 -0
  197. package/dist/util/module-imports.d.ts +36 -0
  198. package/dist/util/module-imports.d.ts.map +1 -1
  199. package/dist/util/module-imports.js +216 -0
  200. package/dist/util/module-imports.js.map +1 -1
  201. package/dist/util/test-source.d.ts +2 -0
  202. package/dist/util/test-source.d.ts.map +1 -0
  203. package/dist/util/test-source.js +5 -0
  204. package/dist/util/test-source.js.map +1 -0
  205. package/dist/zustand/entry-store.d.ts +9 -0
  206. package/dist/zustand/entry-store.d.ts.map +1 -0
  207. package/dist/zustand/entry-store.js +136 -0
  208. package/dist/zustand/entry-store.js.map +1 -0
  209. package/dist/zustand/redux-stores.d.ts +7 -4
  210. package/dist/zustand/redux-stores.d.ts.map +1 -1
  211. package/dist/zustand/redux-stores.js +128 -11
  212. package/dist/zustand/redux-stores.js.map +1 -1
  213. package/dist/zustand/redux-to-zustand.d.ts +11 -2
  214. package/dist/zustand/redux-to-zustand.d.ts.map +1 -1
  215. package/dist/zustand/redux-to-zustand.js +147 -46
  216. package/dist/zustand/redux-to-zustand.js.map +1 -1
  217. package/dist/zustand/zustand-plan.d.ts +14 -5
  218. package/dist/zustand/zustand-plan.d.ts.map +1 -1
  219. package/dist/zustand/zustand-plan.js +226 -52
  220. package/dist/zustand/zustand-plan.js.map +1 -1
  221. package/package.json +1 -1
  222. package/src/i18n/translate-hard-coded-strings.ts +442 -0
  223. package/src/index.ts +17 -0
  224. package/src/mui/adapt-v4-theme.ts +43 -0
  225. package/src/mui/add-component-prop.ts +43 -0
  226. package/src/mui/add-emotion-prepend.ts +48 -0
  227. package/src/mui/change-module-specifier.ts +71 -0
  228. package/src/mui/convert-mui-imports.ts +184 -0
  229. package/src/mui/convert-prop-to-sx.ts +89 -0
  230. package/src/mui/index.ts +31 -0
  231. package/src/mui/jsx-attributes.ts +133 -0
  232. package/src/mui/mark-manual-migration.ts +53 -0
  233. package/src/mui/mark-palette-mode-usage.ts +36 -0
  234. package/src/mui/move-component-prop-to-slot.ts +84 -0
  235. package/src/mui/move-primary-text-to-children.ts +41 -0
  236. package/src/mui/move-system-props-to-sx.ts +118 -0
  237. package/src/mui/mui-components.ts +40 -0
  238. package/src/mui/mui-tag-visitor.ts +36 -0
  239. package/src/mui/pre-v5-recipe.ts +82 -0
  240. package/src/mui/remove-component-prop.ts +43 -0
  241. package/src/mui/remove-root-ref.ts +41 -0
  242. package/src/mui/remove-spacing-px-suffix.ts +43 -0
  243. package/src/mui/rename-component-prop.ts +55 -0
  244. package/src/mui/rename-joy-css-variables.ts +41 -0
  245. package/src/mui/rename-theme-palette-type.ts +42 -0
  246. package/src/mui/replace-box-border-radius.ts +42 -0
  247. package/src/mui/replace-breakpoints-width.ts +28 -0
  248. package/src/mui/replace-component-class.ts +97 -0
  249. package/src/mui/replace-components-with-slots.ts +61 -0
  250. package/src/mui/replace-import-paths.ts +100 -0
  251. package/src/mui/replace-in-string-literals.ts +44 -0
  252. package/src/mui/replace-list-item-button-prop.ts +59 -0
  253. package/src/mui/replace-tabs-scroll-buttons.ts +31 -0
  254. package/src/mui/replace-theme-color-functions.ts +55 -0
  255. package/src/mui/replace-theme-spacing-unit.ts +59 -0
  256. package/src/mui/replace-typography-round.ts +29 -0
  257. package/src/mui/shift-hidden-down-props.ts +44 -0
  258. package/src/mui/theme-access.ts +18 -0
  259. package/src/mui/update-theme-breakpoints.ts +47 -0
  260. package/src/mui/upgrade-grid-props.ts +82 -0
  261. package/src/search/find-enzyme-usage.ts +109 -12
  262. package/src/search/find-hard-coded-strings.ts +1006 -0
  263. package/src/search/find-missing-use-client-directive.ts +1 -1
  264. package/src/testing/enzyme-host-components.ts +110 -0
  265. package/src/testing/enzyme-portals.ts +4 -44
  266. package/src/testing/enzyme-render-blockers.ts +278 -0
  267. package/src/testing/enzyme-to-react-testing-library.ts +240 -34
  268. package/src/testing/enzyme-usage.ts +48 -2
  269. package/src/testing/enzyme-wrapper-scope.ts +35 -3
  270. package/src/util/json-and-javascript.ts +26 -0
  271. package/src/util/module-imports.ts +223 -0
  272. package/src/util/test-source.ts +2 -0
  273. package/src/zustand/entry-store.ts +131 -0
  274. package/src/zustand/redux-stores.ts +131 -12
  275. package/src/zustand/redux-to-zustand.ts +179 -52
  276. package/src/zustand/zustand-plan.ts +256 -49
@@ -23,7 +23,9 @@ exports.rewriteVersion = rewriteVersion;
23
23
  exports.injectsRootStyles = injectsRootStyles;
24
24
  exports.parsesOptionalChaining = parsesOptionalChaining;
25
25
  exports.reactMajor = reactMajor;
26
+ exports.incompatibility = incompatibility;
26
27
  exports.simulatesEvents = simulatesEvents;
28
+ exports.rtlTarget = rtlTarget;
27
29
  const rewrite_1 = require("@openrewrite/rewrite");
28
30
  const text_1 = require("@openrewrite/rewrite/text");
29
31
  const javascript_1 = require("@openrewrite/rewrite/javascript");
@@ -37,6 +39,7 @@ const find_enzyme_usage_1 = require("../search/find-enzyme-usage");
37
39
  const java_recipe_proxy_1 = require("../util/java-recipe-proxy");
38
40
  const module_imports_1 = require("../util/module-imports");
39
41
  const enzyme_usage_1 = require("./enzyme-usage");
42
+ const enzyme_render_blockers_1 = require("./enzyme-render-blockers");
40
43
  const enzyme_host_components_1 = require("./enzyme-host-components");
41
44
  const enzyme_portals_1 = require("./enzyme-portals");
42
45
  const enzyme_constant_strings_1 = require("./enzyme-constant-strings");
@@ -76,11 +79,15 @@ class EnzymeTestDependency extends java_recipe_proxy_1.JavaDependencyRecipe {
76
79
  this.addition = addition;
77
80
  this.forecast = forecast;
78
81
  this.landed = new Set();
82
+ this.declined = new Set();
83
+ this.outcomes = new Map();
79
84
  this.manifests = [];
80
85
  this.held = [];
81
86
  }
82
87
  initialValue() {
83
88
  this.landed.clear();
89
+ this.declined.clear();
90
+ this.outcomes.clear();
84
91
  this.manifests.length = 0;
85
92
  this.held.length = 0;
86
93
  return super.initialValue();
@@ -109,11 +116,19 @@ class EnzymeTestDependency extends java_recipe_proxy_1.JavaDependencyRecipe {
109
116
  var _a, _b;
110
117
  const converting = yield ((_b = (_a = this.forecast).converting) === null || _b === void 0 ? void 0 : _b.call(_a));
111
118
  const scopes = lockfileScopes(this.held);
112
- const forwarded = new Set(this.held.filter(manifest => {
119
+ const withheld = (manifest) => {
113
120
  var _a;
114
121
  const scope = (_a = scopes.get(manifest.sourcePath)) !== null && _a !== void 0 ? _a : packageRoot(manifest.sourcePath);
115
- return !converting || [...converting].some(source => source.startsWith(scope));
116
- }));
122
+ if (converting && ![...converting].some(source => source.startsWith(scope)))
123
+ return { kind: "withheld" };
124
+ return this.withholds(scope) ? { kind: "peer" } : undefined;
125
+ };
126
+ const forwarded = new Set(this.held.filter(manifest => !withheld(manifest)));
127
+ for (const manifest of this.manifests) {
128
+ const why = forwarded.has(manifest) ? undefined : withheld(manifest);
129
+ if (why)
130
+ this.outcomes.set(packageRoot(manifest.sourcePath), why);
131
+ }
117
132
  const scanner = yield this.java.scanner(acc);
118
133
  for (const manifest of forwarded)
119
134
  yield scanner.visit(manifest, ctx);
@@ -124,12 +139,37 @@ class EnzymeTestDependency extends java_recipe_proxy_1.JavaDependencyRecipe {
124
139
  const editor = yield this.java.editorWithData(acc);
125
140
  for (const manifest of this.manifests) {
126
141
  const edited = yield editor.visit(manifest, ctx);
142
+ const root = manifest.sourcePath.slice(0, -"package.json".length);
127
143
  if (edited && edited !== manifest && declares(edited, this.addition.packageName))
128
- this.landed.add(manifest.sourcePath.slice(0, -"package.json".length));
144
+ this.landed.add(root);
145
+ else if (!declares(manifest, this.addition.packageName) && this.resolvesGate(manifest)) {
146
+ this.declined.add(root);
147
+ const warning = (edited !== null && edited !== void 0 ? edited : manifest).markers.markers.find(marker => marker.kind === rewrite_1.MarkersKind.MarkupWarn);
148
+ this.outcomes.set(root, { kind: "declined", warning: warning && [warning.message, warning.detail].filter(Boolean).join("\n") });
149
+ }
150
+ else if (!declares(manifest, this.addition.packageName))
151
+ this.outcomes.set(root, { kind: "gate" });
129
152
  }
130
153
  return generated;
131
154
  });
132
155
  }
156
+ resolvesGate(manifest) {
157
+ var _a, _b, _c;
158
+ const resolved = (_b = (_a = (0, javascript_1.findNodeResolutionResult)(manifest)) === null || _a === void 0 ? void 0 : _a.resolvedDependencies) !== null && _b !== void 0 ? _b : [];
159
+ return ((_c = this.addition.onlyIfResolving) !== null && _c !== void 0 ? _c : []).every(gate => {
160
+ const at = gate.lastIndexOf("@");
161
+ const name = gate.slice(0, at);
162
+ return resolved.some(dep => dep.name === name && (0, semver_1.valid)(dep.version) !== null && (0, semver_1.satisfies)(dep.version, gate.slice(at + 1)));
163
+ });
164
+ }
165
+ withholds(_scope) {
166
+ return false;
167
+ }
168
+ }
169
+ function dependencySteps(forecast) {
170
+ const rtl = new AddTestingLibraryReact(forecast);
171
+ const dom18 = new AddTestingLibraryDom18(forecast);
172
+ return { rtl, dom18, rtl18: new AddTestingLibraryReact18(forecast, dom18) };
133
173
  }
134
174
  class AddTestingLibraryReact extends EnzymeTestDependency {
135
175
  constructor(forecast = {}) {
@@ -141,12 +181,16 @@ class AddTestingLibraryReact extends EnzymeTestDependency {
141
181
  }
142
182
  exports.AddTestingLibraryReact = AddTestingLibraryReact;
143
183
  class AddTestingLibraryReact18 extends EnzymeTestDependency {
144
- constructor(forecast = {}) {
184
+ constructor(forecast = {}, peer) {
145
185
  super(RTL_18_ADDITION, forecast);
186
+ this.peer = peer;
146
187
  this.name = "org.openrewrite.react.migrate.add-testing-library-react-18";
147
188
  this.displayName = "Add `@testing-library/react` 16 where Enzyme tests on React 18 are migrated";
148
189
  this.description = "Adds `@testing-library/react` 16 as a dev dependency to packages that declare `enzyme` and resolve React and React DOM 18.";
149
190
  }
191
+ withholds(scope) {
192
+ return !!this.peer && [...this.peer.declined].some(root => root.startsWith(scope));
193
+ }
150
194
  }
151
195
  exports.AddTestingLibraryReact18 = AddTestingLibraryReact18;
152
196
  class AddTestingLibraryDom18 extends EnzymeTestDependency {
@@ -250,6 +294,9 @@ const READS = {
250
294
  function reactMajor(packages, sourcePath, landed = new Set()) {
251
295
  return compatibility(packages, sourcePath, landed).react;
252
296
  }
297
+ function incompatibility(packages, sourcePath, landed = new Set()) {
298
+ return compatibility(packages, sourcePath, landed).why;
299
+ }
253
300
  const HOVER_EVENTS = new Set(["mouseEnter", "mouseLeave", "mouseOver", "mouseOut"]);
254
301
  function simulatesEvents(packages, sourcePath, landed = new Set()) {
255
302
  const { react, rtl } = compatibility(packages, sourcePath, landed);
@@ -259,6 +306,10 @@ function simulatesEvents(packages, sourcePath, landed = new Set()) {
259
306
  return { events: new Set([...enzyme_wrapper_scope_1.SIMULATED_EVENTS].filter(event => !HOVER_EVENTS.has(event))), attached: true };
260
307
  return { events: new Set(), attached: false };
261
308
  }
309
+ function rtlTarget(packages, sourcePath) {
310
+ const { enzymeRoot, enzymeReact } = compatibility(packages, sourcePath, new Set());
311
+ return enzymeRoot === undefined ? undefined : { root: enzymeRoot, react18: enzymeReact === 18 };
312
+ }
262
313
  function compatibility(packages, sourcePath, landed) {
263
314
  var _a;
264
315
  const roots = [...packages.keys()].filter(root => sourcePath.startsWith(root)).sort((a, b) => b.length - a.length);
@@ -277,7 +328,12 @@ function compatibility(packages, sourcePath, landed) {
277
328
  const rtlMajor = added ? (enzymeReact.major >= 18 ? 16 : 12) : typeof rtl === "object" && rtl.major >= 10 && rtl.major <= 16 ? rtl.major : 0;
278
329
  const compatible = supportedReact(react) && supportedReact(reactDom) && react.major === reactDom.major &&
279
330
  rtlMajor > 0 && rtlSupports(rtlMajor, react.major);
280
- return { react: compatible ? react.major : 0, rtl: rtlMajor };
331
+ const target = { enzymeRoot: enzymeRoots[0], enzymeReact: supportedReact(enzymeReact) ? enzymeReact.major : undefined };
332
+ if (compatible)
333
+ return Object.assign({ react: react.major, rtl: rtlMajor }, target);
334
+ const why = !supportedReact(react) || !supportedReact(reactDom) || react.major !== reactDom.major ? "react" :
335
+ rtl === undefined && !added ? "rtlMissing" : "rtl";
336
+ return Object.assign({ react: 0, rtl: rtlMajor, why }, target);
281
337
  }
282
338
  function providerRoots(packages, roots) {
283
339
  var _a;
@@ -334,17 +390,18 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
334
390
  super(options);
335
391
  this.name = "org.openrewrite.react.migrate.enzyme-to-react-testing-library";
336
392
  this.displayName = "Migrate Enzyme to React Testing Library";
337
- this.description = "Migrates Enzyme `mount` wrappers whose every use is a supported DOM read or event (`find(selector).length`, `.exists()`, `.text()`, `.html()`, `.hasClass()`, positions through `.at(n)`, `.first()`, `.last()`, the wrapper's `text()` and `exists(selector)`, found nodes as a `toHaveLength` subject, `setProps` as a rerender of the cloned element, and `simulate` with common mouse, keyboard, focus, form, and touch events, including `nativeEvent` mocks, on React 17 and 18 and, without the hover events and in a render attached to the document, on React 15.5 and 16) and bare `mount` statements to React Testing Library container queries, `rerender`, and `fireEvent` in packages using React 16 or 17 with RTL 10 to 12, React 15.5+ with RTL 12, or React 18 with RTL 16, adding RTL 12, or RTL 16 with its peer `@testing-library/dom` 10, where it is missing. On React 15, whose markup differs, `html()` and DOM nodes are left for review. Converts `shallow` wrappers the same way, without `simulate` or `html()`, where the component is imported from a source in the repository that creates host elements only and runs no effects, so a full render produces the DOM the shallow render does. Selectors are limited to HTML or SVG tag, class, ID, and pass-through attribute compounds and their descendant combinations. Reports remaining Enzyme usages for manual review. Requires an existing DOM test environment; shared wrappers, props, snapshots, and shallow rendering of other components are left for review.";
393
+ this.description = "Migrates Enzyme `mount` wrappers whose every use is a supported DOM read or event (`find(selector).length`, `.exists()`, `.text()`, `.html()`, `.hasClass()`, positions through `.at(n)`, `.first()`, `.last()`, the wrapper's `text()` and `exists(selector)`, found nodes as a `toHaveLength` subject, `setProps` as a rerender of the cloned element, and `simulate` with common mouse, keyboard, focus, form, and touch events, including `nativeEvent` mocks, on React 17 and 18 and, without the hover events and in a render attached to the document, on React 15.5 and 16) and bare `mount` statements to React Testing Library container queries, `rerender`, and `fireEvent` in packages using React 16 or 17 with RTL 10 to 12, React 15.5+ with RTL 12, or React 18 with RTL 16, adding RTL 12, or RTL 16 with its peer `@testing-library/dom` 10, where it is missing. This includes a shared `let` wrapper that each test assigns first, or that the last statement of a `beforeEach` assigns, where every test of it converts. On React 15, whose markup differs, `html()` and DOM nodes are left for review. Converts `shallow` wrappers the same way, without `simulate` or `html()`, where the component is imported from a source in the repository that creates host elements only and runs no effects, so a full render produces the DOM the shallow render does. Selectors are limited to HTML or SVG tag, class, ID, and pass-through attribute compounds and their descendant combinations. Reports remaining Enzyme usages for manual review. Requires an existing DOM test environment; props, snapshots, and shallow rendering of other components are left for review.";
338
394
  this.forecast = {};
339
395
  this.tests = [];
340
- this.dependencySteps = ADDS_RTL ? { rtl: new AddTestingLibraryReact(this.forecast), rtl18: new AddTestingLibraryReact18(this.forecast),
341
- dom18: new AddTestingLibraryDom18(this.forecast) } : undefined;
396
+ this.forecastBlockers = new Map();
397
+ this.dependencySteps = ADDS_RTL ? dependencySteps(this.forecast) : undefined;
342
398
  this.snapshots = false;
343
399
  this.usages = new rewrite_1.DataTable(enzyme_usage_1.ENZYME_USAGE_TABLE, "Enzyme migration inventory", "Remaining Enzyme usages and migration actions. Module rows include references whose call types may be unavailable; they are not counts of test cases.", enzyme_usage_1.EnzymeUsageRow);
344
400
  }
345
401
  initialValue() {
346
402
  this.tests.length = 0;
347
- return { packages: new Map(), components: new Map(), modules: new Map(), names: new Map(), nullSnapshots: new Set() };
403
+ this.forecastBlockers.clear();
404
+ return { packages: new Map(), components: new Map(), composites: new Map(), modules: new Map(), names: new Map(), nullSnapshots: new Set() };
348
405
  }
349
406
  scanner(scanned) {
350
407
  return __awaiter(this, void 0, void 0, function* () {
@@ -356,6 +413,9 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
356
413
  visitJsCompilationUnit(cu) {
357
414
  return __awaiter(this, void 0, void 0, function* () {
358
415
  scanned.components.set(cu.sourcePath, (0, enzyme_host_components_1.hostComponentExports)(cu));
416
+ const composite = (0, enzyme_host_components_1.compositeFacts)(cu);
417
+ if (composite)
418
+ scanned.composites.set(cu.sourcePath, composite);
359
419
  scanned.modules.set(cu.sourcePath, (0, enzyme_portals_1.moduleFacts)(cu));
360
420
  scanned.names.set(cu.sourcePath, (0, enzyme_selector_names_1.selectorNames)(cu));
361
421
  if ((0, module_imports_1.importBindings)(cu).some(({ module }) => module === enzyme_usage_1.ENZYME))
@@ -489,6 +549,19 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
489
549
  };
490
550
  const usages = this.usages;
491
551
  const steps = this.dependencySteps;
552
+ const forecastBlockers = this.forecastBlockers;
553
+ const notAdded = (sourcePath) => {
554
+ var _a, _b;
555
+ const target = rtlTarget(scanned.packages, sourcePath);
556
+ if (!target)
557
+ return new Map([[enzyme_usage_1.FILE_BLOCKER, (0, enzyme_render_blockers_1.blockedByFile)("rtlMissing")]]);
558
+ const outcome = !steps ? undefined : target.react18 ?
559
+ (_a = steps.dom18.outcomes.get(target.root)) !== null && _a !== void 0 ? _a : steps.rtl18.outcomes.get(target.root) : steps.rtl.outcomes.get(target.root);
560
+ const blockers = new Map([[enzyme_usage_1.FILE_BLOCKER, (0, enzyme_render_blockers_1.blockedByPackage)(target.root, outcome)]]);
561
+ if ((outcome === null || outcome === void 0 ? void 0 : outcome.kind) === "withheld")
562
+ (_b = forecastBlockers.get(sourcePath)) === null || _b === void 0 ? void 0 : _b.forEach((why, id) => blockers.set(id, why));
563
+ return blockers;
564
+ };
492
565
  const untaggedPositions = this.untaggedSelectorPositions !== false;
493
566
  const snapshots = this.snapshots;
494
567
  return (0, rewrite_1.check)((0, rewrite_1.and)((0, rewrite_1.not)((0, javascript_1.isVendoredOrBundled)()), (0, rewrite_1.or)((0, javascript_1.usesMethod)("enzyme mount(..)"), (0, javascript_1.usesMethod)("enzyme shallow(..)"))), new class extends javascript_1.JavaScriptVisitor {
@@ -505,18 +578,21 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
505
578
  this.mounts = new Map();
506
579
  this.imports = new Map();
507
580
  this.importedNames = new Set();
581
+ this.bindings = [];
508
582
  this.declaredHost = new Set();
509
583
  this.uses = new Map();
510
584
  this.removedStatements = new Set();
511
585
  this.unmounts = new Set();
512
586
  this.declarations = new Set();
513
587
  this.pending = new Set();
588
+ this.sharedRenders = new Set();
514
589
  this.reformat = new Set();
515
590
  this.hoists = new Map();
516
591
  this.hoistedMounts = new Map();
517
592
  this.names = new Set();
518
593
  this.portals = new Set();
519
594
  this.rows = [];
595
+ this.blockers = new Map();
520
596
  this.prettier = false;
521
597
  this.printWidth = 80;
522
598
  }
@@ -526,10 +602,15 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
526
602
  });
527
603
  return __awaiter(this, void 0, void 0, function* () {
528
604
  this.sourcePath = cu.sourcePath;
529
- [this.mounts, this.uses, this.removedStatements, this.unmounts, this.declarations, this.pending, this.reformat].forEach(ids => ids.clear());
605
+ [this.mounts, this.uses, this.removedStatements, this.unmounts, this.declarations, this.pending, this.reformat, this.sharedRenders].forEach(ids => ids.clear());
530
606
  this.hoists.clear();
531
607
  this.hoistedMounts.clear();
532
608
  this.rows.length = 0;
609
+ this.blockers.clear();
610
+ if (!dry)
611
+ enzyme_usage_1.RENDER_BLOCKERS.delete(cu.sourcePath);
612
+ if (!dry)
613
+ yield this.readSelectors(cu);
533
614
  this.names = (0, javascript_1.namesUsedIn)(cu);
534
615
  const prettierStyle = (0, rewrite_1.findMarker)(cu, javascript_1.StyleKind.PrettierStyle);
535
616
  this.prettier = prettierStyle !== undefined && !prettierStyle.ignored && (yield formattedBy(cu, prettierStyle));
@@ -542,9 +623,16 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
542
623
  this.typescript = (0, javascript_1.isTypeScript)(cu);
543
624
  this.optionalChaining = parsesOptionalChaining(scanned.packages, cu.sourcePath, this.typescript);
544
625
  this.enabled = this.reactMajor > 0 && (0, javascript_1.moduleBindings)(this).moduleSystem === "esm";
545
- if (!this.enabled)
626
+ if (!this.enabled) {
627
+ const why = this.reactMajor === 0 ? incompatibility(scanned.packages, cu.sourcePath, landed) : "commonjs";
628
+ if (dry && why && why !== "rtlMissing")
629
+ forecastBlockers.set(cu.sourcePath, new Map([[enzyme_usage_1.FILE_BLOCKER, (0, enzyme_render_blockers_1.blockedByFile)(why)]]));
630
+ if (!dry && why)
631
+ enzyme_usage_1.RENDER_BLOCKERS.set(cu.sourcePath, why === "rtlMissing" ? notAdded(cu.sourcePath) : new Map([[enzyme_usage_1.FILE_BLOCKER, (0, enzyme_render_blockers_1.blockedByFile)(why)]]));
546
632
  return cu;
633
+ }
547
634
  this.imports = (0, enzyme_host_components_1.relativeImports)(cu, scanned.components);
635
+ this.bindings = (0, module_imports_1.importBindings)(cu);
548
636
  this.importedNames = (0, enzyme_host_components_1.importedNames)(cu);
549
637
  this.declaredHost = (0, enzyme_host_components_1.hostComponentsDeclared)(cu);
550
638
  const foreign = prettierStyle !== undefined && !this.prettier;
@@ -559,9 +647,15 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
559
647
  if (dry) {
560
648
  if (this.rows.some(row => row.status === "CONVERTED"))
561
649
  dry.converted.add(cu.sourcePath);
650
+ if (this.blockers.size > 0)
651
+ forecastBlockers.set(cu.sourcePath, new Map(this.blockers));
562
652
  }
563
- else
653
+ else {
564
654
  this.rows.forEach(row => usages.insertRow(ctx, row));
655
+ yield this.blockShapes(cu, ctx);
656
+ if (this.blockers.size > 0)
657
+ enzyme_usage_1.RENDER_BLOCKERS.set(cu.sourcePath, new Map(this.blockers));
658
+ }
565
659
  if (!foreign || !visited)
566
660
  return visited;
567
661
  return visited === visiting ? cu : (0, mutative_1.create)(visited, draft => {
@@ -581,10 +675,26 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
581
675
  this.cursor = new rewrite_1.Cursor(candidate, original.parent);
582
676
  const converted = yield this.convertBlock(candidate, ctx);
583
677
  this.cursor = original;
584
- if (mounts.every(id => this.mounts.has(id) && !this.pending.has(id)))
678
+ if (mounts.every(({ id }) => this.mounts.has(id) && !this.pending.has(id)))
585
679
  return this.renderedInHooks(converted, block, shared, ctx);
680
+ const kept = new Map();
681
+ for (const { id, from } of mounts) {
682
+ const why = this.blockers.get(id);
683
+ if (why && !kept.has(from))
684
+ kept.set(from, why);
685
+ }
686
+ for (const { id, from, name } of mounts) {
687
+ if (!kept.has(from) && this.mounts.has(id) && !this.pending.has(id))
688
+ kept.set(from, (0, enzyme_render_blockers_1.blockedByShared)(name));
689
+ }
586
690
  this.restoreState(saved);
587
- return this.convertBlock(block, ctx);
691
+ const plain = yield this.convertBlock(block, ctx);
692
+ mounts.forEach(({ from }) => this.sharedRenders.add(from));
693
+ kept.forEach((why, id) => {
694
+ if (!this.blockers.has(id))
695
+ this.blockers.set(id, why);
696
+ });
697
+ return plain;
588
698
  });
589
699
  }
590
700
  renderedInHooks(block, original, shared, ctx) {
@@ -769,7 +879,7 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
769
879
  const declared = yield declare.apply(statement.element, cursor);
770
880
  if (!declared)
771
881
  throw new Error(`Cannot declare ${name}`);
772
- mounts.push(declared.variables[0].element.initializer.element.id);
882
+ mounts.push({ id: declared.variables[0].element.initializer.element.id, from: assignment.assignment.element.id, name });
773
883
  statements.push(Object.assign(Object.assign({}, statement), { element: Object.assign(Object.assign({}, declared), { prefix: statement.element.prefix }) }));
774
884
  }
775
885
  return withoutStatements((0, mutative_1.create)(visited, draft => {
@@ -788,7 +898,7 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
788
898
  const declared = yield declare.apply(first.element, cursor);
789
899
  if (!declared)
790
900
  throw new Error(`Cannot declare ${hooked.name}`);
791
- mounts.push(declared.variables[0].element.initializer.element.id);
901
+ mounts.push({ id: declared.variables[0].element.initializer.element.id, from: hooked.mount.id, name: hooked.name });
792
902
  const semicolon = test.statements.some(padded => padded.markers.markers.some(marker => marker.kind === java_1.J.Markers.Semicolon));
793
903
  const padded = Object.assign(Object.assign({}, first), { element: Object.assign(Object.assign({}, declared), { prefix: first.element.prefix }), markers: Object.assign(Object.assign({}, first.markers), { markers: semicolon ? [{ kind: java_1.J.Markers.Semicolon, id: (0, rewrite_1.randomId)() }] : [] }) });
794
904
  return (0, mutative_1.create)(test, draft => {
@@ -804,7 +914,7 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
804
914
  return { mounts: new Map(this.mounts), uses: new Map(this.uses), removedStatements: new Set(this.removedStatements),
805
915
  unmounts: new Set(this.unmounts), declarations: new Set(this.declarations), pending: new Set(this.pending),
806
916
  reformat: new Set(this.reformat), hoists: new Map(this.hoists), hoistedMounts: new Map(this.hoistedMounts),
807
- portals: new Set(this.portals), rows: this.rows.length, afterVisit: this.afterVisit.length };
917
+ portals: new Set(this.portals), rows: this.rows.length, afterVisit: this.afterVisit.length, blockers: new Map(this.blockers) };
808
918
  }
809
919
  restoreState(saved) {
810
920
  const refill = (target, from) => {
@@ -819,6 +929,7 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
819
929
  remap(this.uses, saved.uses);
820
930
  remap(this.hoists, saved.hoists);
821
931
  remap(this.hoistedMounts, saved.hoistedMounts);
932
+ remap(this.blockers, saved.blockers);
822
933
  [[this.removedStatements, saved.removedStatements], [this.unmounts, saved.unmounts], [this.declarations, saved.declarations],
823
934
  [this.pending, saved.pending], [this.reformat, saved.reformat], [this.portals, saved.portals]]
824
935
  .forEach(([target, from]) => refill(target, from));
@@ -839,19 +950,27 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
839
950
  const api = candidate.render;
840
951
  const reads = READS[api];
841
952
  const markup = this.reactMajor >= 16;
842
- const scope = (0, enzyme_wrapper_scope_1.analyzeWrapperScope)(this.cursor, candidate, { events: reads.simulate ? this.events.events : new Set(), html: reads.html && markup, untaggedPositions, hostNames, snapshots: snapshots && markup, optionalChaining: this.optionalChaining,
843
- constant: node => this.constantString(node) });
844
- if (!scope)
953
+ let blocking;
954
+ const scope = (0, enzyme_wrapper_scope_1.analyzeWrapperScope)(this.cursor, candidate, { events: reads.simulate ? this.events.events : new Set(), html: reads.html && markup, untaggedPositions, hostNames, snapshots: snapshots && markup, optInSnapshots: !snapshots && markup, optionalChaining: this.optionalChaining,
955
+ constant: node => this.constantString(node), blocked: references => blocking = references });
956
+ if (!scope) {
957
+ if (blocking)
958
+ this.blockers.set(candidate.mount.id, yield (0, enzyme_render_blockers_1.blockedByUses)(blocking));
845
959
  continue;
846
- if ([...scope.uses.values()].some(use => use.use === "setProps" && !reads.props(use.props, this.importedNames)))
960
+ }
961
+ if ([...scope.uses.values()].some(use => use.use === "setProps" && !reads.props(use.props, this.importedNames))) {
962
+ this.blockers.set(candidate.mount.id, (0, enzyme_render_blockers_1.blockedByGate)("setProps"));
847
963
  continue;
964
+ }
848
965
  const mount = new rewrite_1.Cursor(candidate.mount, (0, enzyme_wrapper_scope_1.variableCursor)(this.cursor, candidate.declaration));
849
966
  const document = documentAt(mount);
850
967
  if (!document || !(yield renderPatterns[api].render.match(candidate.mount, mount)))
851
968
  continue;
852
969
  const attached = this.events.attached && [...scope.uses.values()].some(use => use.use === "simulate");
853
- if (!attached && this.rootStyles && [...scope.uses.values()].some(use => CONTAINER_READS.has(use.use)))
970
+ if (!attached && this.rootStyles && [...scope.uses.values()].some(use => CONTAINER_READS.has(use.use))) {
971
+ this.blockers.set(candidate.mount.id, (0, enzyme_render_blockers_1.blockedByGate)("rootStyles"));
854
972
  continue;
973
+ }
855
974
  this.mounts.set(candidate.mount.id, { document, api, attached });
856
975
  apis.push(api);
857
976
  this.declarations.add(candidate.declaration.id);
@@ -1116,10 +1235,19 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
1116
1235
  return undefined;
1117
1236
  const call = node;
1118
1237
  const api = (0, enzyme_usage_1.enzymeMethod)(call);
1119
- if (api === "mount")
1120
- return read && this.rendersPortal(call) ? undefined : api;
1238
+ if (api === "mount") {
1239
+ if (!read || !this.rendersPortal(call))
1240
+ return api;
1241
+ this.blockers.set(call.id, (0, enzyme_render_blockers_1.blockedByGate)("portal"));
1242
+ return undefined;
1243
+ }
1244
+ if (api !== "shallow" || call.arguments.elements.length !== 1)
1245
+ return undefined;
1121
1246
  const element = (_a = call.arguments.elements[0]) === null || _a === void 0 ? void 0 : _a.element;
1122
- return api === "shallow" && call.arguments.elements.length === 1 && (0, enzyme_host_components_1.rendersHostElements)(element, this.imports, scanned.components, this.importedNames, this.declaredHost) ? api : undefined;
1247
+ if ((0, enzyme_host_components_1.rendersHostElements)(element, this.imports, scanned.components, this.importedNames, this.declaredHost))
1248
+ return api;
1249
+ this.blockers.set(call.id, (0, enzyme_render_blockers_1.blockedByShallow)((0, enzyme_host_components_1.shallowMiss)(element, this.imports, scanned.components, scanned.composites, this.bindings)));
1250
+ return undefined;
1123
1251
  }
1124
1252
  rendersPortal(call) {
1125
1253
  var _a;
@@ -1148,6 +1276,88 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
1148
1276
  const declares = (name) => roots.some(root => scanned.packages.get(root).dependencies.has(name));
1149
1277
  return { roots, declares, resolve: (0, enzyme_portals_1.resolver)(scanned.modules, [...new Set([...roots, ""])], declares) };
1150
1278
  }
1279
+ blockShapes(cu, ctx) {
1280
+ return __awaiter(this, void 0, void 0, function* () {
1281
+ const blockers = this.blockers;
1282
+ const mounts = this.mounts;
1283
+ const sharedRenders = this.sharedRenders;
1284
+ yield new class extends javascript_1.JavaScriptVisitor {
1285
+ visitMethodInvocation(method, ctx) {
1286
+ const _super = Object.create(null, {
1287
+ visitMethodInvocation: { get: () => super.visitMethodInvocation }
1288
+ });
1289
+ return __awaiter(this, void 0, void 0, function* () {
1290
+ const api = (0, enzyme_usage_1.enzymeMethod)(method);
1291
+ if ((api === "mount" || api === "shallow") && !blockers.has(method.id) && !mounts.has(method.id) && !sharedRenders.has(method.id)) {
1292
+ const why = (0, enzyme_render_blockers_1.blockedByShape)(this.cursor);
1293
+ if (why)
1294
+ blockers.set(method.id, why);
1295
+ }
1296
+ return _super.visitMethodInvocation.call(this, method, ctx);
1297
+ });
1298
+ }
1299
+ }().visit(cu, ctx);
1300
+ });
1301
+ }
1302
+ readSelectors(cu) {
1303
+ return __awaiter(this, void 0, void 0, function* () {
1304
+ enzyme_usage_1.SELECTOR_VALUES.delete(cu.sourcePath);
1305
+ const finds = [];
1306
+ (0, javascript_1.walk)(cu, tree => {
1307
+ if (tree.kind === java_1.J.Kind.MethodInvocation && (0, enzyme_usage_1.enzymeMethod)(tree) === "find" &&
1308
+ tree.arguments.elements.length === 1)
1309
+ finds.push(tree);
1310
+ return true;
1311
+ });
1312
+ const topLevel = new Set(cu.statements.map(({ element }) => { var _a; return element.kind === javascript_1.JS.Kind.ExportDeclaration ? (_a = element.exportClause) === null || _a === void 0 ? void 0 : _a.id : element.id; }));
1313
+ const nested = new Set();
1314
+ (0, javascript_1.walk)(cu, tree => {
1315
+ if (tree.kind !== java_1.J.Kind.VariableDeclarations || topLevel.has(tree.id))
1316
+ return true;
1317
+ const variables = tree;
1318
+ if (!variables.modifiers.some(modifier => modifier.keyword === "const"))
1319
+ return true;
1320
+ for (const { element: variable } of variables.variables) {
1321
+ if ((0, java_1.isIdentifier)(variable.name) && variable.initializer && (0, enzyme_constant_strings_1.stringParts)(variable.initializer.element))
1322
+ nested.add(variable.name.simpleName);
1323
+ }
1324
+ return true;
1325
+ });
1326
+ const reads = new Map();
1327
+ for (const find of finds) {
1328
+ const read = yield this.selectorRead(find.arguments.elements[0].element, nested);
1329
+ if (read)
1330
+ reads.set(find.id, read);
1331
+ }
1332
+ if (reads.size > 0)
1333
+ enzyme_usage_1.SELECTOR_VALUES.set(cu.sourcePath, reads);
1334
+ });
1335
+ }
1336
+ selectorRead(selector, nested) {
1337
+ return __awaiter(this, void 0, void 0, function* () {
1338
+ const named = (name) => (0, enzyme_constant_strings_1.evaluate)([{ name }], this.sourcePath, scanned.modules, this.moduleResolution().resolve);
1339
+ const printed = (node) => __awaiter(this, void 0, void 0, function* () { return (yield rewrite_1.TreePrinters.printer(javascript_1.JS.Kind.CompilationUnit).print(node)).trim().replace(/\s+/g, " "); });
1340
+ if (selector.kind === javascript_1.JS.Kind.TemplateExpression) {
1341
+ const value = this.constantString(selector);
1342
+ if (value !== undefined)
1343
+ return { value };
1344
+ for (const { element: span } of selector.spans) {
1345
+ const part = span.expression;
1346
+ if ((0, java_1.isIdentifier)(part) && nested.has(part.simpleName))
1347
+ return undefined;
1348
+ if (!(0, java_1.isIdentifier)(part) || named(part.simpleName) === undefined)
1349
+ return { unread: yield printed(part) };
1350
+ }
1351
+ return undefined;
1352
+ }
1353
+ const value = (0, java_1.isIdentifier)(selector) ? named(selector.simpleName) : undefined;
1354
+ if (value !== undefined)
1355
+ return { value };
1356
+ if (java_1.TypedTree.getType(selector) !== java_1.Type.Primitive.String || (0, java_1.isIdentifier)(selector) && nested.has(selector.simpleName))
1357
+ return undefined;
1358
+ return (0, java_1.isIdentifier)(selector) || selector.kind === java_1.J.Kind.FieldAccess ? { unread: yield printed(selector) } : undefined;
1359
+ });
1360
+ }
1151
1361
  constantString(node) {
1152
1362
  const parts = (0, enzyme_constant_strings_1.stringParts)(node);
1153
1363
  return parts && (0, enzyme_constant_strings_1.evaluate)(parts, this.sourcePath, scanned.modules, this.moduleResolution().resolve);
@@ -1169,7 +1379,7 @@ class EnzymeToReactTestingLibrary extends rewrite_1.ScanningRecipe {
1169
1379
  recipeList() {
1170
1380
  return __awaiter(this, void 0, void 0, function* () {
1171
1381
  const steps = this.dependencySteps;
1172
- return [...steps ? [steps.rtl, steps.rtl18, steps.dom18] : [], new find_enzyme_usage_1.FindEnzymeUsage()];
1382
+ return [...steps ? [steps.rtl, steps.dom18, steps.rtl18] : [], new find_enzyme_usage_1.FindEnzymeUsage()];
1173
1383
  });
1174
1384
  }
1175
1385
  }