embedded-react 0.10.2 → 0.11.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 +8 -1
- package/assets/bake-image.mjs +47 -9
- package/assets/emit-c.mjs +11 -6
- package/assets/emit-container.mjs +30 -1
- package/assets/emit-pack.mjs +31 -6
- package/assets/index.mjs +2 -1
- package/build.mjs +6 -1
- package/cli.mjs +10 -1
- package/hotreload/pack-app.mjs +6 -1
- package/hotreload/pack-split.mjs +6 -1
- package/pack-container.mjs +6 -1
- package/package.json +1 -1
- package/sim/embedded-react.wasm +0 -0
- package/sim-server.mjs +3 -1
package/README.md
CHANGED
|
@@ -144,7 +144,11 @@ firmware that prefers to **compile assets into the image** and call it once at b
|
|
|
144
144
|
`er_font_register`, both flash-resident, zero runtime RAM). Either way the asset name/family is the
|
|
145
145
|
file's basename.
|
|
146
146
|
|
|
147
|
-
- **Images:** PNG → premultiplied ARGB8888 (`bake-image.mjs`, via `pngjs`).
|
|
147
|
+
- **Images:** PNG → premultiplied ARGB8888 (`bake-image.mjs`, via `pngjs`). Fully opaque art —
|
|
148
|
+
full-screen backgrounds especially — can opt into a 16-bit **RGB565** bake per image (see the
|
|
149
|
+
config below): half the flash and half the source-read bandwidth on every repaint. The baker
|
|
150
|
+
rejects a non-opaque source rather than silently dropping transparency, and the engine renders
|
|
151
|
+
RGB565 images through its opaque copy fast path (no per-pixel blending).
|
|
148
152
|
- **Fonts:** TTF/OTF → pre-rasterized `BitmapFont` glyphs (`bake-font.mjs`, via `opentype.js` + a
|
|
149
153
|
pure-JS rasterizer). The engine has no runtime rasterizer, so the baker rasterizes **exactly the
|
|
150
154
|
literal `fontSize` values the bundle uses**. Computed/dynamic sizes snap to the nearest baked size
|
|
@@ -157,6 +161,9 @@ export default {
|
|
|
157
161
|
fonts: {
|
|
158
162
|
Inter: { sizes: [14, 18, 24], bpp: 4, glyphs: 'common' }, // bpp 1|2|4|8 (4 default); glyphs: 'ascii'|'common'|'minimal'|'greek'|[codepoints]
|
|
159
163
|
},
|
|
164
|
+
images: {
|
|
165
|
+
bg: { format: 'rgb565' }, // 16-bit bake for opaque art; default is 'argb8888'
|
|
166
|
+
},
|
|
160
167
|
};
|
|
161
168
|
```
|
|
162
169
|
|
package/assets/bake-image.mjs
CHANGED
|
@@ -14,28 +14,66 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
// Build-time image baker: PNG → premultiplied ARGB8888
|
|
18
|
-
// references by pointer (er_image_load
|
|
19
|
-
// scales at render time, so bake at
|
|
17
|
+
// Build-time image baker: PNG → premultiplied ARGB8888 (the default) or RGB565, the two formats
|
|
18
|
+
// the engine's image registry references by pointer (er_image_load / er_image_load_rgb565).
|
|
19
|
+
// Pure JS (pngjs) — no native deps, no Python. The engine scales at render time, so bake at
|
|
20
|
+
// whatever source resolution you want to ship.
|
|
20
21
|
import fs from 'node:fs';
|
|
21
22
|
import {PNG} from 'pngjs';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* Decodes an image and returns its
|
|
25
|
+
* Decodes an image and returns its baked pixels.
|
|
26
|
+
*
|
|
27
|
+
* The default format is premultiplied ARGB8888 (row-major, 0xAARRGGBB). Pass format 'rgb565' to bake
|
|
28
|
+
* 16-bit RGB565 instead — half the flash and half the source-read bandwidth on every repaint,
|
|
29
|
+
* meant for opaque full-screen backgrounds. RGB565 has no alpha channel, so a source image with
|
|
30
|
+
* any non-opaque pixel is rejected with an error rather than silently dropping its transparency.
|
|
25
31
|
*
|
|
26
32
|
* @param {object} opts
|
|
27
|
-
* @param {string} opts.path
|
|
28
|
-
* @param {string} opts.name
|
|
29
|
-
* @
|
|
33
|
+
* @param {string} opts.path Path to the source image.
|
|
34
|
+
* @param {string} opts.name Asset name an <Image source>/imageName looks up.
|
|
35
|
+
* @param {string} [opts.format] 'argb8888' (default) or 'rgb565'.
|
|
36
|
+
* @returns {{name:string, width:number, height:number, format:'argb8888'|'rgb565',
|
|
37
|
+
* pixels:Uint32Array|Uint16Array}}
|
|
30
38
|
*/
|
|
31
|
-
export function bakeImage({path, name}) {
|
|
39
|
+
export function bakeImage({path, name, format = 'argb8888'}) {
|
|
32
40
|
if (!/\.png$/i.test(path)) {
|
|
33
41
|
throw new Error(
|
|
34
42
|
`image "${path}": only PNG is supported by the baker (convert to PNG, or extend bake-image.mjs)`,
|
|
35
43
|
);
|
|
36
44
|
}
|
|
45
|
+
if (format !== 'argb8888' && format !== 'rgb565') {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`image "${name}": unknown format "${format}" (expected "argb8888" or "rgb565")`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
37
50
|
const png = PNG.sync.read(fs.readFileSync(path));
|
|
38
51
|
const {width, height, data} = png; // data = RGBA, 8-bit, row-major
|
|
52
|
+
|
|
53
|
+
if (format === 'rgb565') {
|
|
54
|
+
const pixels = new Uint16Array(width * height);
|
|
55
|
+
for (let i = 0; i < width * height; i++) {
|
|
56
|
+
const r = data[i * 4];
|
|
57
|
+
const g = data[i * 4 + 1];
|
|
58
|
+
const b = data[i * 4 + 2];
|
|
59
|
+
const a = data[i * 4 + 3];
|
|
60
|
+
if (a !== 255) {
|
|
61
|
+
const x = i % width;
|
|
62
|
+
const y = (i - x) / width;
|
|
63
|
+
throw new Error(
|
|
64
|
+
`image "${name}": rgb565 requires a fully opaque source, but pixel (${x},${y}) has alpha ${a} — ` +
|
|
65
|
+
`flatten the art onto its background, or keep the default argb8888 format`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
// Round-to-nearest 8→5/6/5 bit reduction (the engine bit-replicates back on expand).
|
|
69
|
+
const r5 = Math.round((r * 31) / 255);
|
|
70
|
+
const g6 = Math.round((g * 63) / 255);
|
|
71
|
+
const b5 = Math.round((b * 31) / 255);
|
|
72
|
+
pixels[i] = ((r5 << 11) | (g6 << 5) | b5) & 0xffff;
|
|
73
|
+
}
|
|
74
|
+
return {name, width, height, format, pixels};
|
|
75
|
+
}
|
|
76
|
+
|
|
39
77
|
const pixels = new Uint32Array(width * height);
|
|
40
78
|
for (let i = 0; i < width * height; i++) {
|
|
41
79
|
const r = data[i * 4];
|
|
@@ -48,5 +86,5 @@ export function bakeImage({path, name}) {
|
|
|
48
86
|
const bp = Math.floor((b * a + 127) / 255);
|
|
49
87
|
pixels[i] = ((a << 24) | (rp << 16) | (gp << 8) | bp) >>> 0;
|
|
50
88
|
}
|
|
51
|
-
return {name, width, height, pixels};
|
|
89
|
+
return {name, width, height, format, pixels};
|
|
52
90
|
}
|
package/assets/emit-c.mjs
CHANGED
|
@@ -67,7 +67,7 @@ export function emitAssetsC({headerName, images = [], fonts = []}) {
|
|
|
67
67
|
const lines = [];
|
|
68
68
|
lines.push(`/* Generated by bridges/quickjs/js/assets — DO NOT EDIT. */`);
|
|
69
69
|
lines.push(
|
|
70
|
-
`/* Images: premultiplied ARGB8888, referenced by pointer. Fonts: baked BitmapFont per size. */`,
|
|
70
|
+
`/* Images: premultiplied ARGB8888 (or RGB565 when baked 16-bit), referenced by pointer. Fonts: baked BitmapFont per size. */`,
|
|
71
71
|
);
|
|
72
72
|
lines.push(``);
|
|
73
73
|
lines.push(`#include "${headerName}"`);
|
|
@@ -81,13 +81,16 @@ export function emitAssetsC({headerName, images = [], fonts = []}) {
|
|
|
81
81
|
// --- Images ---------------------------------------------------------------------------------
|
|
82
82
|
for (const img of images) {
|
|
83
83
|
const id = cIdent(img.name);
|
|
84
|
+
const is565 = img.format === 'rgb565';
|
|
84
85
|
const hex = Array.from(
|
|
85
86
|
img.pixels,
|
|
86
|
-
p => '0x' + p.toString(16).toUpperCase().padStart(8, '0') + 'u',
|
|
87
|
+
p => '0x' + p.toString(16).toUpperCase().padStart(is565 ? 4 : 8, '0') + 'u',
|
|
87
88
|
);
|
|
88
|
-
lines.push(
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
lines.push(
|
|
90
|
+
`/* image "${img.name}" — ${img.width}x${img.height}${is565 ? ' (RGB565)' : ''} */`,
|
|
91
|
+
);
|
|
92
|
+
lines.push(`static const ${is565 ? 'uint16_t' : 'uint32_t'} ${id}_px[] = {`);
|
|
93
|
+
lines.push(rows(hex, is565 ? 12 : 8));
|
|
91
94
|
lines.push(`};`);
|
|
92
95
|
lines.push(``);
|
|
93
96
|
}
|
|
@@ -111,8 +114,10 @@ export function emitAssetsC({headerName, images = [], fonts = []}) {
|
|
|
111
114
|
lines.push(`void er_register_assets(void)`);
|
|
112
115
|
lines.push(`{`);
|
|
113
116
|
for (const img of images) {
|
|
117
|
+
const loadFn =
|
|
118
|
+
img.format === 'rgb565' ? 'er_image_load_rgb565' : 'er_image_load';
|
|
114
119
|
lines.push(
|
|
115
|
-
`
|
|
120
|
+
` ${loadFn}(${JSON.stringify(img.name)}, ${cIdent(img.name)}_px, ${img.width}, ${img.height});`,
|
|
116
121
|
);
|
|
117
122
|
}
|
|
118
123
|
for (const reg of fontRegistrations) lines.push(reg);
|
|
@@ -32,14 +32,25 @@
|
|
|
32
32
|
// qjs_tag u16 len + bytes — QuickJS release the bytecode targets (loader rejects mismatch)
|
|
33
33
|
// section_count u32
|
|
34
34
|
// sections[section_count]: type u32, len u32, bytes
|
|
35
|
+
// type 0 = alignment padding (zero bytes — carries no payload, skipped by loaders)
|
|
35
36
|
// type 1 = QuickJS bytecode (the app — run last)
|
|
36
37
|
// type 2 = ERPK asset pack (registered before the app mounts)
|
|
37
38
|
// type 3 = QuickJS vendor bytecode (react + reconciler + lib — run FIRST, before the app). Optional;
|
|
38
39
|
// present only for the vendor/app split used by incremental hot reload. A container with no
|
|
39
40
|
// type-3 section is a plain monolithic app, loaded exactly as before (backwards-compatible).
|
|
41
|
+
//
|
|
42
|
+
// Alignment contract: the engine reads asset pixels IN PLACE from wherever the container sits (e.g.
|
|
43
|
+
// memory-mapped flash), and the pack's internal pixel padding is computed relative to the pack's own
|
|
44
|
+
// first byte. Those pads only mean anything at the absolute addresses the engine reads if the pack
|
|
45
|
+
// itself starts on a 4-byte boundary — so the emitter inserts a type-0 padding section before the
|
|
46
|
+
// asset pack whenever needed to 4-align the pack's first byte RELATIVE TO THE CONTAINER, and the host
|
|
47
|
+
// must place the container at a 4-byte-aligned base address (linker scripts typically give 16; malloc
|
|
48
|
+
// guarantees it). Loaders bounds-walk every section and dispatch only on types they know, so old
|
|
49
|
+
// loaders skip the padding section untouched — no format version bump.
|
|
40
50
|
|
|
41
51
|
const FORMAT_VERSION = 1;
|
|
42
52
|
|
|
53
|
+
export const SECTION_PAD = 0;
|
|
43
54
|
export const SECTION_BYTECODE = 1;
|
|
44
55
|
export const SECTION_ASSET_PACK = 2;
|
|
45
56
|
export const SECTION_VENDOR_BYTECODE = 3;
|
|
@@ -118,8 +129,26 @@ export function emitContainer({bytecode, vendorBytecode, assetPack, qjsTag}) {
|
|
|
118
129
|
if (assetPack && assetPack.length)
|
|
119
130
|
sections.push([SECTION_ASSET_PACK, assetPack]);
|
|
120
131
|
sections.push([SECTION_BYTECODE, bytecode]);
|
|
121
|
-
|
|
132
|
+
|
|
133
|
+
// 4-align the asset pack's first byte relative to the container (see the alignment contract above)
|
|
134
|
+
// by inserting a type-0 padding section ahead of it when the layout calls for one. Walk the layout
|
|
135
|
+
// once to place pads, then write — section_count must already include them.
|
|
136
|
+
const withPads = [];
|
|
137
|
+
let off = 12 + 2 + Buffer.byteLength(qjsTag, 'utf8') + 4; // header + tag + section_count
|
|
122
138
|
for (const [type, data] of sections) {
|
|
139
|
+
if (type === SECTION_ASSET_PACK) {
|
|
140
|
+
const pad = (4 - ((off + 8) % 4)) % 4; // +8 = this section's own type+len header
|
|
141
|
+
if (pad) {
|
|
142
|
+
withPads.push([SECTION_PAD, Buffer.alloc(pad)]);
|
|
143
|
+
off += 8 + pad;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
withPads.push([type, data]);
|
|
147
|
+
off += 8 + data.length;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
body.u32(withPads.length);
|
|
151
|
+
for (const [type, data] of withPads) {
|
|
123
152
|
body.u32(type);
|
|
124
153
|
body.u32(data.length);
|
|
125
154
|
body.bytes(data);
|
package/assets/emit-pack.mjs
CHANGED
|
@@ -21,15 +21,21 @@
|
|
|
21
21
|
// loads this at runtime and calls er_image_load / er_font_register, so assets hot-reload without a
|
|
22
22
|
// sim rebuild. Little-endian (the simulator is x86). Format:
|
|
23
23
|
//
|
|
24
|
-
// magic "ERPK" (4 bytes), version u32
|
|
25
|
-
// images[n_images]: name(u16 len + bytes), width u32, height u32,
|
|
24
|
+
// magic "ERPK" (4 bytes), version u32 (1 or 2), n_images u32, n_font_sizes u32
|
|
25
|
+
// images[n_images]: name(u16 len + bytes), width u32, height u32,
|
|
26
|
+
// [v2 only: format u8 (0=ARGB8888, 1=RGB565), zero-pad to 4-byte alignment],
|
|
27
|
+
// pixels (w*h * u32 ARGB, or w*h * u16 RGB565 when format=1)
|
|
26
28
|
// fonts[n_font_sizes]: family(u16 len + bytes), pixel_size/line_height/baseline/format (4*u8),
|
|
27
29
|
// first u16, last u16, glyph_count u16, extras_count u16, bitmap_len u32,
|
|
28
30
|
// glyphs[glyph_count] (9B: off u32, w/h u8, xo/yo i8, adv u8),
|
|
29
31
|
// extras[extras_count] (13B: codepoint u32 + the 9B glyph),
|
|
30
32
|
// bitmap (bitmap_len bytes)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
//
|
|
34
|
+
// Version 2 is now emitted ALWAYS. It was introduced for the 16-bit image bake, but its real value
|
|
35
|
+
// is the per-image alignment pad: the engine reads pixels in place, and a DMA2D-class backend
|
|
36
|
+
// refuses a word-misaligned ARGB8888 source (configuration error — silently absent image). v1 had
|
|
37
|
+
// no alignment machinery, so whether an image's pixels landed word-aligned in flash was an accident
|
|
38
|
+
// of the name strings — it varied build to build. Parsers still accept v1 packs from older tooling.
|
|
33
39
|
|
|
34
40
|
/** Accumulates little-endian binary chunks. */
|
|
35
41
|
class Writer {
|
|
@@ -64,6 +70,12 @@ class Writer {
|
|
|
64
70
|
bytes(buf) {
|
|
65
71
|
this.chunks.push(Buffer.from(buf));
|
|
66
72
|
}
|
|
73
|
+
/** Zero-pads so the next write lands on an n-byte boundary from the pack start. */
|
|
74
|
+
align(n) {
|
|
75
|
+
const len = this.chunks.reduce((a, b) => a + b.length, 0);
|
|
76
|
+
const pad = (n - (len % n)) % n;
|
|
77
|
+
if (pad) this.chunks.push(Buffer.alloc(pad));
|
|
78
|
+
}
|
|
67
79
|
done() {
|
|
68
80
|
return Buffer.concat(this.chunks);
|
|
69
81
|
}
|
|
@@ -88,9 +100,17 @@ function writeGlyph(w, g) {
|
|
|
88
100
|
* @returns {Buffer} The pack bytes.
|
|
89
101
|
*/
|
|
90
102
|
export function emitAssetPack({images = [], fonts = []}) {
|
|
103
|
+
// Emit in a locale-independent sorted order: the discovery maps upstream are filled by esbuild
|
|
104
|
+
// onLoad callbacks in whatever order the bundler visits files, which varies run to run — and an
|
|
105
|
+
// unstable pack means unstable in-flash addresses and non-reproducible builds.
|
|
106
|
+
const byName = k => (a, b) => (a[k] < b[k] ? -1 : a[k] > b[k] ? 1 : 0);
|
|
107
|
+
images = [...images].sort(byName('name'));
|
|
108
|
+
fonts = [...fonts].sort(byName('family'));
|
|
109
|
+
|
|
110
|
+
const version = 2;
|
|
91
111
|
const w = new Writer();
|
|
92
112
|
w.bytes(Buffer.from('ERPK', 'ascii'));
|
|
93
|
-
w.u32(
|
|
113
|
+
w.u32(version);
|
|
94
114
|
w.u32(images.length);
|
|
95
115
|
const fontSizes = fonts.reduce((n, f) => n + f.sizes.length, 0);
|
|
96
116
|
w.u32(fontSizes);
|
|
@@ -99,7 +119,12 @@ export function emitAssetPack({images = [], fonts = []}) {
|
|
|
99
119
|
w.str(img.name);
|
|
100
120
|
w.u32(img.width);
|
|
101
121
|
w.u32(img.height);
|
|
102
|
-
|
|
122
|
+
if (version >= 2) {
|
|
123
|
+
w.u8(img.format === 'rgb565' ? 1 : 0);
|
|
124
|
+
w.align(4); // the engine reads the pixels in place; keep the pointer 4-byte aligned
|
|
125
|
+
}
|
|
126
|
+
// pixels is a Uint32Array (premultiplied ARGB words) or Uint16Array (RGB565);
|
|
127
|
+
// copy its LE bytes verbatim.
|
|
103
128
|
w.bytes(
|
|
104
129
|
Buffer.from(
|
|
105
130
|
img.pixels.buffer,
|
package/assets/index.mjs
CHANGED
|
@@ -28,7 +28,8 @@ import {emitAssetPack} from './emit-pack.mjs';
|
|
|
28
28
|
* Bakes the given assets and writes assets.generated.{c,h} into outDir.
|
|
29
29
|
*
|
|
30
30
|
* @param {object} opts
|
|
31
|
-
* @param {Array<{path:string,name:string}>} [opts.images] Discovered image
|
|
31
|
+
* @param {Array<{path:string,name:string,format?:string}>} [opts.images] Discovered image
|
|
32
|
+
* imports; format 'rgb565' bakes 16-bit (see bake-image.mjs), default ARGB8888.
|
|
32
33
|
* @param {Array<{path:string,family:string,sizes:number[],bpp:number,glyphs:any}>} [opts.fonts]
|
|
33
34
|
* Discovered font imports with their resolved size/bpp/glyph config.
|
|
34
35
|
* @param {string} opts.outDir Directory to write the generated files into.
|
package/build.mjs
CHANGED
|
@@ -139,6 +139,7 @@ if (existsSync(configPath)) {
|
|
|
139
139
|
config = (await import(pathToFileURL(configPath).href)).default || {};
|
|
140
140
|
}
|
|
141
141
|
const fontConfig = config.fonts || {};
|
|
142
|
+
const imageConfig = config.images || {};
|
|
142
143
|
|
|
143
144
|
const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
144
145
|
const fc = fontConfig[family] || {};
|
|
@@ -150,7 +151,11 @@ const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
|
150
151
|
: [16];
|
|
151
152
|
return {path, family, sizes, bpp: fc.bpp ?? 4, glyphs: fc.glyphs ?? 'ascii'};
|
|
152
153
|
});
|
|
153
|
-
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
154
|
+
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
155
|
+
path,
|
|
156
|
+
name,
|
|
157
|
+
format: imageConfig[name]?.format,
|
|
158
|
+
}));
|
|
154
159
|
|
|
155
160
|
const summary = bakeAssets({
|
|
156
161
|
images: imageJobs,
|
package/cli.mjs
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
readFileSync,
|
|
31
31
|
writeFileSync,
|
|
32
32
|
} from 'node:fs';
|
|
33
|
-
import {fileURLToPath} from 'node:url';
|
|
33
|
+
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
34
34
|
import {dirname, relative, resolve} from 'node:path';
|
|
35
35
|
import {tmpdir} from 'node:os';
|
|
36
36
|
import {buildApp, runDevServer} from './sim-server.mjs';
|
|
@@ -383,9 +383,18 @@ async function buildAot(cwd, explicit, outDir, screen) {
|
|
|
383
383
|
writeFileSync(resolve(outDir, 'app.gen.c'), result.c);
|
|
384
384
|
writeFileSync(resolve(outDir, 'app.gen.h'), result.h);
|
|
385
385
|
|
|
386
|
+
// Optional per-image overrides (same file the JS flows read): assets.config.js
|
|
387
|
+
// export default { images: { 'bg': { format: 'rgb565' } } }
|
|
388
|
+
let cfg = {};
|
|
389
|
+
const cp = resolve(cwd, 'assets.config.js');
|
|
390
|
+
if (existsSync(cp))
|
|
391
|
+
cfg = (await import(pathToFileURL(cp).href)).default || {};
|
|
392
|
+
const imageConfig = cfg.images || {};
|
|
393
|
+
|
|
386
394
|
const imageJobs = result.images.map(im => ({
|
|
387
395
|
name: im.name,
|
|
388
396
|
path: resolve(appDir, im.importPath),
|
|
397
|
+
format: imageConfig[im.name]?.format,
|
|
389
398
|
}));
|
|
390
399
|
for (const j of imageJobs) {
|
|
391
400
|
if (!existsSync(j.path)) {
|
package/hotreload/pack-app.mjs
CHANGED
|
@@ -157,6 +157,7 @@ export async function packAppContainer({
|
|
|
157
157
|
if (existsSync(cp))
|
|
158
158
|
cfg = (await import(pathToFileURL(cp).href)).default || {};
|
|
159
159
|
const fontConfig = cfg.fonts || {};
|
|
160
|
+
const imageConfig = cfg.images || {};
|
|
160
161
|
const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
161
162
|
const fc = fontConfig[family] || {};
|
|
162
163
|
return {
|
|
@@ -171,7 +172,11 @@ export async function packAppContainer({
|
|
|
171
172
|
glyphs: fc.glyphs ?? 'ascii',
|
|
172
173
|
};
|
|
173
174
|
});
|
|
174
|
-
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
175
|
+
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
176
|
+
path,
|
|
177
|
+
name,
|
|
178
|
+
format: imageConfig[name]?.format,
|
|
179
|
+
}));
|
|
175
180
|
const bakedImages = imageJobs.map(bakeImage);
|
|
176
181
|
const bakedFonts = fontJobs.map(bakeFont);
|
|
177
182
|
const assetPack =
|
package/hotreload/pack-split.mjs
CHANGED
|
@@ -218,6 +218,7 @@ async function bakeAssets({images, fonts, source, projectRoot}) {
|
|
|
218
218
|
if (existsSync(cp))
|
|
219
219
|
cfg = (await import(pathToFileURL(cp).href)).default || {};
|
|
220
220
|
const fontConfig = cfg.fonts || {};
|
|
221
|
+
const imageConfig = cfg.images || {};
|
|
221
222
|
|
|
222
223
|
const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
223
224
|
const fc = fontConfig[family] || {};
|
|
@@ -233,7 +234,11 @@ async function bakeAssets({images, fonts, source, projectRoot}) {
|
|
|
233
234
|
glyphs: fc.glyphs ?? 'ascii',
|
|
234
235
|
};
|
|
235
236
|
});
|
|
236
|
-
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
237
|
+
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
238
|
+
path,
|
|
239
|
+
name,
|
|
240
|
+
format: imageConfig[name]?.format,
|
|
241
|
+
}));
|
|
237
242
|
const bakedImages = imageJobs.map(bakeImage);
|
|
238
243
|
const bakedFonts = fontJobs.map(bakeFont);
|
|
239
244
|
return bakedImages.length || bakedFonts.length
|
package/pack-container.mjs
CHANGED
|
@@ -183,6 +183,7 @@ const configPath = resolve(demoDir, 'assets.config.js');
|
|
|
183
183
|
if (existsSync(configPath))
|
|
184
184
|
config = (await import(pathToFileURL(configPath).href)).default || {};
|
|
185
185
|
const fontConfig = config.fonts || {};
|
|
186
|
+
const imageConfig = config.images || {};
|
|
186
187
|
|
|
187
188
|
const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
188
189
|
const fc = fontConfig[family] || {};
|
|
@@ -194,7 +195,11 @@ const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
|
194
195
|
: [16];
|
|
195
196
|
return {path, family, sizes, bpp: fc.bpp ?? 4, glyphs: fc.glyphs ?? 'ascii'};
|
|
196
197
|
});
|
|
197
|
-
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
198
|
+
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
199
|
+
path,
|
|
200
|
+
name,
|
|
201
|
+
format: imageConfig[name]?.format,
|
|
202
|
+
}));
|
|
198
203
|
|
|
199
204
|
const bakedImages = imageJobs.map(i => bakeImage(i));
|
|
200
205
|
const bakedFonts = fontJobs.map(f => bakeFont(f));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embedded-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native-style component package + reconciler that drives the embedded-react C engine through the QuickJS NativeUI bridge (Flow A).",
|
|
6
6
|
"license": "Apache-2.0",
|
package/sim/embedded-react.wasm
CHANGED
|
Binary file
|
package/sim-server.mjs
CHANGED
|
@@ -111,6 +111,7 @@ function createBundle({
|
|
|
111
111
|
(await import(`${pathToFileURL(cp).href}?t=${mtime(cp)}`)).default ||
|
|
112
112
|
{};
|
|
113
113
|
const fontConfig = cfg.fonts || {};
|
|
114
|
+
const imageConfig = cfg.images || {};
|
|
114
115
|
|
|
115
116
|
const fontJobs = [...fonts.entries()].map(([family, path]) => {
|
|
116
117
|
const fc = fontConfig[family] || {};
|
|
@@ -131,10 +132,11 @@ function createBundle({
|
|
|
131
132
|
const imageJobs = [...images.entries()].map(([name, path]) => ({
|
|
132
133
|
path,
|
|
133
134
|
name,
|
|
135
|
+
format: imageConfig[name]?.format,
|
|
134
136
|
}));
|
|
135
137
|
|
|
136
138
|
const sig = JSON.stringify({
|
|
137
|
-
i: imageJobs.map(j => [j.name, j.path, mtime(j.path)]).sort(),
|
|
139
|
+
i: imageJobs.map(j => [j.name, j.path, mtime(j.path), j.format]).sort(),
|
|
138
140
|
f: fontJobs
|
|
139
141
|
.map(j => [j.family, j.path, mtime(j.path), j.sizes, j.bpp, j.glyphs])
|
|
140
142
|
.sort(),
|