├── src ├── main.ts ├── style.css └── app.tsx ├── vite.config.ts ├── index.html ├── .gitignore ├── package.json ├── tsconfig.json ├── .github └── workflows │ └── pages.yml └── renderer └── __reactive_renderer.ts /src/main.ts: -------------------------------------------------------------------------------- 1 | import {main} from "./app.tsx"; 2 | main(); -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import path from 'path'; 3 | 4 | export default defineConfig({ 5 | esbuild: { 6 | // jsxInject: `import {__jsx} from '@renderer/renderer';`, 7 | }, 8 | resolve: { 9 | alias: { 10 | 'renderer': path.resolve(__dirname, './renderer/') 11 | } 12 | } 13 | }) -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |;
8 | container.innerHTML = hljs.highlight(el.trim(), { language: lang }).value;
9 | container.prepend(36 | You shouldn't need to learn a whole framework to have HTML that is 37 | synced with your code. 38 |
39 |40 | This library attempts to match the syntax and experience of writing 41 | plain vanilla JS. No need for functions to set values, access them like 42 | you would any other variable :) 43 |
44 |Create and change a reactive value using the “$” syntax.
49 | {render_code("html", `71 | It's easy to have complex expressions that will be re-evaluated 72 | whenever one of the used values is updated. 73 |
74 |75 | (Note: Currently this may only work for variables that are accessed on the initial evaluation, so they may not work if they are behind an if statement.) 76 |
77 |You can work around this by simply referencing any variables at the start of the function to make sure they are included.
78 | {render_code( 79 | "jsx", 80 | `app = $_(() => ($.worldEmoji == "🌏" ? "Yes!" : "nope :("))` 81 | )} 82 |93 | Variables can reference other variables and then be set to another 94 | value without affecting the original. This is achieved by simply using 95 | the same function used to create re-evaluated expressions. 96 |
97 | {render_code( 98 | "jsx", 99 | ` 100 | $.reflected = $_(() => $.worldEmoji + "... copycat"); 101 | 102 | app =125 | If a reactive variable does not exist when you try to access it, it 126 | will actually create a placeholder variable in case it gets set in the 127 | future. 128 |
129 | {render_code( 130 | "jsx", 131 | ` 132 | app =And of course, arrays of JSX function how you'd expect.
155 | {render_code( 156 | "jsx", 157 | ` 158 | $.arr = [ 159 | fireEmoji: {$.fireEmoji} | , 160 | worldEmoji: {$.worldEmoji}, 161 | ]; 162 | 163 | app = {$.arr} 164 | ` 165 | )} 166 |It even supports mutations!
167 | {render_code("jsx", ` 168 | 169 | 170 | `)} 171 | 172 |