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
@@ -16,9 +16,9 @@
16
16
 
17
17
  // useHostValue — a numeric value fed by the C HOST at runtime, not by the app.
18
18
  //
19
- // Flow B (AOT): the compiler recognizes `const steps = useHostValue(0)` and lowers it to an ordinary
20
- // `s_state` field PLUS a generated public setter `er_app_set_steps(int)`. The host (e.g. a pedometer
21
- // reading an IMU in main.c) calls that setter each frame; the app renders the value like any state.
19
+ // Flow B (AOT): the compiler recognizes `const steps = useHostValue(0)` and lowers it to an ordinary state
20
+ // slot, which the package names as an input. The host (e.g. a pedometer reading an IMU in main.c) finds it
21
+ // with erb_input_find("steps") and sets it with erb_input_set_int(); the app renders the value like any state.
22
22
  // There is no JS setter — the host is the only writer.
23
23
  //
24
24
  // Flow A / simulator: there is no host, so this simply returns the initial value (the simulator has no
@@ -47,23 +47,23 @@ export function usePersistentState(key, initial) {
47
47
  return typeof initial === 'function' ? initial() : initial;
48
48
  });
49
49
 
50
- const set = useCallback(
50
+ const setPersistedValue = useCallback(
51
51
  next => {
52
- setValue(prev => {
53
- const v = typeof next === 'function' ? next(prev) : next;
52
+ setValue(previous => {
53
+ const resolved = typeof next === 'function' ? next(previous) : next;
54
54
  const store = globalThis.__erPersist;
55
55
  if (store) {
56
56
  try {
57
- store.set(key, JSON.stringify(v));
57
+ store.set(key, JSON.stringify(resolved));
58
58
  } catch {
59
59
  /* unserializable value — skip persistence, keep the in-memory state */
60
60
  }
61
61
  }
62
- return v;
62
+ return resolved;
63
63
  });
64
64
  },
65
65
  [key],
66
66
  );
67
67
 
68
- return [value, set];
68
+ return [value, setPersistedValue];
69
69
  }
@@ -68,7 +68,7 @@ export function createPropWarner(component, supported, hint, quiet = []) {
68
68
  return props => {
69
69
  if (warned) return;
70
70
  const names = Object.keys(props).filter(
71
- k => !supported.includes(k) && !quiet.includes(k),
71
+ name => !supported.includes(name) && !quiet.includes(name),
72
72
  );
73
73
  if (names.length === 0) return;
74
74
  warned = true;
@@ -34,7 +34,7 @@ import {splitAnimatedStyle} from './embedded-react/split-style.js';
34
34
 
35
35
  // --- Animated bindings ---------------------------------------------------------------------------
36
36
  // A bound prop is owned by the engine from then on: it re-pushes the animated value over the static
37
- // props of every later setProps (er_anim_reapply_bound), which is what keeps a re-render from jumping
37
+ // props of every later setProps (er_animation_reapply_bound), which is what keeps a re-render from jumping
38
38
  // a running animation back to its declared value. Nothing in React says "this prop stopped being
39
39
  // animated", so the binding has to be released explicitly or it keeps writing the prop forever — and a
40
40
  // prop that swapped Animated.Values ends up written by both. Instances are bare node handles with no
@@ -46,16 +46,16 @@ const boundValues = new Map();
46
46
  * alone. Identity settles an Animated.Value; an interpolation is a throwaway object that
47
47
  * `value.interpolate(...)` rebuilds on every render, so it answers __bindEq for itself.
48
48
  */
49
- function sameBinding(prev, next) {
50
- if (prev === next) return true;
51
- if (prev == null || next == null) return false;
52
- return typeof prev.__bindEq === 'function' && prev.__bindEq(next);
49
+ function sameBinding(previous, next) {
50
+ if (previous === next) return true;
51
+ if (previous == null || next == null) return false;
52
+ return typeof previous.__bindEq === 'function' && previous.__bindEq(next);
53
53
  }
54
54
 
55
55
  /** The value `bindings` (from splitAnimatedStyle) drives `prop` with, or undefined if none does. */
56
56
  function bindingFor(bindings, prop) {
57
- for (const b of bindings) {
58
- if (b.prop === prop) return b.value;
57
+ for (const binding of bindings) {
58
+ if (binding.prop === prop) return binding.value;
59
59
  }
60
60
  return undefined;
61
61
  }
@@ -86,25 +86,27 @@ function releaseStaleBindings(handle, bindings) {
86
86
  function applyBindings(handle, bindings) {
87
87
  if (bindings.length === 0) return;
88
88
  let bound = boundValues.get(handle);
89
- for (const b of bindings) {
90
- if (bound !== undefined && sameBinding(bound.get(b.prop), b.value))
89
+ for (const binding of bindings) {
90
+ if (
91
+ bound !== undefined &&
92
+ sameBinding(bound.get(binding.prop), binding.value)
93
+ )
91
94
  continue;
92
- b.value.__bind(handle, b.prop);
95
+ binding.value.__bind(handle, binding.prop);
93
96
  if (bound === undefined) {
94
97
  bound = new Map();
95
98
  boundValues.set(handle, bound);
96
99
  }
97
- bound.set(b.prop, b.value);
100
+ bound.set(binding.prop, binding.value);
98
101
  }
99
102
  }
100
103
 
101
104
  /**
102
105
  * Forgets what a handle was bound to. The engine releases the bindings itself when a node is destroyed
103
- * (er_anim_unbind_node), so this only drops our record — but it has to happen, because handles are
104
- * recycled: a record left behind would make the next node to claim that handle look already-bound.
105
- * Called on destroy for the node React hands us, and again on create because destroyNode reclaims a
106
- * whole SUBTREE in C — React never mentions the descendants, so their handles come back from the free
107
- * list still carrying a record.
106
+ * (er_animation_unbind_node), so this only drops our record — but it has to happen, or the map keeps a
107
+ * record for every destroyed node. Called on destroy for the node React hands us, and again from
108
+ * detachDeletedInstance because destroyNode reclaims a whole SUBTREE in C — React never hands
109
+ * removeChild the descendants, and detaching is where it names them.
108
110
  */
109
111
  function forgetBindings(handle) {
110
112
  boundValues.delete(handle);
@@ -115,6 +117,7 @@ function forgetBindings(handle) {
115
117
  // children of a parent that did not fit are never attached to anything, and removing that parent frees
116
118
  // nothing in C. Each failed create gets its own negative instance (the bridge ignores handles <= 0), and
117
119
  // the children appended to it are kept here so they are freed when it is deleted.
120
+ const FAILED_CREATE = 0; // createNode's handle when the pool is full
118
121
  const orphansOf = new Map(); // failed instance → Set of child handles
119
122
  let nextFailedInstance = -1;
120
123
 
@@ -184,13 +187,14 @@ function applyTextSpans(type, handle, props, flatStyle) {
184
187
  }
185
188
 
186
189
  /** Resolves an <Svg>'s render-box dimension from style/props, falling back to the source's intrinsic size. */
187
- function svgBoxSize(props, dim, intrinsic) {
188
- const s =
189
- props.style && typeof props.style[dim] === 'number'
190
- ? props.style[dim]
190
+ function svgBoxSize(props, dimension, intrinsic) {
191
+ const styleSize =
192
+ props.style && typeof props.style[dimension] === 'number'
193
+ ? props.style[dimension]
191
194
  : undefined;
192
- const p = typeof props[dim] === 'number' ? props[dim] : undefined;
193
- return s ?? p ?? intrinsic;
195
+ const propSize =
196
+ typeof props[dimension] === 'number' ? props[dimension] : undefined;
197
+ return styleSize ?? propSize ?? intrinsic;
194
198
  }
195
199
 
196
200
  /**
@@ -200,17 +204,17 @@ function svgBoxSize(props, dim, intrinsic) {
200
204
  * (an imported artifact's kind is fixed at build time, so it never flips for a given element).
201
205
  */
202
206
  function rasterSvgArtifact(type, props) {
203
- const src = props && props.source;
204
- return type === 'Svg' && src && src.kind === 'raster' ? src : null;
207
+ const source = props && props.source;
208
+ return type === 'Svg' && source && source.kind === 'raster' ? source : null;
205
209
  }
206
210
 
207
211
  /** Maps a raster `<Svg source>` to equivalent `<Image>` props: the baked asset name + the resolved box size. */
208
- function rasterImageProps(props, art) {
209
- const width = svgBoxSize(props, 'width', art.width);
210
- const height = svgBoxSize(props, 'height', art.height);
212
+ function rasterImageProps(props, artifact) {
213
+ const width = svgBoxSize(props, 'width', artifact.width);
214
+ const height = svgBoxSize(props, 'height', artifact.height);
211
215
  return {
212
216
  ...props,
213
- source: art.name,
217
+ source: artifact.name,
214
218
  style: {...(props.style || {}), width, height},
215
219
  };
216
220
  }
@@ -227,12 +231,12 @@ function applyVectorOps(type, handle, props) {
227
231
  let ops;
228
232
  let paints;
229
233
  let gradients;
230
- const src = props.source;
231
- if (src && src.kind === 'vector' && Array.isArray(src.ops)) {
234
+ const source = props.source;
235
+ if (source && source.kind === 'vector' && Array.isArray(source.ops)) {
232
236
  ({ops, paints, gradients} = scaleVectorArtifact(
233
- src,
234
- svgBoxSize(props, 'width', src.width),
235
- svgBoxSize(props, 'height', src.height),
237
+ source,
238
+ svgBoxSize(props, 'width', source.width),
239
+ svgBoxSize(props, 'height', source.height),
236
240
  ));
237
241
  } else {
238
242
  ({ops, paints, gradients} = flattenSvg(props));
@@ -262,12 +266,16 @@ function applyVectorOps(type, handle, props) {
262
266
  * drag, a color tweak) does not need the tape re-uploaded.
263
267
  */
264
268
  function svgSourceBoxChanged(prevProps, nextProps) {
265
- const src = nextProps.source;
266
- const iw = src && src.kind === 'vector' ? src.width : undefined;
267
- const ih = src && src.kind === 'vector' ? src.height : undefined;
269
+ const source = nextProps.source;
270
+ const intrinsicWidth =
271
+ source && source.kind === 'vector' ? source.width : undefined;
272
+ const intrinsicHeight =
273
+ source && source.kind === 'vector' ? source.height : undefined;
268
274
  return (
269
- svgBoxSize(prevProps, 'width', iw) !== svgBoxSize(nextProps, 'width', iw) ||
270
- svgBoxSize(prevProps, 'height', ih) !== svgBoxSize(nextProps, 'height', ih)
275
+ svgBoxSize(prevProps, 'width', intrinsicWidth) !==
276
+ svgBoxSize(nextProps, 'width', intrinsicWidth) ||
277
+ svgBoxSize(prevProps, 'height', intrinsicHeight) !==
278
+ svgBoxSize(nextProps, 'height', intrinsicHeight)
271
279
  );
272
280
  }
273
281
 
@@ -300,10 +308,10 @@ function diffUpdate(type, prevProps, nextProps) {
300
308
  let events = false;
301
309
  let vector = false;
302
310
  const diffKey = key => {
303
- const a = prevProps[key];
304
- const b = nextProps[key];
305
- if (Object.is(a, b)) return;
306
- if (isEventProp(key, a) || isEventProp(key, b)) {
311
+ const previousValue = prevProps[key];
312
+ const nextValue = nextProps[key];
313
+ if (Object.is(previousValue, nextValue)) return;
314
+ if (isEventProp(key, previousValue) || isEventProp(key, nextValue)) {
307
315
  events = true;
308
316
  return;
309
317
  }
@@ -312,16 +320,16 @@ function diffUpdate(type, prevProps, nextProps) {
312
320
  // Only subtree-owning types render children through their OWN props (shouldSetTextContent);
313
321
  // everywhere else children are separate host instances React mutates directly.
314
322
  if (type === 'Text') {
315
- if (!deepEqualProps(a, b)) {
323
+ if (!deepEqualProps(previousValue, nextValue)) {
316
324
  props = true; // flat.text is built from children
317
325
  spans = true;
318
326
  }
319
327
  } else if (type === 'Svg') {
320
- if (!deepEqualProps(a, b)) vector = true;
328
+ if (!deepEqualProps(previousValue, nextValue)) vector = true;
321
329
  }
322
330
  return;
323
331
  case 'style':
324
- if (!deepEqualProps(a, b)) {
332
+ if (!deepEqualProps(previousValue, nextValue)) {
325
333
  props = true;
326
334
  if (type === 'Text') spans = true;
327
335
  if (type === 'Svg' && nextProps.source)
@@ -342,7 +350,7 @@ function diffUpdate(type, prevProps, nextProps) {
342
350
  }
343
351
  // fall through: on other types these are ordinary (ignored or passthrough) props
344
352
  default:
345
- if (!deepEqualProps(a, b)) {
353
+ if (!deepEqualProps(previousValue, nextValue)) {
346
354
  props = true;
347
355
  // A source tape ignores root paint.
348
356
  if (type === 'Svg' && !nextProps.source && PAINT_PROPS.includes(key))
@@ -418,15 +426,13 @@ export const hostConfig = {
418
426
  const raster = rasterSvgArtifact(type, props);
419
427
  if (raster) {
420
428
  const handle = NativeUI.createNode('Image');
421
- if (handle === 0) return nextFailedInstance--;
422
- forgetBindings(handle);
429
+ if (handle === FAILED_CREATE) return nextFailedInstance--;
423
430
  applyProps('Image', handle, rasterImageProps(props, raster));
424
431
  applyEvents(handle, null, props);
425
432
  return handle;
426
433
  }
427
434
  const handle = NativeUI.createNode(type);
428
- if (handle === 0) return nextFailedInstance--;
429
- forgetBindings(handle);
435
+ if (handle === FAILED_CREATE) return nextFailedInstance--;
430
436
  const flatStyle = applyProps(type, handle, props);
431
437
  applyTextSpans(type, handle, props, flatStyle);
432
438
  applyVectorOps(type, handle, props);
@@ -515,6 +521,7 @@ export const hostConfig = {
515
521
  detachDeletedInstance(instance) {
516
522
  // Called for every host instance in a deleted subtree, including failed creates below its top.
517
523
  if (instance < 0) freeOrphans(instance);
524
+ else forgetBindings(instance);
518
525
  },
519
526
  getCurrentEventPriority() {
520
527
  return DefaultEventPriority;
@@ -530,12 +537,12 @@ export const hostConfig = {
530
537
  },
531
538
 
532
539
  // --- Scheduling ---
533
- scheduleTimeout: (fn, delay) => setTimeout(fn, delay),
534
- cancelTimeout: id => clearTimeout(id),
540
+ scheduleTimeout: (callback, delay) => setTimeout(callback, delay),
541
+ cancelTimeout: timeoutId => clearTimeout(timeoutId),
535
542
  supportsMicrotasks: true,
536
543
  scheduleMicrotask:
537
544
  typeof queueMicrotask === 'function'
538
545
  ? queueMicrotask
539
- : fn => Promise.resolve().then(fn),
546
+ : callback => Promise.resolve().then(callback),
540
547
  now: () => NativeUI.now(),
541
548
  };
package/src/props.js CHANGED
@@ -64,22 +64,22 @@ export const PASSTHROUGH = [
64
64
  ];
65
65
 
66
66
  /**
67
- * Flattens RN-style `style` (object or nested array) into the `out` object.
67
+ * Flattens RN-style `style` (object or nested array) into the `output` object.
68
68
  */
69
- export function flattenStyle(style, out) {
69
+ export function flattenStyle(style, output) {
70
70
  if (!style) return;
71
71
  if (Array.isArray(style)) {
72
- for (const s of style) flattenStyle(s, out);
72
+ for (const entry of style) flattenStyle(entry, output);
73
73
  } else {
74
- Object.assign(out, style);
74
+ Object.assign(output, style);
75
75
  }
76
76
  }
77
77
 
78
78
  /** Flattens a style (object/array) into a fresh plain object. */
79
79
  export function flattenStyleObj(style) {
80
- const out = {};
81
- flattenStyle(style, out);
82
- return out;
80
+ const flattened = {};
81
+ flattenStyle(style, flattened);
82
+ return flattened;
83
83
  }
84
84
 
85
85
  // Style fields the engine honors per inline text span (everything else inherits from the node).
@@ -127,7 +127,7 @@ export function flattenTextChildren(children, baseStyle) {
127
127
  return;
128
128
  }
129
129
  if (Array.isArray(node)) {
130
- for (const c of node) walk(c, style);
130
+ for (const child of node) walk(child, style);
131
131
  return;
132
132
  }
133
133
  if (node && node.props !== undefined) {
@@ -152,11 +152,12 @@ export function buildTextSpans(props, flatStyle) {
152
152
  if (!isTextContent(props.children)) return [];
153
153
  const baseStyle = flatStyle || flattenStyleObj(props.style);
154
154
  const segments = flattenTextChildren(props.children, baseStyle);
155
- if (!segments.some(s => s.style !== baseStyle)) return [];
156
- return segments.map(s => {
157
- const span = {text: s.text};
158
- for (const k of SPAN_STYLE_KEYS) {
159
- if (s.style && s.style[k] !== undefined) span[k] = s.style[k];
155
+ if (!segments.some(segment => segment.style !== baseStyle)) return [];
156
+ return segments.map(segment => {
157
+ const span = {text: segment.text};
158
+ for (const key of SPAN_STYLE_KEYS) {
159
+ if (segment.style && segment.style[key] !== undefined)
160
+ span[key] = segment.style[key];
160
161
  }
161
162
  return span;
162
163
  });
@@ -181,8 +182,8 @@ export function resolveImageSource(source) {
181
182
  export function buildProps(type, props, flatStyle) {
182
183
  const flat = flatStyle ? {...flatStyle} : {};
183
184
  if (!flatStyle) flattenStyle(props.style, flat);
184
- for (const k of PASSTHROUGH) {
185
- if (props[k] !== undefined) flat[k] = props[k];
185
+ for (const key of PASSTHROUGH) {
186
+ if (props[key] !== undefined) flat[key] = props[key];
186
187
  }
187
188
  // <Svg> takes width/height as DIRECT props (the react-native-svg convention) — the engine sizes the
188
189
  // vector node from them. Fold them into the resolved style (an explicit style width/height still wins)
@@ -221,9 +222,9 @@ export function buildProps(type, props, flatStyle) {
221
222
  // The engine renders this when no spans are set; with spans (buildTextSpans) it carries the same
222
223
  // text for the plain-text fallback. Non-flattenable children fall back to mounted child instances.
223
224
  if (type === 'Text' && isTextContent(props.children)) {
224
- const base = flatStyle || flattenStyleObj(props.style);
225
- flat.text = flattenTextChildren(props.children, base)
226
- .map(s => s.text)
225
+ const baseStyle = flatStyle || flattenStyleObj(props.style);
226
+ flat.text = flattenTextChildren(props.children, baseStyle)
227
+ .map(segment => segment.text)
227
228
  .join('');
228
229
  }
229
230
  return flat;
@@ -242,43 +243,50 @@ const DEEP_EQUAL_MAX_DEPTH = 24;
242
243
  * Animated.Value) compare by IDENTITY only: a fresh instance must read as changed, so it gets bound
243
244
  * to the node, while the same instance is already bound and can be skipped.
244
245
  */
245
- export function deepEqualProps(a, b, depth = 0) {
246
- if (Object.is(a, b)) return true;
246
+ export function deepEqualProps(left, right, depth = 0) {
247
+ if (Object.is(left, right)) return true;
247
248
  if (depth >= DEEP_EQUAL_MAX_DEPTH) return false;
248
249
  if (
249
- typeof a !== 'object' ||
250
- typeof b !== 'object' ||
251
- a === null ||
252
- b === null
250
+ typeof left !== 'object' ||
251
+ typeof right !== 'object' ||
252
+ left === null ||
253
+ right === null
253
254
  )
254
255
  return false;
255
- if (Array.isArray(a) || Array.isArray(b)) {
256
- if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)
256
+ if (Array.isArray(left) || Array.isArray(right)) {
257
+ if (
258
+ !Array.isArray(left) ||
259
+ !Array.isArray(right) ||
260
+ left.length !== right.length
261
+ )
257
262
  return false;
258
- for (let i = 0; i < a.length; i++) {
259
- if (!deepEqualProps(a[i], b[i], depth + 1)) return false;
263
+ for (let index = 0; index < left.length; index++) {
264
+ if (!deepEqualProps(left[index], right[index], depth + 1)) return false;
260
265
  }
261
266
  return true;
262
267
  }
263
268
  // React elements: equal when they render the same host output — same type, same props.
264
- if (a.$$typeof !== b.$$typeof) return false;
265
- if (a.$$typeof !== undefined) {
266
- return a.type === b.type && deepEqualProps(a.props, b.props, depth + 1);
269
+ if (left.$$typeof !== right.$$typeof) return false;
270
+ if (left.$$typeof !== undefined) {
271
+ return (
272
+ left.type === right.type &&
273
+ deepEqualProps(left.props, right.props, depth + 1)
274
+ );
267
275
  }
268
276
  // Plain objects only; class instances fall through to "changed" (identity already ruled equal out).
269
- const protoA = Object.getPrototypeOf(a);
270
- const protoB = Object.getPrototypeOf(b);
277
+ const leftPrototype = Object.getPrototypeOf(left);
278
+ const rightPrototype = Object.getPrototypeOf(right);
271
279
  if (
272
- (protoA !== null && protoA !== Object.prototype) ||
273
- (protoB !== null && protoB !== Object.prototype)
280
+ (leftPrototype !== null && leftPrototype !== Object.prototype) ||
281
+ (rightPrototype !== null && rightPrototype !== Object.prototype)
274
282
  )
275
283
  return false;
276
- const keysA = Object.keys(a);
277
- const keysB = Object.keys(b);
278
- if (keysA.length !== keysB.length) return false;
279
- for (const k of keysA) {
280
- if (!Object.prototype.hasOwnProperty.call(b, k)) return false;
281
- if (!deepEqualProps(a[k], b[k], depth + 1)) return false;
284
+ const leftKeys = Object.keys(left);
285
+ const rightKeys = Object.keys(right);
286
+ if (leftKeys.length !== rightKeys.length) return false;
287
+ for (const key of leftKeys) {
288
+ if (!Object.prototype.hasOwnProperty.call(right, key)) return false;
289
+ if (!deepEqualProps(left[key], right[key], depth + 1)) return false;
282
290
  }
283
291
  return true;
284
292
  }
package/src/renderer.js CHANGED
@@ -34,19 +34,19 @@ const LegacyRoot = 0;
34
34
  // frame does in one batch and leaves it as one render and one commit. Installed here rather than at
35
35
  // createRoot() so the reconciler that batches is the one that renders.
36
36
  // On an instrumented build the batcher is also where the JS phase's split gets drawn (er_perf.h):
37
- // `fn(a, b)` is the callback, and whatever batchedUpdates does around it is React's render. That
37
+ // `callback(firstArgument, secondArgument)` is the callback, and whatever batchedUpdates does around it is React's render. That
38
38
  // boundary is only visible from here — React flushes when it decides to, not reliably at the batch
39
39
  // call the C side can see — so marking it in C measured the call overhead and left reconcile at ~0.
40
40
  // The instrumented wrapper is chosen ONCE, here, so an ordinary build runs the plain one.
41
41
  NativeUI.setBatcher?.(
42
42
  NativeUI.perfRenderBegin
43
- ? (fn, a, b) => {
43
+ ? (callback, firstArgument, secondArgument) => {
44
44
  NativeUI.perfRenderBegin();
45
45
  try {
46
46
  return reconciler.batchedUpdates(() => {
47
47
  NativeUI.perfCallbackBegin();
48
48
  try {
49
- return fn(a, b);
49
+ return callback(firstArgument, secondArgument);
50
50
  } finally {
51
51
  NativeUI.perfCallbackEnd();
52
52
  }
@@ -55,7 +55,10 @@ NativeUI.setBatcher?.(
55
55
  NativeUI.perfRenderEnd();
56
56
  }
57
57
  }
58
- : (fn, a, b) => reconciler.batchedUpdates(() => fn(a, b)),
58
+ : (callback, firstArgument, secondArgument) =>
59
+ reconciler.batchedUpdates(() =>
60
+ callback(firstArgument, secondArgument),
61
+ ),
59
62
  );
60
63
 
61
64
  /**