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,8 +17,8 @@
17
17
  - Imports
18
18
  ---------------------------------------------------------------------------------------------------------------------*/
19
19
  import { checkNumber } from './check.mjs';
20
- import { NODE_TYPES } from '../style-map.mjs';
21
- import { aotError, checkEngineString, constantText, withLoc, } from './diagnostics.mjs';
20
+ import { NODE_TYPES, OPACITY_OPAQUE } from '../style-map.mjs';
21
+ import { aotError, checkEngineString, constantText, currentLoc, withLoc, } from './diagnostics.mjs';
22
22
  import { buildValueOf, foldBoot } from './boot.mjs';
23
23
  import { evalStaticOrThrow, evalStatic, foldScope } from './static-eval.mjs';
24
24
  import { lowerExpr } from './expressions.mjs';
@@ -27,7 +27,8 @@ import { attrExpr, collectStyleAssigns, lowerNodeText, collectTextSpans, } from
27
27
  import { at, checkAttributes, checkNoChildren, elementSpec, EVENT_TYPES, withoutPlatformNoOps, } from './elements/props.mjs';
28
28
  import { lowerHandler } from './handlers.mjs';
29
29
  import { emitPanResponder, panSpreadTarget } from './pan-responder.mjs';
30
- import { emitComponent, emitChildren } from './control-flow.mjs';
30
+ import { emitComponent, emitChildren, emitProvider } from './control-flow.mjs';
31
+ import { providedContextOf } from './contexts.mjs';
31
32
  import { emitSvg } from './svg.mjs';
32
33
  import { emitDial } from './elements/dial.mjs';
33
34
  import { emitSwitch } from './elements/switch.mjs';
@@ -35,18 +36,13 @@ import { emitTextInput } from './elements/text-input.mjs';
35
36
  import { emitActivityIndicator } from './elements/activity-indicator.mjs';
36
37
  import { emitModal } from './elements/modal.mjs';
37
38
  import { emitFlatList } from './elements/flat-list.mjs';
39
+ import { emitButton } from './elements/button.mjs';
40
+ import { emitImageBackground } from './elements/image-background.mjs';
41
+ import { emitSectionList } from './elements/section-list.mjs';
38
42
  import { resolveImageAttrs } from './elements/image.mjs';
39
43
  /*----------------------------------------------------------------------------------------------------------------------
40
44
  - Constants
41
45
  ---------------------------------------------------------------------------------------------------------------------*/
42
- // JS-only wrappers with no lowering yet, mapped to the tree to write by hand; "unknown element" would mislead.
43
- const FLOW_A_ONLY_COMPONENTS = {
44
- Button: '<Pressable style={…} onPress={…}><Text style={…}>title</Text></Pressable>.',
45
- ImageBackground: "<View style={…}><Image source={…} style={{position: 'absolute', top: 0, left: 0, " +
46
- 'right: 0, bottom: 0}} />…children…</View>.',
47
- SectionList: '<ScrollView> with the header element and a data.map(…) per section (a section is not ' +
48
- 'one .map, which is why it has no lowering).',
49
- };
50
46
  // <TouchableOpacity> press feedback (see touchablePressFades).
51
47
  const TOUCHABLE_ACTIVE_OPACITY = 0.2; // RN's default
52
48
  const TOUCHABLE_RESTORE_MS = 250; // RN's fade-back; the dim itself lands with no ramp
@@ -62,6 +58,10 @@ const ELLIPSIZE_MODES = {
62
58
  tail: 'ER_TEXT_ELLIPSIZE_TAIL',
63
59
  clip: 'ER_TEXT_ELLIPSIZE_CLIP',
64
60
  };
61
+ /** The most lines a <Text> may keep: the engine counts them in a byte. */
62
+ const MAX_NUMBER_OF_LINES = 255;
63
+ /** The longest long press, in ms: the engine keeps it in 16 bits. */
64
+ const MAX_LONG_PRESS_MS = 65535;
65
65
  /*----------------------------------------------------------------------------------------------------------------------
66
66
  - Implementation
67
67
  ---------------------------------------------------------------------------------------------------------------------*/
@@ -86,25 +86,25 @@ function resolveTag(openingElement) {
86
86
  * The node refs `ref={myRef}` stores the element's handle in (a node ref from useRef), marked used.
87
87
  *
88
88
  * @param openingElement The element's opening tag.
89
- * @param env The expression environment.
89
+ * @param environment The expression environment.
90
90
  *
91
- * @returns The refs' C slots.
91
+ * @returns The refs' slots.
92
92
  */
93
- export function lowerRefBinds(openingElement, env) {
93
+ export function lowerRefBinds(openingElement, environment) {
94
94
  const refs = [];
95
- for (const attr of openingElement.attributes) {
96
- if (attr.type !== 'JSXAttribute' ||
97
- attr.name.name !== 'ref') {
95
+ for (const attribute of openingElement.attributes) {
96
+ if (attribute.type !== 'JSXAttribute' ||
97
+ attribute.name.name !== 'ref') {
98
98
  continue;
99
99
  }
100
- const refExpr = attr.value?.type === 'JSXExpressionContainer'
101
- ? attr.value.expression
100
+ const refExpression = attribute.value?.type === 'JSXExpressionContainer'
101
+ ? attribute.value.expression
102
102
  : null;
103
- if (refExpr?.type === 'Identifier' &&
104
- env.refs?.get(refExpr.name)?.kind === 'node') {
105
- const nodeRef = env.refs.get(refExpr.name);
103
+ if (refExpression?.type === 'Identifier' &&
104
+ environment.refs?.get(refExpression.name)?.kind === 'node') {
105
+ const nodeRef = environment.refs.get(refExpression.name);
106
106
  nodeRef.used = true;
107
- refs.push(nodeRef.cVar);
107
+ refs.push(nodeRef.slotName);
108
108
  }
109
109
  else {
110
110
  throw new Error('AOT: ref={…} must reference a node ref declared with useRef()');
@@ -121,7 +121,9 @@ export function lowerRefBinds(openingElement, env) {
121
121
  * @returns The attribute, if the element has it.
122
122
  */
123
123
  function namedAttr(openingElement, name) {
124
- return openingElement.attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name && attr.name.name === name);
124
+ return openingElement.attributes.find((attribute) => attribute.type === 'JSXAttribute' &&
125
+ attribute.name &&
126
+ attribute.name.name === name);
125
127
  }
126
128
  /**
127
129
  * True for `<Pressable disabled>` / `<TouchableOpacity disabled={SOME_CONST}>`. Must fold: `disabled`
@@ -135,10 +137,10 @@ function namedAttr(openingElement, name) {
135
137
  * @returns Whether it is disabled.
136
138
  */
137
139
  function pressableIsDisabled(element, tag, scope) {
138
- const attr = namedAttr(element.openingElement, 'disabled');
139
- if (!attr)
140
+ const attribute = namedAttr(element.openingElement, 'disabled');
141
+ if (!attribute)
140
142
  return false;
141
- return !!evalStaticOrThrow(attrExpr(attr), scope, `AOT: <${tag} disabled> must be a compile-time constant`, 'a disabled one still renders — it lowers to a plain <Pressable>, children, layout ' +
143
+ return !!evalStaticOrThrow(attrExpr(attribute), scope, `AOT: <${tag} disabled> must be a compile-time constant`, 'a disabled one still renders — it lowers to a plain <Pressable>, children, layout ' +
142
144
  'and style intact — but its press handlers are not emitted at all, so the ' +
143
145
  'AOT has to know at build time. To gate on state, leave it enabled and return early ' +
144
146
  'in the handler (`onPress={() => { if (!ready) return; … }}`).');
@@ -154,26 +156,26 @@ function pressableIsDisabled(element, tag, scope) {
154
156
  */
155
157
  function lowerTextTruncation(openingElement, scope) {
156
158
  const assigns = [];
157
- const linesAttr = namedAttr(openingElement, 'numberOfLines');
158
- if (linesAttr) {
159
- const lines = foldAttr(linesAttr, scope, 'AOT: <Text numberOfLines> must be a compile-time constant');
159
+ const linesAttribute = namedAttr(openingElement, 'numberOfLines');
160
+ if (linesAttribute) {
161
+ const lines = foldAttr(linesAttribute, scope, 'AOT: <Text numberOfLines> must be a compile-time constant');
160
162
  if (typeof lines !== 'number' ||
161
163
  !Number.isInteger(lines) ||
162
164
  lines < 0 ||
163
- lines > 255) {
164
- throw at(aotError(`AOT: <Text numberOfLines> must be a whole number from 0 to 255 (got ${String(lines)})`, '0 does not truncate; any other value is the most lines the text wraps to.'), linesAttr);
165
+ lines > MAX_NUMBER_OF_LINES) {
166
+ throw at(aotError(`AOT: <Text numberOfLines> must be a whole number from 0 to ${MAX_NUMBER_OF_LINES} (got ${String(lines)})`, '0 does not truncate; any other value is the most lines the text wraps to.'), linesAttribute);
165
167
  }
166
- assigns.push({ field: 'number_of_lines', expr: String(lines) });
168
+ assigns.push({ field: 'number_of_lines', value: lines });
167
169
  }
168
- const modeAttr = namedAttr(openingElement, 'ellipsizeMode');
169
- if (modeAttr) {
170
- const mode = foldAttr(modeAttr, scope, 'AOT: <Text ellipsizeMode> must be a compile-time constant');
170
+ const modeAttribute = namedAttr(openingElement, 'ellipsizeMode');
171
+ if (modeAttribute) {
172
+ const mode = foldAttr(modeAttribute, scope, 'AOT: <Text ellipsizeMode> must be a compile-time constant');
171
173
  if (!Object.hasOwn(ELLIPSIZE_MODES, mode)) {
172
- throw at(aotError(`AOT: <Text ellipsizeMode> "${String(mode)}" is not drawn by the engine`, "use 'tail' or 'clip'; the engine draws 'head' and 'middle' as 'tail'."), modeAttr);
174
+ throw at(aotError(`AOT: <Text ellipsizeMode> "${String(mode)}" is not drawn by the engine`, "use 'tail' or 'clip'; the engine draws 'head' and 'middle' as 'tail'."), modeAttribute);
173
175
  }
174
176
  assigns.push({
175
177
  field: 'ellipsize_mode',
176
- expr: ELLIPSIZE_MODES[mode],
178
+ value: ELLIPSIZE_MODES[mode],
177
179
  });
178
180
  }
179
181
  return assigns;
@@ -181,32 +183,32 @@ function lowerTextTruncation(openingElement, scope) {
181
183
  /**
182
184
  * An attribute's value, which must fold; the error is pinned to the attribute.
183
185
  *
184
- * @param attr The attribute.
186
+ * @param attribute The attribute.
185
187
  * @param scope Compile-time constants in reach.
186
188
  * @param message The error when it does not fold.
187
189
  *
188
190
  * @returns The folded value.
189
191
  */
190
- function foldAttr(attr, scope, message) {
192
+ function foldAttr(attribute, scope, message) {
191
193
  try {
192
- return evalStaticOrThrow(attrExpr(attr), scope, message);
194
+ return evalStaticOrThrow(attrExpr(attribute), scope, message);
193
195
  }
194
196
  catch (error) {
195
- throw at(error, attr);
197
+ throw at(error, attribute);
196
198
  }
197
199
  }
198
200
  /**
199
201
  * A folded `activeOpacity` as a number in 0..1. Everything else is an error HERE, where the source line
200
- * is still in reach: it would otherwise reach floatLit and land in the generated C as a literal that
201
- * either does not compile (`NaNf`) or quietly means something the app never asked for — a bare
202
- * `activeOpacity` is `true`, so `1.0f`, which is not dim at all; `{false}` is an invisible one.
202
+ * is still in reach: it would otherwise reach floatConstant and land in the package as a value that
203
+ * is not a number, or quietly means something the app never asked for — a bare
204
+ * `activeOpacity` is `true`, so 1, which is not dim at all; `{false}` is an invisible one.
203
205
  *
204
206
  * @param value The folded value.
205
- * @param attr The attribute, for the error's location.
207
+ * @param attribute The attribute, for the error's location.
206
208
  *
207
209
  * @returns The opacity.
208
210
  */
209
- function opacityLiteralOrThrow(value, attr) {
211
+ function opacityLiteralOrThrow(value, attribute) {
210
212
  if (typeof value !== 'number' ||
211
213
  !Number.isFinite(value) ||
212
214
  value < 0 ||
@@ -216,8 +218,8 @@ function opacityLiteralOrThrow(value, attr) {
216
218
  ? String(value)
217
219
  : (JSON.stringify(value) ?? String(value));
218
220
  const error = aotError(`AOT: <TouchableOpacity activeOpacity> must be a number between 0 and 1 (got ${shown})`, 'it is the opacity the node dims to while held — 0 is invisible, 1 is no dim at all. RN defaults it to 0.2.');
219
- if (attr.loc) {
220
- error.aotLoc = attr.loc.start;
221
+ if (attribute.loc) {
222
+ error.aotLoc = attribute.loc.start;
221
223
  }
222
224
  throw error;
223
225
  }
@@ -233,43 +235,45 @@ function opacityLiteralOrThrow(value, attr) {
233
235
  * @param element The <TouchableOpacity>.
234
236
  * @param nodeId The node's variable.
235
237
  * @param staticAssigns The style's constant writes.
236
- * @param dynAssigns The style's state-driven writes.
238
+ * @param dynamicAssigns The style's state-driven writes.
237
239
  * @param binds The style's animated-value binds.
238
- * @param out Everything emitted so far.
240
+ * @param output Everything emitted so far.
239
241
  * @param scope Compile-time constants in reach.
240
242
  *
241
243
  * @returns The opacity bind, and the fade to run on onPressIn and the one to run on onPressOut.
242
244
  */
243
- function touchablePressFades(element, nodeId, staticAssigns, dynAssigns, binds, out, scope) {
245
+ function touchablePressFades(element, nodeId, staticAssigns, dynamicAssigns, binds, output, scope) {
244
246
  // The press feedback owns the node's opacity, so the style may not animate it or drive it from state.
245
247
  const hasAnimatedOpacity = binds.some(bind => bind.prop === 'ER_PROP_OPACITY');
246
248
  if (hasAnimatedOpacity ||
247
- dynAssigns.some(assign => assign.field === 'opacity')) {
249
+ dynamicAssigns.some(assign => assign.field === 'opacity')) {
248
250
  throw aotError(`AOT: <TouchableOpacity> cannot take ${hasAnimatedOpacity ? 'an Animated' : 'a state-driven'} opacity`, "the press feedback owns this node's opacity — a second writer does not blend with " +
249
251
  'it, it races it. To animate opacity yourself, use <Pressable>: the dim is just ' +
250
252
  'onPressIn/onPressOut driving an Animated.Value (see TouchableOpacity.js for the ' +
251
253
  'whole of it).');
252
254
  }
253
- // lowerStyle scaled static opacity to 0–255 (the resting value); leave a NaN one for the C compiler to reject.
255
+ // lowerStyle scaled static opacity to 0–255 (the resting value); a NaN one is refused later.
254
256
  const opacityAssign = staticAssigns.find(assign => assign.field === 'opacity');
255
- const restingRaw = opacityAssign ? Number(opacityAssign.expr) / 255 : 1;
257
+ const restingRaw = opacityAssign
258
+ ? Number(opacityAssign.value) / OPACITY_OPAQUE
259
+ : 1;
256
260
  const restingOpacity = Number.isFinite(restingRaw) ? restingRaw : 1;
257
261
  // The dim target: a folded activeOpacity, or RN's default.
258
- const activeAttr = namedAttr(element.openingElement, 'activeOpacity');
259
- const activeOpacity = activeAttr
260
- ? opacityLiteralOrThrow(evalStaticOrThrow(attrExpr(activeAttr), scope, 'AOT: <TouchableOpacity activeOpacity> must be a compile-time constant', 'the dim target is baked into the generated handler, so it cannot come from state.'), activeAttr)
262
+ const activeAttribute = namedAttr(element.openingElement, 'activeOpacity');
263
+ const activeOpacity = activeAttribute
264
+ ? opacityLiteralOrThrow(evalStaticOrThrow(attrExpr(activeAttribute), scope, 'AOT: <TouchableOpacity activeOpacity> must be a compile-time constant', 'the dim target is baked into the handler, so it cannot come from state.'), activeAttribute)
261
265
  : TOUCHABLE_ACTIVE_OPACITY;
262
266
  // Bind a fresh animated value, starting at rest, to the node's opacity.
263
- const cVar = `s_av_press_${nodeId}`;
267
+ const slotName = `anim_press_${nodeId}`;
264
268
  checkNumber(restingOpacity);
265
- out.childAnimations.push({ cVar, initial: restingOpacity });
269
+ output.childAnimations.push({ slotName, initial: restingOpacity });
266
270
  // Each fade is one timing animation of that value.
267
271
  return {
268
- bind: { cVar, prop: 'ER_PROP_OPACITY' },
272
+ bind: { slotName, prop: 'ER_PROP_OPACITY' },
269
273
  fades: {
270
- onPressIn: { value: cVar, opacity: activeOpacity, durationMs: 0 },
274
+ onPressIn: { value: slotName, opacity: activeOpacity, durationMs: 0 },
271
275
  onPressOut: {
272
- value: cVar,
276
+ value: slotName,
273
277
  opacity: restingOpacity,
274
278
  durationMs: TOUCHABLE_RESTORE_MS,
275
279
  },
@@ -297,7 +301,7 @@ function applyShow(node, show) {
297
301
  value: {
298
302
  kind: 'whileShown',
299
303
  show,
300
- value: { kind: 'constant', code: visible.expr },
304
+ value: { kind: 'constant', value: visible.value },
301
305
  },
302
306
  });
303
307
  return;
@@ -309,77 +313,86 @@ function applyShow(node, show) {
309
313
  * Lowers an event prop's function to a handler: a useCallback compiles once per instance and is shared, a
310
314
  * callback prop compiles in its caller's environment, and an inline function compiles where it is.
311
315
  *
312
- * @param attr The event prop.
313
- * @param out Everything emitted so far.
314
- * @param env The expression environment.
316
+ * @param attribute The event prop.
317
+ * @param output Everything emitted so far.
318
+ * @param environment The expression environment.
315
319
  * @param state The component's state table.
316
320
  *
317
321
  * @returns The handler's name.
318
322
  */
319
- export function lowerEventHandler(attr, out, env, state) {
320
- const fn = attrExpr(attr);
321
- const layout = attr.name.name === 'onLayout';
322
- if (fn.type === 'Identifier' && env.callbacks?.has(fn.name)) {
323
+ export function lowerEventHandler(attribute, output, environment, state) {
324
+ const handlerExpression = attrExpr(attribute);
325
+ const layout = attribute.name.name === 'onLayout';
326
+ if (handlerExpression.type === 'Identifier' &&
327
+ environment.callbacks?.has(handlerExpression.name)) {
323
328
  // A useCallback compiles to one shared handler, namespaced by cbPrefix so each child instance gets its own.
324
329
  // Its onLayout use gets a handler of its own, since only that event carries the layout rect. The key's
325
- // `layout:` and the name's `er_cbl_` can't come from an identifier, so they never meet another callback.
326
- const callbackKey = `${env.cbPrefix ?? ''}${fn.name}`;
330
+ // `layout:` and the name's `layout_callback_` can't come from an identifier, so they never meet another callback.
331
+ const callbackKey = `${environment.callbackPrefix ?? ''}${handlerExpression.name}`;
327
332
  const emittedKey = layout ? `layout:${callbackKey}` : callbackKey;
328
- let handlerName = out.cbEmitted.get(emittedKey);
333
+ let handlerName = output.emittedCallbacks.get(emittedKey);
329
334
  if (!handlerName) {
330
- handlerName = `${layout ? 'er_cbl_' : 'er_cb_'}${callbackKey}`;
331
- out.cbEmitted.set(emittedKey, handlerName);
332
- out.handlers.push({
335
+ handlerName = `${layout ? 'layout_callback_' : 'callback_'}${callbackKey}`;
336
+ output.emittedCallbacks.set(emittedKey, handlerName);
337
+ output.handlers.push({
333
338
  kind: 'callback',
334
339
  name: handlerName,
335
- callback: lowerHandler(env.callbacks.get(fn.name), { ...env, layout }, state, out),
340
+ callback: lowerHandler(environment.callbacks.get(handlerExpression.name), { ...environment, layout }, state, output),
336
341
  });
337
342
  }
338
343
  return handlerName;
339
344
  }
340
- const handlerName = `er_handler_${out.handlers.length}`;
341
- if (fn.type === 'Identifier' && env.fnProps?.has(fn.name)) {
345
+ const handlerName = `handler_${output.handlers.length}`;
346
+ if (handlerExpression.type === 'Identifier' &&
347
+ environment.functionProps?.has(handlerExpression.name)) {
342
348
  // Inline a callback prop's function, compiled in the caller's env/state so its setters and locals resolve.
343
- const callbackProp = env.fnProps.get(fn.name);
344
- out.handlers.push({
349
+ const callbackProp = environment.functionProps.get(handlerExpression.name);
350
+ output.handlers.push({
345
351
  kind: 'callback',
346
352
  name: handlerName,
347
- callback: lowerHandler(callbackProp.node, { ...callbackProp.env, layout }, callbackProp.state, out),
353
+ callback: lowerHandler(callbackProp.node, { ...callbackProp.environment, layout }, callbackProp.state, output),
348
354
  });
349
355
  }
350
- else if (isFn(fn)) {
351
- out.handlers.push({
356
+ else if (isFn(handlerExpression)) {
357
+ output.handlers.push({
352
358
  kind: 'callback',
353
359
  name: handlerName,
354
- callback: lowerHandler(fn, { ...env, layout }, state, out),
360
+ callback: lowerHandler(handlerExpression, { ...environment, layout }, state, output),
355
361
  });
356
362
  }
357
363
  else {
358
- throw aotError(`AOT: ${attr.name.name} must be an inline function, a useCallback, or a callback prop`, `pass an inline arrow (onPress={() => setX(…)}), a useCallback identifier, or a ` +
364
+ throw aotError(`AOT: ${attribute.name.name} must be an inline function, a useCallback, or a callback prop`, `pass an inline arrow (onPress={() => setX(…)}), a useCallback identifier, or a ` +
359
365
  `function prop received by this component.`);
360
366
  }
361
367
  return handlerName;
362
368
  }
363
369
  /**
364
370
  * Lowers one JSX element to its engine node (see emitNode, the located entry point): dispatches the typed
365
- * elements (Svg, Switch, Dial, TextInput, ActivityIndicator, Modal, FlatList) and function components to
366
- * their emitters, and builds a generic host node (View / Text / Pressable / TouchableOpacity / Image /
371
+ * elements (Svg, Switch, Dial, TextInput, ActivityIndicator, Modal), the wrappers (FlatList, SectionList,
372
+ * Button, ImageBackground) and function components to their emitters, and builds a generic host node (View / Text / Pressable / TouchableOpacity / Image /
367
373
  * ScrollView) itself: style, text, events, refs, and children.
368
374
  *
369
375
  * @param element The element.
370
376
  * @param scope Compile-time constants in reach.
371
- * @param out Everything emitted so far.
372
- * @param env The expression environment.
377
+ * @param output Everything emitted so far.
378
+ * @param environment The expression environment.
373
379
  * @param state The component's state table.
374
- * @param opts How the element is placed.
380
+ * @param options How the element is placed.
375
381
  *
376
382
  * @returns What the element lowered to.
377
383
  */
378
- function emitNodeImpl(element, scope, out, env, state, opts = {}) {
384
+ function emitNodeImpl(element, scope, output, environment, state, options = {}) {
385
+ // A context's provider stands for the one element it wraps.
386
+ const context = providedContextOf(element, environment);
387
+ if (context) {
388
+ return emitProvider(element, context, scope, output, environment, state, options);
389
+ }
379
390
  // Refuse any prop the element does not declare, whatever its value, then drop the no-ops and the props that
380
391
  // fold to undefined before dispatch.
392
+ // A component in this file wins over a built-in that is no host node, as its binding would in JS.
381
393
  const tag = resolveTag(element.openingElement);
382
- const spec = elementSpec(tag);
394
+ const localComponent = !NODE_TYPES[tag] && output.components.has(tag);
395
+ const spec = localComponent ? undefined : elementSpec(tag);
383
396
  if (spec) {
384
397
  checkAttributes(spec, element.openingElement);
385
398
  if (spec.children === 'none') {
@@ -387,45 +400,48 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
387
400
  }
388
401
  element = withoutPlatformNoOps(spec, element);
389
402
  }
390
- element = omitUndefinedAttrs(element, scope, env);
403
+ element = omitUndefinedAttrs(element, scope, environment);
391
404
  const typed = (node) => {
392
- if (opts.show) {
393
- applyShow(node, opts.show);
405
+ if (options.show) {
406
+ applyShow(node, options.show);
394
407
  }
395
408
  return { kind: 'node', id: node.id, node };
396
409
  };
410
+ if (localComponent) {
411
+ return emitComponent(element, scope, output, environment, state, options);
412
+ }
397
413
  if (tag === 'Svg') {
398
- return typed(emitSvg(element, scope, out, env, state, opts));
414
+ return typed(emitSvg(element, scope, output, environment, state, options));
399
415
  }
400
416
  if (tag === 'Switch') {
401
- return typed(emitSwitch(element, scope, out, env, state));
417
+ return typed(emitSwitch(element, scope, output, environment, state));
402
418
  }
403
419
  if (tag === 'Dial')
404
- return typed(emitDial(element, scope, out, env, state));
420
+ return typed(emitDial(element, scope, output, environment, state));
405
421
  if (tag === 'TextInput') {
406
- return typed(emitTextInput(element, scope, out, env, state));
422
+ return typed(emitTextInput(element, scope, output, environment, state));
407
423
  }
408
424
  if (tag === 'ActivityIndicator') {
409
- return typed(emitActivityIndicator(element, scope, out, env));
425
+ return typed(emitActivityIndicator(element, scope, output, environment));
410
426
  }
411
427
  if (tag === 'Modal') {
412
- return typed(emitModal(element, scope, out, env, state));
428
+ return typed(emitModal(element, scope, output, environment, state));
413
429
  }
414
430
  if (tag === 'FlatList') {
415
- return emitFlatList(element, scope, out, env, state, opts);
431
+ return emitFlatList(element, scope, output, environment, state, options);
432
+ }
433
+ if (tag === 'SectionList') {
434
+ return emitSectionList(element, scope, output, environment, state, options);
435
+ }
436
+ if (tag === 'Button') {
437
+ return emitButton(element, scope, output, environment, state, options);
416
438
  }
417
- // Anything else must be a host node or a function component defined in this file.
439
+ if (tag === 'ImageBackground') {
440
+ return emitImageBackground(element, scope, output, environment, state, options);
441
+ }
442
+ // Anything else must be a host node.
418
443
  const nodeType = NODE_TYPES[tag];
419
444
  if (!nodeType) {
420
- if (out.components.has(tag)) {
421
- return emitComponent(element, scope, out, env, state, opts);
422
- }
423
- // A package export with no lowering yet gets its own error; "unknown element" would read like a typo.
424
- const replacement = FLOW_A_ONLY_COMPONENTS[tag];
425
- if (replacement) {
426
- throw aotError(`AOT: <${tag}> is not supported in Flow B yet`, `it renders in Flow A (the simulator and the QuickJS runtime) but the AOT has no ` +
427
- `lowering for it. Write it out by hand for the device build: ${replacement}`);
428
- }
429
445
  throw aotError(`AOT: unknown element <${tag}> (not a built-in or a component in this file)`, `<${tag}> must be a built-in (View / Text / Pressable / TouchableOpacity / Image / ` +
430
446
  `ScrollView / Svg + shapes / Animated.*) or a function component defined in THIS ` +
431
447
  `file. Check the import / spelling or define the component here.`);
@@ -440,7 +456,7 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
440
456
  continue;
441
457
  let panResponder;
442
458
  try {
443
- panResponder = panSpreadTarget(spread.argument, env);
459
+ panResponder = panSpreadTarget(spread.argument, environment);
444
460
  }
445
461
  catch (error) {
446
462
  if (spread.loc && !error.aotLoc) {
@@ -462,62 +478,68 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
462
478
  throw spreadError;
463
479
  }
464
480
  // Allocate the node and collect its style, text content, and image attributes.
465
- const nodeId = `n${out.allocateNodeId()}`;
466
- const { staticAssigns, dynAssigns, binds } = collectStyleAssigns(element.openingElement, scope, env, spec);
481
+ const nodeId = `n${output.allocateNodeId()}`;
482
+ const { staticAssigns, dynamicAssigns, binds } = collectStyleAssigns(element.openingElement, scope, environment, spec);
467
483
  if (tag === 'Text') {
468
484
  staticAssigns.push(...lowerTextTruncation(element.openingElement, scope));
469
485
  }
470
486
  // A <Text> with a nested <Text> becomes inline SPANS; otherwise a single (possibly dynamic) string.
471
- const spans = tag === 'Text' ? collectTextSpans(element.children, scope, env) : null;
487
+ const spans = tag === 'Text'
488
+ ? collectTextSpans(element.children, scope, environment)
489
+ : null;
472
490
  const text = tag === 'Text' && !spans
473
- ? lowerNodeText(element.children, scope, env)
491
+ ? lowerNodeText(element.children, scope, environment)
474
492
  : null;
475
493
  if (text) {
476
494
  checkEngineString(constantText(text), 'ER_TEXT_MAX', 'a <Text>');
477
495
  }
478
496
  // An <Image>'s resize/tint are static, so fold them into staticAssigns for both the static and dynamic paths.
479
- const image = tag === 'Image' ? resolveImageAttrs(element, env, out) : null;
497
+ const image = tag === 'Image' ? resolveImageAttrs(element, environment, output) : null;
480
498
  checkEngineString(image?.imageName ?? null, 'ER_IMAGE_NAME_MAX', `image name "${image?.imageName}"`);
481
499
  if (image?.resizeMode) {
482
- staticAssigns.push({ field: 'resize_mode', expr: image.resizeMode });
500
+ staticAssigns.push({ field: 'resize_mode', value: image.resizeMode });
483
501
  }
484
502
  if (image?.tintColor) {
485
- staticAssigns.push({ field: 'tint_color', expr: image.tintColor });
503
+ staticAssigns.push({ field: 'tint_color', value: image.tintColor });
486
504
  }
487
505
  // `visible` is `display` as in Flow A (style `display` wins); not in collectStyleAssigns, which <Modal> shares.
488
- const visibleAttr = element.openingElement.attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'visible');
489
- if (visibleAttr &&
506
+ const visibleAttribute = element.openingElement.attributes.find((attribute) => attribute.type === 'JSXAttribute' &&
507
+ attribute.name &&
508
+ attribute.name.name === 'visible');
509
+ if (visibleAttribute &&
490
510
  !staticAssigns.some(assign => assign.field === 'display') &&
491
- !dynAssigns.some(assign => assign.field === 'display')) {
492
- const expr = visibleAttr.value == null ? null : attrExpr(visibleAttr); // bare `visible` === true
493
- if (expr == null) {
494
- staticAssigns.push({ field: 'display', expr: 'ER_DISPLAY_FLEX' });
511
+ !dynamicAssigns.some(assign => assign.field === 'display')) {
512
+ const expression = visibleAttribute.value == null ? null : attrExpr(visibleAttribute); // bare `visible` === true
513
+ if (expression == null) {
514
+ staticAssigns.push({ field: 'display', value: 'ER_DISPLAY_FLEX' });
495
515
  }
496
516
  else {
497
517
  try {
498
518
  staticAssigns.push({
499
519
  field: 'display',
500
- expr: evalStatic(expr, scope) ? 'ER_DISPLAY_FLEX' : 'ER_DISPLAY_NONE',
520
+ value: evalStatic(expression, scope)
521
+ ? 'ER_DISPLAY_FLEX'
522
+ : 'ER_DISPLAY_NONE',
501
523
  });
502
524
  }
503
525
  catch {
504
- dynAssigns.push({
526
+ dynamicAssigns.push({
505
527
  field: 'display',
506
- value: { kind: 'visible', value: lowerExpr(expr, env) },
528
+ value: { kind: 'visible', value: lowerExpr(expression, environment) },
507
529
  });
508
530
  }
509
531
  }
510
532
  }
511
533
  // delayLongPress must fold since it is baked into props; 0 becomes 1 ms because 0 means "default" to the engine.
512
- const delayAttr = namedAttr(element.openingElement, 'delayLongPress');
513
- if (delayAttr) {
534
+ const delayAttribute = namedAttr(element.openingElement, 'delayLongPress');
535
+ if (delayAttribute) {
514
536
  const delayError = aotError(`AOT: <${tag} delayLongPress> must fold to a number`, 'pass a literal or a module-level constant in milliseconds, e.g. delayLongPress={800}.');
515
- if (delayAttr.value == null) {
537
+ if (delayAttribute.value == null) {
516
538
  throw delayError;
517
539
  }
518
540
  let delayMs;
519
541
  try {
520
- delayMs = Number(evalStatic(attrExpr(delayAttr), scope));
542
+ delayMs = Number(evalStatic(attrExpr(delayAttribute), scope));
521
543
  }
522
544
  catch {
523
545
  throw delayError;
@@ -527,19 +549,19 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
527
549
  }
528
550
  staticAssigns.push({
529
551
  field: 'long_press_ms',
530
- expr: String(Math.min(65535, Math.max(1, Math.round(delayMs)))),
552
+ value: Math.min(MAX_LONG_PRESS_MS, Math.max(1, Math.round(delayMs))),
531
553
  });
532
554
  }
533
- // A state-driven conditional flips `display` in app_update; pushed last to beat the element's visible/display.
534
- if (opts.show) {
535
- dynAssigns.push({
555
+ // A state-driven conditional flips `display` in the update; pushed last to beat the element's visible/display.
556
+ if (options.show) {
557
+ dynamicAssigns.push({
536
558
  field: 'display',
537
- value: { kind: 'shown', show: opts.show },
559
+ value: { kind: 'shown', show: options.show },
538
560
  });
539
561
  }
540
562
  // <TouchableOpacity>'s own opacity binding, on top of any the style asked for.
541
563
  const press = tag === 'TouchableOpacity' && !isPressDisabled
542
- ? touchablePressFades(element, nodeId, staticAssigns, dynAssigns, binds, out, scope)
564
+ ? touchablePressFades(element, nodeId, staticAssigns, dynamicAssigns, binds, output, scope)
543
565
  : null;
544
566
  // A host node wires its binds (the press feedback's last), then its refs, events and PanResponders.
545
567
  const wiring = binds.map((bind, index) => ({
@@ -550,18 +572,19 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
550
572
  if (press) {
551
573
  wiring.push({ kind: 'bind', bind: press.bind, index: binds.length });
552
574
  }
553
- for (const slot of lowerRefBinds(element.openingElement, env)) {
575
+ for (const slot of lowerRefBinds(element.openingElement, environment)) {
554
576
  wiring.push({ kind: 'ref', slot });
555
577
  }
556
578
  const node = {
557
579
  id: nodeId,
580
+ location: currentLoc(),
558
581
  type: nodeType,
559
582
  constantProps: staticAssigns,
560
- stateProps: dynAssigns,
583
+ stateProps: dynamicAssigns,
561
584
  placeholder: null,
562
585
  text,
563
- image: image?.imageNameDyn != null
564
- ? { kind: 'value', value: image.imageNameDyn }
586
+ image: image?.imageNameDynamic != null
587
+ ? { kind: 'value', value: image.imageNameDynamic }
565
588
  : image?.imageName != null
566
589
  ? { kind: 'static', name: image.imageName }
567
590
  : null,
@@ -571,29 +594,29 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
571
594
  };
572
595
  // Compile each event prop into a handler; a disabled one drops its press events.
573
596
  const fadesWired = new Set();
574
- for (const attr of element.openingElement.attributes) {
575
- if (attr.type !== 'JSXAttribute')
597
+ for (const attribute of element.openingElement.attributes) {
598
+ if (attribute.type !== 'JSXAttribute')
576
599
  continue;
577
- const eventType = EVENT_TYPES[attr.name.name];
600
+ const eventType = EVENT_TYPES[attribute.name.name];
578
601
  if (!eventType)
579
602
  continue;
580
603
  if (isPressDisabled &&
581
- PRESS_EVENTS.has(attr.name.name)) {
604
+ PRESS_EVENTS.has(attribute.name.name)) {
582
605
  continue;
583
606
  }
584
- let handlerName = lowerEventHandler(attr, out, env, state);
607
+ let handlerName = lowerEventHandler(attribute, output, environment, state);
585
608
  // Wrap the app's press-in/out with the fade; prepending would dim every other element sharing a useCallback.
586
- const pressFade = press?.fades[attr.name.name];
609
+ const pressFade = press?.fades[attribute.name.name];
587
610
  if (pressFade) {
588
- const wrapperName = `er_handler_${out.handlers.length}`;
589
- out.handlers.push({
611
+ const wrapperName = `handler_${output.handlers.length}`;
612
+ output.handlers.push({
590
613
  kind: 'pressFade',
591
614
  name: wrapperName,
592
615
  fade: pressFade,
593
616
  then: handlerName,
594
617
  });
595
618
  handlerName = wrapperName;
596
- fadesWired.add(attr.name.name);
619
+ fadesWired.add(attribute.name.name);
597
620
  }
598
621
  wiring.push({ kind: 'event', event: eventType, handler: handlerName });
599
622
  }
@@ -602,8 +625,8 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
602
625
  for (const eventName of ['onPressIn', 'onPressOut']) {
603
626
  if (fadesWired.has(eventName))
604
627
  continue;
605
- const fadeHandlerName = `er_handler_${out.handlers.length}`;
606
- out.handlers.push({
628
+ const fadeHandlerName = `handler_${output.handlers.length}`;
629
+ output.handlers.push({
607
630
  kind: 'pressFade',
608
631
  name: fadeHandlerName,
609
632
  fade: press.fades[eventName],
@@ -620,13 +643,13 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
620
643
  for (const panResponder of panSpreads) {
621
644
  wiring.push({
622
645
  kind: 'responder',
623
- pan: emitPanResponder(panResponder, out, env, state),
646
+ pan: emitPanResponder(panResponder, output, environment, state),
624
647
  });
625
648
  }
626
649
  checkInterpolations(node);
627
650
  // A <Text>'s children are its text, already consumed above.
628
651
  if (tag !== 'Text') {
629
- node.children = emitChildren(element.children, scope, out, env, state);
652
+ node.children = emitChildren(element.children, scope, output, environment, state);
630
653
  }
631
654
  return { kind: 'node', id: nodeId, node };
632
655
  }
@@ -640,24 +663,24 @@ function emitNodeImpl(element, scope, out, env, state, opts = {}) {
640
663
  *
641
664
  * @param element The element.
642
665
  * @param scope Compile-time constants in reach.
643
- * @param env The expression environment.
666
+ * @param environment The expression environment.
644
667
  *
645
668
  * @returns The element, or a copy of it without those attributes.
646
669
  */
647
- function omitUndefinedAttrs(element, scope, env) {
648
- const attrs = element.openingElement.attributes;
670
+ function omitUndefinedAttrs(element, scope, environment) {
671
+ const attributes = element.openingElement.attributes;
649
672
  // Built lazily: the runtime-aware scope plus the global `undefined`, so `SHOW ? true : undefined` folds too.
650
673
  let foldingScope = null;
651
- const keptAttrs = attrs.filter(attr => {
652
- if (attr.type !== 'JSXAttribute' ||
653
- attr.value?.type !== 'JSXExpressionContainer') {
674
+ const keptAttributes = attributes.filter(attribute => {
675
+ if (attribute.type !== 'JSXAttribute' ||
676
+ attribute.value?.type !== 'JSXExpressionContainer') {
654
677
  return true;
655
678
  }
656
- foldingScope ??= Object.assign(Object.create(foldScope(env, scope)), {
679
+ foldingScope ??= Object.assign(Object.create(foldScope(environment, scope)), {
657
680
  undefined,
658
681
  });
659
682
  try {
660
- const value = evalStatic(attr.value.expression, foldingScope, 'boot');
683
+ const value = evalStatic(attribute.value.expression, foldingScope, 'boot');
661
684
  if (buildValueOf(value) !== undefined)
662
685
  return true;
663
686
  foldBoot(value); // undefined on this panel only: omitting it assumes the panel
@@ -667,26 +690,26 @@ function omitUndefinedAttrs(element, scope, env) {
667
690
  return true; // not a compile-time value — its reader decides
668
691
  }
669
692
  });
670
- return keptAttrs.length === attrs.length
693
+ return keptAttributes.length === attributes.length
671
694
  ? element
672
695
  : {
673
696
  ...element,
674
- openingElement: { ...element.openingElement, attributes: keptAttrs },
697
+ openingElement: { ...element.openingElement, attributes: keptAttributes },
675
698
  };
676
699
  }
677
700
  /**
678
- * Refuses an interpolation table holding a number C cannot write, at the element that binds it rather than when
701
+ * Refuses an interpolation table holding a number that isn't finite, at the element that binds it rather than when
679
702
  * its build lines are written.
680
703
  *
681
704
  * @param node The node.
682
705
  */
683
706
  export function checkInterpolations(node) {
684
707
  for (const wire of node.wiring) {
685
- if (wire.kind !== 'bind' || !wire.bind.interp)
708
+ if (wire.kind !== 'bind' || !wire.bind.interpolation)
686
709
  continue;
687
710
  for (const point of [
688
- ...wire.bind.interp.input,
689
- ...wire.bind.interp.output,
711
+ ...wire.bind.interpolation.input,
712
+ ...wire.bind.interpolation.output,
690
713
  ]) {
691
714
  checkNumber(point);
692
715
  }