embedded-react 0.21.0 → 0.22.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 +2 -2
- package/aot/compile.mjs +1 -1
- package/aot/compiler/alerts.mjs +604 -0
- package/aot/compiler/check.mjs +1 -1
- package/aot/compiler/collect.mjs +1 -1
- package/aot/compiler/elements/button.mjs +3 -3
- package/aot/compiler/elements/image-background.mjs +1 -1
- package/aot/compiler/elements/props.mjs +10 -6
- package/aot/compiler/elements/section-list.mjs +1 -1
- package/aot/compiler/expressions.mjs +29 -2
- package/aot/compiler/handlers.mjs +73 -16
- package/aot/compiler/keyboard-dismiss.mjs +99 -0
- package/aot/compiler/keyboard.mjs +1 -1
- package/aot/compiler/lower.mjs +12 -0
- package/aot/compiler/nodes.mjs +17 -9
- package/aot/compiler/out.mjs +4 -0
- package/aot/compiler/package/codegen.mjs +36 -2
- package/aot/compiler/package/format.mjs +5 -3
- package/aot/compiler/package/lower.mjs +53 -19
- package/aot/compiler/scroll-to.mjs +112 -0
- package/aot/compiler/style-text.mjs +2 -2
- package/aot/compiler/svg.mjs +6 -3
- package/aot/compiler/updaters.mjs +1 -0
- package/aot/style-map.mjs +44 -1
- package/assets/bake-font.mjs +187 -244
- package/assets/bake-image.mjs +47 -71
- package/assets/bake-svg.mjs +465 -533
- package/assets/build-builtin-font.mjs +14 -27
- package/assets/emit-c.mjs +124 -204
- package/assets/emit-container.mjs +129 -197
- package/assets/emit-pack.mjs +92 -136
- package/assets/font-config.mjs +19 -27
- package/assets/font-sizes.mjs +432 -507
- package/assets/glyph-coverage.mjs +170 -214
- package/assets/index.mjs +52 -97
- package/assets/rasterize.mjs +173 -194
- package/assets/svg-loader.mjs +42 -48
- package/build.mjs +84 -101
- package/cli.mjs +482 -621
- package/compile-bin.mjs +24 -36
- package/flash.mjs +297 -401
- package/hotreload/dev-device.mjs +229 -270
- package/hotreload/pack-app.mjs +118 -159
- package/hotreload/pack-split.mjs +144 -200
- package/hotreload/package-transfer.mjs +128 -131
- package/hotreload/protocol.mjs +118 -118
- package/hotreload/uploader.mjs +132 -159
- package/hotreload/watch-tree.mjs +56 -65
- package/pack-container.mjs +93 -123
- package/package.json +19 -16
- package/persist-transform.mjs +89 -105
- package/qjsc-wasm.mjs +47 -72
- package/sim/embedded-react.wasm +0 -0
- package/sim/index.html +1 -1
- package/sim-server.mjs +260 -354
- package/src/embedded-react/Alert.mjs +112 -0
- package/src/embedded-react/Animated.mjs +412 -0
- package/src/embedded-react/{AppRegistry.js → AppRegistry.mjs} +26 -25
- package/src/embedded-react/{Button.js → Button.mjs} +29 -53
- package/src/embedded-react/{Dimensions.js → Dimensions.mjs} +12 -17
- package/src/embedded-react/Easing.mjs +34 -0
- package/src/embedded-react/{FlatList.js → FlatList.mjs} +25 -42
- package/src/embedded-react/{ImageBackground.js → ImageBackground.mjs} +11 -22
- package/src/embedded-react/Keyboard.mjs +82 -0
- package/src/embedded-react/{LayoutAnimation.js → LayoutAnimation.mjs} +17 -28
- package/src/embedded-react/PanResponder.mjs +256 -0
- package/src/embedded-react/{Platform.js → Platform.mjs} +8 -9
- package/src/embedded-react/{Pressable.js → Pressable.mjs} +12 -25
- package/src/embedded-react/SectionList.mjs +103 -0
- package/src/embedded-react/{StyleSheet.js → StyleSheet.mjs} +16 -20
- package/src/embedded-react/{TouchableOpacity.js → TouchableOpacity.mjs} +47 -83
- package/src/embedded-react/background-image.mjs +321 -0
- package/src/embedded-react/{components.js → components.mjs} +1 -3
- package/src/embedded-react/{imperative.js → imperative.mjs} +27 -38
- package/src/embedded-react/index.d.ts +155 -2
- package/src/embedded-react/index.js +26 -19
- package/src/embedded-react/layout-anim-config.mjs +85 -0
- package/src/embedded-react/{list-child.js → list-child.mjs} +11 -20
- package/src/embedded-react/{named-colors.js → named-colors.mjs} +2 -6
- package/src/embedded-react/nativeModule.mjs +371 -0
- package/src/embedded-react/split-style.mjs +57 -0
- package/src/embedded-react/svg-ops.mjs +1075 -0
- package/src/embedded-react/{useHostValue.js → useHostValue.mjs} +2 -4
- package/src/embedded-react/{usePersistentState.js → usePersistentState.mjs} +34 -38
- package/src/embedded-react/{warn-props.js → warn-props.mjs} +32 -39
- package/src/host-config.mjs +512 -0
- package/src/{native-ui.js → native-ui.mjs} +1 -8
- package/src/props.mjs +341 -0
- package/src/{renderer.js → renderer.mjs} +30 -44
- package/src/embedded-react/Animated.js +0 -440
- package/src/embedded-react/Easing.js +0 -39
- package/src/embedded-react/PanResponder.js +0 -330
- package/src/embedded-react/SectionList.js +0 -146
- package/src/embedded-react/layout-anim-config.js +0 -101
- package/src/embedded-react/nativeModule.js +0 -462
- package/src/embedded-react/split-style.js +0 -58
- package/src/embedded-react/svg-ops.js +0 -1295
- package/src/host-config.js +0 -548
- package/src/props.js +0 -306
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
16
|
// useHostValue — a numeric value fed by the C HOST at runtime, not by the app.
|
|
18
17
|
//
|
|
19
18
|
// Flow B (AOT): the compiler recognizes `const steps = useHostValue(0)` and lowers it to an ordinary state
|
|
@@ -24,8 +23,7 @@
|
|
|
24
23
|
// Flow A / simulator: there is no host, so this simply returns the initial value (the simulator has no
|
|
25
24
|
// IMU to drive it anyway).
|
|
26
25
|
//
|
|
27
|
-
//
|
|
28
|
-
// @returns {number} the current value.
|
|
26
|
+
// `initial` is the value until the host writes one.
|
|
29
27
|
export function useHostValue(initial) {
|
|
30
|
-
|
|
28
|
+
return initial;
|
|
31
29
|
}
|
|
@@ -13,57 +13,53 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
16
|
// usePersistentState — a useState that survives the simulator's hot reload (see
|
|
18
|
-
// tools/simulator/README.md). The simulator's build transform (persist-transform.
|
|
17
|
+
// tools/simulator/README.md). The simulator's build transform (persist-transform.mts) rewrites the app's plain `useState`
|
|
19
18
|
// into this helper, so persistence is transparent — you normally never call this directly; it's also
|
|
20
19
|
// exported for explicit use. Outside the simulator (e.g., on a device, where the host doesn't install
|
|
21
20
|
// `__erPersist`) it is exactly useState, so the same app code runs everywhere.
|
|
22
21
|
//
|
|
23
22
|
// Values must be JSON-serializable (numbers, strings, booleans, plain objects/arrays). The simulator
|
|
24
23
|
// resets the persisted state when you press R (manual reload) or restart it.
|
|
25
|
-
import {useState, useCallback} from 'react';
|
|
26
|
-
|
|
24
|
+
import { useState, useCallback } from 'react';
|
|
27
25
|
/**
|
|
28
26
|
* Drop-in useState that persists across simulator reloads, keyed by a stable string.
|
|
29
27
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @returns {[*, Function]} [value, setValue] — same shape as useState.
|
|
28
|
+
* `key` is a stable identity for this piece of state, unique within the app. `initial` is the value, or a
|
|
29
|
+
* lazy initializer, used when nothing is persisted.
|
|
33
30
|
*/
|
|
34
31
|
export function usePersistentState(key, initial) {
|
|
35
|
-
|
|
36
|
-
const store = globalThis.__erPersist;
|
|
37
|
-
if (store) {
|
|
38
|
-
const stored = store.get(key);
|
|
39
|
-
if (stored !== undefined) {
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(stored);
|
|
42
|
-
} catch {
|
|
43
|
-
/* corrupt/incompatible — fall back to initial */
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return typeof initial === 'function' ? initial() : initial;
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const setPersistedValue = useCallback(
|
|
51
|
-
next => {
|
|
52
|
-
setValue(previous => {
|
|
53
|
-
const resolved = typeof next === 'function' ? next(previous) : next;
|
|
32
|
+
const [value, setValue] = useState(() => {
|
|
54
33
|
const store = globalThis.__erPersist;
|
|
55
34
|
if (store) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
const stored = store.get(key);
|
|
36
|
+
if (stored !== undefined) {
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(stored);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
/* corrupt/incompatible — fall back to initial */
|
|
42
|
+
}
|
|
43
|
+
}
|
|
61
44
|
}
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
return typeof initial === 'function' ? initial() : initial;
|
|
46
|
+
});
|
|
47
|
+
const setPersistedValue = useCallback((next) => {
|
|
48
|
+
setValue(previous => {
|
|
49
|
+
const resolved = typeof next === 'function'
|
|
50
|
+
? next(previous)
|
|
51
|
+
: next;
|
|
52
|
+
const store = globalThis.__erPersist;
|
|
53
|
+
if (store) {
|
|
54
|
+
try {
|
|
55
|
+
store.set(key, JSON.stringify(resolved));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
/* unserializable value — skip persistence, keep the in-memory state */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return resolved;
|
|
62
|
+
});
|
|
63
|
+
}, [key]);
|
|
64
|
+
return [value, setPersistedValue];
|
|
69
65
|
}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
16
|
// Shared "you passed a prop this component ignores" warning for the JS-only RN wrappers (Button,
|
|
18
17
|
// FlatList, ImageBackground, SectionList). Those components exist for API compatibility, so an app
|
|
19
18
|
// ported from React Native arrives carrying props that mean nothing on a panel — and a prop that is
|
|
@@ -22,7 +21,6 @@
|
|
|
22
21
|
// Warns ONCE per component and then stops scanning: these render on the Flow A commit path, and a
|
|
23
22
|
// misconfigured list re-renders on every data change. One line in the device console is a hint; one
|
|
24
23
|
// line per commit is a flood that pushes everything else out of the scrollback.
|
|
25
|
-
|
|
26
24
|
/**
|
|
27
25
|
* RN props that wrap an OS service a bare panel does not have: a screen reader, a focus engine, a test
|
|
28
26
|
* runner, a click sound. They are real RN props, they cost nothing to carry, and keeping them means a
|
|
@@ -34,47 +32,42 @@
|
|
|
34
32
|
* about it is the point.
|
|
35
33
|
*/
|
|
36
34
|
export const RN_PLATFORM_NO_OPS = [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
'accessible',
|
|
36
|
+
'accessibilityLabel',
|
|
37
|
+
'accessibilityHint',
|
|
38
|
+
'accessibilityLanguage',
|
|
39
|
+
'accessibilityRole',
|
|
40
|
+
'accessibilityState',
|
|
41
|
+
'accessibilityActions',
|
|
42
|
+
'onAccessibilityAction',
|
|
43
|
+
'importantForAccessibility',
|
|
44
|
+
'testID',
|
|
45
|
+
'touchSoundDisabled',
|
|
46
|
+
'hasTVPreferredFocus',
|
|
47
|
+
'nextFocusDown',
|
|
48
|
+
'nextFocusForward',
|
|
49
|
+
'nextFocusLeft',
|
|
50
|
+
'nextFocusRight',
|
|
51
|
+
'nextFocusUp',
|
|
54
52
|
];
|
|
55
|
-
|
|
56
53
|
/**
|
|
57
54
|
* Builds the once-only prop warner for a component.
|
|
58
55
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* doesn't have (accessibility, TV focus, test ids). They are portable no-ops, not mistakes.
|
|
64
|
-
* @returns {(props: object) => void} Call with the full prop object on every render.
|
|
56
|
+
* `component` is the name as it appears in JSX. `supported` are the props it honours, listed in the
|
|
57
|
+
* warning as the way out. `hint` says why the rest are ignored, and ends the first sentence. `quiet` are
|
|
58
|
+
* props to ignore silently: RN props that wrap an OS service this board doesn't have. Call the result
|
|
59
|
+
* with the full prop object on every render.
|
|
65
60
|
*/
|
|
66
61
|
export function createPropWarner(component, supported, hint, quiet = []) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
);
|
|
79
|
-
};
|
|
62
|
+
let warned = false;
|
|
63
|
+
return props => {
|
|
64
|
+
if (warned)
|
|
65
|
+
return;
|
|
66
|
+
const names = Object.keys(props).filter(name => !supported.includes(name) && !quiet.includes(name));
|
|
67
|
+
if (names.length === 0)
|
|
68
|
+
return;
|
|
69
|
+
warned = true;
|
|
70
|
+
console.warn(`embedded-react: <${component}> ignores ${names.join(', ')} — ${hint} ` +
|
|
71
|
+
`Supported here: ${supported.join(', ')}.`);
|
|
72
|
+
};
|
|
80
73
|
}
|