From 2cc6be6f7d575649e323870882475769dfc6598b Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 29 Dec 2023 11:05:42 -0800 Subject: [PATCH 1/6] add Symbol.dispose methods --- packages/internal-tsconfig/tsconfig.json | 5 ++- .../internal-tsconfig/vite.base.config.mts | 3 ++ .../quickjs-emscripten-core/src/context.ts | 12 +++++-- .../src/deferred-promise.ts | 5 +-- .../src/lifetime.test.ts | 14 ++++++++ .../quickjs-emscripten-core/src/lifetime.ts | 34 +++++++++++++++++-- .../quickjs-emscripten-core/src/runtime.ts | 5 +-- 7 files changed, 68 insertions(+), 10 deletions(-) diff --git a/packages/internal-tsconfig/tsconfig.json b/packages/internal-tsconfig/tsconfig.json index 35616c24..9e0c23e6 100644 --- a/packages/internal-tsconfig/tsconfig.json +++ b/packages/internal-tsconfig/tsconfig.json @@ -15,7 +15,10 @@ "lib": [ "ES2020", // Need DOM for WebAssembty.XYZ namespace - "DOM" + "DOM", + // Symbol.dispose + // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management + "esnext.disposable" ], // "allowJs": true /* Allow javascript files to be compiled. */, // "checkJs": true, /* Report errors in .js files. */ diff --git a/packages/internal-tsconfig/vite.base.config.mts b/packages/internal-tsconfig/vite.base.config.mts index bda0d569..fa07145b 100644 --- a/packages/internal-tsconfig/vite.base.config.mts +++ b/packages/internal-tsconfig/vite.base.config.mts @@ -2,5 +2,8 @@ import { defineConfig } from "vite" import tsconfigPaths from "vite-tsconfig-paths" export default defineConfig({ + esbuild: { + target: "es2020", + }, plugins: [tsconfigPaths()], }) diff --git a/packages/quickjs-emscripten-core/src/context.ts b/packages/quickjs-emscripten-core/src/context.ts index 2c08179e..e574e07e 100644 --- a/packages/quickjs-emscripten-core/src/context.ts +++ b/packages/quickjs-emscripten-core/src/context.ts @@ -16,7 +16,7 @@ import { QuickJSDeferredPromise } from "./deferred-promise" import type { shouldInterruptAfterDeadline } from "./interrupt-helpers" import { QuickJSUnwrapError } from "./errors" import type { Disposable } from "./lifetime" -import { Lifetime, Scope, StaticLifetime, WeakLifetime } from "./lifetime" +import { Lifetime, Scope, StaticLifetime, UsingDisposable, WeakLifetime } from "./lifetime" import { ModuleMemory } from "./memory" import type { ContextCallbacks, QuickJSModuleCallbacks } from "./module" import type { @@ -77,6 +77,10 @@ class ContextMemory extends ModuleMemory implements Disposable { return this.scope.dispose() } + [Symbol.dispose]() { + return this.dispose() + } + /** * Track `lifetime` so that it is disposed when this scope is disposed. */ @@ -136,7 +140,10 @@ class ContextMemory extends ModuleMemory implements Disposable { * */ // TODO: Manage own callback registration -export class QuickJSContext implements LowLevelJavascriptVm, Disposable { +export class QuickJSContext + extends UsingDisposable + implements LowLevelJavascriptVm, Disposable +{ /** * The runtime that created this context. */ @@ -179,6 +186,7 @@ export class QuickJSContext implements LowLevelJavascriptVm, Disp ownedLifetimes?: Disposable[] callbacks: QuickJSModuleCallbacks }) { + super() this.runtime = args.runtime this.module = args.module this.ffi = args.ffi diff --git a/packages/quickjs-emscripten-core/src/deferred-promise.ts b/packages/quickjs-emscripten-core/src/deferred-promise.ts index 2e579a9c..325ff7bf 100644 --- a/packages/quickjs-emscripten-core/src/deferred-promise.ts +++ b/packages/quickjs-emscripten-core/src/deferred-promise.ts @@ -1,4 +1,4 @@ -import type { Disposable } from "./lifetime" +import { UsingDisposable, type Disposable } from "./lifetime" import type { QuickJSHandle } from "./types" import type { QuickJSRuntime } from "./runtime" import type { QuickJSContext } from "./context" @@ -25,7 +25,7 @@ export type { PromiseExecutor } from "./types" * QuickJS handles that back {@link resolve} and {@link reject}. For this object, * {@link dispose} is idempotent. */ -export class QuickJSDeferredPromise implements Disposable { +export class QuickJSDeferredPromise extends UsingDisposable implements Disposable { public owner: QuickJSRuntime public context: QuickJSContext @@ -55,6 +55,7 @@ export class QuickJSDeferredPromise implements Disposable { resolveHandle: QuickJSHandle rejectHandle: QuickJSHandle }) { + super() this.context = args.context this.owner = args.context.runtime this.handle = args.promiseHandle diff --git a/packages/quickjs-emscripten-core/src/lifetime.test.ts b/packages/quickjs-emscripten-core/src/lifetime.test.ts index e5812e5a..565b73f7 100644 --- a/packages/quickjs-emscripten-core/src/lifetime.test.ts +++ b/packages/quickjs-emscripten-core/src/lifetime.test.ts @@ -20,6 +20,20 @@ describe("Lifetime", () => { assert.strictEqual(disposed, true) }) }) + + describe("using statement", () => { + it("disposes the lifetime", () => { + let outerLifetime + + { + using lifetime = new Lifetime(1) + outerLifetime = lifetime + assert.strictEqual(outerLifetime.alive, true) + } + + assert.strictEqual(outerLifetime.alive, false) + }) + }) }) describe("Scope", () => { diff --git a/packages/quickjs-emscripten-core/src/lifetime.ts b/packages/quickjs-emscripten-core/src/lifetime.ts index 3d15f85e..ae414503 100644 --- a/packages/quickjs-emscripten-core/src/lifetime.ts +++ b/packages/quickjs-emscripten-core/src/lifetime.ts @@ -4,6 +4,16 @@ import { QTS_DEBUG } from "./debug" import { QuickJSUseAfterFree } from "./errors" import type { QuickJSHandle } from "./types" +// Polyfill Symbol.dispose if needed +if (typeof Symbol.dispose !== "symbol") { + Object.defineProperty(Symbol, "dispose", { + configurable: false, + enumerable: false, + writable: false, + value: Symbol.for("dispose"), + }) +} + /** * An object that can be disposed. * {@link Lifetime} is the canonical implementation of Disposable. @@ -20,6 +30,19 @@ export interface Disposable { * @returns false after the object has been {@link dispose}d */ alive: boolean + + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ + [Symbol.dispose](): void +} + +export abstract class UsingDisposable implements Disposable { + declare abstract readonly alive: boolean + abstract dispose(): void + [Symbol.dispose]() { + return this.dispose() + } } /** @@ -28,7 +51,10 @@ export interface Disposable { * * Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. */ -export class Lifetime implements Disposable { +export class Lifetime + extends UsingDisposable + implements Disposable +{ protected _alive: boolean = true protected _constructorStack = QTS_DEBUG ? new Error("Lifetime constructed").stack : undefined @@ -45,7 +71,9 @@ export class Lifetime implements Disposable { protected readonly copier?: (value: T | TCopy) => TCopy, protected readonly disposer?: (value: T | TCopy) => void, protected readonly _owner?: Owner, - ) {} + ) { + super() + } get alive() { return this._alive @@ -195,7 +223,7 @@ function scopeFinally(scope: Scope, blockError: Error | undefined) { * Scope helps reduce the burden of manually tracking and disposing of * Lifetimes. See {@link withScope}. and {@link withScopeAsync}. */ -export class Scope implements Disposable { +export class Scope extends UsingDisposable implements Disposable { /** * Run `block` with a new Scope instance that will be disposed after the block returns. * Inside `block`, call `scope.manage` on each lifetime you create to have the lifetime diff --git a/packages/quickjs-emscripten-core/src/runtime.ts b/packages/quickjs-emscripten-core/src/runtime.ts index 7a556615..3ec01e27 100644 --- a/packages/quickjs-emscripten-core/src/runtime.ts +++ b/packages/quickjs-emscripten-core/src/runtime.ts @@ -11,7 +11,7 @@ import { QuickJSContext } from "./context" import { debugLog } from "./debug" import { QuickJSWrongOwner } from "./errors" import type { Disposable } from "./lifetime" -import { Lifetime, Scope } from "./lifetime" +import { Lifetime, Scope, UsingDisposable } from "./lifetime" import { ModuleMemory } from "./memory" import type { QuickJSModuleCallbacks, RuntimeCallbacks } from "./module" import type { ContextOptions, JSModuleLoader, JSModuleNormalizer, QuickJSHandle } from "./types" @@ -68,7 +68,7 @@ export type ExecutePendingJobsResult = SuccessOrFail< * * Configure ES module loading with {@link setModuleLoader}. */ -export class QuickJSRuntime implements Disposable { +export class QuickJSRuntime extends UsingDisposable implements Disposable { /** * If this runtime was created as as part of a context, points to the context * associated with the runtime. @@ -106,6 +106,7 @@ export class QuickJSRuntime implements Disposable { callbacks: QuickJSModuleCallbacks ownedLifetimes?: Disposable[] }) { + super() args.ownedLifetimes?.forEach((lifetime) => this.scope.manage(lifetime)) this.module = args.module this.memory = new ModuleMemory(this.module) From 1db2d8a1c8456445dacc689833d2b234b103f3c3 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 29 Dec 2023 11:20:50 -0800 Subject: [PATCH 2/6] doc; remove polyfill --- .../classes/Lifetime.md | 78 +++++++---- .../classes/QuickJSAsyncContext.md | 105 +++++++++------ .../classes/QuickJSAsyncRuntime.md | 39 ++++-- .../classes/QuickJSContext.md | 125 +++++++++++------- .../classes/QuickJSDeferredPromise.md | 58 ++++++-- .../classes/QuickJSRuntime.md | 57 ++++++-- doc/quickjs-emscripten-core/classes/Scope.md | 54 ++++++-- .../classes/StaticLifetime.md | 57 +++++--- .../classes/UsingDisposable.md | 101 ++++++++++++++ .../classes/WeakLifetime.md | 57 +++++--- doc/quickjs-emscripten-core/exports.md | 1 + .../interfaces/Disposable.md | 21 ++- doc/quickjs-emscripten/README.md | 34 +++-- doc/quickjs-emscripten/classes/Lifetime.md | 78 +++++++---- .../classes/QuickJSAsyncContext.md | 105 +++++++++------ .../classes/QuickJSAsyncRuntime.md | 25 +++- .../classes/QuickJSAsyncWASMModule.md | 8 +- .../classes/QuickJSContext.md | 125 +++++++++++------- .../classes/QuickJSDeferredPromise.md | 59 +++++++-- .../classes/QuickJSRuntime.md | 39 +++++- .../classes/QuickJSWASMModule.md | 6 +- doc/quickjs-emscripten/classes/Scope.md | 54 ++++++-- .../classes/StaticLifetime.md | 57 +++++--- .../classes/TestQuickJSWASMModule.md | 16 +-- .../classes/UsingDisposable.md | 101 ++++++++++++++ .../classes/WeakLifetime.md | 57 +++++--- doc/quickjs-emscripten/exports.md | 17 +-- .../interfaces/CustomizeVariantOptions.md | 16 +-- .../interfaces/Disposable.md | 17 +++ .../interfaces/ModuleEvalOptions.md | 8 +- .../namespaces/errors/README.md | 32 ++--- .../internal-tsconfig/vite.base.config.mts | 3 - .../quickjs-emscripten-core/src/lifetime.ts | 24 ++-- .../quickjs-emscripten-core/src/runtime.ts | 3 +- 34 files changed, 1197 insertions(+), 440 deletions(-) create mode 100644 doc/quickjs-emscripten-core/classes/UsingDisposable.md create mode 100644 doc/quickjs-emscripten/classes/UsingDisposable.md diff --git a/doc/quickjs-emscripten-core/classes/Lifetime.md b/doc/quickjs-emscripten-core/classes/Lifetime.md index dd055d90..0bbb6768 100644 --- a/doc/quickjs-emscripten-core/classes/Lifetime.md +++ b/doc/quickjs-emscripten-core/classes/Lifetime.md @@ -7,13 +7,13 @@ # Class: Lifetime\ A lifetime prevents access to a value after the lifetime has been -[dispose](Lifetime.md#dispose)ed. +[dispose](Lifetime.md#dispose-1)ed. Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. ## Contents -- [Extended By](Lifetime.md#extended-by) +- [Extends](Lifetime.md#extends) - [Type parameters](Lifetime.md#type-parameters) - [Implements](Lifetime.md#implements) - [Constructors](Lifetime.md#constructors) @@ -31,14 +31,14 @@ Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. - [owner](Lifetime.md#owner) - [value](Lifetime.md#value) - [Methods](Lifetime.md#methods) + - [`[dispose]`()](Lifetime.md#dispose) - [consume()](Lifetime.md#consume) - [dispose()](Lifetime.md#dispose) - [dup()](Lifetime.md#dup) -## Extended By +## Extends -- [`StaticLifetime`](StaticLifetime.md) -- [`WeakLifetime`](WeakLifetime.md) +- [`UsingDisposable`](UsingDisposable.md) ## Type parameters @@ -79,9 +79,13 @@ the creator. [`Lifetime`](Lifetime.md)\<`T`, `TCopy`, `Owner`\> +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.constructor`](UsingDisposable.md#constructors) + #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:43](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L43) +[packages/quickjs-emscripten-core/src/lifetime.ts:75](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L75) ## Properties @@ -91,7 +95,7 @@ the creator. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:32](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L32) +[packages/quickjs-emscripten-core/src/lifetime.ts:64](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L64) *** @@ -101,7 +105,7 @@ the creator. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L33) +[packages/quickjs-emscripten-core/src/lifetime.ts:65](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L65) *** @@ -111,7 +115,7 @@ the creator. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:47](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L47) +[packages/quickjs-emscripten-core/src/lifetime.ts:79](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L79) *** @@ -121,7 +125,7 @@ the creator. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:44](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L44) +[packages/quickjs-emscripten-core/src/lifetime.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L76) *** @@ -139,7 +143,7 @@ the creator. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L45) +[packages/quickjs-emscripten-core/src/lifetime.ts:77](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L77) *** @@ -157,7 +161,7 @@ the creator. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:46](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L46) +[packages/quickjs-emscripten-core/src/lifetime.ts:78](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L78) ## Accessors @@ -171,11 +175,11 @@ the creator. true if the object is alive -false after the object has been [dispose](Lifetime.md#dispose)d +false after the object has been [dispose](Lifetime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:50](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L50) +[packages/quickjs-emscripten-core/src/lifetime.ts:84](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L84) *** @@ -189,7 +193,7 @@ false after the object has been [dispose](Lifetime.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:69](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L69) +[packages/quickjs-emscripten-core/src/lifetime.ts:103](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L103) *** @@ -203,7 +207,7 @@ false after the object has been [dispose](Lifetime.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:65](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L65) +[packages/quickjs-emscripten-core/src/lifetime.ts:99](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L99) *** @@ -216,7 +220,7 @@ may become invalid, leading to memory errors. #### Throws -If the lifetime has been [dispose](Lifetime.md#dispose)d already. +If the lifetime has been [dispose](Lifetime.md#dispose-1)d already. #### Returns @@ -224,10 +228,34 @@ If the lifetime has been [dispose](Lifetime.md#dispose)d already. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:60](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L60) +[packages/quickjs-emscripten-core/src/lifetime.ts:94](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L94) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten-core.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### consume() #### consume(map) @@ -252,7 +280,7 @@ the result of `map(this)`. ##### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:93](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L93) +[packages/quickjs-emscripten-core/src/lifetime.ts:127](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L127) #### consume(map) @@ -272,7 +300,7 @@ the result of `map(this)`. ##### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:96](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L96) +[packages/quickjs-emscripten-core/src/lifetime.ts:130](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L130) *** @@ -288,11 +316,15 @@ Dispose of [value](Lifetime.md#value-1) and perform cleanup. #### Implementation of -[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:107](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L107) +[packages/quickjs-emscripten-core/src/lifetime.ts:141](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L141) *** @@ -308,7 +340,7 @@ Create a new handle pointing to the same [value](Lifetime.md#value-1). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L76) +[packages/quickjs-emscripten-core/src/lifetime.ts:110](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L110) *** diff --git a/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md b/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md index 781fac2c..dee944cf 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md @@ -27,6 +27,7 @@ host functions as though they were synchronous. - [true](QuickJSAsyncContext.md#true) - [undefined](QuickJSAsyncContext.md#undefined) - [Methods](QuickJSAsyncContext.md#methods) + - [`[dispose]`()](QuickJSAsyncContext.md#dispose) - [callFunction()](QuickJSAsyncContext.md#callfunction) - [decodeBinaryJSON()](QuickJSAsyncContext.md#decodebinaryjson) - [defineProp()](QuickJSAsyncContext.md#defineprop) @@ -100,7 +101,7 @@ to create a new QuickJSContext. #### Source -[packages/quickjs-emscripten-core/src/context.ts:173](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L173) +[packages/quickjs-emscripten-core/src/context.ts:180](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L180) ## Properties @@ -130,11 +131,11 @@ The runtime that created this context. true if the object is alive -false after the object has been [dispose](QuickJSAsyncContext.md#dispose)d +false after the object has been [dispose](QuickJSAsyncContext.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/context.ts:200](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L200) +[packages/quickjs-emscripten-core/src/context.ts:208](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L208) *** @@ -150,7 +151,7 @@ false after the object has been [dispose](QuickJSAsyncContext.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/context.ts:258](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L258) +[packages/quickjs-emscripten-core/src/context.ts:266](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L266) *** @@ -168,7 +169,7 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:273](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L273) +[packages/quickjs-emscripten-core/src/context.ts:281](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L281) *** @@ -184,7 +185,7 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:232](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L232) +[packages/quickjs-emscripten-core/src/context.ts:240](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L240) *** @@ -200,7 +201,7 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:245](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L245) +[packages/quickjs-emscripten-core/src/context.ts:253](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L253) *** @@ -216,10 +217,30 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:219](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L219) +[packages/quickjs-emscripten-core/src/context.ts:227](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L227) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten-core.QuickJSContext.[dispose]`](QuickJSContext.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### callFunction() > **callFunction**(`func`, `thisVal`, ...`args`): [`VmCallResult`](../exports.md#vmcallresultvmhandle)\<[`QuickJSHandle`](../exports.md#quickjshandle)\> @@ -254,7 +275,7 @@ value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:706](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L706) +[packages/quickjs-emscripten-core/src/context.ts:714](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L714) *** @@ -287,7 +308,7 @@ socket.on("data", chunk => { #### Source -[packages/quickjs-emscripten-core/src/context.ts:997](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L997) +[packages/quickjs-emscripten-core/src/context.ts:1005](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1005) *** @@ -318,7 +339,7 @@ Javascript string or number (which will be converted automatically to a JSValue) #### Source -[packages/quickjs-emscripten-core/src/context.ts:657](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L657) +[packages/quickjs-emscripten-core/src/context.ts:665](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L665) *** @@ -334,7 +355,7 @@ Dispose of this VM's underlying resources. #### Inherited from -[`quickjs-emscripten-core.QuickJSContext.dispose`](QuickJSContext.md#dispose) +[`quickjs-emscripten-core.QuickJSContext.dispose`](QuickJSContext.md#dispose-1) #### Throws @@ -343,7 +364,7 @@ will result in an error. #### Source -[packages/quickjs-emscripten-core/src/context.ts:210](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L210) +[packages/quickjs-emscripten-core/src/context.ts:218](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L218) *** @@ -368,7 +389,7 @@ Returns `handle.toString()` if it cannot be serialized to JSON. #### Source -[packages/quickjs-emscripten-core/src/context.ts:823](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L823) +[packages/quickjs-emscripten-core/src/context.ts:831](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L831) *** @@ -402,7 +423,7 @@ socket.write(dataLifetime?.value) #### Source -[packages/quickjs-emscripten-core/src/context.ts:980](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L980) +[packages/quickjs-emscripten-core/src/context.ts:988](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L988) *** @@ -452,7 +473,7 @@ interrupted, the error will have name `InternalError` and message #### Source -[packages/quickjs-emscripten-core/src/context.ts:753](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L753) +[packages/quickjs-emscripten-core/src/context.ts:761](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L761) *** @@ -502,7 +523,7 @@ Coverts `handle` to a JavaScript ArrayBuffer #### Source -[packages/quickjs-emscripten-core/src/context.ts:556](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L556) +[packages/quickjs-emscripten-core/src/context.ts:564](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L564) *** @@ -526,7 +547,7 @@ Converts `handle` to a Javascript bigint. #### Source -[packages/quickjs-emscripten-core/src/context.ts:547](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L547) +[packages/quickjs-emscripten-core/src/context.ts:555](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L555) *** @@ -552,7 +573,7 @@ Converts `handle` into a Javascript number. #### Source -[packages/quickjs-emscripten-core/src/context.ts:518](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L518) +[packages/quickjs-emscripten-core/src/context.ts:526](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L526) *** @@ -582,7 +603,7 @@ Javascript string (which will be converted automatically). #### Source -[packages/quickjs-emscripten-core/src/context.ts:621](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L621) +[packages/quickjs-emscripten-core/src/context.ts:629](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L629) *** @@ -606,7 +627,7 @@ Converts `handle` to a Javascript string. #### Source -[packages/quickjs-emscripten-core/src/context.ts:526](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L526) +[packages/quickjs-emscripten-core/src/context.ts:534](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L534) *** @@ -631,7 +652,7 @@ registry in the guest, it will be created with Symbol.for on the host. #### Source -[packages/quickjs-emscripten-core/src/context.ts:535](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L535) +[packages/quickjs-emscripten-core/src/context.ts:543](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L543) *** @@ -652,7 +673,7 @@ Create a new QuickJS [array](https://developer.mozilla.org/en-US/docs/Web/JavaSc #### Source -[packages/quickjs-emscripten-core/src/context.ts:372](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L372) +[packages/quickjs-emscripten-core/src/context.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L380) *** @@ -676,7 +697,7 @@ Create a new QuickJS [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/ #### Source -[packages/quickjs-emscripten-core/src/context.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L380) +[packages/quickjs-emscripten-core/src/context.ts:388](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L388) *** @@ -732,7 +753,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -[packages/quickjs-emscripten-core/src/context.ts:338](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L338) +[packages/quickjs-emscripten-core/src/context.ts:346](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L346) *** @@ -760,7 +781,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ##### Source -[packages/quickjs-emscripten-core/src/context.ts:473](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L473) +[packages/quickjs-emscripten-core/src/context.ts:481](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L481) #### newError(message) @@ -780,7 +801,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ##### Source -[packages/quickjs-emscripten-core/src/context.ts:474](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L474) +[packages/quickjs-emscripten-core/src/context.ts:482](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L482) #### newError(undefined) @@ -796,7 +817,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ##### Source -[packages/quickjs-emscripten-core/src/context.ts:475](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L475) +[packages/quickjs-emscripten-core/src/context.ts:483](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L483) *** @@ -837,7 +858,7 @@ return deferred.handle #### Source -[packages/quickjs-emscripten-core/src/context.ts:467](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L467) +[packages/quickjs-emscripten-core/src/context.ts:475](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L475) *** @@ -861,7 +882,7 @@ Converts a Javascript number into a QuickJS value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:297](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L297) +[packages/quickjs-emscripten-core/src/context.ts:305](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L305) *** @@ -888,7 +909,7 @@ Like [`Object.create`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R #### Source -[packages/quickjs-emscripten-core/src/context.ts:358](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L358) +[packages/quickjs-emscripten-core/src/context.ts:366](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L366) *** @@ -913,7 +934,7 @@ resources; see the documentation on [QuickJSDeferredPromise](QuickJSDeferredProm ##### Source -[packages/quickjs-emscripten-core/src/context.ts:393](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L393) +[packages/quickjs-emscripten-core/src/context.ts:401](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L401) #### newPromise(promise) @@ -939,7 +960,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -[packages/quickjs-emscripten-core/src/context.ts:401](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L401) +[packages/quickjs-emscripten-core/src/context.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L409) #### newPromise(newPromiseFn) @@ -964,7 +985,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -[packages/quickjs-emscripten-core/src/context.ts:408](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L408) +[packages/quickjs-emscripten-core/src/context.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L416) *** @@ -988,7 +1009,7 @@ Create a QuickJS [string](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -[packages/quickjs-emscripten-core/src/context.ts:304](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L304) +[packages/quickjs-emscripten-core/src/context.ts:312](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L312) *** @@ -1013,7 +1034,7 @@ All symbols created with the same key will be the same value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:327](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L327) +[packages/quickjs-emscripten-core/src/context.ts:335](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L335) *** @@ -1038,7 +1059,7 @@ No two symbols created with this function will be the same value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:315](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L315) +[packages/quickjs-emscripten-core/src/context.ts:323](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L323) *** @@ -1070,7 +1091,7 @@ You may need to call [runtime](QuickJSAsyncContext.md#runtime).[QuickJSRuntime#e #### Source -[packages/quickjs-emscripten-core/src/context.ts:578](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L578) +[packages/quickjs-emscripten-core/src/context.ts:586](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L586) *** @@ -1107,7 +1128,7 @@ properties. #### Source -[packages/quickjs-emscripten-core/src/context.ts:642](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L642) +[packages/quickjs-emscripten-core/src/context.ts:650](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L650) *** @@ -1131,7 +1152,7 @@ Throw an error in the VM, interrupted whatever current execution is in progress #### Source -[packages/quickjs-emscripten-core/src/context.ts:783](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L783) +[packages/quickjs-emscripten-core/src/context.ts:791](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L791) *** @@ -1159,7 +1180,7 @@ Does not support BigInt values correctly. #### Source -[packages/quickjs-emscripten-core/src/context.ts:509](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L509) +[packages/quickjs-emscripten-core/src/context.ts:517](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L517) *** @@ -1190,7 +1211,7 @@ If the result is an error, converts the error to a native object and throws the #### Source -[packages/quickjs-emscripten-core/src/context.ts:852](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L852) +[packages/quickjs-emscripten-core/src/context.ts:860](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L860) *** diff --git a/doc/quickjs-emscripten-core/classes/QuickJSAsyncRuntime.md b/doc/quickjs-emscripten-core/classes/QuickJSAsyncRuntime.md index 9044ba71..0b77c7e3 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSAsyncRuntime.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSAsyncRuntime.md @@ -38,6 +38,7 @@ Configure ES module loading with [setModuleLoader](QuickJSAsyncRuntime.md#setmod - [Accessors](QuickJSAsyncRuntime.md#accessors) - [alive](QuickJSAsyncRuntime.md#alive) - [Methods](QuickJSAsyncRuntime.md#methods) + - [`[dispose]`()](QuickJSAsyncRuntime.md#dispose) - [assertOwned()](QuickJSAsyncRuntime.md#assertowned) - [computeMemoryUsage()](QuickJSAsyncRuntime.md#computememoryusage) - [dispose()](QuickJSAsyncRuntime.md#dispose) @@ -88,14 +89,34 @@ A context here may be allocated if one is needed by the runtime, eg for [compute true if the object is alive -false after the object has been [dispose](QuickJSAsyncRuntime.md#dispose)d +false after the object has been [dispose](QuickJSAsyncRuntime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:121](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L121) +[packages/quickjs-emscripten-core/src/runtime.ts:122](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L122) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten-core.QuickJSRuntime.[dispose]`](QuickJSRuntime.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### assertOwned() > **assertOwned**(`handle`): `void` @@ -160,11 +181,11 @@ Dispose of the underlying resources used by this object. #### Inherited from -[`quickjs-emscripten-core.QuickJSRuntime.dispose`](QuickJSRuntime.md#dispose) +[`quickjs-emscripten-core.QuickJSRuntime.dispose`](QuickJSRuntime.md#dispose-1) #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:125](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L125) +[packages/quickjs-emscripten-core/src/runtime.ts:126](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L126) *** @@ -223,7 +244,7 @@ functions or rejected promises. Those errors are available by calling #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:242](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L242) +[packages/quickjs-emscripten-core/src/runtime.ts:243](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L243) *** @@ -246,7 +267,7 @@ true if there is at least one pendingJob queued up. #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:193](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L193) +[packages/quickjs-emscripten-core/src/runtime.ts:194](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L194) *** @@ -295,7 +316,7 @@ See [setInterruptHandler](QuickJSAsyncRuntime.md#setinterrupthandler). #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:218](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L218) +[packages/quickjs-emscripten-core/src/runtime.ts:219](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L219) *** @@ -315,7 +336,7 @@ Remove the the loader set by [setModuleLoader](QuickJSAsyncRuntime.md#setmodulel #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:180](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L180) +[packages/quickjs-emscripten-core/src/runtime.ts:181](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L181) *** @@ -343,7 +364,7 @@ The interrupt handler can be removed with [removeInterruptHandler](QuickJSAsyncR #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:206](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L206) +[packages/quickjs-emscripten-core/src/runtime.ts:207](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L207) *** diff --git a/doc/quickjs-emscripten-core/classes/QuickJSContext.md b/doc/quickjs-emscripten-core/classes/QuickJSContext.md index 08334ad3..2184c2a4 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSContext.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSContext.md @@ -38,7 +38,7 @@ See [QuickJSRuntime](QuickJSRuntime.md) for more information. ## Contents -- [Extended By](QuickJSContext.md#extended-by) +- [Extends](QuickJSContext.md#extends) - [Implements](QuickJSContext.md#implements) - [Constructors](QuickJSContext.md#constructors) - [new QuickJSContext(args)](QuickJSContext.md#new-quickjscontextargs) @@ -52,6 +52,7 @@ See [QuickJSRuntime](QuickJSRuntime.md) for more information. - [true](QuickJSContext.md#true) - [undefined](QuickJSContext.md#undefined) - [Methods](QuickJSContext.md#methods) + - [`[dispose]`()](QuickJSContext.md#dispose) - [callFunction()](QuickJSContext.md#callfunction) - [decodeBinaryJSON()](QuickJSContext.md#decodebinaryjson) - [defineProp()](QuickJSContext.md#defineprop) @@ -82,9 +83,9 @@ See [QuickJSRuntime](QuickJSRuntime.md) for more information. - [typeof()](QuickJSContext.md#typeof) - [unwrapResult()](QuickJSContext.md#unwrapresult) -## Extended By +## Extends -- [`QuickJSAsyncContext`](QuickJSAsyncContext.md) +- [`UsingDisposable`](UsingDisposable.md) ## Implements @@ -122,9 +123,13 @@ to create a new QuickJSContext. [`QuickJSContext`](QuickJSContext.md) +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.constructor`](UsingDisposable.md#constructors) + #### Source -[packages/quickjs-emscripten-core/src/context.ts:173](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L173) +[packages/quickjs-emscripten-core/src/context.ts:180](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L180) ## Properties @@ -136,7 +141,7 @@ The runtime that created this context. #### Source -[packages/quickjs-emscripten-core/src/context.ts:143](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L143) +[packages/quickjs-emscripten-core/src/context.ts:150](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L150) ## Accessors @@ -150,11 +155,11 @@ The runtime that created this context. true if the object is alive -false after the object has been [dispose](QuickJSContext.md#dispose)d +false after the object has been [dispose](QuickJSContext.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/context.ts:200](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L200) +[packages/quickjs-emscripten-core/src/context.ts:208](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L208) *** @@ -170,7 +175,7 @@ false after the object has been [dispose](QuickJSContext.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/context.ts:258](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L258) +[packages/quickjs-emscripten-core/src/context.ts:266](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L266) *** @@ -188,7 +193,7 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:273](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L273) +[packages/quickjs-emscripten-core/src/context.ts:281](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L281) *** @@ -204,7 +209,7 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:232](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L232) +[packages/quickjs-emscripten-core/src/context.ts:240](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L240) *** @@ -220,7 +225,7 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:245](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L245) +[packages/quickjs-emscripten-core/src/context.ts:253](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L253) *** @@ -236,10 +241,34 @@ You can set properties to create global variables. #### Source -[packages/quickjs-emscripten-core/src/context.ts:219](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L219) +[packages/quickjs-emscripten-core/src/context.ts:227](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L227) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten-core.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### callFunction() > **callFunction**(`func`, `thisVal`, ...`args`): [`VmCallResult`](../exports.md#vmcallresultvmhandle)\<[`QuickJSHandle`](../exports.md#quickjshandle)\> @@ -274,7 +303,7 @@ value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:706](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L706) +[packages/quickjs-emscripten-core/src/context.ts:714](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L714) *** @@ -303,7 +332,7 @@ socket.on("data", chunk => { #### Source -[packages/quickjs-emscripten-core/src/context.ts:997](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L997) +[packages/quickjs-emscripten-core/src/context.ts:1005](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1005) *** @@ -334,7 +363,7 @@ Javascript string or number (which will be converted automatically to a JSValue) #### Source -[packages/quickjs-emscripten-core/src/context.ts:657](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L657) +[packages/quickjs-emscripten-core/src/context.ts:665](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L665) *** @@ -350,7 +379,11 @@ Dispose of this VM's underlying resources. #### Implementation of -[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Throws @@ -359,7 +392,7 @@ will result in an error. #### Source -[packages/quickjs-emscripten-core/src/context.ts:210](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L210) +[packages/quickjs-emscripten-core/src/context.ts:218](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L218) *** @@ -380,7 +413,7 @@ Returns `handle.toString()` if it cannot be serialized to JSON. #### Source -[packages/quickjs-emscripten-core/src/context.ts:823](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L823) +[packages/quickjs-emscripten-core/src/context.ts:831](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L831) *** @@ -410,7 +443,7 @@ socket.write(dataLifetime?.value) #### Source -[packages/quickjs-emscripten-core/src/context.ts:980](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L980) +[packages/quickjs-emscripten-core/src/context.ts:988](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L988) *** @@ -460,7 +493,7 @@ interrupted, the error will have name `InternalError` and message #### Source -[packages/quickjs-emscripten-core/src/context.ts:753](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L753) +[packages/quickjs-emscripten-core/src/context.ts:761](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L761) *** @@ -480,7 +513,7 @@ Coverts `handle` to a JavaScript ArrayBuffer #### Source -[packages/quickjs-emscripten-core/src/context.ts:556](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L556) +[packages/quickjs-emscripten-core/src/context.ts:564](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L564) *** @@ -500,7 +533,7 @@ Converts `handle` to a Javascript bigint. #### Source -[packages/quickjs-emscripten-core/src/context.ts:547](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L547) +[packages/quickjs-emscripten-core/src/context.ts:555](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L555) *** @@ -526,7 +559,7 @@ Converts `handle` into a Javascript number. #### Source -[packages/quickjs-emscripten-core/src/context.ts:518](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L518) +[packages/quickjs-emscripten-core/src/context.ts:526](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L526) *** @@ -556,7 +589,7 @@ Javascript string (which will be converted automatically). #### Source -[packages/quickjs-emscripten-core/src/context.ts:621](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L621) +[packages/quickjs-emscripten-core/src/context.ts:629](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L629) *** @@ -580,7 +613,7 @@ Converts `handle` to a Javascript string. #### Source -[packages/quickjs-emscripten-core/src/context.ts:526](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L526) +[packages/quickjs-emscripten-core/src/context.ts:534](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L534) *** @@ -601,7 +634,7 @@ registry in the guest, it will be created with Symbol.for on the host. #### Source -[packages/quickjs-emscripten-core/src/context.ts:535](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L535) +[packages/quickjs-emscripten-core/src/context.ts:543](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L543) *** @@ -618,7 +651,7 @@ Create a new QuickJS [array](https://developer.mozilla.org/en-US/docs/Web/JavaSc #### Source -[packages/quickjs-emscripten-core/src/context.ts:372](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L372) +[packages/quickjs-emscripten-core/src/context.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L380) *** @@ -638,7 +671,7 @@ Create a new QuickJS [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/ #### Source -[packages/quickjs-emscripten-core/src/context.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L380) +[packages/quickjs-emscripten-core/src/context.ts:388](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L388) *** @@ -658,7 +691,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -[packages/quickjs-emscripten-core/src/context.ts:338](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L338) +[packages/quickjs-emscripten-core/src/context.ts:346](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L346) *** @@ -682,7 +715,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ##### Source -[packages/quickjs-emscripten-core/src/context.ts:473](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L473) +[packages/quickjs-emscripten-core/src/context.ts:481](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L481) #### newError(message) @@ -698,7 +731,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ##### Source -[packages/quickjs-emscripten-core/src/context.ts:474](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L474) +[packages/quickjs-emscripten-core/src/context.ts:482](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L482) #### newError(undefined) @@ -710,7 +743,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ##### Source -[packages/quickjs-emscripten-core/src/context.ts:475](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L475) +[packages/quickjs-emscripten-core/src/context.ts:483](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L483) *** @@ -751,7 +784,7 @@ return deferred.handle #### Source -[packages/quickjs-emscripten-core/src/context.ts:467](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L467) +[packages/quickjs-emscripten-core/src/context.ts:475](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L475) *** @@ -775,7 +808,7 @@ Converts a Javascript number into a QuickJS value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:297](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L297) +[packages/quickjs-emscripten-core/src/context.ts:305](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L305) *** @@ -802,7 +835,7 @@ Like [`Object.create`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R #### Source -[packages/quickjs-emscripten-core/src/context.ts:358](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L358) +[packages/quickjs-emscripten-core/src/context.ts:366](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L366) *** @@ -823,7 +856,7 @@ resources; see the documentation on [QuickJSDeferredPromise](QuickJSDeferredProm ##### Source -[packages/quickjs-emscripten-core/src/context.ts:393](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L393) +[packages/quickjs-emscripten-core/src/context.ts:401](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L401) #### newPromise(promise) @@ -845,7 +878,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -[packages/quickjs-emscripten-core/src/context.ts:401](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L401) +[packages/quickjs-emscripten-core/src/context.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L409) #### newPromise(newPromiseFn) @@ -866,7 +899,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -[packages/quickjs-emscripten-core/src/context.ts:408](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L408) +[packages/quickjs-emscripten-core/src/context.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L416) *** @@ -890,7 +923,7 @@ Create a QuickJS [string](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -[packages/quickjs-emscripten-core/src/context.ts:304](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L304) +[packages/quickjs-emscripten-core/src/context.ts:312](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L312) *** @@ -911,7 +944,7 @@ All symbols created with the same key will be the same value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:327](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L327) +[packages/quickjs-emscripten-core/src/context.ts:335](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L335) *** @@ -932,7 +965,7 @@ No two symbols created with this function will be the same value. #### Source -[packages/quickjs-emscripten-core/src/context.ts:315](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L315) +[packages/quickjs-emscripten-core/src/context.ts:323](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L323) *** @@ -960,7 +993,7 @@ You may need to call [runtime](QuickJSContext.md#runtime).[QuickJSRuntime#execut #### Source -[packages/quickjs-emscripten-core/src/context.ts:578](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L578) +[packages/quickjs-emscripten-core/src/context.ts:586](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L586) *** @@ -997,7 +1030,7 @@ properties. #### Source -[packages/quickjs-emscripten-core/src/context.ts:642](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L642) +[packages/quickjs-emscripten-core/src/context.ts:650](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L650) *** @@ -1017,7 +1050,7 @@ Throw an error in the VM, interrupted whatever current execution is in progress #### Source -[packages/quickjs-emscripten-core/src/context.ts:783](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L783) +[packages/quickjs-emscripten-core/src/context.ts:791](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L791) *** @@ -1045,7 +1078,7 @@ Does not support BigInt values correctly. #### Source -[packages/quickjs-emscripten-core/src/context.ts:509](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L509) +[packages/quickjs-emscripten-core/src/context.ts:517](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L517) *** @@ -1072,7 +1105,7 @@ If the result is an error, converts the error to a native object and throws the #### Source -[packages/quickjs-emscripten-core/src/context.ts:852](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L852) +[packages/quickjs-emscripten-core/src/context.ts:860](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L860) *** diff --git a/doc/quickjs-emscripten-core/classes/QuickJSDeferredPromise.md b/doc/quickjs-emscripten-core/classes/QuickJSDeferredPromise.md index 2f13f45c..86dbb484 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSDeferredPromise.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSDeferredPromise.md @@ -22,12 +22,13 @@ itself, (2) the `resolve` callback, and (3) the `reject` callback. and ensure that either [resolve](QuickJSDeferredPromise.md#resolve) or [reject](QuickJSDeferredPromise.md#reject) will be called. No other clean-up is necessary. -- In other cases, call [dispose](QuickJSDeferredPromise.md#dispose), which will dispose [handle](QuickJSDeferredPromise.md#handle) as well as the +- In other cases, call [dispose](QuickJSDeferredPromise.md#dispose-1), which will dispose [handle](QuickJSDeferredPromise.md#handle) as well as the QuickJS handles that back [resolve](QuickJSDeferredPromise.md#resolve) and [reject](QuickJSDeferredPromise.md#reject). For this object, - [dispose](QuickJSDeferredPromise.md#dispose) is idempotent. + [dispose](QuickJSDeferredPromise.md#dispose-1) is idempotent. ## Contents +- [Extends](QuickJSDeferredPromise.md#extends) - [Implements](QuickJSDeferredPromise.md#implements) - [Constructors](QuickJSDeferredPromise.md#constructors) - [new QuickJSDeferredPromise(args)](QuickJSDeferredPromise.md#new-quickjsdeferredpromiseargs) @@ -39,10 +40,15 @@ itself, (2) the `resolve` callback, and (3) the `reject` callback. - [Accessors](QuickJSDeferredPromise.md#accessors) - [alive](QuickJSDeferredPromise.md#alive) - [Methods](QuickJSDeferredPromise.md#methods) + - [`[dispose]`()](QuickJSDeferredPromise.md#dispose) - [dispose()](QuickJSDeferredPromise.md#dispose) - [reject()](QuickJSDeferredPromise.md#reject) - [resolve()](QuickJSDeferredPromise.md#resolve) +## Extends + +- [`UsingDisposable`](UsingDisposable.md) + ## Implements - [`Disposable`](../interfaces/Disposable.md) @@ -72,6 +78,10 @@ this constructor directly. [`QuickJSDeferredPromise`](QuickJSDeferredPromise.md) +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.constructor`](UsingDisposable.md#constructors) + #### Source [packages/quickjs-emscripten-core/src/deferred-promise.ts:52](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L52) @@ -134,14 +144,38 @@ A native promise that will resolve once this deferred is settled. true if the object is alive -false after the object has been [dispose](QuickJSDeferredPromise.md#dispose)d +false after the object has been [dispose](QuickJSDeferredPromise.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/deferred-promise.ts:122](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L122) +[packages/quickjs-emscripten-core/src/deferred-promise.ts:123](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L123) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten-core.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### dispose() > **dispose**(): `void` @@ -154,11 +188,15 @@ Dispose of the underlying resources used by this object. #### Implementation of -[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -[packages/quickjs-emscripten-core/src/deferred-promise.ts:126](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L126) +[packages/quickjs-emscripten-core/src/deferred-promise.ts:127](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L127) *** @@ -167,7 +205,7 @@ Dispose of the underlying resources used by this object. > **reject**(`value`?): `void` Reject [handle](QuickJSDeferredPromise.md#handle) with the given value, if any. -Calling this method after calling [dispose](QuickJSDeferredPromise.md#dispose) is a no-op. +Calling this method after calling [dispose](QuickJSDeferredPromise.md#dispose-1) is a no-op. Note that after rejecting a promise, you may need to call [QuickJSRuntime#executePendingJobs](QuickJSRuntime.md#executependingjobs) to propagate the result to the promise's @@ -183,7 +221,7 @@ callbacks. #### Source -[packages/quickjs-emscripten-core/src/deferred-promise.ts:103](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L103) +[packages/quickjs-emscripten-core/src/deferred-promise.ts:104](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L104) *** @@ -192,7 +230,7 @@ callbacks. > **resolve**(`value`?): `void` Resolve [handle](QuickJSDeferredPromise.md#handle) with the given value, if any. -Calling this method after calling [dispose](QuickJSDeferredPromise.md#dispose) is a no-op. +Calling this method after calling [dispose](QuickJSDeferredPromise.md#dispose-1) is a no-op. Note that after resolving a promise, you may need to call [QuickJSRuntime#executePendingJobs](QuickJSRuntime.md#executependingjobs) to propagate the result to the promise's @@ -208,7 +246,7 @@ callbacks. #### Source -[packages/quickjs-emscripten-core/src/deferred-promise.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L76) +[packages/quickjs-emscripten-core/src/deferred-promise.ts:77](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L77) *** diff --git a/doc/quickjs-emscripten-core/classes/QuickJSRuntime.md b/doc/quickjs-emscripten-core/classes/QuickJSRuntime.md index 0b7bd852..79a964e6 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSRuntime.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSRuntime.md @@ -32,13 +32,14 @@ Configure ES module loading with [setModuleLoader](QuickJSRuntime.md#setmodulelo ## Contents -- [Extended By](QuickJSRuntime.md#extended-by) +- [Extends](QuickJSRuntime.md#extends) - [Implements](QuickJSRuntime.md#implements) - [Properties](QuickJSRuntime.md#properties) - [context](QuickJSRuntime.md#context) - [Accessors](QuickJSRuntime.md#accessors) - [alive](QuickJSRuntime.md#alive) - [Methods](QuickJSRuntime.md#methods) + - [`[dispose]`()](QuickJSRuntime.md#dispose) - [assertOwned()](QuickJSRuntime.md#assertowned) - [computeMemoryUsage()](QuickJSRuntime.md#computememoryusage) - [dispose()](QuickJSRuntime.md#dispose) @@ -53,9 +54,9 @@ Configure ES module loading with [setModuleLoader](QuickJSRuntime.md#setmodulelo - [setMemoryLimit()](QuickJSRuntime.md#setmemorylimit) - [setModuleLoader()](QuickJSRuntime.md#setmoduleloader) -## Extended By +## Extends -- [`QuickJSAsyncRuntime`](QuickJSAsyncRuntime.md) +- [`UsingDisposable`](UsingDisposable.md) ## Implements @@ -89,14 +90,38 @@ A context here may be allocated if one is needed by the runtime, eg for [compute true if the object is alive -false after the object has been [dispose](QuickJSRuntime.md#dispose)d +false after the object has been [dispose](QuickJSRuntime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:121](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L121) +[packages/quickjs-emscripten-core/src/runtime.ts:122](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L122) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten-core.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### assertOwned() > **assertOwned**(`handle`): `void` @@ -153,11 +178,15 @@ Dispose of the underlying resources used by this object. #### Implementation of -[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:125](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L125) +[packages/quickjs-emscripten-core/src/runtime.ts:126](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L126) *** @@ -208,7 +237,7 @@ functions or rejected promises. Those errors are available by calling #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:242](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L242) +[packages/quickjs-emscripten-core/src/runtime.ts:243](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L243) *** @@ -227,7 +256,7 @@ true if there is at least one pendingJob queued up. #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:193](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L193) +[packages/quickjs-emscripten-core/src/runtime.ts:194](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L194) *** @@ -251,7 +280,7 @@ You should dispose a created context before disposing this runtime. #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:136](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L136) +[packages/quickjs-emscripten-core/src/runtime.ts:137](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L137) *** @@ -268,7 +297,7 @@ See [setInterruptHandler](QuickJSRuntime.md#setinterrupthandler). #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:218](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L218) +[packages/quickjs-emscripten-core/src/runtime.ts:219](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L219) *** @@ -284,7 +313,7 @@ Remove the the loader set by [setModuleLoader](QuickJSRuntime.md#setmoduleloader #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:180](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L180) +[packages/quickjs-emscripten-core/src/runtime.ts:181](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L181) *** @@ -308,7 +337,7 @@ The interrupt handler can be removed with [removeInterruptHandler](QuickJSRuntim #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:206](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L206) +[packages/quickjs-emscripten-core/src/runtime.ts:207](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L207) *** @@ -375,7 +404,7 @@ The loader can be removed with [removeModuleLoader](QuickJSRuntime.md#removemodu #### Source -[packages/quickjs-emscripten-core/src/runtime.ts:171](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L171) +[packages/quickjs-emscripten-core/src/runtime.ts:172](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/runtime.ts#L172) *** diff --git a/doc/quickjs-emscripten-core/classes/Scope.md b/doc/quickjs-emscripten-core/classes/Scope.md index bacd64e9..3bcd8301 100644 --- a/doc/quickjs-emscripten-core/classes/Scope.md +++ b/doc/quickjs-emscripten-core/classes/Scope.md @@ -11,18 +11,24 @@ Lifetimes. See [withScope](Scope.md#withscope). and [withScopeAsync](Scope.md#wi ## Contents +- [Extends](Scope.md#extends) - [Implements](Scope.md#implements) - [Constructors](Scope.md#constructors) - [new Scope(undefined)](Scope.md#new-scopeundefined) - [Accessors](Scope.md#accessors) - [alive](Scope.md#alive) - [Methods](Scope.md#methods) + - [`[dispose]`()](Scope.md#dispose) - [dispose()](Scope.md#dispose) - [manage()](Scope.md#manage) - [withScope()](Scope.md#withscope) - [withScopeAsync()](Scope.md#withscopeasync) - [withScopeMaybeAsync()](Scope.md#withscopemaybeasync) +## Extends + +- [`UsingDisposable`](UsingDisposable.md) + ## Implements - [`Disposable`](../interfaces/Disposable.md) @@ -37,6 +43,10 @@ Lifetimes. See [withScope](Scope.md#withscope). and [withScopeAsync](Scope.md#wi [`Scope`](Scope.md) +#### Inherited from + +[`quickjs-emscripten-core.UsingDisposable.constructor`](UsingDisposable.md#constructors) + ## Accessors ### alive @@ -49,14 +59,38 @@ Lifetimes. See [withScope](Scope.md#withscope). and [withScopeAsync](Scope.md#wi true if the object is alive -false after the object has been [dispose](Scope.md#dispose)d +false after the object has been [dispose](Scope.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:266](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L266) +[packages/quickjs-emscripten-core/src/lifetime.ts:300](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L300) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten-core.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### dispose() > **dispose**(): `void` @@ -69,11 +103,15 @@ Dispose of the underlying resources used by this object. #### Implementation of -[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten-core.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:270](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L270) +[packages/quickjs-emscripten-core/src/lifetime.ts:304](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L304) *** @@ -97,7 +135,7 @@ Track `lifetime` so that it is disposed when this scope is disposed. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:261](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L261) +[packages/quickjs-emscripten-core/src/lifetime.ts:295](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L295) *** @@ -127,7 +165,7 @@ Do not use with async functions. Instead, use [withScopeAsync](Scope.md#withscop #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:206](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L206) +[packages/quickjs-emscripten-core/src/lifetime.ts:240](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L240) *** @@ -154,7 +192,7 @@ block returns. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:243](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L243) +[packages/quickjs-emscripten-core/src/lifetime.ts:277](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L277) *** @@ -182,7 +220,7 @@ block returns. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:219](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L219) +[packages/quickjs-emscripten-core/src/lifetime.ts:253](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L253) *** diff --git a/doc/quickjs-emscripten-core/classes/StaticLifetime.md b/doc/quickjs-emscripten-core/classes/StaticLifetime.md index 5fb08c91..749a2ae9 100644 --- a/doc/quickjs-emscripten-core/classes/StaticLifetime.md +++ b/doc/quickjs-emscripten-core/classes/StaticLifetime.md @@ -27,6 +27,7 @@ A Lifetime that lives forever. Used for constants. - [owner](StaticLifetime.md#owner) - [value](StaticLifetime.md#value) - [Methods](StaticLifetime.md#methods) + - [`[dispose]`()](StaticLifetime.md#dispose) - [consume()](StaticLifetime.md#consume) - [dispose()](StaticLifetime.md#dispose) - [dup()](StaticLifetime.md#dup) @@ -63,7 +64,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:131](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L131) +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) ## Properties @@ -77,7 +78,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:32](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L32) +[packages/quickjs-emscripten-core/src/lifetime.ts:64](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L64) *** @@ -91,7 +92,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L33) +[packages/quickjs-emscripten-core/src/lifetime.ts:65](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L65) *** @@ -105,7 +106,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:47](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L47) +[packages/quickjs-emscripten-core/src/lifetime.ts:79](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L79) *** @@ -119,7 +120,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:44](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L44) +[packages/quickjs-emscripten-core/src/lifetime.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L76) *** @@ -141,7 +142,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L45) +[packages/quickjs-emscripten-core/src/lifetime.ts:77](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L77) *** @@ -163,7 +164,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:46](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L46) +[packages/quickjs-emscripten-core/src/lifetime.ts:78](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L78) ## Accessors @@ -177,11 +178,11 @@ A Lifetime that lives forever. Used for constants. true if the object is alive -false after the object has been [dispose](StaticLifetime.md#dispose)d +false after the object has been [dispose](StaticLifetime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:50](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L50) +[packages/quickjs-emscripten-core/src/lifetime.ts:84](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L84) *** @@ -195,7 +196,7 @@ false after the object has been [dispose](StaticLifetime.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:136](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L136) +[packages/quickjs-emscripten-core/src/lifetime.ts:170](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L170) *** @@ -209,7 +210,7 @@ false after the object has been [dispose](StaticLifetime.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:65](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L65) +[packages/quickjs-emscripten-core/src/lifetime.ts:99](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L99) *** @@ -222,7 +223,7 @@ may become invalid, leading to memory errors. #### Throws -If the lifetime has been [dispose](StaticLifetime.md#dispose)d already. +If the lifetime has been [dispose](StaticLifetime.md#dispose-1)d already. #### Returns @@ -230,10 +231,30 @@ If the lifetime has been [dispose](StaticLifetime.md#dispose)d already. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:60](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L60) +[packages/quickjs-emscripten-core/src/lifetime.ts:94](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L94) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten-core.Lifetime.[dispose]`](Lifetime.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### consume() #### consume(map) @@ -262,7 +283,7 @@ the result of `map(this)`. ##### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:93](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L93) +[packages/quickjs-emscripten-core/src/lifetime.ts:127](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L127) #### consume(map) @@ -286,7 +307,7 @@ the result of `map(this)`. ##### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:96](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L96) +[packages/quickjs-emscripten-core/src/lifetime.ts:130](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L130) *** @@ -302,11 +323,11 @@ Dispose of [value](StaticLifetime.md#value-1) and perform cleanup. #### Overrides -[`quickjs-emscripten-core.Lifetime.dispose`](Lifetime.md#dispose) +[`quickjs-emscripten-core.Lifetime.dispose`](Lifetime.md#dispose-1) #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:146](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L146) +[packages/quickjs-emscripten-core/src/lifetime.ts:180](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L180) *** @@ -326,7 +347,7 @@ Create a new handle pointing to the same [value](StaticLifetime.md#value-1). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:141](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L141) +[packages/quickjs-emscripten-core/src/lifetime.ts:175](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L175) *** diff --git a/doc/quickjs-emscripten-core/classes/UsingDisposable.md b/doc/quickjs-emscripten-core/classes/UsingDisposable.md new file mode 100644 index 00000000..4adab4e0 --- /dev/null +++ b/doc/quickjs-emscripten-core/classes/UsingDisposable.md @@ -0,0 +1,101 @@ +[quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) + +*** + +[quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / UsingDisposable + +# Class: `abstract` UsingDisposable + +Base abstract class that helps implement [Disposable](../interfaces/Disposable.md) by providing a default implementation of [Symbol.dispose]([object Object]). + +## Contents + +- [Extended By](UsingDisposable.md#extended-by) +- [Implements](UsingDisposable.md#implements) +- [Constructors](UsingDisposable.md#constructors) + - [new UsingDisposable(undefined)](UsingDisposable.md#new-usingdisposableundefined) +- [Properties](UsingDisposable.md#properties) + - [`abstract` alive](UsingDisposable.md#abstract-alive) +- [Methods](UsingDisposable.md#methods) + - [`[dispose]`()](UsingDisposable.md#dispose) + - [`abstract` dispose()](UsingDisposable.md#abstract-dispose) + +## Extended By + +- [`QuickJSContext`](QuickJSContext.md) +- [`QuickJSRuntime`](QuickJSRuntime.md) +- [`Lifetime`](Lifetime.md) +- [`Scope`](Scope.md) +- [`QuickJSDeferredPromise`](QuickJSDeferredPromise.md) + +## Implements + +- [`Disposable`](../interfaces/Disposable.md) + +## Constructors + +### new UsingDisposable(undefined) + +> **new UsingDisposable**(): [`UsingDisposable`](UsingDisposable.md) + +#### Returns + +[`UsingDisposable`](UsingDisposable.md) + +## Properties + +### `abstract` alive + +> **`abstract`** **`readonly`** **alive**: `boolean` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.alive`](../interfaces/Disposable.md#alive) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L41) + +## Methods + +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + +### `abstract` dispose() + +> **`abstract`** **dispose**(): `void` + +Dispose of the underlying resources used by this object. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten-core.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L45) + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten-core/classes/WeakLifetime.md b/doc/quickjs-emscripten-core/classes/WeakLifetime.md index bb384c07..a411d4aa 100644 --- a/doc/quickjs-emscripten-core/classes/WeakLifetime.md +++ b/doc/quickjs-emscripten-core/classes/WeakLifetime.md @@ -31,6 +31,7 @@ Used for function arguments. - [owner](WeakLifetime.md#owner) - [value](WeakLifetime.md#value) - [Methods](WeakLifetime.md#methods) + - [`[dispose]`()](WeakLifetime.md#dispose) - [consume()](WeakLifetime.md#consume) - [dispose()](WeakLifetime.md#dispose) - [dup()](WeakLifetime.md#dup) @@ -73,7 +74,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:157](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L157) +[packages/quickjs-emscripten-core/src/lifetime.ts:191](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L191) ## Properties @@ -87,7 +88,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:32](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L32) +[packages/quickjs-emscripten-core/src/lifetime.ts:64](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L64) *** @@ -101,7 +102,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L33) +[packages/quickjs-emscripten-core/src/lifetime.ts:65](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L65) *** @@ -115,7 +116,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:47](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L47) +[packages/quickjs-emscripten-core/src/lifetime.ts:79](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L79) *** @@ -129,7 +130,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:44](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L44) +[packages/quickjs-emscripten-core/src/lifetime.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L76) *** @@ -151,7 +152,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L45) +[packages/quickjs-emscripten-core/src/lifetime.ts:77](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L77) *** @@ -173,7 +174,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:46](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L46) +[packages/quickjs-emscripten-core/src/lifetime.ts:78](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L78) ## Accessors @@ -187,11 +188,11 @@ Used for function arguments. true if the object is alive -false after the object has been [dispose](WeakLifetime.md#dispose)d +false after the object has been [dispose](WeakLifetime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:50](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L50) +[packages/quickjs-emscripten-core/src/lifetime.ts:84](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L84) *** @@ -205,7 +206,7 @@ false after the object has been [dispose](WeakLifetime.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:69](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L69) +[packages/quickjs-emscripten-core/src/lifetime.ts:103](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L103) *** @@ -219,7 +220,7 @@ false after the object has been [dispose](WeakLifetime.md#dispose)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:65](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L65) +[packages/quickjs-emscripten-core/src/lifetime.ts:99](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L99) *** @@ -232,7 +233,7 @@ may become invalid, leading to memory errors. #### Throws -If the lifetime has been [dispose](WeakLifetime.md#dispose)d already. +If the lifetime has been [dispose](WeakLifetime.md#dispose-1)d already. #### Returns @@ -240,10 +241,30 @@ If the lifetime has been [dispose](WeakLifetime.md#dispose)d already. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:60](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L60) +[packages/quickjs-emscripten-core/src/lifetime.ts:94](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L94) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten-core.Lifetime.[dispose]`](Lifetime.md#dispose) + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L49) + +*** + ### consume() #### consume(map) @@ -272,7 +293,7 @@ the result of `map(this)`. ##### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:93](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L93) +[packages/quickjs-emscripten-core/src/lifetime.ts:127](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L127) #### consume(map) @@ -296,7 +317,7 @@ the result of `map(this)`. ##### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:96](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L96) +[packages/quickjs-emscripten-core/src/lifetime.ts:130](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L130) *** @@ -312,11 +333,11 @@ Dispose of [value](WeakLifetime.md#value-1) and perform cleanup. #### Overrides -[`quickjs-emscripten-core.Lifetime.dispose`](Lifetime.md#dispose) +[`quickjs-emscripten-core.Lifetime.dispose`](Lifetime.md#dispose-1) #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:167](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L167) +[packages/quickjs-emscripten-core/src/lifetime.ts:201](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L201) *** @@ -336,7 +357,7 @@ Create a new handle pointing to the same [value](WeakLifetime.md#value-1). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L76) +[packages/quickjs-emscripten-core/src/lifetime.ts:110](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L110) *** diff --git a/doc/quickjs-emscripten-core/exports.md b/doc/quickjs-emscripten-core/exports.md index 16cc7524..37704943 100644 --- a/doc/quickjs-emscripten-core/exports.md +++ b/doc/quickjs-emscripten-core/exports.md @@ -79,6 +79,7 @@ - [Scope](classes/Scope.md) - [StaticLifetime](classes/StaticLifetime.md) - [TestQuickJSWASMModule](classes/TestQuickJSWASMModule.md) +- [UsingDisposable](classes/UsingDisposable.md) - [WeakLifetime](classes/WeakLifetime.md) ## Interfaces diff --git a/doc/quickjs-emscripten-core/interfaces/Disposable.md b/doc/quickjs-emscripten-core/interfaces/Disposable.md index afe9fda8..34455102 100644 --- a/doc/quickjs-emscripten-core/interfaces/Disposable.md +++ b/doc/quickjs-emscripten-core/interfaces/Disposable.md @@ -15,6 +15,7 @@ Use [Scope](../classes/Scope.md) to manage cleaning up multiple disposables. - [Properties](Disposable.md#properties) - [alive](Disposable.md#alive) - [Methods](Disposable.md#methods) + - [`[dispose]`()](Disposable.md#dispose) - [dispose()](Disposable.md#dispose) ## Properties @@ -25,10 +26,26 @@ Use [Scope](../classes/Scope.md) to manage cleaning up multiple disposables. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:22](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L22) +[packages/quickjs-emscripten-core/src/lifetime.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L25) ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + +#### Returns + +`void` + +#### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:30](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L30) + +*** + ### dispose() > **dispose**(): `void` @@ -41,7 +58,7 @@ Dispose of the underlying resources used by this object. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:16](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L16) +[packages/quickjs-emscripten-core/src/lifetime.ts:19](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L19) *** diff --git a/doc/quickjs-emscripten/README.md b/doc/quickjs-emscripten/README.md index 8b5105c6..7ea7d27e 100644 --- a/doc/quickjs-emscripten/README.md +++ b/doc/quickjs-emscripten/README.md @@ -556,17 +556,25 @@ To use a variant, call `newQuickJSWASMModule` or `newQuickJSAsyncWASMModule` wit ```typescript import { - newQuickJSWASMModule, newQuickJSAsyncWASMModule, - RELEASE_SYNC, DEBUG_SYNC, - RELEASE_ASYNC, DEBUG_ASYNC, -} from 'quickjs-emscripten' + newQuickJSWASMModule, + newQuickJSAsyncWASMModule, + RELEASE_SYNC, + DEBUG_SYNC, + RELEASE_ASYNC, + DEBUG_ASYNC, +} from "quickjs-emscripten" const QuickJSReleaseSync = await newQuickJSWASMModule(RELEASE_SYNC) const QuickJSDebugSync = await newQuickJSWASMModule(DEBUG_SYNC) const QuickJSReleaseAsync = await newQuickJSAsyncWASMModule(RELEASE_ASYNC) const QuickJSDebugAsync = await newQuickJSAsyncWASMModule(DEBUG_ASYNC) -for (const quickjs of [QuickJSReleaseSync, QuickJSDebugSync, QuickJSReleaseAsync, QuickJSDebugAsync]) { +for (const quickjs of [ + QuickJSReleaseSync, + QuickJSDebugSync, + QuickJSReleaseAsync, + QuickJSDebugAsync, +]) { const vm = quickjs.newContext() const result = vm.unwrapResult(vm.evalCode("1 + 1")).consume(vm.getNumber) console.log(result) @@ -579,7 +587,7 @@ for (const quickjs of [QuickJSReleaseSync, QuickJSDebugSync, QuickJSReleaseAsync Including 4 different copies of the WebAssembly module in the main package gives it an install size of [about 9.04mb](https://packagephobia.com/result?p=quickjs-emscripten). If you're building a CLI package or library of your own, or otherwise don't need to include 4 different variants in your `node_modules`, you can switch to the `quickjs-emscripten-core` package, which contains only the Javascript code for this library, and install one (or more) variants a-la-carte as separate packages. -The most minimal setup would be to install `quickjs-emscripten-core` and `@jitl/quickjs-wasmfile-release-sync` (1.3M total): +The most minimal setup would be to install `quickjs-emscripten-core` and `@jitl/quickjs-wasmfile-release-sync` (1.3mb total): ```bash yarn add quickjs-emscripten-core @jitl/quickjs-wasmfile-release-sync @@ -594,12 +602,12 @@ Then, you can use quickjs-emscripten-core's `newQuickJSWASMModuleFromVariant` to ```typescript // src/quickjs.mjs -import { newQuickJSWASMModuleFromVariant } from 'quickjs-emscripten-core' -import RELEASE_SYNC from '@jitl/quickjs-wasmfile-release-sync' +import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core" +import RELEASE_SYNC from "@jitl/quickjs-wasmfile-release-sync" export const QuickJS = await newQuickJSWASMModuleFromVariant(RELEASE_SYNC) // src/app.mjs -import { QuickJS } from './quickjs.mjs' +import { QuickJS } from "./quickjs.mjs" console.log(QuickJS.evalCode("1 + 1")) ``` @@ -614,9 +622,9 @@ To run QuickJS, we need to load a WebAssembly module into the host Javascript ru To customize the loading of an existing variant, create a new variant with your loading settings using `newVariant`, passing [CustomizeVariantOptions][newVariant]. For example, you need to customize loading in Cloudflare Workers (see [the full example][cloudflare]). ```typescript -import { newQuickJSWASMModule, DEBUG_SYNC as baseVariant, newVariant } from 'quickjs-emscripten'; -import cloudflareWasmModule from './DEBUG_SYNC.wasm'; -import cloudflareWasmModuleSourceMap from './DEBUG_SYNC.wasm.map.txt'; +import { newQuickJSWASMModule, DEBUG_SYNC as baseVariant, newVariant } from "quickjs-emscripten" +import cloudflareWasmModule from "./DEBUG_SYNC.wasm" +import cloudflareWasmModuleSourceMap from "./DEBUG_SYNC.wasm.map.txt" /** * We need to make a new variant that directly passes the imported WebAssembly.Module @@ -626,7 +634,7 @@ import cloudflareWasmModuleSourceMap from './DEBUG_SYNC.wasm.map.txt'; const cloudflareVariant = newVariant(baseVariant, { wasmModule: cloudflareWasmModule, wasmSourceMapData: cloudflareWasmModuleSourceMap, -}); +}) ``` [newVariant]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/interfaces/CustomizeVariantOptions.md diff --git a/doc/quickjs-emscripten/classes/Lifetime.md b/doc/quickjs-emscripten/classes/Lifetime.md index 64548df3..7b11704f 100644 --- a/doc/quickjs-emscripten/classes/Lifetime.md +++ b/doc/quickjs-emscripten/classes/Lifetime.md @@ -7,13 +7,13 @@ # Class: Lifetime\ A lifetime prevents access to a value after the lifetime has been -[dispose](Lifetime.md#dispose)ed. +[dispose](Lifetime.md#dispose-1)ed. Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. ## Contents -- [Extended By](Lifetime.md#extended-by) +- [Extends](Lifetime.md#extends) - [Type parameters](Lifetime.md#type-parameters) - [Implements](Lifetime.md#implements) - [Constructors](Lifetime.md#constructors) @@ -31,14 +31,14 @@ Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. - [owner](Lifetime.md#owner) - [value](Lifetime.md#value) - [Methods](Lifetime.md#methods) + - [`[dispose]`()](Lifetime.md#dispose) - [consume()](Lifetime.md#consume) - [dispose()](Lifetime.md#dispose) - [dup()](Lifetime.md#dup) -## Extended By +## Extends -- [`StaticLifetime`](StaticLifetime.md) -- [`WeakLifetime`](WeakLifetime.md) +- [`UsingDisposable`](UsingDisposable.md) ## Type parameters @@ -79,9 +79,13 @@ the creator. [`Lifetime`](Lifetime.md)\<`T`, `TCopy`, `Owner`\> +#### Overrides + +[`quickjs-emscripten.UsingDisposable.constructor`](UsingDisposable.md#constructors) + #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:521 +packages/quickjs-emscripten-core/dist/index.d.ts:543 ## Properties @@ -91,7 +95,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:521 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:511 +packages/quickjs-emscripten-core/dist/index.d.ts:533 *** @@ -101,7 +105,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:511 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:512 +packages/quickjs-emscripten-core/dist/index.d.ts:534 *** @@ -111,7 +115,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:512 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:510 +packages/quickjs-emscripten-core/dist/index.d.ts:532 *** @@ -121,7 +125,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:510 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:507 +packages/quickjs-emscripten-core/dist/index.d.ts:529 *** @@ -139,7 +143,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:507 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:508 +packages/quickjs-emscripten-core/dist/index.d.ts:530 *** @@ -157,7 +161,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:508 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:509 +packages/quickjs-emscripten-core/dist/index.d.ts:531 ## Accessors @@ -171,11 +175,11 @@ packages/quickjs-emscripten-core/dist/index.d.ts:509 true if the object is alive -false after the object has been [dispose](Lifetime.md#dispose)d +false after the object has been [dispose](Lifetime.md#dispose-1)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:522 +packages/quickjs-emscripten-core/dist/index.d.ts:544 *** @@ -189,7 +193,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:522 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:531 +packages/quickjs-emscripten-core/dist/index.d.ts:553 *** @@ -203,7 +207,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:531 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:530 +packages/quickjs-emscripten-core/dist/index.d.ts:552 *** @@ -216,7 +220,7 @@ may become invalid, leading to memory errors. #### Throws -If the lifetime has been [dispose](Lifetime.md#dispose)d already. +If the lifetime has been [dispose](Lifetime.md#dispose-1)d already. #### Returns @@ -224,10 +228,34 @@ If the lifetime has been [dispose](Lifetime.md#dispose)d already. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:529 +packages/quickjs-emscripten-core/dist/index.d.ts:551 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### consume() #### consume(map) @@ -252,7 +280,7 @@ the result of `map(this)`. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:540 +packages/quickjs-emscripten-core/dist/index.d.ts:562 #### consume(map) @@ -272,7 +300,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:540 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:541 +packages/quickjs-emscripten-core/dist/index.d.ts:563 *** @@ -288,11 +316,15 @@ Dispose of [value](Lifetime.md#value-1) and perform cleanup. #### Implementation of -[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:545 +packages/quickjs-emscripten-core/dist/index.d.ts:567 *** @@ -308,7 +340,7 @@ Create a new handle pointing to the same [value](Lifetime.md#value-1). #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:535 +packages/quickjs-emscripten-core/dist/index.d.ts:557 *** diff --git a/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md b/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md index 862b0aee..2d045949 100644 --- a/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md +++ b/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md @@ -27,6 +27,7 @@ host functions as though they were synchronous. - [true](QuickJSAsyncContext.md#true) - [undefined](QuickJSAsyncContext.md#undefined) - [Methods](QuickJSAsyncContext.md#methods) + - [`[dispose]`()](QuickJSAsyncContext.md#dispose) - [callFunction()](QuickJSAsyncContext.md#callfunction) - [decodeBinaryJSON()](QuickJSAsyncContext.md#decodebinaryjson) - [defineProp()](QuickJSAsyncContext.md#defineprop) @@ -100,7 +101,7 @@ to create a new QuickJSContext. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:766 +packages/quickjs-emscripten-core/dist/index.d.ts:789 ## Properties @@ -130,11 +131,11 @@ packages/quickjs-emscripten-core/dist/index.d.ts:319 true if the object is alive -false after the object has been [dispose](QuickJSAsyncContext.md#dispose)d +false after the object has been [dispose](QuickJSAsyncContext.md#dispose-1)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:775 +packages/quickjs-emscripten-core/dist/index.d.ts:798 *** @@ -150,7 +151,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:775 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:798 +packages/quickjs-emscripten-core/dist/index.d.ts:821 *** @@ -168,7 +169,7 @@ You can set properties to create global variables. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:804 +packages/quickjs-emscripten-core/dist/index.d.ts:827 *** @@ -184,7 +185,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:804 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:790 +packages/quickjs-emscripten-core/dist/index.d.ts:813 *** @@ -200,7 +201,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:790 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:794 +packages/quickjs-emscripten-core/dist/index.d.ts:817 *** @@ -216,10 +217,30 @@ packages/quickjs-emscripten-core/dist/index.d.ts:794 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:786 +packages/quickjs-emscripten-core/dist/index.d.ts:809 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten.QuickJSContext.[dispose]`](QuickJSContext.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### callFunction() > **callFunction**(`func`, `thisVal`, ...`args`): [`VmCallResult`](../exports.md#vmcallresultvmhandle)\<[`QuickJSHandle`](../exports.md#quickjshandle)\> @@ -254,7 +275,7 @@ value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:970 +packages/quickjs-emscripten-core/dist/index.d.ts:993 *** @@ -287,7 +308,7 @@ socket.on("data", chunk => { #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1063 +packages/quickjs-emscripten-core/dist/index.d.ts:1086 *** @@ -318,7 +339,7 @@ Javascript string or number (which will be converted automatically to a JSValue) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:956 +packages/quickjs-emscripten-core/dist/index.d.ts:979 *** @@ -334,7 +355,7 @@ Dispose of this VM's underlying resources. #### Inherited from -[`quickjs-emscripten.QuickJSContext.dispose`](QuickJSContext.md#dispose) +[`quickjs-emscripten.QuickJSContext.dispose`](QuickJSContext.md#dispose-1) #### Throws @@ -343,7 +364,7 @@ will result in an error. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:782 +packages/quickjs-emscripten-core/dist/index.d.ts:805 *** @@ -368,7 +389,7 @@ Returns `handle.toString()` if it cannot be serialized to JSON. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1016 +packages/quickjs-emscripten-core/dist/index.d.ts:1039 *** @@ -402,7 +423,7 @@ socket.write(dataLifetime?.value) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1050 +packages/quickjs-emscripten-core/dist/index.d.ts:1073 *** @@ -452,7 +473,7 @@ interrupted, the error will have name `InternalError` and message #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:991 +packages/quickjs-emscripten-core/dist/index.d.ts:1014 *** @@ -502,7 +523,7 @@ Coverts `handle` to a JavaScript ArrayBuffer #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:918 +packages/quickjs-emscripten-core/dist/index.d.ts:941 *** @@ -526,7 +547,7 @@ Converts `handle` to a Javascript bigint. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:914 +packages/quickjs-emscripten-core/dist/index.d.ts:937 *** @@ -552,7 +573,7 @@ Converts `handle` into a Javascript number. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:901 +packages/quickjs-emscripten-core/dist/index.d.ts:924 *** @@ -582,7 +603,7 @@ Javascript string (which will be converted automatically). #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:937 +packages/quickjs-emscripten-core/dist/index.d.ts:960 *** @@ -606,7 +627,7 @@ Converts `handle` to a Javascript string. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:905 +packages/quickjs-emscripten-core/dist/index.d.ts:928 *** @@ -631,7 +652,7 @@ registry in the guest, it will be created with Symbol.for on the host. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:910 +packages/quickjs-emscripten-core/dist/index.d.ts:933 *** @@ -652,7 +673,7 @@ Create a new QuickJS [array](https://developer.mozilla.org/en-US/docs/Web/JavaSc #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:838 +packages/quickjs-emscripten-core/dist/index.d.ts:861 *** @@ -676,7 +697,7 @@ Create a new QuickJS [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/ #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:842 +packages/quickjs-emscripten-core/dist/index.d.ts:865 *** @@ -732,7 +753,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:826 +packages/quickjs-emscripten-core/dist/index.d.ts:849 *** @@ -760,7 +781,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:826 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:884 +packages/quickjs-emscripten-core/dist/index.d.ts:907 #### newError(message) @@ -780,7 +801,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:884 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:888 +packages/quickjs-emscripten-core/dist/index.d.ts:911 #### newError(undefined) @@ -796,7 +817,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:888 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:889 +packages/quickjs-emscripten-core/dist/index.d.ts:912 *** @@ -837,7 +858,7 @@ return deferred.handle #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:883 +packages/quickjs-emscripten-core/dist/index.d.ts:906 *** @@ -861,7 +882,7 @@ Converts a Javascript number into a QuickJS value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:808 +packages/quickjs-emscripten-core/dist/index.d.ts:831 *** @@ -888,7 +909,7 @@ Like [`Object.create`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:833 +packages/quickjs-emscripten-core/dist/index.d.ts:856 *** @@ -913,7 +934,7 @@ resources; see the documentation on [QuickJSDeferredPromise](QuickJSDeferredProm ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:849 +packages/quickjs-emscripten-core/dist/index.d.ts:872 #### newPromise(promise) @@ -939,7 +960,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:857 +packages/quickjs-emscripten-core/dist/index.d.ts:880 #### newPromise(newPromiseFn) @@ -964,7 +985,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:864 +packages/quickjs-emscripten-core/dist/index.d.ts:887 *** @@ -988,7 +1009,7 @@ Create a QuickJS [string](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:812 +packages/quickjs-emscripten-core/dist/index.d.ts:835 *** @@ -1013,7 +1034,7 @@ All symbols created with the same key will be the same value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:822 +packages/quickjs-emscripten-core/dist/index.d.ts:845 *** @@ -1038,7 +1059,7 @@ No two symbols created with this function will be the same value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:817 +packages/quickjs-emscripten-core/dist/index.d.ts:840 *** @@ -1070,7 +1091,7 @@ You may need to call [runtime](QuickJSAsyncContext.md#runtime).[QuickJSRuntime#e #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:929 +packages/quickjs-emscripten-core/dist/index.d.ts:952 *** @@ -1107,7 +1128,7 @@ properties. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:949 +packages/quickjs-emscripten-core/dist/index.d.ts:972 *** @@ -1131,7 +1152,7 @@ Throw an error in the VM, interrupted whatever current execution is in progress #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1003 +packages/quickjs-emscripten-core/dist/index.d.ts:1026 *** @@ -1159,7 +1180,7 @@ Does not support BigInt values correctly. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:896 +packages/quickjs-emscripten-core/dist/index.d.ts:919 *** @@ -1190,7 +1211,7 @@ If the result is an error, converts the error to a native object and throws the #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1023 +packages/quickjs-emscripten-core/dist/index.d.ts:1046 *** diff --git a/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md b/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md index ce1385c6..a6b9d3a2 100644 --- a/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md +++ b/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md @@ -38,6 +38,7 @@ Configure ES module loading with [setModuleLoader](QuickJSAsyncRuntime.md#setmod - [Accessors](QuickJSAsyncRuntime.md#accessors) - [alive](QuickJSAsyncRuntime.md#alive) - [Methods](QuickJSAsyncRuntime.md#methods) + - [`[dispose]`()](QuickJSAsyncRuntime.md#dispose) - [assertOwned()](QuickJSAsyncRuntime.md#assertowned) - [computeMemoryUsage()](QuickJSAsyncRuntime.md#computememoryusage) - [dispose()](QuickJSAsyncRuntime.md#dispose) @@ -88,7 +89,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:280 true if the object is alive -false after the object has been [dispose](QuickJSAsyncRuntime.md#dispose)d +false after the object has been [dispose](QuickJSAsyncRuntime.md#dispose-1)d #### Source @@ -96,6 +97,26 @@ packages/quickjs-emscripten-core/dist/index.d.ts:187 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten.QuickJSRuntime.[dispose]`](QuickJSRuntime.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### assertOwned() > **assertOwned**(`handle`): `void` @@ -160,7 +181,7 @@ Dispose of the underlying resources used by this object. #### Inherited from -[`quickjs-emscripten.QuickJSRuntime.dispose`](QuickJSRuntime.md#dispose) +[`quickjs-emscripten.QuickJSRuntime.dispose`](QuickJSRuntime.md#dispose-1) #### Source diff --git a/doc/quickjs-emscripten/classes/QuickJSAsyncWASMModule.md b/doc/quickjs-emscripten/classes/QuickJSAsyncWASMModule.md index ca131913..58b6cbee 100644 --- a/doc/quickjs-emscripten/classes/QuickJSAsyncWASMModule.md +++ b/doc/quickjs-emscripten/classes/QuickJSAsyncWASMModule.md @@ -49,7 +49,7 @@ Synchronous evalCode is not supported. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1236 +packages/quickjs-emscripten-core/dist/index.d.ts:1259 *** @@ -79,7 +79,7 @@ See the documentation for [QuickJSWASMModule#evalCode](QuickJSWASMModule.md#eval #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1248 +packages/quickjs-emscripten-core/dist/index.d.ts:1271 *** @@ -105,7 +105,7 @@ be disposed when the context is disposed. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1234 +packages/quickjs-emscripten-core/dist/index.d.ts:1257 *** @@ -131,7 +131,7 @@ concurrent async actions, create multiple WebAssembly modules. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1228 +packages/quickjs-emscripten-core/dist/index.d.ts:1251 *** diff --git a/doc/quickjs-emscripten/classes/QuickJSContext.md b/doc/quickjs-emscripten/classes/QuickJSContext.md index f84997d5..5e5d5e35 100644 --- a/doc/quickjs-emscripten/classes/QuickJSContext.md +++ b/doc/quickjs-emscripten/classes/QuickJSContext.md @@ -38,7 +38,7 @@ See [QuickJSRuntime](QuickJSRuntime.md) for more information. ## Contents -- [Extended By](QuickJSContext.md#extended-by) +- [Extends](QuickJSContext.md#extends) - [Implements](QuickJSContext.md#implements) - [Constructors](QuickJSContext.md#constructors) - [new QuickJSContext(args)](QuickJSContext.md#new-quickjscontextargs) @@ -52,6 +52,7 @@ See [QuickJSRuntime](QuickJSRuntime.md) for more information. - [true](QuickJSContext.md#true) - [undefined](QuickJSContext.md#undefined) - [Methods](QuickJSContext.md#methods) + - [`[dispose]`()](QuickJSContext.md#dispose) - [callFunction()](QuickJSContext.md#callfunction) - [decodeBinaryJSON()](QuickJSContext.md#decodebinaryjson) - [defineProp()](QuickJSContext.md#defineprop) @@ -82,9 +83,9 @@ See [QuickJSRuntime](QuickJSRuntime.md) for more information. - [typeof()](QuickJSContext.md#typeof) - [unwrapResult()](QuickJSContext.md#unwrapresult) -## Extended By +## Extends -- [`QuickJSAsyncContext`](QuickJSAsyncContext.md) +- [`UsingDisposable`](UsingDisposable.md) ## Implements @@ -122,9 +123,13 @@ to create a new QuickJSContext. [`QuickJSContext`](QuickJSContext.md) +#### Overrides + +[`quickjs-emscripten.UsingDisposable.constructor`](UsingDisposable.md#constructors) + #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:766 +packages/quickjs-emscripten-core/dist/index.d.ts:789 ## Properties @@ -136,7 +141,7 @@ The runtime that created this context. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:739 +packages/quickjs-emscripten-core/dist/index.d.ts:762 ## Accessors @@ -150,11 +155,11 @@ packages/quickjs-emscripten-core/dist/index.d.ts:739 true if the object is alive -false after the object has been [dispose](QuickJSContext.md#dispose)d +false after the object has been [dispose](QuickJSContext.md#dispose-1)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:775 +packages/quickjs-emscripten-core/dist/index.d.ts:798 *** @@ -170,7 +175,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:775 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:798 +packages/quickjs-emscripten-core/dist/index.d.ts:821 *** @@ -188,7 +193,7 @@ You can set properties to create global variables. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:804 +packages/quickjs-emscripten-core/dist/index.d.ts:827 *** @@ -204,7 +209,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:804 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:790 +packages/quickjs-emscripten-core/dist/index.d.ts:813 *** @@ -220,7 +225,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:790 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:794 +packages/quickjs-emscripten-core/dist/index.d.ts:817 *** @@ -236,10 +241,34 @@ packages/quickjs-emscripten-core/dist/index.d.ts:794 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:786 +packages/quickjs-emscripten-core/dist/index.d.ts:809 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### callFunction() > **callFunction**(`func`, `thisVal`, ...`args`): [`VmCallResult`](../exports.md#vmcallresultvmhandle)\<[`QuickJSHandle`](../exports.md#quickjshandle)\> @@ -274,7 +303,7 @@ value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:970 +packages/quickjs-emscripten-core/dist/index.d.ts:993 *** @@ -303,7 +332,7 @@ socket.on("data", chunk => { #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1063 +packages/quickjs-emscripten-core/dist/index.d.ts:1086 *** @@ -334,7 +363,7 @@ Javascript string or number (which will be converted automatically to a JSValue) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:956 +packages/quickjs-emscripten-core/dist/index.d.ts:979 *** @@ -350,7 +379,11 @@ Dispose of this VM's underlying resources. #### Implementation of -[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Throws @@ -359,7 +392,7 @@ will result in an error. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:782 +packages/quickjs-emscripten-core/dist/index.d.ts:805 *** @@ -380,7 +413,7 @@ Returns `handle.toString()` if it cannot be serialized to JSON. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1016 +packages/quickjs-emscripten-core/dist/index.d.ts:1039 *** @@ -410,7 +443,7 @@ socket.write(dataLifetime?.value) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1050 +packages/quickjs-emscripten-core/dist/index.d.ts:1073 *** @@ -460,7 +493,7 @@ interrupted, the error will have name `InternalError` and message #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:991 +packages/quickjs-emscripten-core/dist/index.d.ts:1014 *** @@ -480,7 +513,7 @@ Coverts `handle` to a JavaScript ArrayBuffer #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:918 +packages/quickjs-emscripten-core/dist/index.d.ts:941 *** @@ -500,7 +533,7 @@ Converts `handle` to a Javascript bigint. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:914 +packages/quickjs-emscripten-core/dist/index.d.ts:937 *** @@ -526,7 +559,7 @@ Converts `handle` into a Javascript number. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:901 +packages/quickjs-emscripten-core/dist/index.d.ts:924 *** @@ -556,7 +589,7 @@ Javascript string (which will be converted automatically). #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:937 +packages/quickjs-emscripten-core/dist/index.d.ts:960 *** @@ -580,7 +613,7 @@ Converts `handle` to a Javascript string. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:905 +packages/quickjs-emscripten-core/dist/index.d.ts:928 *** @@ -601,7 +634,7 @@ registry in the guest, it will be created with Symbol.for on the host. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:910 +packages/quickjs-emscripten-core/dist/index.d.ts:933 *** @@ -618,7 +651,7 @@ Create a new QuickJS [array](https://developer.mozilla.org/en-US/docs/Web/JavaSc #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:838 +packages/quickjs-emscripten-core/dist/index.d.ts:861 *** @@ -638,7 +671,7 @@ Create a new QuickJS [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/ #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:842 +packages/quickjs-emscripten-core/dist/index.d.ts:865 *** @@ -658,7 +691,7 @@ Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:826 +packages/quickjs-emscripten-core/dist/index.d.ts:849 *** @@ -682,7 +715,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:826 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:884 +packages/quickjs-emscripten-core/dist/index.d.ts:907 #### newError(message) @@ -698,7 +731,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:884 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:888 +packages/quickjs-emscripten-core/dist/index.d.ts:911 #### newError(undefined) @@ -710,7 +743,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:888 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:889 +packages/quickjs-emscripten-core/dist/index.d.ts:912 *** @@ -751,7 +784,7 @@ return deferred.handle #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:883 +packages/quickjs-emscripten-core/dist/index.d.ts:906 *** @@ -775,7 +808,7 @@ Converts a Javascript number into a QuickJS value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:808 +packages/quickjs-emscripten-core/dist/index.d.ts:831 *** @@ -802,7 +835,7 @@ Like [`Object.create`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:833 +packages/quickjs-emscripten-core/dist/index.d.ts:856 *** @@ -823,7 +856,7 @@ resources; see the documentation on [QuickJSDeferredPromise](QuickJSDeferredProm ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:849 +packages/quickjs-emscripten-core/dist/index.d.ts:872 #### newPromise(promise) @@ -845,7 +878,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:857 +packages/quickjs-emscripten-core/dist/index.d.ts:880 #### newPromise(newPromiseFn) @@ -866,7 +899,7 @@ You can still resolve/reject the created promise "early" using its methods. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:864 +packages/quickjs-emscripten-core/dist/index.d.ts:887 *** @@ -890,7 +923,7 @@ Create a QuickJS [string](https://developer.mozilla.org/en-US/docs/Web/JavaScrip #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:812 +packages/quickjs-emscripten-core/dist/index.d.ts:835 *** @@ -911,7 +944,7 @@ All symbols created with the same key will be the same value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:822 +packages/quickjs-emscripten-core/dist/index.d.ts:845 *** @@ -932,7 +965,7 @@ No two symbols created with this function will be the same value. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:817 +packages/quickjs-emscripten-core/dist/index.d.ts:840 *** @@ -960,7 +993,7 @@ You may need to call [runtime](QuickJSContext.md#runtime).[QuickJSRuntime#execut #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:929 +packages/quickjs-emscripten-core/dist/index.d.ts:952 *** @@ -997,7 +1030,7 @@ properties. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:949 +packages/quickjs-emscripten-core/dist/index.d.ts:972 *** @@ -1017,7 +1050,7 @@ Throw an error in the VM, interrupted whatever current execution is in progress #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1003 +packages/quickjs-emscripten-core/dist/index.d.ts:1026 *** @@ -1045,7 +1078,7 @@ Does not support BigInt values correctly. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:896 +packages/quickjs-emscripten-core/dist/index.d.ts:919 *** @@ -1072,7 +1105,7 @@ If the result is an error, converts the error to a native object and throws the #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1023 +packages/quickjs-emscripten-core/dist/index.d.ts:1046 *** diff --git a/doc/quickjs-emscripten/classes/QuickJSDeferredPromise.md b/doc/quickjs-emscripten/classes/QuickJSDeferredPromise.md index 4eeaeb34..a458cc4e 100644 --- a/doc/quickjs-emscripten/classes/QuickJSDeferredPromise.md +++ b/doc/quickjs-emscripten/classes/QuickJSDeferredPromise.md @@ -28,6 +28,7 @@ itself, (2) the `resolve` callback, and (3) the `reject` callback. ## Contents +- [Extends](QuickJSDeferredPromise.md#extends) - [Implements](QuickJSDeferredPromise.md#implements) - [Constructors](QuickJSDeferredPromise.md#constructors) - [new QuickJSDeferredPromise(args)](QuickJSDeferredPromise.md#new-quickjsdeferredpromiseargs) @@ -41,6 +42,12 @@ itself, (2) the `resolve` callback, and (3) the `reject` callback. - [settled](QuickJSDeferredPromise.md#settled) - [Accessors](QuickJSDeferredPromise.md#accessors) - [alive](QuickJSDeferredPromise.md#alive) +- [Methods](QuickJSDeferredPromise.md#methods) + - [`[dispose]`()](QuickJSDeferredPromise.md#dispose) + +## Extends + +- [`UsingDisposable`](UsingDisposable.md) ## Implements @@ -71,9 +78,13 @@ this constructor directly. [`QuickJSDeferredPromise`](QuickJSDeferredPromise.md) +#### Overrides + +[`quickjs-emscripten.UsingDisposable.constructor`](UsingDisposable.md#constructors) + #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:639 +packages/quickjs-emscripten-core/dist/index.d.ts:661 ## Properties @@ -83,7 +94,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:639 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:621 +packages/quickjs-emscripten-core/dist/index.d.ts:643 *** @@ -97,11 +108,15 @@ packages/quickjs-emscripten-core/dist/index.d.ts:621 #### Implementation of -[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:664 +packages/quickjs-emscripten-core/dist/index.d.ts:686 *** @@ -115,7 +130,7 @@ are finished with it. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:627 +packages/quickjs-emscripten-core/dist/index.d.ts:649 *** @@ -125,7 +140,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:627 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:620 +packages/quickjs-emscripten-core/dist/index.d.ts:642 *** @@ -150,7 +165,7 @@ callbacks. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:662 +packages/quickjs-emscripten-core/dist/index.d.ts:684 *** @@ -175,7 +190,7 @@ callbacks. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:653 +packages/quickjs-emscripten-core/dist/index.d.ts:675 *** @@ -187,7 +202,7 @@ A native promise that will resolve once this deferred is settled. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:631 +packages/quickjs-emscripten-core/dist/index.d.ts:653 ## Accessors @@ -205,7 +220,31 @@ false after the object has been [dispose](QuickJSDeferredPromise.md#dispose)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:663 +packages/quickjs-emscripten-core/dist/index.d.ts:685 + +## Methods + +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 *** diff --git a/doc/quickjs-emscripten/classes/QuickJSRuntime.md b/doc/quickjs-emscripten/classes/QuickJSRuntime.md index a693cb7c..90ba831e 100644 --- a/doc/quickjs-emscripten/classes/QuickJSRuntime.md +++ b/doc/quickjs-emscripten/classes/QuickJSRuntime.md @@ -32,13 +32,14 @@ Configure ES module loading with [setModuleLoader](QuickJSRuntime.md#setmodulelo ## Contents -- [Extended By](QuickJSRuntime.md#extended-by) +- [Extends](QuickJSRuntime.md#extends) - [Implements](QuickJSRuntime.md#implements) - [Properties](QuickJSRuntime.md#properties) - [context](QuickJSRuntime.md#context) - [Accessors](QuickJSRuntime.md#accessors) - [alive](QuickJSRuntime.md#alive) - [Methods](QuickJSRuntime.md#methods) + - [`[dispose]`()](QuickJSRuntime.md#dispose) - [assertOwned()](QuickJSRuntime.md#assertowned) - [computeMemoryUsage()](QuickJSRuntime.md#computememoryusage) - [dispose()](QuickJSRuntime.md#dispose) @@ -53,9 +54,9 @@ Configure ES module loading with [setModuleLoader](QuickJSRuntime.md#setmodulelo - [setMemoryLimit()](QuickJSRuntime.md#setmemorylimit) - [setModuleLoader()](QuickJSRuntime.md#setmoduleloader) -## Extended By +## Extends -- [`QuickJSAsyncRuntime`](QuickJSAsyncRuntime.md) +- [`UsingDisposable`](UsingDisposable.md) ## Implements @@ -89,7 +90,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:160 true if the object is alive -false after the object has been [dispose](QuickJSRuntime.md#dispose)d +false after the object has been [dispose](QuickJSRuntime.md#dispose-1)d #### Source @@ -97,6 +98,30 @@ packages/quickjs-emscripten-core/dist/index.d.ts:187 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### assertOwned() > **assertOwned**(`handle`): `void` @@ -153,7 +178,11 @@ Dispose of the underlying resources used by this object. #### Implementation of -[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source diff --git a/doc/quickjs-emscripten/classes/QuickJSWASMModule.md b/doc/quickjs-emscripten/classes/QuickJSWASMModule.md index d287a607..cc695028 100644 --- a/doc/quickjs-emscripten/classes/QuickJSWASMModule.md +++ b/doc/quickjs-emscripten/classes/QuickJSWASMModule.md @@ -80,7 +80,7 @@ with name `"InternalError"` and message `"interrupted"`. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1192 +packages/quickjs-emscripten-core/dist/index.d.ts:1215 *** @@ -102,7 +102,7 @@ be disposed when the context is disposed. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1166 +packages/quickjs-emscripten-core/dist/index.d.ts:1189 *** @@ -124,7 +124,7 @@ loading for one or more [QuickJSContext](QuickJSContext.md)s inside the runtime. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1160 +packages/quickjs-emscripten-core/dist/index.d.ts:1183 *** diff --git a/doc/quickjs-emscripten/classes/Scope.md b/doc/quickjs-emscripten/classes/Scope.md index 5fa53d86..08307197 100644 --- a/doc/quickjs-emscripten/classes/Scope.md +++ b/doc/quickjs-emscripten/classes/Scope.md @@ -11,18 +11,24 @@ Lifetimes. See [withScope](Scope.md#withscope). and [withScopeAsync](Scope.md#wi ## Contents +- [Extends](Scope.md#extends) - [Implements](Scope.md#implements) - [Constructors](Scope.md#constructors) - [new Scope(undefined)](Scope.md#new-scopeundefined) - [Accessors](Scope.md#accessors) - [alive](Scope.md#alive) - [Methods](Scope.md#methods) + - [`[dispose]`()](Scope.md#dispose) - [dispose()](Scope.md#dispose) - [manage()](Scope.md#manage) - [withScope()](Scope.md#withscope) - [withScopeAsync()](Scope.md#withscopeasync) - [withScopeMaybeAsync()](Scope.md#withscopemaybeasync) +## Extends + +- [`UsingDisposable`](UsingDisposable.md) + ## Implements - [`Disposable`](../interfaces/Disposable.md) @@ -37,6 +43,10 @@ Lifetimes. See [withScope](Scope.md#withscope). and [withScopeAsync](Scope.md#wi [`Scope`](Scope.md) +#### Inherited from + +[`quickjs-emscripten.UsingDisposable.constructor`](UsingDisposable.md#constructors) + ## Accessors ### alive @@ -49,14 +59,38 @@ Lifetimes. See [withScope](Scope.md#withscope). and [withScopeAsync](Scope.md#wi true if the object is alive -false after the object has been [dispose](Scope.md#dispose)d +false after the object has been [dispose](Scope.md#dispose-1)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:594 +packages/quickjs-emscripten-core/dist/index.d.ts:616 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Inherited from + +[`quickjs-emscripten.UsingDisposable.[dispose]`](UsingDisposable.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### dispose() > **dispose**(): `void` @@ -69,11 +103,15 @@ Dispose of the underlying resources used by this object. #### Implementation of -[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose) +[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Overrides + +[`quickjs-emscripten.UsingDisposable.dispose`](UsingDisposable.md#abstract-dispose) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:595 +packages/quickjs-emscripten-core/dist/index.d.ts:617 *** @@ -97,7 +135,7 @@ Track `lifetime` so that it is disposed when this scope is disposed. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:593 +packages/quickjs-emscripten-core/dist/index.d.ts:615 *** @@ -127,7 +165,7 @@ Do not use with async functions. Instead, use [withScopeAsync](Scope.md#withscop #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:580 +packages/quickjs-emscripten-core/dist/index.d.ts:602 *** @@ -154,7 +192,7 @@ block returns. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:588 +packages/quickjs-emscripten-core/dist/index.d.ts:610 *** @@ -182,7 +220,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:588 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:581 +packages/quickjs-emscripten-core/dist/index.d.ts:603 *** diff --git a/doc/quickjs-emscripten/classes/StaticLifetime.md b/doc/quickjs-emscripten/classes/StaticLifetime.md index b4ed7850..d5a8874e 100644 --- a/doc/quickjs-emscripten/classes/StaticLifetime.md +++ b/doc/quickjs-emscripten/classes/StaticLifetime.md @@ -27,6 +27,7 @@ A Lifetime that lives forever. Used for constants. - [owner](StaticLifetime.md#owner) - [value](StaticLifetime.md#value) - [Methods](StaticLifetime.md#methods) + - [`[dispose]`()](StaticLifetime.md#dispose) - [consume()](StaticLifetime.md#consume) - [dispose()](StaticLifetime.md#dispose) - [dup()](StaticLifetime.md#dup) @@ -63,7 +64,7 @@ A Lifetime that lives forever. Used for constants. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:552 +packages/quickjs-emscripten-core/dist/index.d.ts:574 ## Properties @@ -77,7 +78,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:552 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:511 +packages/quickjs-emscripten-core/dist/index.d.ts:533 *** @@ -91,7 +92,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:511 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:512 +packages/quickjs-emscripten-core/dist/index.d.ts:534 *** @@ -105,7 +106,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:512 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:510 +packages/quickjs-emscripten-core/dist/index.d.ts:532 *** @@ -119,7 +120,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:510 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:507 +packages/quickjs-emscripten-core/dist/index.d.ts:529 *** @@ -141,7 +142,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:507 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:508 +packages/quickjs-emscripten-core/dist/index.d.ts:530 *** @@ -163,7 +164,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:508 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:509 +packages/quickjs-emscripten-core/dist/index.d.ts:531 ## Accessors @@ -177,11 +178,11 @@ packages/quickjs-emscripten-core/dist/index.d.ts:509 true if the object is alive -false after the object has been [dispose](StaticLifetime.md#dispose)d +false after the object has been [dispose](StaticLifetime.md#dispose-1)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:522 +packages/quickjs-emscripten-core/dist/index.d.ts:544 *** @@ -195,7 +196,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:522 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:553 +packages/quickjs-emscripten-core/dist/index.d.ts:575 *** @@ -209,7 +210,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:553 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:530 +packages/quickjs-emscripten-core/dist/index.d.ts:552 *** @@ -222,7 +223,7 @@ may become invalid, leading to memory errors. #### Throws -If the lifetime has been [dispose](StaticLifetime.md#dispose)d already. +If the lifetime has been [dispose](StaticLifetime.md#dispose-1)d already. #### Returns @@ -230,10 +231,30 @@ If the lifetime has been [dispose](StaticLifetime.md#dispose)d already. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:529 +packages/quickjs-emscripten-core/dist/index.d.ts:551 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten.Lifetime.[dispose]`](Lifetime.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### consume() #### consume(map) @@ -262,7 +283,7 @@ the result of `map(this)`. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:540 +packages/quickjs-emscripten-core/dist/index.d.ts:562 #### consume(map) @@ -286,7 +307,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:540 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:541 +packages/quickjs-emscripten-core/dist/index.d.ts:563 *** @@ -302,11 +323,11 @@ Dispose of [value](StaticLifetime.md#value-1) and perform cleanup. #### Overrides -[`quickjs-emscripten.Lifetime.dispose`](Lifetime.md#dispose) +[`quickjs-emscripten.Lifetime.dispose`](Lifetime.md#dispose-1) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:555 +packages/quickjs-emscripten-core/dist/index.d.ts:577 *** @@ -326,7 +347,7 @@ Create a new handle pointing to the same [value](StaticLifetime.md#value-1). #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:554 +packages/quickjs-emscripten-core/dist/index.d.ts:576 *** diff --git a/doc/quickjs-emscripten/classes/TestQuickJSWASMModule.md b/doc/quickjs-emscripten/classes/TestQuickJSWASMModule.md index 3ba52e00..9aee0d30 100644 --- a/doc/quickjs-emscripten/classes/TestQuickJSWASMModule.md +++ b/doc/quickjs-emscripten/classes/TestQuickJSWASMModule.md @@ -50,7 +50,7 @@ freed all the memory you've ever allocated. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1426 +packages/quickjs-emscripten-core/dist/index.d.ts:1449 ## Properties @@ -60,7 +60,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1426 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1424 +packages/quickjs-emscripten-core/dist/index.d.ts:1447 *** @@ -70,7 +70,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1424 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1425 +packages/quickjs-emscripten-core/dist/index.d.ts:1448 ## Methods @@ -84,7 +84,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1425 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1431 +packages/quickjs-emscripten-core/dist/index.d.ts:1454 *** @@ -98,7 +98,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1431 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1430 +packages/quickjs-emscripten-core/dist/index.d.ts:1453 *** @@ -122,7 +122,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1430 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1429 +packages/quickjs-emscripten-core/dist/index.d.ts:1452 *** @@ -144,7 +144,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1429 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1428 +packages/quickjs-emscripten-core/dist/index.d.ts:1451 *** @@ -166,7 +166,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1428 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1427 +packages/quickjs-emscripten-core/dist/index.d.ts:1450 *** diff --git a/doc/quickjs-emscripten/classes/UsingDisposable.md b/doc/quickjs-emscripten/classes/UsingDisposable.md new file mode 100644 index 00000000..1aaffcb3 --- /dev/null +++ b/doc/quickjs-emscripten/classes/UsingDisposable.md @@ -0,0 +1,101 @@ +[quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) + +*** + +[quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / UsingDisposable + +# Class: `abstract` UsingDisposable + +Base abstract class that helps implement [Disposable](../interfaces/Disposable.md) by providing a default implementation of [Symbol.dispose]([object Object]). + +## Contents + +- [Extended By](UsingDisposable.md#extended-by) +- [Implements](UsingDisposable.md#implements) +- [Constructors](UsingDisposable.md#constructors) + - [new UsingDisposable(undefined)](UsingDisposable.md#new-usingdisposableundefined) +- [Properties](UsingDisposable.md#properties) + - [`abstract` alive](UsingDisposable.md#abstract-alive) +- [Methods](UsingDisposable.md#methods) + - [`[dispose]`()](UsingDisposable.md#dispose) + - [`abstract` dispose()](UsingDisposable.md#abstract-dispose) + +## Extended By + +- [`Lifetime`](Lifetime.md) +- [`QuickJSContext`](QuickJSContext.md) +- [`QuickJSDeferredPromise`](QuickJSDeferredPromise.md) +- [`QuickJSRuntime`](QuickJSRuntime.md) +- [`Scope`](Scope.md) + +## Implements + +- [`Disposable`](../interfaces/Disposable.md) + +## Constructors + +### new UsingDisposable(undefined) + +> **new UsingDisposable**(): [`UsingDisposable`](UsingDisposable.md) + +#### Returns + +[`UsingDisposable`](UsingDisposable.md) + +## Properties + +### `abstract` alive + +> **`abstract`** **`readonly`** **alive**: `boolean` + +#### Implementation of + +[`quickjs-emscripten.Disposable.alive`](../interfaces/Disposable.md#alive) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:512 + +## Methods + +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.[dispose]`](../interfaces/Disposable.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + +### `abstract` dispose() + +> **`abstract`** **dispose**(): `void` + +Dispose of the underlying resources used by this object. + +#### Returns + +`void` + +#### Implementation of + +[`quickjs-emscripten.Disposable.dispose`](../interfaces/Disposable.md#dispose-1) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:516 + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten/classes/WeakLifetime.md b/doc/quickjs-emscripten/classes/WeakLifetime.md index 90bd3d4c..867fcd64 100644 --- a/doc/quickjs-emscripten/classes/WeakLifetime.md +++ b/doc/quickjs-emscripten/classes/WeakLifetime.md @@ -31,6 +31,7 @@ Used for function arguments. - [owner](WeakLifetime.md#owner) - [value](WeakLifetime.md#value) - [Methods](WeakLifetime.md#methods) + - [`[dispose]`()](WeakLifetime.md#dispose) - [consume()](WeakLifetime.md#consume) - [dispose()](WeakLifetime.md#dispose) - [dup()](WeakLifetime.md#dup) @@ -73,7 +74,7 @@ Used for function arguments. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:565 +packages/quickjs-emscripten-core/dist/index.d.ts:587 ## Properties @@ -87,7 +88,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:565 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:511 +packages/quickjs-emscripten-core/dist/index.d.ts:533 *** @@ -101,7 +102,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:511 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:512 +packages/quickjs-emscripten-core/dist/index.d.ts:534 *** @@ -115,7 +116,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:512 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:510 +packages/quickjs-emscripten-core/dist/index.d.ts:532 *** @@ -129,7 +130,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:510 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:507 +packages/quickjs-emscripten-core/dist/index.d.ts:529 *** @@ -151,7 +152,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:507 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:508 +packages/quickjs-emscripten-core/dist/index.d.ts:530 *** @@ -173,7 +174,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:508 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:509 +packages/quickjs-emscripten-core/dist/index.d.ts:531 ## Accessors @@ -187,11 +188,11 @@ packages/quickjs-emscripten-core/dist/index.d.ts:509 true if the object is alive -false after the object has been [dispose](WeakLifetime.md#dispose)d +false after the object has been [dispose](WeakLifetime.md#dispose-1)d #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:522 +packages/quickjs-emscripten-core/dist/index.d.ts:544 *** @@ -205,7 +206,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:522 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:531 +packages/quickjs-emscripten-core/dist/index.d.ts:553 *** @@ -219,7 +220,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:531 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:530 +packages/quickjs-emscripten-core/dist/index.d.ts:552 *** @@ -232,7 +233,7 @@ may become invalid, leading to memory errors. #### Throws -If the lifetime has been [dispose](WeakLifetime.md#dispose)d already. +If the lifetime has been [dispose](WeakLifetime.md#dispose-1)d already. #### Returns @@ -240,10 +241,30 @@ If the lifetime has been [dispose](WeakLifetime.md#dispose)d already. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:529 +packages/quickjs-emscripten-core/dist/index.d.ts:551 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +Just calls the standard .dispose() method of this class. + +#### Returns + +`void` + +#### Inherited from + +[`quickjs-emscripten.Lifetime.[dispose]`](Lifetime.md#dispose) + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:520 + +*** + ### consume() #### consume(map) @@ -272,7 +293,7 @@ the result of `map(this)`. ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:540 +packages/quickjs-emscripten-core/dist/index.d.ts:562 #### consume(map) @@ -296,7 +317,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:540 ##### Source -packages/quickjs-emscripten-core/dist/index.d.ts:541 +packages/quickjs-emscripten-core/dist/index.d.ts:563 *** @@ -312,11 +333,11 @@ Dispose of [value](WeakLifetime.md#value-1) and perform cleanup. #### Overrides -[`quickjs-emscripten.Lifetime.dispose`](Lifetime.md#dispose) +[`quickjs-emscripten.Lifetime.dispose`](Lifetime.md#dispose-1) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:566 +packages/quickjs-emscripten-core/dist/index.d.ts:588 *** @@ -336,7 +357,7 @@ Create a new handle pointing to the same [value](WeakLifetime.md#value-1). #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:535 +packages/quickjs-emscripten-core/dist/index.d.ts:557 *** diff --git a/doc/quickjs-emscripten/exports.md b/doc/quickjs-emscripten/exports.md index 7c826320..263bc5e3 100644 --- a/doc/quickjs-emscripten/exports.md +++ b/doc/quickjs-emscripten/exports.md @@ -93,6 +93,7 @@ - [Scope](classes/Scope.md) - [StaticLifetime](classes/StaticLifetime.md) - [TestQuickJSWASMModule](classes/TestQuickJSWASMModule.md) +- [UsingDisposable](classes/UsingDisposable.md) - [WeakLifetime](classes/WeakLifetime.md) ## Interfaces @@ -454,7 +455,7 @@ packages/quickjs-ffi-types/dist/index.d.ts:80 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1310 +packages/quickjs-emscripten-core/dist/index.d.ts:1333 *** @@ -507,7 +508,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:482 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1251 +packages/quickjs-emscripten-core/dist/index.d.ts:1274 *** @@ -572,7 +573,7 @@ Property key for getting or setting a property on a handle with #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:672 +packages/quickjs-emscripten-core/dist/index.d.ts:694 *** @@ -984,7 +985,7 @@ const getDebugModule = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SY #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1309 +packages/quickjs-emscripten-core/dist/index.d.ts:1332 *** @@ -1113,7 +1114,7 @@ const quickjs = new newQuickJSAsyncWASMModuleFromVariant( #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1298 +packages/quickjs-emscripten-core/dist/index.d.ts:1321 *** @@ -1175,7 +1176,7 @@ const quickjs = new newQuickJSWASMModuleFromVariant( #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1273 +packages/quickjs-emscripten-core/dist/index.d.ts:1296 *** @@ -1202,7 +1203,7 @@ This may be necessary in Cloudflare Workers, which can't compile WebAssembly mod #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1351 +packages/quickjs-emscripten-core/dist/index.d.ts:1374 *** @@ -1225,7 +1226,7 @@ Interrupt execution if it's still running after this time. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1359 +packages/quickjs-emscripten-core/dist/index.d.ts:1382 *** diff --git a/doc/quickjs-emscripten/interfaces/CustomizeVariantOptions.md b/doc/quickjs-emscripten/interfaces/CustomizeVariantOptions.md index a01ccc0a..b766eccc 100644 --- a/doc/quickjs-emscripten/interfaces/CustomizeVariantOptions.md +++ b/doc/quickjs-emscripten/interfaces/CustomizeVariantOptions.md @@ -28,7 +28,7 @@ The enumerable properties of this object will be passed verbatim, although they #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1343 +packages/quickjs-emscripten-core/dist/index.d.ts:1366 *** @@ -68,7 +68,7 @@ Often `''` (empty string) #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1341 +packages/quickjs-emscripten-core/dist/index.d.ts:1364 *** @@ -100,7 +100,7 @@ Debug logger #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1345 +packages/quickjs-emscripten-core/dist/index.d.ts:1368 *** @@ -112,7 +112,7 @@ If given, Emscripten will compile the WebAssembly.Module from these bytes. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1315 +packages/quickjs-emscripten-core/dist/index.d.ts:1338 *** @@ -124,7 +124,7 @@ If given, Emscripten will try to load the WebAssembly module data from this loca #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1313 +packages/quickjs-emscripten-core/dist/index.d.ts:1336 *** @@ -136,7 +136,7 @@ If given, Emscripten will instantiate the WebAssembly.Instance from this existin #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1317 +packages/quickjs-emscripten-core/dist/index.d.ts:1340 *** @@ -148,7 +148,7 @@ If given, we will provide the source map to Emscripten directly. This may only b #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1321 +packages/quickjs-emscripten-core/dist/index.d.ts:1344 *** @@ -160,7 +160,7 @@ If given, Emscripten will try to load the source map for the WebAssembly module #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1319 +packages/quickjs-emscripten-core/dist/index.d.ts:1342 *** diff --git a/doc/quickjs-emscripten/interfaces/Disposable.md b/doc/quickjs-emscripten/interfaces/Disposable.md index d2989b31..002cf0a9 100644 --- a/doc/quickjs-emscripten/interfaces/Disposable.md +++ b/doc/quickjs-emscripten/interfaces/Disposable.md @@ -15,6 +15,7 @@ Use [Scope](../classes/Scope.md) to manage cleaning up multiple disposables. - [Properties](Disposable.md#properties) - [alive](Disposable.md#alive) - [Methods](Disposable.md#methods) + - [`[dispose]`()](Disposable.md#dispose) - [dispose()](Disposable.md#dispose) ## Properties @@ -29,6 +30,22 @@ packages/quickjs-emscripten-core/dist/index.d.ts:498 ## Methods +### `[dispose]`() + +> **[dispose]**(): `void` + +A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + +#### Returns + +`void` + +#### Source + +packages/quickjs-emscripten-core/dist/index.d.ts:502 + +*** + ### dispose() > **dispose**(): `void` diff --git a/doc/quickjs-emscripten/interfaces/ModuleEvalOptions.md b/doc/quickjs-emscripten/interfaces/ModuleEvalOptions.md index 06dbb75f..aca78256 100644 --- a/doc/quickjs-emscripten/interfaces/ModuleEvalOptions.md +++ b/doc/quickjs-emscripten/interfaces/ModuleEvalOptions.md @@ -27,7 +27,7 @@ To remove the limit, set to `0`. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1102 +packages/quickjs-emscripten-core/dist/index.d.ts:1125 *** @@ -39,7 +39,7 @@ Memory limit, in bytes, of WebAssembly heap memory used by the QuickJS VM. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1097 +packages/quickjs-emscripten-core/dist/index.d.ts:1120 *** @@ -51,7 +51,7 @@ Module loader for any `import` statements or expressions. #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1106 +packages/quickjs-emscripten-core/dist/index.d.ts:1129 *** @@ -64,7 +64,7 @@ See [shouldInterruptAfterDeadline](../exports.md#shouldinterruptafterdeadline). #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1093 +packages/quickjs-emscripten-core/dist/index.d.ts:1116 *** diff --git a/doc/quickjs-emscripten/namespaces/errors/README.md b/doc/quickjs-emscripten/namespaces/errors/README.md index 4bbe4a7b..6a5fa9b3 100644 --- a/doc/quickjs-emscripten/namespaces/errors/README.md +++ b/doc/quickjs-emscripten/namespaces/errors/README.md @@ -35,7 +35,7 @@ #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1392 +packages/quickjs-emscripten-core/dist/index.d.ts:1415 *** @@ -45,7 +45,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1392 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1394 +packages/quickjs-emscripten-core/dist/index.d.ts:1417 *** @@ -55,7 +55,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1394 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1396 +packages/quickjs-emscripten-core/dist/index.d.ts:1419 *** @@ -65,7 +65,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1396 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1398 +packages/quickjs-emscripten-core/dist/index.d.ts:1421 *** @@ -75,7 +75,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1398 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1400 +packages/quickjs-emscripten-core/dist/index.d.ts:1423 *** @@ -85,7 +85,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1400 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1402 +packages/quickjs-emscripten-core/dist/index.d.ts:1425 *** @@ -95,7 +95,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1402 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1404 +packages/quickjs-emscripten-core/dist/index.d.ts:1427 *** @@ -105,7 +105,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1404 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1406 +packages/quickjs-emscripten-core/dist/index.d.ts:1429 ## Variables @@ -115,7 +115,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1406 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1392 +packages/quickjs-emscripten-core/dist/index.d.ts:1415 *** @@ -125,7 +125,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1392 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1394 +packages/quickjs-emscripten-core/dist/index.d.ts:1417 *** @@ -135,7 +135,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1394 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1396 +packages/quickjs-emscripten-core/dist/index.d.ts:1419 *** @@ -145,7 +145,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1396 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1398 +packages/quickjs-emscripten-core/dist/index.d.ts:1421 *** @@ -155,7 +155,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1398 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1400 +packages/quickjs-emscripten-core/dist/index.d.ts:1423 *** @@ -165,7 +165,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1400 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1402 +packages/quickjs-emscripten-core/dist/index.d.ts:1425 *** @@ -175,7 +175,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1402 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1404 +packages/quickjs-emscripten-core/dist/index.d.ts:1427 *** @@ -185,7 +185,7 @@ packages/quickjs-emscripten-core/dist/index.d.ts:1404 #### Source -packages/quickjs-emscripten-core/dist/index.d.ts:1406 +packages/quickjs-emscripten-core/dist/index.d.ts:1429 *** diff --git a/packages/internal-tsconfig/vite.base.config.mts b/packages/internal-tsconfig/vite.base.config.mts index fa07145b..bda0d569 100644 --- a/packages/internal-tsconfig/vite.base.config.mts +++ b/packages/internal-tsconfig/vite.base.config.mts @@ -2,8 +2,5 @@ import { defineConfig } from "vite" import tsconfigPaths from "vite-tsconfig-paths" export default defineConfig({ - esbuild: { - target: "es2020", - }, plugins: [tsconfigPaths()], }) diff --git a/packages/quickjs-emscripten-core/src/lifetime.ts b/packages/quickjs-emscripten-core/src/lifetime.ts index ae414503..ad01a0ac 100644 --- a/packages/quickjs-emscripten-core/src/lifetime.ts +++ b/packages/quickjs-emscripten-core/src/lifetime.ts @@ -4,15 +4,8 @@ import { QTS_DEBUG } from "./debug" import { QuickJSUseAfterFree } from "./errors" import type { QuickJSHandle } from "./types" -// Polyfill Symbol.dispose if needed -if (typeof Symbol.dispose !== "symbol") { - Object.defineProperty(Symbol, "dispose", { - configurable: false, - enumerable: false, - writable: false, - value: Symbol.for("dispose"), - }) -} +// Note: we don't need to polyfill Symbol.dispose because ESBuild falls back to +// Symbol.for("Symbol.dispose") when Symbol.dispose is not available. /** * An object that can be disposed. @@ -37,9 +30,22 @@ export interface Disposable { [Symbol.dispose](): void } +/** + * Base abstract class that helps implement {@link Disposable} by providing a default implementation of {@link Symbol.dispose}. + */ export abstract class UsingDisposable implements Disposable { + /** + * @returns true if the object is alive + * @returns false after the object has been {@link dispose}d + */ declare abstract readonly alive: boolean + /** + * Dispose of the underlying resources used by this object. + */ abstract dispose(): void + /** + * Just calls the standard .dispose() method of this class. + */ [Symbol.dispose]() { return this.dispose() } diff --git a/packages/quickjs-emscripten-core/src/runtime.ts b/packages/quickjs-emscripten-core/src/runtime.ts index 3ec01e27..915f2d0b 100644 --- a/packages/quickjs-emscripten-core/src/runtime.ts +++ b/packages/quickjs-emscripten-core/src/runtime.ts @@ -241,7 +241,7 @@ export class QuickJSRuntime extends UsingDisposable implements Disposable { * {@link QuickJSContext#resolvePromise} on the promise handle returned by the async function. */ executePendingJobs(maxJobsToExecute: number | void = -1): ExecutePendingJobsResult { - const ctxPtrOut = this.memory.newMutablePointerArray(1) + using ctxPtrOut = this.memory.newMutablePointerArray(1) const valuePtr = this.ffi.QTS_ExecutePendingJob( this.rt.value, maxJobsToExecute ?? -1, @@ -249,7 +249,6 @@ export class QuickJSRuntime extends UsingDisposable implements Disposable { ) const ctxPtr = ctxPtrOut.value.typedArray[0] as JSContextPointer - ctxPtrOut.dispose() if (ctxPtr === 0) { // No jobs executed. this.ffi.QTS_FreeValuePointerRuntime(this.rt.value, valuePtr) From 4edc3144d65fff4218b049c40a79386e95b65cbc Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 29 Dec 2023 11:30:15 -0800 Subject: [PATCH 3/6] document using statement; test example --- README.md | 28 +++++++++++++++++++ doc/README.md | 28 +++++++++++++++++++ doc/quickjs-emscripten/README.md | 28 +++++++++++++++++++ .../internal-tsconfig/vite.base.config.mts | 3 ++ .../quickjs-emscripten/src/readme.test.ts | 20 +++++++++++++ 5 files changed, 107 insertions(+) diff --git a/README.md b/README.md index 3b2f0c6f..b37a94a0 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ main() - [Interfacing with the interpreter](#interfacing-with-the-interpreter) - [Runtime](#runtime) - [Memory Management](#memory-management) + - [`using` statement](#using-statement) - [Scope](#scope) - [`Lifetime.consume(fn)`](#lifetimeconsumefn) - [Exposing APIs](#exposing-apis) @@ -192,6 +193,33 @@ vm.dispose() Here are some strategies to reduce the toil of calling `.dispose()` on each handle you create: +#### `using` statement + +The `using` statement is a Stage 3 (as of 2023-12-29) proposal for Javascript that declares a constant variable and automatically calls the `[Symbol.dispose]()` method of an object when it goes out of scope. Read more [in this Typescript release announcement][using]. Here's the "Interfacing with the interpreter" example re-written using `using`: + +```typescript +using vm = QuickJS.newContext() +let state = 0 + +// The block here isn't needed for correctness, but it shows +// how to get a tighter bound on the lifetime of `fnHandle`. +{ + using fnHandle = vm.newFunction("nextId", () => { + return vm.newNumber(++state) + }) + + vm.setProp(vm.global, "nextId", fnHandle) + // fnHandle.dispose() is called automatically when the block exits +} + +using nextId = vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)) +console.log("vm result:", vm.getNumber(nextId), "native state:", state) +// nextId.dispose() is called automatically when the block exits +// vm.dispose() is called automatically when the block exits +``` + +[using]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management + #### Scope A diff --git a/doc/README.md b/doc/README.md index b5898f76..f8745fc8 100644 --- a/doc/README.md +++ b/doc/README.md @@ -54,6 +54,7 @@ main() - [Interfacing with the interpreter](#interfacing-with-the-interpreter) - [Runtime](#runtime) - [Memory Management](#memory-management) + - [`using` statement](#using-statement) - [Scope](#scope) - [`Lifetime.consume(fn)`](#lifetimeconsumefn) - [Exposing APIs](#exposing-apis) @@ -196,6 +197,33 @@ vm.dispose() Here are some strategies to reduce the toil of calling `.dispose()` on each handle you create: +#### `using` statement + +The `using` statement is a Stage 3 (as of 2023-12-29) proposal for Javascript that declares a constant variable and automatically calls the `[Symbol.dispose]()` method of an object when it goes out of scope. Read more [in this Typescript release announcement][using]. Here's the "Interfacing with the interpreter" example re-written using `using`: + +```typescript +using vm = QuickJS.newContext() +let state = 0 + +// The block here isn't needed for correctness, but it shows +// how to get a tighter bound on the lifetime of `fnHandle`. +{ + using fnHandle = vm.newFunction("nextId", () => { + return vm.newNumber(++state) + }) + + vm.setProp(vm.global, "nextId", fnHandle) + // fnHandle.dispose() is called automatically when the block exits +} + +using nextId = vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)) +console.log("vm result:", vm.getNumber(nextId), "native state:", state) +// nextId.dispose() is called automatically when the block exits +// vm.dispose() is called automatically when the block exits +``` + +[using]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management + #### Scope A diff --git a/doc/quickjs-emscripten/README.md b/doc/quickjs-emscripten/README.md index 7ea7d27e..6de028f5 100644 --- a/doc/quickjs-emscripten/README.md +++ b/doc/quickjs-emscripten/README.md @@ -54,6 +54,7 @@ main() - [Interfacing with the interpreter](#interfacing-with-the-interpreter) - [Runtime](#runtime) - [Memory Management](#memory-management) + - [`using` statement](#using-statement) - [Scope](#scope) - [`Lifetime.consume(fn)`](#lifetimeconsumefn) - [Exposing APIs](#exposing-apis) @@ -216,6 +217,33 @@ vm.dispose() Here are some strategies to reduce the toil of calling `.dispose()` on each handle you create: +#### `using` statement + +The `using` statement is a Stage 3 (as of 2023-12-29) proposal for Javascript that declares a constant variable and automatically calls the `[Symbol.dispose]()` method of an object when it goes out of scope. Read more [in this Typescript release announcement][using]. Here's the "Interfacing with the interpreter" example re-written using `using`: + +```typescript +using vm = QuickJS.newContext() +let state = 0 + +// The block here isn't needed for correctness, but it shows +// how to get a tighter bound on the lifetime of `fnHandle`. +{ + using fnHandle = vm.newFunction("nextId", () => { + return vm.newNumber(++state) + }) + + vm.setProp(vm.global, "nextId", fnHandle) + // fnHandle.dispose() is called automatically when the block exits +} + +using nextId = vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)) +console.log("vm result:", vm.getNumber(nextId), "native state:", state) +// nextId.dispose() is called automatically when the block exits +// vm.dispose() is called automatically when the block exits +``` + +[using]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management + #### Scope A diff --git a/packages/internal-tsconfig/vite.base.config.mts b/packages/internal-tsconfig/vite.base.config.mts index bda0d569..1f42c5d6 100644 --- a/packages/internal-tsconfig/vite.base.config.mts +++ b/packages/internal-tsconfig/vite.base.config.mts @@ -2,5 +2,8 @@ import { defineConfig } from "vite" import tsconfigPaths from "vite-tsconfig-paths" export default defineConfig({ + build: { + target: "es2020", + }, plugins: [tsconfigPaths()], }) diff --git a/packages/quickjs-emscripten/src/readme.test.ts b/packages/quickjs-emscripten/src/readme.test.ts index 24cfa864..2b0e682d 100644 --- a/packages/quickjs-emscripten/src/readme.test.ts +++ b/packages/quickjs-emscripten/src/readme.test.ts @@ -101,6 +101,26 @@ describe("README.md", () => { assert.strictEqual(consoleLogCalls[0].join(" "), "vm result: 3 native state: 3") }) + it("context example w/ using statement", () => { + { + using vm = QuickJS.newContext() + let state = 0 + + { + using fnHandle = vm.newFunction("nextId", () => { + return vm.newNumber(++state) + }) + + vm.setProp(vm.global, "nextId", fnHandle) + } + + using nextId = vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)) + console.log("vm result:", vm.getNumber(nextId), "native state:", state) + } + + assert.strictEqual(consoleLogCalls[0].join(" "), "vm result: 3 native state: 3") + }) + it("runtime example", () => { // prettier-ignore { From 48a785e38b763b3ba9027d90156d0b79ad573cf1 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 29 Dec 2023 11:31:57 -0800 Subject: [PATCH 4/6] fix vite tests --- packages/internal-tsconfig/vite.base.config.mts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/internal-tsconfig/vite.base.config.mts b/packages/internal-tsconfig/vite.base.config.mts index 1f42c5d6..b1a17da4 100644 --- a/packages/internal-tsconfig/vite.base.config.mts +++ b/packages/internal-tsconfig/vite.base.config.mts @@ -2,7 +2,8 @@ import { defineConfig } from "vite" import tsconfigPaths from "vite-tsconfig-paths" export default defineConfig({ - build: { + // Incantation needed for vite to not barf on "using" statement + esbuild: { target: "es2020", }, plugins: [tsconfigPaths()], From bffe844b4aaee174b1397dd23baf206ad3b976b5 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 29 Dec 2023 11:36:46 -0800 Subject: [PATCH 5/6] smoketest node minimal when running yarn check --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e83be0b..2aa73e42 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "clean": "git clean -dfx ./build && yarn for-each-package clean", "prettier": "prettier --write .", "update-quickjs": "git subtree pull --prefix=quickjs --squash git@github.com:bellard/quickjs.git master", - "smoketest-node": "yarn tarball && ./scripts/smoketest-node.ts", + "smoketest-node": "yarn tarball && ./scripts/smoketest-node-minimal.ts && ./scripts/smoketest-node.ts", "smoketest-cra": "yarn tarball && ./scripts/smoketest-create-react-app.ts", "smoketest-vite": "yarn tarball && ./scripts/smoketest-vite.ts", "check": "yarn build && yarn check:packages && yarn check:format && yarn check:types && yarn test && yarn lint", @@ -26,7 +26,7 @@ "check:types": "yarn for-each-package tsc", "check:format": "prettier --check .", "check:packages": "./scripts/check-packages-built.ts", - "check:smoketest": "yarn tarball && ./scripts/smoketest-node.ts && ./scripts/smoketest-create-react-app.ts && ./scripts/smoketest-vite.ts", + "check:smoketest": "yarn tarball && ./scripts/smoketest-node-minimal.ts && ./scripts/smoketest-node.ts && ./scripts/smoketest-create-react-app.ts && ./scripts/smoketest-vite.ts", "lint": "npx eslint .", "fix": "yarn lint --fix ; yarn prettier > /dev/null", "build": "cp -v README.md packages/quickjs-emscripten && yarn build:codegen && yarn build:packages && yarn doc", From c9a5a5c94520e4bfb24e96d912ce742ee76a9a50 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Fri, 29 Dec 2023 11:37:16 -0800 Subject: [PATCH 6/6] smoketest changes --- examples/node-minimal/package-lock.json | 4 +- examples/node-typescript/package-lock.json | 48 +++++++++++----------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/node-minimal/package-lock.json b/examples/node-minimal/package-lock.json index 55359de7..f62a3427 100644 --- a/examples/node-minimal/package-lock.json +++ b/examples/node-minimal/package-lock.json @@ -17,7 +17,7 @@ "node_modules/@jitl/quickjs-ffi-types": { "version": "0.25.1", "resolved": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", - "integrity": "sha512-PtyXxJxf8+7nLRvYk3DPEeIhceFaE0zaBbnzVw8L5iFqLAE7YbIxvtcyIjnpeE84dHFjvL3OLGz0YeAXwutbnw==" + "integrity": "sha512-rwE+Z6RxDpdRKX3i+V9zEO3vJ6D5mnq8APWr3WTG3u/rtQR5MboEbUkLlrHmS0ftYuEacLhBECGMKjBKdQcrIA==" }, "node_modules/@jitl/quickjs-wasmfile-release-sync": { "version": "0.25.1", @@ -30,7 +30,7 @@ "node_modules/quickjs-emscripten-core": { "version": "0.25.1", "resolved": "file:../../build/tar/quickjs-emscripten-core.tgz", - "integrity": "sha512-rKO+bEkTA98HAZTxceGgLExU2IOBA3e2mCpLfBxlFMYZ4PbRFbW9P9zzrAq08E82/+srptWuqQEqKCrfMwqlBw==", + "integrity": "sha512-S8LXDaZE92xEUi8D22SN1t5Uedsmep0Kr02vDIftmRJ4m6IsPTzvoZX4OD88W5Xdzl9qL/i/dPpNM1jhLu8P1Q==", "license": "MIT", "dependencies": { "@jitl/quickjs-ffi-types": "0.25.1" diff --git a/examples/node-typescript/package-lock.json b/examples/node-typescript/package-lock.json index 03529293..f16ff34b 100644 --- a/examples/node-typescript/package-lock.json +++ b/examples/node-typescript/package-lock.json @@ -20,65 +20,65 @@ } }, "node_modules/@jitl/quickjs-ffi-types": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", - "integrity": "sha512-i5n7mzUFkPNf2GcTBSgaEBDKrdK+pooRa4nV53A8QOOkIFDY5RI27JMASR2uhH2wrkUCRqcLVWMA92VB0CS87A==" + "integrity": "sha512-rwE+Z6RxDpdRKX3i+V9zEO3vJ6D5mnq8APWr3WTG3u/rtQR5MboEbUkLlrHmS0ftYuEacLhBECGMKjBKdQcrIA==" }, "node_modules/@jitl/quickjs-wasmfile-debug-asyncify": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", - "integrity": "sha512-tWFS+A3jHj7VRz/svRTbprSbl5qHmmCO3oaMRAEE5JNA2egtgT21bAvT0Wm/AIkCLnO+YpQCds6xp9cJMFdRuA==", + "integrity": "sha512-0bN7QFjKdoIVMXhU37ehNbeP1pHWsmsr/shfziKnQq13u9wnJHIcOdgX/PC+UeiYRLGEb8MRKHi47bCYJMSWpQ==", "dependencies": { - "@jitl/quickjs-ffi-types": "0.25.0-rc.7" + "@jitl/quickjs-ffi-types": "0.25.1" } }, "node_modules/@jitl/quickjs-wasmfile-debug-sync": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", - "integrity": "sha512-ZhTtXLgasYiEQSwwpCuueO44kV0zkWbSNDYxeg2zGCe82sIIMRsVgYq+nvQXvIR0JoFzB+/gJg0GbWtMsYVVcg==", + "integrity": "sha512-+y9Q+jhfl/5xaBqcfBSI5LRMjNrYJTHpH2d6cAjpBvzc5ijeG6GM+CoYDg0T4+1gXCgIXzi71ChoTPCc4hx20g==", "dependencies": { - "@jitl/quickjs-ffi-types": "0.25.0-rc.7" + "@jitl/quickjs-ffi-types": "0.25.1" } }, "node_modules/@jitl/quickjs-wasmfile-release-asyncify": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", - "integrity": "sha512-X7SWwtwSAhqPW5Advts3xOereqWq+TaYyIqgmceeczSKH+JUXuFYhLbyV5as0nW7wS9/m5KRw6v9usldLUEGjw==", + "integrity": "sha512-vWaSYpmYl/8aPICn+ZTAFsq6wRhLgR3MOvFsun+jTD/vZEKTM1ETa0+QXK4S1Ii2uhUNDaRhBTw/N4lE1FlnDA==", "dependencies": { - "@jitl/quickjs-ffi-types": "0.25.0-rc.7" + "@jitl/quickjs-ffi-types": "0.25.1" } }, "node_modules/@jitl/quickjs-wasmfile-release-sync": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", - "integrity": "sha512-oGd1fuBCExmiIiNpT87iY3m8dsVhQgy+9ivBwnCXuYGsXyXYMlNbi3bOK5mf6wD8BBVmv0oWL1pmDod5wo4S/A==", + "integrity": "sha512-ONGiWzUe6MWoJezanVgOWYTisjJu4iKZsHfgBprvtoqWDaU82tk8VWOIa42lQng2ch6T2XeZjZHVnCKSB9uydw==", "dependencies": { - "@jitl/quickjs-ffi-types": "0.25.0-rc.7" + "@jitl/quickjs-ffi-types": "0.25.1" } }, "node_modules/quickjs-emscripten": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/quickjs-emscripten.tgz", - "integrity": "sha512-VO3LphNA/rf+Xe5ZoHm41xmyKfalSSoleZidgIBZKpzdlSe7ofdzGX+6w1KOV3np0IO5t89W3aR4hxb8VrlZRQ==", + "integrity": "sha512-GbbZ23vV++ra2IB0ocaA1u6GOWPryS43uadDiD022xSvEAeHvA6uvmuzkE3P1UoGQmACvSSty2ZXaUQvmDSn7A==", "license": "MIT", "dependencies": { - "@jitl/quickjs-wasmfile-debug-asyncify": "0.25.0-rc.7", - "@jitl/quickjs-wasmfile-debug-sync": "0.25.0-rc.7", - "@jitl/quickjs-wasmfile-release-asyncify": "0.25.0-rc.7", - "@jitl/quickjs-wasmfile-release-sync": "0.25.0-rc.7", - "quickjs-emscripten-core": "0.25.0-rc.7" + "@jitl/quickjs-wasmfile-debug-asyncify": "0.25.1", + "@jitl/quickjs-wasmfile-debug-sync": "0.25.1", + "@jitl/quickjs-wasmfile-release-asyncify": "0.25.1", + "@jitl/quickjs-wasmfile-release-sync": "0.25.1", + "quickjs-emscripten-core": "0.25.1" }, "engines": { "node": ">=16.0.0" } }, "node_modules/quickjs-emscripten-core": { - "version": "0.25.0-rc.7", + "version": "0.25.1", "resolved": "file:../../build/tar/quickjs-emscripten-core.tgz", - "integrity": "sha512-tty1MtuDy+3X61kPHmaDeGQPv3HKbbRk8x2SKvhNgMi4T/GLLa/9DV20xsu2B2kLTjgbCXwraDG8uTgPjgnjhg==", + "integrity": "sha512-S8LXDaZE92xEUi8D22SN1t5Uedsmep0Kr02vDIftmRJ4m6IsPTzvoZX4OD88W5Xdzl9qL/i/dPpNM1jhLu8P1Q==", "license": "MIT", "dependencies": { - "@jitl/quickjs-ffi-types": "0.25.0-rc.7" + "@jitl/quickjs-ffi-types": "0.25.1" } }, "node_modules/typescript": {