embedded-react 0.1.0 → 0.1.1
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.
- package/README.md +23 -9
- package/aot/compile.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
# embedded-react
|
|
1
|
+
# embedded-react
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
**React Native for embedded MCUs** — write JSX, run it on a microcontroller. This npm package is the
|
|
4
|
+
**JavaScript layer**: the React-Native-style component API you import, the
|
|
5
|
+
[`react-reconciler`](https://www.npmjs.com/package/react-reconciler) host config that drives the C engine
|
|
6
|
+
at runtime (**Flow A**), and the JSX→C ahead-of-time compiler (**Flow B**, `aot/`).
|
|
6
7
|
|
|
7
8
|
```
|
|
8
9
|
React → react-reconciler → host-config.js → NativeUI.* → er_scene.h (engine)
|
|
9
10
|
```
|
|
10
11
|
|
|
12
|
+
> ### Part of a monorepo
|
|
13
|
+
> This package is just the `bridges/quickjs/js` folder of the **embedded-react** project. The C rendering
|
|
14
|
+
> engine, the hardware backends, the runnable examples, the demo apps, and the simulator all live in the
|
|
15
|
+
> main repo — **https://github.com/TheMasterCoder007/embedded-react**. The engine itself is distributed
|
|
16
|
+
> separately as C source (CMake `FetchContent`, the ESP-IDF Component Registry, and PlatformIO) — see the
|
|
17
|
+
> repos **Install** section. Everything ships at one lockstep version (this package's version == the engine's).
|
|
18
|
+
>
|
|
19
|
+
> The end-to-end app workflow below (bundling, packing, the simulator, running on a board) assumes a **clone
|
|
20
|
+
> of the repo** — the CLIs operate on the repo's `demos/` and `examples/`. A standalone project scaffolder
|
|
21
|
+
> (`create-embedded-react`) that works in your own directory is still to come (see Status). Until then,
|
|
22
|
+
> `npm install embedded-react` gives you the importable component API + the AOT compiler module.
|
|
23
|
+
|
|
11
24
|
## What an app imports
|
|
12
25
|
|
|
13
26
|
The package is the React Native analog — same idiom (hooks from `react`, everything else here):
|
|
@@ -58,10 +71,10 @@ pack-container.mjs bundle + bytecode-compile + bake → dist/app.erpkg c
|
|
|
58
71
|
vitest.config.js unit test config
|
|
59
72
|
```
|
|
60
73
|
|
|
61
|
-
The demo apps themselves live in the top-level **`demos/`** folder (one folder per demo), *not*
|
|
62
|
-
|
|
63
|
-
resolves its `'embedded-react'` import to `src/embedded-react/index.js
|
|
64
|
-
[
|
|
74
|
+
The demo apps themselves live in the repo's top-level **`demos/`** folder (one folder per demo), *not*
|
|
75
|
+
in this package — this package is the library + reconciler + AOT compiler + tests. `build.mjs` bundles a
|
|
76
|
+
selected demo and resolves its `'embedded-react'` import to `src/embedded-react/index.js`. See
|
|
77
|
+
[demos/ in the repo](https://github.com/TheMasterCoder007/embedded-react/tree/master/demos).
|
|
65
78
|
|
|
66
79
|
The host config flattens RN `style` (+ nested arrays) into the flat prop bag, routes `on*`
|
|
67
80
|
handlers to `setEvent`, and uses `shouldSetTextContent` so a flattenable `<Text>` subtree (a string,
|
|
@@ -220,5 +233,6 @@ anything that exercises the reconciler → engine pipeline → a `test/runtime/*
|
|
|
220
233
|
- ✅ **State survives hot reload** — in the simulator, plain `useState` transparently persists across
|
|
221
234
|
saves (a sim-only build transform rewrites it to a persisting helper; press R to reset). On a device
|
|
222
235
|
it's just `useState`, so the same app code runs everywhere. `usePersistentState` is the underlying
|
|
223
|
-
helper, also exported for explicit use. See
|
|
236
|
+
helper, also exported for explicit use. See
|
|
237
|
+
[SIMULATOR.md in the repo](https://github.com/TheMasterCoder007/embedded-react/blob/master/SIMULATOR.md).
|
|
224
238
|
- ⏳ **`create-embedded-react` scaffold** — the project-init CLI is still to come (§4).
|
package/aot/compile.mjs
CHANGED
|
@@ -2969,7 +2969,7 @@ const body = `/*
|
|
|
2969
2969
|
A mismatch fails HERE at compile time (not on-device). Regenerate the app (npm run aot) or align versions. */
|
|
2970
2970
|
_Static_assert(ER_VERSION_MAJOR == ${PKG_MAJOR} && ER_VERSION_MINOR == ${PKG_MINOR},
|
|
2971
2971
|
"embedded-react version mismatch: app.gen.c was generated by ${PKG_VERSION} but the engine header (er_version.h) is a different major.minor. Regenerate the app with 'npm run aot', or align the engine and npm versions.");
|
|
2972
|
-
${usesMath ? '#include <math.h>\n' : ''}${stateBlock ? '\n' + stateBlock : ''}${refDecls ? '\n' + refDecls + '\n' : ''}${effectDeclsBlock ? '\n' + effectDeclsBlock + '\n' : ''}${vectorBlock ? '\n' + vectorBlock + '\n' : ''}${vectorBuilderBlock ? '\n' + vectorBuilderBlock + '\n' : ''}${animDecls ? '\n' + animDecls + '\n' : ''}${handleDecls ? '\n' + handleDecls + '\n' : ''}${timerTableBlock ? '\n' + timerTableBlock + '\n' : ''}${effectFwdDecls ? '\n' + effectFwdDecls + '\n' : ''}${updateBlock ? '\n' + updateBlock + '\n' : ''}${animCbDecls ? '\n' + animCbDecls + '\n' : ''}${handlerDefs ? '\n' + handlerDefs + '\n' : ''}${effectFnDefs ? '\n' + effectFnDefs + '\n' : ''}${animCbDefs ? '\n' + animCbDefs + '\n' : ''}${timerFnDefs ? '\n' + timerFnDefs + '\n' : ''}${out.kbdData ? '\n' + out.kbdData + '\n' : ''}
|
|
2972
|
+
${usesMath ? '#include <math.h>\n/* M_PI is not in ISO C99 <math.h> (only POSIX/GNU); define a fallback so the generated app compiles under -std=c99 / MSVC. */\n#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n' : ''}${stateBlock ? '\n' + stateBlock : ''}${refDecls ? '\n' + refDecls + '\n' : ''}${effectDeclsBlock ? '\n' + effectDeclsBlock + '\n' : ''}${vectorBlock ? '\n' + vectorBlock + '\n' : ''}${vectorBuilderBlock ? '\n' + vectorBuilderBlock + '\n' : ''}${animDecls ? '\n' + animDecls + '\n' : ''}${handleDecls ? '\n' + handleDecls + '\n' : ''}${timerTableBlock ? '\n' + timerTableBlock + '\n' : ''}${effectFwdDecls ? '\n' + effectFwdDecls + '\n' : ''}${updateBlock ? '\n' + updateBlock + '\n' : ''}${animCbDecls ? '\n' + animCbDecls + '\n' : ''}${handlerDefs ? '\n' + handlerDefs + '\n' : ''}${effectFnDefs ? '\n' + effectFnDefs + '\n' : ''}${animCbDefs ? '\n' + animCbDefs + '\n' : ''}${timerFnDefs ? '\n' + timerFnDefs + '\n' : ''}${out.kbdData ? '\n' + out.kbdData + '\n' : ''}
|
|
2973
2973
|
${appTickFn}
|
|
2974
2974
|
|
|
2975
2975
|
void er_app_build(int screen_w, int screen_h)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embedded-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native-style component package + reconciler that drives the embedded-react C engine through the QuickJS NativeUI bridge (Flow A).",
|
|
6
6
|
"license": "Apache-2.0",
|