Conversation
The C runtime could install only the ui surface; native hosts had no way to
expose device services to the guest. Add two optional host op tables:
- PocketAudioOps installs globalThis.audio with the method set the audio spec
already pins (contracts/spec/audio.ts); hosts fill the table before boot and
leave it absent otherwise (the framework player stays a no-op).
- PocketBacklightOps installs globalThis.backlight { get, set(percent) } —
pinned here until a display spec lands.
Both follow the existing ui-module installation shape; no wire changes, no
behavior change for hosts that pass no tables.
This was referenced Sep 12, 2026
Collaborator
|
See #407 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The C runtime (
engine/quickjs-c) could install only theuisurface, so native hosts had no way to expose device services to the guest. Two optional host op tables, filled before boot:globalThis.audiowith the method set the audio spec already pins (contracts/spec/audio.ts: createStream/destroyStream/writePcm/play/pause/stop/setVolume/endStream/poll). Hosts without the table leave the global absent and the framework player stays the silent no-op it is today, so existing targets are byte-identical.globalThis.backlight{get(),set(percent)} — pinned here until a display spec exists.Both follow the existing
install_hostshape.writePcmborrows the guest buffer for the synchronous call, matching the spec's ownership rule; event lines are JSON per the spec.Why
The d211-linux host (PR #407) needs real UI sounds and panel brightness for a product app; without a host-module hook the only alternatives were product logic in the runtime or a second JS engine binding. The same hook unblocks any C host with device audio.
Validation
feat/d211-host-modules).createStream(22050,2)→writePcm→play(aplay child) →creditevent →endStream; brightness 0-100 maps onto/sys/class/backlightand the panel changes.