compmd-host
What every host of CompMD documents shares, whatever its platform: the bundle a host builds before anyone reads (the sandbox's frames under a content hash, the packs it installs, and its manifest.json), the store of packs it gets later, and respond, the serving contract an adapter puts behind its origin. The design, and why each rule is there, is hosting CompMD.
use ;
let bundle = read?; // what @compmd/vite wrote
let store = new;
let response = respond; // for a request on the adapter's origin
Bundlereads a bundle embedded in a binary, in a folder, or made in memory for a test (Bundle::from_files); itsManifestis what@compmd/vitewrote, and a manifest of a format this crate doesn't know is refused, saying what to upgrade.Storeis where a host keeps packs beyond the bundle;FolderStorekeeps them in a folder, by their place, with their integrity. Each release is written whole beside the one kept, then renamed into place, so a keep that fails halfway leaves the release that was there.respondanswersGET /frames/<hash>/<path>andGET /packs/<name>@<version>/<path>, with the headers that sandbox them, and refuses anything else, saying why.HostPacks(theprocessorfeature) gives the processor,compmd, the same packs the frames load.registry::Resolution(theregistryfeature) resolves a request's packs from registries: the version each import takes, the policy before any download, the tarball checked against its integrity and read. It does no I/O: it says what it needs next (the processor's missing packs, a cache's files, a registry's metadata or tarball), and the host does it its own way and answers (the registry rules).registry::FolderCacheanswers its cache's steps from a folder: the releases, asFolderStorekeeps them, and each pack's versions for as long as its registry'sCache-Controlsays.registry::resolve(theclientfeature) drives a resolution to its end on a thread of the host's own: its cache's steps from aFolderCache, its registries' withregistry::Client(ureq, from each registry's own origin), or none when the host is off the network.registry::Proxy(theclientfeature) is a host'sregistry/proxy, as@compmd/registry'sregistryProxyis in JavaScript: it passes a pack's metadata, its tarballs' URLs its own, and its tarballs on from the registries a bundle's manifest names (registries,fetch,maxPackSize).registry::Client::search(theclientfeature) lists a scope's packs from its registry's search, by the keywordcompmd-pack, for an editor to suggest them;registry::FolderCache::packs_inlists those a cache kept.registry::LocalRegistry(thelocal-registryfeature) serves packs over npm's protocol fromhttp://127.0.0.1, each scope's search too, for a host's tests.tracing:respondis a span (compmd_host::respond, with the path) with an event of the status it answered, andFolderStore::keepone (compmd_host::keep, with the release) with a warning when the release isn't kept. The crate installs no subscriber: a host that wants them installs its own.
Adapters: tauri-plugin-compmd for Tauri.
Status
In development, released with CompMD's packages at the same version.
Versions:
- 0.12.0: the
registryfeature, the registry rules as a state machine (registry::Resolution), withregistry::FolderCache; theclientfeature,registry::resolve,registry::Client(withClient::metadata) andregistry::Proxy; thelocal-registryfeature,registry::LocalRegistry.registry::Options::registry_ofgives a pack's registry, andregistry_of_scopea scope's. A scope's packs from a registry's search:Client::search,search_pathandsearched,PACK_KEYWORD;FolderCache::packs_inlists those kept;LocalRegistryserves each scope's search.FolderStore::files_ofgives a kept release's files.Manifestreadsregistries,fetch(FetchedBy) andmaxPackSize. With theprocessorfeature,ChainedPacksasks pack sources in order and lists their known packs (Packs::known). Breaking, for Rust code:Manifesthas new public fields. - 0.11.0: a request's path is percent-decoded segment by segment before it is read, and a decoded
..is still refused;refusedandBundle::pack_file_orare public, so Rust and JavaScript hosts serve a bundle the same way.FolderStore::keepwrites a release whole, then moves it into place, so a store never holds half a release. With theprocessorfeature,HostPacks::policy()andambient()give the bundle's policy and ambient packs forresolve_with, and a policy the processor can't read isManifestError::Policy.tracingspanscompmd_host::respondandcompmd_host::keep. Breaking, for Rust code:compmd_host::Filesis no longer public;ManifestErrorhas a new variant. - 0.10.0: the same as 0.9.0.
- 0.9.0: the same as 0.8.0.
- 0.8.0: the serving contract's decision apart from its answer:
route, a path'sRoute, aRefusalsaying why, andserved_headersandrefusal_headers, which@compmd/hostshares as WebAssembly;respondanswers as before. - 0.7.1: the same as 0.7.0; its homepage and links name the website's new address, compmd.dev.
- 0.7.0: the first version.