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/hotreload/pack-split.mjs
CHANGED
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
16
|
// pack-split — build the vendor/app SPLIT of a Flow A app, for incremental hot reload.
|
|
18
17
|
//
|
|
19
|
-
// The monolithic packer (pack-app.
|
|
18
|
+
// The monolithic packer (pack-app.mts) inlines react + react-reconciler + the embedded-react library
|
|
20
19
|
// together with the user's source into one ~1 MB bytecode blob. But the framework half never changes
|
|
21
20
|
// when you edit your app, so re-shipping and re-parsing it on every save is pure waste. pack-split cuts
|
|
22
21
|
// the bundle along the one seam that matters:
|
|
@@ -32,45 +31,40 @@
|
|
|
32
31
|
// then the app. A hot-reload frame carries only the app chunk — the device keeps the resident vendor and
|
|
33
32
|
// swaps just the app (a "soft reset"). Old monolithic containers still boot unchanged (emit-container's
|
|
34
33
|
// vendor section is optional), so this is backwards-compatible, and production behavior is identical.
|
|
35
|
-
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {existsSync, statSync} from 'node:fs';
|
|
40
|
-
|
|
34
|
+
import { createRequire } from 'node:module';
|
|
35
|
+
import { pathToFileURL } from 'node:url';
|
|
36
|
+
import { basename, dirname, resolve, relative } from 'node:path';
|
|
37
|
+
import { existsSync, statSync } from 'node:fs';
|
|
41
38
|
const require = createRequire(import.meta.url);
|
|
42
|
-
|
|
43
|
-
// QuickJS release the bytecode container targets — MUST match cli.
|
|
39
|
+
const loadEsbuild = () => require('esbuild');
|
|
40
|
+
// QuickJS release the bytecode container targets — MUST match cli.mts's QJS_TAG, pack-app.mts, and the
|
|
44
41
|
// device loader.
|
|
45
42
|
const QJS_TAG = 'v0.15.0';
|
|
46
|
-
|
|
47
43
|
// The shared deps the app chunk resolve through the vendor registry instead of inlining.
|
|
48
44
|
export const VENDOR_EXTERNALS = [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
'react',
|
|
46
|
+
'react/jsx-runtime',
|
|
47
|
+
'embedded-react',
|
|
52
48
|
];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
write: false,
|
|
49
|
+
const esbuildCommon = (nodePaths) => ({
|
|
50
|
+
bundle: true,
|
|
51
|
+
format: 'iife',
|
|
52
|
+
platform: 'neutral',
|
|
53
|
+
target: 'es2020',
|
|
54
|
+
jsx: 'automatic',
|
|
55
|
+
nodePaths,
|
|
56
|
+
define: { 'process.env.NODE_ENV': '"production"' },
|
|
57
|
+
legalComments: 'none',
|
|
58
|
+
logLevel: 'silent',
|
|
59
|
+
write: false,
|
|
65
60
|
});
|
|
66
|
-
|
|
67
61
|
/**
|
|
68
62
|
* The vendor chunk's synthetic entry source: import the shared deps, register them in a runtime module
|
|
69
63
|
* registry, and install the `require()` shim the app chunk resolves through. esbuild's `__require` helper
|
|
70
64
|
* (emitted for the app chunk's external imports) finds this global `require` at runtime.
|
|
71
65
|
*/
|
|
72
66
|
function vendorEntrySource() {
|
|
73
|
-
|
|
67
|
+
return `import * as React from 'react';
|
|
74
68
|
import * as JsxRuntime from 'react/jsx-runtime';
|
|
75
69
|
import * as EmbeddedReact from 'embedded-react';
|
|
76
70
|
const reg = (globalThis.__er_modules = globalThis.__er_modules || {});
|
|
@@ -84,217 +78,167 @@ globalThis.require = function (id) {
|
|
|
84
78
|
};
|
|
85
79
|
`;
|
|
86
80
|
}
|
|
87
|
-
|
|
88
81
|
/**
|
|
89
82
|
* Bundle the vendor chunk (react + reconciler + embedded-react lib) to a self-contained IIFE source.
|
|
90
83
|
*
|
|
91
|
-
* @
|
|
92
|
-
* @param {string} options.libSrc embedded-react library entry (aliased as 'embedded-react').
|
|
93
|
-
* @param {string[]} options.nodePaths esbuild nodePaths (package + project node_modules).
|
|
94
|
-
* @returns {Promise<string>} The bundled JS source.
|
|
84
|
+
* @returns The bundled JS source.
|
|
95
85
|
*/
|
|
96
|
-
export async function bundleVendorSource({libSrc, nodePaths}) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
86
|
+
export async function bundleVendorSource({ libSrc, nodePaths, }) {
|
|
87
|
+
const esbuild = loadEsbuild();
|
|
88
|
+
const result = await esbuild.build({
|
|
89
|
+
...esbuildCommon(nodePaths),
|
|
90
|
+
stdin: {
|
|
91
|
+
contents: vendorEntrySource(),
|
|
92
|
+
resolveDir: dirname(libSrc),
|
|
93
|
+
sourcefile: 'vendor-entry.js',
|
|
94
|
+
loader: 'js',
|
|
95
|
+
},
|
|
96
|
+
alias: { 'embedded-react': libSrc },
|
|
97
|
+
});
|
|
98
|
+
return result.outputFiles[0].text;
|
|
109
99
|
}
|
|
110
|
-
|
|
111
100
|
/**
|
|
112
101
|
* Build an asset-discovering esbuild plugin shared with the monolithic packer's behavior: image/font/svg
|
|
113
102
|
* imports become bare string names (the bytes live in the ERPK pack). The app's own source gives its native modules
|
|
114
103
|
* their signatures and, when persist is on, gets the useState→persist transform so state survives a live reload.
|
|
115
104
|
*/
|
|
116
|
-
function makeAssetPlugin({images, fonts, persist, projectRoot}) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
fonts.set(family, args.path);
|
|
158
|
-
return {
|
|
159
|
-
contents: `module.exports = ${JSON.stringify(family)};`,
|
|
160
|
-
loader: 'js',
|
|
161
|
-
};
|
|
162
|
-
});
|
|
163
|
-
registerSvgVectorLoader(build, (name, pngPath) =>
|
|
164
|
-
images.set(name, pngPath),
|
|
165
|
-
);
|
|
166
|
-
},
|
|
167
|
-
};
|
|
105
|
+
function makeAssetPlugin({ images, fonts, persist, projectRoot, }) {
|
|
106
|
+
const assetName = (filePath) => basename(filePath).replace(/\.[^.]+$/, '');
|
|
107
|
+
return {
|
|
108
|
+
name: 'embedded-react-assets',
|
|
109
|
+
async setup(build) {
|
|
110
|
+
const { registerSvgVectorLoader } = await import('../assets/svg-loader.mjs');
|
|
111
|
+
const { shouldPersist, transformPersist } = await import('../persist-transform.mjs');
|
|
112
|
+
const { loadAppFile, loadDependencyFile } = await import('../aot/app-file-loader.mjs');
|
|
113
|
+
const normalizedProjectRoot = projectRoot.replace(/\\/g, '/');
|
|
114
|
+
build.onLoad({ filter: /\.(jsx?|tsx?)$/ }, async (args) => {
|
|
115
|
+
if (!shouldPersist(args.path, normalizedProjectRoot)) {
|
|
116
|
+
return loadDependencyFile(args.path);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
return await loadAppFile(args.path, persist
|
|
120
|
+
? (source) => transformPersist(source, relative(projectRoot, args.path).replace(/\\/g, '/'))
|
|
121
|
+
: undefined);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return { errors: [{ text: `persist transform: ${error.message}` }] };
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
build.onLoad({ filter: /\.(png|jpe?g|webp|gif|bmp)$/i }, args => {
|
|
128
|
+
const name = assetName(args.path);
|
|
129
|
+
images.set(name, args.path);
|
|
130
|
+
return {
|
|
131
|
+
contents: `module.exports = ${JSON.stringify(name)};`,
|
|
132
|
+
loader: 'js',
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
build.onLoad({ filter: /\.(ttf|otf)$/i }, args => {
|
|
136
|
+
const family = assetName(args.path);
|
|
137
|
+
fonts.set(family, args.path);
|
|
138
|
+
return {
|
|
139
|
+
contents: `module.exports = ${JSON.stringify(family)};`,
|
|
140
|
+
loader: 'js',
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
registerSvgVectorLoader(build, (name, pngPath) => images.set(name, pngPath));
|
|
144
|
+
},
|
|
145
|
+
};
|
|
168
146
|
}
|
|
169
|
-
|
|
170
147
|
/**
|
|
171
148
|
* Bundle the app chunk: the user's entry with the shared deps marked external (resolved at runtime through
|
|
172
149
|
* the vendor registry). Returns the bundled source plus the discovered image/font maps for baking.
|
|
173
150
|
*/
|
|
174
|
-
export async function bundleAppSource({
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
...esbuildCommon(nodePaths),
|
|
186
|
-
entryPoints: [entry],
|
|
187
|
-
external: VENDOR_EXTERNALS,
|
|
188
|
-
plugins: [makeAssetPlugin({images, fonts, persist, projectRoot})],
|
|
189
|
-
});
|
|
190
|
-
return {source: result.outputFiles[0].text, images, fonts};
|
|
151
|
+
export async function bundleAppSource({ entry, projectRoot, nodePaths, persist = false, }) {
|
|
152
|
+
const esbuild = loadEsbuild();
|
|
153
|
+
const images = new Map();
|
|
154
|
+
const fonts = new Map();
|
|
155
|
+
const result = await esbuild.build({
|
|
156
|
+
...esbuildCommon(nodePaths),
|
|
157
|
+
entryPoints: [entry],
|
|
158
|
+
external: VENDOR_EXTERNALS,
|
|
159
|
+
plugins: [makeAssetPlugin({ images, fonts, persist, projectRoot })],
|
|
160
|
+
});
|
|
161
|
+
return { source: result.outputFiles[0].text, images, fonts };
|
|
191
162
|
}
|
|
192
|
-
|
|
193
163
|
/** Bake the discovered images/fonts into an ERPK asset pack (or null if there are none). */
|
|
194
|
-
async function bakeAssets({images, fonts, source, projectRoot}) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
await import('../assets/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
config
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}));
|
|
223
|
-
const bakedImages = imageJobs.map(bakeImage);
|
|
224
|
-
const bakedFonts = fontJobs.map(bakeFont);
|
|
225
|
-
warnMissingGlyphs({source, fonts: bakedFonts});
|
|
226
|
-
warnFontSizes({used: usedSizes, fonts: bakedFonts});
|
|
227
|
-
return bakedImages.length || bakedFonts.length
|
|
228
|
-
? emitAssetPack({images: bakedImages, fonts: bakedFonts})
|
|
229
|
-
: null;
|
|
164
|
+
async function bakeAssets({ images, fonts, source, projectRoot, }) {
|
|
165
|
+
const { bakeImage } = await import('../assets/bake-image.mjs');
|
|
166
|
+
const { bakeFont } = await import('../assets/bake-font.mjs');
|
|
167
|
+
const { resolveFontJobs } = await import('../assets/font-config.mjs');
|
|
168
|
+
const { analyzeFontSizes, warnFontSizes } = await import('../assets/font-sizes.mjs');
|
|
169
|
+
const { warnMissingGlyphs } = await import('../assets/glyph-coverage.mjs');
|
|
170
|
+
const { emitAssetPack } = await import('../assets/emit-pack.mjs');
|
|
171
|
+
const usedSizes = analyzeFontSizes(source);
|
|
172
|
+
let config = {};
|
|
173
|
+
const configPath = resolve(projectRoot, 'assets.config.js');
|
|
174
|
+
if (existsSync(configPath))
|
|
175
|
+
config =
|
|
176
|
+
(await import(`${pathToFileURL(configPath).href}?t=${statSync(configPath).mtimeMs}`)).default || {};
|
|
177
|
+
const fontConfig = config.fonts || {};
|
|
178
|
+
const imageConfig = config.images || {};
|
|
179
|
+
const fontJobs = resolveFontJobs(fonts, fontConfig, usedSizes.sizes);
|
|
180
|
+
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
181
|
+
path,
|
|
182
|
+
name,
|
|
183
|
+
format: imageConfig[name]?.format,
|
|
184
|
+
}));
|
|
185
|
+
const bakedImages = imageJobs.map(bakeImage);
|
|
186
|
+
const bakedFonts = fontJobs.map(bakeFont);
|
|
187
|
+
warnMissingGlyphs({ source, fonts: bakedFonts });
|
|
188
|
+
warnFontSizes({ used: usedSizes, fonts: bakedFonts });
|
|
189
|
+
return bakedImages.length || bakedFonts.length
|
|
190
|
+
? emitAssetPack({ images: bakedImages, fonts: bakedFonts })
|
|
191
|
+
: null;
|
|
230
192
|
}
|
|
231
|
-
|
|
232
193
|
/**
|
|
233
194
|
* Compile the vendor chunk to a QuickJS bytecode blob. Built once per dev session (it changes only when a
|
|
234
195
|
* dependency changes), so the per-edit reload never re-ships it.
|
|
235
|
-
*
|
|
236
|
-
* @returns {Promise<{bytecode: Buffer, bytecodeLen: number}>}
|
|
237
196
|
*/
|
|
238
|
-
export async function packVendor({libSrc, nodePaths, simDir, strip = false}) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
197
|
+
export async function packVendor({ libSrc, nodePaths, simDir, strip = false, }) {
|
|
198
|
+
const { compileToBytecode } = await import('../qjsc-wasm.mjs');
|
|
199
|
+
const source = await bundleVendorSource({ libSrc, nodePaths });
|
|
200
|
+
const bytecode = await compileToBytecode(source, simDir, { strip });
|
|
201
|
+
return { bytecode, bytecodeLen: bytecode.length };
|
|
243
202
|
}
|
|
244
|
-
|
|
245
203
|
/**
|
|
246
204
|
* Compile the app chunk to a QuickJS bytecode blob and bake its assets. This is the only thing rebuilt on
|
|
247
205
|
* each save — and the only thing a hot-reload frame carries.
|
|
248
|
-
*
|
|
249
|
-
* @returns {Promise<{bytecode: Buffer, assetPack: Buffer|null, bytecodeLen: number, assetsLen: number}>}
|
|
250
206
|
*/
|
|
251
|
-
export async function packApp({
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const bytecode = await compileToBytecode(source, simDir, {strip});
|
|
268
|
-
const assetPack = await bakeAssets({images, fonts, source, projectRoot});
|
|
269
|
-
return {
|
|
270
|
-
bytecode,
|
|
271
|
-
assetPack,
|
|
272
|
-
bytecodeLen: bytecode.length,
|
|
273
|
-
assetsLen: assetPack ? assetPack.length : 0,
|
|
274
|
-
};
|
|
207
|
+
export async function packApp({ entry, projectRoot, nodePaths, simDir, persist = false, strip = false, }) {
|
|
208
|
+
const { compileToBytecode } = await import('../qjsc-wasm.mjs');
|
|
209
|
+
const { source, images, fonts } = await bundleAppSource({
|
|
210
|
+
entry,
|
|
211
|
+
projectRoot,
|
|
212
|
+
nodePaths,
|
|
213
|
+
persist,
|
|
214
|
+
});
|
|
215
|
+
const bytecode = await compileToBytecode(source, simDir, { strip });
|
|
216
|
+
const assetPack = await bakeAssets({ images, fonts, source, projectRoot });
|
|
217
|
+
return {
|
|
218
|
+
bytecode,
|
|
219
|
+
assetPack,
|
|
220
|
+
bytecodeLen: bytecode.length,
|
|
221
|
+
assetsLen: assetPack ? assetPack.length : 0,
|
|
222
|
+
};
|
|
275
223
|
}
|
|
276
|
-
|
|
277
224
|
/**
|
|
278
225
|
* Assemble the flashed BOOT container: vendor + app + assets in one ERCF. The device runs vendor first
|
|
279
226
|
* (installs the registry + require shim), registers assets, then runs the app. Used by `embedded-react
|
|
280
227
|
* build` so the same firmware/artifact serves both production and hot reload.
|
|
281
228
|
*/
|
|
282
|
-
export function emitBootContainer({vendorBytecode, appBytecode, assetPack}) {
|
|
283
|
-
|
|
229
|
+
export function emitBootContainer({ vendorBytecode, appBytecode, assetPack, }) {
|
|
230
|
+
return emit({ bytecode: appBytecode, vendorBytecode, assetPack });
|
|
284
231
|
}
|
|
285
|
-
|
|
286
232
|
/**
|
|
287
233
|
* Assemble a hot-reload APP frame: the app chunk + its assets, NO vendor. The device keeps the resident
|
|
288
234
|
* vendor and swaps just the app (soft reset). This is the ~64 KB that travels on each save.
|
|
289
235
|
*/
|
|
290
|
-
export function emitAppFrame({appBytecode, assetPack}) {
|
|
291
|
-
|
|
236
|
+
export function emitAppFrame({ appBytecode, assetPack, }) {
|
|
237
|
+
return emit({ bytecode: appBytecode, assetPack });
|
|
292
238
|
}
|
|
293
|
-
|
|
294
239
|
// emitBootContainer/emitAppFrame are async (emit() dynamically imports the emitter) — callers await them.
|
|
295
240
|
async function emit(options) {
|
|
296
|
-
|
|
297
|
-
|
|
241
|
+
const { emitContainer } = await import('../assets/emit-container.mjs');
|
|
242
|
+
return emitContainer({ ...options, qjsTag: QJS_TAG });
|
|
298
243
|
}
|
|
299
|
-
|
|
300
|
-
export {QJS_TAG};
|
|
244
|
+
export { QJS_TAG };
|