├── .gitignore ├── .npmignore ├── LICENCE.md ├── README.md ├── package.json ├── pnpm-lock.yaml ├── reactor.svg ├── src ├── ShadowingVisitor.ts ├── cli.ts ├── emitHook.ts ├── hookExtractor.ts ├── idGen.ts ├── test.ts ├── transform.ts └── transforms │ ├── callify.ts │ ├── convertStyles.ts │ ├── currentify.ts │ └── memberify.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | # use pnpm smh 4 | package-lock.json 5 | .idea -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !dist/**/* -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022 Cain Atkinson All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the author nor the names of its contributors may 14 | be used to endorse or promote products derived from this software 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | Reactor 5 |

6 | 7 | [![SWC](https://img.shields.io/badge/transforms%20by-SWC-orange)](https://swc.rs) 8 | [![EmitKit](https://img.shields.io/badge/enhanced%20with-EmitKit-blueviolet)](https://github.com/yellowsink/emitkit) 9 | 10 | --- 11 | 12 | [CLICK HERE FOR SOLIDHACK SUBMISSION DEMO VIDEO](https://youtu.be/Yt-_b3h0SjE) 13 | 14 | A compiler to ease the move from React to SolidJS. 15 | 16 | ## Features 17 | 18 | - Converts the following hooks to Solid equivalents: 19 | * `useState` -> `createSignal` 20 | * `useEffect` -> `createEffect` 21 | - attempting to recreate the "run on every rerender" behaviour 22 | * `useReducer` -> `createSignal` + a function 23 | * `useRef` -> `{ current: }` + a variable 24 | - convert (useRef-returned only) refs in `ref={myRef}` to `ref={myRef.current}`. 25 | 26 | - Converts camel case (`marginRight`) style names to skewer case (`margin-right`) 27 | 28 | ## Example 29 | ```js 30 | export default () => { 31 | const [state, setState] = React.useState(0); 32 | 33 | let [, rerender] = useReducer((a) => ~a, 0); 34 | 35 | Reactor.useEffect(() => console.log(state)); 36 | 37 | const myRef = useRef(); 38 | 39 | return ( 40 | <> 41 |