Expand description
The ZDeceptron JavaScript runtime, embedded and executable from Rust.
The runtime library that generated code links against is written in JavaScript, because it manipulates the DOM and there is no other way to do that (spec §14E.2). But verifying it must not require a JavaScript toolchain: needing Node to build ZDeceptron would be the first crack in the claim that a developer installs one binary and nothing else.
So the sources are embedded here and evaluated with a pure-Rust engine.
cargo test covers the runtime; nothing else has to be installed.
§Two halves, and why the seam is a feature
Holding the runtime sources and running them are different jobs, and
the evaluate feature is where they part. Everything above the seam is
text and plain data — the .js and .css a bundle ships, and the
signatures a capability is written against. Everything below it is
boa_engine, a JavaScript interpreter written in Rust.
The seam is cut here rather than left implicit because boa_engine
reaches getrandom, and getrandom will not build for
wasm32-unknown-unknown without an entropy backend chosen by --cfg.
zdc-codegen depends on this crate for seven const &strs, so without
the seam the entire front end inherited that refusal and no part of this
compiler could run in a browser (#171). See the feature’s comment in
Cargo.toml for the dependency chain in full.
Structs§
- Capability
- One capability the compiler answers for the code it is running.
- Runtime
Error - An evaluation failure, with the engine’s own message.
- Sandbox
- A JavaScript sandbox the compiler owns, for running the code it just emitted — spec §17.4.8.
Enums§
- Mode
- Which build a runtime module is being emitted for — spec §16.3.1’s “ships nothing it does not use”, applied to the checks themselves.
- Provided
- What a capability may answer with.
Constants§
- BASE_
CSS - The base styling of the built-in elements, as classes.
- CLOCK_
JS - The clock:
every "250ms",every frameandafter "2s". - DEV_
CLOSE - The line that closes one.
- DEV_
OPEN - The line that opens a block only a development build carries.
- DOM_JS
- DOM rendering. Requires a document, so it is embedded for shipping rather than for evaluation here.
- DOM_
SHIM_ JS - The minimal DOM the runtime and everything downstream of it run against when there is no browser.
- ELEMENTS_
JS - The built-in view elements.
- FOREIGN_
JS - The lifecycle of a
foreign … gives view: create, update, destroy. - KEYS_JS
- Document key listeners:
on key "Escape". - LIST_JS
- Keyed list reconciliation:
each,eachIntoand the interim key function. - MARKUP_
JS - The
Proserender path — the one function in the runtime that parses HTML. Its own module so a program with noProsedoes not ship it. - MEDIA_
JS media "…"— a CSS media query, as a signal that changes with it.- MODULES
- Every embedded runtime module, by the path a bundle writes it to.
- REMEMBERED_
JS - The
rememberedplacement’s store:localStorage, as a signal. - REQUEST_
JS - The outbound request a
requestdeclaration is (#19). - RPC_JS
- The client half of the derived boundary:
$remoteand$call. - SIGNAL_
JS - The reactivity core: signals, derived values, effects, batching.
- STORE_
JS - Live sync for
durableplacement, and the transport seam it needs. - WIRE_JS
- The wire format: how a ZD value survives JSON.
Functions§
- eval_
with_ signals - Evaluate
scriptwith the reactivity core already in scope. - for_
mode - One runtime module’s source, as the given build ships it.