Skip to content

Latest commit

 

History

History
1704 lines (972 loc) · 49.5 KB

File metadata and controls

1704 lines (972 loc) · 49.5 KB

quickjs-emscriptenquickjs-emscriptenReadme | Exports


quickjs-emscripten / quickjs-emscripten

quickjs-emscripten

Contents

Namespaces

Classes

Interfaces

Type Aliases

AsyncFunctionImplementation

AsyncFunctionImplementation: (this, ...args) => Promise<QuickJSHandle | VmCallResult<QuickJSHandle> | void>

Parameters

this: QuickJSHandle

• ...args: QuickJSHandle[]

Returns

Promise<QuickJSHandle | VmCallResult<QuickJSHandle> | void>

Source

packages/quickjs-emscripten-core/src/context-asyncify.ts:18


BorrowedHeapCharPointer

BorrowedHeapCharPointer: Pointer<"const char" | "char" | "js const char">

Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.

Source

packages/quickjs-ffi-types/dist/index.d.ts:70


DisposableArray<T>

DisposableArray<T>: T[] & Disposable

An Array that also implements Disposable:

Type parameters

T

Source

packages/quickjs-emscripten-core/src/lifetime.ts:354


DisposableResult<S, F>

DisposableResult<S, F>: DisposableSuccess<S> | DisposableFail<F>

Type parameters

S

F

Source

packages/quickjs-emscripten-core/src/lifetime.ts:478


EitherFFI

EitherFFI: QuickJSFFI | QuickJSAsyncFFI

Source

packages/quickjs-ffi-types/dist/index.d.ts:538


EitherModule

EitherModule: QuickJSEmscriptenModule | QuickJSAsyncEmscriptenModule

Source

packages/quickjs-ffi-types/dist/index.d.ts:332


ExecutePendingJobsResult

ExecutePendingJobsResult: DisposableResult<number, QuickJSHandle & Object>

Used as an optional for the results of executing pendingJobs. On success, value contains the number of async jobs executed by the runtime.

Source

Source

packages/quickjs-emscripten-core/src/runtime.ts:35


InterruptHandler

InterruptHandler: (runtime) => boolean | undefined | void

Callback called regularly while the VM executes code. Determines if a VM's execution should be interrupted.

Parameters

runtime: QuickJSRuntime

Returns

boolean | undefined | void

true to interrupt JS execution inside the VM.

false or undefined to continue JS execution inside the VM.

Source

packages/quickjs-emscripten-core/src/runtime.ts:27


Intrinsics

Intrinsics: Object

Language features that can be enabled or disabled in a QuickJSContext.

See

ContextOptions

Type declaration

BaseObjects?

BaseObjects?: boolean

BigDecimal?

BigDecimal?: boolean

BigFloat?

BigFloat?: boolean

BigInt?

BigInt?: boolean

BignumExt?

BignumExt?: boolean

Date?

Date?: boolean

Eval?

Eval?: boolean

JSON?

JSON?: boolean

MapSet?

MapSet?: boolean

OperatorOverloading?

OperatorOverloading?: boolean

Promise?

Promise?: boolean

Proxy?

Proxy?: boolean

RegExp?

RegExp?: boolean

RegExpCompiler?

RegExpCompiler?: boolean

StringNormalize?

StringNormalize?: boolean

TypedArrays?

TypedArrays?: boolean

Source

packages/quickjs-emscripten-core/src/types.ts:146


JSBorrowedCharPointer

JSBorrowedCharPointer: Pointer<"js const char">

Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.

Source

packages/quickjs-ffi-types/dist/index.d.ts:80


JSContextPointer

JSContextPointer: Pointer<"JSContext">

JSContext*.

Source

packages/quickjs-ffi-types/dist/index.d.ts:20


JSContextPointerPointer

JSContextPointerPointer: Pointer<"JSContext">

JSContext**. Used internally for execute pending jobs.

Source

packages/quickjs-ffi-types/dist/index.d.ts:24


JSModuleDefPointer

JSModuleDefPointer: Pointer<"JSModuleDef">

JSModuleDef*.

Source

packages/quickjs-ffi-types/dist/index.d.ts:28


JSModuleLoadFailure

JSModuleLoadFailure: Error | QuickJSHandle

Source

packages/quickjs-emscripten-core/src/types.ts:69


JSModuleLoadResult

JSModuleLoadResult: JSModuleLoadSuccess | SuccessOrFail<JSModuleLoadSuccess, JSModuleLoadFailure>

Source

packages/quickjs-emscripten-core/src/types.ts:70


JSModuleLoadSuccess

JSModuleLoadSuccess: string

Source

packages/quickjs-emscripten-core/src/types.ts:68


JSModuleNormalizeFailure

JSModuleNormalizeFailure: Error | QuickJSHandle

Source

packages/quickjs-emscripten-core/src/types.ts:87


JSModuleNormalizeResult

JSModuleNormalizeResult: JSModuleNormalizeSuccess | SuccessOrFail<JSModuleNormalizeSuccess, JSModuleNormalizeFailure>

Source

packages/quickjs-emscripten-core/src/types.ts:88


JSModuleNormalizeSuccess

JSModuleNormalizeSuccess: string

Source

packages/quickjs-emscripten-core/src/types.ts:86


JSPromiseState

JSPromiseState: JSPromiseStatePending | JSPromiseStateFulfilled | JSPromiseStateRejected

A promise state inside QuickJS, which can be pending, fulfilled, or rejected. You can unwrap a JSPromiseState with QuickJSContext#unwrapResult.

Source

packages/quickjs-emscripten-core/src/deferred-promise.ts:11


JSPromiseStateEnum

JSPromiseStateEnum: Brand<typeof JSPromiseStateEnum[keyof typeof JSPromiseStateEnum], "JSPromiseStateEnum">

State of a promise.

Source

packages/quickjs-ffi-types/dist/index.d.ts:145


JSRuntimePointer

JSRuntimePointer: Pointer<"JSRuntime">

JSRuntime*.

Source

packages/quickjs-ffi-types/dist/index.d.ts:16


JSValue

JSValue: Lifetime<JSValuePointer, JSValuePointer, QuickJSRuntime>

A owned QuickJSHandle that should be disposed or returned.

The QuickJS interpreter passes Javascript values between functions as JSValue structs that references some internal data. Because passing structs cross the Empscripten FFI interfaces is bothersome, we use pointers to these structs instead.

A JSValue reference is "owned" in its scope. before exiting the scope, it should be freed, by calling JS_FreeValue(ctx, js_value)) or returned from the scope. We extend that contract - a JSValuePointer (JSValue*) must also be freed.

You can do so from Javascript by calling the .dispose() method.

Source

packages/quickjs-emscripten-core/src/types.ts:43


JSValueConst

JSValueConst: Lifetime<JSValueConstPointer, JSValuePointer, QuickJSRuntime>

A QuickJSHandle to a borrowed value that does not need to be disposed.

In QuickJS, a JSValueConst is a "borrowed" reference that isn't owned by the current scope. That means that the current scope should not JS_FreeValue it, or retain a reference to it after the scope exits, because it may be freed by its owner.

quickjs-emscripten takes care of disposing JSValueConst references.

Source

packages/quickjs-emscripten-core/src/types.ts:26


JSValueConstPointer

JSValueConstPointer: Pointer<"JSValueConst">

`JSValueConst* See JSValueConst and StaticJSValue.

Source

packages/quickjs-ffi-types/dist/index.d.ts:38


JSValueConstPointerPointer

JSValueConstPointerPointer: Pointer<"JSValueConst[]">

Used internally for Javascript-to-C function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:50


JSValuePointer

JSValuePointer: Pointer<"JSValue">

JSValue*. See JSValue.

Source

packages/quickjs-ffi-types/dist/index.d.ts:33


JSValuePointerPointer

JSValuePointerPointer: Pointer<"JSValue[]">

Used internally for Javascript-to-C function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:42


JSValuePointerPointerPointer

JSValuePointerPointerPointer: Pointer<"*JSValue[]">

Used internally for Javascript-to-C function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:46


JSVoidPointer

JSVoidPointer: Pointer<any>

Opaque pointer that was allocated by js_malloc.

Source

packages/quickjs-ffi-types/dist/index.d.ts:84


OrLoader<T>

OrLoader<T>: T | () => Promise<T>

Type parameters

T

Source

packages/quickjs-emscripten-core/src/from-variant.ts:117


OwnedHeapCharPointer

OwnedHeapCharPointer: Pointer<"char">

Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.

Source

packages/quickjs-ffi-types/dist/index.d.ts:75


PromiseExecutor<ResolveT, RejectT>

PromiseExecutor<ResolveT, RejectT>: (resolve, reject) => void

Type parameters

ResolveT

RejectT

Parameters

resolve: (value) => void

reject: (reason) => void

Returns

void

Source

packages/quickjs-emscripten-core/src/types.ts:333


PromisedDefault<T>

PromisedDefault<T>: T | Promise<T> | Promise<Object> | Promise<Object>

Type parameters

T

Source

packages/quickjs-emscripten-core/src/from-variant.ts:17


QTS_C_To_HostCallbackFuncPointer

QTS_C_To_HostCallbackFuncPointer: Pointer<"C_To_HostCallbackFunc">

Used internally for C-to-Javascript function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:57


QTS_C_To_HostInterruptFuncPointer

QTS_C_To_HostInterruptFuncPointer: Pointer<"C_To_HostInterruptFunc">

Used internally for C-to-Javascript interrupt handlers.

Source

packages/quickjs-ffi-types/dist/index.d.ts:61


QTS_C_To_HostLoadModuleFuncPointer

QTS_C_To_HostLoadModuleFuncPointer: Pointer<"C_To_HostLoadModuleFunc">

Used internally for C-to-Javascript module loading.

Source

packages/quickjs-ffi-types/dist/index.d.ts:65


QuickJSHandle

QuickJSHandle: StaticJSValue | JSValue | JSValueConst

Wraps a C pointer to a QuickJS JSValue, which represents a Javascript value inside a QuickJS virtual machine.

Values must not be shared between QuickJSContext instances. You must dispose of any handles you create by calling the .dispose() method.

Source

packages/quickjs-emscripten-core/src/types.ts:53


QuickJSPropertyKey

QuickJSPropertyKey: number | string | QuickJSHandle

Property key for getting or setting a property on a handle with QuickJSContext#getProp, QuickJSContext#setProp, or QuickJSContext#defineProp.

Source

packages/quickjs-emscripten-core/src/context.ts:68


QuickJSVariant

QuickJSVariant: QuickJSSyncVariant | QuickJSAsyncVariant

Source

packages/quickjs-ffi-types/dist/index.d.ts:537


StaticJSValue

StaticJSValue: Lifetime<JSValueConstPointer, JSValueConstPointer, QuickJSRuntime>

A QuickJSHandle to a constant that will never change, and does not need to be disposed.

Source

packages/quickjs-emscripten-core/src/types.ts:14


SuccessOrFail<S, F>

SuccessOrFail<S, F>: Object | Object

Used as an optional. { value: S } | { error: E }.

Type parameters

S

F

Source

packages/quickjs-emscripten-core/src/vm-interface.ts:5


UInt32Pointer

UInt32Pointer: Pointer<"uint32_t">

Source

packages/quickjs-ffi-types/dist/index.d.ts:85


VmCallResult<VmHandle>

VmCallResult<VmHandle>: SuccessOrFail<VmHandle, VmHandle>

Used as an optional for results of a Vm call. { value: VmHandle } | { error: VmHandle }.

Type parameters

VmHandle

Source

packages/quickjs-emscripten-core/src/vm-interface.ts:26


VmFunctionImplementation<VmHandle>

VmFunctionImplementation<VmHandle>: (this, ...args) => VmHandle | VmCallResult<VmHandle> | void

Type parameters

VmHandle

A VmFunctionImplementation takes handles as arguments. It should return a handle, or be void.

To indicate an exception, a VMs can throw either a handle (transferred directly) or any other Javascript value (only the poperties name and message will be transferred). Or, the VmFunctionImplementation may return a VmCallResult's { error: handle } error variant.

VmFunctionImplementation should not free its arguments or its return value. It should not retain a reference to its return value or thrown error.

Parameters

this: VmHandle

• ...args: VmHandle[]

Returns

VmHandle | VmCallResult<VmHandle> | void

Source

packages/quickjs-emscripten-core/src/vm-interface.ts:40

Variables

DEBUG_ASYNC

const DEBUG_ASYNC: QuickJSAsyncVariant

@jitl/quickjs-wasmfile-debug-asyncify

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15.
releaseMode debug Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs.
syncMode asyncify Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-debug-asyncify/dist/index.d.ts:18


DEBUG_SYNC

const DEBUG_SYNC: QuickJSSyncVariant

@jitl/quickjs-wasmfile-debug-sync

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15.
releaseMode debug Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs.
syncMode sync The default, normal build. Note that both variants support regular async functions.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-debug-sync/dist/index.d.ts:18


DefaultIntrinsics

const DefaultIntrinsics: Readonly<Object>

The default Intrinsics language features enabled in a QuickJSContext.

See

ContextOptions

Type declaration

BaseObjects

readonly BaseObjects: true = true

Date

readonly Date: true = true

Eval

readonly Eval: true = true

JSON

readonly JSON: true = true

MapSet

readonly MapSet: true = true

Promise

readonly Promise: true = true

Proxy

readonly Proxy: true = true

RegExp

readonly RegExp: true = true

StringNormalize

readonly StringNormalize: true = true

TypedArrays

readonly TypedArrays: true = true

Source

packages/quickjs-emscripten-core/src/types.ts:173


DisposableResult

DisposableResult: typeof AbstractDisposableResult

Source

packages/quickjs-emscripten-core/src/lifetime.ts:478


EvalFlags

EvalFlags: Object

Bitfield options for JS_Eval() C function.

Type declaration

JS_EVAL_FLAG_BACKTRACE_BARRIER

readonly JS_EVAL_FLAG_BACKTRACE_BARRIER: number

don't include the stack frames before this eval in the Error() backtraces

JS_EVAL_FLAG_COMPILE_ONLY

readonly JS_EVAL_FLAG_COMPILE_ONLY: number

compile but do not run. The result is an object with a JS_TAG_FUNCTION_BYTECODE or JS_TAG_MODULE tag. It can be executed with JS_EvalFunction().

JS_EVAL_FLAG_STRICT

readonly JS_EVAL_FLAG_STRICT: number

force 'strict' mode

JS_EVAL_FLAG_STRIP

readonly JS_EVAL_FLAG_STRIP: number

force 'strip' mode

JS_EVAL_TYPE_DIRECT

readonly JS_EVAL_TYPE_DIRECT: number

direct call (internal use)

JS_EVAL_TYPE_GLOBAL

readonly JS_EVAL_TYPE_GLOBAL: number

global code (default)

JS_EVAL_TYPE_INDIRECT

readonly JS_EVAL_TYPE_INDIRECT: number

indirect call (internal use)

JS_EVAL_TYPE_MASK

readonly JS_EVAL_TYPE_MASK: number

JS_EVAL_TYPE_MODULE

readonly JS_EVAL_TYPE_MODULE: number

module code

Source

packages/quickjs-ffi-types/dist/index.d.ts:94


GetOwnPropertyNamesFlags

GetOwnPropertyNamesFlags: Object

Bitfield options for QTS_GetOwnPropertyNames

Type declaration

JS_GPN_ENUM_ONLY

JS_GPN_ENUM_ONLY: number

JS_GPN_PRIVATE_MASK

JS_GPN_PRIVATE_MASK: number

JS_GPN_SET_ENUM

JS_GPN_SET_ENUM: number

JS_GPN_STRING_MASK

JS_GPN_STRING_MASK: number

JS_GPN_SYMBOL_MASK

JS_GPN_SYMBOL_MASK: number

QTS_GPN_NUMBER_MASK

QTS_GPN_NUMBER_MASK: number

QTS_STANDARD_COMPLIANT_NUMBER

QTS_STANDARD_COMPLIANT_NUMBER: number

Source

packages/quickjs-ffi-types/dist/index.d.ts:154


IntrinsicsFlags

IntrinsicsFlags: Object

Bitfield options for QTS_NewContext intrinsics

Type declaration

BaseObjects

readonly BaseObjects: number

BigDecimal

readonly BigDecimal: number

BigFloat

readonly BigFloat: number

BigInt

readonly BigInt: number

BignumExt

readonly BignumExt: number

Date

readonly Date: number

Eval

readonly Eval: number

JSON

readonly JSON: number

MapSet

readonly MapSet: number

OperatorOverloading

readonly OperatorOverloading: number

Promise

readonly Promise: number

Proxy

readonly Proxy: number

RegExp

readonly RegExp: number

RegExpCompiler

readonly RegExpCompiler: number

StringNormalize

readonly StringNormalize: number

TypedArrays

readonly TypedArrays: number

Source

packages/quickjs-ffi-types/dist/index.d.ts:122


IsEqualOp

IsEqualOp: Object

Type declaration

IsSameValue

IsSameValue: IsEqualOp

IsSameValueZero

IsSameValueZero: IsEqualOp

IsStrictlyEqual

IsStrictlyEqual: IsEqualOp

Source

packages/quickjs-ffi-types/dist/index.d.ts:168


JSPromiseStateEnum

JSPromiseStateEnum: Object

Type declaration

Fulfilled

readonly Fulfilled: 1

Pending

readonly Pending: 0

Rejected

readonly Rejected: 2

Source

packages/quickjs-ffi-types/dist/index.d.ts:145


RELEASE_ASYNC

const RELEASE_ASYNC: QuickJSAsyncVariant

@jitl/quickjs-wasmfile-release-asyncify

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15.
releaseMode release Optimized for performance; use when building/deploying your application.
syncMode asyncify Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-release-asyncify/dist/index.d.ts:18


RELEASE_SYNC

const RELEASE_SYNC: QuickJSSyncVariant

@jitl/quickjs-wasmfile-release-sync

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15.
releaseMode release Optimized for performance; use when building/deploying your application.
syncMode sync The default, normal build. Note that both variants support regular async functions.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-release-sync/dist/index.d.ts:18

Functions

assertSync()

assertSync<Args, R>(fn): (...args) => R

Type parameters

Args extends any[]

R

Parameters

fn: (...args) => R

Returns

Function

Parameters

• ...args: Args

Returns

R

Source

packages/quickjs-ffi-types/dist/index.d.ts:90


createDisposableArray()

createDisposableArray<T>(items?): DisposableArray<T>

Create an array that also implements Disposable.

Type parameters

T extends Disposable

Parameters

items?: Iterable<T>

Returns

DisposableArray<T>

Source

packages/quickjs-emscripten-core/src/lifetime.ts:359


getQuickJS()

getQuickJS(): Promise<QuickJSWASMModule>

Get a shared singleton QuickJSWASMModule. Use this to evaluate code or create Javascript environments.

This is the top-level entrypoint for the quickjs-emscripten library.

If you need strictest possible isolation guarantees, you may create a separate QuickJSWASMModule via newQuickJSWASMModule.

To work with the asyncified version of this library, see these functions:

Returns

Promise<QuickJSWASMModule>

Source

packages/quickjs-emscripten/src/mod.ts:28


getQuickJSSync()

getQuickJSSync(): QuickJSWASMModule

Provides synchronous access to the shared QuickJSWASMModule instance returned by getQuickJS, as long as least once.

Returns

QuickJSWASMModule

Throws

If called before getQuickJS resolves.

Source

packages/quickjs-emscripten/src/mod.ts:41


isFail()

isFail<S, F>(successOrFail): successOrFail is Object

Type parameters

S

F

Parameters

successOrFail: SuccessOrFail<S, F>

Returns

successOrFail is Object

Source

packages/quickjs-emscripten-core/src/vm-interface.ts:18


isSuccess()

isSuccess<S, F>(successOrFail): successOrFail is Object

Type parameters

S

F

Parameters

successOrFail: SuccessOrFail<S, F>

Returns

successOrFail is Object

Source

packages/quickjs-emscripten-core/src/vm-interface.ts:14


memoizePromiseFactory()

memoizePromiseFactory<T>(fn): () => Promise<T>

Helper intended to memoize the creation of a WebAssembly module.

const getDebugModule = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))

Type parameters

T

Parameters

fn: () => Promise<T>

Returns

Function

Returns

Promise<T>

Source

packages/quickjs-emscripten-core/src/from-variant.ts:100


newAsyncContext()

newAsyncContext(options?): Promise<QuickJSAsyncContext>

Create a new QuickJSAsyncContext (with an associated runtime) in an separate WebAssembly module.

Each context is isolated in a separate WebAssembly module, so that errors in one runtime cannot contaminate another runtime, and each runtime can execute an asynchronous action without conflicts.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

options?: ContextOptions

Returns

Promise<QuickJSAsyncContext>

Source

packages/quickjs-emscripten/src/mod.ts:76


newAsyncRuntime()

newAsyncRuntime(options?): Promise<QuickJSAsyncRuntime>

Create a new QuickJSAsyncRuntime in a separate WebAssembly module.

Each runtime is isolated in a separate WebAssembly module, so that errors in one runtime cannot contaminate another runtime, and each runtime can execute an asynchronous action without conflicts.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

options?: AsyncRuntimeOptions

Returns

Promise<QuickJSAsyncRuntime>

Source

packages/quickjs-emscripten/src/mod.ts:59


newQuickJSAsyncWASMModule()

newQuickJSAsyncWASMModule(variantOrPromise): Promise<QuickJSAsyncWASMModule>

Create a new, completely isolated WebAssembly module containing a version of the QuickJS library compiled with Emscripten's ASYNCIFY transform.

This version of the library offers features that enable synchronous code inside the VM to interact with asynchronous code in the host environment. See the documentation on QuickJSAsyncWASMModule, QuickJSAsyncRuntime, and QuickJSAsyncContext.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSAsyncVariant>= RELEASE_ASYNC

Optionally, pass a QuickJSAsyncVariant to construct a different WebAssembly module.

Returns

Promise<QuickJSAsyncWASMModule>

Source

packages/quickjs-emscripten/src/variants.ts:47


newQuickJSAsyncWASMModuleFromVariant()

newQuickJSAsyncWASMModuleFromVariant(variantOrPromise): Promise<QuickJSAsyncWASMModule>

Create a new, completely isolated WebAssembly module containing a version of the QuickJS library compiled with Emscripten's ASYNCIFY transform.

This version of the library offers features that enable synchronous code inside the VM to interact with asynchronous code in the host environment. See the documentation on QuickJSAsyncWASMModule, QuickJSAsyncRuntime, and QuickJSAsyncContext.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSAsyncVariant>

A QuickJSAsyncVariant to construct the WebAssembly module.

Returns

Promise<QuickJSAsyncWASMModule>

Example

const quickjs = new newQuickJSAsyncWASMModuleFromVariant(
  import('@jitl/quickjs-browser-debug-asyncify-wasm')
)

Source

packages/quickjs-emscripten-core/src/from-variant.ts:76


newQuickJSWASMModule()

newQuickJSWASMModule(variantOrPromise): Promise<QuickJSWASMModule>

Create a new, completely isolated WebAssembly module containing the QuickJS library. See the documentation on QuickJSWASMModule.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSSyncVariant>= RELEASE_SYNC

Optionally, pass a QuickJSSyncVariant to construct a different WebAssembly module.

Returns

Promise<QuickJSWASMModule>

Source

packages/quickjs-emscripten/src/variants.ts:25


newQuickJSWASMModuleFromVariant()

newQuickJSWASMModuleFromVariant(variantOrPromise): Promise<QuickJSWASMModule>

Create a new, completely isolated WebAssembly module containing the QuickJS library. See the documentation on QuickJSWASMModule.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSSyncVariant>

A QuickJSSyncVariant to construct the WebAssembly module.

Returns

Promise<QuickJSWASMModule>

Example

const quickjs = new newQuickJSWASMModuleFromVariant(
  import('@jitl/quickjs-browser-release-sync-wasm')
)

Source

packages/quickjs-emscripten-core/src/from-variant.ts:38


newVariant()

newVariant<T>(baseVariant, options): T

Create a new variant by overriding how Emscripten obtains the WebAssembly module. This may be necessary in Cloudflare Workers, which can't compile WebAssembly modules from binary data.

Type parameters

T extends QuickJSVariant

Parameters

baseVariant: T

options: CustomizeVariantOptions

Returns

T

Source

packages/quickjs-emscripten-core/src/from-variant.ts:162


setDebugMode()

setDebugMode(enabled): void

Enable (or disable) debug logging and object creation tracking globally. This setting is inherited by newly created QuickJSRuntime instances. To get debug logging in the WebAssembly module, you need to use a debug build variant. See the quickjs-emscripten-core README for more about build variants.

Parameters

enabled: boolean= true

Returns

void

Source

packages/quickjs-emscripten-core/src/debug.ts:13


shouldInterruptAfterDeadline()

shouldInterruptAfterDeadline(deadline): InterruptHandler

Returns an interrupt handler that interrupts Javascript execution after a deadline time.

Parameters

deadline: number | Date

Interrupt execution if it's still running after this time. Number values are compared against Date.now()

Returns

InterruptHandler

Source

packages/quickjs-emscripten-core/src/interrupt-helpers.ts:9


Generated using typedoc-plugin-markdown and TypeDoc