Zorb (Zorb v0.10.0)

Copy Markdown View Source

Zorb is a high-performance Z-machine implementation that compiles Z-machine stories into optimized, standalone WebAssembly "Game Capsules".

This module provides the primary entry point for compiling stories into WASM.

Summary

Functions

Clears all cached WASM capsules and temporary artifacts.

Compiles a Z-machine story file into a WebAssembly Game Capsule.

Extracts metadata from a Z-machine story file.

Prunes the cache based on size, file count, or age.

Functions

clear_cache()

Clears all cached WASM capsules and temporary artifacts.

compile(story_path, opts \\ [])

@spec compile(
  binary(),
  keyword()
) :: binary()

Compiles a Z-machine story file into a WebAssembly Game Capsule.

Returns the WASM binary representation of the capsule.

Options

  • :cache - Whether to load from or save to the persistent cache. Defaults to false.

Examples

wasm_bytes = Zorb.compile("path/to/story.z5")
wasm_bytes = Zorb.compile("path/to/story.z5", cache: true)

metadata(story_path)

@spec metadata(binary()) :: map()

Extracts metadata from a Z-machine story file.

prune_cache(opts \\ [])

Prunes the cache based on size, file count, or age.

Options

  • :max_files - Keep only the N most recently used files.
  • :max_size - Keep the most recently used files up to the total size in bytes.
  • :older_than - Remove files that haven't been accessed in the given number of seconds.

Examples

Zorb.prune_cache(max_files: 50)
Zorb.prune_cache(max_size: 1024 * 1024 * 100) # 100MB
Zorb.prune_cache(older_than: 3600 * 24 * 7)   # 1 week