wasm

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package wasm holds build-time JS and HTML assets for the `lg -w` WASM bundler. AssembleHTML returns a single self-contained HTML page given the Go runtime support source and the gzipped-base64 program WASM.

The host JS is split into two assets:

  • lg-host-core.js: the host-agnostic glue (COI, wasm decode, the window.LetGoHost surface, the worker/main-thread boot). Always emitted.
  • lg-shell-xterm.js: the default xterm.js shell, which binds to the runtime only through LetGoHost. Emitted unless shell == false, i.e. `lg -w -w-shell none`, where the client supplies its own shell.

lg-host-core.js carries two markers (__WASM_EXEC_JS__ and __WASM_GZ_B64__) the assembler substitutes with JSON-encoded JS strings. host.html carries __LG_XTERM_CSS__ / __LG_XTERM_JS__ (the xterm CDN tags, dropped in shell-less builds) and __LG_HOST_JS_BODY_PLACEHOLDER__ where the host JS is inlined.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssembleHTML

func AssembleHTML(wasmExecJS, wasmGzB64 string, shell, externalWasm, hostEval bool) string

AssembleHTML returns the full self-contained HTML page produced by `lg -w`. With shell == true the default xterm shell and its CDN tags are included; with shell == false only the host-agnostic core ships and the client binds its own shell to window.LetGoHost. With externalWasm == true the payload is delivered as a separate main.wasm the loader fetches and streams (wasmGzB64 is ignored); otherwise it is gzip-base64 inlined into the page. With hostEval == true the page exposes LetGoHost.eval (the -w-host-eval bundle); when false it is omitted, so feature detection stays honest. Pure function: same inputs produce same output. Tested via golden files in testdata/.

func RenderMain added in v1.11.0

func RenderMain(storeID string, hostEval bool) string

RenderMain fills wasmMainTmpl's placeholders: the storage-id, and the -w-host-eval splice (the window.Eval bridge + park, plus its syscall/js import). With hostEval false the marker lines are removed whole, so the default bundle's generated main is byte-identical to the pre-flag output.

Types

This section is empty.

Jump to

Keyboard shortcuts

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