Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ExportInit is the function to initialize an empty QuickJS runtime. // Signature: qjs_init() -> i32 (0 on success) ExportInit = "qjs_init" // ExportInitArgv is the function to initialize QuickJS with CLI arguments. // This can be used to pass flags like --std or load scripts via WASI filesystem. // Signature: qjs_init_argv(argc: i32, argv: i32) -> i32 (0 on success) ExportInitArgv = "qjs_init_argv" // ExportEval is the function to evaluate JavaScript code. // Signature: qjs_eval(code: i32, len: i32, filename: i32, is_module: i32) -> i32 // The filename parameter is a pointer to a null-terminated string (or 0 for default). ExportEval = "qjs_eval" // ExportLoopOnce runs one iteration of the event loop. // Signature: qjs_loop_once() -> i32 // Returns: // >0: next timer fires in N ms // 0: more microtasks pending, call again immediately // -1: idle, no pending work // -2: error occurred ExportLoopOnce = "qjs_loop_once" // ExportPollIO polls for I/O events and invokes registered read/write handlers. // This must be called when the host knows stdin (or other fds) have data available. // Signature: qjs_poll_io(timeout_ms: i32) -> i32 // Parameters: // timeout_ms: Poll timeout in milliseconds // 0 = non-blocking (check and return immediately) // >0 = wait up to timeout_ms for I/O events // -1 = block indefinitely (not recommended) // Returns: // 0: success (handler invoked or no handlers registered) // -1: error or no I/O handlers // -2: not initialized or exception in handler ExportPollIO = "qjs_poll_io" // ExportDestroy cleans up the QuickJS runtime. // Signature: qjs_destroy() -> void ExportDestroy = "qjs_destroy" // ExportMalloc allocates memory in WASM linear memory. // Signature: malloc(size: i32) -> i32 (pointer) ExportMalloc = "malloc" // ExportFree frees memory in WASM linear memory. // Signature: free(ptr: i32) -> void ExportFree = "free" )
Reactor export function names
View Source
const ( // LoopResultIdle indicates no pending work (-1) LoopResultIdle = -1 // LoopResultError indicates an error occurred (-2) LoopResultError = -2 )
Loop result constants from qjs_loop_once()
View Source
const ( // Version is the QuickJS-NG reactor version Version = "v0.11.0-wasi29-reactor-r3" // DownloadURL is the URL where this WASM file was downloaded from DownloadURL = "https://github.com/paralin/quickjs/releases/download/v0.11.0-wasi29-reactor-r3/qjs-wasi-reactor.wasm" )
QuickJS-NG WASI Reactor version information
View Source
const QuickJSWASMFilename = "qjs-wasi.wasm"
QuickJSWASMFilename is the filename for QuickJSWASM.
Variables ¶
View Source
var QuickJSWASM []byte
QuickJSWASM contains the binary contents of the QuickJS WASI reactor build.
This is a reactor-model WASM that exports functions for re-entrant execution in host environments. Unlike the command model which blocks in _start(), the reactor model allows the host to control execution flow.
Exported functions:
- qjs_init() - Initialize empty runtime
- qjs_init_argv(argc, argv) - Initialize with CLI args (e.g. ["qjs", "--std", "script.js"])
- qjs_eval(code, len, filename, is_module) - Evaluate JS code from WASM memory
- qjs_loop_once() - Run one iteration of the event loop (non-blocking)
- qjs_poll_io(timeout_ms) - Poll for I/O and invoke read/write handlers
- qjs_destroy() - Cleanup runtime
- malloc/free - For host to allocate memory for code strings
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.