embedded-react 0.18.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 (117) hide show
  1. package/NOTICE +1 -1
  2. package/README.md +8 -4
  3. package/aot/compile.mjs +178 -58
  4. package/aot/compiler/animations.mjs +290 -281
  5. package/aot/compiler/boot.mjs +70 -33
  6. package/aot/compiler/branch-merge.mjs +4 -3
  7. package/aot/compiler/check.mjs +9 -9
  8. package/aot/compiler/collect.mjs +324 -205
  9. package/aot/compiler/control-flow.mjs +209 -197
  10. package/aot/compiler/diagnostics.mjs +22 -25
  11. package/aot/compiler/elements/activity-indicator.mjs +25 -24
  12. package/aot/compiler/elements/dial.mjs +91 -77
  13. package/aot/compiler/elements/flat-list.mjs +24 -22
  14. package/aot/compiler/elements/image.mjs +51 -50
  15. package/aot/compiler/elements/modal.mjs +31 -30
  16. package/aot/compiler/elements/props.mjs +23 -23
  17. package/aot/compiler/elements/switch.mjs +42 -34
  18. package/aot/compiler/elements/text-input.mjs +34 -32
  19. package/aot/compiler/expressions.mjs +372 -333
  20. package/aot/compiler/handlers.mjs +473 -387
  21. package/aot/compiler/ir/functions.mjs +11 -1
  22. package/aot/compiler/ir/nodes.mjs +4 -4
  23. package/aot/compiler/ir/reads.mjs +19 -19
  24. package/aot/compiler/ir/types.mjs +14 -14
  25. package/aot/compiler/ir/vectors.mjs +5 -1
  26. package/aot/compiler/keyboard.mjs +17 -7
  27. package/aot/compiler/lower.mjs +77 -80
  28. package/aot/compiler/nodes.mjs +169 -152
  29. package/aot/compiler/options.mjs +35 -30
  30. package/aot/compiler/out.mjs +18 -22
  31. package/aot/compiler/package/animations.mjs +669 -0
  32. package/aot/compiler/package/arena.mjs +252 -0
  33. package/aot/compiler/package/assemble.mjs +177 -0
  34. package/aot/compiler/package/bytecode.mjs +286 -0
  35. package/aot/compiler/package/checks.mjs +1022 -0
  36. package/aot/compiler/package/codegen.mjs +1329 -0
  37. package/aot/compiler/package/enums.mjs +138 -0
  38. package/aot/compiler/package/format.mjs +760 -0
  39. package/aot/compiler/package/layouts.mjs +136 -0
  40. package/aot/compiler/package/lower.mjs +1606 -0
  41. package/aot/compiler/package/props.mjs +118 -0
  42. package/aot/compiler/package/tables.mjs +103 -0
  43. package/aot/compiler/package/vectors.mjs +502 -0
  44. package/aot/compiler/package/writer.mjs +664 -0
  45. package/aot/compiler/pan-responder.mjs +69 -61
  46. package/aot/compiler/parse.mjs +21 -21
  47. package/aot/compiler/static-eval.mjs +25 -23
  48. package/aot/compiler/style-text.mjs +161 -172
  49. package/aot/compiler/svg.mjs +477 -251
  50. package/aot/screenshot-smoke.mjs +55 -41
  51. package/aot/style-map.mjs +102 -90
  52. package/assets/bake-font.mjs +123 -77
  53. package/assets/bake-image.mjs +39 -22
  54. package/assets/bake-svg.mjs +361 -262
  55. package/assets/build-builtin-font.mjs +14 -10
  56. package/assets/emit-c.mjs +83 -62
  57. package/assets/emit-container.mjs +124 -38
  58. package/assets/emit-pack.mjs +77 -67
  59. package/assets/font-config.mjs +9 -6
  60. package/assets/font-sizes.mjs +163 -123
  61. package/assets/glyph-coverage.mjs +74 -54
  62. package/assets/index.mjs +31 -9
  63. package/assets/rasterize.mjs +126 -99
  64. package/assets/svg-loader.mjs +8 -8
  65. package/build.mjs +16 -14
  66. package/cli.mjs +359 -172
  67. package/compile-bin.mjs +5 -5
  68. package/flash.mjs +537 -0
  69. package/hotreload/dev-device.mjs +90 -33
  70. package/hotreload/pack-app.mjs +55 -43
  71. package/hotreload/pack-split.mjs +46 -37
  72. package/hotreload/package-transfer.mjs +175 -0
  73. package/hotreload/protocol.mjs +51 -38
  74. package/hotreload/uploader.mjs +38 -27
  75. package/hotreload/watch-tree.mjs +19 -19
  76. package/pack-container.mjs +31 -23
  77. package/package.json +11 -12
  78. package/persist-transform.mjs +34 -28
  79. package/qjsc-wasm.mjs +25 -14
  80. package/sim/embedded-react.cjs +1 -1
  81. package/sim/embedded-react.js +1 -1
  82. package/sim/embedded-react.wasm +0 -0
  83. package/sim/index.html +94 -85
  84. package/sim-server.mjs +101 -82
  85. package/src/embedded-react/Animated.js +24 -24
  86. package/src/embedded-react/Easing.js +1 -1
  87. package/src/embedded-react/FlatList.js +4 -4
  88. package/src/embedded-react/LayoutAnimation.js +8 -5
  89. package/src/embedded-react/PanResponder.js +75 -71
  90. package/src/embedded-react/Pressable.js +2 -8
  91. package/src/embedded-react/SectionList.js +6 -6
  92. package/src/embedded-react/StyleSheet.js +4 -3
  93. package/src/embedded-react/TouchableOpacity.js +13 -8
  94. package/src/embedded-react/index.d.ts +5 -5
  95. package/src/embedded-react/layout-anim-config.js +10 -4
  96. package/src/embedded-react/list-child.js +5 -5
  97. package/src/embedded-react/named-colors.js +1 -1
  98. package/src/embedded-react/split-style.js +11 -11
  99. package/src/embedded-react/svg-ops.js +760 -593
  100. package/src/embedded-react/useHostValue.js +3 -3
  101. package/src/embedded-react/usePersistentState.js +6 -6
  102. package/src/embedded-react/warn-props.js +1 -1
  103. package/src/host-config.js +60 -53
  104. package/src/props.js +49 -41
  105. package/src/renderer.js +7 -4
  106. package/aot/compiler/assemble.mjs +0 -944
  107. package/aot/compiler/c/animations.mjs +0 -436
  108. package/aot/compiler/c/boot.mjs +0 -127
  109. package/aot/compiler/c/expressions.mjs +0 -270
  110. package/aot/compiler/c/functions.mjs +0 -268
  111. package/aot/compiler/c/keyboard.mjs +0 -96
  112. package/aot/compiler/c/nodes.mjs +0 -303
  113. package/aot/compiler/c/pan-responder.mjs +0 -136
  114. package/aot/compiler/c/statements.mjs +0 -319
  115. package/aot/compiler/c/text.mjs +0 -83
  116. package/aot/compiler/c/vectors.mjs +0 -381
  117. package/aot/compiler/c-syntax.mjs +0 -127
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  // Animated — the React Native analog, backed by the engine's native-driver value system
18
- // (er_anim_value_*). An Animated.Value is a handle to an engine-side float; binding it to a node
18
+ // (er_animation_value_*). An Animated.Value is a handle to an engine-side float; binding it to a node
19
19
  // prop (via Animated.View) lets the engine advance the animation each frame with NO per-frame JS.
20
20
  import {createElement, useRef, useEffect} from 'react';
21
21
  import {NativeUI} from '../native-ui.js';
@@ -55,9 +55,9 @@ export class AnimatedValue {
55
55
  this._destroyed = false;
56
56
  }
57
57
 
58
- setValue(v) {
59
- this._value = v;
60
- NativeUI.animValueSet(this._handle, v);
58
+ setValue(value) {
59
+ this._value = value;
60
+ NativeUI.animValueSet(this._handle, value);
61
61
  }
62
62
 
63
63
  /**
@@ -103,14 +103,14 @@ export class AnimatedInterpolation {
103
103
  }
104
104
 
105
105
  __bind(node, prop) {
106
- const out = this._config?.outputRange;
107
- if (Array.isArray(out)) {
106
+ const outputRange = this._config?.outputRange;
107
+ if (Array.isArray(outputRange)) {
108
108
  if (COLOR_PROPS.has(prop)) {
109
- if (out.some(c => typeof c !== 'string')) {
109
+ if (outputRange.some(output => typeof output !== 'string')) {
110
110
  warnColorBind(prop);
111
111
  return;
112
112
  }
113
- } else if (out.some(n => typeof n !== 'number')) {
113
+ } else if (outputRange.some(output => typeof output !== 'number')) {
114
114
  warnNumberBind(prop);
115
115
  return;
116
116
  }
@@ -142,13 +142,13 @@ export class AnimatedInterpolation {
142
142
  }
143
143
  }
144
144
 
145
- /** Wraps fn so it runs at most once, regardless of how many times it is invoked. */
146
- function once(fn) {
145
+ /** Wraps callback so it runs at most once, regardless of how many times it is invoked. */
146
+ function once(callback) {
147
147
  let called = false;
148
- return arg => {
148
+ return argument => {
149
149
  if (called) return;
150
150
  called = true;
151
- if (fn) fn(arg);
151
+ if (callback) callback(argument);
152
152
  };
153
153
  }
154
154
 
@@ -166,11 +166,11 @@ function makeAnimation(value, toValue, config) {
166
166
  _value: value,
167
167
  start(onComplete) {
168
168
  // Always pass a wrapper so we can null out the (possibly recycled) handle on completion.
169
- const cb = finished => {
169
+ const onEnd = finished => {
170
170
  handle = 0;
171
171
  if (onComplete) onComplete({finished: !!finished});
172
172
  };
173
- handle = NativeUI.animValueAnimate(value._handle, toValue, config, cb);
173
+ handle = NativeUI.animValueAnimate(value._handle, toValue, config, onEnd);
174
174
  },
175
175
  stop() {
176
176
  if (handle) NativeUI.animStop(handle);
@@ -252,16 +252,16 @@ export function parallel(animations, config) {
252
252
  anyUnfinished = true;
253
253
  if (stopTogether && !stopped) {
254
254
  stopped = true;
255
- for (const a of animations) a.stop();
255
+ for (const animation of animations) animation.stop();
256
256
  }
257
257
  }
258
258
  if (doneCount >= total) done({finished: !anyUnfinished});
259
259
  };
260
- for (const a of animations) a.start(onChild);
260
+ for (const animation of animations) animation.start(onChild);
261
261
  },
262
262
  stop() {
263
263
  stopped = true;
264
- for (const a of animations) a.stop();
264
+ for (const animation of animations) animation.stop();
265
265
  },
266
266
  };
267
267
  }
@@ -285,22 +285,22 @@ export function stagger(delay, animations) {
285
285
  if (!result || result.finished === false) anyUnfinished = true;
286
286
  if (doneCount >= total) done({finished: !anyUnfinished});
287
287
  };
288
- animations.forEach((a, i) => {
289
- if (i === 0) {
290
- a.start(onChild);
288
+ animations.forEach((animation, index) => {
289
+ if (index === 0) {
290
+ animation.start(onChild);
291
291
  } else {
292
292
  timers.push(
293
293
  setTimeout(() => {
294
- if (!stopped) a.start(onChild);
295
- }, delay * i),
294
+ if (!stopped) animation.start(onChild);
295
+ }, delay * index),
296
296
  );
297
297
  }
298
298
  });
299
299
  },
300
300
  stop() {
301
301
  stopped = true;
302
- for (const t of timers) clearTimeout(t);
303
- for (const a of animations) a.stop();
302
+ for (const timer of timers) clearTimeout(timer);
303
+ for (const animation of animations) animation.stop();
304
304
  },
305
305
  };
306
306
  }
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- // Easing tokens. The engine implements a fixed set of easing curves (ERAnimEasing), so unlike RN's
17
+ // Easing tokens. The engine implements a fixed set of easing curves (ERAnimationEasing), so unlike RN's
18
18
  // composable Easing functions these are string tokens the bridge maps to the engine enum. `bezier`
19
19
  // returns a control-point object the bridge reads as a custom cubic-bezier curve.
20
20
  export const Easing = {
@@ -28,7 +28,7 @@
28
28
  // data.length x (nodes per row) slots out of the fixed ERUI_MAX_NODES pool. See "FlatList is a
29
29
  // ScrollView alias" in the top-level README for the limits and when to reach for something else.
30
30
  //
31
- // This mirrors the AOT's emitFlatList (bridges/quickjs/js/aot/compiler/elements/flat-list.mts),
31
+ // This mirrors the AOT's emitFlatList (packages/embedded-react/aot/compiler/elements/flat-list.mts),
32
32
  // which performs the same rewrite at compile time. The two flows accept the SAME four props on
33
33
  // purpose — a list that renders in the simulator must also compile for the device, so anything
34
34
  // Flow B rejects is warned about here rather than silently forwarded.
@@ -74,11 +74,11 @@ export function FlatList(props = {}) {
74
74
  const row = renderItem({item, index});
75
75
  // The key is built lazily: pushKeyedChild calls this only for a row that can hold one, so
76
76
  // keyExtractor never runs for a row that rendered nothing or for a raw string.
77
- pushKeyedChild(rows, row, el =>
77
+ pushKeyedChild(rows, row, element =>
78
78
  keyExtractor
79
79
  ? String(keyExtractor(item, index))
80
- : el.key !== null && el.key !== undefined
81
- ? el.key
80
+ : element.key !== null && element.key !== undefined
81
+ ? element.key
82
82
  : String(index),
83
83
  );
84
84
  }
@@ -16,8 +16,8 @@
16
16
 
17
17
  // LayoutAnimation — the React Native analog. Calling configureNext(...) before a state update that
18
18
  // changes layout makes the engine tween every node whose computed rect moved (instead of snapping)
19
- // on the next commit. Backed by the engine's er_layout_anim_configure_next; the tween advances in C
20
- // each frame (er_layout_anim_tick), so there's no per-frame JS.
19
+ // on the next commit. Backed by the engine's er_layout_animation_configure_next; the tween advances in C
20
+ // each frame (er_layout_animation_tick), so there's no per-frame JS.
21
21
  import {NativeUI} from '../native-ui.js';
22
22
  import {
23
23
  Types,
@@ -25,6 +25,7 @@ import {
25
25
  Presets,
26
26
  toEngineConfig,
27
27
  create,
28
+ DEFAULT_DURATION_MS,
28
29
  } from './layout-anim-config.js';
29
30
 
30
31
  /**
@@ -34,9 +35,11 @@ import {
34
35
  export function configureNext(config, onAnimationDidEnd) {
35
36
  NativeUI.configureNextLayoutAnimation(toEngineConfig(config));
36
37
  if (typeof onAnimationDidEnd === 'function') {
37
- const ms =
38
- config && typeof config.duration === 'number' ? config.duration : 300;
39
- setTimeout(onAnimationDidEnd, ms);
38
+ const durationMs =
39
+ config && typeof config.duration === 'number'
40
+ ? config.duration
41
+ : DEFAULT_DURATION_MS;
42
+ setTimeout(onAnimationDidEnd, durationMs);
40
43
  }
41
44
  }
42
45
 
@@ -23,8 +23,8 @@
23
23
  //
24
24
  // const pan = useRef(PanResponder.create({
25
25
  // onStartShouldSetPanResponder: () => true,
26
- // onPanResponderMove: (e, g) => setX(g.dx),
27
- // onPanResponderRelease: (e, g) => (g.vx > 0.5 ? next() : settle()),
26
+ // onPanResponderMove: (event, gesture) => setX(gesture.dx),
27
+ // onPanResponderRelease: (event, gesture) => (gesture.vx > 0.5 ? next() : settle()),
28
28
  // })).current;
29
29
  //
30
30
  // <View {...pan.panHandlers} />
@@ -86,7 +86,8 @@ const SUPPORTED = [
86
86
  * The engine's monotonic millisecond clock, used for velocity. `performance.now()` is installed by the
87
87
  * QuickJS runtime on every context (it is React's scheduler clock) and exists in the simulator and in
88
88
  * Node; `Date.now()` jumps whenever the host sets the wall clock, so it is never used here.
89
- * The clock only advances when the host ticks, so a dt of 0 is normal and leaves velocity untouched.
89
+ * The clock only advances when the host ticks, so an elapsed time of 0 is normal and leaves velocity
90
+ * untouched.
90
91
  */
91
92
  const now = () =>
92
93
  typeof performance !== 'undefined' && typeof performance.now === 'function'
@@ -108,10 +109,10 @@ function asConfig(config) {
108
109
  /** Warns ONCE PER KEY about config keys this module does not act on. */
109
110
  function warnUnsupportedConfig(config) {
110
111
  const names = Object.keys(config).filter(
111
- k => !SUPPORTED.includes(k) && !s_warnedKeys.has(k),
112
+ key => !SUPPORTED.includes(key) && !s_warnedKeys.has(key),
112
113
  );
113
114
  if (names.length === 0) return;
114
- for (const k of names) s_warnedKeys.add(k);
115
+ for (const key of names) s_warnedKeys.add(key);
115
116
  console.warn(
116
117
  `embedded-react: PanResponder ignores ${names.join(', ')} — ` +
117
118
  `supported: ${SUPPORTED.join(', ')}.`,
@@ -122,17 +123,17 @@ function warnUnsupportedConfig(config) {
122
123
  * Clears the travel/velocity fields between gestures. `numberActiveTouches` is deliberately left alone:
123
124
  * it counts fingers on the panel, which outlives the gesture when a second finger is still down.
124
125
  *
125
- * @param {object} g The gesture state to reset in place.
126
+ * @param {object} gestureState The gesture state to reset in place.
126
127
  */
127
- function resetGestureState(g) {
128
- g.moveX = 0;
129
- g.moveY = 0;
130
- g.x0 = 0;
131
- g.y0 = 0;
132
- g.dx = 0;
133
- g.dy = 0;
134
- g.vx = 0;
135
- g.vy = 0;
128
+ function resetGestureState(gestureState) {
129
+ gestureState.moveX = 0;
130
+ gestureState.moveY = 0;
131
+ gestureState.x0 = 0;
132
+ gestureState.y0 = 0;
133
+ gestureState.dx = 0;
134
+ gestureState.dy = 0;
135
+ gestureState.vx = 0;
136
+ gestureState.vy = 0;
136
137
  }
137
138
 
138
139
  /**
@@ -170,62 +171,63 @@ export function create(userConfig = {}) {
170
171
 
171
172
  let granted = false;
172
173
  let lastMoveTime = 0;
173
- // The engine measures e.dx/e.dy from TOUCH-DOWN; RN (and this module) measure g.dx/g.dy from the
174
- // GRANT — a responder that needed 10px of slop to claim starts its own travel at zero, so the slop
175
- // never shows up as a jump. The base is what e.dx read at the moment of the grant.
174
+ // The engine measures event.dx/event.dy from TOUCH-DOWN; RN (and this module) measure
175
+ // gestureState.dx/dy from the GRANT — a responder that needed 10px of slop to claim starts its own
176
+ // travel at zero, so the slop never shows up as a jump. The base is what event.dx read at the moment
177
+ // of the grant.
176
178
  let baseDx = 0;
177
179
  let baseDy = 0;
178
180
 
179
- const fire = (name, e) => {
180
- if (typeof config[name] === 'function') config[name](e, gestureState);
181
+ const fire = (name, event) => {
182
+ if (typeof config[name] === 'function') config[name](event, gestureState);
181
183
  };
182
184
 
183
- /** Folds one engine payload (e.x/e.y absolute, e.dx/e.dy from touch-down) into the travel fields. */
184
- const advance = e => {
185
- gestureState.moveX = e.x;
186
- gestureState.moveY = e.y;
187
- gestureState.dx = e.dx - baseDx;
188
- gestureState.dy = e.dy - baseDy;
185
+ /** Folds one engine payload (event.x/y absolute, event.dx/dy from touch-down) into the travel fields. */
186
+ const advance = event => {
187
+ gestureState.moveX = event.x;
188
+ gestureState.moveY = event.y;
189
+ gestureState.dx = event.dx - baseDx;
190
+ gestureState.dy = event.dy - baseDy;
189
191
  };
190
192
 
191
193
  /** A move: travel, plus a fresh velocity reading over the time since the last one. */
192
- const track = e => {
193
- const t = now();
194
- const dt = t - lastMoveTime;
195
- const prevDx = gestureState.dx;
196
- const prevDy = gestureState.dy;
194
+ const track = event => {
195
+ const time = now();
196
+ const elapsed = time - lastMoveTime;
197
+ const previousDx = gestureState.dx;
198
+ const previousDy = gestureState.dy;
197
199
 
198
- advance(e);
200
+ advance(event);
199
201
 
200
- // dt is 0 whenever two touches land inside one host frame (the clock only moves on er_tick), and
201
- // the division would be Infinity. Keeping the previous velocity is the honest answer: nothing new
202
- // has been measured yet.
203
- if (dt > 0) {
204
- gestureState.vx = (gestureState.dx - prevDx) / dt;
205
- gestureState.vy = (gestureState.dy - prevDy) / dt;
202
+ // The elapsed time is 0 whenever two touches land inside one host frame (the clock only moves on
203
+ // er_tick), and the division would be Infinity. Keeping the previous velocity is the honest
204
+ // answer: nothing new has been measured yet.
205
+ if (elapsed > 0) {
206
+ gestureState.vx = (gestureState.dx - previousDx) / elapsed;
207
+ gestureState.vy = (gestureState.dy - previousDy) / elapsed;
206
208
  }
207
- lastMoveTime = t;
209
+ lastMoveTime = time;
208
210
  };
209
211
 
210
212
  /** Wraps a should-set predicate as an engine query: track the point, ask, absent means "no" (as in RN). */
211
213
  const query = name =>
212
214
  typeof config[name] === 'function'
213
- ? e => {
214
- if (!granted) advance(e);
215
- return config[name](e, gestureState) === true;
215
+ ? event => {
216
+ if (!granted) advance(event);
217
+ return config[name](event, gestureState) === true;
216
218
  }
217
219
  : undefined;
218
220
 
219
221
  /** Ends the gesture: reports it if this responder owned it, then clears the state for the next one. */
220
- const finish = (e, callback) => {
222
+ const finish = (event, callback) => {
221
223
  const wasGranted = granted;
222
224
  granted = false;
223
225
  // Fold the final point into the travel so `dx` is the gesture's true total even when the finger
224
226
  // lifted without a final move — but leave vx/vy at the last MOVE's reading. A fling ends with the
225
227
  // finger resting for a frame or two, and re-measuring across that would report zero and throw the
226
228
  // throw away.
227
- advance(e);
228
- if (wasGranted) fire(callback, e);
229
+ advance(event);
230
+ if (wasGranted) fire(callback, event);
229
231
  resetGestureState(gestureState);
230
232
  baseDx = 0;
231
233
  baseDy = 0;
@@ -233,7 +235,7 @@ export function create(userConfig = {}) {
233
235
 
234
236
  const panHandlers = {
235
237
  // --- Raw touch bookkeeping (bubbles per finger): finger count + Start/End for extra fingers ---
236
- onTouchStart(e) {
238
+ onTouchStart(event) {
237
239
  gestureState.numberActiveTouches += 1;
238
240
  // A later finger joins the gesture in flight (the engine events carry no finger id, so
239
241
  // independent tracking is impossible). Its own touch slot re-negotiates and re-grants this
@@ -242,19 +244,19 @@ export function create(userConfig = {}) {
242
244
  resetGestureState(gestureState);
243
245
  baseDx = 0;
244
246
  baseDy = 0;
245
- gestureState.x0 = e.x;
246
- gestureState.y0 = e.y;
247
- gestureState.moveX = e.x;
248
- gestureState.moveY = e.y;
247
+ gestureState.x0 = event.x;
248
+ gestureState.y0 = event.y;
249
+ gestureState.moveX = event.x;
250
+ gestureState.moveY = event.y;
249
251
  lastMoveTime = now();
250
252
  },
251
- onTouchEnd(e) {
253
+ onTouchEnd(event) {
252
254
  if (gestureState.numberActiveTouches > 0)
253
255
  gestureState.numberActiveTouches -= 1;
254
256
  // A finger lifted but the gesture continues; the RELEASE for the last one arrives as a
255
257
  // responder event below.
256
258
  if (granted && gestureState.numberActiveTouches > 0)
257
- fire('onPanResponderEnd', e);
259
+ fire('onPanResponderEnd', event);
258
260
  },
259
261
  onTouchCancel() {
260
262
  gestureState.numberActiveTouches = 0;
@@ -271,53 +273,55 @@ export function create(userConfig = {}) {
271
273
  ),
272
274
  onResponderTerminationRequest:
273
275
  typeof config.onPanResponderTerminationRequest === 'function'
274
- ? e => config.onPanResponderTerminationRequest(e, gestureState) === true
276
+ ? event =>
277
+ config.onPanResponderTerminationRequest(event, gestureState) ===
278
+ true
275
279
  : undefined, // absent → the engine's default: yield (RN's default too)
276
280
 
277
281
  // --- Responder lifecycle (native events; fire only on the node that owns the gesture) ---
278
- onResponderGrant(e) {
282
+ onResponderGrant(event) {
279
283
  if (granted) {
280
284
  // A second finger's touch slot granted the same node: one gesture, not two. RN calls this a
281
285
  // responder "start" for the extra touch.
282
- fire('onPanResponderStart', e);
286
+ fire('onPanResponderStart', event);
283
287
  return;
284
288
  }
285
289
  granted = true;
286
- baseDx = e.dx;
287
- baseDy = e.dy;
288
- gestureState.x0 = e.x;
289
- gestureState.y0 = e.y;
290
+ baseDx = event.dx;
291
+ baseDy = event.dy;
292
+ gestureState.x0 = event.x;
293
+ gestureState.y0 = event.y;
290
294
  gestureState.dx = 0;
291
295
  gestureState.dy = 0;
292
296
  lastMoveTime = now();
293
- fire('onPanResponderGrant', e);
297
+ fire('onPanResponderGrant', event);
294
298
  },
295
- onResponderMove(e) {
299
+ onResponderMove(event) {
296
300
  if (!granted) return;
297
- track(e);
298
- fire('onPanResponderMove', e);
301
+ track(event);
302
+ fire('onPanResponderMove', event);
299
303
  },
300
- onResponderRelease(e) {
304
+ onResponderRelease(event) {
301
305
  if (!granted) return;
302
306
  // Another finger still down: its touch slot keeps the responder, so the gesture continues (the
303
307
  // raw onTouchEnd above already reported the End).
304
308
  if (gestureState.numberActiveTouches > 0) return;
305
- finish(e, 'onPanResponderRelease');
309
+ finish(event, 'onPanResponderRelease');
306
310
  },
307
- onResponderTerminate(e) {
311
+ onResponderTerminate(event) {
308
312
  if (!granted) return;
309
313
  gestureState.numberActiveTouches = 0;
310
- finish(e, 'onPanResponderTerminate');
314
+ finish(event, 'onPanResponderTerminate');
311
315
  },
312
- onResponderReject(e) {
313
- fire('onPanResponderReject', e);
316
+ onResponderReject(event) {
317
+ fire('onPanResponderReject', event);
314
318
  },
315
319
  };
316
320
 
317
321
  // Absent queries must not appear as props at all (an undefined on* prop is skipped by the host
318
322
  // config anyway, but a clean bag is easier to reason about and to spread).
319
- for (const k of Object.keys(panHandlers)) {
320
- if (panHandlers[k] === undefined) delete panHandlers[k];
323
+ for (const key of Object.keys(panHandlers)) {
324
+ if (panHandlers[key] === undefined) delete panHandlers[key];
321
325
  }
322
326
 
323
327
  return {panHandlers};
@@ -38,14 +38,8 @@ import {Pressable as HostPressable} from './components.js';
38
38
  * @returns {*} A host <Pressable> element.
39
39
  */
40
40
  export const Pressable = forwardRef(function Pressable(props = {}, ref) {
41
- const {
42
- disabled,
43
- onPress,
44
- onLongPress,
45
- onPressIn,
46
- onPressOut,
47
- ...rest
48
- } = props;
41
+ const {disabled, onPress, onLongPress, onPressIn, onPressOut, ...rest} =
42
+ props;
49
43
 
50
44
  return createElement(HostPressable, {
51
45
  ...rest,
@@ -91,12 +91,12 @@ export function SectionList(props = {}) {
91
91
 
92
92
  const children = [];
93
93
  if (Array.isArray(sections)) {
94
- for (let s = 0; s < sections.length; s++) {
95
- const section = sections[s];
94
+ for (let sectionIndex = 0; sectionIndex < sections.length; sectionIndex++) {
95
+ const section = sections[sectionIndex];
96
96
  if (section === null || typeof section !== 'object') continue;
97
97
  const sectionKey =
98
98
  section.key === null || section.key === undefined
99
- ? String(s)
99
+ ? String(sectionIndex)
100
100
  : String(section.key);
101
101
 
102
102
  if (typeof renderSectionHeader === 'function')
@@ -120,11 +120,11 @@ export function SectionList(props = {}) {
120
120
  const row = rowRenderer({item, index, section});
121
121
  // Built lazily, so keyExtractor never runs for a row that rendered nothing or for a raw
122
122
  // string — see pushKeyedChild.
123
- pushKeyedChild(children, row, el => {
123
+ pushKeyedChild(children, row, element => {
124
124
  const key = rowKey
125
125
  ? String(rowKey(item, index))
126
- : el.key !== null && el.key !== undefined
127
- ? el.key
126
+ : element.key !== null && element.key !== undefined
127
+ ? element.key
128
128
  : String(index);
129
129
  return `${sectionKey}:${key}`;
130
130
  });
@@ -24,9 +24,10 @@ export const StyleSheet = {
24
24
  flatten(style) {
25
25
  if (!style) return {};
26
26
  if (Array.isArray(style)) {
27
- const out = {};
28
- for (const s of style) Object.assign(out, StyleSheet.flatten(s));
29
- return out;
27
+ const flattened = {};
28
+ for (const entry of style)
29
+ Object.assign(flattened, StyleSheet.flatten(entry));
30
+ return flattened;
30
31
  }
31
32
  return style;
32
33
  },
@@ -22,7 +22,7 @@
22
22
  // <Pressable style={[styles.tile, {opacity: dim}]} onPressIn={…} onPressOut={…}>…</Pressable>
23
23
  //
24
24
  // The fade is a native-driver animation, not a re-render: the two press handlers hand the engine a
25
- // target opacity and a duration, and it runs the ramp in C (er_anim_value_*). Nothing re-enters JS per
25
+ // target opacity and a duration, and it runs the ramp in C (er_animation_value_*). Nothing re-enters JS per
26
26
  // frame, and the subtree React just built is not touched at all.
27
27
  //
28
28
  // Worth knowing before wrapping a whole screen in one: an opacity below 1 makes the Pressable an
@@ -45,6 +45,7 @@ import {flattenStyleObj} from '../props.js';
45
45
  // RN's own numbers (Libraries/Components/Touchable/TouchableOpacity.js): the dim lands on touch-down
46
46
  // with no ramp at all and fades back over a quarter second once the finger lifts.
47
47
  const DEFAULT_ACTIVE_OPACITY = 0.2;
48
+ const FULLY_OPAQUE = 1;
48
49
  const DIM_MS = 0;
49
50
  const RESTORE_MS = 250;
50
51
 
@@ -52,8 +53,8 @@ let warnedAnimatedOpacity = false;
52
53
 
53
54
  /** The opacity the touchable rests at — whatever its style asks for, fully opaque if it asks nothing. */
54
55
  function restingOpacity(style) {
55
- const o = flattenStyleObj(style).opacity;
56
- if (o && o.__animated) {
56
+ const opacity = flattenStyleObj(style).opacity;
57
+ if (opacity && opacity.__animated) {
57
58
  if (!warnedAnimatedOpacity) {
58
59
  warnedAnimatedOpacity = true;
59
60
  console.warn(
@@ -62,14 +63,18 @@ function restingOpacity(style) {
62
63
  'onPressIn/onPressOut driving an Animated.Value.',
63
64
  );
64
65
  }
65
- return 1;
66
+ return FULLY_OPAQUE;
66
67
  }
67
- return typeof o === 'number' ? o : 1;
68
+ return typeof opacity === 'number' ? opacity : FULLY_OPAQUE;
68
69
  }
69
70
 
70
- /** Runs `value` to `to` over `ms` on the native driver (a 0 ms ramp snaps, without taking a slot). */
71
- function fadeTo(value, to, ms) {
72
- timing(value, {toValue: to, duration: ms, easing: Easing.quadInOut}).start();
71
+ /** Runs `value` to `target` over `durationMs` on the native driver (a 0 ms ramp snaps, without taking a slot). */
72
+ function fadeTo(value, target, durationMs) {
73
+ timing(value, {
74
+ toValue: target,
75
+ duration: durationMs,
76
+ easing: Easing.quadInOut,
77
+ }).start();
73
78
  }
74
79
 
75
80
  /**
@@ -670,9 +670,9 @@ export interface SvgPaintProps {
670
670
  strokeMiterlimit?: SvgNumber;
671
671
  fillRule?: 'nonzero' | 'evenodd';
672
672
  /** Fills with a gradient instead of the solid `fill`. */
673
- fillGrad?: VectorGradient;
673
+ fillGradient?: VectorGradient;
674
674
  /** Strokes with a gradient instead of the solid `stroke`. */
675
- strokeGrad?: VectorGradient;
675
+ strokeGradient?: VectorGradient;
676
676
  }
677
677
 
678
678
  /** A `.svg` import: the build bakes it to a vector op-tape, or to a raster asset when it uses features the
@@ -1058,8 +1058,8 @@ export interface VectorShape {
1058
1058
  cap?: 'butt' | 'round' | 'square';
1059
1059
  join?: 'miter' | 'round' | 'bevel';
1060
1060
  fillRule?: 'nonzero' | 'evenodd';
1061
- fillGrad?: VectorGradient;
1062
- strokeGrad?: VectorGradient;
1061
+ fillGradient?: VectorGradient;
1062
+ strokeGradient?: VectorGradient;
1063
1063
  }
1064
1064
 
1065
1065
  /**
@@ -1103,7 +1103,7 @@ export interface KeyboardConfig {
1103
1103
  rowHeight?: number;
1104
1104
  keyGap?: number;
1105
1105
  keyRadius?: number;
1106
- gridCols?: number;
1106
+ gridColumns?: number;
1107
1107
  layers?: KeyboardKey[][][];
1108
1108
  }
1109
1109
 
@@ -18,6 +18,9 @@
18
18
  // Node (see __tests__/layout-animation.unit.test.js). LayoutAnimation.js wires configureNext to the
19
19
  // bridge using these.
20
20
 
21
+ /** Duration when a config gives none, as in RN. */
22
+ export const DEFAULT_DURATION_MS = 300;
23
+
21
24
  /** RN-compatible animation type tokens. */
22
25
  export const Types = {
23
26
  spring: 'spring',
@@ -58,10 +61,13 @@ function easingForType(type) {
58
61
  * are accepted for parity but not separately animated.
59
62
  */
60
63
  export function toEngineConfig(config) {
61
- const c = config || {};
62
- const duration = typeof c.duration === 'number' ? c.duration : 300;
63
- const update = c.update || {};
64
- const type = update.type || c.type || Types.easeInEaseOut;
64
+ const options = config || {};
65
+ const duration =
66
+ typeof options.duration === 'number'
67
+ ? options.duration
68
+ : DEFAULT_DURATION_MS;
69
+ const update = options.update || {};
70
+ const type = update.type || options.type || Types.easeInEaseOut;
65
71
  if (type === Types.spring) {
66
72
  return {type: 'spring', duration};
67
73
  }
@@ -28,7 +28,7 @@ export const isElement = node =>
28
28
  node !== null && typeof node === 'object' && node.$$typeof !== undefined;
29
29
 
30
30
  /**
31
- * Appends one rendered row to `out`, keyed, or drops it if it rendered nothing.
31
+ * Appends one rendered row to `children`, keyed, or drops it if it rendered nothing.
32
32
  *
33
33
  * Callers own the key because they know what makes one unique (a SectionList's rows are siblings
34
34
  * across sections, a FlatList's are not). A row that is not an element goes in untouched: there is no
@@ -39,16 +39,16 @@ export const isElement = node =>
39
39
  * nothing, or for a raw string that cannot be cloned, is both wasted work on the commit path and a
40
40
  * side effect the app never asked for. Passing the key by value invites exactly that, and did.
41
41
  *
42
- * @param {Array} out The child list being built.
42
+ * @param {Array} children The child list being built.
43
43
  * @param {*} node Whatever the render callback returned.
44
44
  * @param {(element: object) => string} keyFor Builds the React key, given the keyable element.
45
45
  */
46
- export function pushKeyedChild(out, node, keyFor) {
46
+ export function pushKeyedChild(children, node, keyFor) {
47
47
  if (rendersNothing(node)) return;
48
48
  if (!isElement(node)) {
49
- out.push(node);
49
+ children.push(node);
50
50
  return;
51
51
  }
52
52
  const key = keyFor(node);
53
- out.push(node.key === key ? node : cloneElement(node, {key}));
53
+ children.push(node.key === key ? node : cloneElement(node, {key}));
54
54
  }