1. Introduction
  2. Guidance
  3. 1. Get started
  4. 2. Bundles
    1. 2.1. All-in-One Library for Browsers
    2. 2.2. All-in-One Library for Node.js
  5. 3. Compilers
    1. 3.1. (Pre-)Compiler in CLI
    2. 3.2. Compiler in Rust
    3. 3.3. Compiler in Node.js
    4. 3.4. Compiler in Wasm (Web)
  6. 4. Renderers
    1. 4.1. Renderer in Rust
    2. 4.2. Renderer in Node.js
    3. 4.3. Renderer in Wasm (Web)
    4. 4.4. Renderer in React
    5. 4.5. Renderer in Solid
    6. 4.6. Renderer in Angular
    7. 4.7. Renderer in Vue3
    8. 4.8. Hexo Plugin
  7. 5. Samples
    1. 5.1. Static, Responsive rendering
    2. 5.2. Streaming, Incremental rendering
    3. 5.3. Serverless rendering
  8. 6. Trouble Shooting
  9. Project samples
  10. 8. shiroa
  11. 9. typst-preview
  12. 10. hexo-renderer-typst
  13. References
  14. 13. Routing to Renferences

reflexo-typst Documentation

… todo: rewrite me.

Note: the following content is for typst.ts <v0.6.0

#

Creating and Using a CompileExporter Instance

Note: The struct CompileExporter implements trait CompileMiddleware.
Note: The struct CompileExporter derives trait Compiler.

Retrieve an exporter instance that is executed on each successful compilation (more useful for incremental compilation).


        
let driver = CompileExporter::default()

        
  .with_exporter(exporter)

        
let driver = CompileExporter::default()

        
  .with_exporter(exporter)

See exporter.rs for usage of the exporter feature.

Glance at current available exporters:


        
type WithAst = reflexo_typst::AstExporter;

        
type WithPdf = reflexo_typst::PdfDocExporter;

        
type WithSvg = reflexo_typst::PureSvgExporter;

        
type WithSvgHtml = reflexo_typst::SvgHtmlExporter<DefaultExportFeature>;

        
type WithSIR = reflexo_typst::SvgModuleExporter;

        
type WithText = reflexo_typst::TextExporter;

        
type WithAst = reflexo_typst::AstExporter;

        
type WithPdf = reflexo_typst::PdfDocExporter;

        
type WithSvg = reflexo_typst::PureSvgExporter;

        
type WithSvgHtml = reflexo_typst::SvgHtmlExporter<DefaultExportFeature>;

        
type WithSIR = reflexo_typst::SvgModuleExporter;

        
type WithText = reflexo_typst::TextExporter;

#

Creating and Using a DynamicLayoutCompiler Instance

Note: The struct DynamicLayoutCompiler implements trait CompileMiddleware.
Note: The struct DynamicLayoutCompiler derives trait Compiler.

Enable dynamic layout based on a trait Compiler.


        
let driver = DynamicLayoutCompiler::new(driver, output_dir);

        
let driver = DynamicLayoutCompiler::new(driver, output_dir);

#

Creating and Using a CompileActor Instance

Specifical for incremental compilation (Specifically, it watches files and compiles on demand) based on some universe instance.

Example: use of struct CompileActor in tool/preview.rs in tinymist


        
let (intr_tx, intr_rx) = mpsc::unbounded_channel();

        
let actor = CompileActor::new(verse,

        
  intr_tx, intr_rx).with_watch(Some(handle.clone()));

        
let (intr_tx, intr_rx) = mpsc::unbounded_channel();

        
let actor = CompileActor::new(verse,

        
  intr_tx, intr_rx).with_watch(Some(handle.clone()));

Example: use of intr_tx in tool/preview.rs in tinymist

Access the service of the CompileActor instance.


        
/// Updates the overlay layer of VFS (Virtual File System)

        
let _ = self.intr_tx.send(Interrupt::Memory(event));

        
/// Reads the snapshot of the current compilation

        
let (tx, rx) = oneshot::channel();

        
self.intr_tx.send(Interrupt::SnapshotRead(tx))?;

        
let snapshot = rx.await

        
/// Updates the overlay layer of VFS (Virtual File System)

        
let _ = self.intr_tx.send(Interrupt::Memory(event));

        
/// Reads the snapshot of the current compilation

        
let (tx, rx) = oneshot::channel();

        
self.intr_tx.send(Interrupt::SnapshotRead(tx))?;

        
let snapshot = rx.await

#

Adding Exporters to a CompileActor Instance

Example fn compile_export in compile.rs in typst-ts-cli


        
let mut exporter: Vec<DynExporter<CompileSnapshot<_>>> = vec![];

        
let handle = Arc::new(CompileHandler { exporter });

        


        
let actor = CompileActor::new_with(

        
    verse, intr_tx, intr_rx,

        
    CompileServerOpts {

        
        handle,

        
        ..Default::default()

        
    },

        
)

        
.with_enable_watch(args.watch);

        
let mut exporter: Vec<DynExporter<CompileSnapshot<_>>> = vec![];

        
let handle = Arc::new(CompileHandler { exporter });

        


        
let actor = CompileActor::new_with(

        
    verse, intr_tx, intr_rx,

        
    CompileServerOpts {

        
        handle,

        
        ..Default::default()

        
    },

        
)

        
.with_enable_watch(args.watch);