Skip to main content

API Reference

Complete reference for the @suntime-js/core public API.


StaticJsRealm

The root object for a sandboxed JavaScript environment. Each realm holds its own prototypes, global object, type factory, and task queue. Everything else in the API is accessed through or created by a realm.

Key members: types, global, globalThis, evaluateScript, evaluateScriptSync, evaluateModule, awaitIdle


StaticJsTypeFactory

Accessed via realm.types. Creates and coerces all sandbox values: booleans, numbers, strings, objects, arrays, functions, symbols, and proxies. Also exposes well-known singleton values (undefined, null, true, false) and the intrinsic symbol registry.

Key members: boolean, number, string, object, array, function, error, proxy, toStaticJsValue


StaticJsModule

Returned by realm.evaluateModule() and passed to module resolver callbacks. Exposes named exports as StaticJsValue instances or coerced native values. Also documents StaticJsModuleResolver, StaticJsModuleResolution, and StaticJsRealmModuleExports.

Key members: getExportedNames, getExportAsync, getExportJsSync, getModuleNamespaceAsync, getModuleNamespaceJsSync


StaticJsTaskIterator

The iterator interface passed to task runners. Each call to .next() evaluates one operation in the sandbox. Exposes introspection (location, stack, currentTaskType) and control (abort, throw).

Also documents the built-in task runners createTimeBoundTaskRunner and createTimeSharingTaskRunner.

Key members: done, async, next(), abort(), location, stack


Types

The core types used by StaticJs.

TypeDescription
StaticJsValueUnion of all sandbox values
StaticJsPrimitiveBase interface: realm, typeOf, toNative()
StaticJsScalarUnion of scalar types (exposes .value)
StaticJsObjectBase for all object-like types; full property API
StaticJsStringSandboxed string
StaticJsNumberSandboxed number
StaticJsBooleanSandboxed boolean
StaticJsNullSandboxed null
StaticJsUndefinedSandboxed undefined
StaticJsSymbolSandboxed symbol
StaticJsPlainObjectPlain {} object
StaticJsArrayArray instance
StaticJsFunctionFunction and callable interface
StaticJsProxyProxy object

Errors

Error classes thrown by the runtime or surfaced through evaluation.

ClassWhen thrown
StaticJsEngineErrorInternal interpreter bug or unsupported host API usage
StaticJsSyntaxErrorSource text could not be parsed
StaticJsRuntimeErrorSandboxed code threw a value that propagated out of the sandbox
StaticJsUnhandledRejectionErrorA sandbox Promise was rejected with no rejection handler
StaticJsConcurrentEvaluationErrorA synchronous evaluation was attempted while another task was already running
StaticJsSynchronousTaskIncompleteErrorA synchronous task runner returned without fully draining the task iterator
StaticJsTaskErrorBase class for task lifecycle errors
StaticJsTaskCompletedErrorA task method was called after the task already finished
StaticJsTaskAbortedErrorA task method was called on an aborted task, or used as the default abort reason