@corbet-labs/ctypst
v0.3.1
Published
Shared Typst measurement: versioned protocol, Typst-WASM adapter, font manifest and assets. Mirrors the ctypst Rust crate release line.
Downloads
295
Readme
@corbet-labs/ctypst
Shared Typst measurement for browser and Node runtimes: the versioned
ctypst-measure-v1 protocol, the Typst-WASM adapter, the font manifest,
and the canonical font bytes. Mirrors the ctypst Rust crate release
line — both artifacts are cut from the same tag with matching hashes.
import { createTypstCompiler, loadFonts } from '@myriaddreamin/typst.ts';
import { CtypstMeasure } from '@corbet-labs/ctypst';
const compiler = createTypstCompiler();
await compiler.init({ beforeBuild: [loadFonts(fontBytes, { assets: false })] });
const measure = new CtypstMeasure(compiler);
const results = await measure.measureAll(items, format);Layout
src/protocol.ts— request/result types.src/adapter.ts—CtypstMeasure(transport, validation, caching). Bring your own compiler: the browser keeps its worker, incremental compiler, and font initialization.src/generated/measure-asset.ts— generated byscripts/sync-assets.sh(runs onprepack): the Typst program text, the manifest, the font file list, and the crate version. Never edited by hand.assets/,fonts/— generated copies of the canonical sources for bundlers and servers that load bytes from disk.scripts/conformance.mts— WASM side of the cross-runtime gate: runsprotocol/measure-v1vectors through the adapter and compares withexpected.json.
Requests are data, never generated Typst source. Failures are loud: unknown versions, empty or duplicate ids, unknown weights, bad dimensions, missing or unexpected results, and compiler errors all throw.
