frameos-wasm 2026.7.3

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 ADDED
@@ -0,0 +1,72 @@
1
+ # frameos-wasm
2
+
3
+ Run [FrameOS](https://frameos.net) scenes in the browser through WebAssembly. The package wraps the
4
+ emscripten-built FrameOS scene runtime with a typed API and ships a minimal management interface:
5
+ a live canvas, scene switching, showIf-aware state fields, event buttons, and logs — the same
6
+ control surface a frame exposes on-device.
7
+
8
+ The package version always equals the FrameOS release the runtime was built from.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install frameos-wasm
14
+ ```
15
+
16
+ The runtime assets (`frameos.js`, `frameos.wasm`, `preview-worker.js`) live in
17
+ `frameos-wasm/dist/assets/`. They must be served **same-origin** (the runtime runs in a module Web
18
+ Worker and uses synchronous XHR): copy that directory into your static assets, e.g. to
19
+ `/frameos-wasm/`.
20
+
21
+ ## Quick start — management interface
22
+
23
+ ```ts
24
+ import { mountFrameOSManager } from 'frameos-wasm'
25
+
26
+ const handle = mountFrameOSManager(document.getElementById('preview')!, {
27
+ workerUrl: '/frameos-wasm/preview-worker.js',
28
+ width: 800,
29
+ height: 480,
30
+ scenes, // parsed scenes.json (from a template zip, backup, or export)
31
+ })
32
+ // later: handle.preview.sendEvent('myButton'), handle.destroy()
33
+ ```
34
+
35
+ ## Lower level — just the runtime
36
+
37
+ ```ts
38
+ import { createFrameOSPreview } from 'frameos-wasm'
39
+
40
+ const preview = createFrameOSPreview({
41
+ workerUrl: '/frameos-wasm/preview-worker.js',
42
+ width: 800,
43
+ height: 480,
44
+ scenes,
45
+ canvas: document.querySelector('canvas'),
46
+ onLog: (line) => console.log(line),
47
+ onState: (state) => console.log('scene state', state),
48
+ })
49
+ preview.setSceneState({ message: 'Hello' })
50
+ preview.sendEvent('button', { label: 'a' })
51
+ preview.selectScene('sceneId')
52
+ preview.destroy()
53
+ ```
54
+
55
+ Helpers for building your own UI are exported too: `evaluateShowIf`, `visiblePublicStateFields`,
56
+ `coerceStateFieldValue`, `sceneEventButtons`, and the `StateField`/`FrameOSScene` types.
57
+
58
+ ## Notes
59
+
60
+ - Scenes that fetch external URLs are subject to browser CORS unless you pass `proxyUrl` (a
61
+ same-origin endpoint that forwards `{method, url, headers, bodyBase64, timeoutMs}` — see
62
+ FrameOS's `/api/frames/{id}/scene_preview_proxy`).
63
+ - Apps that need host processes are not in the wasm build: `data/chromiumScreenshot`,
64
+ `data/rstpSnapshot`, `data/localImage`.
65
+ - `index.html` in the package root is a standalone demo page:
66
+ `npx serve node_modules/frameos-wasm` and paste a scenes.json.
67
+
68
+ ## Development (FrameOS repo)
69
+
70
+ The runtime assets are built by `frameos/tools/build_wasm.sh` into `frontend/public/frameos-wasm`
71
+ and copied into `dist/assets` by `npm run build`. `npm run sync-version` copies the FrameOS
72
+ version out of the repo's `versions.json`; publishing refuses to run when the two disagree.