Skip to content

Commit 69bc3d9

Browse files
committed
changelog, naming adjustments
1 parent 0bd818b commit 69bc3d9

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## v0.30.0
4+
5+
- [#200](https://github.com/justjake/quickjs-emscripten/pull/200) Inspect and iterate handles, equality, changes to result types, changes to debug logging.
6+
- [#195](https://github.com/justjake/quickjs-emscripten/pull/195) Export `setDebugMode`
7+
8+
### Collection & Iteration
9+
10+
- For objects and arrays: add `context.getOwnPropertyNames(handle, options)` to iterate the key or array index handles.
11+
- For arrays: add `context.getLength(handle)` which reads `handle.length` and returns it as a number or undefined to make writing `for (i=0;i<length;i++)` loops easier.
12+
- For iterable collections like Map, Set, Array: add `context.getIterator(handle)` calls `handle[Symbol.iterator]()` and then exposes the result as an `IterableIterator` to host javascript.
13+
14+
### Usability improvements
15+
16+
- The `SuccessOrFail<T, QuickJSHandle>` return type is largely replaced with a new return type `DisposableSuccess<T> | DisposableFail<QuickJSHandle>`. The new type implements `result.unwrap()` as a replacement for `context.unwrapResult(result)`. It also implements `dispose()` directly, so you no longer need to distinguish between success and failure to clean up.
17+
- add `context.callMethod(handle, 'methodName')`, this makes it easier to call methods like `context.callMethod(handle, 'keys')` or `context.callMethod('values')` which can be used with the new iterator.
18+
19+
### Equality
20+
21+
- Added `context.eq(a, b)`, `context.sameValue(a, b)`, `context.sameValueZero(a, b)`
22+
23+
### Debug logging changes
24+
25+
Debug logging is now disabled by default, even when using a DEBUG variant. It can be enabled on a runtime-by-runtime basis with `runtime.setDebugMode(boolean)` or `context.runtime.setDebugMode(boolean)`, or globally using `setDebugMode(boolean)`. As with before, you should use a DEBUG variant to see logs from the WebAssembly C code.
26+
27+
## v0.29.2
28+
29+
- [#179](https://github.com/justjake/quickjs-emscripten/pull/161) Add a work-around for a bug in Webkit ARM to quickjs build variants. quickjs-ng is still affected by this bug.
30+
331
## v0.29.1
432

533
- [#161](https://github.com/justjake/quickjs-emscripten/pull/161) Fix a bug where `context.evalCode(..., { type: 'module' })` would return success when some kinds of error occurred when using `quickjs` variants.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
JSRuntimePointer,
77
JSValuePointer,
88
} from "@jitl/quickjs-ffi-types"
9-
import type { ContextResult } from "./context"
9+
import type { QuickJSContextResult } from "./context"
1010
import { QuickJSContext } from "./context"
1111
import type { Lifetime } from "./lifetime"
1212
import type { QuickJSModuleCallbacks } from "./module"
@@ -46,7 +46,7 @@ export class QuickJSAsyncContext extends QuickJSContext {
4646
filename: string = "eval.js",
4747
/** See {@link EvalFlags} for number semantics */
4848
options?: number | ContextEvalOptions,
49-
): Promise<ContextResult<QuickJSHandle>> {
49+
): Promise<QuickJSContextResult<QuickJSHandle>> {
5050
const detectModule = (options === undefined ? 1 : 0) as EvalDetectModule
5151
const flags = evalOptionsToFlags(options) as EvalFlags
5252
let resultPtr = 0 as JSValuePointer

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import type {
6060
} from "./vm-interface"
6161
import { QuickJSIterator } from "./QuickJSIterator"
6262

63-
export type ContextResult<S> = DisposableResult<S, QuickJSHandle>
63+
export type QuickJSContextResult<S> = DisposableResult<S, QuickJSHandle>
6464

6565
/**
6666
* Property key for getting or setting a property on a handle with
@@ -752,7 +752,7 @@ export class QuickJSContext
752752
*
753753
* @param promiseLikeHandle - A handle to a Promise-like value with a `.then(onSuccess, onError)` method.
754754
*/
755-
resolvePromise(promiseLikeHandle: QuickJSHandle): Promise<ContextResult<QuickJSHandle>> {
755+
resolvePromise(promiseLikeHandle: QuickJSHandle): Promise<QuickJSContextResult<QuickJSHandle>> {
756756
this.runtime.assertOwned(promiseLikeHandle)
757757
const vmResolveResult = Scope.withScope((scope) => {
758758
const vmPromise = scope.manage(this.getProp(this.global, "Promise"))
@@ -763,7 +763,7 @@ export class QuickJSContext
763763
return Promise.resolve(vmResolveResult)
764764
}
765765

766-
return new Promise<ContextResult<QuickJSHandle>>((resolve) => {
766+
return new Promise<QuickJSContextResult<QuickJSHandle>>((resolve) => {
767767
Scope.withScope((scope) => {
768768
const resolveHandle = scope.manage(
769769
this.newFunction("resolve", (value) => {
@@ -911,7 +911,7 @@ export class QuickJSContext
911911
strings: true,
912912
numbersAsStrings: true,
913913
},
914-
): ContextResult<DisposableArray<QuickJSHandle>> {
914+
): QuickJSContextResult<DisposableArray<QuickJSHandle>> {
915915
this.runtime.assertOwned(handle)
916916
handle.value // assert alive
917917
const flags = getOwnPropertyNamesOptionsToFlags(options)
@@ -958,7 +958,7 @@ export class QuickJSContext
958958
* }
959959
* ```
960960
*/
961-
getIterator(iterableHandle: QuickJSHandle): ContextResult<QuickJSIterator> {
961+
getIterator(iterableHandle: QuickJSHandle): QuickJSContextResult<QuickJSIterator> {
962962
const SymbolIterator = (this._SymbolIterator ??= this.memory.manage(
963963
this.getWellKnownSymbol("iterator"),
964964
))
@@ -1061,17 +1061,17 @@ export class QuickJSContext
10611061
func: QuickJSHandle,
10621062
thisVal: QuickJSHandle,
10631063
args?: QuickJSHandle[],
1064-
): ContextResult<QuickJSHandle>
1064+
): QuickJSContextResult<QuickJSHandle>
10651065
callFunction(
10661066
func: QuickJSHandle,
10671067
thisVal: QuickJSHandle,
10681068
...args: QuickJSHandle[]
1069-
): ContextResult<QuickJSHandle>
1069+
): QuickJSContextResult<QuickJSHandle>
10701070
callFunction(
10711071
func: QuickJSHandle,
10721072
thisVal: QuickJSHandle,
10731073
...restArgs: Array<QuickJSHandle | QuickJSHandle[] | undefined>
1074-
): ContextResult<QuickJSHandle> {
1074+
): QuickJSContextResult<QuickJSHandle> {
10751075
this.runtime.assertOwned(func)
10761076
let args
10771077
const firstArg = restArgs[0]
@@ -1115,7 +1115,7 @@ export class QuickJSContext
11151115
thisHandle: QuickJSHandle,
11161116
key: QuickJSPropertyKey,
11171117
args: QuickJSHandle[] = [],
1118-
): ContextResult<QuickJSHandle> {
1118+
): QuickJSContextResult<QuickJSHandle> {
11191119
return this.getProp(thisHandle, key).consume((func) =>
11201120
this.callFunction(func, thisHandle, args),
11211121
)
@@ -1164,7 +1164,7 @@ export class QuickJSContext
11641164
* See {@link EvalFlags} for number semantics.
11651165
*/
11661166
options?: number | ContextEvalOptions,
1167-
): ContextResult<QuickJSHandle> {
1167+
): QuickJSContextResult<QuickJSHandle> {
11681168
const detectModule = (options === undefined ? 1 : 0) as EvalDetectModule
11691169
const flags = evalOptionsToFlags(options) as EvalFlags
11701170
const resultPtr = this.memory

0 commit comments

Comments
 (0)