embedded-react 0.19.0 → 0.20.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 (116) hide show
  1. package/README.md +7 -3
  2. package/aot/compile.mjs +178 -58
  3. package/aot/compiler/animations.mjs +290 -281
  4. package/aot/compiler/boot.mjs +70 -33
  5. package/aot/compiler/branch-merge.mjs +4 -3
  6. package/aot/compiler/check.mjs +9 -9
  7. package/aot/compiler/collect.mjs +324 -205
  8. package/aot/compiler/control-flow.mjs +209 -197
  9. package/aot/compiler/diagnostics.mjs +22 -25
  10. package/aot/compiler/elements/activity-indicator.mjs +25 -24
  11. package/aot/compiler/elements/dial.mjs +91 -77
  12. package/aot/compiler/elements/flat-list.mjs +24 -22
  13. package/aot/compiler/elements/image.mjs +51 -50
  14. package/aot/compiler/elements/modal.mjs +31 -30
  15. package/aot/compiler/elements/props.mjs +23 -23
  16. package/aot/compiler/elements/switch.mjs +42 -34
  17. package/aot/compiler/elements/text-input.mjs +34 -32
  18. package/aot/compiler/expressions.mjs +372 -333
  19. package/aot/compiler/handlers.mjs +473 -387
  20. package/aot/compiler/ir/functions.mjs +11 -1
  21. package/aot/compiler/ir/nodes.mjs +4 -4
  22. package/aot/compiler/ir/reads.mjs +19 -19
  23. package/aot/compiler/ir/types.mjs +14 -14
  24. package/aot/compiler/ir/vectors.mjs +5 -1
  25. package/aot/compiler/keyboard.mjs +17 -7
  26. package/aot/compiler/lower.mjs +77 -80
  27. package/aot/compiler/nodes.mjs +169 -152
  28. package/aot/compiler/options.mjs +35 -30
  29. package/aot/compiler/out.mjs +18 -22
  30. package/aot/compiler/package/animations.mjs +669 -0
  31. package/aot/compiler/package/arena.mjs +252 -0
  32. package/aot/compiler/package/assemble.mjs +177 -0
  33. package/aot/compiler/package/bytecode.mjs +286 -0
  34. package/aot/compiler/package/checks.mjs +1022 -0
  35. package/aot/compiler/package/codegen.mjs +1329 -0
  36. package/aot/compiler/package/enums.mjs +138 -0
  37. package/aot/compiler/package/format.mjs +760 -0
  38. package/aot/compiler/package/layouts.mjs +136 -0
  39. package/aot/compiler/package/lower.mjs +1606 -0
  40. package/aot/compiler/package/props.mjs +118 -0
  41. package/aot/compiler/package/tables.mjs +103 -0
  42. package/aot/compiler/package/vectors.mjs +502 -0
  43. package/aot/compiler/package/writer.mjs +664 -0
  44. package/aot/compiler/pan-responder.mjs +69 -61
  45. package/aot/compiler/parse.mjs +21 -21
  46. package/aot/compiler/static-eval.mjs +25 -23
  47. package/aot/compiler/style-text.mjs +161 -172
  48. package/aot/compiler/svg.mjs +477 -251
  49. package/aot/screenshot-smoke.mjs +54 -40
  50. package/aot/style-map.mjs +102 -90
  51. package/assets/bake-font.mjs +123 -77
  52. package/assets/bake-image.mjs +39 -22
  53. package/assets/bake-svg.mjs +361 -262
  54. package/assets/build-builtin-font.mjs +11 -7
  55. package/assets/emit-c.mjs +77 -58
  56. package/assets/emit-container.mjs +123 -37
  57. package/assets/emit-pack.mjs +77 -67
  58. package/assets/font-config.mjs +9 -6
  59. package/assets/font-sizes.mjs +163 -123
  60. package/assets/glyph-coverage.mjs +74 -54
  61. package/assets/index.mjs +31 -9
  62. package/assets/rasterize.mjs +126 -99
  63. package/assets/svg-loader.mjs +8 -8
  64. package/build.mjs +14 -12
  65. package/cli.mjs +359 -172
  66. package/compile-bin.mjs +3 -3
  67. package/flash.mjs +537 -0
  68. package/hotreload/dev-device.mjs +90 -33
  69. package/hotreload/pack-app.mjs +55 -43
  70. package/hotreload/pack-split.mjs +46 -37
  71. package/hotreload/package-transfer.mjs +175 -0
  72. package/hotreload/protocol.mjs +50 -37
  73. package/hotreload/uploader.mjs +38 -27
  74. package/hotreload/watch-tree.mjs +19 -19
  75. package/pack-container.mjs +28 -20
  76. package/package.json +7 -8
  77. package/persist-transform.mjs +34 -28
  78. package/qjsc-wasm.mjs +25 -14
  79. package/sim/embedded-react.cjs +1 -1
  80. package/sim/embedded-react.js +1 -1
  81. package/sim/embedded-react.wasm +0 -0
  82. package/sim/index.html +94 -85
  83. package/sim-server.mjs +101 -82
  84. package/src/embedded-react/Animated.js +24 -24
  85. package/src/embedded-react/Easing.js +1 -1
  86. package/src/embedded-react/FlatList.js +3 -3
  87. package/src/embedded-react/LayoutAnimation.js +8 -5
  88. package/src/embedded-react/PanResponder.js +75 -71
  89. package/src/embedded-react/Pressable.js +2 -8
  90. package/src/embedded-react/SectionList.js +6 -6
  91. package/src/embedded-react/StyleSheet.js +4 -3
  92. package/src/embedded-react/TouchableOpacity.js +13 -8
  93. package/src/embedded-react/index.d.ts +5 -5
  94. package/src/embedded-react/layout-anim-config.js +10 -4
  95. package/src/embedded-react/list-child.js +5 -5
  96. package/src/embedded-react/named-colors.js +1 -1
  97. package/src/embedded-react/split-style.js +11 -11
  98. package/src/embedded-react/svg-ops.js +760 -593
  99. package/src/embedded-react/useHostValue.js +3 -3
  100. package/src/embedded-react/usePersistentState.js +6 -6
  101. package/src/embedded-react/warn-props.js +1 -1
  102. package/src/host-config.js +60 -53
  103. package/src/props.js +49 -41
  104. package/src/renderer.js +7 -4
  105. package/aot/compiler/assemble.mjs +0 -944
  106. package/aot/compiler/c/animations.mjs +0 -436
  107. package/aot/compiler/c/boot.mjs +0 -127
  108. package/aot/compiler/c/expressions.mjs +0 -270
  109. package/aot/compiler/c/functions.mjs +0 -268
  110. package/aot/compiler/c/keyboard.mjs +0 -96
  111. package/aot/compiler/c/nodes.mjs +0 -303
  112. package/aot/compiler/c/pan-responder.mjs +0 -136
  113. package/aot/compiler/c/statements.mjs +0 -319
  114. package/aot/compiler/c/text.mjs +0 -83
  115. package/aot/compiler/c/vectors.mjs +0 -381
  116. package/aot/compiler/c-syntax.mjs +0 -127
@@ -56,7 +56,7 @@ export const constantText = (text) => text.parts.every(part => part.kind === 'li
56
56
  ? text.parts.map(part => part.text).join('')
57
57
  : null;
58
58
  /**
59
- * Refuses a constant string too long for the engine buffer it is copied into, which C would cut short.
59
+ * Refuses a constant string too long for the engine buffer it is copied into, which would cut it short.
60
60
  *
61
61
  * @param text The string, or null for one built at run time (checked when it is written).
62
62
  * @param limit The er_scene.h define that sizes the buffer.
@@ -87,35 +87,35 @@ export function aotError(message, hint) {
87
87
  return error;
88
88
  }
89
89
  /**
90
- * Pins an AOT error that has no location yet to `loc`, as a located emitter does.
90
+ * Pins an AOT error that has no location yet to `location`, as a located emitter does.
91
91
  *
92
92
  * @param error The thrown value.
93
- * @param loc Where the construct being lowered is, if it is anywhere.
93
+ * @param location Where the construct being lowered is, if it is anywhere.
94
94
  */
95
- export function locateError(error, loc) {
95
+ export function locateError(error, location) {
96
96
  if (error &&
97
97
  typeof error.message === 'string' &&
98
98
  error.message.startsWith('AOT:') &&
99
99
  !error.aotLoc &&
100
- loc) {
101
- error.aotLoc = loc;
100
+ location) {
101
+ error.aotLoc = location;
102
102
  }
103
103
  }
104
104
  /**
105
105
  * Wraps an emit function so a thrown AOT error (without a location yet) is tagged with the current node's
106
106
  * loc. Wrapped emitters nest, so the deepest node that failed is the one reported. The expression, node, and
107
- * handler emitters are all wrapped, and compileSource formats the result with formatAotError. While it runs,
107
+ * handler emitters are all wrapped, and compilePackage formats the result with formatAotError. While it runs,
108
108
  * currentLoc() reports the same location, for a check recorded now and run later.
109
109
  *
110
- * @param fn The emit function; its first parameter is the node it lowers.
110
+ * @param lower The emit function; its first parameter is the node it lowers.
111
111
  *
112
112
  * @returns The same function, with its AOT errors located.
113
113
  */
114
- export function withLoc(fn) {
114
+ export function withLoc(lower) {
115
115
  return function (node, ...rest) {
116
116
  loweringAt.push(node?.loc?.start);
117
117
  try {
118
- return fn(node, ...rest);
118
+ return lower(node, ...rest);
119
119
  }
120
120
  catch (error) {
121
121
  locateError(error, node?.loc?.start); // babel loc: { line (1-based), column (0-based) }
@@ -128,38 +128,35 @@ export function withLoc(fn) {
128
128
  }
129
129
  /**
130
130
  * Rebuilds an AOT error with `file:line:col`, a code-frame, any hint, and the screen size this build folded
131
- * its layout at (from the resolved `opts`), all folded into the message, for compileSource to throw.
131
+ * its layout at (from the resolved `options`), all folded into the message, for compilePackage to throw.
132
132
  *
133
- * @param error The error compileSource caught.
134
- * @param src The app's source, for the code-frame.
133
+ * @param error The error compilePackage caught.
134
+ * @param source The app's source, for the code-frame.
135
135
  * @param filename The source's path, as the message should show it.
136
- * @param opts The compile's resolved options, for the screen footer.
136
+ * @param options The compile's resolved options, for the screen footer.
137
137
  *
138
138
  * @returns The located error; `error` itself when it has no location.
139
139
  */
140
- export function formatAotError(error, src, filename, opts) {
140
+ export function formatAotError(error, source, filename, options) {
141
141
  if (!error || !error.aotLoc)
142
142
  return error; // nothing to locate — leave the bare message
143
143
  // Render the code-frame around the error's location, and the hint when there is one.
144
144
  const { line, column } = error.aotLoc;
145
- const frameLoc = { start: { line, column: column + 1 } }; // code-frame columns are 1-based
145
+ const frameLocation = { start: { line, column: column + 1 } }; // code-frame columns are 1-based
146
146
  let codeFrame = '';
147
147
  try {
148
- codeFrame = codeFrameColumns(src, frameLoc, { highlightCode: false });
148
+ codeFrame = codeFrameColumns(source, frameLocation, { highlightCode: false });
149
149
  }
150
150
  catch {
151
151
  /* code-frame is best-effort */
152
152
  }
153
153
  // Name the screen size the layout was folded at: it picks which branch of a responsive app the error came from.
154
154
  const hint = error.aotHint ? `\n\nhint: ${error.aotHint}` : '';
155
- const size = `${opts.screen.width}×${opts.screen.height}`;
156
- const screen = opts.screenFrom === 'option'
157
- ? `\n\nscreen: ${size}.`
158
- : opts.screenFrom === 'env'
159
- ? `\n\nscreen: ${size} (from ER_AOT_SCREEN_W/H).`
160
- : `\n\nscreen: ${size} — ER_AOT_SCREEN_W/H did not supply both dimensions, so the ` +
161
- `default filled in. A responsive app picks its layout from \`screen\`, so this may be compiling a ` +
162
- `branch meant for another board.`;
155
+ const size = `${options.screen.width}×${options.screen.height}`;
156
+ const screen = options.screenFrom === 'search'
157
+ ? `\n\nscreen: this is the layout a ${size} panel picks. Every layout has to compile; name the panels with ` +
158
+ `--screen to drop the others.`
159
+ : `\n\nscreen: ${size}.`;
163
160
  // Build the located error, keeping the location and hint for any caller that inspects them.
164
161
  const located = new Error(`${error.message}\n at ${filename}:${line}:${column + 1}\n\n${codeFrame}${hint}${screen}`);
165
162
  located.aotLoc = error.aotLoc;
@@ -16,8 +16,8 @@
16
16
  /*----------------------------------------------------------------------------------------------------------------------
17
17
  - Imports
18
18
  ---------------------------------------------------------------------------------------------------------------------*/
19
- import { colorLiteral } from '../../style-map.mjs';
20
- import { aotError } from '../diagnostics.mjs';
19
+ import { parseColorValue } from '../../style-map.mjs';
20
+ import { aotError, currentLoc } from '../diagnostics.mjs';
21
21
  import { evalStatic } from '../static-eval.mjs';
22
22
  import { lowerExpr } from '../expressions.mjs';
23
23
  import { attrExpr, lowerColorValue, styleWrites, collectStyleAssigns, } from '../style-text.mjs';
@@ -45,48 +45,48 @@ const SIZE_LARGE = 36;
45
45
  *
46
46
  * @param element The JSX element.
47
47
  * @param scope The current scope.
48
- * @param out The current output.
49
- * @param env The current environment.
48
+ * @param output The current output.
49
+ * @param environment The current environment.
50
50
  *
51
51
  * @returns The name of the node variable (Node ID).
52
52
  */
53
- export function emitActivityIndicator(element, scope, out, env) {
53
+ export function emitActivityIndicator(element, scope, output, environment) {
54
54
  // get node id
55
- const nodeId = `n${out.allocateNodeId()}`;
55
+ const nodeId = `n${output.allocateNodeId()}`;
56
56
  // collect style assignments
57
- const { staticAssigns, dynAssigns, binds } = collectStyleAssigns(element.openingElement, scope, env, elementSpec('ActivityIndicator'));
58
- const hasField = (field) => styleWrites(staticAssigns, dynAssigns, field);
57
+ const { staticAssigns, dynamicAssigns, binds } = collectStyleAssigns(element.openingElement, scope, environment, elementSpec('ActivityIndicator'));
58
+ const hasField = (field) => styleWrites(staticAssigns, dynamicAssigns, field);
59
59
  // `style.color` tints the spinner, as in Flow A; a `color` prop written after it wins.
60
- for (const assign of [...staticAssigns, ...dynAssigns]) {
60
+ for (const assign of [...staticAssigns, ...dynamicAssigns]) {
61
61
  if (assign.field === 'color') {
62
62
  assign.field = 'indicator_color';
63
63
  }
64
64
  }
65
65
  // process element attributes
66
66
  let size = SIZE_LARGE;
67
- for (const attr of element.openingElement.attributes) {
67
+ for (const attribute of element.openingElement.attributes) {
68
68
  // Ensure all props are explicit named attributes.
69
69
  // Spread props cannot be analyzed statically
70
- if (attr.type !== 'JSXAttribute') {
70
+ if (attribute.type !== 'JSXAttribute') {
71
71
  throw aotError('AOT: spread props on <ActivityIndicator> are not supported');
72
72
  }
73
73
  // skip non-props
74
- const name = attr.name.name;
74
+ const name = attribute.name.name;
75
75
  if (name === 'style' || name === 'ref' || name === 'key')
76
76
  continue;
77
77
  // process props
78
- const node = attrExpr(attr);
78
+ const node = attrExpr(attribute);
79
79
  if (name === 'color') {
80
80
  try {
81
81
  staticAssigns.push({
82
82
  field: 'indicator_color',
83
- expr: colorLiteral(String(evalStatic(node, scope))),
83
+ value: parseColorValue(String(evalStatic(node, scope))),
84
84
  });
85
85
  }
86
86
  catch {
87
- dynAssigns.push({
87
+ dynamicAssigns.push({
88
88
  field: 'indicator_color',
89
- value: lowerColorValue(node, env),
89
+ value: lowerColorValue(node, environment),
90
90
  });
91
91
  }
92
92
  }
@@ -103,22 +103,22 @@ export function emitActivityIndicator(element, scope, out, env) {
103
103
  ? Math.round(sizeValue)
104
104
  : NaN;
105
105
  if (Number.isNaN(size)) {
106
- throw at(aotError(`AOT: <ActivityIndicator size> must be 'small', 'large' or a number of pixels (got ${JSON.stringify(sizeValue) ?? String(sizeValue)})`), attr);
106
+ throw at(aotError(`AOT: <ActivityIndicator size> must be 'small', 'large' or a number of pixels (got ${JSON.stringify(sizeValue) ?? String(sizeValue)})`), attribute);
107
107
  }
108
108
  }
109
109
  else if (name === 'animating') {
110
110
  try {
111
111
  staticAssigns.push({
112
112
  field: 'animating',
113
- expr: evalStatic(node, scope) ? '1' : '0',
113
+ value: evalStatic(node, scope) ? 1 : 0,
114
114
  });
115
115
  }
116
116
  catch {
117
- dynAssigns.push({
117
+ dynamicAssigns.push({
118
118
  field: 'animating',
119
119
  value: {
120
120
  kind: 'flag',
121
- test: lowerExpr(node, env),
121
+ test: lowerExpr(node, environment),
122
122
  truthiness: 'value',
123
123
  negate: false,
124
124
  whenTrue: 1,
@@ -132,16 +132,17 @@ export function emitActivityIndicator(element, scope, out, env) {
132
132
  }
133
133
  // default size: large unless style sets width/height
134
134
  if (!hasField('width')) {
135
- staticAssigns.push({ field: 'width', expr: String(size) });
135
+ staticAssigns.push({ field: 'width', value: size });
136
136
  }
137
137
  if (!hasField('height')) {
138
- staticAssigns.push({ field: 'height', expr: String(size) });
138
+ staticAssigns.push({ field: 'height', value: size });
139
139
  }
140
140
  const node = {
141
141
  id: nodeId,
142
+ location: currentLoc(),
142
143
  type: 'ER_NODE_ACTIVITY_INDICATOR',
143
144
  constantProps: staticAssigns,
144
- stateProps: dynAssigns,
145
+ stateProps: dynamicAssigns,
145
146
  placeholder: null,
146
147
  text: null,
147
148
  image: null,
@@ -149,7 +150,7 @@ export function emitActivityIndicator(element, scope, out, env) {
149
150
  children: [],
150
151
  wiring: [
151
152
  ...binds.map((bind, index) => ({ kind: 'bind', bind, index })),
152
- ...lowerRefBinds(element.openingElement, env).map(slot => ({
153
+ ...lowerRefBinds(element.openingElement, environment).map(slot => ({
153
154
  kind: 'ref',
154
155
  slot,
155
156
  })),
@@ -17,10 +17,9 @@
17
17
  - Imports
18
18
  ---------------------------------------------------------------------------------------------------------------------*/
19
19
  import { check, checkNumber, DIAL_MAX_GRADIENT_STOPS } from '../check.mjs';
20
- import { colorLiteral } from '../../style-map.mjs';
21
- import { aotError } from '../diagnostics.mjs';
20
+ import { floatConstant, parseColorValue } from '../../style-map.mjs';
21
+ import { aotError, currentLoc } from '../diagnostics.mjs';
22
22
  import { evalStaticOrThrow, evalStatic } from '../static-eval.mjs';
23
- import { floatLit } from '../c-syntax.mjs';
24
23
  import { lowerExpr } from '../expressions.mjs';
25
24
  import { isFn } from '../collect.mjs';
26
25
  import { attrExpr, lowerColorValue, lowerEnumValue, styleWrites, collectStyleAssigns, } from '../style-text.mjs';
@@ -29,6 +28,7 @@ import { emitChildren } from '../control-flow.mjs';
29
28
  import { checkInterpolations, lowerRefBinds } from '../nodes.mjs';
30
29
  import { at, elementSpec } from './props.mjs';
31
30
  import { imageNameFromSource } from './image.mjs';
31
+ import { FLOAT } from '../ir/types.mjs';
32
32
  /*----------------------------------------------------------------------------------------------------------------------
33
33
  - Constants
34
34
  ---------------------------------------------------------------------------------------------------------------------*/
@@ -73,6 +73,8 @@ const DIAL_ENUM_PROPS = {
73
73
  },
74
74
  },
75
75
  };
76
+ /** A <Dial>'s width and height when its style sets neither. */
77
+ const DEFAULT_SIZE = 120;
76
78
  /*----------------------------------------------------------------------------------------------------------------------
77
79
  - Implementation
78
80
  ---------------------------------------------------------------------------------------------------------------------*/
@@ -81,102 +83,102 @@ const DIAL_ENUM_PROPS = {
81
83
  * indicatorGradient bandColor cap segments gapAngle knob knobSize knobColor knobBorderColor
82
84
  * knobBorderWidth knobImage adjustable onChange={(v) => setV(v)} style=… />
83
85
  * → ER_NODE_ARC, the engine's native arc widget. Numbers and colors are static literals or state-driven
84
- * (recomputed in app_update); `value` may also be a useAnimatedValue handle, which binds ER_PROP_ARC_VALUE
85
- * natively so a ramp costs no app_update at all. onChange lowers to ER_EVENT_VALUE_CHANGE with its param
86
+ * (recomputed in the update); `value` may also be a useAnimatedValue handle, which binds ER_PROP_ARC_VALUE
87
+ * natively so a ramp costs no update at all. onChange lowers to ER_EVENT_VALUE_CHANGE with its param
86
88
  * bound to data->value (the quantized value the built-in drag produced). Default 120x120 box.
87
89
  *
88
90
  * @param element The <Dial>.
89
91
  * @param scope Compile-time constants in reach.
90
- * @param out Everything emitted so far.
91
- * @param env The expression environment.
92
+ * @param output Everything emitted so far.
93
+ * @param environment The expression environment.
92
94
  * @param state The component's state table.
93
95
  *
94
96
  * @returns The node's variable.
95
97
  */
96
- export function emitDial(element, scope, out, env, state) {
98
+ export function emitDial(element, scope, output, environment, state) {
97
99
  // get node id
98
- const nodeID = `n${out.allocateNodeId()}`;
100
+ const nodeID = `n${output.allocateNodeId()}`;
99
101
  // collect style assignments
100
- const { staticAssigns, dynAssigns, binds } = collectStyleAssigns(element.openingElement, scope, env, elementSpec('Dial'));
101
- const hasField = (field) => styleWrites(staticAssigns, dynAssigns, field);
102
+ const { staticAssigns, dynamicAssigns, binds } = collectStyleAssigns(element.openingElement, scope, environment, elementSpec('Dial'));
103
+ const hasField = (field) => styleWrites(staticAssigns, dynamicAssigns, field);
102
104
  if (!hasField('width')) {
103
- staticAssigns.push({ field: 'width', expr: '120' });
105
+ staticAssigns.push({ field: 'width', value: DEFAULT_SIZE });
104
106
  }
105
107
  if (!hasField('height')) {
106
- staticAssigns.push({ field: 'height', expr: '120' });
108
+ staticAssigns.push({ field: 'height', value: DEFAULT_SIZE });
107
109
  }
108
- // Fold numeric props when possible; otherwise emit runtime assignments for app_update().
109
- const numeric = (field, node, isFloat, attr) => {
110
+ // Fold numeric props when possible; otherwise emit runtime assignments for the update.
111
+ const numeric = (field, node, isFloat, attribute) => {
110
112
  let number;
111
113
  try {
112
114
  number = evalStatic(node, scope, 'strict');
113
115
  }
114
116
  catch {
115
- const value = lowerExpr(node, env);
116
- dynAssigns.push({
117
+ const value = lowerExpr(node, environment);
118
+ dynamicAssigns.push({
117
119
  field,
118
120
  value: isFloat ? { kind: 'float', value } : { kind: 'dimension', value },
119
121
  });
120
122
  return;
121
123
  }
122
124
  if (typeof number !== 'number') {
123
- throw at(aotError(`AOT: <Dial ${attr.name.name}> must be a number (got ${JSON.stringify(number) ?? String(number)})`), attr);
125
+ throw at(aotError(`AOT: <Dial ${attribute.name.name}> must be a number (got ${JSON.stringify(number) ?? String(number)})`), attribute);
124
126
  }
125
- // floatLit checks a float field itself; an int field needs the same check before it is rounded.
127
+ // floatConstant checks a float field itself; an int field needs the same check before it is rounded.
126
128
  if (!isFloat) {
127
129
  checkNumber(number);
128
130
  }
129
131
  staticAssigns.push({
130
132
  field,
131
- expr: isFloat ? floatLit(number) : String(Math.round(number)),
133
+ value: isFloat ? floatConstant(number) : Math.round(number),
132
134
  });
133
135
  };
134
- // Fold static colors now; emit dynamic color expressions for app_update().
135
- const colour = (field, node, attr) => {
136
+ // Fold static colors now; emit dynamic color expressions for the update.
137
+ const colour = (field, node, attribute) => {
136
138
  let color;
137
139
  try {
138
140
  color = evalStatic(node, scope, 'strict');
139
141
  }
140
142
  catch {
141
- dynAssigns.push({ field, value: lowerColorValue(node, env) });
143
+ dynamicAssigns.push({ field, value: lowerColorValue(node, environment) });
142
144
  return;
143
145
  }
144
146
  if (typeof color !== 'string') {
145
- throw at(aotError(`AOT: <Dial ${attr.name.name}> must be a color string (got ${JSON.stringify(color) ?? String(color)})`), attr);
147
+ throw at(aotError(`AOT: <Dial ${attribute.name.name}> must be a color string (got ${JSON.stringify(color) ?? String(color)})`), attribute);
146
148
  }
147
- staticAssigns.push({ field, expr: colorLiteral(color) });
149
+ staticAssigns.push({ field, value: parseColorValue(color) });
148
150
  };
149
151
  // Process <Dial> props, splitting them into static props, dynamic updates, binds, assets, and handlers.
150
- let onChangeFn = null;
152
+ let onChangeFunction = null;
151
153
  let knobImage = null; // static asset name
152
- for (const attr of element.openingElement.attributes) {
154
+ for (const attribute of element.openingElement.attributes) {
153
155
  // Ensure all props are explicit named attributes.
154
156
  // Spread props cannot be analyzed statically
155
- if (attr.type !== 'JSXAttribute') {
157
+ if (attribute.type !== 'JSXAttribute') {
156
158
  throw aotError('AOT: spread props on <Dial> are not supported');
157
159
  }
158
160
  // skip non-props
159
- const name = attr.name.name;
161
+ const name = attribute.name.name;
160
162
  if (name === 'style' || name === 'ref' || name === 'key')
161
163
  continue;
162
164
  // process props
163
- const node = attrExpr(attr);
165
+ const node = attrExpr(attribute);
164
166
  if ((name === 'value' || name === 'valueStart') &&
165
167
  node?.type === 'Identifier' &&
166
- env.animations?.has(node.name)) {
168
+ environment.animations?.has(node.name)) {
167
169
  binds.push({
168
- cVar: env.animations.get(node.name).cVar,
170
+ slotName: environment.animations.get(node.name).slotName,
169
171
  prop: name === 'value' ? 'ER_PROP_ARC_VALUE' : 'ER_PROP_ARC_VALUE_START',
170
172
  });
171
173
  }
172
174
  else if (DIAL_FLOAT_PROPS[name]) {
173
- numeric(DIAL_FLOAT_PROPS[name], node, true, attr);
175
+ numeric(DIAL_FLOAT_PROPS[name], node, true, attribute);
174
176
  }
175
177
  else if (DIAL_INT_PROPS[name]) {
176
- numeric(DIAL_INT_PROPS[name], node, false, attr);
178
+ numeric(DIAL_INT_PROPS[name], node, false, attribute);
177
179
  }
178
180
  else if (DIAL_COLOR_PROPS[name]) {
179
- colour(DIAL_COLOR_PROPS[name], node, attr);
181
+ colour(DIAL_COLOR_PROPS[name], node, attribute);
180
182
  }
181
183
  else if (DIAL_ENUM_PROPS[name]) {
182
184
  const { field, table } = DIAL_ENUM_PROPS[name];
@@ -191,12 +193,15 @@ export function emitDial(element, scope, out, env, state) {
191
193
  if (!table[token]) {
192
194
  throw aotError(`AOT: unsupported <Dial ${name}> "${token}"`, `${name} must be one of: ${Object.keys(table).join(' / ')}.`);
193
195
  }
194
- staticAssigns.push({ field, expr: table[token] });
196
+ staticAssigns.push({ field, value: table[token] });
195
197
  }
196
198
  else {
197
- dynAssigns.push({
199
+ dynamicAssigns.push({
198
200
  field,
199
- value: { kind: 'byte', value: lowerEnumValue(node, table, env) },
201
+ value: {
202
+ kind: 'byte',
203
+ value: lowerEnumValue(node, table, environment),
204
+ },
200
205
  });
201
206
  }
202
207
  }
@@ -205,15 +210,15 @@ export function emitDial(element, scope, out, env, state) {
205
210
  try {
206
211
  staticAssigns.push({
207
212
  field,
208
- expr: evalStatic(node, scope, 'strict') ? '1' : '0',
213
+ value: evalStatic(node, scope, 'strict') ? 1 : 0,
209
214
  });
210
215
  }
211
216
  catch {
212
- dynAssigns.push({
217
+ dynamicAssigns.push({
213
218
  field,
214
219
  value: {
215
220
  kind: 'flag',
216
- test: lowerExpr(node, env),
221
+ test: lowerExpr(node, environment),
217
222
  truthiness: 'value',
218
223
  negate: false,
219
224
  whenTrue: 1,
@@ -222,52 +227,58 @@ export function emitDial(element, scope, out, env, state) {
222
227
  }
223
228
  }
224
229
  else if (name === 'knobImage') {
225
- knobImage = imageNameFromSource(node, env);
230
+ knobImage = imageNameFromSource(node, environment);
226
231
  if (knobImage == null) {
227
232
  throw aotError('AOT: <Dial knobImage> must resolve to a static asset name', "use an imported image (`import knob from './knob.png'` → knobImage={knob}) or a string asset name.");
228
233
  }
229
- const path = env.imageNames?.get(knobImage);
234
+ const path = environment.imageNames?.get(knobImage);
230
235
  if (path) {
231
- out.images.set(knobImage, path);
236
+ output.images.set(knobImage, path);
232
237
  }
233
238
  }
234
239
  else if (name === 'indicatorGradient') {
235
240
  // Allow indicatorGradient to be statically defined but conditionally enabled with a ternary against null/undefined.
236
- let gradNode = node;
237
- let gradCond = null;
241
+ let gradientNode = node;
242
+ let gradientCondition = null;
238
243
  if (node?.type === 'ConditionalExpression') {
239
- const nullish = (n) => n?.type === 'NullLiteral' ||
240
- (n?.type === 'Identifier' && n.name === 'undefined');
244
+ const nullish = (candidate) => candidate?.type === 'NullLiteral' ||
245
+ (candidate?.type === 'Identifier' && candidate.name === 'undefined');
241
246
  if (nullish(node.alternate)) {
242
- gradNode = node.consequent;
243
- gradCond = { test: lowerExpr(node.test, env), negate: false };
247
+ gradientNode = node.consequent;
248
+ gradientCondition = {
249
+ test: lowerExpr(node.test, environment),
250
+ negate: false,
251
+ };
244
252
  }
245
253
  else if (nullish(node.consequent)) {
246
- gradNode = node.alternate;
247
- gradCond = { test: lowerExpr(node.test, env), negate: true };
254
+ gradientNode = node.alternate;
255
+ gradientCondition = {
256
+ test: lowerExpr(node.test, environment),
257
+ negate: true,
258
+ };
248
259
  }
249
260
  }
250
261
  // Validate and normalize the static gradient definition, keeping only the engine-supported stop count.
251
- const gradient = evalStaticOrThrow(gradNode, scope, 'AOT: <Dial indicatorGradient> must be a static object (optionally behind a ternary against null)', "indicatorGradient={{ type: 'conic', stops: [{ color: '#00f' }, { color: '#f00' }] }}, or " +
262
+ const gradient = evalStaticOrThrow(gradientNode, scope, 'AOT: <Dial indicatorGradient> must be a static object (optionally behind a ternary against null)', "indicatorGradient={{ type: 'conic', stops: [{ color: '#00f' }, { color: '#f00' }] }}, or " +
252
263
  'indicatorGradient={on ? {…} : null}');
253
264
  const allStops = Array.isArray(gradient?.stops) ? gradient.stops : [];
254
265
  check({ kind: 'dialGradientStops', count: allStops.length });
255
266
  const stops = allStops.slice(0, DIAL_MAX_GRADIENT_STOPS);
256
267
  staticAssigns.push({
257
268
  field: 'gradient_type',
258
- expr: gradient.type === 'radial'
269
+ value: gradient.type === 'radial'
259
270
  ? 'ER_GRADIENT_RADIAL'
260
271
  : 'ER_GRADIENT_CONIC',
261
272
  });
262
273
  // Emit the stop count separately so a ternary can enable/disable the static gradient at runtime.
263
- if (gradCond) {
264
- dynAssigns.push({
274
+ if (gradientCondition) {
275
+ dynamicAssigns.push({
265
276
  field: 'gradient_stop_count',
266
277
  value: {
267
278
  kind: 'flag',
268
- test: gradCond.test,
279
+ test: gradientCondition.test,
269
280
  truthiness: 'value',
270
- negate: gradCond.negate,
281
+ negate: gradientCondition.negate,
271
282
  whenTrue: stops.length,
272
283
  },
273
284
  });
@@ -275,24 +286,26 @@ export function emitDial(element, scope, out, env, state) {
275
286
  else {
276
287
  staticAssigns.push({
277
288
  field: 'gradient_stop_count',
278
- expr: String(stops.length),
289
+ value: stops.length,
279
290
  });
280
291
  }
281
292
  // Emit each fixed stop, filling in missing offsets with evenly spaced positions.
282
- stops.forEach((st, i) => {
283
- const off = typeof st.offset === 'number' ? st.offset : i / (stops.length - 1);
293
+ stops.forEach((stop, index) => {
294
+ const offset = typeof stop.offset === 'number'
295
+ ? stop.offset
296
+ : index / (stops.length - 1);
284
297
  staticAssigns.push({
285
- field: `gradient_stops[${i}].color`,
286
- expr: colorLiteral(String(st.color)),
298
+ field: `gradient_stops[${index}].color`,
299
+ value: parseColorValue(String(stop.color)),
287
300
  });
288
301
  staticAssigns.push({
289
- field: `gradient_stops[${i}].position`,
290
- expr: floatLit(off),
302
+ field: `gradient_stops[${index}].position`,
303
+ value: floatConstant(offset),
291
304
  });
292
305
  });
293
306
  }
294
307
  else if (name === 'onChange') {
295
- onChangeFn = node;
308
+ onChangeFunction = node;
296
309
  }
297
310
  else {
298
311
  throw aotError(`AOT: <Dial> prop "${name}" is not supported`);
@@ -301,9 +314,10 @@ export function emitDial(element, scope, out, env, state) {
301
314
  // Animated bindings: style props plus an animated `value` (ER_PROP_ARC_VALUE).
302
315
  const node = {
303
316
  id: nodeID,
317
+ location: currentLoc(),
304
318
  type: 'ER_NODE_ARC',
305
319
  constantProps: staticAssigns,
306
- stateProps: dynAssigns,
320
+ stateProps: dynamicAssigns,
307
321
  placeholder: null,
308
322
  text: null,
309
323
  image: knobImage != null ? { kind: 'static', name: knobImage } : null,
@@ -312,22 +326,22 @@ export function emitDial(element, scope, out, env, state) {
312
326
  wiring: binds.map((bind, index) => ({ kind: 'bind', bind, index })),
313
327
  };
314
328
  // Compile <Dial onChange> into an ER_EVENT_VALUE_CHANGE handler.
315
- if (onChangeFn) {
329
+ if (onChangeFunction) {
316
330
  // A useCallback identifier resolves to its arrow, the same way the generic host-node event path does —
317
331
  // a dial's change handler is exactly the kind of thing an app wraps in useCallback.
318
- if (onChangeFn.type === 'Identifier' &&
319
- env.callbacks?.has(onChangeFn.name)) {
320
- onChangeFn = env.callbacks.get(onChangeFn.name);
332
+ if (onChangeFunction.type === 'Identifier' &&
333
+ environment.callbacks?.has(onChangeFunction.name)) {
334
+ onChangeFunction = environment.callbacks.get(onChangeFunction.name);
321
335
  }
322
336
  // Require a function node so lowerValueHandler can bind the dial's value parameters.
323
- if (!isFn(onChangeFn)) {
337
+ if (!isFn(onChangeFunction)) {
324
338
  throw aotError('AOT: <Dial onChange> must be an inline function or a useCallback', 'onChange={(v) => setValue(v)}');
325
339
  }
326
- const handlerName = `er_handler_${out.handlers.length}`;
327
- out.handlers.push({
340
+ const handlerName = `handler_${output.handlers.length}`;
341
+ output.handlers.push({
328
342
  kind: 'callback',
329
343
  name: handlerName,
330
- callback: lowerValueHandler(onChangeFn, 'data->value', env, state, out, 'float', 'data->value_start'),
344
+ callback: lowerValueHandler(onChangeFunction, environment, state, output, 'float', false, { kind: 'event', field: 'value', type: FLOAT }, { kind: 'event', field: 'value_start', type: FLOAT }),
331
345
  });
332
346
  node.wiring.push({
333
347
  kind: 'event',
@@ -335,10 +349,10 @@ export function emitDial(element, scope, out, env, state) {
335
349
  handler: handlerName,
336
350
  });
337
351
  }
338
- for (const slot of lowerRefBinds(element.openingElement, env)) {
352
+ for (const slot of lowerRefBinds(element.openingElement, environment)) {
339
353
  node.wiring.push({ kind: 'ref', slot });
340
354
  }
341
355
  checkInterpolations(node);
342
- node.children = emitChildren(element.children, scope, out, env, state);
356
+ node.children = emitChildren(element.children, scope, output, environment, state);
343
357
  return node;
344
358
  }