wasm

command
v0.0.0-...-0a035d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package main is the WebAssembly entry point for Gnata. Build with: GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm/

The -s -w flags strip debug info; -trimpath removes local paths. When served with brotli or gzip the browser transfer size is ~1.2–1.4 MB.

Raw WASM exports (registered on the JS global object with underscore prefix):

_gnataEval(expr, jsonData)            → string | Error
_gnataCompile(expr)                   → number | Error
_gnataEvalHandle(handle, jsonData)    → string | Error
_gnataReleaseHandle(handle)           → undefined | Error

playground.html wraps these with a wrapWasm factory that converts returned Error values into thrown exceptions, exposing the public names without the underscore prefix. Consumers embedding this WASM outside the playground must implement their own wrapper or use the underscore names directly.

Cache lifetime: exprCache (keyed by expression string) and compiledCache (keyed by handle) are intentionally unbounded for the playground use-case — sessions are short-lived and the expression universe is small. Call gnataReleaseHandle when a compiled handle is no longer needed to free the associated memory.

Error handling: Go WASM's js.FuncOf does not reliably recover panics, so we return JS Error objects and let a thin JS wrapper throw them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL