Packaging
A widget ships as a single ZIP archive. Toolblox downloads it from the URL in the signed catalogue, checks it against the SHA-256 the catalogue pins, extracts it into a staging folder under strict limits, validates the manifest against the catalogue entry, and only then swaps it into place. During development, the same folder layout loads unpacked from the widgets folder.
The install code is
install_archive in
src-tauri/src/widgets.rs,
called from install_catalogue_widget in
src-tauri/src/app_commands.rs.
Package layout
Section titled “Package layout”widget.json must be at the root of the archive, not inside a top-level folder.
- widget.json required
- main.js when the manifest declares
module - index.html when the manifest declares
entry - settings.html when the manifest declares
settingsEntry - dashboard.html when the manifest declares
dashboardEntry Directoryassets/ anything else the widget loads, in any folder layout
- styles.css
- icon.svg
Directoryoptional-bin/ native executables, when the manifest declares
processes- worker.exe
- worker
- LICENSE
Every file the manifest declares must exist in the package: main.js, each declared HTML entry,
and each process executable. Other files are free-form, served read-only through the
widget asset protocol. Keep
names lowercase and use the extensions the protocol recognizes so files are served with the right
content type.
Building the archive from a folder:
# macOS or Linux, from inside the widget folderzip -r -X ../trade_tracker-1.2.0.zip . -x '.*'
# Windows 10 or later, from inside the widget foldertar -a -c -f ..\trade_tracker-1.2.0.zip *Entry names must use forward slashes. Some Windows tools, including Compress-Archive in Windows
PowerShell 5.1, write backslashes, which other platforms read as part of a file name. List the
archive (unzip -l or tar -tf) before publishing to check.
Then hash it for the catalogue entry:
shasum -a 256 trade_tracker-1.2.0.zip # macOSsha256sum trade_tracker-1.2.0.zip # Linux(Get-FileHash trade_tracker-1.2.0.zip).Hash # Windows PowerShellThe hash covers the exact archive bytes. Rebuilding the ZIP, even from identical files, usually changes timestamps and therefore the hash, so hash the exact file you upload.
Executables
Section titled “Executables”Native executables go under optional-bin/ and must be declared under processes in the
manifest. On macOS, extraction applies each entry’s Unix permission bits from the archive, so the
archive must record the executable bit (chmod +x before zipping with a tool that preserves
modes, such as zip). Without it, the process can’t start. Archives created on Windows usually
carry no Unix permission bits, so build packages that include macOS executables on macOS or
Linux. Windows ignores the
bits.
A widget that supports both platforms can declare one process per platform, such as
worker-windows pointing at optional-bin/worker.exe and worker-macos pointing at
optional-bin/worker, and choose which to start from toolblox.getState().platform.
Limits
Section titled “Limits”| Limit | Value | Error |
|---|---|---|
| Archive size | 20 MB (20 × 1024 × 1024 bytes) | The widget package is larger than 20 MB. |
| Total extracted size | 80 MB | The widget package is too large when extracted. |
| Entries in the archive, including folders | 2,000 | The widget package contains too many files. |
widget.json size |
128 KB | The widget manifest is too large. |
How installation verifies a package
Section titled “How installation verifies a package”-
Look up the entry. The widget must be in the verified catalogue loaded this session. Otherwise:
The widget isn't in the verified catalogue. Can you refresh it?Installing a widget that’s already installed fails withThe widget is already installed. Can you update it instead? -
Download. Toolblox requests
archiveUrlover HTTPS with its own HTTP client, which doesn’t follow redirects and times out after 20 seconds. Anything other than a2xxresponse fails withThe widget package download failed with status <code>. Can you try again?The body is read up to 20 MB. -
Check size and hash. Before anything touches the disk, the archive’s SHA-256 is compared, case-insensitively, with the catalogue’s
sha256. A mismatch fails withThe widget package checksum doesn't match the catalogue. -
Stage. Toolblox creates
.<id>-install-<random>in the widgets folder. Folders starting with.are never loaded as widgets. -
Extract with path checks. For each entry in the archive:
- The name must resolve inside the staging folder. Absolute paths,
.., root, and drive components fail withThe widget package contains an unsafe path. - Two entries that normalize to the same path fail with
The widget package contains duplicate paths. - Symbolic links fail with
The widget package contains a symbolic link. - The running total of uncompressed sizes must stay within 80 MB.
- Each file is written and synced to disk. On macOS, its permission bits are applied.
A corrupt archive fails with
The widget package isn't a valid ZIP archive.orCouldn't read the widget package. - The name must resolve inside the staging folder. Absolute paths,
-
Validate the manifest.
widget.jsonis read from the staging folder and validated. Then:- its
idmust equal the catalogue entry’sid:The widget package ID doesn't match the catalogue. - its
versionmust equal the entry’sversionexactly:The widget package version doesn't match the catalogue. - its
permissionsmust equal the entry’spermissionsas a set:The widget permissions don't match the catalogue. - every declared
module,entry,settingsEntry, anddashboardEntrymust be a file:The widget package doesn't contain <file>. - every process executable must be a file:
Widget process <id> is missing.
- its
-
Record the install. Toolblox writes
.installed.jsonnext to the manifest:{"schemaVersion": 1,"id": "trade_tracker","version": "1.2.0","sha256": "<package SHA-256>","manifestSha256": "<SHA-256 of widget.json>"} -
Swap. If a previous version exists, its folder is renamed to
.<id>-backup-<random>. The staging folder is renamed to<id>. If that rename fails, the backup is renamed back, so the previous version stays installed. On success the backup is deleted.
Whatever happens, the staging folder is removed. Every failure is logged as
Widget <id> <version> wasn't installed: <error> and shown to the user as
<name> couldn't be installed. Does retrying help? (<error>).
Verification after install
Section titled “Verification after install”Each time Toolblox lists widgets, which happens on every state reload, it reads every non-hidden folder in the widgets folder and, in release builds:
- requires
.installed.jsonto exist (Widget <id> is missing install metadata.) and to parse (Widget <id> has invalid install metadata.); - requires its
schemaVersionto be1and itsidandversionto match the manifest (Widget <id> has inconsistent install metadata.); - requires both hashes to be valid SHA-256 strings;
- requires the SHA-256 of the current
widget.jsonto equalmanifestSha256:Widget <id> has a modified manifest. Reinstall it from the Catalogue.
Any failure keeps the widget out of the app and shows Widget <folder> couldn't load: <reason> on
the Widgets page. Only the manifest is re-hashed; other package files aren’t re-verified after
installation.
Development builds
Section titled “Development builds”Development builds (the canary channel, built with debug assertions) load unpacked widgets
straight from the widgets folder. The Widgets page shows that folder’s path with a copy button.
| Platform | Widgets folder |
|---|---|
| Windows | %LOCALAPPDATA%\Toolblox\widgets |
| macOS | ~/Library/Application Support/Toolblox/widgets |
| Override | $TOOLBLOX_DATA_DIR/widgets when TOOLBLOX_DATA_DIR is set (debug builds only) |
-
Create a folder named exactly after the manifest’s
id, such aswidgets/trade_tracker/. Asset URLs, process paths, and the enable switch all resolve<widgets folder>/<id>. -
Put
widget.jsonand the widget’s files directly inside it, in the package layout. -
Bring Toolblox to the front or wait for its next state reload. The widget appears under Installed and in the sidebar. A folder without
.installed.jsonis accepted in development builds and reported with an all-zero SHA-256. -
After changing
main.js, reload the app window so the module is imported again. Frame pages reload each time their surface opens.
The manifest is still validated, so mistakes show up at the top of the Widgets page. If a folder
has an .installed.json from a real install, the manifest hash check still applies; delete the
file to edit the manifest freely.
Development builds without a configured catalogue URL list the repository’s widgets/ and
examples/ folders as their catalogue. See
Testing the catalogue locally.
Once a widget from widgets/ is installed, development builds keep it in sync with the working
tree. Toolblox checks the folder once a second, and when a file changes it stops the widget’s
processes, reinstalls the folder with the same checks a catalogue package gets, and reloads the
widget’s module in every window. Save a file, or rebuild a helper into optional-bin/, and the
change applies without a reinstall, a version bump, or a window reload. A change that fails a
check, such as invalid widget.json, is logged and the installed copy stays.
Updates
Section titled “Updates”When the catalogue lists a version that’s strictly greater, by SemVer precedence, than the installed one, the widget’s card shows Update to v<version>. The confirmation lists the new version’s permissions from the catalogue.
An update:
- checks again that the catalogue version is greater:
The catalogue doesn't contain a newer widget version.; - stops all of the widget’s processes;
- runs the full install sequence above, ending in the atomic swap.
Storage, per-account data, and the enabled state are kept. The module’s URL carries the installed package’s hash, so a module that was already loaded is unloaded and the new code is imported; see the host API lifecycle.
There’s no downgrade path in the app: a lower catalogue version isn’t offered.
Uninstall
Section titled “Uninstall”Uninstalling, after a confirmation that it “This removes the widget and its settings from this device”:
- stops all of the widget’s processes;
- deletes
<widgets folder>/<id>. If a file is locked, for example by a process that didn’t stop, this fails withCouldn't remove the widget. Is a widget process still running?; - removes the widget from the disabled list;
- deletes its
storagevalue.
Per-account data written with widgetData.set stays with each account and is available again if
the widget is reinstalled. After uninstalling, the widget appears in the Catalogue section again.
Enable and disable
Section titled “Enable and disable”The switch on each installed card turns a widget on or off. The state is saved in Toolblox’s settings and kept across restarts and updates. Disabling:
- unloads the module and runs its cleanup,
- stops all of its processes,
- closes any open frame,
- disables its sidebar entry and Open button, and makes its routes show Page unavailable.
Enabling loads it again. Every widget is enabled when first installed.