quickjs-emscripten
Advanced tools
Changelog
v0.24.0
#127 Upgrade to quickjs 2023-12-09:
#125 (thanks to @tbrockman):
#111 (thanks to @yourWaifu) ArrayBuffer and binary json encoding:
context.newArrayBuffer(bufferLike)
creates an ArrayBuffer in the VM from a buffer-like object.context.getArrayBuffer(handle)
creates a view on an ArrayBuffer in the VM as a UInt8Array on the host.context.encodeBinaryJSON(handle)
encodes a QuickJS handle in QuickJS's binary format (like JSON.stringify)context.decodeBinaryJSON(handle)
decodes a QuickJS handle containing the binary format (like JSON.parse)Changelog
v0.23.0
QuickJSAsyncRuntime.setMaxStackSize(stackSizeBytes)
now also adjusts the ASYNCIFY_STACK_SIZE for the entire module.Changelog
v0.22.0
#78, #105 (thanks to @ayaboy) add Symbol helpers context.newUniqueSymbol
, context.newSymbolFor
, as well as support for symbols in context.dump
.
#104 BigInt support.
#100 Breaking change upgrade Emscripten version and switch to async import(...)
for loading variants.
We also drop support for older browsers and Node versions:
Changelog
v0.20.0
This is a large release! The summary is:
This release introduces class QuickJSRuntime
. This class wraps QuickJS's JSRuntime*
type:
JSRuntime
represents a Javascript runtime corresponding to an object heap. Several runtimes can exist at the same time but they cannot exchange objects. Inside a given runtime, no multi-threading is supported.
QuickJSRuntime.newContext
creates a new context inside an existing runtime.QuickJSRuntime.setModuleLoader
enables EcmaScript module loading.This release renames QuickJSVm
to class QuickJSContext
, and removes some methods.
The new class wraps QuickJS's JSContext*
type:
JSContext
represents a Javascript context (or Realm). Each JSContext has its own global objects and system objects. There can be several JSContexts per JSRuntime [...], similar to frames of the same origin sharing Javascript objects in a web browser.
QuickJSContext
replaces QuickJSVm
as the main way to interact with the
environment inside the QuickJS virtual machine.
QuickJSContext.runtime
provides access to a context's parent runtime.QuickJSContext.evalCode
now takes an options argument to set eval mode
to 'module'
.There are also Asyncified versions of both QuickJSRuntime
(QuickJSRuntimeAsync
) and QuickJSContext
(QuickJSContextAsync
). These variants trade some runtime performance for additional features.
QuickJSRuntimeAsync.setModuleLoader
accepts module loaders that return
Promise<string>
.QuickJSContextAsync.newAsyncifiedFunction
allows creating async functions that
act like sync functions inside the VM.class QuickJSVm
is removed. Most functionality is available on
QuickJSContext
, with identical function signatures. Functionality related to
runtime limits, memory limits, and pending jobs moved to QuickJSRuntime
.
Migration guide:
vm.hasPendingJob
-> context.runtime.hasPendingJob
vm.setInterruptHandler
-> context.runtime.setInterruptHandler
vm.removeInterruptHandler
-> context.runtime.removeInterruptHandler
vm.executePendingJobs
-> context.runtime.executePendingJobs
vm.setMemoryLimit
-> context.runtime.setMemoryLimit
vm.computeMemoryUsage
-> context.runtime.computeMemoryUsage
QuickJS.createVm()
is removed.
Migration guide: use QuickJS.newContext()
instead.