embedded-react 0.3.0 → 0.4.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.
@@ -18,8 +18,14 @@
18
18
  // changes layout makes the engine tween every node whose computed rect moved (instead of snapping)
19
19
  // on the next commit. Backed by the engine's er_layout_anim_configure_next; the tween advances in C
20
20
  // each frame (er_layout_anim_tick), so there's no per-frame JS.
21
- import { NativeUI } from '../native-ui.js';
22
- import { Types, Properties, Presets, toEngineConfig, create } from './layout-anim-config.js';
21
+ import {NativeUI} from '../native-ui.js';
22
+ import {
23
+ Types,
24
+ Properties,
25
+ Presets,
26
+ toEngineConfig,
27
+ create,
28
+ } from './layout-anim-config.js';
23
29
 
24
30
  /**
25
31
  * Arms a layout animation for the next commit. Call right before the setState that changes layout.
@@ -28,7 +34,8 @@ import { Types, Properties, Presets, toEngineConfig, create } from './layout-ani
28
34
  export function configureNext(config, onAnimationDidEnd) {
29
35
  NativeUI.configureNextLayoutAnimation(toEngineConfig(config));
30
36
  if (typeof onAnimationDidEnd === 'function') {
31
- const ms = config && typeof config.duration === 'number' ? config.duration : 300;
37
+ const ms =
38
+ config && typeof config.duration === 'number' ? config.duration : 300;
32
39
  setTimeout(onAnimationDidEnd, ms);
33
40
  }
34
41
  }
@@ -39,7 +46,7 @@ export const LayoutAnimation = {
39
46
  Types,
40
47
  Properties,
41
48
  Presets,
42
- easeInEaseOut: (onDone) => configureNext(Presets.easeInEaseOut, onDone),
43
- linear: (onDone) => configureNext(Presets.linear, onDone),
44
- spring: (onDone) => configureNext(Presets.spring, onDone),
49
+ easeInEaseOut: onDone => configureNext(Presets.easeInEaseOut, onDone),
50
+ linear: onDone => configureNext(Presets.linear, onDone),
51
+ spring: onDone => configureNext(Presets.spring, onDone),
45
52
  };
@@ -32,5 +32,5 @@ export const StyleSheet = {
32
32
  },
33
33
 
34
34
  hairlineWidth: 1,
35
- absoluteFill: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 },
35
+ absoluteFill: {position: 'absolute', top: 0, left: 0, right: 0, bottom: 0},
36
36
  };
@@ -20,8 +20,8 @@
20
20
  // reconcile + flatten dominate. For continuous gestures (e.g., dragging a dial), grab a node handle via
21
21
  // a ref and push updates directly here: it skips React entirely and, for vectors, skips the d-string
22
22
  // parser too. Commit back to React state when the gesture ends so the declarative tree re-syncs.
23
- import { NativeUI } from '../native-ui.js';
24
- import { shapesToVector } from './svg-ops.js';
23
+ import {NativeUI} from '../native-ui.js';
24
+ import {shapesToVector, warnVectorCaps} from './svg-ops.js';
25
25
 
26
26
  /**
27
27
  * Imperatively sets an <Svg> node's geometry from primitive shape descriptors (see shapesToVector).
@@ -33,8 +33,20 @@ import { shapesToVector } from './svg-ops.js';
33
33
  */
34
34
  export function updateVector(handle, shapes, dirtyRect) {
35
35
  if (handle == null) return;
36
- const { ops, paints } = shapesToVector(shapes);
37
- NativeUI.setVectorOps(handle, ops, paints, dirtyRect);
36
+ const {ops, paints} = shapesToVector(shapes);
37
+ warnVectorCaps(
38
+ ops.length,
39
+ paints.length,
40
+ NativeUI.maxVectorOps,
41
+ NativeUI.maxVectorPaints,
42
+ );
43
+ NativeUI.setVectorOps(
44
+ handle,
45
+ ops,
46
+ paints,
47
+ undefined /* gradients: imperative shapes are solid */,
48
+ dirtyRect,
49
+ );
38
50
  }
39
51
 
40
52
  /**
@@ -45,13 +57,13 @@ export function updateVector(handle, shapes, dirtyRect) {
45
57
  */
46
58
  export function updateText(handle, text) {
47
59
  if (handle == null) return;
48
- NativeUI.setTextSpans(handle, [{ text: String(text) }]);
60
+ NativeUI.setTextSpans(handle, [{text: String(text)}]);
49
61
  }
50
62
 
51
63
  /**
52
- * Customises the on-screen software keyboard's appearance and/or layout. Only effective when the engine was
64
+ * Customizes the on-screen software keyboard's appearance and/or layout. Only effective when the engine was
53
65
  * built with the keyboard enabled (ERUI_ONSCREEN_KEYBOARD=1); a no-op otherwise. The config is a plain
54
- * object of colours/sizes plus an optional `layers` array; omit `layers` to keep the built-in QWERTY:
66
+ * object of colors/sizes plus an optional `layers` array; omit `layers` to keep the built-in QWERTY:
55
67
  *
56
68
  * setKeyboardConfig({ keyColor: '#fff', labelColor: '#111', fontSize: 20,
57
69
  * layers: [ [ [ { char: 'a' }, ... ], // a row
@@ -42,11 +42,11 @@ export {
42
42
  G,
43
43
  Arc,
44
44
  } from './components.js';
45
- export { updateVector, updateText, setKeyboardConfig } from './imperative.js';
46
- export { StyleSheet } from './StyleSheet.js';
47
- export { Platform } from './Platform.js';
48
- export { AppRegistry } from './AppRegistry.js';
49
- export { Animated, useAnimatedValue } from './Animated.js';
50
- export { usePersistentState } from './usePersistentState.js';
51
- export { Easing } from './Easing.js';
52
- export { LayoutAnimation } from './LayoutAnimation.js';
45
+ export {updateVector, updateText, setKeyboardConfig} from './imperative.js';
46
+ export {StyleSheet} from './StyleSheet.js';
47
+ export {Platform} from './Platform.js';
48
+ export {AppRegistry} from './AppRegistry.js';
49
+ export {Animated, useAnimatedValue} from './Animated.js';
50
+ export {usePersistentState} from './usePersistentState.js';
51
+ export {Easing} from './Easing.js';
52
+ export {LayoutAnimation} from './LayoutAnimation.js';
@@ -63,18 +63,22 @@ export function toEngineConfig(config) {
63
63
  const update = c.update || {};
64
64
  const type = update.type || c.type || Types.easeInEaseOut;
65
65
  if (type === Types.spring) {
66
- return { type: 'spring', duration };
66
+ return {type: 'spring', duration};
67
67
  }
68
- return { type: 'timing', duration, easing: easingForType(type) };
68
+ return {type: 'timing', duration, easing: easingForType(type)};
69
69
  }
70
70
 
71
71
  /** Builds an RN-shaped config (duration + create/update/delete) from a type + creation property. */
72
- export function create(duration, type = Types.easeInEaseOut, creationProp = Properties.opacity) {
72
+ export function create(
73
+ duration,
74
+ type = Types.easeInEaseOut,
75
+ creationProp = Properties.opacity,
76
+ ) {
73
77
  return {
74
78
  duration,
75
- create: { type, property: creationProp },
76
- update: { type },
77
- delete: { type, property: creationProp },
79
+ create: {type, property: creationProp},
80
+ update: {type},
81
+ delete: {type, property: creationProp},
78
82
  };
79
83
  }
80
84
 
@@ -84,8 +88,8 @@ export const Presets = {
84
88
  linear: create(500, Types.linear, Properties.opacity),
85
89
  spring: {
86
90
  duration: 700,
87
- create: { type: Types.linear, property: Properties.opacity },
88
- update: { type: Types.spring, springDamping: 0.4 },
89
- delete: { type: Types.linear, property: Properties.opacity },
91
+ create: {type: Types.linear, property: Properties.opacity},
92
+ update: {type: Types.spring, springDamping: 0.4},
93
+ delete: {type: Types.linear, property: Properties.opacity},
90
94
  },
91
95
  };
@@ -18,7 +18,7 @@
18
18
  // bindings (Animated.Value / interpolation, bound to the node's prop so the engine drives them).
19
19
  // Pure (no NativeUI), so it's unit-testable. An animated entry is anything with an `__animated`
20
20
  // marker — `transform: [{ translateX: value }]` entries are handled too (scale binds both axes).
21
- import { flattenStyle } from '../props.js';
21
+ import {flattenStyle} from '../props.js';
22
22
 
23
23
  export function splitAnimatedStyle(style) {
24
24
  const staticStyle = {};
@@ -37,10 +37,10 @@ export function splitAnimatedStyle(style) {
37
37
  const v = entry[axis];
38
38
  if (v && v.__animated) {
39
39
  if (axis === 'scale') {
40
- bindings.push({ prop: 'scaleX', value: v });
41
- bindings.push({ prop: 'scaleY', value: v });
40
+ bindings.push({prop: 'scaleX', value: v});
41
+ bindings.push({prop: 'scaleY', value: v});
42
42
  } else {
43
- bindings.push({ prop: axis, value: v });
43
+ bindings.push({prop: axis, value: v});
44
44
  }
45
45
  } else {
46
46
  staticTransform.push(entry);
@@ -48,11 +48,11 @@ export function splitAnimatedStyle(style) {
48
48
  }
49
49
  if (staticTransform.length > 0) staticStyle.transform = staticTransform;
50
50
  } else if (val && val.__animated) {
51
- bindings.push({ prop: key, value: val });
51
+ bindings.push({prop: key, value: val});
52
52
  } else {
53
53
  staticStyle[key] = val;
54
54
  }
55
55
  }
56
56
 
57
- return { staticStyle, bindings };
57
+ return {staticStyle, bindings};
58
58
  }