libraries, at exact versions, the ones
it loads from there instead of bundling them; anything it does not name, it bundles. A library loaded from the catalog
adds nothing to the definition, and loading React from the catalog keeps one React across react-dom and
react-bootstrap, where two copies would break every component that uses hooks.
This page lists the catalog, says how the frame resolves a widget’s imports through it, states the rules a build follows
to make one module that loads, and gives BlobHub’s light and dark colors. Everything here is what a widget needs
without the kit.
The catalog
The catalog ishttps://blobhub.io/libs/catalog.json, also served at /libs/catalog.json on every widget origin, and
it is the complete, current list of libraries and their versions. Each version’s files sit at an immutable path,
/libs/<name>/<version>/, on every widget origin, so a widget loads its libraries from its own origin. A published
version is never changed or removed, so a widget that names one keeps loading it; a later version of a library is added
beside the earlier ones, never in their place. The browser caches each library file as immutable, once per widget
origin: on a warm cache a library costs nothing, and on a cold one a download per widget.
These are the libraries and versions the catalog holds:
- Peers. A peer is a catalog library that a library imports by its bare name, so that one instance is shared: React
across
react-domandreact-bootstrap, the grid’s module registry acrossag-grid-reactandag-grid-community, Ace acrossreact-aceand Ace’s modes, andd3-selectionacrossd3-zoom’s transitions. A widget that declares a library declares its peers too: the frame resolves only what the widget declares. A library whose peer is not declared cannot import it, and the widget does not start.catalog.jsondoes not list peers, and neither the CLI nor the server checks them, so this table is where they are found. Everything else a library needs is bundled inside it. - Ace.
ace-buildsholds Ace’s minified files undersrc-noconflict/, without its workers, since the frame refuses a worker loaded from a URL. A widget sets Ace’sbasePathto/libs/ace-builds/1.35.4/src-noconflict, so that Ace loads a mode, theme or snippet itself, anduseWorker: false, so Ace runs without its background syntax checker. Eachace-builds/src-noconflict/<file>entry loadsace-buildsfirst, so a mode imported before Ace still finds it. - TradingView.
tradingviewis TradingView’s charting library. It draws its chart in a frame nested in the widget and loads its files from its directory in the catalog, both of which the frame allows, so it works in a widget unchanged; a widget passeslibrary_path: "/libs/tradingview/29.6.0/"when it creates a chart.
The format
catalogis the format’s version,1. A reader refuses a version it does not know: the frame does not load the widget, andblobhub workflow deployrefuses it withWIDGET_CATALOG_UNAVAILABLE.librariesmaps each library’s name to every published version of it, eachMAJOR.MINOR.PATCH.importsmaps each import-map entry the version answers to onto a file, andcsslists its stylesheets. Both hold paths relative to/libs/<name>/<version>/, so@xyflow/react12.1.1’s entry@xyflow/reactresolves to/libs/@xyflow/react/12.1.1/index.js.integrityholds the Subresource Integrity value of every file in the version’s module graph: the filesimportsandcssname, and the files they import. A file a library loads itself, outside the import map, is not checked againstintegrity: TradingView’s bundles have no value, and a mode, theme or snippet Ace loads from itsbasePathis fetched as a classic script, which an import map’s integrity does not cover. A mode, theme or snippet is checked only when the widget imports it through itsace-builds/src-noconflict/<file>entry.
The import map
When a widget loads, the frame’s bootstrap page reads/libs/catalog.json from the widget’s own origin and, before it
imports the entry, writes an import map for exactly the libraries the widget declares: every import-map entry each
declared version answers to, mapped to its file under /libs/<name>/<version>/, with the integrity value of every file
the version lists. It links each declared library’s stylesheets, with their integrity values, and then the widget’s own,
so the widget’s rules come after the catalog’s and can restyle them. Then it imports the entry.
A bare import of a declared library’s entry resolves through the map, static or dynamic, in the widget’s code and in the
catalog’s libraries alike, which is how a library reaches its peers. A static import loads with the entry; a dynamic
one, such as import("mermaid"), loads only when the code reaches it, so a heavy library a widget seldom needs costs
nothing until then. An entry ending / answers to every specifier that starts with it, as an import map resolves it.
Nothing else resolves. A declared library or version the catalog lacks stops the load, and the playground shows
This widget needs <library> <version>, which the catalog does not have. in place of the widget. A bare name no
declared library answers to fails the import, and the widget does not start.
blobhub workflow deploy catches both before it uploads
anything: it refuses a library or version the catalog lacks with WIDGET_LIBRARY_UNKNOWN, and an entry that imports a
relative path, a URL, or a bare name no declared library answers to with WIDGET_IMPORT_INVALID. A computed
import(expr), which it cannot judge, draws the advisory WIDGET_IMPORT_UNVERIFIED.
Building one module
A widget’s own build writes the directoryblobhub workflow build packs, as
Deploying shows. Whatever bundler makes it, the output
follows these rules; a build that breaks one makes a widget that does not load, or loads broken:
- One ES module. The entry is an ES module that exports
mount, with the widget’s own dynamic imports inlined: no code splitting and no chunks. The frame loads every file from ablob:URL, which cannot resolve a relative import, so a chunk is never found, andbuild,deployanddiffrefuse a relative import. - Declared libraries stay bare. Every import of a declared library’s import-map entry is left as a bare import, for
the import map to resolve, and a declared library is imported only through its entries. Bundled, a library is a
second copy beside the one the catalog’s libraries import: with two Reacts, a component that uses hooks fails. Nor
does a widget import a path into a declared library that is not one of its entries, such as
react-dom/server: left bare it resolves to nothing, and the CLI refuses it. - A CommonJS
require()of a declared library becomes an import. A CommonJS dependency that callsrequire("react")must receive the library the import map loads, through an import. Left as arequire, it throws when the module loads, since a browser has norequire, and the widget does not start. The CLI cannot see this: arequireis not an import. - A declared library’s stylesheet is left out. The bootstrap links the catalog’s stylesheet of every declared
library that has one, so the build drops any import of it, from a script or from a stylesheet’s
@import. Left bare, the import resolves to nothing, and the CLI refuses it in a script; bundled, it is a second copy in the definition. A stylesheet the catalog does not serve, such as a highlight.js theme, is bundled. - Images and fonts inlined. Every image and font the code or a stylesheet uses is inlined as a
data:URL. A stylesheet loaded from ablob:URL cannot resolve a relativeurl(), and the widget’s origin serves no file of the widget’s, so an image or font left as a file never shows. index.jsandindex.css. The output is the entry module,index.js, and, when the widget has styles, one stylesheet,index.css.widget.yaml’sentrynames the module, and the bootstrap links every stylesheet in the build after the catalog’s.
build.mjs in the widget’s project, run with node build.mjs before blobhub workflow build, for the
Order Board’s two libraries:
externalholds every entry of the declared versions, read from the catalog. esbuild also leaves every path under a listed package bare, its stylesheets included, so the widget imports no stylesheet of a declared library. One the catalog does not serve is imported by its path relative to the importing file, such as../node_modules/highlight.js/styles/github.css, which esbuild bundles.jsx: "automatic"compiles JSX into imports ofreact/jsx-runtime, an entry the catalog’s React answers to.definereplacesprocess.env.NODE_ENV, which many packages read and a browser does not have.- The CommonJS case. esbuild uses a package’s ES module build when the package ships one. When a dependency ships
only CommonJS and calls
require()on a declared library, esbuild keeps the call, and the module throwsDynamic require of "react" is not supportedwhen it loads. Such a dependency needs a plugin that resolves thatrequireto a module importing the entry and handing its exports back, or a replacement that ships ES modules.
Light and dark
The bootstrap sets<html data-theme> to the page’s theme, light or dark, before the entry loads.
hello answers the same theme, and when the page
switches between light and dark the host pushes theme.changed (Watches and
events), on which the widget sets the
attribute itself: the bootstrap sets it only once. A stylesheet keys its dark colors on :root[data-theme="dark"], and
a library that draws from script, such as a chart or an editor, is given the theme as an option: from hello on load,
and again on each theme.changed.
None of the catalog’s stylesheets follows data-theme. Bootstrap’s is light-only, and AG Grid’s and React Flow’s stay
light unless switched by a class or option of their own. A widget that uses them restyles them for dark in its own
stylesheet, which the bootstrap links after theirs. Here a widget declares a few of the tokens for both
themes and draws with them:
color-scheme: dark darkens the frame’s own backdrop, scrollbars and form controls. In mount, the widget follows the
page’s theme after load:
Tokens
BlobHub’s own widgets draw with--bh-* custom properties. The frame declares none of them: a widget that takes
BlobHub’s look declares the ones it uses, with these values. The core tokens:
- Status colors. Each of
success,danger,warningandinfohas a mark color, a pale-tintplate, and a-textcolor for text on that plate. --bh-focus-ringis a color only: a focus ring isbox-shadow: 0 0 0 0.2rem var(--bh-focus-ring).- The shadows hold a whole
box-shadowvalue. In dark, where a shadow barely shows, each also draws an edge from--bh-borderor--bh-border-strong, so a widget that uses a shadow declares that token too.
Storage
A widget keeps a viewer’s preferences, such as a chosen tab or a column’s width, inlocalStorage on its own origin. No
other widget and no page on blobhub.io can read it, and the bridge has no storage call. The origin belongs to the
widget’s alias in its blob, so every placement of the widget on the blob’s playgrounds, every build deployed under that
alias in any revision, and every person who opens it in the same browser share that storage. A widget therefore keys
each entry by the viewer’s id, from hello and viewer.changed, and reads what an earlier build wrote without
assuming its shape. What it stores stays in that browser.
See also
- Custom Widgets:
widget.yamland itslibraries, the definition, permissions, and deploying. - Bridge Protocol: the entry, the handshake, every call, event and refusal.
- Security Model: the frame and its origin, the headers that cut it off from the network, and the risks that remain.

