Skip to main content

Module widgets

Module widgets 

Source
Expand description

Widgets: React components used as capitalized HTML tags in Markdown.

On the server a page’s widget tags become placeholder elements carrying the widget’s name, its props’ source and its content ([tags]), which comrak renders as Markdown. In the browser the page script loads React and the widgets, compiled here from TSX by oxc ([compile]), and mounts each placeholder. What was read and compiled is kept in a Modules cache.

This module is the widget set a document has: its names, the address each is served at, what a page loads, and what a request for one of its modules answers ([request]).

Structs§

Compiled
A widget module, compiled, as a request for it is answered.
Modules
What was read and compiled, shared by every handle to it.
Snapshot
The files a module is made from, each read once: the module and every module its relative imports reach inside the served folder. Its version and its compiled bytes both come from one snapshot, so a save landing between the two can’t serve new bytes under the old version.
Widgets
The widgets a document’s pages can use: name → the address its module is served at.

Constants§

NOTES
The tag a slide’s speaker notes are written in.
SIDEBAR
The widget that is a site’s sidebar: devpage’s own chrome, mounted by the page script on the sidebar the server rendered, never written in a page. Its Devpage prefix keeps it clear of a project’s names: a project may have its own Sidebar.
SYSTEM
The widgets devpage ships, compiled into the binary.

Functions§

expand
Replaces the tags of the widgets named in known in Markdown with placeholder elements, leaving code alone, and takes <Notes> out. An unknown capitalized tag, and a Tab outside a Tabs, are reported; an unknown tag is replaced by an error in its place rather than passed through as HTML.
is_widget_file
Whether path is a widget or helper file: a .ts or .tsx directly in a widgets folder.
project_module
The project widget or helper at path in folder’s served folder, compiled, asked for at version. An import without an extension finds the .tsx or .ts beside it. It renders by name the widgets of the document whose widgets folder holds it — the entry document’s when no other names it. Err with why when it, or any helper its imports reach, doesn’t compile — the browser would only say an import failed; None when no such file is in the served folder.
system
The source of a system widget, by name.
system_address
The address the system widget name is served at for the document served under mount, carrying its version.
system_hash
A system widget’s version: its source, the names it can render and the build — everything its compiled bytes are made from. None for a name that isn’t a system widget.
system_module
The system widget name — Tabs.tsx — compiled, asked for at version; Err with why when it doesn’t compile, and None for a name that isn’t a system widget.