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.
| Type | Description |
|---|---|
| StaticJsValue | Union of all sandbox values |
| StaticJsPrimitive | Base interface: realm, typeOf, toNative() |
| StaticJsScalar | Union of scalar types (exposes .value) |
| StaticJsObject | Base for all object-like types; full property API |
| StaticJsString | Sandboxed string |
| StaticJsNumber | Sandboxed number |
| StaticJsBoolean | Sandboxed boolean |
| StaticJsNull | Sandboxed null |
| StaticJsUndefined | Sandboxed undefined |
| StaticJsSymbol | Sandboxed symbol |
| StaticJsPlainObject | Plain {} object |
| StaticJsArray | Array instance |
| StaticJsFunction | Function and callable interface |
| StaticJsProxy | Proxy object |
Errors
Error classes thrown by the runtime or surfaced through evaluation.
| Class | When thrown |
|---|---|
| StaticJsEngineError | Internal interpreter bug or unsupported host API usage |
| StaticJsSyntaxError | Source text could not be parsed |
| StaticJsRuntimeError | Sandboxed code threw a value that propagated out of the sandbox |
| StaticJsUnhandledRejectionError | A sandbox Promise was rejected with no rejection handler |
| StaticJsConcurrentEvaluationError | A synchronous evaluation was attempted while another task was already running |
| StaticJsSynchronousTaskIncompleteError | A synchronous task runner returned without fully draining the task iterator |
| StaticJsTaskError | Base class for task lifecycle errors |
| StaticJsTaskCompletedError | A task method was called after the task already finished |
| StaticJsTaskAbortedError | A task method was called on an aborted task, or used as the default abort reason |