embedded-react 0.3.0 → 0.4.1
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/aot/compile.mjs +2407 -697
- package/aot/screenshot-smoke.mjs +34 -17
- package/aot/style-map.mjs +156 -80
- package/assets/bake-font.mjs +45 -21
- package/assets/bake-image.mjs +7 -5
- package/assets/bake-svg.mjs +563 -0
- package/assets/build-builtin-font.mjs +25 -12
- package/assets/emit-c.mjs +52 -20
- package/assets/emit-container.mjs +5 -3
- package/assets/emit-pack.mjs +8 -2
- package/assets/index.mjs +25 -16
- package/assets/rasterize.mjs +45 -11
- package/assets/svg-loader.mjs +81 -0
- package/build.mjs +43 -20
- package/cli.mjs +134 -52
- package/pack-container.mjs +84 -35
- package/package.json +8 -3
- package/persist-transform.mjs +23 -9
- package/qjsc-wasm.mjs +19 -8
- package/sim/embedded-react.wasm +0 -0
- package/sim-server.mjs +160 -48
- package/src/embedded-react/Animated.js +51 -36
- package/src/embedded-react/AppRegistry.js +4 -4
- package/src/embedded-react/Easing.js +1 -1
- package/src/embedded-react/LayoutAnimation.js +13 -6
- package/src/embedded-react/StyleSheet.js +1 -1
- package/src/embedded-react/imperative.js +19 -7
- package/src/embedded-react/index.js +8 -8
- package/src/embedded-react/layout-anim-config.js +13 -9
- package/src/embedded-react/split-style.js +6 -6
- package/src/embedded-react/svg-ops.js +369 -41
- package/src/embedded-react/usePersistentState.js +3 -3
- package/src/host-config.js +137 -18
- package/src/native-ui.js +3 -1
- package/src/props.js +22 -10
- package/src/renderer.js +3 -3
|
@@ -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 {
|
|
22
|
-
import {
|
|
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 =
|
|
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:
|
|
43
|
-
linear:
|
|
44
|
-
spring:
|
|
49
|
+
easeInEaseOut: onDone => configureNext(Presets.easeInEaseOut, onDone),
|
|
50
|
+
linear: onDone => configureNext(Presets.linear, onDone),
|
|
51
|
+
spring: onDone => configureNext(Presets.spring, onDone),
|
|
45
52
|
};
|
|
@@ -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 {
|
|
24
|
-
import {
|
|
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 {
|
|
37
|
-
|
|
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, [{
|
|
60
|
+
NativeUI.setTextSpans(handle, [{text: String(text)}]);
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
/**
|
|
52
|
-
*
|
|
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
|
|
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 {
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
export {
|
|
49
|
-
export {
|
|
50
|
-
export {
|
|
51
|
-
export {
|
|
52
|
-
export {
|
|
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 {
|
|
66
|
+
return {type: 'spring', duration};
|
|
67
67
|
}
|
|
68
|
-
return {
|
|
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(
|
|
72
|
+
export function create(
|
|
73
|
+
duration,
|
|
74
|
+
type = Types.easeInEaseOut,
|
|
75
|
+
creationProp = Properties.opacity,
|
|
76
|
+
) {
|
|
73
77
|
return {
|
|
74
78
|
duration,
|
|
75
|
-
create: {
|
|
76
|
-
update: {
|
|
77
|
-
delete: {
|
|
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: {
|
|
88
|
-
update: {
|
|
89
|
-
delete: {
|
|
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 {
|
|
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({
|
|
41
|
-
bindings.push({
|
|
40
|
+
bindings.push({prop: 'scaleX', value: v});
|
|
41
|
+
bindings.push({prop: 'scaleY', value: v});
|
|
42
42
|
} else {
|
|
43
|
-
bindings.push({
|
|
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({
|
|
51
|
+
bindings.push({prop: key, value: val});
|
|
52
52
|
} else {
|
|
53
53
|
staticStyle[key] = val;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
return {
|
|
57
|
+
return {staticStyle, bindings};
|
|
58
58
|
}
|