embedded-react 0.12.0 → 0.13.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.
- package/README.md +144 -5
- package/aot/compile.mjs +1222 -72
- package/aot/style-map.mjs +10 -5
- package/assets/bake-font.mjs +104 -12
- package/assets/bake-svg.mjs +11 -1
- package/assets/build-builtin-font.mjs +6 -12
- package/assets/emit-c.mjs +10 -2
- package/assets/font-config.mjs +49 -0
- package/assets/font-sizes.mjs +652 -0
- package/assets/glyph-coverage.mjs +281 -0
- package/assets/index.mjs +29 -5
- package/build.mjs +11 -21
- package/cli.mjs +13 -1
- package/compile-bin.mjs +71 -0
- package/hotreload/pack-app.mjs +8 -21
- package/hotreload/pack-split.mjs +12 -27
- package/pack-container.mjs +10 -47
- package/package.json +2 -1
- package/sim/embedded-react.wasm +0 -0
- package/sim/index.html +32 -3
- package/sim-server.mjs +33 -27
- package/src/embedded-react/Animated.js +23 -9
- package/src/embedded-react/Button.js +98 -0
- package/src/embedded-react/FlatList.js +88 -0
- package/src/embedded-react/ImageBackground.js +67 -0
- package/src/embedded-react/PanResponder.js +326 -0
- package/src/embedded-react/SectionList.js +148 -0
- package/src/embedded-react/TouchableOpacity.js +152 -0
- package/src/embedded-react/components.js +4 -3
- package/src/embedded-react/index.d.ts +866 -60
- package/src/embedded-react/index.js +7 -2
- package/src/embedded-react/list-child.js +54 -0
- package/src/embedded-react/svg-ops.js +220 -72
- package/src/embedded-react/warn-props.js +80 -0
- package/src/host-config.js +98 -3
- package/src/props.js +38 -0
|
@@ -14,20 +14,116 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
// Public type declarations for the `embedded-react` package — the React Native analog.
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
17
|
+
// Public type declarations for the `embedded-react` package — the React Native analog. The runtime is
|
|
18
|
+
// JavaScript and ignores types entirely; these only power editors and `tsc`. React hooks (useState,
|
|
19
|
+
// useEffect, …) still come from 'react', as in React Native.
|
|
20
|
+
//
|
|
21
|
+
// What is declared here is what the RUNTIME honors. The sources of truth are the bridge's prop and event
|
|
22
|
+
// tables (`k_prop_names` / `event_type_from_name` in bridges/quickjs/native_ui_bridge.c), the top-level
|
|
23
|
+
// prop list (`PASSTHROUGH` in src/props.js), and the SVG compiler (src/embedded-react/svg-ops.js). A prop
|
|
24
|
+
// the engine ignores is deliberately absent, so a name that typechecks is a name that reaches the engine.
|
|
25
|
+
// `npm test` runs a parity test over those tables to keep it that way.
|
|
26
|
+
//
|
|
27
|
+
// Flow B (the AOT compiler) lowers a documented SUBSET of this surface and fails the build on anything it
|
|
28
|
+
// cannot compile, so these types describe Flow A and the AOT reports the difference.
|
|
21
29
|
|
|
22
|
-
import type {ReactNode} from 'react';
|
|
30
|
+
import type {ReactNode, Ref} from 'react';
|
|
31
|
+
|
|
32
|
+
/** A node handle: what a `ref` on a host component receives, and what the imperative API takes. */
|
|
33
|
+
export type NodeHandle = number;
|
|
23
34
|
|
|
24
35
|
// --- Styling ---------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A box dimension. Percentage strings are resolved for `width` and `height` only — every other box
|
|
39
|
+
* property (margins, padding, min/max, borders, insets) takes pixels and ignores a string.
|
|
40
|
+
*/
|
|
41
|
+
export type DimensionValue = number | `${number}%`;
|
|
42
|
+
|
|
43
|
+
/** Drop-shadow displacement in px (RN's `shadowOffset`). */
|
|
44
|
+
export interface ShadowOffset {
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Fractional pivot `[x, y]` in 0–1 that `transform` rotates and scales about. Defaults to the centre. */
|
|
50
|
+
export type TransformOrigin = [number, number];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* One transform entry. Every axis except `perspective` can be driven by an `AnimatedValue`; `scale` binds
|
|
54
|
+
* both axes at once. Rotations are CSS angle strings ('45deg', '0.5rad').
|
|
55
|
+
*/
|
|
56
|
+
export type TransformStyle =
|
|
57
|
+
| {scale: number | AnimatedValue}
|
|
58
|
+
| {scaleX: number | AnimatedValue}
|
|
59
|
+
| {scaleY: number | AnimatedValue}
|
|
60
|
+
| {translateX: number | AnimatedValue}
|
|
61
|
+
| {translateY: number | AnimatedValue}
|
|
62
|
+
| {rotate: string | AnimatedValue}
|
|
63
|
+
| {rotateX: string | AnimatedValue}
|
|
64
|
+
| {rotateY: string | AnimatedValue}
|
|
65
|
+
| {rotateZ: string | AnimatedValue}
|
|
66
|
+
| {perspective: number};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Value type of an untyped style entry. Styles stay open (a not-yet-declared key is not an error), and the
|
|
70
|
+
* union covers the object- and array-valued entries — `shadowOffset`, `transformOrigin`, `transform` — so
|
|
71
|
+
* they are legal both under their own declarations and through the index signature.
|
|
72
|
+
*/
|
|
73
|
+
export type StyleValue =
|
|
74
|
+
| string
|
|
75
|
+
| number
|
|
76
|
+
| AnimatedValue
|
|
77
|
+
| TransformStyle[]
|
|
78
|
+
| ShadowOffset
|
|
79
|
+
| TransformOrigin
|
|
80
|
+
| undefined;
|
|
81
|
+
|
|
25
82
|
/** A single style object. Properties mirror the React Native subset the engine supports. */
|
|
26
83
|
export interface ViewStyle {
|
|
27
|
-
[key: string]:
|
|
84
|
+
[key: string]: StyleValue;
|
|
85
|
+
|
|
86
|
+
// Box size.
|
|
87
|
+
width?: DimensionValue;
|
|
88
|
+
height?: DimensionValue;
|
|
89
|
+
minWidth?: number;
|
|
90
|
+
minHeight?: number;
|
|
91
|
+
maxWidth?: number;
|
|
92
|
+
maxHeight?: number;
|
|
93
|
+
aspectRatio?: number;
|
|
94
|
+
|
|
95
|
+
// Insets (with `position: 'absolute'`). A percentage measures against the containing block:
|
|
96
|
+
// left/right against its width, top/bottom against its height.
|
|
97
|
+
top?: DimensionValue;
|
|
98
|
+
left?: DimensionValue;
|
|
99
|
+
right?: DimensionValue;
|
|
100
|
+
bottom?: DimensionValue;
|
|
101
|
+
|
|
102
|
+
// Margin.
|
|
103
|
+
margin?: number;
|
|
104
|
+
marginTop?: number;
|
|
105
|
+
marginRight?: number;
|
|
106
|
+
marginBottom?: number;
|
|
107
|
+
marginLeft?: number;
|
|
108
|
+
marginHorizontal?: number;
|
|
109
|
+
marginVertical?: number;
|
|
110
|
+
|
|
111
|
+
// Padding.
|
|
112
|
+
padding?: number;
|
|
113
|
+
paddingTop?: number;
|
|
114
|
+
paddingRight?: number;
|
|
115
|
+
paddingBottom?: number;
|
|
116
|
+
paddingLeft?: number;
|
|
117
|
+
paddingHorizontal?: number;
|
|
118
|
+
paddingVertical?: number;
|
|
119
|
+
|
|
120
|
+
// Flex.
|
|
28
121
|
flex?: number;
|
|
122
|
+
flexGrow?: number;
|
|
123
|
+
flexShrink?: number;
|
|
124
|
+
flexBasis?: number;
|
|
29
125
|
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
30
|
-
|
|
126
|
+
flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
31
127
|
justifyContent?:
|
|
32
128
|
| 'flex-start'
|
|
33
129
|
| 'flex-end'
|
|
@@ -35,111 +131,642 @@ export interface ViewStyle {
|
|
|
35
131
|
| 'space-between'
|
|
36
132
|
| 'space-around'
|
|
37
133
|
| 'space-evenly';
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
padding?: number;
|
|
48
|
-
paddingVertical?: number;
|
|
49
|
-
paddingHorizontal?: number;
|
|
134
|
+
alignItems?: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch';
|
|
135
|
+
alignSelf?: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch';
|
|
136
|
+
alignContent?:
|
|
137
|
+
| 'flex-start'
|
|
138
|
+
| 'flex-end'
|
|
139
|
+
| 'center'
|
|
140
|
+
| 'stretch'
|
|
141
|
+
| 'space-between'
|
|
142
|
+
| 'space-around';
|
|
50
143
|
gap?: number;
|
|
51
|
-
|
|
144
|
+
rowGap?: number;
|
|
145
|
+
columnGap?: number;
|
|
146
|
+
|
|
147
|
+
// Placement and visibility.
|
|
148
|
+
position?: 'relative' | 'absolute';
|
|
149
|
+
display?: 'flex' | 'none';
|
|
150
|
+
overflow?: 'visible' | 'hidden' | 'scroll';
|
|
151
|
+
zIndex?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Hit-testing behaviour for this node and its subtree. 'none' ignores touches entirely, 'box-none' lets
|
|
154
|
+
* children be touched but not the node itself, 'box-only' the reverse. RN also allows this as a
|
|
155
|
+
* top-level prop; here it is a style entry, which is what the engine reads.
|
|
156
|
+
*/
|
|
157
|
+
pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only';
|
|
158
|
+
|
|
159
|
+
// Paint.
|
|
160
|
+
backgroundColor?: string | AnimatedValue;
|
|
161
|
+
opacity?: number | AnimatedValue;
|
|
162
|
+
|
|
163
|
+
// Border.
|
|
52
164
|
borderRadius?: number;
|
|
165
|
+
borderTopLeftRadius?: number;
|
|
166
|
+
borderTopRightRadius?: number;
|
|
167
|
+
borderBottomLeftRadius?: number;
|
|
168
|
+
borderBottomRightRadius?: number;
|
|
53
169
|
borderWidth?: number;
|
|
170
|
+
borderTopWidth?: number;
|
|
171
|
+
borderRightWidth?: number;
|
|
172
|
+
borderBottomWidth?: number;
|
|
173
|
+
borderLeftWidth?: number;
|
|
54
174
|
borderColor?: string;
|
|
55
|
-
|
|
175
|
+
borderTopColor?: string;
|
|
176
|
+
borderRightColor?: string;
|
|
177
|
+
borderBottomColor?: string;
|
|
178
|
+
borderLeftColor?: string;
|
|
179
|
+
borderStyle?: 'solid' | 'dashed' | 'dotted';
|
|
180
|
+
|
|
181
|
+
// Transform.
|
|
56
182
|
transform?: TransformStyle[];
|
|
57
|
-
|
|
183
|
+
transformOrigin?: TransformOrigin;
|
|
184
|
+
|
|
185
|
+
// Shadow. Rendered only in a build with shadows enabled (ERUI_SHADOWS) and `shadowOpacity` above 0.
|
|
186
|
+
shadowColor?: string;
|
|
187
|
+
shadowOffset?: ShadowOffset;
|
|
188
|
+
shadowOpacity?: number;
|
|
189
|
+
shadowRadius?: number;
|
|
190
|
+
elevation?: number;
|
|
58
191
|
}
|
|
59
192
|
|
|
60
193
|
export interface TextStyle extends ViewStyle {
|
|
61
|
-
color?: string;
|
|
194
|
+
color?: string | AnimatedValue;
|
|
62
195
|
fontSize?: number;
|
|
63
196
|
fontFamily?: string;
|
|
197
|
+
/** Anything from 600 up (or 'bold') selects the bold face; the engine carries no other weights. */
|
|
64
198
|
fontWeight?: string | number;
|
|
199
|
+
/** 'italic' is a synthetic slant (horizontal shear), not a separate face. */
|
|
200
|
+
fontStyle?: 'normal' | 'italic';
|
|
65
201
|
textAlign?: 'auto' | 'left' | 'right' | 'center';
|
|
202
|
+
textDecorationLine?: 'none' | 'underline' | 'line-through';
|
|
203
|
+
lineHeight?: number;
|
|
204
|
+
letterSpacing?: number;
|
|
66
205
|
}
|
|
67
206
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
207
|
+
/** <Modal> styling: a View plus the scrim color painted behind the modal. */
|
|
208
|
+
export interface ModalStyle extends ViewStyle {
|
|
209
|
+
backdropColor?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** <TextInput> styling: text styling plus the caret color. */
|
|
213
|
+
export interface TextInputStyle extends TextStyle {
|
|
214
|
+
cursorColor?: string;
|
|
215
|
+
}
|
|
75
216
|
|
|
76
217
|
export type StyleProp<T> = T | false | null | undefined | StyleProp<T>[];
|
|
77
218
|
|
|
219
|
+
// --- Events ----------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
/** The laid-out box reported by `onLayout`, in parent coordinates. */
|
|
222
|
+
export interface LayoutRectangle {
|
|
223
|
+
x: number;
|
|
224
|
+
y: number;
|
|
225
|
+
width: number;
|
|
226
|
+
height: number;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The object an event handler receives. `type` is the engine's own name for the event that fired, so a
|
|
231
|
+
* handler shared between events can switch on it. Coordinates are screen px; `dx`/`dy` are the distance
|
|
232
|
+
* traveled since the touch went down.
|
|
233
|
+
*/
|
|
234
|
+
/**
|
|
235
|
+
* The touch payload every gesture callback receives: the point, the displacement from touch-down, and
|
|
236
|
+
* the speed the finger was traveling at when it was last measured. Raw `onTouch*` events carry the same
|
|
237
|
+
* fields as the responder events do, so a flick is `onTouchEnd={e => e.vx > 0.4 && next()}` — no
|
|
238
|
+
* PanResponder and no clock needed.
|
|
239
|
+
*/
|
|
240
|
+
export interface TouchPoint {
|
|
241
|
+
x: number;
|
|
242
|
+
y: number;
|
|
243
|
+
dx: number;
|
|
244
|
+
dy: number;
|
|
245
|
+
/** Velocity in px/ms, measured over the most recent move (0 before the first one). */
|
|
246
|
+
vx: number;
|
|
247
|
+
vy: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface NativeEvent<T extends string = string> extends TouchPoint {
|
|
251
|
+
type: T;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** The `type` string on each of the engine's responder lifecycle events. */
|
|
255
|
+
export type ResponderEvent = NativeEvent<
|
|
256
|
+
| 'responderGrant'
|
|
257
|
+
| 'responderReject'
|
|
258
|
+
| 'responderMove'
|
|
259
|
+
| 'responderRelease'
|
|
260
|
+
| 'responderTerminate'
|
|
261
|
+
>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* What a responder NEGOTIATION query is handed. Deliberately a bare `TouchPoint`: a query is not one
|
|
265
|
+
* of the named events — the engine asks it mid-hit-test — so the object carries NO `type` field. Reading
|
|
266
|
+
* `event.type` in a should-set predicate would be `undefined` at runtime, and the types say so.
|
|
267
|
+
*/
|
|
268
|
+
export type ResponderQueryEvent = TouchPoint;
|
|
269
|
+
|
|
270
|
+
/** Any touch or press event — the type to give a handler shared across several of them. */
|
|
271
|
+
export type GestureResponderEvent = NativeEvent<
|
|
272
|
+
| 'press'
|
|
273
|
+
| 'longPress'
|
|
274
|
+
| 'pressIn'
|
|
275
|
+
| 'pressOut'
|
|
276
|
+
| 'touchStart'
|
|
277
|
+
| 'touchMove'
|
|
278
|
+
| 'touchEnd'
|
|
279
|
+
| 'touchCancel'
|
|
280
|
+
>;
|
|
281
|
+
|
|
282
|
+
/** Any <TextInput> focus / blur / submit event. */
|
|
283
|
+
export type TextInputEvent = NativeEvent<'focus' | 'blur' | 'submitEditing'>;
|
|
284
|
+
|
|
285
|
+
export interface ScrollEvent extends NativeEvent<'scroll'> {
|
|
286
|
+
scrollX: number;
|
|
287
|
+
scrollY: number;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface LayoutChangeEvent extends NativeEvent<'layout'> {
|
|
291
|
+
layout: LayoutRectangle;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The gesture responder system, RN-shaped — accepted on every host component. The `*ShouldSet*` props
|
|
296
|
+
* are negotiation QUERIES: on every touch-down (start) and touch-move (move) the engine walks the hit
|
|
297
|
+
* chain — capture phase root→leaf first, then bubble leaf→root — and the first node whose predicate
|
|
298
|
+
* returns true claims the gesture. The `onResponder*` events then fire on the owner alone. A granted
|
|
299
|
+
* responder blocks a ScrollView ancestor's auto-scroll and takes the gesture back from one that has
|
|
300
|
+
* already started scrolling. Most apps want `PanResponder` (below) instead of wiring these directly.
|
|
301
|
+
*/
|
|
302
|
+
export interface GestureResponderHandlers {
|
|
303
|
+
onStartShouldSetResponder?: (event: ResponderQueryEvent) => boolean;
|
|
304
|
+
onStartShouldSetResponderCapture?: (event: ResponderQueryEvent) => boolean;
|
|
305
|
+
onMoveShouldSetResponder?: (event: ResponderQueryEvent) => boolean;
|
|
306
|
+
onMoveShouldSetResponderCapture?: (event: ResponderQueryEvent) => boolean;
|
|
307
|
+
/** The gesture was won: this node now owns the touch stream. */
|
|
308
|
+
onResponderGrant?: (event: ResponderEvent) => void;
|
|
309
|
+
/** A claim was refused — the current owner declined to yield. Re-asked on later moves. */
|
|
310
|
+
onResponderReject?: (event: ResponderEvent) => void;
|
|
311
|
+
/** A move while owning the gesture; `dx`/`dy` accumulate from touch-down. */
|
|
312
|
+
onResponderMove?: (event: ResponderEvent) => void;
|
|
313
|
+
/** The touch lifted while this node owned the gesture. */
|
|
314
|
+
onResponderRelease?: (event: ResponderEvent) => void;
|
|
315
|
+
/** The gesture was taken away (a canceled touch, or this node yielded to a challenger). */
|
|
316
|
+
onResponderTerminate?: (event: ResponderEvent) => void;
|
|
317
|
+
/** A challenger wants the gesture: return true to yield (the default), false to keep it. */
|
|
318
|
+
onResponderTerminationRequest?: (event: ResponderQueryEvent) => boolean;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Touch and layout handlers, accepted on every host component. Raw touches bubble from the node that was
|
|
323
|
+
* hit up through its ancestors, so a handler on a container sees its children's touches too — and they
|
|
324
|
+
* keep bubbling whatever the responder system decides; the responder props above are how a node OWNS a
|
|
325
|
+
* gesture. `onTouchCancel` fires when the sequence is abandoned rather than finished — the host reporting
|
|
326
|
+
* a canceled touch, or a fresh touch-down on a finger whose previous sequence never ended — and is the
|
|
327
|
+
* hook for undoing whatever `onTouchStart` began.
|
|
328
|
+
*/
|
|
329
|
+
export interface TouchEventProps extends GestureResponderHandlers {
|
|
330
|
+
onTouchStart?: (event: NativeEvent<'touchStart'>) => void;
|
|
331
|
+
onTouchMove?: (event: NativeEvent<'touchMove'>) => void;
|
|
332
|
+
onTouchEnd?: (event: NativeEvent<'touchEnd'>) => void;
|
|
333
|
+
onTouchCancel?: (event: NativeEvent<'touchCancel'>) => void;
|
|
334
|
+
onLayout?: (event: LayoutChangeEvent) => void;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* The press family. A press looks for the nearest ancestor carrying one of these, so wrapping a subtree in
|
|
339
|
+
* a single <Pressable> is enough — no handler per child.
|
|
340
|
+
*/
|
|
341
|
+
export interface PressEventProps {
|
|
342
|
+
onPress?: (event: NativeEvent<'press'>) => void;
|
|
343
|
+
onLongPress?: (event: NativeEvent<'longPress'>) => void;
|
|
344
|
+
onPressIn?: (event: NativeEvent<'pressIn'>) => void;
|
|
345
|
+
onPressOut?: (event: NativeEvent<'pressOut'>) => void;
|
|
346
|
+
delayLongPress?: number;
|
|
347
|
+
}
|
|
348
|
+
|
|
78
349
|
// --- Components ------------------------------------------------------------
|
|
79
|
-
|
|
350
|
+
|
|
351
|
+
export interface ViewProps extends TouchEventProps {
|
|
80
352
|
style?: StyleProp<ViewStyle>;
|
|
81
353
|
children?: ReactNode;
|
|
354
|
+
/** Prunes the subtree from layout, raster and hit-testing without unmounting it (style `display` wins). */
|
|
82
355
|
visible?: boolean;
|
|
356
|
+
ref?: Ref<NodeHandle>;
|
|
83
357
|
}
|
|
84
358
|
|
|
85
|
-
export interface TextProps {
|
|
359
|
+
export interface TextProps extends TouchEventProps {
|
|
86
360
|
style?: StyleProp<TextStyle>;
|
|
87
361
|
children?: ReactNode;
|
|
362
|
+
/** Truncate past this many lines. 0 (the default) does not truncate. */
|
|
88
363
|
numberOfLines?: number;
|
|
364
|
+
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
|
|
365
|
+
visible?: boolean;
|
|
366
|
+
ref?: Ref<NodeHandle>;
|
|
89
367
|
}
|
|
90
368
|
|
|
91
|
-
|
|
369
|
+
/**
|
|
370
|
+
* An image source: the name an asset import resolves to (the bundler's image plugin turns
|
|
371
|
+
* `import logo from './logo.png'` into the file's basename), or an RN-style `{uri}`. RN's numeric
|
|
372
|
+
* `require()` id is not accepted — it carries no engine-side asset name, so it never resolves.
|
|
373
|
+
*/
|
|
374
|
+
export type ImageSource = string | {uri: string};
|
|
375
|
+
|
|
376
|
+
export interface ImageProps extends TouchEventProps {
|
|
377
|
+
source: ImageSource;
|
|
378
|
+
style?: StyleProp<ViewStyle>;
|
|
379
|
+
/** How the bitmap fills its box. Defaults to 'cover'. */
|
|
380
|
+
resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center';
|
|
381
|
+
/** Recolors the image, keeping its alpha — for monochrome icons. */
|
|
382
|
+
tintColor?: string;
|
|
383
|
+
/** The engine asset name, when set directly instead of through `source`. */
|
|
384
|
+
imageName?: string;
|
|
385
|
+
visible?: boolean;
|
|
386
|
+
ref?: Ref<NodeHandle>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface PressableProps extends TouchEventProps, PressEventProps {
|
|
92
390
|
style?: StyleProp<ViewStyle>;
|
|
93
391
|
children?: ReactNode;
|
|
94
|
-
onPress?: () => void;
|
|
95
392
|
disabled?: boolean;
|
|
96
393
|
visible?: boolean;
|
|
394
|
+
ref?: Ref<NodeHandle>;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* A `<Pressable>` that dims while it is held — every Pressable prop works here unchanged. The fade runs
|
|
399
|
+
* on the native driver, so it costs no re-render; note that a dimmed node composites its whole subtree
|
|
400
|
+
* off-screen, so dim the box that reads as the button rather than the surrounding screen.
|
|
401
|
+
*
|
|
402
|
+
* The press feedback owns `opacity`: an animated one in `style` is ignored here and rejected by the AOT.
|
|
403
|
+
* To animate opacity yourself, use `<Pressable>`. Animating any other property, `transform` included, is
|
|
404
|
+
* fine.
|
|
405
|
+
*/
|
|
406
|
+
export interface TouchableOpacityProps extends PressableProps {
|
|
407
|
+
/** Opacity to dim to while held, 0–1. Defaults to RN's 0.2. */
|
|
408
|
+
activeOpacity?: number;
|
|
97
409
|
}
|
|
98
410
|
|
|
99
|
-
|
|
411
|
+
/**
|
|
412
|
+
* A scrolling container. It scrolls whichever axis overflows, so lay the content out with
|
|
413
|
+
* `flexDirection: 'row'` for a horizontal scroller.
|
|
414
|
+
*/
|
|
415
|
+
export interface ScrollViewProps extends ViewProps {
|
|
416
|
+
onScroll?: (event: ScrollEvent) => void;
|
|
417
|
+
}
|
|
100
418
|
|
|
101
|
-
|
|
102
|
-
|
|
419
|
+
/**
|
|
420
|
+
* `<FlatList>` is a thin `<ScrollView>` alias, **not** a virtualized list — every row mounts as a real
|
|
421
|
+
* engine node and stays mounted. These four props are the only ones either flow honors (the AOT
|
|
422
|
+
* rejects the rest at compile time); for headers, footers, separators, `horizontal` or
|
|
423
|
+
* `onEndReached`, use a `<ScrollView>` with `.map` directly.
|
|
424
|
+
*/
|
|
425
|
+
export interface FlatListProps<T = unknown> {
|
|
426
|
+
data?: readonly T[];
|
|
427
|
+
renderItem?: (info: {item: T; index: number}) => ReactNode;
|
|
428
|
+
keyExtractor?: (item: T, index: number) => string | number;
|
|
103
429
|
style?: StyleProp<ViewStyle>;
|
|
104
430
|
}
|
|
105
431
|
|
|
106
|
-
|
|
107
|
-
|
|
432
|
+
/**
|
|
433
|
+
* `<SectionList>` is a thin `<ScrollView>` alias like `<FlatList>` — no virtualization, no sticky
|
|
434
|
+
* headers, and every header, row and footer mounts as a real engine node and stays mounted. Header,
|
|
435
|
+
* rows and footer are flat siblings, exactly as in RN. Flow A / simulator only for now: the AOT has no
|
|
436
|
+
* `<SectionList>` lowering yet.
|
|
437
|
+
*/
|
|
438
|
+
export interface SectionListProps<ItemT = unknown, SectionT = DefaultSectionT> {
|
|
439
|
+
sections?: ReadonlyArray<SectionListData<ItemT, SectionT>>;
|
|
440
|
+
renderItem?: (info: SectionListRenderItemInfo<ItemT, SectionT>) => ReactNode;
|
|
441
|
+
renderSectionHeader?: (info: {
|
|
442
|
+
section: SectionListData<ItemT, SectionT>;
|
|
443
|
+
}) => ReactNode;
|
|
444
|
+
renderSectionFooter?: (info: {
|
|
445
|
+
section: SectionListData<ItemT, SectionT>;
|
|
446
|
+
}) => ReactNode;
|
|
447
|
+
keyExtractor?: (item: ItemT, index: number) => string | number;
|
|
448
|
+
style?: StyleProp<ViewStyle>;
|
|
108
449
|
}
|
|
109
450
|
|
|
110
|
-
|
|
111
|
-
|
|
451
|
+
/** Whatever else a section carries alongside its `data` — RN's convention is a `title`. */
|
|
452
|
+
export type DefaultSectionT = {[key: string]: any};
|
|
453
|
+
|
|
454
|
+
/** One section: your own fields, plus the row data and the optional per-section overrides. */
|
|
455
|
+
export type SectionListData<ItemT, SectionT = DefaultSectionT> = SectionT & {
|
|
456
|
+
data: readonly ItemT[];
|
|
457
|
+
/** Namespaces this section's row keys. Defaults to the section's index. */
|
|
458
|
+
key?: string | number;
|
|
459
|
+
/** Overrides the list-wide `renderItem` for this section only. */
|
|
460
|
+
renderItem?: (info: SectionListRenderItemInfo<ItemT, SectionT>) => ReactNode;
|
|
461
|
+
/** Overrides the list-wide `keyExtractor` for this section only. */
|
|
462
|
+
keyExtractor?: (item: ItemT, index: number) => string | number;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/** What `renderItem` is called with. RN's `separators` is absent — there are no separators here. */
|
|
466
|
+
export interface SectionListRenderItemInfo<ItemT, SectionT = DefaultSectionT> {
|
|
467
|
+
item: ItemT;
|
|
468
|
+
/** The row's index WITHIN its section. */
|
|
469
|
+
index: number;
|
|
470
|
+
section: SectionListData<ItemT, SectionT>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* RN's pre-styled button: a `<Pressable>` around a single centred `<Text>`. It takes no `style` — that
|
|
475
|
+
* is upstream's design, and the escape hatch is the same one RN gives you: build the `<Pressable>` +
|
|
476
|
+
* `<Text>` yourself. Accessibility, TV-focus and `testID` props are accepted and ignored (no OS to
|
|
477
|
+
* report them to); anything else warns once.
|
|
478
|
+
*/
|
|
479
|
+
export interface ButtonProps {
|
|
480
|
+
title?: string;
|
|
481
|
+
onPress?: (event: NativeEvent<'press'>) => void;
|
|
482
|
+
/** Fill colour, replacing the default blue. */
|
|
483
|
+
color?: string;
|
|
484
|
+
/** Greys the button out and detaches `onPress`. */
|
|
485
|
+
disabled?: boolean;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* A `<View>` with an `<Image>` stretched behind its children — what you reach for because `<Image>`
|
|
490
|
+
* takes no children. `style` lays out the container; every other prop goes to the image, as upstream.
|
|
491
|
+
*/
|
|
492
|
+
export interface ImageBackgroundProps extends Omit<
|
|
493
|
+
ImageProps,
|
|
494
|
+
'style' | 'ref'
|
|
495
|
+
> {
|
|
496
|
+
/** Container style — the box the picture fills (its content box, so padding insets the picture). */
|
|
497
|
+
style?: StyleProp<ViewStyle>;
|
|
498
|
+
/** Merged over the fill: `borderRadius`, `opacity`, `tintColor`. */
|
|
499
|
+
imageStyle?: StyleProp<ViewStyle>;
|
|
500
|
+
/** Ref to the `<Image>` node; the outer `ref` points at the `<View>`. */
|
|
501
|
+
imageRef?: Ref<NodeHandle>;
|
|
502
|
+
children?: ReactNode;
|
|
503
|
+
ref?: Ref<NodeHandle>;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface TextInputProps extends TouchEventProps {
|
|
507
|
+
style?: StyleProp<TextInputStyle>;
|
|
112
508
|
value?: string;
|
|
113
509
|
placeholder?: string;
|
|
510
|
+
placeholderTextColor?: string;
|
|
511
|
+
editable?: boolean;
|
|
512
|
+
visible?: boolean;
|
|
114
513
|
onChangeText?: (text: string) => void;
|
|
514
|
+
onSubmitEditing?: (event: NativeEvent<'submitEditing'>) => void;
|
|
515
|
+
onFocus?: (event: NativeEvent<'focus'>) => void;
|
|
516
|
+
onBlur?: (event: NativeEvent<'blur'>) => void;
|
|
517
|
+
ref?: Ref<NodeHandle>;
|
|
115
518
|
}
|
|
116
519
|
|
|
117
|
-
export interface SwitchProps {
|
|
520
|
+
export interface SwitchProps extends TouchEventProps {
|
|
521
|
+
style?: StyleProp<ViewStyle>;
|
|
118
522
|
value?: boolean;
|
|
119
523
|
onValueChange?: (value: boolean) => void;
|
|
524
|
+
trackColor?: {false?: string; true?: string};
|
|
525
|
+
thumbColor?: string;
|
|
526
|
+
visible?: boolean;
|
|
527
|
+
ref?: Ref<NodeHandle>;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export interface ActivityIndicatorProps extends TouchEventProps {
|
|
531
|
+
/** The spinner tint comes from the style's `color`, as in RN. */
|
|
532
|
+
style?: StyleProp<TextStyle>;
|
|
533
|
+
/** Whether the spinner is turning. Defaults to true. */
|
|
534
|
+
animating?: boolean;
|
|
535
|
+
visible?: boolean;
|
|
536
|
+
ref?: Ref<NodeHandle>;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export interface ModalProps extends TouchEventProps {
|
|
540
|
+
style?: StyleProp<ModalStyle>;
|
|
541
|
+
children?: ReactNode;
|
|
542
|
+
/** Shows or hides the modal. Unlike other components this does not mean style `display`. */
|
|
543
|
+
visible?: boolean;
|
|
544
|
+
ref?: Ref<NodeHandle>;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export interface DialGradient {
|
|
548
|
+
/** 'conic' sweeps the stops along the angle; 'radial' across the thickness. */
|
|
549
|
+
type: 'conic' | 'radial';
|
|
550
|
+
stops: Array<{color: string; offset?: number}>;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Native arc widget: a dial / gauge / progress ring rasterized analytically by the engine. Angles are
|
|
555
|
+
* degrees clockwise from 3 o'clock; the default is a 270° sweep starting at 135° (the LVGL arc).
|
|
556
|
+
*/
|
|
557
|
+
export interface DialProps extends TouchEventProps {
|
|
558
|
+
style?: StyleProp<ViewStyle>;
|
|
559
|
+
/** Current value in [min, max]. Animatable with Animated.Value (native driver). */
|
|
560
|
+
value?: number | AnimatedValue;
|
|
561
|
+
min?: number;
|
|
562
|
+
max?: number;
|
|
563
|
+
startAngle?: number;
|
|
564
|
+
sweepAngle?: number;
|
|
565
|
+
/** Drag quantisation step (default 1). */
|
|
566
|
+
step?: number;
|
|
567
|
+
/** Track + indicator thickness in px (default: 1/10 of the smaller side). */
|
|
568
|
+
thickness?: number;
|
|
569
|
+
/** Optional wider backing band behind the track, centred on it. */
|
|
570
|
+
bandThickness?: number;
|
|
571
|
+
bandColor?: string;
|
|
572
|
+
trackColor?: string;
|
|
573
|
+
indicatorColor?: string;
|
|
574
|
+
/** Indicator paint ramp; overrides indicatorColor. */
|
|
575
|
+
indicatorGradient?: DialGradient;
|
|
576
|
+
cap?: 'butt' | 'round';
|
|
577
|
+
/** Split the arc into N segments separated by gapAngle degrees (default 2). */
|
|
578
|
+
segments?: number;
|
|
579
|
+
gapAngle?: number;
|
|
580
|
+
/** 'child': the engine positions the first child on the value point (multi-knob dials, custom knobs). */
|
|
581
|
+
knob?: 'none' | 'circle' | 'image' | 'child';
|
|
582
|
+
knobSize?: number;
|
|
583
|
+
knobColor?: string;
|
|
584
|
+
knobBorderColor?: string;
|
|
585
|
+
knobBorderWidth?: number;
|
|
586
|
+
knobImage?: ImageSource;
|
|
587
|
+
/** Built-in drag-to-set: the knob follows the finger natively; onChange gets the quantized value. */
|
|
588
|
+
adjustable?: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Dual-setpoint mode: the indicator spans [valueStart, value] and gets a knob at each end. A drag
|
|
591
|
+
* latches the end it started nearest, and the ends clamp against each other instead of crossing.
|
|
592
|
+
*/
|
|
593
|
+
range?: boolean;
|
|
594
|
+
/** RANGE mode: the band's low end. Animatable like `value`. */
|
|
595
|
+
valueStart?: number | AnimatedValue;
|
|
596
|
+
/**
|
|
597
|
+
* RANGE mode: the minimum separation the two ends keep, in value units. 0 (default) lets them meet.
|
|
598
|
+
* Above 0, a drag that would close the gap pushes the far end along instead of stopping dead, and
|
|
599
|
+
* stops only once that end reaches the range bound.
|
|
600
|
+
*/
|
|
601
|
+
minSpan?: number;
|
|
602
|
+
/** Called with the new value; in `range` mode the band's low end is the second argument. */
|
|
603
|
+
onChange?: (value: number, valueStart: number) => void;
|
|
604
|
+
visible?: boolean;
|
|
605
|
+
children?: ReactNode;
|
|
606
|
+
ref?: Ref<NodeHandle>;
|
|
120
607
|
}
|
|
121
608
|
|
|
122
609
|
export const View: (props: ViewProps) => JSX.Element;
|
|
123
610
|
export const Text: (props: TextProps) => JSX.Element;
|
|
124
611
|
export const Image: (props: ImageProps) => JSX.Element;
|
|
125
612
|
export const Pressable: (props: PressableProps) => JSX.Element;
|
|
126
|
-
export const TouchableOpacity: (props:
|
|
613
|
+
export const TouchableOpacity: (props: TouchableOpacityProps) => JSX.Element;
|
|
127
614
|
export const ScrollView: (props: ScrollViewProps) => JSX.Element;
|
|
128
|
-
export
|
|
615
|
+
export function FlatList<T>(props: FlatListProps<T>): JSX.Element;
|
|
616
|
+
export function SectionList<ItemT, SectionT = DefaultSectionT>(
|
|
617
|
+
props: SectionListProps<ItemT, SectionT>,
|
|
618
|
+
): JSX.Element;
|
|
619
|
+
export const Button: (props: ButtonProps) => JSX.Element;
|
|
620
|
+
export const ImageBackground: (props: ImageBackgroundProps) => JSX.Element;
|
|
129
621
|
export const TextInput: (props: TextInputProps) => JSX.Element;
|
|
130
622
|
export const Switch: (props: SwitchProps) => JSX.Element;
|
|
131
|
-
export const ActivityIndicator: (props:
|
|
132
|
-
export const Modal: (props:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
623
|
+
export const ActivityIndicator: (props: ActivityIndicatorProps) => JSX.Element;
|
|
624
|
+
export const Modal: (props: ModalProps) => JSX.Element;
|
|
625
|
+
export const Dial: (props: DialProps) => JSX.Element;
|
|
626
|
+
|
|
627
|
+
// --- SVG -------------------------------------------------------------------
|
|
628
|
+
// <Svg> is the only host node (an engine vector node). The shape tags are descriptive children that the
|
|
629
|
+
// renderer flattens into that node's op-tape — like raw text inside <Text>, they are never mounted on
|
|
630
|
+
// their own, so they take no style, no events and no ref. Use them only inside an <Svg>.
|
|
631
|
+
// Arrays and fragments around them are unwrapped, so a mapped list of shapes works. A component is never
|
|
632
|
+
// rendered — flattening the subtree means it is not mounted, so `<Needle/>` draws nothing whatever it
|
|
633
|
+
// returns; inline its shapes, or call it as a plain function ({needle()}) to put them in children.
|
|
634
|
+
|
|
635
|
+
/** An SVG geometry attribute: a number, or a numeric string as in the SVG markup ('12', '1.5'). */
|
|
636
|
+
export type SvgNumber = number | string;
|
|
637
|
+
|
|
638
|
+
/** Gradient kind: 1 linear (axis (ax,ay)→(bx,by)), 2 radial (centre (ax,ay), radius r), 3 conic. */
|
|
639
|
+
export type VectorGradientType = 1 | 2 | 3;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* A gradient ramp for a shape's fill or stroke. Up to 8 stops are carried to the engine; a longer list is
|
|
643
|
+
* resampled down to 8 rather than truncated, so the ramp keeps its shape.
|
|
644
|
+
*/
|
|
645
|
+
export interface VectorGradient {
|
|
646
|
+
type: VectorGradientType;
|
|
647
|
+
stops: Array<{color: string | number; offset: number}>;
|
|
648
|
+
ax?: number;
|
|
649
|
+
ay?: number;
|
|
650
|
+
bx?: number;
|
|
651
|
+
by?: number;
|
|
652
|
+
r?: number;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Paint attributes, shared by every shape. A <G> resolves these for its children, which override
|
|
657
|
+
* individually. Colours accept #rgb / #rgba / #rrggbb / #rrggbbaa, rgb() / rgba(), and a small named set
|
|
658
|
+
* (none, transparent, black, white, red, green, blue, gray). An unfilled shape defaults to BLACK — set
|
|
659
|
+
* `fill="none"` on anything meant to be stroke-only.
|
|
660
|
+
*/
|
|
661
|
+
export interface SvgPaintProps {
|
|
662
|
+
fill?: string;
|
|
663
|
+
stroke?: string;
|
|
664
|
+
strokeWidth?: SvgNumber;
|
|
665
|
+
strokeLinecap?: 'butt' | 'round' | 'square';
|
|
666
|
+
strokeLinejoin?: 'miter' | 'round' | 'bevel';
|
|
667
|
+
strokeMiterlimit?: SvgNumber;
|
|
668
|
+
fillRule?: 'nonzero' | 'evenodd';
|
|
669
|
+
/** Fills with a gradient instead of the solid `fill`. */
|
|
670
|
+
fillGrad?: VectorGradient;
|
|
671
|
+
/** Strokes with a gradient instead of the solid `stroke`. */
|
|
672
|
+
strokeGrad?: VectorGradient;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/** A `.svg` import: the build bakes it to a vector op-tape, or to a raster asset when it uses features the
|
|
676
|
+
* vector baker cannot represent (text, masks, filters). Pass it straight to `<Svg source>`. */
|
|
677
|
+
export type SvgSource =
|
|
678
|
+
| {
|
|
679
|
+
kind: 'vector';
|
|
680
|
+
ops: number[];
|
|
681
|
+
paints: number[];
|
|
682
|
+
gradients?: unknown[];
|
|
683
|
+
width: number;
|
|
684
|
+
height: number;
|
|
685
|
+
}
|
|
686
|
+
| {kind: 'raster'; name: string; width: number; height: number};
|
|
687
|
+
|
|
688
|
+
export interface SvgProps extends SvgPaintProps, TouchEventProps {
|
|
689
|
+
children?: ReactNode;
|
|
690
|
+
/** An imported `.svg`. Its tape is scaled to the render box and any shape children are ignored. */
|
|
691
|
+
source?: SvgSource;
|
|
692
|
+
/** Render-box size. Taken as direct props (the react-native-svg convention); a style width/height wins. */
|
|
693
|
+
width?: SvgNumber;
|
|
694
|
+
height?: SvgNumber;
|
|
695
|
+
/** 'minX minY width height'. Coordinates are baked into the tape against width/height. */
|
|
696
|
+
viewBox?: string;
|
|
697
|
+
style?: StyleProp<ViewStyle>;
|
|
698
|
+
visible?: boolean;
|
|
699
|
+
ref?: Ref<NodeHandle>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** Groups shapes under one paint and an optional translate/scale, composed with any enclosing <G>. */
|
|
703
|
+
export interface GProps extends SvgPaintProps {
|
|
704
|
+
children?: ReactNode;
|
|
705
|
+
x?: SvgNumber;
|
|
706
|
+
y?: SvgNumber;
|
|
707
|
+
translateX?: SvgNumber;
|
|
708
|
+
translateY?: SvgNumber;
|
|
709
|
+
scale?: SvgNumber;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export interface PathProps extends SvgPaintProps {
|
|
713
|
+
/** Path data. M/L/H/V/C/S/Q/T/A/Z, absolute and relative. Parsing a `d` string costs more than the
|
|
714
|
+
* primitive shapes — prefer <Circle>/<Rect>/<Arc> for anything rebuilt per frame. */
|
|
715
|
+
d?: string;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export interface CircleProps extends SvgPaintProps {
|
|
719
|
+
cx?: SvgNumber;
|
|
720
|
+
cy?: SvgNumber;
|
|
721
|
+
r?: SvgNumber;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export interface EllipseProps extends SvgPaintProps {
|
|
725
|
+
cx?: SvgNumber;
|
|
726
|
+
cy?: SvgNumber;
|
|
727
|
+
rx?: SvgNumber;
|
|
728
|
+
ry?: SvgNumber;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export interface RectProps extends SvgPaintProps {
|
|
732
|
+
x?: SvgNumber;
|
|
733
|
+
y?: SvgNumber;
|
|
734
|
+
width?: SvgNumber;
|
|
735
|
+
height?: SvgNumber;
|
|
736
|
+
/** Corner radii. Omitting one (or giving it a negative value, which SVG treats as `auto`) falls back to
|
|
737
|
+
* the other; each is clamped to half its own side. */
|
|
738
|
+
rx?: SvgNumber;
|
|
739
|
+
ry?: SvgNumber;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export interface LineProps extends SvgPaintProps {
|
|
743
|
+
x1?: SvgNumber;
|
|
744
|
+
y1?: SvgNumber;
|
|
745
|
+
x2?: SvgNumber;
|
|
746
|
+
y2?: SvgNumber;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Circular-arc convenience primitive (not a standard SVG element). Angles are DEGREES clockwise from
|
|
751
|
+
* 12 o'clock. It emits a native arc op — no `d` parsing or bezier conversion — so it is cheap enough to
|
|
752
|
+
* rebuild every drag frame.
|
|
753
|
+
*/
|
|
754
|
+
export interface ArcProps extends SvgPaintProps {
|
|
755
|
+
cx?: SvgNumber;
|
|
756
|
+
cy?: SvgNumber;
|
|
757
|
+
r?: SvgNumber;
|
|
758
|
+
startAngle?: SvgNumber;
|
|
759
|
+
endAngle?: SvgNumber;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export const Svg: (props: SvgProps) => JSX.Element;
|
|
763
|
+
export const Path: (props: PathProps) => JSX.Element;
|
|
764
|
+
export const Circle: (props: CircleProps) => JSX.Element;
|
|
765
|
+
export const Ellipse: (props: EllipseProps) => JSX.Element;
|
|
766
|
+
export const Rect: (props: RectProps) => JSX.Element;
|
|
767
|
+
export const Line: (props: LineProps) => JSX.Element;
|
|
768
|
+
export const G: (props: GProps) => JSX.Element;
|
|
769
|
+
export const Arc: (props: ArcProps) => JSX.Element;
|
|
143
770
|
|
|
144
771
|
// --- StyleSheet ------------------------------------------------------------
|
|
145
772
|
export const StyleSheet: {
|
|
@@ -193,7 +820,10 @@ export const Animated: {
|
|
|
193
820
|
spring(value: AnimatedValue, config: AnimationConfig): Animation;
|
|
194
821
|
decay(value: AnimatedValue, config: Record<string, unknown>): Animation;
|
|
195
822
|
sequence(animations: Animation[]): Animation;
|
|
196
|
-
parallel(
|
|
823
|
+
parallel(
|
|
824
|
+
animations: Animation[],
|
|
825
|
+
config?: {stopTogether?: boolean},
|
|
826
|
+
): Animation;
|
|
197
827
|
stagger(delay: number, animations: Animation[]): Animation;
|
|
198
828
|
loop(animation: Animation, config?: {iterations?: number}): Animation;
|
|
199
829
|
delay(ms: number): Animation;
|
|
@@ -210,6 +840,182 @@ export function usePersistentState<S>(
|
|
|
210
840
|
export function useHostValue(initial: number): number;
|
|
211
841
|
export const Easing: Record<string, (t: number) => number>;
|
|
212
842
|
export const LayoutAnimation: Record<string, unknown>;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
843
|
+
|
|
844
|
+
// --- PanResponder ----------------------------------------------------------
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* The running state of a drag, handed to every PanResponder callback. It is ONE mutable object reused
|
|
848
|
+
* for the responder's lifetime — read what you need during the callback; don't stash it expecting a
|
|
849
|
+
* snapshot.
|
|
850
|
+
*/
|
|
851
|
+
export interface PanResponderGestureState {
|
|
852
|
+
/** Identifies this responder; stable for its lifetime. */
|
|
853
|
+
stateID: number;
|
|
854
|
+
/** Latest touchpoint. */
|
|
855
|
+
moveX: number;
|
|
856
|
+
moveY: number;
|
|
857
|
+
/** Where the gesture was granted — the anchor `dx`/`dy` are measured from. */
|
|
858
|
+
x0: number;
|
|
859
|
+
y0: number;
|
|
860
|
+
/** Travel since the grant, in pixels. */
|
|
861
|
+
dx: number;
|
|
862
|
+
dy: number;
|
|
863
|
+
/** Velocity in pixels per millisecond. */
|
|
864
|
+
vx: number;
|
|
865
|
+
vy: number;
|
|
866
|
+
/** Fingers currently on the panel. */
|
|
867
|
+
numberActiveTouches: number;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
export type PanResponderCallback = (
|
|
871
|
+
event: ResponderEvent,
|
|
872
|
+
gestureState: PanResponderGestureState,
|
|
873
|
+
) => void;
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Returning `true` claims the gesture — or, for a termination request, KEEPS it. The event is a bare
|
|
877
|
+
* touchpoint: a negotiation query carries no `type`.
|
|
878
|
+
*/
|
|
879
|
+
export type PanResponderPredicate = (
|
|
880
|
+
event: ResponderQueryEvent,
|
|
881
|
+
gestureState: PanResponderGestureState,
|
|
882
|
+
) => boolean;
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* RN's PanResponder config, riding the engine's native responder system (the low-level
|
|
886
|
+
* GestureResponderHandlers above). Returning `true` from a should-set predicate claims the gesture
|
|
887
|
+
* through real negotiation — capture asks root→leaf before bubble asks leaf→root — so a granted pan
|
|
888
|
+
* OWNS the touch stream: a ScrollView ancestor will not auto-scroll under it, and a move-should-set
|
|
889
|
+
* claim takes the gesture back from a scroller that already started. With no should-set supplied the
|
|
890
|
+
* responder never grants, exactly as in RN.
|
|
891
|
+
*
|
|
892
|
+
* Only `onShouldBlockNativeResponder` (Android-specific) is absent; passing it — or a typo — warns.
|
|
893
|
+
*
|
|
894
|
+
* Flow B compiles this config too: the AOT lowers `useRef(PanResponder.create({…})).current` and the
|
|
895
|
+
* `{...pan.panHandlers}` spread onto the same engine responder system, so the gesture needs no JS on the
|
|
896
|
+
* device. `onPanResponderStart`/`End` are the exception — they fold EXTRA fingers into one gesture, which
|
|
897
|
+
* is Flow A only, and the AOT fails the build by name rather than dropping them.
|
|
898
|
+
*/
|
|
899
|
+
export interface PanResponderConfig {
|
|
900
|
+
onStartShouldSetPanResponder?: PanResponderPredicate;
|
|
901
|
+
onStartShouldSetPanResponderCapture?: PanResponderPredicate;
|
|
902
|
+
onMoveShouldSetPanResponder?: PanResponderPredicate;
|
|
903
|
+
onMoveShouldSetPanResponderCapture?: PanResponderPredicate;
|
|
904
|
+
onPanResponderGrant?: PanResponderCallback;
|
|
905
|
+
onPanResponderMove?: PanResponderCallback;
|
|
906
|
+
onPanResponderRelease?: PanResponderCallback;
|
|
907
|
+
/** The gesture was taken away: a canceled touch, or this responder yielded to a challenger. */
|
|
908
|
+
onPanResponderTerminate?: PanResponderCallback;
|
|
909
|
+
/** A challenger wants the gesture: return true to yield (the default), false to keep it. */
|
|
910
|
+
onPanResponderTerminationRequest?: PanResponderPredicate;
|
|
911
|
+
/** This responder's claim lost a negotiation. Re-asked claims are re-rejected on later moves. */
|
|
912
|
+
onPanResponderReject?: PanResponderCallback;
|
|
913
|
+
/** A later finger joined the gesture in flight. Flow A only (the AOT rejects it by name). */
|
|
914
|
+
onPanResponderStart?: PanResponderCallback;
|
|
915
|
+
/**
|
|
916
|
+
* A finger lifted, but the gesture continues on the ones still down. Driven by the raw touch stream
|
|
917
|
+
* rather than a responder event, so this one receives the `touchEnd` payload. Flow A only (the AOT
|
|
918
|
+
* rejects it by name).
|
|
919
|
+
*/
|
|
920
|
+
onPanResponderEnd?: (
|
|
921
|
+
event: NativeEvent<'touchEnd'>,
|
|
922
|
+
gestureState: PanResponderGestureState,
|
|
923
|
+
) => void;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
export interface PanResponderInstance {
|
|
927
|
+
/** Spread onto any component: `<View {...pan.panHandlers} />`. */
|
|
928
|
+
panHandlers: TouchEventProps;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Recognizes drags, swipes, and flings via the native gesture responder system. Create it ONCE per
|
|
933
|
+
* component and keep it in a ref — the handlers close over one gesture state, so re-creating it per
|
|
934
|
+
* render loses the drag.
|
|
935
|
+
*/
|
|
936
|
+
export const PanResponder: {
|
|
937
|
+
create(config?: PanResponderConfig): PanResponderInstance;
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
// --- Imperative escape hatch -----------------------------------------------
|
|
941
|
+
// For continuous gestures, where a React render per pointer move is too slow. Grab a node handle from a
|
|
942
|
+
// ref, push updates here, and commit back to React state when the gesture ends.
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* One primitive for `updateVector`: exactly one geometry key plus its paint. Note the SHORT paint spellings
|
|
946
|
+
* (`cap`, `join`, `miter`) — this is the allocation-free path, not the JSX attribute set.
|
|
947
|
+
*/
|
|
948
|
+
export interface VectorShape {
|
|
949
|
+
/** [cx, cy, r, startDeg, endDeg] — degrees clockwise from 12 o'clock. */
|
|
950
|
+
arc?: [number, number, number, number, number];
|
|
951
|
+
/** [cx, cy, r] */
|
|
952
|
+
circle?: [number, number, number];
|
|
953
|
+
/** [x1, y1, x2, y2] */
|
|
954
|
+
line?: [number, number, number, number];
|
|
955
|
+
/** [x, y, w, h], or [x, y, w, h, rx, ry] for rounded corners. */
|
|
956
|
+
rect?:
|
|
957
|
+
| [number, number, number, number]
|
|
958
|
+
| [number, number, number, number, number, number];
|
|
959
|
+
/** Path data. Slower than the primitives above (regex + bezier conversion). */
|
|
960
|
+
path?: string;
|
|
961
|
+
fill?: string;
|
|
962
|
+
stroke?: string;
|
|
963
|
+
strokeWidth?: number;
|
|
964
|
+
miter?: number;
|
|
965
|
+
cap?: 'butt' | 'round' | 'square';
|
|
966
|
+
join?: 'miter' | 'round' | 'bevel';
|
|
967
|
+
fillRule?: 'nonzero' | 'evenodd';
|
|
968
|
+
fillGrad?: VectorGradient;
|
|
969
|
+
strokeGrad?: VectorGradient;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Sets an <Svg> node's geometry from primitive shape descriptors, skipping React and the `d` parser.
|
|
974
|
+
* `dirtyRect` is an optional node-local [x, y, w, h] bounding the change; give it and only that region is
|
|
975
|
+
* repainted, which is a large win for a small update on a big vector node.
|
|
976
|
+
*/
|
|
977
|
+
export function updateVector(
|
|
978
|
+
handle: NodeHandle | null | undefined,
|
|
979
|
+
shapes: VectorShape[],
|
|
980
|
+
dirtyRect?: [number, number, number, number],
|
|
981
|
+
): void;
|
|
982
|
+
|
|
983
|
+
/** Sets a <Text> node's content without disturbing its style. A later React render reverts cleanly. */
|
|
984
|
+
export function updateText(
|
|
985
|
+
handle: NodeHandle | null | undefined,
|
|
986
|
+
text: string | number,
|
|
987
|
+
): void;
|
|
988
|
+
|
|
989
|
+
/** One key in a `setKeyboardConfig` layer. `char` types it; `layer` switches layer; `backspace`/`done` act. */
|
|
990
|
+
export interface KeyboardKey {
|
|
991
|
+
char?: string;
|
|
992
|
+
label?: string;
|
|
993
|
+
/** Index of the layer this key switches to. */
|
|
994
|
+
layer?: number;
|
|
995
|
+
backspace?: boolean;
|
|
996
|
+
done?: boolean;
|
|
997
|
+
/** Grid columns the key spans (default 1) — a wider space bar or shift. */
|
|
998
|
+
span?: number;
|
|
999
|
+
/** Lit while its own layer is showing. */
|
|
1000
|
+
highlight?: boolean;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/** A keyboard layout: layers of rows of keys. Omit `layers` to keep the built-in QWERTY. */
|
|
1004
|
+
export interface KeyboardConfig {
|
|
1005
|
+
panelColor?: string;
|
|
1006
|
+
keyColor?: string;
|
|
1007
|
+
keyActiveColor?: string;
|
|
1008
|
+
labelColor?: string;
|
|
1009
|
+
fontSize?: number;
|
|
1010
|
+
rowHeight?: number;
|
|
1011
|
+
keyGap?: number;
|
|
1012
|
+
keyRadius?: number;
|
|
1013
|
+
gridCols?: number;
|
|
1014
|
+
layers?: KeyboardKey[][][];
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Customizes the on-screen software keyboard. Only effective when the engine was built with the keyboard
|
|
1019
|
+
* enabled (ERUI_ONSCREEN_KEYBOARD=1); a no-op otherwise. Pass nothing to restore the built-in default.
|
|
1020
|
+
*/
|
|
1021
|
+
export function setKeyboardConfig(config?: KeyboardConfig | null): void;
|