@openrewrite/recipes-react 0.17.0 → 0.19.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 (109) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +9 -5
  4. package/dist/index.js.map +1 -1
  5. package/dist/migration/cra-to-vite/find-cra-config-blockers.d.ts.map +1 -1
  6. package/dist/migration/cra-to-vite/find-cra-config-blockers.js +3 -5
  7. package/dist/migration/cra-to-vite/find-cra-config-blockers.js.map +1 -1
  8. package/dist/migration/cra-to-vite/update-react-app-env-types.d.ts.map +1 -1
  9. package/dist/migration/cra-to-vite/update-react-app-env-types.js +5 -2
  10. package/dist/migration/cra-to-vite/update-react-app-env-types.js.map +1 -1
  11. package/dist/react18/replace-unmount-component-at-node.d.ts.map +1 -1
  12. package/dist/react18/replace-unmount-component-at-node.js +8 -1
  13. package/dist/react18/replace-unmount-component-at-node.js.map +1 -1
  14. package/dist/react19/find-legacy-context-api.d.ts.map +1 -1
  15. package/dist/react19/find-legacy-context-api.js +21 -38
  16. package/dist/react19/find-legacy-context-api.js.map +1 -1
  17. package/dist/react19/no-implicit-ref-callback-return.d.ts.map +1 -1
  18. package/dist/react19/no-implicit-ref-callback-return.js +25 -5
  19. package/dist/react19/no-implicit-ref-callback-return.js.map +1 -1
  20. package/dist/{react18 → react19}/remove-unstable-batched-updates.d.ts +2 -2
  21. package/dist/react19/remove-unstable-batched-updates.d.ts.map +1 -0
  22. package/dist/react19/remove-unstable-batched-updates.js +295 -0
  23. package/dist/react19/remove-unstable-batched-updates.js.map +1 -0
  24. package/dist/react19/replace-default-props.d.ts +1 -0
  25. package/dist/react19/replace-default-props.d.ts.map +1 -1
  26. package/dist/react19/replace-default-props.js +198 -151
  27. package/dist/react19/replace-default-props.js.map +1 -1
  28. package/dist/react19/replace-react-shallow-renderer.d.ts.map +1 -1
  29. package/dist/react19/replace-react-shallow-renderer.js +10 -25
  30. package/dist/react19/replace-react-shallow-renderer.js.map +1 -1
  31. package/dist/refactoring/class-to-functional.d.ts.map +1 -1
  32. package/dist/refactoring/class-to-functional.js +2 -0
  33. package/dist/refactoring/class-to-functional.js.map +1 -1
  34. package/dist/refactoring/create-class-to-es6.d.ts.map +1 -1
  35. package/dist/refactoring/create-class-to-es6.js +14 -49
  36. package/dist/refactoring/create-class-to-es6.js.map +1 -1
  37. package/dist/search/find-function-component-default-props.d.ts.map +1 -1
  38. package/dist/search/find-function-component-default-props.js +6 -15
  39. package/dist/search/find-function-component-default-props.js.map +1 -1
  40. package/dist/search/find-redux-stores.d.ts +12 -0
  41. package/dist/search/find-redux-stores.d.ts.map +1 -0
  42. package/dist/search/find-redux-stores.js +87 -0
  43. package/dist/search/find-redux-stores.js.map +1 -0
  44. package/dist/simplify-object-pattern-property.d.ts.map +1 -1
  45. package/dist/simplify-object-pattern-property.js +14 -21
  46. package/dist/simplify-object-pattern-property.js.map +1 -1
  47. package/dist/simplify-react-imports.d.ts.map +1 -1
  48. package/dist/simplify-react-imports.js +10 -59
  49. package/dist/simplify-react-imports.js.map +1 -1
  50. package/dist/testing/enzyme-host-components.d.ts +2 -1
  51. package/dist/testing/enzyme-host-components.d.ts.map +1 -1
  52. package/dist/testing/enzyme-host-components.js +33 -2
  53. package/dist/testing/enzyme-host-components.js.map +1 -1
  54. package/dist/testing/enzyme-to-react-testing-library.d.ts +10 -1
  55. package/dist/testing/enzyme-to-react-testing-library.d.ts.map +1 -1
  56. package/dist/testing/enzyme-to-react-testing-library.js +83 -24
  57. package/dist/testing/enzyme-to-react-testing-library.js.map +1 -1
  58. package/dist/testing/enzyme-wrapper-scope.d.ts +4 -1
  59. package/dist/testing/enzyme-wrapper-scope.d.ts.map +1 -1
  60. package/dist/testing/enzyme-wrapper-scope.js +36 -7
  61. package/dist/testing/enzyme-wrapper-scope.js.map +1 -1
  62. package/dist/util/java-recipe-proxy.d.ts +2 -0
  63. package/dist/util/java-recipe-proxy.d.ts.map +1 -1
  64. package/dist/util/java-recipe-proxy.js +14 -2
  65. package/dist/util/java-recipe-proxy.js.map +1 -1
  66. package/dist/util/reindent.d.ts +5 -0
  67. package/dist/util/reindent.d.ts.map +1 -0
  68. package/dist/util/reindent.js +44 -0
  69. package/dist/util/reindent.js.map +1 -0
  70. package/dist/zustand/redux-stores.d.ts +74 -0
  71. package/dist/zustand/redux-stores.d.ts.map +1 -0
  72. package/dist/zustand/redux-stores.js +439 -0
  73. package/dist/zustand/redux-stores.js.map +1 -0
  74. package/dist/zustand/redux-to-zustand.d.ts +76 -0
  75. package/dist/zustand/redux-to-zustand.d.ts.map +1 -0
  76. package/dist/zustand/redux-to-zustand.js +654 -0
  77. package/dist/zustand/redux-to-zustand.js.map +1 -0
  78. package/dist/zustand/zustand-plan.d.ts +97 -0
  79. package/dist/zustand/zustand-plan.d.ts.map +1 -0
  80. package/dist/zustand/zustand-plan.js +833 -0
  81. package/dist/zustand/zustand-plan.js.map +1 -0
  82. package/package.json +1 -1
  83. package/src/index.ts +7 -3
  84. package/src/migration/cra-to-vite/find-cra-config-blockers.ts +3 -5
  85. package/src/migration/cra-to-vite/update-react-app-env-types.ts +3 -3
  86. package/src/react18/replace-unmount-component-at-node.ts +13 -2
  87. package/src/react19/find-legacy-context-api.ts +21 -42
  88. package/src/react19/no-implicit-ref-callback-return.ts +34 -8
  89. package/src/react19/remove-unstable-batched-updates.ts +301 -0
  90. package/src/react19/replace-default-props.ts +212 -159
  91. package/src/react19/replace-react-shallow-renderer.ts +13 -36
  92. package/src/refactoring/class-to-functional.ts +3 -1
  93. package/src/refactoring/create-class-to-es6.ts +12 -63
  94. package/src/search/find-function-component-default-props.ts +8 -10
  95. package/src/search/find-redux-stores.ts +76 -0
  96. package/src/simplify-object-pattern-property.ts +22 -49
  97. package/src/simplify-react-imports.ts +12 -66
  98. package/src/testing/enzyme-host-components.ts +38 -3
  99. package/src/testing/enzyme-to-react-testing-library.ts +118 -31
  100. package/src/testing/enzyme-wrapper-scope.ts +39 -10
  101. package/src/util/java-recipe-proxy.ts +15 -2
  102. package/src/util/reindent.ts +35 -0
  103. package/src/zustand/redux-stores.ts +441 -0
  104. package/src/zustand/redux-to-zustand.ts +660 -0
  105. package/src/zustand/zustand-plan.ts +854 -0
  106. package/dist/react18/remove-unstable-batched-updates.d.ts.map +0 -1
  107. package/dist/react18/remove-unstable-batched-updates.js +0 -170
  108. package/dist/react18/remove-unstable-batched-updates.js.map +0 -1
  109. package/src/react18/remove-unstable-batched-updates.ts +0 -192
@@ -0,0 +1,76 @@
1
+ import { ExecutionContext, ScanningRecipe, SourceFile, TreeVisitor } from "@openrewrite/rewrite";
2
+ import { AddDependencyOptions } from "@openrewrite/rewrite/javascript";
3
+ import { JavaDependencyRecipe } from "../util/java-recipe-proxy";
4
+ import { SliceModule } from "./redux-stores";
5
+ import { SliceSource, SourceFacts } from "./zustand-plan";
6
+ export interface ZustandForecast {
7
+ converting?: () => Promise<ReadonlySet<string>>;
8
+ refused?: Map<string, {
9
+ message: string;
10
+ lock: string;
11
+ }>;
12
+ react?: (root: string) => string | undefined;
13
+ }
14
+ interface PackageFacts {
15
+ react?: string;
16
+ zustand?: string;
17
+ immer?: string;
18
+ }
19
+ interface Scanned {
20
+ sources: Map<string, SourceFacts>;
21
+ modules: Map<string, SliceModule>;
22
+ sliceSources: Map<string, SliceSource>;
23
+ packages: Map<string, PackageFacts>;
24
+ }
25
+ declare abstract class ZustandDependency extends JavaDependencyRecipe {
26
+ private readonly addition;
27
+ private readonly forecast;
28
+ readonly landed: Set<string>;
29
+ private readonly held;
30
+ private readonly locks;
31
+ private readonly unfit;
32
+ protected constructor(addition: AddDependencyOptions, forecast: ZustandForecast);
33
+ initialValue(): number;
34
+ protected scanned(manifest: SourceFile): boolean;
35
+ protected edits(manifest: SourceFile): boolean;
36
+ private fits;
37
+ private lockOf;
38
+ generate(acc: number, ctx: ExecutionContext): Promise<SourceFile[]>;
39
+ }
40
+ export declare class AddZustand extends ZustandDependency {
41
+ readonly name = "org.openrewrite.react.migrate.add-zustand";
42
+ readonly displayName = "Add `zustand` where a Redux store is migrated";
43
+ readonly description = "Adds `zustand` 5 to packages that declare `@reduxjs/toolkit` and resolve React 18 or later, where a Redux store moves to zustand.";
44
+ constructor(forecast?: ZustandForecast);
45
+ }
46
+ export declare class AddZustand4 extends ZustandDependency {
47
+ readonly name = "org.openrewrite.react.migrate.add-zustand-4";
48
+ readonly displayName = "Add `zustand` 4 where a Redux store is migrated on React 16.8 to 17";
49
+ readonly description = "Adds `zustand` 4 to packages that declare `@reduxjs/toolkit` and resolve React 16.8 to 17, where a Redux store moves to zustand.";
50
+ constructor(forecast?: ZustandForecast);
51
+ }
52
+ export declare class AddImmer extends ZustandDependency {
53
+ readonly name = "org.openrewrite.react.migrate.add-immer";
54
+ readonly displayName = "Add `immer` where a Redux store is migrated";
55
+ readonly description = "Adds `immer` 10 to packages that declare `@reduxjs/toolkit` and resolve React 16.8 or later, where a Redux store moves to zustand and its slices' reducers run through `produce`.";
56
+ constructor(forecast?: ZustandForecast);
57
+ }
58
+ export declare class ReduxToZustand extends ScanningRecipe<Scanned> {
59
+ readonly name = "org.openrewrite.react.migrate.redux-to-zustand";
60
+ readonly displayName = "Migrate Redux Toolkit slices to zustand";
61
+ readonly description = "Moves a repository's one Redux Toolkit store to zustand when it is a `configureStore` of `createSlice` reducers with no other option, its sources are JavaScript, and every use of it converts: each slice becomes a zustand store whose action creators keep their names and run the slice's reducers through immer's `produce`, `useSelector` reads of one slice become the slice's zustand hook, `dispatch` and `store.dispatch` of the slices' action creators become calls of them, `store.getState()` reads become the slice store's `getState()`, and the react-redux `Provider` and the store's source are removed. A slice's own `createAsyncThunk`s, whose stages its `extraReducers` handles, keep running on Redux Toolkit and send their actions to the slice's zustand store. Adds `zustand` and `immer` where they are missing. Stores with any other use, such as `connect`, thunks that reach the rest of the store, selectors that build values or several stores, stay in Redux and are recorded for review.";
62
+ private readonly forecast;
63
+ private readonly storeSources;
64
+ private asked?;
65
+ private readonly steps;
66
+ private readonly stores;
67
+ initialValue(): Scanned;
68
+ scanner(scanned: Scanned): Promise<TreeVisitor<any, ExecutionContext>>;
69
+ private plans;
70
+ private planned;
71
+ private dependencies;
72
+ editorWithData(scanned: Scanned): Promise<TreeVisitor<any, ExecutionContext>>;
73
+ recipeList(): Promise<(AddZustand | AddZustand4 | AddImmer)[]>;
74
+ }
75
+ export {};
76
+ //# sourceMappingURL=redux-to-zustand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redux-to-zustand.d.ts","sourceRoot":"","sources":["../../src/zustand/redux-to-zustand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,gBAAgB,EAAqC,cAAc,EAAE,UAAU,EAAsB,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACvL,OAAO,EACH,oBAAoB,EACvB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAAC,oBAAoB,EAAc,MAAM,2BAA2B,CAAC;AAG5E,OAAO,EAA6E,WAAW,EAAiC,MAAM,gBAAgB,CAAC;AACvJ,OAAO,EAEwD,WAAW,EAAE,WAAW,EACtF,MAAM,gBAAgB,CAAC;AAcxB,MAAM,WAAW,eAAe;IAC5B,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAKhD,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAEvD,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAChD;AAKD,UAAU,YAAY;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,OAAO;IACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,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