Repository navigation
Development
The project is one SolidJS codebase on SolidTV, whose renderer is a fork of LightningJS, shared across every platform while keeping platform-specific code isolated. Every screen draws into one WebGL canvas, with the video playing underneath it.
moonfin/
├── src/
│ ├── index.jsx # Boot: polyfills, strings, storage, the renderer and fonts, then the app
│ ├── App.jsx # The shell: router, page stack, nav and overlays
│ ├── routes.js # Every route
│ ├── app/ # Navigation, the page stack, focus and the key map
│ ├── pages/ # Screens, one folder per area
│ ├── ui/ # Theme, text and fonts, and the components under ui/components/
│ ├── state/ # Stores on signals: settings, auth, session, home rows, Watch Party...
│ ├── services/ # API and service modules
│ ├── utils/ # Helpers
│ ├── theme/ # Theme registry and theme specs
│ └── platform/ # tizen/, webos/, vega/ and xbox/: video, storage, keys and device profiles
├── public/ # Fonts and their atlases, icons, images, workers, and translations under resources/
├── packaging/ # webOS appinfo.json and Tizen config.xml, icons, and each TV's service
├── scripts/ # Packaging, the boot page, renderer patches, fonts, icons, checks, in-app updates (ota/)
├── vega/ # Vega build script and the React Native shell -> .vpkg
├── xbox/ # Xbox build script, the UWP host, the device probe and the console helper -> .msix
├── tools/ # cdp.mjs and samsung.sh, for driving and inspecting the app on a TV
├── vite.config.js # The modern and ES5 builds
└── package.json
Shared code in src/ never touches tizen.*, webapis.* or the webOS Luna bus directly. Platform-specific behavior is reached through runtime detection instead:
import { isTizen, isWebOS, isVega, isXbox, getPlatform } from './platform';Services such as video, storage, and device profiles ask services/platformModule.js for their implementation, which dynamically imports it from src/platform/tizen/, webos/, vega/ or xbox/ for the platform getPlatform() reports. Anything that touches a native API belongs in one of those folders, not in the shared code.
- SolidTV builds the interface: SolidJS components that the renderer draws into one WebGL canvas, with no DOM and no CSS. Its focus manager sends each key to the focused element and then up through its parents, each list owns its own arrows and Enter, and Vite builds the modern and ES5 bundles.
-
Plex servers go through
services/plexApi.js, which answers the same library, playback and Live TV calls the app makes to Jellyfin, withservices/plexMapper.jsturning Plex's answers into the item shapes the screens read.services/plexTv.jshandles the plex.tv sign in, Plex Home users and picking the best address for a server. -
Silo servers go through
services/siloApi.js, which answers the same methods the app calls on Jellyfin over Silo's native/api/v2, withservices/siloMapper.jsturning Silo's answers into Jellyfin's shapes andservices/siloSeerr.jsanswering the Seerr screens from Silo's own requests.services/moonbaseEndpoint.jsworks out where a server's Moonbase lives: the server itself on Jellyfin and Emby, the plugin in Silo, or Moonbase for Plex beside a Plex server. -
Tizen uses the AVPlay API for video and
tizen.tvinputdevicefor remote keys. -
webOS uses a shared HTML5 video element with the
audioTracksAPI, and Luna service calls for storage. -
Vega (Fire TV) runs the app inside the Vega WebView (Chromium 144), hosted by a small React Native shell in
vega/shell/. The shell writes what it knows about the device intowindow.__MOONFIN_VEGA__before page code runs, forwards app state and keys asmoonfin:vegaevents, and the page talks back throughwindow.ReactNativeWebView.postMessage(seesrc/platform/vega/bridge.js). The WebView plays H.264, HEVC, VP9 and native HLS through the webOS player code, with no AV1, Dolby or DTS decoding, so those tracks are transcoded by the server. The page lives atfile:///pkg/assets, whose null origin can't fetch a sibling file or start a Worker from one, so the build packs every image, JSON file and font intovega-files/*.jsthatvega/inject/package-files.jsanswers XHR and fetch from, andvega/inject/worker-shim.jsstarts the subtitle workers from blobs. A backgrounded app may keep no more than 150 MB and loses the decoder, so the player ends the session and leaves to the details page when the app goes to the background, and the shell can send the stop report itself from the session the page shares with it on every progress tick. The stick rasters on its GPU, so it keeps thehighperformance tier and draws at full resolution, and the whole app sits around 250 MB against Amazon's 420 MB foreground cap. A--debugbuild exposes Chrome DevTools on port 9229 (vega exec vda forward tcp:9229 tcp:9229). -
Xbox runs the app in a WebView2 hosted by a small UWP app in
xbox/shell/, served from the package athttp://moonfin.internal. The host writes what it knows about the console intowindow.__MOONFIN_XBOX__before page code runs, forwards app state, network changes and the media remote asmoonfin:xboxevents, and the page talks back throughwindow.chrome.webview.postMessage(seesrc/platform/xbox/bridge.js). The controller arrives as the gamepad's own key codes, whichsrc/platform/xbox/keys.jsturns into the arrows, Enter and Escape the app knows. Video plays in the console's own player through FFmpegInteropX, behind a see-through WebView:src/platform/xbox/nativeVideo.jshands the player a real video element whose properties and events are routed over the bridge, so the shared webOS player code drives it unchanged and keeps drawing the controls and subtitles on top. The device probe underxbox/probe/reports what a console can do, andxbox/console.cjsinstalls and drives a console through its Device Portal. - Packaged apps (
.wgt,.ipk,.vpkgand.msix) bypass CORS restrictions that apply to the browser dev server, except that the Vega WebView does send anullorigin, which stock Jellyfin and Emby accept. Plex servers only let Plex's own web app read their answers, so on Fire TV those requests go through the React Native shell instead. - Cross-origin cookies do not persist in either platform's webview, so API keys are used instead.
- UI changes should be tested on real TV hardware when possible. Focus behavior, performance, and video in particular do not fully reproduce in a desktop browser.
Behaviors that have each can cause a headache. Read them before your first change.
-
The oldest TVs run a 2014 browser. The ES5 bundle runs on Chrome 38, which is what webOS 3 is. Syntax gets compiled to ES5, but only the built-ins listed in
vite.config.jsandsrc/fastPolyfills.jsare polyfilled, and missing DOM features aren't.KeyboardEvent.keydoesn't exist there, which is whyapp/keys.jslists every key by its code, so add a key there before handling it.SetandMaparen't iterable (Array.from(set)gives[]), and typed arrays have noslice. One token Chrome 38 can't parse stops the app, so CI parses every legacy file as ES5 (node scripts/check-legacy-js.mjs dist/webos-legacy). -
Never use Solid stores.
createStoreandcreateMutableneed Proxy, which Chrome 38 lacks. Use signals, orreactive()fromstate/reactive.js. -
There's no CSS to style with. Colors, fonts and sizes come from the active theme through
theme()inui/theme.js. Text goes throughfontFor()for server text anduiFont()for the app's own strings, which fall back to canvas text for scripts the font atlas doesn't cover. -
Every dynamic child gets a container of its own. The renderer draws children in the order their nodes were created, not their place in the JSX, so a
<For>,<Index>or<Show>that fills in later draws over the static siblings after it. Wrap it:<view><For .../></view>. -
A key handler stops the key only by returning exactly
true. Anything else,undefinedincluded, lets it bubble up to the parents. -
Give a scrolling view its own size. A
<view>with no width or height takes its parent's size when it's created, and once it scrolls past that box the renderer stops drawing it and everything in it. - A node at alpha 0 never loads its texture. Start an image at 0.001 when it has to load before it fades in.
- Older sets are limited by fill rate, not JavaScript. Every animated element, shadow and blur costs frames there, so check a change with General > Performance on Performance as well as High Quality.
- Older LGs have little memory to spare. A webOS 3 set was measured with about 250 to 350 MB free while the app runs, and webOS closes the app with no error when it runs out, so don't read whole files into memory and let go of what a screen no longer shows.
-
Adding a font means running
npm run fontsto rebuild the font atlases. A font cut from a variable font has to have its glyph overlap flags cleared first, or Chrome 38 refuses it and the text falls back to sans-serif. -
The renderer is patched.
npm installrunsscripts/patch-renderer.mjs, which fits@solidtv/renderer1.10.2 only and fails loudly when the renderer changes. An upgrade has to carry the patches, and nothing should work around them in a component. -
Installed update loaders never change. App code that ships through in-app updates has to keep calling
window.__moonfinOtathe wayservices/versionChecker.jsdoes now. -
Every packaged file ships in updates except the boot page, the loader, the manifests, the service and the comic reader's worker (
SHELLinscripts/ota/index.mjs). Show a packaged image through a node'ssrc, and load any other packaged file (a font, a script, a sound, a worker, a DOM stylesheet'surl()) throughassetUrl()inutils/assetUrl.js, so a TV that took an update uses that update's copy. -
A retail Samsung TV can still be inspected.
sdb shellis locked down, but with the app closed,sdb shell 0 debug MoonfinApp.moonfinlaunches it with a debug port, andsdb forward tcp:9222 tcp:<port>opens that to Chrome DevTools atlocalhost:9222. The port changes every launch.TV=<tv ip> tools/samsung.sh MoonfinApp.moonfindoes all of it in one go.
Moonfin is translated through Weblate. See the Smart-TV translation project rather than editing translation files by hand. Weblate writes them to public/resources/<lang>/strings.json, new English strings go in public/resources/strings.json, and translations reach sideloaded TVs with each in-app update.
Using Moonfin
Going deeper
For developers