@openrewrite/recipes-react 0.15.0 → 0.17.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 (216) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +1 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/migration/cra-to-vite/add-vite-config.d.ts +7 -0
  5. package/dist/migration/cra-to-vite/add-vite-config.d.ts.map +1 -1
  6. package/dist/migration/cra-to-vite/add-vite-config.js +58 -1
  7. package/dist/migration/cra-to-vite/add-vite-config.js.map +1 -1
  8. package/dist/migration/cra-to-vite/cra-file-gate.d.ts +3 -0
  9. package/dist/migration/cra-to-vite/cra-file-gate.d.ts.map +1 -0
  10. package/dist/migration/cra-to-vite/cra-file-gate.js +10 -0
  11. package/dist/migration/cra-to-vite/cra-file-gate.js.map +1 -0
  12. package/dist/migration/cra-to-vite/cra-runtime.d.ts +2 -0
  13. package/dist/migration/cra-to-vite/cra-runtime.d.ts.map +1 -0
  14. package/dist/migration/cra-to-vite/cra-runtime.js +24 -0
  15. package/dist/migration/cra-to-vite/cra-runtime.js.map +1 -0
  16. package/dist/migration/cra-to-vite/cra-script.d.ts +8 -0
  17. package/dist/migration/cra-to-vite/cra-script.d.ts.map +1 -0
  18. package/dist/migration/cra-to-vite/cra-script.js +82 -0
  19. package/dist/migration/cra-to-vite/cra-script.js.map +1 -0
  20. package/dist/migration/cra-to-vite/cra-to-vite.d.ts +2 -1
  21. package/dist/migration/cra-to-vite/cra-to-vite.d.ts.map +1 -1
  22. package/dist/migration/cra-to-vite/cra-to-vite.js +23 -16
  23. package/dist/migration/cra-to-vite/cra-to-vite.js.map +1 -1
  24. package/dist/migration/cra-to-vite/cra-typecheck.d.ts +4 -0
  25. package/dist/migration/cra-to-vite/cra-typecheck.d.ts.map +1 -0
  26. package/dist/migration/cra-to-vite/cra-typecheck.js +35 -0
  27. package/dist/migration/cra-to-vite/cra-typecheck.js.map +1 -0
  28. package/dist/migration/cra-to-vite/find-cra-config-blockers.d.ts.map +1 -1
  29. package/dist/migration/cra-to-vite/find-cra-config-blockers.js +22 -29
  30. package/dist/migration/cra-to-vite/find-cra-config-blockers.js.map +1 -1
  31. package/dist/migration/cra-to-vite/index.d.ts +8 -2
  32. package/dist/migration/cra-to-vite/index.d.ts.map +1 -1
  33. package/dist/migration/cra-to-vite/index.js +17 -2
  34. package/dist/migration/cra-to-vite/index.js.map +1 -1
  35. package/dist/migration/cra-to-vite/migrate-cra-package.d.ts +17 -0
  36. package/dist/migration/cra-to-vite/migrate-cra-package.d.ts.map +1 -0
  37. package/dist/migration/cra-to-vite/migrate-cra-package.js +181 -0
  38. package/dist/migration/cra-to-vite/migrate-cra-package.js.map +1 -0
  39. package/dist/migration/cra-to-vite/migrate-cra-svg-imports.d.ts +9 -0
  40. package/dist/migration/cra-to-vite/migrate-cra-svg-imports.d.ts.map +1 -0
  41. package/dist/migration/cra-to-vite/migrate-cra-svg-imports.js +66 -0
  42. package/dist/migration/cra-to-vite/migrate-cra-svg-imports.js.map +1 -0
  43. package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.d.ts +49 -0
  44. package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.d.ts.map +1 -0
  45. package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.js +506 -0
  46. package/dist/migration/cra-to-vite/migrate-cra-tests-to-vitest.js.map +1 -0
  47. package/dist/migration/cra-to-vite/move-public-index-html.d.ts +2 -0
  48. package/dist/migration/cra-to-vite/move-public-index-html.d.ts.map +1 -1
  49. package/dist/migration/cra-to-vite/move-public-index-html.js +12 -7
  50. package/dist/migration/cra-to-vite/move-public-index-html.js.map +1 -1
  51. package/dist/migration/cra-to-vite/plan-cra-to-vite.d.ts +30 -0
  52. package/dist/migration/cra-to-vite/plan-cra-to-vite.d.ts.map +1 -0
  53. package/dist/migration/cra-to-vite/plan-cra-to-vite.js +428 -0
  54. package/dist/migration/cra-to-vite/plan-cra-to-vite.js.map +1 -0
  55. package/dist/migration/cra-to-vite/prepare-cra-package.d.ts +15 -0
  56. package/dist/migration/cra-to-vite/prepare-cra-package.d.ts.map +1 -0
  57. package/dist/migration/cra-to-vite/prepare-cra-package.js +100 -0
  58. package/dist/migration/cra-to-vite/prepare-cra-package.js.map +1 -0
  59. package/dist/migration/cra-to-vite/remove-cra-configuration.d.ts +12 -0
  60. package/dist/migration/cra-to-vite/remove-cra-configuration.d.ts.map +1 -0
  61. package/dist/migration/cra-to-vite/remove-cra-configuration.js +85 -0
  62. package/dist/migration/cra-to-vite/remove-cra-configuration.js.map +1 -0
  63. package/dist/migration/cra-to-vite/rename-jsx-files.d.ts +20 -0
  64. package/dist/migration/cra-to-vite/rename-jsx-files.d.ts.map +1 -0
  65. package/dist/migration/cra-to-vite/rename-jsx-files.js +220 -0
  66. package/dist/migration/cra-to-vite/rename-jsx-files.js.map +1 -0
  67. package/dist/migration/cra-to-vite/rename-process-env-react-app.d.ts.map +1 -1
  68. package/dist/migration/cra-to-vite/rename-process-env-react-app.js +6 -3
  69. package/dist/migration/cra-to-vite/rename-process-env-react-app.js.map +1 -1
  70. package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.js +1 -1
  71. package/dist/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.js.map +1 -1
  72. package/dist/migration/cra-to-vite/replace-react-scripts-dependency.d.ts +11 -4
  73. package/dist/migration/cra-to-vite/replace-react-scripts-dependency.d.ts.map +1 -1
  74. package/dist/migration/cra-to-vite/replace-react-scripts-dependency.js +47 -50
  75. package/dist/migration/cra-to-vite/replace-react-scripts-dependency.js.map +1 -1
  76. package/dist/migration/cra-to-vite/resolved-cra-dependency.d.ts +3 -0
  77. package/dist/migration/cra-to-vite/resolved-cra-dependency.d.ts.map +1 -0
  78. package/dist/migration/cra-to-vite/resolved-cra-dependency.js +42 -0
  79. package/dist/migration/cra-to-vite/resolved-cra-dependency.js.map +1 -0
  80. package/dist/migration/cra-to-vite/scan-cra-projects.d.ts +13 -0
  81. package/dist/migration/cra-to-vite/scan-cra-projects.d.ts.map +1 -1
  82. package/dist/migration/cra-to-vite/scan-cra-projects.js +52 -4
  83. package/dist/migration/cra-to-vite/scan-cra-projects.js.map +1 -1
  84. package/dist/migration/cra-to-vite/shared.d.ts +2 -15
  85. package/dist/migration/cra-to-vite/shared.d.ts.map +1 -1
  86. package/dist/migration/cra-to-vite/shared.js +32 -130
  87. package/dist/migration/cra-to-vite/shared.js.map +1 -1
  88. package/dist/migration/cra-to-vite/svg-component.d.ts +5 -0
  89. package/dist/migration/cra-to-vite/svg-component.d.ts.map +1 -0
  90. package/dist/migration/cra-to-vite/svg-component.js +60 -0
  91. package/dist/migration/cra-to-vite/svg-component.js.map +1 -0
  92. package/dist/migration/cra-to-vite/update-react-app-env-types.d.ts.map +1 -1
  93. package/dist/migration/cra-to-vite/update-react-app-env-types.js +8 -2
  94. package/dist/migration/cra-to-vite/update-react-app-env-types.js.map +1 -1
  95. package/dist/migration/cra-to-vite/update-react-scripts-scripts.d.ts +3 -2
  96. package/dist/migration/cra-to-vite/update-react-scripts-scripts.d.ts.map +1 -1
  97. package/dist/migration/cra-to-vite/update-react-scripts-scripts.js +28 -29
  98. package/dist/migration/cra-to-vite/update-react-scripts-scripts.js.map +1 -1
  99. package/dist/migration/cra-to-vite/update-tsconfig-for-vite.d.ts.map +1 -1
  100. package/dist/migration/cra-to-vite/update-tsconfig-for-vite.js +4 -13
  101. package/dist/migration/cra-to-vite/update-tsconfig-for-vite.js.map +1 -1
  102. package/dist/react17/migrate-deprecated-lifecycles.js +1 -1
  103. package/dist/react17/migrate-deprecated-lifecycles.js.map +1 -1
  104. package/dist/react17/use-new-jsx-transform.d.ts.map +1 -1
  105. package/dist/react17/use-new-jsx-transform.js +30 -78
  106. package/dist/react17/use-new-jsx-transform.js.map +1 -1
  107. package/dist/react18/replace-reactdom-render.d.ts.map +1 -1
  108. package/dist/react18/replace-reactdom-render.js +16 -8
  109. package/dist/react18/replace-reactdom-render.js.map +1 -1
  110. package/dist/react18/replace-unmount-component-at-node.d.ts.map +1 -1
  111. package/dist/react18/replace-unmount-component-at-node.js +62 -20
  112. package/dist/react18/replace-unmount-component-at-node.js.map +1 -1
  113. package/dist/react19/replace-default-props.d.ts.map +1 -1
  114. package/dist/react19/replace-default-props.js +10 -13
  115. package/dist/react19/replace-default-props.js.map +1 -1
  116. package/dist/react19/replace-react-shallow-renderer.d.ts.map +1 -1
  117. package/dist/react19/replace-react-shallow-renderer.js +1 -6
  118. package/dist/react19/replace-react-shallow-renderer.js.map +1 -1
  119. package/dist/refactoring/create-class-to-es6.d.ts.map +1 -1
  120. package/dist/refactoring/create-class-to-es6.js +4 -7
  121. package/dist/refactoring/create-class-to-es6.js.map +1 -1
  122. package/dist/refactoring/create-element-to-jsx.d.ts.map +1 -1
  123. package/dist/refactoring/create-element-to-jsx.js +3 -4
  124. package/dist/refactoring/create-element-to-jsx.js.map +1 -1
  125. package/dist/refactoring/prop-types-to-typescript.js +2 -3
  126. package/dist/refactoring/prop-types-to-typescript.js.map +1 -1
  127. package/dist/refactoring/pure-render-mixin.d.ts.map +1 -1
  128. package/dist/refactoring/pure-render-mixin.js +3 -6
  129. package/dist/refactoring/pure-render-mixin.js.map +1 -1
  130. package/dist/testing/enzyme-constant-strings.d.ts +12 -0
  131. package/dist/testing/enzyme-constant-strings.d.ts.map +1 -0
  132. package/dist/testing/enzyme-constant-strings.js +101 -0
  133. package/dist/testing/enzyme-constant-strings.js.map +1 -0
  134. package/dist/testing/enzyme-host-components.d.ts +14 -0
  135. package/dist/testing/enzyme-host-components.d.ts.map +1 -0
  136. package/dist/testing/enzyme-host-components.js +248 -0
  137. package/dist/testing/enzyme-host-components.js.map +1 -0
  138. package/dist/testing/enzyme-portals.d.ts +38 -0
  139. package/dist/testing/enzyme-portals.d.ts.map +1 -0
  140. package/dist/testing/enzyme-portals.js +226 -0
  141. package/dist/testing/enzyme-portals.js.map +1 -0
  142. package/dist/testing/enzyme-selector-names.d.ts +9 -0
  143. package/dist/testing/enzyme-selector-names.d.ts.map +1 -0
  144. package/dist/testing/enzyme-selector-names.js +50 -0
  145. package/dist/testing/enzyme-selector-names.js.map +1 -0
  146. package/dist/testing/enzyme-to-react-testing-library.d.ts +80 -12
  147. package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
  148. package/dist/testing/enzyme-to-react-testing-library.js +447 -135
  149. package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
  150. package/dist/testing/enzyme-usage.d.ts.map +1 -1
  151. package/dist/testing/enzyme-usage.js +27 -4
  152. package/dist/testing/enzyme-usage.js.map +1 -1
  153. package/dist/testing/enzyme-wrapper-scope.d.ts +23 -8
  154. package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
  155. package/dist/testing/enzyme-wrapper-scope.js +291 -169
  156. package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
  157. package/dist/util/java-recipe-proxy.d.ts +16 -0
  158. package/dist/util/java-recipe-proxy.d.ts.map +1 -0
  159. package/dist/util/java-recipe-proxy.js +85 -0
  160. package/dist/util/java-recipe-proxy.js.map +1 -0
  161. package/dist/util/module-imports.d.ts +13 -0
  162. package/dist/util/module-imports.d.ts.map +1 -0
  163. package/dist/util/module-imports.js +60 -0
  164. package/dist/util/module-imports.js.map +1 -0
  165. package/dist/util/react-class.d.ts +1 -0
  166. package/dist/util/react-class.d.ts.map +1 -1
  167. package/dist/util/react-class.js +3 -2
  168. package/dist/util/react-class.js.map +1 -1
  169. package/package.json +4 -4
  170. package/src/index.ts +2 -1
  171. package/src/migration/cra-to-vite/add-vite-config.ts +53 -1
  172. package/src/migration/cra-to-vite/cra-file-gate.ts +8 -0
  173. package/src/migration/cra-to-vite/cra-runtime.ts +16 -0
  174. package/src/migration/cra-to-vite/cra-script.ts +61 -0
  175. package/src/migration/cra-to-vite/cra-to-vite.ts +25 -36
  176. package/src/migration/cra-to-vite/cra-typecheck.ts +33 -0
  177. package/src/migration/cra-to-vite/find-cra-config-blockers.ts +23 -28
  178. package/src/migration/cra-to-vite/index.ts +10 -2
  179. package/src/migration/cra-to-vite/migrate-cra-package.ts +127 -0
  180. package/src/migration/cra-to-vite/migrate-cra-svg-imports.ts +41 -0
  181. package/src/migration/cra-to-vite/migrate-cra-tests-to-vitest.ts +376 -0
  182. package/src/migration/cra-to-vite/move-public-index-html.ts +12 -7
  183. package/src/migration/cra-to-vite/plan-cra-to-vite.ts +283 -0
  184. package/src/migration/cra-to-vite/prepare-cra-package.ts +86 -0
  185. package/src/migration/cra-to-vite/remove-cra-configuration.ts +64 -0
  186. package/src/migration/cra-to-vite/rename-jsx-files.ts +155 -0
  187. package/src/migration/cra-to-vite/rename-process-env-react-app.ts +6 -3
  188. package/src/migration/cra-to-vite/rename-react-app-env-vars-in-env-files.ts +1 -1
  189. package/src/migration/cra-to-vite/replace-react-scripts-dependency.ts +48 -54
  190. package/src/migration/cra-to-vite/resolved-cra-dependency.ts +41 -0
  191. package/src/migration/cra-to-vite/scan-cra-projects.ts +57 -6
  192. package/src/migration/cra-to-vite/shared.ts +35 -146
  193. package/src/migration/cra-to-vite/svg-component.ts +39 -0
  194. package/src/migration/cra-to-vite/update-react-app-env-types.ts +11 -4
  195. package/src/migration/cra-to-vite/update-react-scripts-scripts.ts +30 -41
  196. package/src/migration/cra-to-vite/update-tsconfig-for-vite.ts +6 -13
  197. package/src/react17/migrate-deprecated-lifecycles.ts +2 -2
  198. package/src/react17/use-new-jsx-transform.ts +30 -72
  199. package/src/react18/replace-reactdom-render.ts +17 -8
  200. package/src/react18/replace-unmount-component-at-node.ts +78 -32
  201. package/src/react19/replace-default-props.ts +11 -15
  202. package/src/react19/replace-react-shallow-renderer.ts +2 -7
  203. package/src/refactoring/create-class-to-es6.ts +6 -9
  204. package/src/refactoring/create-element-to-jsx.ts +4 -6
  205. package/src/refactoring/prop-types-to-typescript.ts +4 -4
  206. package/src/refactoring/pure-render-mixin.ts +4 -7
  207. package/src/testing/enzyme-constant-strings.ts +95 -0
  208. package/src/testing/enzyme-host-components.ts +287 -0
  209. package/src/testing/enzyme-portals.ts +279 -0
  210. package/src/testing/enzyme-selector-names.ts +59 -0
  211. package/src/testing/enzyme-to-react-testing-library.ts +584 -140
  212. package/src/testing/enzyme-usage.ts +29 -4
  213. package/src/testing/enzyme-wrapper-scope.ts +309 -151
  214. package/src/util/java-recipe-proxy.ts +81 -0
  215. package/src/util/module-imports.ts +60 -0
  216. package/src/util/react-class.ts +2 -1
@@ -9,20 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SIMULATED_EVENTS = void 0;
12
13
  exports.domSelector = domSelector;
13
14
  exports.selectorLiteral = selectorLiteral;
14
15
  exports.simpleChain = simpleChain;
15
16
  exports.statementPosition = statementPosition;
16
17
  exports.mountedElement = mountedElement;
18
+ exports.passesRef = passesRef;
19
+ exports.variableCursor = variableCursor;
17
20
  exports.wrapperDeclaration = wrapperDeclaration;
18
21
  exports.analyzeWrapperScope = analyzeWrapperScope;
22
+ exports.innermostCall = innermostCall;
19
23
  exports.idsWithin = idsWithin;
20
24
  exports.withoutEnzymeTypes = withoutEnzymeTypes;
21
25
  exports.withRenderOptionsOnElementLine = withRenderOptionsOnElementLine;
26
+ const rewrite_1 = require("@openrewrite/rewrite");
22
27
  const javascript_1 = require("@openrewrite/rewrite/javascript");
23
28
  const java_1 = require("@openrewrite/rewrite/java");
24
29
  const mutative_1 = require("mutative");
25
30
  const enzyme_usage_1 = require("./enzyme-usage");
31
+ const module_imports_1 = require("../util/module-imports");
26
32
  const HTML_TAGS = new Set(["a", "abbr", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo",
27
33
  "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data",
28
34
  "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset",
@@ -64,21 +70,47 @@ function domSelector(value) {
64
70
  function onlyStringPropsRenderTo(value) {
65
71
  return value !== "true" && value !== "false" && String(Number(value)) !== value;
66
72
  }
67
- function selectorLiteral(node) {
68
- return (node === null || node === void 0 ? void 0 : node.kind) === java_1.J.Kind.Literal && domSelector(node.value);
73
+ function selectorLiteral(node, hostNames) {
74
+ return (node === null || node === void 0 ? void 0 : node.kind) === java_1.J.Kind.Literal && acceptedSelector(node.value, hostNames);
75
+ }
76
+ function acceptedSelector(value, hostNames) {
77
+ if (!domSelector(value))
78
+ return false;
79
+ const names = untaggedAncestorNames(value);
80
+ return names !== undefined && (names.length === 0 || hostNames(names));
81
+ }
82
+ const NAME = new RegExp(String.raw `[.#](-?[_a-zA-Z][\w-]*)|\[${ATTRIBUTE}(?:="([^"\\]*)"|='([^'\\]*)')?\]`, "g");
83
+ function untaggedAncestorNames(selector) {
84
+ var _a;
85
+ const compounds = selector.split(" ").slice(0, -1).filter(compound => !/^[a-z]/.test(compound));
86
+ const names = [];
87
+ for (const compound of compounds) {
88
+ for (const [, name, double, single] of compound.matchAll(NAME)) {
89
+ const value = (_a = name !== null && name !== void 0 ? name : double) !== null && _a !== void 0 ? _a : single;
90
+ if (value === undefined)
91
+ return undefined;
92
+ names.push(value);
93
+ }
94
+ }
95
+ return names;
69
96
  }
70
97
  function selectorTag(selector) {
71
- const tags = compoundTags(selector.value);
98
+ const tags = compoundTags(selector);
72
99
  return tags === null || tags === void 0 ? void 0 : tags[tags.length - 1];
73
100
  }
74
101
  function positional(selector, hostNodes) {
75
- const tags = compoundTags(selector.value);
102
+ const tags = compoundTags(selector);
76
103
  return tags.every(tag => tag !== undefined) || (hostNodes && tags.length === 1);
77
104
  }
78
- const SIMULATED_EVENTS = new Set(["click", "doubleClick", "mouseDown", "mouseUp", "mouseEnter", "mouseLeave",
105
+ function onlyBelow(selector, within) {
106
+ const tag = selectorTag(selector);
107
+ const tags = compoundTags(within);
108
+ return tag !== undefined && (tags === null || tags === void 0 ? void 0 : tags.length) === 1 && tags[0] !== undefined && tags[0] !== tag;
109
+ }
110
+ exports.SIMULATED_EVENTS = new Set(["click", "doubleClick", "mouseDown", "mouseUp", "mouseEnter", "mouseLeave",
79
111
  "mouseOver", "mouseOut", "mouseMove", "focus", "blur", "submit", "keyDown", "keyUp", "change", "touchStart",
80
112
  "touchMove", "touchEnd", "wheel"]);
81
- const NATIVE_EVENT_NAMES = new Map([...[...SIMULATED_EVENTS].map(event => [event.toLowerCase(), event]), ["dblclick", "doubleClick"]]);
113
+ const NATIVE_EVENT_NAMES = new Map([...[...exports.SIMULATED_EVENTS].map(event => [event.toLowerCase(), event]), ["dblclick", "doubleClick"]]);
82
114
  const CLICK_DEFAULT_ACTIONS = new Set(["a", "input", "label", "option", "select", "summary", "textarea"]);
83
115
  function simpleChain(node) {
84
116
  if (node.markers.markers.some(marker => marker.kind === javascript_1.JS.Markers.Optional))
@@ -95,9 +127,6 @@ function simpleChain(node) {
95
127
  }
96
128
  return (0, java_1.isIdentifier)(node);
97
129
  }
98
- function untyped(type) {
99
- return !type || type.kind === java_1.Type.Kind.Unknown;
100
- }
101
130
  function noArguments(call) {
102
131
  return call.arguments.elements.every(arg => arg.element.kind === java_1.J.Kind.Empty);
103
132
  }
@@ -123,6 +152,18 @@ function mountedElement(mount) {
123
152
  const [element] = mount.arguments.elements;
124
153
  return mount.arguments.elements.length === 1 && element.element.kind !== java_1.J.Kind.Empty && element.element.kind !== javascript_1.JS.Kind.Spread;
125
154
  }
155
+ function passesRef(mount) {
156
+ let ref = false;
157
+ (0, javascript_1.walk)(mount.arguments.elements[0].element, tree => {
158
+ if (tree.kind === javascript_1.JS.Kind.JsxAttribute) {
159
+ const key = tree.key;
160
+ if ((0, java_1.isIdentifier)(key) && key.simpleName === "ref")
161
+ ref = true;
162
+ }
163
+ return !ref;
164
+ });
165
+ return ref;
166
+ }
126
167
  function nodesMatcher(expectCursor) {
127
168
  var _a;
128
169
  const expect = expectCursor.value;
@@ -145,13 +186,10 @@ function stringLiteral(node) {
145
186
  return (node === null || node === void 0 ? void 0 : node.kind) === java_1.J.Kind.Literal && typeof node.value === "string";
146
187
  }
147
188
  function objectProperties(node) {
148
- if ((node === null || node === void 0 ? void 0 : node.kind) !== java_1.J.Kind.NewClass)
149
- return undefined;
150
- const object = node;
151
- if (object.class || !object.body)
189
+ if (!node || !(0, javascript_1.isObjectLiteral)(node) || !node.body)
152
190
  return undefined;
153
191
  const properties = new Map();
154
- for (const statement of object.body.statements) {
192
+ for (const statement of node.body.statements) {
155
193
  const property = statement.element;
156
194
  if (property.kind !== javascript_1.JS.Kind.PropertyAssignment || property.assigmentToken !== "Colon" ||
157
195
  !(0, java_1.isIdentifier)(property.name.element) || !property.initializer)
@@ -176,6 +214,41 @@ function nativeEventInit(event, init) {
176
214
  const nativeEvent = objectProperties(properties === null || properties === void 0 ? void 0 : properties.get("nativeEvent"));
177
215
  return event !== "change" && (properties === null || properties === void 0 ? void 0 : properties.size) === 1 && nativeEvent ? [...nativeEvent] : undefined;
178
216
  }
217
+ function innerHtmlAssertion(read, html) {
218
+ if (!expectArgument(read, html))
219
+ return false;
220
+ const expect = read.parentTree();
221
+ const matcherCursor = expect.parentTree();
222
+ const matcher = matcherCursor === null || matcherCursor === void 0 ? void 0 : matcherCursor.value;
223
+ if (!selectOf(matcher, expect.value) || !statement(matcherCursor))
224
+ return false;
225
+ const args = matcher.arguments.elements.filter(arg => arg.element.kind !== java_1.J.Kind.Empty).map(arg => arg.element);
226
+ if (call(matcher, "toMatchSnapshot"))
227
+ return args.length === 0 || args.length === 1 && stringLiteral(args[0]);
228
+ return (call(matcher, "toBe") || call(matcher, "toEqual") || call(matcher, "toContain")) &&
229
+ args.length === 1 && stringLiteral(args[0]) && args[0].value !== "";
230
+ }
231
+ function unmountsWithoutThrowing(unmount) {
232
+ var _a, _b;
233
+ const lambdaCursor = unmount.parentTree();
234
+ const lambda = lambdaCursor === null || lambdaCursor === void 0 ? void 0 : lambdaCursor.value;
235
+ if ((lambda === null || lambda === void 0 ? void 0 : lambda.kind) !== java_1.J.Kind.Lambda || lambda.body !== unmount.value ||
236
+ lambda.parameters.parameters.some(parameter => parameter.element.kind !== java_1.J.Kind.Empty))
237
+ return false;
238
+ const arrowCursor = lambdaCursor.parentTree();
239
+ const arrow = arrowCursor === null || arrowCursor === void 0 ? void 0 : arrowCursor.value;
240
+ if ((arrow === null || arrow === void 0 ? void 0 : arrow.kind) !== javascript_1.JS.Kind.ArrowFunction || arrow.lambda !== lambda || !expectArgument(arrowCursor, arrow))
241
+ return false;
242
+ const expectCursor = arrowCursor.parentTree();
243
+ const not = (_a = expectCursor.parentTree()) === null || _a === void 0 ? void 0 : _a.value;
244
+ if ((not === null || not === void 0 ? void 0 : not.kind) !== java_1.J.Kind.FieldAccess || not.target !== expectCursor.value ||
245
+ not.name.element.simpleName !== "not")
246
+ return false;
247
+ const matcherCursor = expectCursor.parentTree().parentTree();
248
+ const matcher = matcherCursor === null || matcherCursor === void 0 ? void 0 : matcherCursor.value;
249
+ return call(matcher, "toThrow") && ((_b = matcher.select) === null || _b === void 0 ? void 0 : _b.element) === not &&
250
+ noArguments(matcher) && statement(matcherCursor) !== undefined;
251
+ }
179
252
  function expectArgument(cursor, node) {
180
253
  var _a;
181
254
  const parent = (_a = cursor.parentTree()) === null || _a === void 0 ? void 0 : _a.value;
@@ -184,7 +257,10 @@ function expectArgument(cursor, node) {
184
257
  const expect = parent;
185
258
  return !expect.select && expect.arguments.elements.length === 1 && expect.arguments.elements[0].element === node;
186
259
  }
187
- function wrapperDeclaration(statement) {
260
+ function variableCursor(block, declaration) {
261
+ return new rewrite_1.Cursor(declaration.variables[0].element, new rewrite_1.Cursor(declaration, block));
262
+ }
263
+ function wrapperDeclaration(statement, classify) {
188
264
  var _a;
189
265
  if ((statement === null || statement === void 0 ? void 0 : statement.kind) !== java_1.J.Kind.VariableDeclarations)
190
266
  return undefined;
@@ -198,173 +274,219 @@ function wrapperDeclaration(statement) {
198
274
  if (!(0, java_1.isIdentifier)(variable.name) || (initializer === null || initializer === void 0 ? void 0 : initializer.kind) !== java_1.J.Kind.MethodInvocation)
199
275
  return undefined;
200
276
  const mount = initializer;
201
- if ((0, enzyme_usage_1.enzymeMethod)(mount) !== "mount" || mount.typeParameters || !mountedElement(mount))
277
+ if (mount.typeParameters || !mountedElement(mount))
202
278
  return undefined;
203
- return { declaration, name: variable.name.simpleName, mount };
279
+ const render = classify(mount);
280
+ return render === undefined ? undefined : { declaration, name: variable.name.simpleName, mount, render };
204
281
  }
205
- function analyzeWrapperScope(block, declaration, name, events, untaggedPositions, cursor, ctx) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- const uses = new Map();
208
- const removedStatements = new Set();
209
- const unmounts = new Set();
210
- let declared = false;
211
- let supported = true;
212
- let unmounted = false;
213
- const variable = declaration.variables[0].element;
214
- yield new class extends javascript_1.JavaScriptVisitor {
215
- visitIdentifier(identifier, ctx) {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- if (identifier.simpleName !== name || !supported)
218
- return identifier;
219
- if (identifier === variable.name) {
220
- declared = true;
221
- return identifier;
222
- }
223
- const use = unmounted ? undefined : this.use(identifier);
224
- if (!use)
225
- supported = false;
226
- return identifier;
227
- });
282
+ function analyzeWrapperScope(block, { declaration, name }, { events, html, untaggedPositions, hostNames, snapshots = false, constant = () => undefined }) {
283
+ let serializers;
284
+ const uses = new Map();
285
+ const removedStatements = new Set();
286
+ const unmounts = new Set();
287
+ let unmounted = false;
288
+ const variable = declaration.variables[0].element;
289
+ const selectorValue = (node) => {
290
+ if (!node)
291
+ return undefined;
292
+ if (selectorLiteral(node, hostNames))
293
+ return node.value;
294
+ const value = node.kind === javascript_1.JS.Kind.TemplateExpression ? constant(node) : undefined;
295
+ return acceptedSelector(value, hostNames) ? value : undefined;
296
+ };
297
+ const record = (node, read) => {
298
+ if (!simpleChain(node))
299
+ return false;
300
+ uses.set(node.id, read);
301
+ return true;
302
+ };
303
+ const elementIndex = (node, inner) => {
304
+ if (!selectOf(node, inner))
305
+ return undefined;
306
+ const method = node;
307
+ if ((call(method, "first") || call(method, "last")) && noArguments(method))
308
+ return method.name.simpleName;
309
+ const [position] = method.arguments.elements;
310
+ if (call(method, "at") && method.arguments.elements.length === 1 && position.element.kind === java_1.J.Kind.Literal &&
311
+ Number.isInteger(position.element.value) && position.element.value >= 0) {
312
+ return position.element;
313
+ }
314
+ return undefined;
315
+ };
316
+ const use = (identifier, reference) => {
317
+ var _a, _b, _c, _d, _e, _f, _g;
318
+ const ancestors = [];
319
+ for (let c = reference.parentTree(); c && ancestors.length < 5; c = c.parentTree())
320
+ ancestors.push(c);
321
+ const first = (_a = ancestors[0]) === null || _a === void 0 ? void 0 : _a.value;
322
+ if (snapshots) {
323
+ serializers !== null && serializers !== void 0 ? serializers : (serializers = snapshotSerializers(block));
324
+ const assertion = snapshotAssertion(identifier, ancestors, serializers);
325
+ if (assertion)
326
+ return record(assertion, { wrapper: identifier, use: "snapshot" });
327
+ }
328
+ if (!selectOf(first, identifier))
329
+ return false;
330
+ const method = first;
331
+ if (call(method, "find")) {
332
+ const args = method.arguments.elements;
333
+ const selectorText = args.length === 1 ? selectorValue(args[0].element) : undefined;
334
+ if (selectorText === undefined)
335
+ return false;
336
+ const selector = args[0].element;
337
+ let k = 1;
338
+ let inner = method;
339
+ let hostNodes = false;
340
+ if (call((_b = ancestors[k]) === null || _b === void 0 ? void 0 : _b.value, "hostNodes") && selectOf(ancestors[k].value, inner) && noArguments(ancestors[k].value)) {
341
+ inner = ancestors[k++].value;
342
+ hostNodes = true;
228
343
  }
229
- use(identifier) {
230
- var _a, _b, _c, _d, _e, _f, _g;
231
- if (!(0, enzyme_usage_1.enzymeWrapper)(identifier.type) && !untyped(identifier.type))
232
- return false;
233
- const ancestors = [];
234
- for (let c = this.cursor.parentTree(); c && ancestors.length < 5; c = c.parentTree())
235
- ancestors.push(c);
236
- const first = (_a = ancestors[0]) === null || _a === void 0 ? void 0 : _a.value;
237
- if (!selectOf(first, identifier))
344
+ const index = elementIndex((_c = ancestors[k]) === null || _c === void 0 ? void 0 : _c.value, inner);
345
+ let within;
346
+ if (index) {
347
+ if (!untaggedPositions && !positional(selectorText, hostNodes))
238
348
  return false;
239
- const method = first;
240
- if (call(method, "find")) {
241
- const args = method.arguments.elements;
242
- if (args.length !== 1 || !selectorLiteral(args[0].element))
243
- return false;
244
- const selector = args[0].element;
245
- let k = 1;
246
- let inner = method;
247
- let hostNodes = false;
248
- if (call((_b = ancestors[k]) === null || _b === void 0 ? void 0 : _b.value, "hostNodes") && selectOf(ancestors[k].value, inner) && noArguments(ancestors[k].value)) {
249
- inner = ancestors[k++].value;
250
- hostNodes = true;
251
- }
252
- const index = this.index((_c = ancestors[k]) === null || _c === void 0 ? void 0 : _c.value, inner);
253
- let within;
254
- if (index) {
255
- if (!untaggedPositions && !positional(selector, hostNodes))
256
- return false;
257
- inner = ancestors[k++].value;
258
- const nested = (_d = ancestors[k]) === null || _d === void 0 ? void 0 : _d.value;
259
- if (call(nested, "find") && selectOf(nested, inner)) {
260
- const [argument] = nested.arguments.elements;
261
- if (nested.arguments.elements.length !== 1 || !selectorLiteral(argument.element))
262
- return false;
263
- within = argument.element;
264
- inner = ancestors[k++].value;
265
- }
266
- }
267
- const outer = (_e = ancestors[k]) === null || _e === void 0 ? void 0 : _e.value;
268
- const outerCursor = ancestors[k];
269
- const read = { wrapper: identifier, selector, index, within };
270
- if ((!index || within) && (outer === null || outer === void 0 ? void 0 : outer.kind) === java_1.J.Kind.FieldAccess && outer.target === inner &&
271
- outer.name.element.simpleName === "length") {
272
- return this.record(outer, Object.assign(Object.assign({}, read), { use: "length" }));
273
- }
274
- if (!index && expectArgument(ancestors[k - 1], inner)) {
275
- const matcher = nodesMatcher(outerCursor);
276
- return matcher !== undefined && this.record(inner, Object.assign(Object.assign({}, read), { use: "nodes", vacuous: matcher === "truthy" }));
277
- }
278
- if (!selectOf(outer, inner))
279
- return false;
280
- const terminal = outer;
281
- const terminalArgs = terminal.arguments.elements.filter(arg => arg.element.kind !== java_1.J.Kind.Empty).map(arg => arg.element);
282
- if (call(terminal, "exists") && terminalArgs.length === 0)
283
- return this.record(terminal, Object.assign(Object.assign({}, read), { use: !index || within ? "exists" : "positionExists" }));
284
- if (within)
349
+ inner = ancestors[k++].value;
350
+ const nested = (_d = ancestors[k]) === null || _d === void 0 ? void 0 : _d.value;
351
+ if (call(nested, "find") && selectOf(nested, inner)) {
352
+ const [argument] = nested.arguments.elements;
353
+ const withinText = nested.arguments.elements.length === 1 ? selectorValue(argument.element) : undefined;
354
+ if (withinText === undefined || !onlyBelow(selectorText, withinText))
285
355
  return false;
286
- if ((call(terminal, "text") || call(terminal, "html")) && terminalArgs.length === 0) {
287
- return this.record(terminal, Object.assign(Object.assign({}, read), { use: call(terminal, "text") ? "selectorText" : "html", unasserted: !expectArgument(outerCursor, terminal) }));
288
- }
289
- if (call(terminal, "hasClass") && terminalArgs.length === 1 && stringLiteral(terminalArgs[0]) &&
290
- /^-?[_a-zA-Z][\w-]*$/.test(terminalArgs[0].value)) {
291
- return this.record(terminal, Object.assign(Object.assign({}, read), { use: "hasClass", className: terminalArgs[0] }));
292
- }
293
- if (call(terminal, "simulate") && events && statement(outerCursor) && terminalArgs.length >= 1 && terminalArgs.length <= 2 &&
294
- stringLiteral(terminalArgs[0])) {
295
- const name = terminalArgs[0].value;
296
- const event = SIMULATED_EVENTS.has(name) ? name : NATIVE_EVENT_NAMES.get(name);
297
- if (!event)
298
- return false;
299
- const nativeEvent = nativeEventInit(event, terminalArgs[1]);
300
- if (!nativeEvent && !eventInit(event, terminalArgs[1]))
301
- return false;
302
- if (event === "click" && CLICK_DEFAULT_ACTIONS.has((_f = selectorTag(selector)) !== null && _f !== void 0 ? _f : ""))
303
- return false;
304
- return this.record(terminal, Object.assign(Object.assign(Object.assign({}, read), { use: "simulate", event }), nativeEvent ? { nativeEvent } : { eventInit: terminalArgs[1] }));
305
- }
306
- return false;
307
- }
308
- const [argument] = method.arguments.elements;
309
- if (call(method, "exists") && method.arguments.elements.length === 1 && selectorLiteral(argument.element)) {
310
- return this.record(method, { wrapper: identifier, selector: argument.element, use: "exists" });
311
- }
312
- if (call(method, "setProps") && method.arguments.elements.length === 1 && statement(ancestors[0]) &&
313
- argument.element.kind !== java_1.J.Kind.Empty && argument.element.kind !== javascript_1.JS.Kind.Spread) {
314
- return this.record(method, { wrapper: identifier, use: "setProps", props: argument.element });
315
- }
316
- if (!noArguments(method))
317
- return false;
318
- if (call(method, "text"))
319
- return this.record(method, { wrapper: identifier, use: "text", unasserted: !expectArgument(ancestors[0], method) });
320
- if (call(method, "update") && ((_g = statement(ancestors[0])) === null || _g === void 0 ? void 0 : _g.prefix.comments.length) === 0 && method.prefix.comments.length === 0) {
321
- removedStatements.add(method.id);
322
- return simpleChain(method);
323
- }
324
- if (call(method, "unmount") && statement(ancestors[0])) {
325
- unmounted = true;
326
- unmounts.add(method.id);
327
- return simpleChain(method);
356
+ within = argument.element;
357
+ inner = ancestors[k++].value;
328
358
  }
359
+ }
360
+ const outer = (_e = ancestors[k]) === null || _e === void 0 ? void 0 : _e.value;
361
+ const outerCursor = ancestors[k];
362
+ const read = { wrapper: identifier, selector, index, within };
363
+ if ((!index || within) && (outer === null || outer === void 0 ? void 0 : outer.kind) === java_1.J.Kind.FieldAccess && outer.target === inner &&
364
+ outer.name.element.simpleName === "length") {
365
+ return record(outer, Object.assign(Object.assign({}, read), { use: "length" }));
366
+ }
367
+ if (!index && expectArgument(ancestors[k - 1], inner)) {
368
+ const matcher = nodesMatcher(outerCursor);
369
+ return matcher !== undefined && record(inner, Object.assign(Object.assign({}, read), { use: "nodes", vacuous: matcher === "truthy" }));
370
+ }
371
+ if (!selectOf(outer, inner))
372
+ return false;
373
+ const terminal = outer;
374
+ const terminalArgs = terminal.arguments.elements.filter(arg => arg.element.kind !== java_1.J.Kind.Empty).map(arg => arg.element);
375
+ if (call(terminal, "exists") && terminalArgs.length === 0)
376
+ return record(terminal, Object.assign(Object.assign({}, read), { use: !index || within ? "exists" : "positionExists" }));
377
+ if (within)
329
378
  return false;
379
+ if (html && (call(terminal, "instance") || call(terminal, "getDOMNode")) && terminalArgs.length === 0 && positional(selectorText, hostNodes)) {
380
+ return record(terminal, Object.assign(Object.assign({}, read), { use: "node" }));
330
381
  }
331
- index(node, inner) {
332
- if (!selectOf(node, inner))
333
- return undefined;
334
- const method = node;
335
- if ((call(method, "first") || call(method, "last")) && noArguments(method))
336
- return method.name.simpleName;
337
- const [position] = method.arguments.elements;
338
- if (call(method, "at") && method.arguments.elements.length === 1 && position.element.kind === java_1.J.Kind.Literal &&
339
- Number.isInteger(position.element.value) && position.element.value >= 0) {
340
- return position.element;
341
- }
342
- return undefined;
382
+ if ((call(terminal, "text") || html && call(terminal, "html")) && terminalArgs.length === 0) {
383
+ return record(terminal, Object.assign(Object.assign({}, read), { use: call(terminal, "text") ? "selectorText" : "html", unasserted: !expectArgument(outerCursor, terminal) }));
343
384
  }
344
- record(node, read) {
345
- if (!simpleChain(node))
385
+ if (call(terminal, "hasClass") && terminalArgs.length === 1 && stringLiteral(terminalArgs[0]) &&
386
+ /^-?[_a-zA-Z][\w-]*$/.test(terminalArgs[0].value)) {
387
+ return record(terminal, Object.assign(Object.assign({}, read), { use: "hasClass", className: terminalArgs[0] }));
388
+ }
389
+ if (call(terminal, "simulate") && events.size > 0 && statement(outerCursor) && terminalArgs.length >= 1 && terminalArgs.length <= 2 &&
390
+ stringLiteral(terminalArgs[0])) {
391
+ const name = terminalArgs[0].value;
392
+ const event = exports.SIMULATED_EVENTS.has(name) ? name : NATIVE_EVENT_NAMES.get(name);
393
+ if (!event || !events.has(event))
394
+ return false;
395
+ const nativeEvent = nativeEventInit(event, terminalArgs[1]);
396
+ if (!nativeEvent && !eventInit(event, terminalArgs[1]))
346
397
  return false;
347
- uses.set(node.id, read);
348
- return true;
398
+ if (event === "click" && CLICK_DEFAULT_ACTIONS.has((_f = selectorTag(selectorText)) !== null && _f !== void 0 ? _f : ""))
399
+ return false;
400
+ return record(terminal, Object.assign(Object.assign(Object.assign({}, read), { use: "simulate", event }), nativeEvent ? { nativeEvent } : { eventInit: terminalArgs[1] }));
349
401
  }
350
- }().visit(block, ctx, cursor);
351
- return declared && supported ? { declaration, name, uses, removedStatements, unmounts } : undefined;
352
- });
402
+ return false;
403
+ }
404
+ const [argument] = method.arguments.elements;
405
+ if (call(method, "exists") && method.arguments.elements.length === 1 && selectorValue(argument.element) !== undefined) {
406
+ return record(method, { wrapper: identifier, selector: argument.element, use: "exists" });
407
+ }
408
+ if (call(method, "setProps") && method.arguments.elements.length === 1 && statement(ancestors[0]) &&
409
+ argument.element.kind !== java_1.J.Kind.Empty && argument.element.kind !== javascript_1.JS.Kind.Spread) {
410
+ return record(method, { wrapper: identifier, use: "setProps", props: argument.element });
411
+ }
412
+ if (!noArguments(method))
413
+ return false;
414
+ if (html && call(method, "html") && innerHtmlAssertion(ancestors[0], method))
415
+ return record(method, { wrapper: identifier, use: "rootHtml" });
416
+ if (call(method, "text"))
417
+ return record(method, { wrapper: identifier, use: "text", unasserted: !expectArgument(ancestors[0], method) });
418
+ if (call(method, "update") && ((_g = statement(ancestors[0])) === null || _g === void 0 ? void 0 : _g.prefix.comments.length) === 0 && method.prefix.comments.length === 0) {
419
+ removedStatements.add(method.id);
420
+ return simpleChain(method);
421
+ }
422
+ if (call(method, "unmount") && (statement(ancestors[0]) || unmountsWithoutThrowing(ancestors[0]))) {
423
+ unmounted = true;
424
+ unmounts.add(method.id);
425
+ return simpleChain(method);
426
+ }
427
+ return false;
428
+ };
429
+ const declared = new rewrite_1.Cursor(variable.name, variableCursor(block, declaration));
430
+ const references = (0, javascript_1.referencesOf)(declared, name, "value");
431
+ if (!references.some(reference => reference.identifier === variable.name))
432
+ return undefined;
433
+ for (const reference of references) {
434
+ if (reference.identifier === variable.name)
435
+ continue;
436
+ if (reference.declares || unmounted || !use(reference.identifier, reference.cursor))
437
+ return undefined;
438
+ }
439
+ return { declaration, name, uses, removedStatements, unmounts };
353
440
  }
354
- function idsWithin(node, ids, ctx) {
355
- return __awaiter(this, void 0, void 0, function* () {
356
- const found = [];
357
- yield new class extends javascript_1.JavaScriptVisitor {
358
- preVisit(tree) {
359
- return __awaiter(this, void 0, void 0, function* () {
360
- if (ids.has(tree.id))
361
- found.push(tree.id);
362
- return tree;
363
- });
364
- }
365
- }().visit(node, ctx);
366
- return found;
441
+ function snapshotSerializers(cursor) {
442
+ const cu = (0, javascript_1.compilationUnitOf)(cursor);
443
+ return new Set(cu ? (0, module_imports_1.importBindings)(cu).filter(({ module }) => module === "enzyme-to-json").map(({ local }) => local) : []);
444
+ }
445
+ function snapshotAssertion(identifier, ancestors, serializers) {
446
+ var _a, _b, _c;
447
+ let k = 0;
448
+ const onlyArgument = (call, argument) => (call === null || call === void 0 ? void 0 : call.kind) === java_1.J.Kind.MethodInvocation && !call.select &&
449
+ call.arguments.elements.length === 1 && call.arguments.elements[0].element === argument;
450
+ let subject = identifier;
451
+ const serialized = (_a = ancestors[k]) === null || _a === void 0 ? void 0 : _a.value;
452
+ if (onlyArgument(serialized, subject) && serializers.has(serialized.name.simpleName)) {
453
+ subject = serialized;
454
+ k++;
455
+ }
456
+ const expectCall = (_b = ancestors[k]) === null || _b === void 0 ? void 0 : _b.value;
457
+ if (!onlyArgument(expectCall, subject) || expectCall.name.simpleName !== "expect")
458
+ return undefined;
459
+ const matcher = (_c = ancestors[k + 1]) === null || _c === void 0 ? void 0 : _c.value;
460
+ if (!call(matcher, "toMatchSnapshot") || !selectOf(matcher, expectCall) || !statement(ancestors[k + 1]))
461
+ return undefined;
462
+ const args = matcher.arguments.elements.filter(arg => arg.element.kind !== java_1.J.Kind.Empty);
463
+ if (args.length > 1 || (args.length === 1 && !stringLiteral(args[0].element)))
464
+ return undefined;
465
+ return expectCall;
466
+ }
467
+ function innermostCall(node) {
468
+ var _a;
469
+ let call;
470
+ for (let current = node; current;) {
471
+ if (current.kind === java_1.J.Kind.FieldAccess)
472
+ current = current.target;
473
+ else if (current.kind === java_1.J.Kind.MethodInvocation) {
474
+ call = current;
475
+ current = (_a = call.select) === null || _a === void 0 ? void 0 : _a.element;
476
+ }
477
+ else
478
+ break;
479
+ }
480
+ return call;
481
+ }
482
+ function idsWithin(node, ids) {
483
+ const found = [];
484
+ (0, javascript_1.walk)(node, tree => {
485
+ if (ids.has(tree.id))
486
+ found.push(tree.id);
487
+ return true;
367
488
  });
489
+ return found;
368
490
  }
369
491
  function withoutEnzymeTypes(node, ctx) {
370
492
  return __awaiter(this, void 0, void 0, function* () {