embedded-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 (62) hide show
  1. package/aot/compile.mjs +173 -8272
  2. package/aot/compiler/animations.mjs +1001 -0
  3. package/aot/compiler/assemble.mjs +922 -0
  4. package/aot/compiler/boot.mjs +441 -0
  5. package/aot/compiler/branch-merge.mjs +319 -0
  6. package/aot/compiler/c/animations.mjs +362 -0
  7. package/aot/compiler/c/boot.mjs +127 -0
  8. package/aot/compiler/c/expressions.mjs +270 -0
  9. package/aot/compiler/c/functions.mjs +268 -0
  10. package/aot/compiler/c/keyboard.mjs +96 -0
  11. package/aot/compiler/c/nodes.mjs +294 -0
  12. package/aot/compiler/c/pan-responder.mjs +136 -0
  13. package/aot/compiler/c/statements.mjs +271 -0
  14. package/aot/compiler/c/text.mjs +83 -0
  15. package/aot/compiler/c/vectors.mjs +381 -0
  16. package/aot/compiler/c-syntax.mjs +127 -0
  17. package/aot/compiler/check.mjs +165 -0
  18. package/aot/compiler/collect.mjs +785 -0
  19. package/aot/compiler/control-flow.mjs +696 -0
  20. package/aot/compiler/diagnostics.mjs +137 -0
  21. package/aot/compiler/elements/activity-indicator.mjs +160 -0
  22. package/aot/compiler/elements/dial.mjs +346 -0
  23. package/aot/compiler/elements/flat-list.mjs +139 -0
  24. package/aot/compiler/elements/image.mjs +151 -0
  25. package/aot/compiler/elements/modal.mjs +158 -0
  26. package/aot/compiler/elements/props.mjs +474 -0
  27. package/aot/compiler/elements/switch.mjs +183 -0
  28. package/aot/compiler/elements/text-input.mjs +171 -0
  29. package/aot/compiler/expressions.mjs +1579 -0
  30. package/aot/compiler/handlers.mjs +1072 -0
  31. package/aot/compiler/ir/animations.mjs +16 -0
  32. package/aot/compiler/ir/app.mjs +16 -0
  33. package/aot/compiler/ir/boot.mjs +16 -0
  34. package/aot/compiler/ir/expressions.mjs +16 -0
  35. package/aot/compiler/ir/functions.mjs +16 -0
  36. package/aot/compiler/ir/keyboard.mjs +16 -0
  37. package/aot/compiler/ir/nodes.mjs +107 -0
  38. package/aot/compiler/ir/pan-responder.mjs +16 -0
  39. package/aot/compiler/ir/reads.mjs +351 -0
  40. package/aot/compiler/ir/source.mjs +16 -0
  41. package/aot/compiler/ir/statements.mjs +16 -0
  42. package/aot/compiler/ir/text.mjs +16 -0
  43. package/aot/compiler/ir/types.mjs +185 -0
  44. package/aot/compiler/ir/vectors.mjs +16 -0
  45. package/aot/compiler/keyboard.mjs +152 -0
  46. package/aot/compiler/lower.mjs +311 -0
  47. package/aot/compiler/nodes.mjs +688 -0
  48. package/aot/compiler/options.mjs +55 -0
  49. package/aot/compiler/out.mjs +94 -0
  50. package/aot/compiler/pan-responder.mjs +354 -0
  51. package/aot/compiler/parse.mjs +300 -0
  52. package/aot/compiler/static-eval.mjs +454 -0
  53. package/aot/compiler/style-text.mjs +807 -0
  54. package/aot/compiler/svg.mjs +1167 -0
  55. package/aot/compiler/types.mjs +16 -0
  56. package/aot/screenshot-smoke.mjs +95 -55
  57. package/aot/style-map.mjs +366 -304
  58. package/cli.mjs +5 -8
  59. package/package.json +14 -6
  60. package/sim/embedded-react.wasm +0 -0
  61. package/src/embedded-react/FlatList.js +4 -4
  62. package/src/props.js +1 -1
package/cli.mjs CHANGED
@@ -381,12 +381,6 @@ function resolveAppComponent(cwd, explicit) {
381
381
 
382
382
  /** Flow B (--aot): compile the App component to C (app.gen.{c,h}) + bake assets, to compile into firmware. */
383
383
  async function buildAot(cwd, explicit, outDir, screen) {
384
- // Bake the target panel size (--screen <WxH>) BEFORE importing the compiler: it reads ER_AOT_SCREEN_W/H at
385
- // module load to fold a responsive app's `screen.width` branch to the one that board renders.
386
- if (screen) {
387
- process.env.ER_AOT_SCREEN_W = screen.w;
388
- process.env.ER_AOT_SCREEN_H = screen.h;
389
- }
390
384
  const {compileSource, bakeSvgArtifacts} = await import('./aot/compile.mjs');
391
385
  const {bakeAssets} = await import('./assets/index.mjs');
392
386
  const {warnMissingGlyphs} = await import('./assets/glyph-coverage.mjs');
@@ -401,9 +395,12 @@ async function buildAot(cwd, explicit, outDir, screen) {
401
395
  const svgArtifacts = await bakeSvgArtifacts(src, appDir);
402
396
  // app.gen.h records WHICH app it came from and a board example guards on that marker, so it must name
403
397
  // the source project — the same ER_AOT_DEMO_watch_2d_face that `npm run aot -- watch-face` produces.
398
+ // The target panel size (--screen <WxH>) folds a responsive app's `screen.width` branch to the one
399
+ // that the board renders. Without it, the compiler falls back to ER_AOT_SCREEN_W/H, then 800x480.
404
400
  result = compileSource(src, projectIdentity(appPath), {
405
401
  filename: appPath,
406
402
  svgArtifacts,
403
+ screen, // null without --screen
407
404
  });
408
405
  } catch (e) {
409
406
  console.error(e && e.aotLoc ? e.message : e?.message || String(e));
@@ -518,7 +515,7 @@ async function build(args) {
518
515
  process.exit(1);
519
516
  }
520
517
  const raw = args[screenIdx + 1];
521
- const m = raw && /^(\d+)x(\d+)$/i.exec(raw);
518
+ const m = raw && /^([1-9]\d*)x([1-9]\d*)$/i.exec(raw);
522
519
  if (!m) {
523
520
  console.error(
524
521
  `--screen expects <width>x<height> (e.g. --screen 240x320), got: ${raw ?? '(nothing)'}\n`,
@@ -526,7 +523,7 @@ async function build(args) {
526
523
  usage();
527
524
  process.exit(1);
528
525
  }
529
- screen = {w: m[1], h: m[2]};
526
+ screen = {width: Number(m[1]), height: Number(m[2])};
530
527
  }
531
528
 
532
529
  // Consume the flag VALUES so they aren't mistaken for the entry (which is a bare, non-`--` token).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embedded-react",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
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",
@@ -63,8 +63,10 @@
63
63
  "scripts": {
64
64
  "build": "node build.mjs",
65
65
  "pack": "node pack-container.mjs",
66
- "aot": "node aot/compile.mjs",
66
+ "aot": "node aot/compile.mts",
67
67
  "aot:smoke": "node aot/screenshot-smoke.mjs",
68
+ "aot:baseline": "node test/aot-same/aot-same.mjs baseline",
69
+ "aot:same": "node test/aot-same/aot-same.mjs check",
68
70
  "parity": "node parity.mjs",
69
71
  "version:sync": "node ../../../tools/sync-version.mjs",
70
72
  "version:check": "node ../../../tools/sync-version.mjs --check",
@@ -78,12 +80,14 @@
78
80
  "test:runtime": "node test/runtime/run.mjs",
79
81
  "test:bytecode": "node test/runtime/run.mjs --bytecode",
80
82
  "test:split": "node test/runtime/split-roundtrip.mjs",
81
- "typecheck": "tsc -p tsconfig.types.json",
82
- "format": "cd ../../.. && prettier --write \"**/*.{js,jsx,mjs,cjs}\"",
83
- "format:check": "cd ../../.. && prettier --check \"**/*.{js,jsx,mjs,cjs}\""
83
+ "typecheck": "tsc -p tsconfig.types.json && tsc -p tsconfig.aot.json",
84
+ "format": "cd ../../.. && prettier --write \"**/*.{js,jsx,mjs,cjs,mts}\"",
85
+ "format:check": "cd ../../.. && prettier --check \"**/*.{js,jsx,mjs,cjs,mts}\""
84
86
  },
85
87
  "dependencies": {
88
+ "@babel/code-frame": "^7.29.7",
86
89
  "@babel/core": "^7.29.7",
90
+ "@babel/parser": "^7.29.9",
87
91
  "@babel/plugin-syntax-jsx": "^7.29.7",
88
92
  "@resvg/resvg-js": "^2.6.2",
89
93
  "esbuild": "^0.28.1",
@@ -94,10 +98,14 @@
94
98
  "svgson": "^5.3.1"
95
99
  },
96
100
  "devDependencies": {
101
+ "@babel/types": "^7.29.8",
102
+ "@types/babel__code-frame": "^7.27.0",
103
+ "@types/babel__core": "^7.20.5",
104
+ "@types/node": "^22.20.4",
97
105
  "@types/react": "18.3.1",
98
106
  "prettier": "^3.4.2",
99
107
  "typescript": "^5.5.0",
100
- "vitest": "^3.2.4"
108
+ "vitest": "^4.1.11"
101
109
  },
102
110
  "optionalDependencies": {
103
111
  "serialport": "^12.0.0"
Binary file
@@ -28,10 +28,10 @@
28
28
  // data.length x (nodes per row) slots out of the fixed ERUI_MAX_NODES pool. See "FlatList is a
29
29
  // ScrollView alias" in the top-level README for the limits and when to reach for something else.
30
30
  //
31
- // This mirrors the AOT's emitFlatList (bridges/quickjs/js/aot/compile.mjs), which performs the same
32
- // rewrite at compile time. The two flows accept the SAME four props on purpose — a list that renders
33
- // in the simulator must also compile for the device, so anything Flow B rejects is warned about here
34
- // rather than silently forwarded.
31
+ // This mirrors the AOT's emitFlatList (bridges/quickjs/js/aot/compiler/elements/flat-list.mts),
32
+ // which performs the same rewrite at compile time. The two flows accept the SAME four props on
33
+ // purpose — a list that renders in the simulator must also compile for the device, so anything
34
+ // Flow B rejects is warned about here rather than silently forwarded.
35
35
  import {createElement} from 'react';
36
36
  import {ScrollView} from './components.js';
37
37
  import {pushKeyedChild} from './list-child.js';
package/src/props.js CHANGED
@@ -186,7 +186,7 @@ export function buildProps(type, props, flatStyle) {
186
186
  }
187
187
  // <Svg> takes width/height as DIRECT props (the react-native-svg convention) — the engine sizes the
188
188
  // vector node from them. Fold them into the resolved style (an explicit style width/height still wins)
189
- // so Flow A matches the Flow B AOT, which reads svg.props.width/height directly (compile.mjs emitSvgBox).
189
+ // so Flow A matches the Flow B AOT, which reads svg.props.width/height directly (aot/compiler/svg.mts emitSvgBox).
190
190
  if (type === 'Svg') {
191
191
  if (flat.width === undefined && props.width !== undefined)
192
192
  flat.width = props.width;