frameos-wasm 2026.10.13 → 2026.10.16

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 CHANGED
@@ -47,11 +47,23 @@ const preview = createFrameOSPreview({
47
47
  onState: (state) => console.log('scene state', state),
48
48
  })
49
49
  preview.setSceneState({ message: 'Hello' })
50
- preview.sendEvent('button', { label: 'a' })
50
+ preview.sendEvent('nextPage')
51
+ preview.buttonDown('A') // ...and preview.buttonUp('A') when it is let go
51
52
  preview.selectScene('sceneId')
52
53
  preview.destroy()
53
54
  ```
54
55
 
56
+ ### Buttons
57
+
58
+ `preview.buttonDown(label)` and `preview.buttonUp(label)` hold a button the way a frame's
59
+ GPIO key is held: the scene gets the `gpio` edges, `down` the moment it is pressed and `up`
60
+ (with `durationMs`) when it is let go, and the runtime makes the `button` `press`,
61
+ `doublePress` or `longPress` those edges add up to, timed as on a frame. A preview button has
62
+ no pin; the label tells keys apart. Call them from `pointerdown` and `pointerup` (capture the
63
+ pointer so a release off the button still counts). A runtime bundle from before `gpio`
64
+ (`preview.runtimeInfo.gpioEvents === false`) gets one `button` per press, on the release.
65
+ `mountFrameOSManager` holds its `button` event buttons this way.
66
+
55
67
  ### Pointer input
56
68
 
57
69
  ```ts
@@ -4334,6 +4334,12 @@ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
4334
4334
  return last === 'localhost' || last === 'local' || last === 'internal' || last === 'lan' || lastTwo === 'home.arpa'
4335
4335
  }
4336
4336
 
4337
+ function frameosLogUrl(url) {
4338
+ var m = /^([a-z][a-z0-9+.-]*:\/\/)(?:[^\/?#\\]*@)?(\[[0-9a-f:.]+\]|[\w.~%\u0080-\uffff-]+)(:\d{0,5})?(?=[\/?#\\]|$)/i.exec(String(url || '').trim())
4339
+ if (!m) return '(invalid URL)'
4340
+ return (m[1] + m[2]).toLowerCase() + (m[3] && m[3].length > 1 ? m[3] : '')
4341
+ }
4342
+
4337
4343
  function _fos_nim_http_request(
4338
4344
  methodPtr,
4339
4345
  urlPtr,
@@ -4402,6 +4408,24 @@ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
4402
4408
  }
4403
4409
  }
4404
4410
 
4411
+ // A cloud frame's local network access (docs/lan-access.md), when the
4412
+ // host page says what it is (`frameosLanAccess: false`): a preview of a
4413
+ // cloud frame with it off refuses a private host the way the frame
4414
+ // would, neither direct nor through the proxy, and in the frame's words —
4415
+ // the SPA's logs panel matches the start of them to link to the setting.
4416
+ // A same-origin target keeps its own path (the proxy only, above).
4417
+ if (Module['frameosLanAccess'] === false && refusedDirect !== 'same-origin') {
4418
+ var lanTarget = null
4419
+ try {
4420
+ lanTarget = inBrowser ? new URL(url, self.location.href) : new URL(url)
4421
+ } catch (e) {}
4422
+ if (lanTarget && (lanTarget.protocol === 'http:' || lanTarget.protocol === 'https:') &&
4423
+ frameosIsPrivateHost(lanTarget.hostname)) {
4424
+ throw new Error('Local network access is off for this frame, so ' + lanTarget.hostname +
4425
+ ' cannot be reached. Turn on local network access in the frame settings.')
4426
+ }
4427
+ }
4428
+
4405
4429
  // Synchronous XHR: the Nim/pixie pipeline is fully synchronous and this
4406
4430
  // module runs in a Web Worker, where sync XHR is permitted.
4407
4431
  var directRequest = function () {
@@ -4470,7 +4494,7 @@ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
4470
4494
  }
4471
4495
  if (maxBytes > 0 && bytes.length > maxBytes) {
4472
4496
  if (Module['onFrameosLog']) {
4473
- Module['onFrameosLog']('http: response for ' + url + ' exceeded ' + maxBytes + ' bytes')
4497
+ Module['onFrameosLog']('http: response for ' + frameosLogUrl(url) + ' exceeded ' + maxBytes + ' bytes')
4474
4498
  }
4475
4499
  return 0
4476
4500
  }
@@ -4482,7 +4506,10 @@ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
4482
4506
  return ptr
4483
4507
  } catch (e) {
4484
4508
  if (Module['onFrameosLog']) {
4485
- Module['onFrameosLog']('http: ' + method + ' ' + url + ' failed: ' + e)
4509
+ // A browser's network error can quote the URL it failed on, too.
4510
+ var origin = frameosLogUrl(url)
4511
+ var reason = url ? String(e).split(url).join(origin) : String(e)
4512
+ Module['onFrameosLog']('http: ' + method + ' ' + origin + ' failed: ' + reason)
4486
4513
  }
4487
4514
  return 0
4488
4515
  }
@@ -4704,6 +4731,7 @@ var _free,
4704
4731
  _frameos_wasm_scene_info,
4705
4732
  _frameos_wasm_scene_state,
4706
4733
  _frameos_wasm_last_error,
4734
+ _frameos_wasm_run_app_tests,
4707
4735
  _frameos_wasm_version,
4708
4736
  _main,
4709
4737
  _frameos_wasm_set_memory_limit,
@@ -4748,6 +4776,7 @@ function assignWasmExports(wasmExports) {
4748
4776
  _frameos_wasm_scene_info = Module['_frameos_wasm_scene_info'] = wasmExports['frameos_wasm_scene_info'];
4749
4777
  _frameos_wasm_scene_state = Module['_frameos_wasm_scene_state'] = wasmExports['frameos_wasm_scene_state'];
4750
4778
  _frameos_wasm_last_error = Module['_frameos_wasm_last_error'] = wasmExports['frameos_wasm_last_error'];
4779
+ _frameos_wasm_run_app_tests = Module['_frameos_wasm_run_app_tests'] = wasmExports['frameos_wasm_run_app_tests'];
4751
4780
  _frameos_wasm_version = Module['_frameos_wasm_version'] = wasmExports['frameos_wasm_version'];
4752
4781
  _main = Module['_main'] = wasmExports['main'];
4753
4782
  _frameos_wasm_set_memory_limit = Module['_frameos_wasm_set_memory_limit'] = wasmExports['frameos_wasm_set_memory_limit'];
Binary file
@@ -7,7 +7,9 @@
7
7
  //
8
8
  // Messages in:
9
9
  // {type: 'init', width, height, timeZone, scenesJson, sceneId, settingsJson, proxyUrl,
10
- // fastMode?, saveAssets?, browserAssets?}
10
+ // fastMode?, saveAssets?, browserAssets?, lanAccess?}
11
+ // lanAccess: the previewed cloud frame's local network access (docs/lan-access.md); `false` makes the
12
+ // runtime refuse private hosts the way that frame would. Absent = nothing to copy, nothing refused.
11
13
  // {type: 'render'} force a render now
12
14
  // {type: 'event', name, payload} dispatch a scene event. Pointer input is three of them, shaped the way
13
15
  // frameos/src/drivers/evdev sends it on a frame: 'mouseMove' {x, y} with
@@ -19,10 +21,12 @@
19
21
  // {type: 'setFastMode', enabled} lift (or restore) the 1 fps throttle
20
22
  // {type: 'assets', requestId, op, ...} browser asset folder ops, see handleAssetsRequest
21
23
  // Messages out:
22
- // {type: 'ready', sceneInfo, browserAssets, runtimeVersion, pointerEvents}
24
+ // {type: 'ready', sceneInfo, browserAssets, runtimeVersion, pointerEvents, inputEvents, gpioEvents}
23
25
  // runtimeVersion: FrameOS version of the bundle (null on older bundles)
24
26
  // pointerEvents: true when this bundle takes pointer input as described above. A bundle without it would hand
25
27
  // the scene raw 0..32767 coordinates and render on every move, so a page must not forward pointers to it.
28
+ // gpioEvents: true when a held button is sent as its `gpio` edges, `down` and `up`. A bundle without it
29
+ // gets one `button` for the whole press.
26
30
  // {type: 'frame', width, height, buffer, renderMs} buffer: transferred ArrayBuffer (RGBA)
27
31
  // {type: 'state', state}
28
32
  // {type: 'log', message}
@@ -742,6 +746,9 @@ async function init(msg) {
742
746
  if (msg.proxyUrl) {
743
747
  Module['frameosProxyUrl'] = msg.proxyUrl
744
748
  }
749
+ if (msg.lanAccess === false) {
750
+ Module['frameosLanAccess'] = false
751
+ }
745
752
 
746
753
  await mountBrowserAssets(msg.browserAssets)
747
754
 
@@ -792,6 +799,10 @@ async function init(msg) {
792
799
  // Input v2 (2026.9.23): pointer events with a position, the wheel, the
793
800
  // keyboard, and the runtime's own gestures and long presses.
794
801
  inputEvents: typeof Module._frameos_wasm_tick === 'function',
802
+ // Buttons as two events (2026.10.16): a `gpio` with `level` and
803
+ // `action: 'down'` / `'up'` is an edge the runtime holds and times into
804
+ // a `button` press, doublePress or longPress, each key by its pin and label.
805
+ gpioEvents: true,
795
806
  })
796
807
  renderNow()
797
808
  } catch (e) {
@@ -834,8 +845,10 @@ function flushPendingMoves() {
834
845
  pendingMoves.clear()
835
846
  }
836
847
 
837
- // While a pointer is held, the runtime is ticked so a long press is delivered
838
- // while the finger is still down, as on a frame (frameos_wasm_tick).
848
+ // While a pointer or a GPIO button is held, or a button press waits out its
849
+ // double-press window, the runtime is ticked so a long press is delivered while
850
+ // the finger is still down and the press once the window closes, as on a frame
851
+ // (frameos_wasm_tick; frameos_wasm_pointers_down counts all three).
839
852
  let tickTimer = null
840
853
 
841
854
  function tickWhileHeld() {
@@ -868,9 +881,9 @@ function handleEvent(name, payload) {
868
881
  }
869
882
  flushPendingMoves()
870
883
  dispatchEvent(name, payload)
871
- if ((name === 'pointerDown' || name === 'mouseDown') && tickTimer === null && Module &&
884
+ if ((name === 'pointerDown' || name === 'mouseDown' || name === 'button') && tickTimer === null && Module &&
872
885
  typeof Module._frameos_wasm_tick === 'function') {
873
- tickTimer = setInterval(tickWhileHeld, 100)
886
+ tickTimer = setInterval(tickWhileHeld, 50)
874
887
  }
875
888
  }
876
889
 
@@ -906,7 +919,40 @@ self.onmessage = (ev) => {
906
919
  case 'assets':
907
920
  void handleAssetsRequest(msg)
908
921
  break
922
+ case 'runAppTests':
923
+ handleRunAppTests(msg)
924
+ break
909
925
  default:
910
926
  break
911
927
  }
912
928
  }
929
+
930
+ // {type: 'runAppTests', requestId, appJson, testFile} -> {type: 'appTestsResult',
931
+ // requestId, ok, report | error}: one test file of a JavaScript app, run in
932
+ // this runtime's interpreter (src/frameos/js_runtime/app_tests.nim). Needs the
933
+ // init that loaded the scenes; the tests see the frame it was given.
934
+ function handleRunAppTests(msg) {
935
+ const requestId = msg.requestId
936
+ if (!Module) {
937
+ post({ type: 'appTestsResult', requestId, ok: false, error: 'the preview runtime is not running' })
938
+ return
939
+ }
940
+ if (typeof Module._frameos_wasm_run_app_tests !== 'function') {
941
+ post({
942
+ type: 'appTestsResult',
943
+ requestId,
944
+ ok: false,
945
+ error: 'This FrameOS runtime bundle cannot run app tests; it needs FrameOS 2026.10.16 or newer.',
946
+ })
947
+ return
948
+ }
949
+ try {
950
+ const text = call('frameos_wasm_run_app_tests', 'string', ['string', 'string'], [
951
+ String(msg.appJson || '{}'),
952
+ String(msg.testFile || ''),
953
+ ])
954
+ post({ type: 'appTestsResult', requestId, ok: true, report: JSON.parse(text) })
955
+ } catch (e) {
956
+ post({ type: 'appTestsResult', requestId, ok: false, error: String(e && e.message ? e.message : e) })
957
+ }
958
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "2026.10.13",
3
- "release": "2026.10.13",
4
- "commit": "b0966e4d0d93df22317c4504d4ada91718581e55",
5
- "built_at": "2026-10-14T18:08:33Z"
2
+ "version": "2026.10.16",
3
+ "release": "2026.10.16",
4
+ "commit": "3a67e2012d4bd8de2e9faa04a9e307a7dc95983c",
5
+ "built_at": "2026-10-18T12:58:31Z"
6
6
  }
package/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export { selectFieldOptions } from './options';
6
6
  export { POINTER_AXIS_MAX, attachKeyboardInput, attachPointerInput, keyPayload, keyText, pointerAxis, pointerButton, pointerButtonsMask, pointerIdOf, pointerMovePayload, pointerPictureRect, pointerTypeOf, wheelNotches, type AttachPointerOptions, type PointerEventSink, type PointerRect, } from './pointer';
7
7
  export { REFRESH_INTERVAL_FIELD_NAME, REFRESH_INTERVAL_LABEL, REFRESH_INTERVAL_ROLE, parseRefreshSeconds, refreshIntervalFieldIndex, sceneStateFields, } from './refreshInterval';
8
8
  export { coerceStateFieldValue, evaluateShowIf, stateFieldShowIfValues, visiblePublicStateFields } from './showIf';
9
- export { KEYBOARD_EVENTS, LIFECYCLE_EVENTS, POINTER_EVENTS, sceneEventButtons, type ConfigFieldCondition, type ConfigFieldConditionAnd, type FrameOSScene, type PreviewAssetEntry, type PreviewAssetsInfo, type PreviewFrame, type PreviewRuntimeInfo, type SceneEventButton, type SceneInfo, type SceneNode, type SelectFieldOption, type ShowIfCondition, type StateField, } from './types';
9
+ export { KEYBOARD_EVENTS, LIFECYCLE_EVENTS, POINTER_EVENTS, sceneEventButtons, type ConfigFieldCondition, type ConfigFieldConditionAnd, type FrameOSScene, type PreviewAssetEntry, type PreviewAssetsInfo, type PreviewFrame, type PreviewRuntimeInfo, type SceneEventButton, type SceneInfo, type SceneNode, type SelectFieldOption, type ShowIfCondition, type StateField, type AppTestError, type AppTestLogLine, type AppTestReport, type AppTestResult, type AppTestSuiteResult, } from './types';
package/dist/manager.js CHANGED
@@ -160,13 +160,19 @@ export function mountFrameOSManager(container, options) {
160
160
  // Custom event nodes as buttons. Listener nodes filter on payload values
161
161
  // (a "button" listener with label "A" only fires for {label: "A"} — see
162
162
  // eventNodeMatchesPayload in frameos' interpreter.nim), so the label must
163
- // ride along in the payload, not just caption the button.
163
+ // ride along in the payload, not just caption the button. A "button" is
164
+ // held like the frame's key; any other event is sent on the click.
164
165
  for (const event of sceneEventButtons(scene)) {
165
166
  const button = document.createElement('button');
166
167
  button.type = 'button';
167
168
  button.className = 'frameos-manager__button';
168
169
  button.textContent = event.label || event.keyword;
169
- button.onclick = () => preview.sendEvent(event.keyword, event.label ? { label: event.label } : {});
170
+ if (event.keyword === 'button') {
171
+ holdLikeAKey(button, preview, event.label);
172
+ }
173
+ else {
174
+ button.onclick = () => preview.sendEvent(event.keyword, event.label ? { label: event.label } : {});
175
+ }
170
176
  buttonRow.appendChild(button);
171
177
  }
172
178
  const render = document.createElement('button');
@@ -294,6 +300,37 @@ function isValidJson(text) {
294
300
  return false;
295
301
  }
296
302
  }
303
+ /** Down while the pointer (or Space / Enter) presses `button`, up when it lets
304
+ * go (FrameOSPreview.buttonDown). The release is listened for on the window:
305
+ * the controls are rebuilt when the scene's state changes, which a press can
306
+ * do while the key is still down. */
307
+ function holdLikeAKey(button, preview, label) {
308
+ const press = (endEvents) => {
309
+ preview.buttonDown(label);
310
+ const release = () => {
311
+ for (const type of endEvents) {
312
+ window.removeEventListener(type, release);
313
+ }
314
+ preview.buttonUp(label);
315
+ };
316
+ for (const type of endEvents) {
317
+ window.addEventListener(type, release);
318
+ }
319
+ };
320
+ button.addEventListener('pointerdown', (event) => {
321
+ if (event.button === 0) {
322
+ press(['pointerup', 'pointercancel']);
323
+ }
324
+ });
325
+ button.addEventListener('keydown', (event) => {
326
+ if (event.key === ' ' || event.key === 'Enter') {
327
+ event.preventDefault();
328
+ if (!event.repeat) {
329
+ press(['keyup', 'blur']);
330
+ }
331
+ }
332
+ });
333
+ }
297
334
  function el(tag, className, text) {
298
335
  const node = document.createElement(tag);
299
336
  node.className = className;
package/dist/preview.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { DeviceLimits } from './devices';
2
2
  import { type PanelPaletteKey } from './dither';
3
- import type { FrameOSScene, PreviewAssetEntry, PreviewAssetsInfo, PreviewFrame, PreviewRuntimeInfo, SceneInfo } from './types';
3
+ import type { FrameOSScene, PreviewAssetEntry, PreviewAssetsInfo, PreviewFrame, PreviewRuntimeInfo, SceneInfo, AppTestReport } from './types';
4
4
  /** What a render cost under a simulated device ceiling. */
5
5
  export interface DeviceMemoryUsage {
6
6
  limitBytes: number;
@@ -85,6 +85,10 @@ export declare class FrameOSPreview {
85
85
  private destroyed;
86
86
  private assetRequests;
87
87
  private nextAssetRequestId;
88
+ private appTestsRequests;
89
+ private nextAppTestsRequestId;
90
+ /** Labels of the buttons `buttonDown` pressed and `buttonUp` has not let go of. */
91
+ private heldButtons;
88
92
  /** Latest scene info from the runtime (set once `ready` fires). */
89
93
  sceneInfo: SceneInfo | null;
90
94
  /** How the runtime's /srv/assets is backed (set once `ready` fires). */
@@ -116,6 +120,19 @@ export declare class FrameOSPreview {
116
120
  render(): void;
117
121
  /** Dispatch a scene event (a custom event node's keyword, "button", ...). */
118
122
  sendEvent(name: string, payload?: Record<string, unknown>): void;
123
+ /**
124
+ * A button held like a frame's key: call `buttonDown` when the pointer (or
125
+ * the keyboard) presses it and `buttonUp` when it lets go, and the scene
126
+ * gets the `gpio` edges as they happen, `down` and `up` (level 0 is down:
127
+ * the line is pulled up). The runtime adds the role and the `up`'s
128
+ * `durationMs`, and makes the `button` `press`, `doublePress` or
129
+ * `longPress` the edges add up to. A preview button has no pin; the label
130
+ * tells keys apart. A bundle from before `gpio` (`runtimeInfo.gpioEvents`)
131
+ * gets one `button` for the whole press, on the release.
132
+ */
133
+ buttonDown(label: string | null): void;
134
+ /** The release of a key `buttonDown` pressed; nothing for one it did not. */
135
+ buttonUp(label: string | null): void;
119
136
  /**
120
137
  * Pass the pointer and the wheel over `canvas` on to the scene as
121
138
  * `pointerMove` / `pointerDown` / `pointerUp` / `pointerCancel` / `wheel`,
@@ -141,6 +158,15 @@ export declare class FrameOSPreview {
141
158
  /** Let the scene render as often as it asks (true), or throttle it back
142
159
  * to one render per second (false). */
143
160
  setFastMode(enabled: boolean): void;
161
+ /**
162
+ * Run one test file of a JavaScript app (`<name>.test.ts` among its
163
+ * sources) in this runtime's interpreter, with the frame this preview was
164
+ * given, and resolve with the harness's report. Rejects when the file does
165
+ * not load or the bundle predates app tests (FrameOS 2026.10.16).
166
+ */
167
+ runAppTests(app: {
168
+ sources: Record<string, string>;
169
+ }, testFile: string): Promise<AppTestReport>;
144
170
  private assetRequest;
145
171
  /** Every file and folder in the browser asset folder (/srv/assets). */
146
172
  listAssets(): Promise<PreviewAssetEntry[]>;
package/dist/preview.js CHANGED
@@ -12,6 +12,11 @@ function panelColors(panel) {
12
12
  }
13
13
  return panel.colors;
14
14
  }
15
+ /** A preview button's payload: its label, when it has one. Listener nodes
16
+ * filter on it (a "button" listener with label "A" only hears `{label: "A"}`). */
17
+ function buttonLabel(label) {
18
+ return label ? { label } : {};
19
+ }
15
20
  export class FrameOSPreview {
16
21
  constructor(options) {
17
22
  this.worker = null;
@@ -20,12 +25,16 @@ export class FrameOSPreview {
20
25
  this.destroyed = false;
21
26
  this.assetRequests = new Map();
22
27
  this.nextAssetRequestId = 1;
28
+ this.appTestsRequests = new Map();
29
+ this.nextAppTestsRequestId = 1;
30
+ /** Labels of the buttons `buttonDown` pressed and `buttonUp` has not let go of. */
31
+ this.heldButtons = new Set();
23
32
  /** Latest scene info from the runtime (set once `ready` fires). */
24
33
  this.sceneInfo = null;
25
34
  /** How the runtime's /srv/assets is backed (set once `ready` fires). */
26
35
  this.assetsInfo = null;
27
36
  /** Which FrameOS version the runtime is (set once `ready` fires). */
28
- this.runtimeInfo = { version: null, pointerEvents: false, inputEvents: false };
37
+ this.runtimeInfo = { version: null, pointerEvents: false, inputEvents: false, gpioEvents: false };
29
38
  /** Latest public state of the current scene. */
30
39
  this.state = {};
31
40
  /** The scene currently selected in the runtime. */
@@ -72,6 +81,7 @@ export class FrameOSPreview {
72
81
  version: typeof msg.runtimeVersion === 'string' ? msg.runtimeVersion : null,
73
82
  pointerEvents: msg.pointerEvents === true,
74
83
  inputEvents: msg.inputEvents === true,
84
+ gpioEvents: msg.gpioEvents === true,
75
85
  };
76
86
  this.options.onReady?.(msg.sceneInfo, this.assetsInfo, this.runtimeInfo);
77
87
  break;
@@ -114,6 +124,19 @@ export class FrameOSPreview {
114
124
  case 'assetsChanged':
115
125
  this.options.onAssetsChanged?.();
116
126
  break;
127
+ case 'appTestsResult': {
128
+ const pending = this.appTestsRequests.get(msg.requestId);
129
+ if (pending) {
130
+ this.appTestsRequests.delete(msg.requestId);
131
+ if (msg.ok) {
132
+ pending.resolve(msg.report);
133
+ }
134
+ else {
135
+ pending.reject(new Error(String(msg.error ?? 'could not run the app tests')));
136
+ }
137
+ }
138
+ break;
139
+ }
117
140
  case 'assetsResult': {
118
141
  const pending = this.assetRequests.get(msg.requestId);
119
142
  if (!pending) {
@@ -184,6 +207,39 @@ export class FrameOSPreview {
184
207
  sendEvent(name, payload = {}) {
185
208
  this.worker?.postMessage({ type: 'event', name, payload });
186
209
  }
210
+ /**
211
+ * A button held like a frame's key: call `buttonDown` when the pointer (or
212
+ * the keyboard) presses it and `buttonUp` when it lets go, and the scene
213
+ * gets the `gpio` edges as they happen, `down` and `up` (level 0 is down:
214
+ * the line is pulled up). The runtime adds the role and the `up`'s
215
+ * `durationMs`, and makes the `button` `press`, `doublePress` or
216
+ * `longPress` the edges add up to. A preview button has no pin; the label
217
+ * tells keys apart. A bundle from before `gpio` (`runtimeInfo.gpioEvents`)
218
+ * gets one `button` for the whole press, on the release.
219
+ */
220
+ buttonDown(label) {
221
+ const key = label ?? '';
222
+ if (this.heldButtons.has(key)) {
223
+ return;
224
+ }
225
+ this.heldButtons.add(key);
226
+ if (this.runtimeInfo.gpioEvents) {
227
+ this.sendEvent('gpio', { ...buttonLabel(label), level: 0, action: 'down' });
228
+ }
229
+ }
230
+ /** The release of a key `buttonDown` pressed; nothing for one it did not. */
231
+ buttonUp(label) {
232
+ if (!this.heldButtons.delete(label ?? '')) {
233
+ return;
234
+ }
235
+ const payload = buttonLabel(label);
236
+ if (this.runtimeInfo.gpioEvents) {
237
+ this.sendEvent('gpio', { ...payload, level: 1, action: 'up' });
238
+ }
239
+ else {
240
+ this.sendEvent('button', payload);
241
+ }
242
+ }
187
243
  /**
188
244
  * Pass the pointer and the wheel over `canvas` on to the scene as
189
245
  * `pointerMove` / `pointerDown` / `pointerUp` / `pointerCancel` / `wheel`,
@@ -226,6 +282,28 @@ export class FrameOSPreview {
226
282
  this.fastMode = enabled;
227
283
  this.worker?.postMessage({ type: 'setFastMode', enabled });
228
284
  }
285
+ /**
286
+ * Run one test file of a JavaScript app (`<name>.test.ts` among its
287
+ * sources) in this runtime's interpreter, with the frame this preview was
288
+ * given, and resolve with the harness's report. Rejects when the file does
289
+ * not load or the bundle predates app tests (FrameOS 2026.10.16).
290
+ */
291
+ runAppTests(app, testFile) {
292
+ return new Promise((resolve, reject) => {
293
+ if (!this.worker || this.destroyed) {
294
+ reject(new Error('preview is not running'));
295
+ return;
296
+ }
297
+ const requestId = this.nextAppTestsRequestId++;
298
+ this.appTestsRequests.set(requestId, { resolve, reject });
299
+ this.worker.postMessage({
300
+ type: 'runAppTests',
301
+ requestId,
302
+ appJson: JSON.stringify({ sources: app.sources }),
303
+ testFile,
304
+ });
305
+ });
306
+ }
229
307
  assetRequest(op, params = {}, transfer = []) {
230
308
  return new Promise((resolve, reject) => {
231
309
  if (!this.worker || this.destroyed) {
package/dist/types.d.ts CHANGED
@@ -97,6 +97,12 @@ export interface PreviewRuntimeInfo {
97
97
  * (see ./pointer). False sends the older bundle the old mouse events and
98
98
  * no keys. */
99
99
  inputEvents: boolean;
100
+ /** Whether the bundle takes a button's edges as `gpio` (2026.10.16): `down`
101
+ * when it is pressed, `up` when it is let go, from which the runtime makes
102
+ * the `button` `press`, `doublePress` or `longPress` (see
103
+ * `FrameOSPreview.buttonDown`). False sends the older bundle one `button`
104
+ * per press, on the release. */
105
+ gpioEvents: boolean;
100
106
  }
101
107
  /** How the runtime's /srv/assets is backed, sent with the worker's `ready` message. */
102
108
  export interface PreviewAssetsInfo {
@@ -128,3 +134,48 @@ export declare const POINTER_EVENTS: Set<string>;
128
134
  export declare const KEYBOARD_EVENTS: Set<string>;
129
135
  /** The custom event nodes of a scene, deduplicated — render these as buttons. */
130
136
  export declare function sceneEventButtons(scene: FrameOSScene | undefined | null): SceneEventButton[];
137
+ /** One line a test (or the app under it) logged: `frameos.log`, `console.*`. */
138
+ export interface AppTestLogLine {
139
+ level: 'log' | 'warn' | 'error';
140
+ text: string;
141
+ }
142
+ export interface AppTestError {
143
+ message: string;
144
+ stack: string;
145
+ expected?: string;
146
+ received?: string;
147
+ }
148
+ export interface AppTestResult {
149
+ kind: 'test';
150
+ name: string;
151
+ status: 'passed' | 'failed' | 'skipped';
152
+ durationMs: number;
153
+ logs: AppTestLogLine[];
154
+ error?: AppTestError;
155
+ }
156
+ export interface AppTestSuiteResult {
157
+ kind: 'suite';
158
+ name: string;
159
+ status: 'passed' | 'failed' | 'skipped';
160
+ children: (AppTestResult | AppTestSuiteResult)[];
161
+ error?: AppTestError;
162
+ }
163
+ /**
164
+ * The report of one app test file, as the runtime's harness builds it
165
+ * (src/frameos/js_runtime/app_test_harness.js). `error` is set, and the
166
+ * tree empty, when the file itself did not load.
167
+ */
168
+ export interface AppTestReport {
169
+ ok: boolean;
170
+ file?: string;
171
+ error?: string;
172
+ counts: {
173
+ passed: number;
174
+ failed: number;
175
+ skipped: number;
176
+ total: number;
177
+ };
178
+ durationMs: number;
179
+ children: (AppTestResult | AppTestSuiteResult)[];
180
+ logs: AppTestLogLine[];
181
+ }
package/dist/types.js CHANGED
@@ -25,7 +25,9 @@ export function sceneEventButtons(scene) {
25
25
  continue;
26
26
  }
27
27
  const data = (node.data ?? {});
28
- const keyword = String(data.keyword ?? '');
28
+ // A `gpio` listener is pressed with the same button as a `button` one: the
29
+ // preview holds it and sends the edges (FrameOSPreview.buttonDown).
30
+ const keyword = data.keyword === 'gpio' ? 'button' : String(data.keyword ?? '');
29
31
  if (!keyword || LIFECYCLE_EVENTS.has(keyword) || POINTER_EVENTS.has(keyword) || KEYBOARD_EVENTS.has(keyword)) {
30
32
  continue;
31
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frameos-wasm",
3
- "version": "2026.10.13",
3
+ "version": "2026.10.16",
4
4
  "description": "Run FrameOS scenes in the browser via WebAssembly: a typed live-preview runtime plus a minimal showIf-aware management interface.",
5
5
  "keywords": [
6
6
  "frameos",