* Migrate from Yarn to pnpm - Replace Yarn 4.0.2 with pnpm 10.29.3 as the package manager - Add pnpm-workspace.yaml and .npmrc configuration - Update all scripts to use pnpm commands - Rename getYarnWorkspaces() to getWorkspaces() in scripts/helpers.ts - Update CI workflow to use pnpm/action-setup@v4 with Node 22 - Add @jitl/tsconfig as root devDependency for proper resolution - Add variant packages as devDependencies for test resolution - Fix TypeScript 5.9 compatibility in memory.ts (Int32Array<ArrayBuffer>) - Upgrade typedoc to 0.28.17 for TypeScript 5.9 support - Upgrade typedoc-plugin-markdown to 4.10.0 - Regenerate documentation with new typedoc version * Clarify git commit --amend rule in CLAUDE.md * CI: Add --ignore-scripts to pnpm install Equivalent to yarn's YARN_ENABLE_SCRIPTS=0 - prevents prepare scripts from running during install, which would fail on a fresh checkout. * Fix pnpm tarball naming in smoketest scripts pnpm pack generates tarball names like jitl-quickjs-ffi-types-0.32.0.tgz (without @ prefix, with version) instead of @jitl-quickjs-ffi-types.tgz * Update examples to TypeScript 5.9 for compatibility The library now requires TypeScript 5.9+ due to stricter typed array generics (Int32Array<ArrayBuffer>). Update all TypeScript-using examples. * Use --legacy-peer-deps for create-react-app smoketest react-scripts@5 only supports TypeScript 3.x/4.x, but our library now requires TypeScript 5.9+ for typed array generics. Use --legacy-peer-deps to work around the peer dependency conflict. * Fix formatting issues * Fix remaining formatting issues * Add reminder to run prettier and lint before pushing * Document CI workflow in CLAUDE.md * Add typedoc.json and remark plugins for in-page table of contents - Add typedoc-plugin-remark, remark-toc, and remark-insert-headings - Configure remark plugins to generate "Contents" section for Class, Interface, Enum, TypeAlias, and Function pages - This restores the in-page TOC that lists methods/properties that was removed in typedoc-plugin-markdown 4.3.0 * Use custom remark plugin for headless TOC in docs Replace remark-insert-headings + remark-toc with a custom plugin that inserts the table of contents directly after the class description, without a separate "Contents" heading. * Revert to standard remark plugins for TOC with Contents heading Use remark-insert-headings + remark-toc instead of custom plugin. Remove mdast-util-toc dependency and custom remark-toc-headless.mjs. * Fix lockfile - remove mdast-util-toc * Ignore pnpm-lock.yaml in prettier, update .yarn to .pnpm --------- Co-authored-by: Hanzo Dev <[email protected]>
7.0 KiB
quickjs-emscripten / quickjs-emscripten-core / QuickJSDeferredPromise
Class: QuickJSDeferredPromise
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:71
QuickJSDeferredPromise wraps a QuickJS promise handle and allows resolveing or rejecting that promise. Use it to bridge asynchronous code on the host to APIs inside a QuickJSContext.
Managing the lifetime of promises is tricky. There are three
QuickJSHandles inside of each deferred promise object: (1) the promise
itself, (2) the resolve callback, and (3) the reject callback.
-
If the promise will be fulfilled before the end of it's owner's lifetime, the only cleanup necessary is
deferred.handle.dispose(), because calling resolve or reject will dispose of both callbacks automatically. -
As the return value of a VmFunctionImplementation, return handle, and ensure that either resolve or reject will be called. No other clean-up is necessary.
-
In other cases, call dispose, which will dispose handle as well as the QuickJS handles that back resolve and reject. For this object, dispose is idempotent.
Contents
Extends
Implements
Constructors
Constructor
new QuickJSDeferredPromise(
args):QuickJSDeferredPromise
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:95
Use QuickJSContext#newPromise to create a new promise instead of calling this constructor directly.
Parameters
args
context
promiseHandle
rejectHandle
resolveHandle
Returns
QuickJSDeferredPromise
Overrides
Properties
context
context:
QuickJSContext
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:73
handle
handle:
QuickJSHandle
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:80
A handle of the Promise instance inside the QuickJSContext. You must dispose handle or the entire QuickJSDeferredPromise once you are finished with it.
owner
owner:
QuickJSRuntime
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:72
settled
settled:
Promise<void>
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:85
A native promise that will resolve once this deferred is settled.
Accessors
alive
Get Signature
get alive():
boolean
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:166
Returns
boolean
true if the object is alive
Implementation of
Overrides
Methods
[dispose]()
[dispose]():
void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:47
Just calls the standard .dispose() method of this class.
Returns
void
Implementation of
Inherited from
dispose()
dispose():
void
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:170
Dispose of the underlying resources used by this object.
Returns
void
Implementation of
Overrides
reject()
reject(
value?):void
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:147
Reject handle with the given value, if any. Calling this method after calling dispose is a no-op.
Note that after rejecting a promise, you may need to call QuickJSRuntime#executePendingJobs to propagate the result to the promise's callbacks.
Parameters
value?
Returns
void
resolve()
resolve(
value?):void
Defined in: packages/quickjs-emscripten-core/src/deferred-promise.ts:120
Resolve handle with the given value, if any. Calling this method after calling dispose is a no-op.
Note that after resolving a promise, you may need to call QuickJSRuntime#executePendingJobs to propagate the result to the promise's callbacks.
Parameters
value?
Returns
void