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
package/qjsc-wasm.mjs
CHANGED
|
@@ -13,88 +13,63 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
// qjsc-wasm.mjs — compile a JS bundle to QuickJS bytecode using the prebuilt simulator `.wasm` (the SAME
|
|
16
|
+
// qjsc-wasm.mts — compile a JS bundle to QuickJS bytecode using the prebuilt simulator `.wasm` (the SAME
|
|
18
17
|
// QuickJS that runs the app in the browser sim), so `embedded-react build` produces a device-ready
|
|
19
18
|
// bytecode container with NO native toolchain. The module is built with `-sENVIRONMENT=web,node`, so the
|
|
20
19
|
// same artifact that powers `dev` loads under Node here.
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {existsSync} from 'node:fs';
|
|
26
|
-
|
|
20
|
+
import { createRequire } from 'node:module';
|
|
21
|
+
import { dirname, resolve } from 'node:path';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
import { existsSync } from 'node:fs';
|
|
27
24
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
28
25
|
const UINT32_BYTES = 4;
|
|
29
|
-
|
|
30
26
|
/**
|
|
31
27
|
* Compile JS source to a QuickJS bytecode blob via the prebuilt sim module.
|
|
32
28
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
29
|
+
* @param jsSource The bundled app (esbuild IIFE output).
|
|
30
|
+
* @param simDir Dir holding embedded-react.{js,wasm} (defaults to the package's sim/).
|
|
31
|
+
* @param options strip: true drops the embedded source text + debug tables
|
|
36
32
|
* (release/device — ~8x smaller blob); default false keeps them so dev-loop stack traces have
|
|
37
33
|
* line numbers. (A sim .wasm built before the strip parameter existed ignores it and always
|
|
38
34
|
* keeps debug info.)
|
|
39
|
-
* @returns
|
|
35
|
+
* @returns The bytecode bytes.
|
|
40
36
|
*/
|
|
41
|
-
export async function compileToBytecode(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// ALLOW_MEMORY_GROWTH=1 can detach views across the malloc/compile calls — read through a FRESH buffer.
|
|
81
|
-
const heap = () => new Uint8Array(Module.HEAPU8.buffer);
|
|
82
|
-
const bytecodeLength = new DataView(heap().buffer).getUint32(
|
|
83
|
-
outputLengthPointer,
|
|
84
|
-
true,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
Module._free(sourcePointer);
|
|
88
|
-
Module._free(outputLengthPointer);
|
|
89
|
-
if (!bytecodePointer || !bytecodeLength) {
|
|
90
|
-
if (bytecodePointer) Module._free(bytecodePointer);
|
|
91
|
-
throw new Error(
|
|
92
|
-
'bytecode compile failed — check the bundle for a syntax error (see stderr above)',
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
const bytecode = Buffer.from(
|
|
96
|
-
heap().subarray(bytecodePointer, bytecodePointer + bytecodeLength),
|
|
97
|
-
); // copy out before freeing
|
|
98
|
-
Module._free(bytecodePointer);
|
|
99
|
-
return bytecode;
|
|
37
|
+
export async function compileToBytecode(jsSource, simDir = resolve(HERE, 'sim'), { strip = false } = {}) {
|
|
38
|
+
// The .cjs (not .js): this package is "type": "module", so Node would load the emscripten .js as ESM and
|
|
39
|
+
// its CommonJS factory export would never run. The .cjs is the same module forced to CommonJS for Node.
|
|
40
|
+
const loader = resolve(simDir, 'embedded-react.cjs');
|
|
41
|
+
if (!existsSync(loader)) {
|
|
42
|
+
throw new Error(`prebuilt simulator module not found at ${loader} (a published package ships it; from source run tools/web-sim/build.mts)`);
|
|
43
|
+
}
|
|
44
|
+
const require = createRequire(import.meta.url);
|
|
45
|
+
const factory = require(loader); // forced CommonJS → MODULARIZE factory
|
|
46
|
+
const Module = await factory();
|
|
47
|
+
const bytes = new TextEncoder().encode(jsSource);
|
|
48
|
+
// QuickJS's JS_Eval requires the source buffer to be NUL-terminated (buf[len] === 0). Allocate one
|
|
49
|
+
// extra byte and zero it: without the terminator the lexer reads an uninitialized sentinel and can
|
|
50
|
+
// stop early ("unexpected token ''") — a heap-state-dependent failure that only bites on larger inputs.
|
|
51
|
+
const sourcePointer = Module._malloc(bytes.length + 1);
|
|
52
|
+
Module.HEAPU8.set(bytes, sourcePointer);
|
|
53
|
+
Module.HEAPU8[sourcePointer + bytes.length] = 0;
|
|
54
|
+
const outputLengthPointer = Module._malloc(UINT32_BYTES);
|
|
55
|
+
const compile = Module.cwrap('er_web_compile_bytecode', 'number', [
|
|
56
|
+
'number',
|
|
57
|
+
'number',
|
|
58
|
+
'number',
|
|
59
|
+
'number',
|
|
60
|
+
]);
|
|
61
|
+
const bytecodePointer = compile(sourcePointer, bytes.length, outputLengthPointer, strip ? 1 : 0);
|
|
62
|
+
// ALLOW_MEMORY_GROWTH=1 can detach views across the malloc/compile calls — read through a FRESH buffer.
|
|
63
|
+
const heap = () => new Uint8Array(Module.HEAPU8.buffer);
|
|
64
|
+
const bytecodeLength = new DataView(heap().buffer).getUint32(outputLengthPointer, true);
|
|
65
|
+
Module._free(sourcePointer);
|
|
66
|
+
Module._free(outputLengthPointer);
|
|
67
|
+
if (!bytecodePointer || !bytecodeLength) {
|
|
68
|
+
if (bytecodePointer)
|
|
69
|
+
Module._free(bytecodePointer);
|
|
70
|
+
throw new Error('bytecode compile failed — check the bundle for a syntax error (see stderr above)');
|
|
71
|
+
}
|
|
72
|
+
const bytecode = Buffer.from(heap().subarray(bytecodePointer, bytecodePointer + bytecodeLength)); // copy out before freeing
|
|
73
|
+
Module._free(bytecodePointer);
|
|
74
|
+
return bytecode;
|
|
100
75
|
}
|
package/sim/embedded-react.wasm
CHANGED
|
Binary file
|