A plugin in Yonto Player is one JavaScript file that teaches the app to talk to one kind of server. That is the easy part to explain. The part I find more interesting is the road the file takes: from a laptop with no TV, emulator or Android SDK, to an address a viewer pastes into a remote-controlled screen, or to a repo that lists many of them.
This post follows that road. It is built on three small things: a command-line tool, a JSON index, and a rule about published files. The opening post of this series has the bigger map; here I only care about getting a plugin out.
The author's loop
The tool is yonto-plugin, in the open-source plugins repo. It runs your plugin in the same QuickJS engine, with the same yonto global and limits as the app, so what passes on a laptop is meant to behave the same on a television. This is the command list from the CLI's README, the part an author uses day to day (an excerpt):
node src/cli.js init <id> [--template <name>] [--name <display name>] a new plugin in ./<id>, from templates/<name> (blank, video-blog) node src/cli.js lint <plugin-dir> manifest and bundle checks, no network node src/cli.js run <plugin-dir> <method> [args…] one method, its JSON, its requests node src/cli.js doctor <plugin-dir> the full battery, exit code for CI Each step answers a different question.
-
initwrites a plugin that already passes the next two commands, so the whole loop is visible before you change a line. -
lintchecks the manifest against its schema, builds the file and works out whichcontractVersionyour code needs. It makes no network request. -
runcalls one function with JSON arguments and prints its answer and the requests it made. -
doctorwalks the plugin the way the app does: categories, a list, page two, a title from that list, a search, then the optional functions. Each step is fed by the one before, and the exit code is meant for CI.
doctor has one rule I like: a successful but empty answer counts as a failure (EMPTY_RESULT), because a plugin that "works" and returns nothing is otherwise silent.
The manifest is a promise, in plain text
The manifest is a comment at the top of the file, and the app reads it as text without running the file. That is why a permission lives there and not in some export. This is the header of the blank template, verbatim:
/* yonto-plugin { "kind": "content-source", "id": "blank", "name": "Blank", "version": "1.0.0", "contractVersion": 21, "description": "A starting point: one made-up title, and no network.", "provides": "source", "allowedHosts": [] } */ id is two to 32 lowercase letters, digits and hyphens. version is three numbers. allowedHosts is the list of hosts the plugin may reach, and the install dialog shows it, so the manifest is what the viewer agrees to. contractVersion is the newest part of the plugin interface the code uses. lint computes it: declaring less is refused, and declaring more is a warning, because a number that is too high would turn away apps that could have run the plugin.
From a file to an address
bundle builds the publishable dist/<id>-<version>.js, makes a zip containing that one file, and prints the zip's size and SHA-256. Put the zip anywhere that serves HTTPS, such as a GitHub release. A viewer then goes to Settings, Advanced, Plugins, Install from URL, pastes the address, and reads the plugin's name, version and reach before choosing Install. The app downloads a plugin file of at most 1 MiB, and the download has 30 seconds.
That is enough for one plugin. For several, you make a repo.
The index
A repo is one address that lists many plugins. yonto-plugin index plugins --base-url https://plugins.example.com bundles each plugin in a directory and prints a document with a plugins list. Here is what it prints for a plugin with the blank template's description, as a simplified sketch (the hash is shortened to a placeholder, and the host is the one from the docs):
{ "plugins": [ { "id": "my-demo", "name": "My demo", "version": "1.0.0", "contractVersion": 21, "provides": "source", "description": "A starting point: one made-up title, and no network.", "url": "https://plugins.example.com/my-demo/my-demo-1.0.0.zip#sha256=<64 hex digits>" } ] } Two design choices are visible in it.
First, an entry has enough to list the plugin and compare versions without downloading anything: id, name, version, contract version, what it provides, a description. The index copies those from the manifest. The JSON Schema in the repo (contracts/index.schema.json) requires the id, name, version, contractVersion, provides and url, and caps the list at 2000 entries, which a device refuses rather than reading part of it.
Second, url is the versioned zip with its hash after the #, exactly the link a person could paste into Install from URL. The address says the version, and the fragment says which bytes. An entry without a hash does not match the schema's pattern, and index --check refuses it.
Checking it from the outside
The index is data written by hand or by tool, so it gets its own check, which I think of as doctor for a repo:
yonto-plugin index --check https://plugins.example.com/index.json It reads the document, then downloads every plugin it lists and holds each one to its entry. It refuses an entry with no hash, a download whose hash differs, and a manifest whose id, version or contract is not the one the entry states. It reports every problem it finds, not only the first. It reads the document with a reader that mirrors the app's, so what the check accepts is what a device is meant to accept.
A viewer adds the repo in Settings, Advanced, Repos, Add a repo, and can Refresh it later. Removing a repo removes the sources made from it, while plugins already installed from it stay installed and stop being offered updates.
Published bytes do not change
The rule I would keep even if I dropped everything else: once a version is public, the file at its address is never replaced. The repo pins each plugin by its SHA-256, so a file that changed under the same address is refused: by the app when it installs, and by index --check when you test the repo. To fix a plugin you raise version, bundle again and publish a new address.
I like this for two reasons. A hash in the index only means something if the bytes behind it can be trusted to stay the same, and an address that names a version is easy to reason about: a new version shows up as a new number and a new address, not as a silent change under an old one.
The checklist in the publishing docs ends with it: "version is new."
What I would take from it
Put the manifest where it can be read without running anything, make the tool that checks it the same engine the app uses, and let an index carry a hash next to every address. Then the road from a laptop to a TV is short, and each stop on it has a command that tells you whether you are still on it.

