Help us shape the future of Go! Take the 2026 Go Developer Survey

scriptc

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package scriptc downloads the scriptc compiler and fits a module it compiled as a WASI reactor to the mod boundary, so the host runs it as it runs any other mod.

scriptc imports its host callbacks and its panic sink from the scriptc module, starts with _initialize and a separate init export, and returns an export's bytes through two out-pointers. The fit renames the callbacks' module to modlock, replaces the panic import with a function that logs the panic through host_call and traps, makes _initialize run the init export, and adds modlock_event, which packs the reply's address and length.

LowerJSX prepares a mod's TSX sources for scriptc, which compiles no JSX.

Index

Constants

View Source
const (
	// InitExport is the profile's init symbol, which sets up the library.
	InitExport = "mod_init"
	// EventExport is the profile's event export. It takes the size of the
	// call the host holds and returns the encoded reply.
	EventExport = "mod_event"
)

The build's scriptc profile declares these symbols.

View Source
const Version = "0.3.6-paralin.3"

Version is the scriptc release that builds script mods. It comes from the paralin/scriptc fork, which carries compiler fixes upstream has not released yet.

Variables

This section is empty.

Functions

func Compiler

func Compiler(ctx context.Context) (compiler, pack string, err error)

Compiler returns the scriptc compiler for this system and the runtime pack it links WebAssembly modules against.

func Fit

func Fit(wasm []byte) ([]byte, error)

Fit returns wasm, a module scriptc built with the profile's InitExport and EventExport, rewritten to import only from modlock and WASI and to export memory, _initialize and modlock_event.

func LowerJSX

func LowerJSX(source []byte) ([]byte, error)

LowerJSX rewrites the JSX in one TSX source file as calls to the modlock library's jsx, since scriptc compiles TypeScript but not JSX. An element becomes jsx(type, props, key). A component renders in place inside a fragment, and a fragment element holds its children, as the library's jsx builds them at run time, so both runtimes build the same tree. Each element keeps the lines it spanned, so the code after it keeps its line numbers.

func Profile

func Profile(entry string) []byte

Profile returns the scriptc profile that builds the module at entry, a path relative to the profile, into one that Fit accepts. The entry declares host_call and host_read and exports event.

Types

This section is empty.

Jump to

Keyboard shortcuts

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