Skip to main content

Module addon

Module addon 

Source
Expand description

A module’s web half: the web/ directory of a [dependencies] entry, holding a lumen-addon.toml.

Every dependency is a module, and a module has up to two halves. Its desktop half is the library the loader opens (or finds compiled in). Its web half is data, not a library: a JavaScript module a page loads beside the runtime, with optional stylesheets, a script that runs before the page paints, and files the module reads, all described by the descriptor at the root of web/:

[addon]
namespace = "echo"
module = "echo.js"
styles = ["echo.css"]

[[function]]
name = "shout"
params = ["text: string"]
returns = "string"

[[function]]
name = "later"
params = ["text: string", "ms: int"]
async = "on_echo"

[[element]]
tag = "echo-view"
html = "div"

A web build takes the web half of every dependency and refuses one that has none; every other build loads the library and never reads web/. The directory is found the same way for every source: under the module’s root, which is the directory a path source names, the package a version source unpacked to, or the toolchain’s copy of a bundled module.

Reading one is a compile’s job: the descriptor becomes the lumen_ir::addon::Addon the compiled app carries, and the files become the site’s. No engine opens anything here.

Structs§

AddonPackage
An add-on read off disk: what the compiled app carries, and the files the site ships.

Constants§

ADDON_MANIFEST
The descriptor’s file name, at the root of a module’s web half.
RESERVED_EXPORTS
Module exports an add-on cannot name a function after, because the page reads them as the module’s own hooks.
RESERVED_NAMESPACES
Script namespaces an add-on cannot take: the runtime’s own, the embedder’s, and the one candela keeps for its standard library.
WEB_DIR
The directory a module keeps its web half in, under its root.

Functions§

describe
The script surface and the elements a descriptor’s text declares, for the module name, without looking at any file it names.
read_web_half
Read the web half of the module rooted at root, declared in [dependencies] as name.
web_half
The web half of the module rooted at root: its web/ directory, when that holds a descriptor.