Skip to content

Commit 8e9ecb2

Browse files
committed
start writing changelog
1 parent dc38ad3 commit 8e9ecb2

9 files changed

+197
-141
lines changed

Diff for: .prettierrc

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"semi": false,
3-
"singleQuote": true,
2+
"tabWidth": 2,
3+
"useTabs": false,
44
"printWidth": 100,
5-
"trailingComma": "es5",
6-
"arrowParens": "avoid"
5+
"semi": false
76
}

Diff for: CHANGELOG.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Changelog
2+
3+
## v0.20.0
4+
5+
This is a large release! The summary is:
6+
7+
- There are several breaking API changes to align our abstractions with the
8+
underlying QuickJS library.
9+
- There's a new build variant build with [Emscripten's
10+
ASYNCIFY](https://emscripten.org/docs/porting/asyncify.html) that allows
11+
_synchronous_ code _inside_ QuickJS to use _asynchronous_ code running on the
12+
host.
13+
- Both build variants have basic support for loading and evaluating EcmaScript
14+
modules, but only the ASYNCIFY variant can asynchronously load EcmaScript code.
15+
16+
### New features
17+
18+
This release introduces `class QuickJSRuntime`. This class wraps QuickJS's `JSRuntime*` type:
19+
20+
> `JSRuntime` represents a Javascript runtime corresponding to an object heap.
21+
> Several runtimes can exist at the same time but they cannot exchange objects.
22+
> Inside a given runtime, no multi-threading is supported.
23+
24+
- `QuickJSRuntime.newContext` creates a new context inside an existing runtime.
25+
- `QuickJSRuntime.setModuleLoader` enables EcmaScript module loading.
26+
27+
This release renames `QuickJSVm` to `class QuickJSContext`, and removes some methods.
28+
The new class wraps QuickJS's `JSContext*` type:
29+
30+
> `JSContext` represents a Javascript context (or Realm). Each JSContext has its
31+
> own global objects and system objects. There can be several JSContexts per
32+
> JSRuntime \[...], similar to frames of the same origin
33+
> sharing Javascript objects in a web browser.
34+
35+
`QuickJSContext` replaces `QuickJSVm` as the main way to interact with the
36+
environment inside the QuickJS virtual machine.
37+
38+
- `QuickJSContext.runtime` provides access to a context's parent runtime.
39+
- `QuickJSContext.evalCode` now takes an options argument to set eval mode
40+
to `'module'`.
41+
42+
There are also **Asyncified** versions of both `QuickJSRuntime` (`QuickJSRuntimeAsync`) and `QuickJSContext` (`QuickJSContextAsync`). These variants trade some runtime performance for additional features.
43+
44+
- `QuickJSRuntimeAsync.setModuleLoader` accepts module loaders that return
45+
`Promise<string>`.
46+
- `QuickJSContextAsync.newAsyncifiedFunction` allows creating async functions that
47+
act like sync functions inside the VM.
48+
49+
### Breaking changes
50+
51+
**`class QuickJSVm` is removed**. Most functionality is available on
52+
`QuickJSContext`, with identical function signatures. Functionality related to
53+
runtime limits, memory limits, and pending jobs moved to `QuickJSRuntime`.
54+
55+
**Migration guide**:
56+
57+
1. Replace usages with QuickJSContext.
58+
2. Replace the following methods:
59+
- `vm.hasPendingJob` -> `context.runtime.hasPendingJob`
60+
- `vm.setInterruptHandler` -> `context.runtime.setInterruptHandler`
61+
- `vm.removeInterruptHandler` -> `context.runtime.removeInterruptHandler`
62+
- `vm.executePendingJobs` -> `context.runtime.executePendingJobs`
63+
- `vm.setMemoryLimit` -> `context.runtime.setMemoryLimit`
64+
- `vm.computeMemoryUsage` -> `context.runtime.computeMemoryUsage`
65+
66+
**`QuickJS.createVm()` is removed.**
67+
68+
**Migration guide**: use `QuickJS.newContext()` instead.
69+
70+
## v0.15.0
71+
72+
This is the last version containing `class QuickJSVm` and constructor
73+
`QuickJS.createVm()`.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quickjs-emscripten",
3-
"version": "0.50.0",
3+
"version": "0.20.0",
44
"main": "dist/quickjs.js",
55
"license": "MIT",
66
"keywords": [

Diff for: ts/asyncify-helpers.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { debug } from './debug'
2-
import { isSuccess, SuccessOrFail } from './vm-interface'
1+
import { debug } from "./debug"
2+
import { isSuccess, SuccessOrFail } from "./vm-interface"
33

44
/**
55
* @private
@@ -28,8 +28,8 @@ export class SyncPromise<T> {
2828

2929
catch<R>(fail: (error: unknown) => R): SyncPromise<T | R> {
3030
return this.then(
31-
value => value,
32-
error => fail(error)
31+
(value) => value,
32+
(error) => fail(error)
3333
)
3434
}
3535

@@ -50,25 +50,25 @@ export function newPromiseLike<T>(fn: () => T | Promise<T>): SyncPromise<T> | Pr
5050
/** @private */
5151
export function intoPromiseLike<T>(value: T | Promise<T>): SyncPromise<T> | Promise<T> {
5252
if (value instanceof Promise) {
53-
debug('intoPromiseLike: async', value)
53+
debug("intoPromiseLike: async", value)
5454
return value
5555
}
5656

57-
debug('intoPromiseLike: sync', value)
57+
debug("intoPromiseLike: sync", value)
5858
return new SyncPromise({ value })
5959
}
6060

6161
/** @private */
6262
export function unwrapPromiseLike<T>(promise: SyncPromise<T> | Promise<T>): T | Promise<T> {
6363
if (promise instanceof SyncPromise) {
64-
debug('unwrapPromiseLike: sync', promise.state)
64+
debug("unwrapPromiseLike: sync", promise.state)
6565
if (isSuccess(promise.state)) {
6666
return promise.state.value
6767
} else {
6868
throw promise.state.error
6969
}
7070
}
7171

72-
debug('unwrapPromiseLike: async', promise)
72+
debug("unwrapPromiseLike: async", promise)
7373
return promise
7474
}

0 commit comments

Comments
 (0)