tanxium 0.3.0

Embeddable JavaScript and TypeScript runtime with Yasumu APIs
docs.rs failed to build tanxium-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: tanxium-0.2.1

Tanxium

Tanxium is an embeddable JavaScript and TypeScript runtime built on Deno. It provides Yasumu's script bootstrap, module loading, Node.js compatibility, virtual modules, workers, and runtime APIs without requiring Tauri. Use it when you need the same script contract in a desktop app, CLI, service, test harness, or other host application.

Install

Add the library to an embedding application:

[dependencies]
tanxium = "0.2"

For a ready-to-use executable, install the companion CLI:

cargo install tanxium-cli
tanxium run script.ts

Prebuilt CLI downloads are available from the GitHub Releases page.

Embed the runtime

Tanxium::builder() keeps application concerns at the host boundary. Configure the workspace and resource roots, supply a host for runtime events and permission decisions, then start a JavaScript or TypeScript entrypoint.

use std::sync::Arc;
use tanxium::{RuntimeEvent, RuntimeHost, Tanxium};

struct Host;

impl RuntimeHost for Host {
    fn emit_event(&self, event: RuntimeEvent) {
        println!("{event:?}");
    }
}

Tanxium::builder()
    .workspace_dir("./workspace")
    .resource_dir("./resources")
    .host(Arc::new(Host))
    .build()?
    .run_file("./script.ts")?;

The runtime owns the Deno event loop, TypeScript transpilation, Node/CommonJS and ESM package resolution, built-in yasumu:* modules, virtual modules, and the globalThis.Yasumu bootstrap. RuntimeHost is intentionally small: embedders decide how to surface renderer events, confirmation requests, and permission prompts.

Permissions and workers

The main worker receives all Deno permissions by default so trusted host bootstrap code remains compatible. Set allow_main_worker_all_permissions(false) to start it sandboxed and delegate permission decisions to the host. Web workers always start without permissions and request them on demand.

The companion CLI takes the safer default: its main worker is sandboxed. Use --sandbox false or --no-sandbox for a trusted entrypoint. Interactive terminals offer allow-once, allow-all, and deny choices; non-interactive sessions deny prompts.

CLI

# Execute an entrypoint. Workspace and resources default to the current directory.
tanxium run script.ts

# Resolve packages from a different workspace or resource root.
tanxium run script.ts --workspace ./workspace --resources ./resources

# Start an interactive session with multiline input and top-level await.
tanxium repl

Pass --verbose to print renderer events such as structured console and notification output. Normal script output remains clean by default.

Documentation

License

Tanxium is licensed under AGPL-3.0.