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
@@ -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
  }
@@ -20,7 +20,7 @@ import { aotError } from '../diagnostics.mjs';
20
20
  import { at } from './props.mjs';
21
21
  import { evalStatic, evalStaticOr } from '../static-eval.mjs';
22
22
  import { lowerExpr } from '../expressions.mjs';
23
- import { attrExpr, argbLiteral } from '../style-text.mjs';
23
+ import { attrExpr, argbValue } from '../style-text.mjs';
24
24
  /*----------------------------------------------------------------------------------------------------------------------
25
25
  - Constants
26
26
  ---------------------------------------------------------------------------------------------------------------------*/
@@ -40,18 +40,18 @@ const RESIZE_MODES = {
40
40
  * the const scope as their asset-name string, so this folds `wxSun`, `item.icon` (unrolled map), and static
41
41
  * ternaries; `{ uri }` is the explicit remote-shape escape.
42
42
  *
43
- * @param expr The source expression, if there is one.
44
- * @param env The expression environment.
43
+ * @param expression The source expression, if there is one.
44
+ * @param environment The expression environment.
45
45
  *
46
46
  * @returns The asset's name, or null when the source does not fold.
47
47
  */
48
- export function imageNameFromSource(expr, env) {
48
+ export function imageNameFromSource(expression, environment) {
49
49
  // No source expression was provided.
50
- if (!expr)
50
+ if (!expression)
51
51
  return null;
52
52
  // Try to resolve the source as a compile-time constant.
53
53
  try {
54
- const value = evalStatic(expr, env.consts ?? {});
54
+ const value = evalStatic(expression, environment.constants ?? {});
55
55
  if (typeof value === 'string')
56
56
  return value;
57
57
  }
@@ -59,8 +59,8 @@ export function imageNameFromSource(expr, env) {
59
59
  /* not a compile-time constant — fall through to {uri}, else dynamic */
60
60
  }
61
61
  // Handle React Native-style object sources: source={{ uri: 'asset_name' }}.
62
- if (expr.type === 'ObjectExpression') {
63
- const uri = expr.properties.find((property) => property.type === 'ObjectProperty' &&
62
+ if (expression.type === 'ObjectExpression') {
63
+ const uri = expression.properties.find((property) => property.type === 'ObjectProperty' &&
64
64
  (property.key.name === 'uri' ||
65
65
  property.key.value === 'uri'));
66
66
  if (uri?.value?.type === 'StringLiteral')
@@ -70,82 +70,83 @@ export function imageNameFromSource(expr, env) {
70
70
  }
71
71
  /**
72
72
  * Resolves an <Image>'s source/imageName/resizeMode/tintColor for the node props (static name, a dynamic
73
- * name expr, resize mode, tint). Records baking intent in `out`: a static name that matches an import is
74
- * marked used (out.images); a dynamic source flips out.bakeAllImages (its asset can't be enumerated). So
73
+ * name expr, resize mode, tint). Records baking intent in `output`: a static name that matches an import is
74
+ * marked used (output.images); a dynamic source flips output.bakeAllImages (its asset can't be enumerated). So
75
75
  * only REACHED images are baked — an import used solely in a folded-away branch costs no flash.
76
76
  *
77
77
  * @param element The <Image>.
78
- * @param env The expression environment.
79
- * @param out Everything emitted so far.
78
+ * @param environment The expression environment.
79
+ * @param output Everything emitted so far.
80
80
  *
81
81
  * @returns The resolved props.
82
82
  */
83
- export function resolveImageAttrs(element, env, out) {
83
+ export function resolveImageAttrs(element, environment, output) {
84
84
  // Find the image source prop, preferring imageName over source.
85
- const attrs = element.openingElement.attributes;
86
- const find = (attrName) => attrs.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === attrName);
87
- const imAttr = find('imageName');
88
- const srcAttr = find('source');
89
- const srcExpr = imAttr
90
- ? attrExpr(imAttr)
91
- : srcAttr
92
- ? attrExpr(srcAttr)
85
+ const attributes = element.openingElement.attributes;
86
+ const find = (attributeName) => attributes.find((attribute) => attribute.type === 'JSXAttribute' &&
87
+ attribute.name.name === attributeName);
88
+ const imageAttribute = find('imageName');
89
+ const sourceAttribute = find('source');
90
+ const sourceExpression = imageAttribute
91
+ ? attrExpr(imageAttribute)
92
+ : sourceAttribute
93
+ ? attrExpr(sourceAttribute)
93
94
  : null;
94
95
  let imageName = null; // static asset name (a literal), OR …
95
- let imageNameDyn = null; // … a runtime string (a list-item field / state) set in app_update.
96
+ let imageNameDynamic = null; // … a runtime string (a list-item field / state) set in the update.
96
97
  // Resolve static sources immediately and mark imported assets for baking.
97
- if (srcExpr) {
98
- imageName = imageNameFromSource(srcExpr, env);
98
+ if (sourceExpression) {
99
+ imageName = imageNameFromSource(sourceExpression, environment);
99
100
  if (imageName != null) {
100
- const path = env.imageNames?.get(imageName); // a baked import (vs. a bare {uri} name the app supplies)
101
+ const path = environment.imageNames?.get(imageName); // a baked import (vs. a bare {uri} name the app supplies)
101
102
  if (path) {
102
- out.images.set(imageName, path);
103
+ output.images.set(imageName, path);
103
104
  }
104
105
  }
105
106
  else {
106
107
  // Fall back to a dynamic runtime image name when the source cannot be folded.
107
108
  // Emits it as a runtime string. The engine resolves it against the image registry by name each frame,
108
- // so the candidate assets must be baked. They can't be enumerated, so bake them ALL (out.bakeAllImages).
109
+ // so the candidate assets must be baked. They can't be enumerated, so bake them ALL (output.bakeAllImages).
109
110
  // Only triggered when a dynamic source is actually REACHED.
110
- out.bakeAllImages = true;
111
- const nameExpr = lowerExpr(srcExpr, env);
112
- if (nameExpr.type.kind !== 'string') {
113
- const err = aotError('AOT: an <Image source> must resolve to an asset NAME (a string)', "use an imported image (`import logo from './logo.png'` → source={logo}), " +
111
+ output.bakeAllImages = true;
112
+ const nameExpression = lowerExpr(sourceExpression, environment);
113
+ if (nameExpression.type.kind !== 'string') {
114
+ const error = aotError('AOT: an <Image source> must resolve to an asset NAME (a string)', "use an imported image (`import logo from './logo.png'` → source={logo}), " +
114
115
  "a string asset name, source={{ uri: 'name' }}, or a string-valued " +
115
116
  'state / list-item field for a dynamic source.');
116
- if (srcExpr.loc) {
117
- err.aotLoc = srcExpr.loc.start;
117
+ if (sourceExpression.loc) {
118
+ error.aotLoc = sourceExpression.loc.start;
118
119
  }
119
120
  {
120
- throw err;
121
+ throw error;
121
122
  }
122
123
  }
123
- imageNameDyn = nameExpr;
124
+ imageNameDynamic = nameExpression;
124
125
  }
125
126
  }
126
127
  // Resolve the optional resize mode and validate it against the supported engine modes.
127
128
  let resizeMode = null;
128
- const rmAttr = find('resizeMode');
129
- if (rmAttr) {
130
- const rm = evalStaticOr(attrExpr(rmAttr), env, null);
131
- resizeMode = RESIZE_MODES[rm];
129
+ const resizeModeAttribute = find('resizeMode');
130
+ if (resizeModeAttribute) {
131
+ const resizeModeValue = evalStaticOr(attrExpr(resizeModeAttribute), environment, null);
132
+ resizeMode = RESIZE_MODES[resizeModeValue];
132
133
  if (!resizeMode) {
133
- const e = aotError(`AOT: unsupported <Image resizeMode> "${rm}"`, `resizeMode must be one of: ${Object.keys(RESIZE_MODES).join(' / ')}.`);
134
- if (rmAttr.loc) {
135
- e.aotLoc = rmAttr.loc.start;
134
+ const error = aotError(`AOT: unsupported <Image resizeMode> "${resizeModeValue}"`, `resizeMode must be one of: ${Object.keys(RESIZE_MODES).join(' / ')}.`);
135
+ if (resizeModeAttribute.loc) {
136
+ error.aotLoc = resizeModeAttribute.loc.start;
136
137
  }
137
- throw e;
138
+ throw error;
138
139
  }
139
140
  }
140
141
  // Resolve the optional tint color into the ARGB literal expected by the engine.
141
142
  let tintColor = null;
142
- const tcAttr = find('tintColor');
143
- if (tcAttr) {
144
- const tc = evalStaticOr(attrExpr(tcAttr), env, null);
145
- if (typeof tc !== 'string' && typeof tc !== 'number') {
146
- throw at(aotError('AOT: <Image tintColor> must be a constant color', 'the tint is baked into the node when it is built; a state-driven one is not lowered yet.'), tcAttr);
143
+ const tintColorAttribute = find('tintColor');
144
+ if (tintColorAttribute) {
145
+ const tintValue = evalStaticOr(attrExpr(tintColorAttribute), environment, null);
146
+ if (typeof tintValue !== 'string' && typeof tintValue !== 'number') {
147
+ throw at(aotError('AOT: <Image tintColor> must be a constant color', 'the tint is baked into the node when it is built; a state-driven one is not lowered yet.'), tintColorAttribute);
147
148
  }
148
- tintColor = argbLiteral(tc);
149
+ tintColor = argbValue(tintValue);
149
150
  }
150
- return { imageName, imageNameDyn, resizeMode, tintColor };
151
+ return { imageName, imageNameDynamic, resizeMode, tintColor };
151
152
  }
@@ -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, styleWrites, collectStyleAssigns } from '../style-text.mjs';
@@ -30,13 +30,13 @@ import { at, elementSpec } from './props.mjs';
30
30
  // Overlay defaults: absolute, fill the parent via four 0 insets (the robust "stretch" for an absolute
31
31
  // node), center the content. The user's style overrides any of these.
32
32
  const DEFAULTS = [
33
- ['position', 'ER_POS_ABSOLUTE'],
34
- ['left', '0'],
35
- ['top', '0'],
36
- ['right', '0'],
37
- ['bottom', '0'],
38
- ['align_items', 'ER_ALIGN_CENTER'],
39
- ['justify_content', 'ER_JUSTIFY_CENTER'],
33
+ { field: 'position', value: 'ER_POSITION_ABSOLUTE' },
34
+ { field: 'left', value: 0 },
35
+ { field: 'top', value: 0 },
36
+ { field: 'right', value: 0 },
37
+ { field: 'bottom', value: 0 },
38
+ { field: 'align_items', value: 'ER_ALIGN_CENTER' },
39
+ { field: 'justify_content', value: 'ER_JUSTIFY_CENTER' },
40
40
  ];
41
41
  /*----------------------------------------------------------------------------------------------------------------------
42
42
  - Implementation
@@ -50,45 +50,45 @@ const DEFAULTS = [
50
50
  *
51
51
  * @param element The <Modal>.
52
52
  * @param scope Compile-time constants in reach.
53
- * @param out Everything emitted so far.
54
- * @param env The expression environment.
53
+ * @param output Everything emitted so far.
54
+ * @param environment The expression environment.
55
55
  * @param state The component's state table.
56
56
  *
57
57
  * @returns The node's variable.
58
58
  */
59
- export function emitModal(element, scope, out, env, state) {
59
+ export function emitModal(element, scope, output, environment, state) {
60
60
  // get node id
61
- const nodeId = `n${out.allocateNodeId()}`;
61
+ const nodeId = `n${output.allocateNodeId()}`;
62
62
  // collect style assignments
63
- const { staticAssigns, dynAssigns, binds } = collectStyleAssigns(element.openingElement, scope, env, elementSpec('Modal'));
64
- const hasField = (f) => styleWrites(staticAssigns, dynAssigns, f);
63
+ const { staticAssigns, dynamicAssigns, binds } = collectStyleAssigns(element.openingElement, scope, environment, elementSpec('Modal'));
64
+ const hasField = (field) => styleWrites(staticAssigns, dynamicAssigns, field);
65
65
  // Apply modal overlay defaults only for fields the user's style has not already set.
66
- for (const [field, expr] of DEFAULTS) {
67
- if (!hasField(field)) {
68
- staticAssigns.push({ field: field, expr });
66
+ for (const assign of DEFAULTS) {
67
+ if (!hasField(assign.field)) {
68
+ staticAssigns.push({ ...assign });
69
69
  }
70
70
  }
71
71
  // process element attributes
72
72
  let visibleNode = null;
73
- for (const attr of element.openingElement.attributes) {
73
+ for (const attribute of element.openingElement.attributes) {
74
74
  // Ensure all props are explicit named attributes.
75
75
  // Spread props cannot be analyzed statically
76
- if (attr.type !== 'JSXAttribute') {
76
+ if (attribute.type !== 'JSXAttribute') {
77
77
  throw aotError('AOT: spread props on <Modal> are not supported');
78
78
  }
79
79
  // skip non-props
80
- const name = attr.name.name;
80
+ const name = attribute.name.name;
81
81
  if (name === 'style' || name === 'ref' || name === 'key')
82
82
  continue;
83
83
  // process props
84
- const node = attrExpr(attr);
84
+ const node = attrExpr(attribute);
85
85
  if (name === 'visible') {
86
86
  visibleNode = node;
87
87
  }
88
88
  else if (name === 'backdropColor') {
89
89
  staticAssigns.push({
90
90
  field: 'backdrop_color',
91
- expr: colorLiteral(String(evalStatic(node, scope))),
91
+ value: parseColorValue(String(evalStatic(node, scope))),
92
92
  });
93
93
  }
94
94
  else if (name === 'animationType') {
@@ -101,7 +101,7 @@ export function emitModal(element, scope, out, env, state) {
101
101
  /* state-driven: refused below */
102
102
  }
103
103
  if (animationType !== 'none') {
104
- throw at(aotError(`AOT: <Modal animationType> ${typeof animationType === 'string' ? `"${animationType}"` : 'from state'} is not supported`, 'the engine shows and hides a Modal at once; use animationType="none", or drop the prop.'), attr);
104
+ throw at(aotError(`AOT: <Modal animationType> ${typeof animationType === 'string' ? `"${animationType}"` : 'from state'} is not supported`, 'the engine shows and hides a Modal at once; use animationType="none", or drop the prop.'), attribute);
105
105
  }
106
106
  }
107
107
  else if (name === 'onRequestClose' || name === 'statusBarTranslucent') {
@@ -118,15 +118,15 @@ export function emitModal(element, scope, out, env, state) {
118
118
  try {
119
119
  staticAssigns.push({
120
120
  field: 'modal_visible',
121
- expr: evalStatic(visibleNode, scope) ? '1' : '0',
121
+ value: evalStatic(visibleNode, scope) ? 1 : 0,
122
122
  });
123
123
  }
124
124
  catch {
125
- dynAssigns.push({
125
+ dynamicAssigns.push({
126
126
  field: 'modal_visible',
127
127
  value: {
128
128
  kind: 'flag',
129
- test: lowerExpr(visibleNode, env),
129
+ test: lowerExpr(visibleNode, environment),
130
130
  truthiness: 'value',
131
131
  negate: false,
132
132
  whenTrue: 1,
@@ -135,9 +135,10 @@ export function emitModal(element, scope, out, env, state) {
135
135
  }
136
136
  const node = {
137
137
  id: nodeId,
138
+ location: currentLoc(),
138
139
  type: 'ER_NODE_MODAL',
139
140
  constantProps: staticAssigns,
140
- stateProps: dynAssigns,
141
+ stateProps: dynamicAssigns,
141
142
  placeholder: null,
142
143
  text: null,
143
144
  image: null,
@@ -145,7 +146,7 @@ export function emitModal(element, scope, out, env, state) {
145
146
  children: [],
146
147
  wiring: [
147
148
  ...binds.map((bind, index) => ({ kind: 'bind', bind, index })),
148
- ...lowerRefBinds(element.openingElement, env).map(slot => ({
149
+ ...lowerRefBinds(element.openingElement, environment).map(slot => ({
149
150
  kind: 'ref',
150
151
  slot,
151
152
  })),
@@ -153,6 +154,6 @@ export function emitModal(element, scope, out, env, state) {
153
154
  };
154
155
  checkInterpolations(node);
155
156
  // The modal's content, shown and hidden with the modal.
156
- node.children = emitChildren(element.children, scope, out, env, state);
157
+ node.children = emitChildren(element.children, scope, output, environment, state);
157
158
  return node;
158
159
  }
@@ -132,8 +132,8 @@ const SVG_PAINT = [
132
132
  'strokeLinejoin',
133
133
  'strokeMiterlimit',
134
134
  'fillRule',
135
- 'fillGrad',
136
- 'strokeGrad',
135
+ 'fillGradient',
136
+ 'strokeGradient',
137
137
  ];
138
138
  /** The attributes every host node lowers: style, visibility, a node ref, and its events. */
139
139
  const HOST_PROPS = [
@@ -237,7 +237,7 @@ const ELEMENTS = {
237
237
  ref: 'Flow A cannot pass a ref through <FlatList> either; use <ScrollView ref={…}> with .map.',
238
238
  }),
239
239
  // The Flow A wrapper warns about these too, so a list that runs in the simulator also compiles.
240
- platformNoOps: false,
240
+ takesPlatformProps: false,
241
241
  },
242
242
  Svg: element('Svg', ['style', 'ref', 'width', 'height', 'viewBox', 'source', ...SVG_PAINT], LAYOUT_STYLE, 'shapes', {
243
243
  visible: 'wrap it: <View visible={…}><Svg …/></View> — the View carries the hide and the whole subtree goes with it.',
@@ -279,7 +279,7 @@ function element(tag, props, styleKeys, children, refused = {}, animatedStyleKey
279
279
  tag,
280
280
  props: new Set(props),
281
281
  refused,
282
- platformNoOps: true,
282
+ takesPlatformProps: true,
283
283
  styleKeys: new Set(styleKeys),
284
284
  animatedStyleKeys: new Set(animatedStyleKeys),
285
285
  children,
@@ -298,7 +298,7 @@ function shape(tag, geometry) {
298
298
  tag,
299
299
  props: new Set([...geometry, ...SVG_PAINT]),
300
300
  refused: {},
301
- platformNoOps: false,
301
+ takesPlatformProps: false,
302
302
  styleKeys: null,
303
303
  animatedStyleKeys: new Set(),
304
304
  children: 'none',
@@ -327,13 +327,13 @@ export const svgShapeSpec = (tag) => Object.hasOwn(SVG_SHAPES, tag) ? SVG_SHAPES
327
327
  /**
328
328
  * An attribute's name as written, a namespaced one (`xlink:href`) included.
329
329
  *
330
- * @param attr The attribute.
330
+ * @param attribute The attribute.
331
331
  *
332
332
  * @returns Its name.
333
333
  */
334
- export const attrName = (attr) => attr.name.type === 'JSXNamespacedName'
335
- ? `${attr.name.namespace.name}:${attr.name.name.name}`
336
- : attr.name.name;
334
+ export const attrName = (attribute) => attribute.name.type === 'JSXNamespacedName'
335
+ ? `${attribute.name.namespace.name}:${attribute.name.name.name}`
336
+ : attribute.name.name;
337
337
  /**
338
338
  * Pins an error to a construct's location.
339
339
  *
@@ -358,17 +358,17 @@ export function at(error, node) {
358
358
  */
359
359
  const declares = (spec, name) => name === 'key' ||
360
360
  spec.props.has(name) ||
361
- (spec.platformNoOps && RN_PLATFORM_NO_OPS.includes(name));
361
+ (spec.takesPlatformProps && RN_PLATFORM_NO_OPS.includes(name));
362
362
  /**
363
- * Whether `attr` sits on a built-in element or shape that does not declare it. A component's props are its own,
363
+ * Whether `attribute` sits on a built-in element or shape that does not declare it. A component's props are its own,
364
364
  * so an attribute on one is never undeclared.
365
365
  *
366
366
  * @param openingElement The element's opening tag.
367
- * @param attr One of its attributes.
367
+ * @param attribute One of its attributes.
368
368
  *
369
369
  * @returns Whether the element would refuse it.
370
370
  */
371
- export function isUndeclaredAttribute(openingElement, attr) {
371
+ export function isUndeclaredAttribute(openingElement, attribute) {
372
372
  const nameNode = openingElement.name;
373
373
  const tag = nameNode.type === 'JSXIdentifier'
374
374
  ? nameNode.name
@@ -378,7 +378,7 @@ export function isUndeclaredAttribute(openingElement, attr) {
378
378
  ? nameNode.property.name
379
379
  : null;
380
380
  const spec = tag == null ? undefined : (elementSpec(tag) ?? svgShapeSpec(tag));
381
- return spec != null && !declares(spec, attrName(attr));
381
+ return spec != null && !declares(spec, attrName(attribute));
382
382
  }
383
383
  /**
384
384
  * Refuses every attribute `spec` does not declare, at the attribute. Spreads are left to the element's
@@ -388,16 +388,16 @@ export function isUndeclaredAttribute(openingElement, attr) {
388
388
  * @param openingElement Its opening tag.
389
389
  */
390
390
  export function checkAttributes(spec, openingElement) {
391
- for (const attr of openingElement.attributes) {
392
- if (attr.type !== 'JSXAttribute')
391
+ for (const attribute of openingElement.attributes) {
392
+ if (attribute.type !== 'JSXAttribute')
393
393
  continue;
394
- const name = attrName(attr);
394
+ const name = attrName(attribute);
395
395
  if (declares(spec, name))
396
396
  continue;
397
397
  const refusal = Object.hasOwn(spec.refused, name)
398
398
  ? spec.refused[name]
399
399
  : undefined;
400
- throw at(aotError(`AOT: <${spec.tag}> prop "${name}" is not supported`, refusal ?? `supported props: ${[...spec.props].join(', ')}.`), attr);
400
+ throw at(aotError(`AOT: <${spec.tag}> prop "${name}" is not supported`, refusal ?? `supported props: ${[...spec.props].join(', ')}.`), attribute);
401
401
  }
402
402
  }
403
403
  /**
@@ -410,12 +410,12 @@ export function checkAttributes(spec, openingElement) {
410
410
  * @returns The element, or a copy of it without those attributes.
411
411
  */
412
412
  export function withoutPlatformNoOps(spec, element) {
413
- if (!spec.platformNoOps)
413
+ if (!spec.takesPlatformProps)
414
414
  return element;
415
- const attrs = element.openingElement.attributes;
416
- const kept = attrs.filter(attr => attr.type !== 'JSXAttribute' ||
417
- !RN_PLATFORM_NO_OPS.includes(attrName(attr)));
418
- return kept.length === attrs.length
415
+ const attributes = element.openingElement.attributes;
416
+ const kept = attributes.filter(attribute => attribute.type !== 'JSXAttribute' ||
417
+ !RN_PLATFORM_NO_OPS.includes(attrName(attribute)));
418
+ return kept.length === attributes.length
419
419
  ? element
420
420
  : {
421
421
  ...element,