embedded-react 0.19.0 → 0.21.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 (148) hide show
  1. package/NOTICE +5 -0
  2. package/README.md +8 -3
  3. package/aot/app-file-loader.mjs +116 -0
  4. package/aot/compile.mjs +180 -90
  5. package/aot/compiler/animations.mjs +568 -317
  6. package/aot/compiler/boot.mjs +97 -35
  7. package/aot/compiler/branch-merge.mjs +4 -3
  8. package/aot/compiler/check.mjs +70 -18
  9. package/aot/compiler/collect.mjs +787 -288
  10. package/aot/compiler/contexts.mjs +391 -0
  11. package/aot/compiler/control-flow.mjs +439 -268
  12. package/aot/compiler/custom-hooks.mjs +686 -0
  13. package/aot/compiler/diagnostics.mjs +22 -25
  14. package/aot/compiler/elements/activity-indicator.mjs +25 -24
  15. package/aot/compiler/elements/button.mjs +182 -0
  16. package/aot/compiler/elements/dial.mjs +91 -77
  17. package/aot/compiler/elements/flat-list.mjs +24 -22
  18. package/aot/compiler/elements/image-background.mjs +76 -0
  19. package/aot/compiler/elements/image.mjs +52 -50
  20. package/aot/compiler/elements/modal.mjs +31 -30
  21. package/aot/compiler/elements/props.mjs +61 -26
  22. package/aot/compiler/elements/rewrite.mjs +118 -0
  23. package/aot/compiler/elements/section-list.mjs +370 -0
  24. package/aot/compiler/elements/switch.mjs +42 -34
  25. package/aot/compiler/elements/text-input.mjs +34 -32
  26. package/aot/compiler/expressions.mjs +1685 -392
  27. package/aot/compiler/handlers.mjs +2029 -547
  28. package/aot/compiler/helper-values.mjs +312 -0
  29. package/aot/compiler/ir/functions.mjs +11 -1
  30. package/aot/compiler/ir/nodes.mjs +43 -4
  31. package/aot/compiler/ir/reads.mjs +223 -22
  32. package/aot/compiler/ir/text.mjs +5 -1
  33. package/aot/compiler/ir/types.mjs +26 -14
  34. package/aot/compiler/ir/vectors.mjs +5 -1
  35. package/aot/compiler/kept-states.mjs +177 -0
  36. package/aot/compiler/keyboard.mjs +17 -7
  37. package/aot/compiler/list-items.mjs +226 -0
  38. package/aot/compiler/list-order.mjs +586 -0
  39. package/aot/compiler/list-split.mjs +259 -0
  40. package/aot/compiler/loops.mjs +582 -0
  41. package/aot/compiler/lower.mjs +246 -111
  42. package/aot/compiler/native-files.mjs +439 -0
  43. package/aot/compiler/native-header.mjs +335 -0
  44. package/aot/compiler/native-modules.mjs +1173 -0
  45. package/aot/compiler/nodes.mjs +195 -172
  46. package/aot/compiler/options.mjs +37 -31
  47. package/aot/compiler/out.mjs +32 -23
  48. package/aot/compiler/package/animations.mjs +779 -0
  49. package/aot/compiler/package/arena.mjs +252 -0
  50. package/aot/compiler/package/assemble.mjs +175 -0
  51. package/aot/compiler/package/bytecode.mjs +315 -0
  52. package/aot/compiler/package/checks.mjs +1026 -0
  53. package/aot/compiler/package/codegen.mjs +2168 -0
  54. package/aot/compiler/package/enums.mjs +148 -0
  55. package/aot/compiler/package/format.mjs +771 -0
  56. package/aot/compiler/package/layouts.mjs +136 -0
  57. package/aot/compiler/package/lower.mjs +2103 -0
  58. package/aot/compiler/package/props.mjs +118 -0
  59. package/aot/compiler/package/string-caps.mjs +515 -0
  60. package/aot/compiler/package/tables.mjs +127 -0
  61. package/aot/compiler/package/vectors.mjs +502 -0
  62. package/aot/compiler/package/writer.mjs +686 -0
  63. package/aot/compiler/pan-responder.mjs +69 -61
  64. package/aot/compiler/parse.mjs +23 -21
  65. package/aot/compiler/record-shapes.mjs +246 -0
  66. package/aot/compiler/records.mjs +654 -0
  67. package/aot/compiler/reducers.mjs +272 -0
  68. package/aot/compiler/static-eval.mjs +340 -30
  69. package/aot/compiler/style-text.mjs +178 -174
  70. package/aot/compiler/svg.mjs +480 -251
  71. package/aot/compiler/switch-cases.mjs +198 -0
  72. package/aot/compiler/tagged-records.mjs +450 -0
  73. package/aot/compiler/typing.mjs +307 -0
  74. package/aot/compiler/updaters.mjs +320 -0
  75. package/aot/compiler/window-dimensions.mjs +94 -0
  76. package/aot/compiler/worked-values.mjs +319 -0
  77. package/aot/demo-file.mjs +30 -0
  78. package/aot/screenshot-smoke.mjs +54 -40
  79. package/aot/style-map.mjs +152 -92
  80. package/assets/bake-font.mjs +123 -77
  81. package/assets/bake-image.mjs +39 -22
  82. package/assets/bake-svg.mjs +361 -262
  83. package/assets/build-builtin-font.mjs +11 -7
  84. package/assets/emit-c.mjs +77 -58
  85. package/assets/emit-container.mjs +123 -37
  86. package/assets/emit-pack.mjs +77 -67
  87. package/assets/font-config.mjs +9 -6
  88. package/assets/font-sizes.mjs +163 -123
  89. package/assets/glyph-coverage.mjs +74 -54
  90. package/assets/index.mjs +31 -9
  91. package/assets/rasterize.mjs +126 -99
  92. package/assets/svg-loader.mjs +8 -8
  93. package/build.mjs +23 -13
  94. package/cli.mjs +402 -172
  95. package/compile-bin.mjs +3 -3
  96. package/flash.mjs +537 -0
  97. package/hotreload/dev-device.mjs +90 -33
  98. package/hotreload/pack-app.mjs +55 -43
  99. package/hotreload/pack-split.mjs +62 -64
  100. package/hotreload/package-transfer.mjs +175 -0
  101. package/hotreload/protocol.mjs +50 -37
  102. package/hotreload/uploader.mjs +38 -27
  103. package/hotreload/watch-tree.mjs +19 -19
  104. package/pack-container.mjs +37 -21
  105. package/package.json +7 -8
  106. package/persist-transform.mjs +34 -28
  107. package/qjsc-wasm.mjs +25 -14
  108. package/sim/embedded-react.cjs +1 -1
  109. package/sim/embedded-react.js +1 -1
  110. package/sim/embedded-react.wasm +0 -0
  111. package/sim/index.html +94 -85
  112. package/sim-server.mjs +113 -94
  113. package/src/embedded-react/Animated.js +24 -24
  114. package/src/embedded-react/Dimensions.js +37 -0
  115. package/src/embedded-react/Easing.js +1 -1
  116. package/src/embedded-react/FlatList.js +3 -3
  117. package/src/embedded-react/LayoutAnimation.js +8 -5
  118. package/src/embedded-react/PanResponder.js +75 -71
  119. package/src/embedded-react/Pressable.js +2 -8
  120. package/src/embedded-react/SectionList.js +7 -9
  121. package/src/embedded-react/StyleSheet.js +4 -3
  122. package/src/embedded-react/TouchableOpacity.js +13 -8
  123. package/src/embedded-react/index.d.ts +88 -8
  124. package/src/embedded-react/index.js +2 -0
  125. package/src/embedded-react/layout-anim-config.js +10 -4
  126. package/src/embedded-react/list-child.js +5 -5
  127. package/src/embedded-react/named-colors.js +1 -1
  128. package/src/embedded-react/nativeModule.js +462 -0
  129. package/src/embedded-react/split-style.js +11 -11
  130. package/src/embedded-react/svg-ops.js +760 -593
  131. package/src/embedded-react/useHostValue.js +3 -3
  132. package/src/embedded-react/usePersistentState.js +6 -6
  133. package/src/embedded-react/warn-props.js +1 -1
  134. package/src/host-config.js +60 -53
  135. package/src/props.js +49 -41
  136. package/src/renderer.js +7 -4
  137. package/aot/compiler/assemble.mjs +0 -944
  138. package/aot/compiler/c/animations.mjs +0 -436
  139. package/aot/compiler/c/boot.mjs +0 -127
  140. package/aot/compiler/c/expressions.mjs +0 -270
  141. package/aot/compiler/c/functions.mjs +0 -268
  142. package/aot/compiler/c/keyboard.mjs +0 -96
  143. package/aot/compiler/c/nodes.mjs +0 -303
  144. package/aot/compiler/c/pan-responder.mjs +0 -136
  145. package/aot/compiler/c/statements.mjs +0 -319
  146. package/aot/compiler/c/text.mjs +0 -83
  147. package/aot/compiler/c/vectors.mjs +0 -381
  148. package/aot/compiler/c-syntax.mjs +0 -127
@@ -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
  }
@@ -31,37 +31,37 @@ import { emitNode } from '../nodes.mjs';
31
31
  *
32
32
  * @param element The <FlatList>.
33
33
  * @param scope Compile-time constants in reach.
34
- * @param out Everything emitted so far.
35
- * @param env The expression environment.
34
+ * @param output Everything emitted so far.
35
+ * @param environment The expression environment.
36
36
  * @param state The component's state table.
37
- * @param opts How the element is placed.
37
+ * @param options How the element is placed.
38
38
  *
39
39
  * @returns The variable of the <ScrollView> node it lowers to.
40
40
  */
41
- export function emitFlatList(element, scope, out, env, state, opts) {
41
+ export function emitFlatList(element, scope, output, environment, state, options) {
42
42
  // Collect the supported <FlatList> props, rejecting anything the AOT rewrite cannot statically lower.
43
43
  let dataNode = null;
44
44
  let renderItem = null;
45
- let styleAttr = null;
46
- for (const attr of element.openingElement.attributes) {
45
+ let styleAttribute = null;
46
+ for (const attribute of element.openingElement.attributes) {
47
47
  // Ensure all props are explicit named attributes.
48
48
  // Spread props cannot be analyzed statically
49
- if (attr.type !== 'JSXAttribute') {
49
+ if (attribute.type !== 'JSXAttribute') {
50
50
  throw aotError('AOT: spread props on <FlatList> are not supported');
51
51
  }
52
52
  // skip non-props
53
- const name = attr.name.name;
53
+ const name = attribute.name.name;
54
54
  if (name === 'keyExtractor' || name === 'key')
55
55
  continue;
56
56
  // process props
57
57
  if (name === 'data') {
58
- dataNode = attrExpr(attr);
58
+ dataNode = attrExpr(attribute);
59
59
  }
60
60
  else if (name === 'renderItem') {
61
- renderItem = attrExpr(attr);
61
+ renderItem = attrExpr(attribute);
62
62
  }
63
63
  else if (name === 'style') {
64
- styleAttr = attr;
64
+ styleAttribute = attribute;
65
65
  }
66
66
  else {
67
67
  throw aotError(`AOT: <FlatList> prop "${name}" is not supported`, 'supported: data, renderItem, keyExtractor, style. For headers/footers/horizontal/onEndReached etc., use <ScrollView> + .map directly.');
@@ -74,14 +74,14 @@ export function emitFlatList(element, scope, out, env, state, opts) {
74
74
  if (!renderItem || !isFn(renderItem)) {
75
75
  throw aotError('AOT: <FlatList> needs a renderItem function', 'renderItem={({ item, index }) => <Row item={item} />}');
76
76
  }
77
- const param = renderItem.params[0];
78
- if (!param || param.type !== 'ObjectPattern') {
77
+ const parameter = renderItem.params[0];
78
+ if (!parameter || parameter.type !== 'ObjectPattern') {
79
79
  throw aotError('AOT: FlatList renderItem must destructure ({ item, index })', 'renderItem={({ item }) => <Row item={item} />}');
80
80
  }
81
81
  // Extract the local item/index names from renderItem's destructured parameter, rejecting any unsupported row fields or patterns.
82
82
  let itemName = null;
83
83
  let indexName = null;
84
- for (const prop of param.properties) {
84
+ for (const prop of parameter.properties) {
85
85
  if (prop.type !== 'ObjectProperty' || prop.value.type !== 'Identifier') {
86
86
  throw aotError('AOT: FlatList renderItem may destructure only item / index (to plain names)');
87
87
  }
@@ -95,18 +95,20 @@ export function emitFlatList(element, scope, out, env, state, opts) {
95
95
  throw aotError(`AOT: FlatList renderItem cannot destructure "${prop.key.name}" (only item / index)`);
96
96
  }
97
97
  }
98
- // Ensure renderItem binds the required item value; index is optional for the generated map callback.
98
+ // Ensure renderItem binds the required item value; index is optional for the map callback.
99
99
  if (!itemName) {
100
100
  throw aotError('AOT: FlatList renderItem must destructure item', 'renderItem={({ item }) => …}');
101
101
  }
102
102
  // Rewrite renderItem `({ item, index }) => BODY` → a positional `.map` callback `(item, index) => BODY`.
103
- const cbParams = [{ type: 'Identifier', name: itemName }];
103
+ const callbackParameters = [
104
+ { type: 'Identifier', name: itemName },
105
+ ];
104
106
  if (indexName) {
105
- cbParams.push({ type: 'Identifier', name: indexName });
107
+ callbackParameters.push({ type: 'Identifier', name: indexName });
106
108
  }
107
- const cb = {
109
+ const callback = {
108
110
  type: 'ArrowFunctionExpression',
109
- params: cbParams,
111
+ params: callbackParameters,
110
112
  body: renderItem.body,
111
113
  async: false,
112
114
  expression: renderItem.body.type !== 'BlockStatement',
@@ -119,14 +121,14 @@ export function emitFlatList(element, scope, out, env, state, opts) {
119
121
  property: { type: 'Identifier', name: 'map' },
120
122
  computed: false,
121
123
  },
122
- arguments: [cb],
124
+ arguments: [callback],
123
125
  };
124
126
  const scrollView = {
125
127
  type: 'JSXElement',
126
128
  openingElement: {
127
129
  type: 'JSXOpeningElement',
128
130
  name: { type: 'JSXIdentifier', name: 'ScrollView' },
129
- attributes: styleAttr ? [styleAttr] : [],
131
+ attributes: styleAttribute ? [styleAttribute] : [],
130
132
  selfClosing: false,
131
133
  },
132
134
  closingElement: {
@@ -135,5 +137,5 @@ export function emitFlatList(element, scope, out, env, state, opts) {
135
137
  },
136
138
  children: [{ type: 'JSXExpressionContainer', expression: mapCall }],
137
139
  };
138
- return emitNode(scrollView, scope, out, env, state, opts);
140
+ return emitNode(scrollView, scope, output, environment, state, options);
139
141
  }
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright 2026 Cory Lamming
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /*----------------------------------------------------------------------------------------------------------------------
17
+ - Imports
18
+ ---------------------------------------------------------------------------------------------------------------------*/
19
+ import { attrExpr } from '../style-text.mjs';
20
+ import { emitNode } from '../nodes.mjs';
21
+ import { attributeOf, elementOf, literalObject, refuseSpreads, renamed, } from './rewrite.mjs';
22
+ /*----------------------------------------------------------------------------------------------------------------------
23
+ - Constants
24
+ ---------------------------------------------------------------------------------------------------------------------*/
25
+ /** StyleSheet.absoluteFill: the image fills the container's padding box. */
26
+ const ABSOLUTE_FILL = {
27
+ position: 'absolute',
28
+ left: 0,
29
+ right: 0,
30
+ top: 0,
31
+ bottom: 0,
32
+ };
33
+ /*----------------------------------------------------------------------------------------------------------------------
34
+ - Implementation
35
+ ---------------------------------------------------------------------------------------------------------------------*/
36
+ /**
37
+ * <ImageBackground style imageStyle imageRef …imageProps>children</ImageBackground> → the tree
38
+ * ImageBackground.js renders: a <View> holding an <Image> that fills it, then the children. `style` and `ref`
39
+ * go to the View, every other prop to the Image.
40
+ *
41
+ * @param element The <ImageBackground>, its props already checked.
42
+ * @param scope Compile-time constants in reach.
43
+ * @param output Everything emitted so far.
44
+ * @param environment The expression environment.
45
+ * @param state The component's state table.
46
+ * @param options How the element is placed.
47
+ *
48
+ * @returns What the <View> lowers to.
49
+ */
50
+ export function emitImageBackground(element, scope, output, environment, state, options) {
51
+ refuseSpreads(element, 'ImageBackground');
52
+ const viewAttributes = [];
53
+ const imageAttributes = [];
54
+ const imageStyles = [literalObject(ABSOLUTE_FILL)];
55
+ for (const attribute of element.openingElement
56
+ .attributes) {
57
+ const name = attribute.name.name;
58
+ if (name === 'key')
59
+ continue;
60
+ if (name === 'style' || name === 'ref') {
61
+ viewAttributes.push(attribute);
62
+ }
63
+ else if (name === 'imageStyle') {
64
+ imageStyles.push(attrExpr(attribute));
65
+ }
66
+ else if (name === 'imageRef') {
67
+ imageAttributes.push(renamed(attribute, 'ref'));
68
+ }
69
+ else {
70
+ imageAttributes.push(attribute);
71
+ }
72
+ }
73
+ imageAttributes.push(attributeOf('style', { type: 'ArrayExpression', elements: imageStyles }));
74
+ const image = elementOf('Image', imageAttributes, [], element);
75
+ return emitNode(elementOf('View', viewAttributes, [image, ...element.children], element), scope, output, environment, state, options);
76
+ }