* 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]>
10 KiB
quickjs-emscripten / quickjs-emscripten-core / Lifetime
Class: Lifetime<T, TCopy, Owner>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:68
A lifetime prevents access to a value after the lifetime has been disposeed.
Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers.
Contents
Extends
Extended by
Type Parameters
T
T
TCopy
TCopy = never
Owner
Owner = never
Implements
Constructors
Constructor
new Lifetime<
T,TCopy,Owner>(_value,copier?,disposer?,_owner?):Lifetime<T,TCopy,Owner>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:83
When the Lifetime is disposed, it will call disposer(_value). Use the
disposer function to implement whatever cleanup needs to happen at the end
of value's lifetime.
_owner is not used or controlled by the lifetime. It's just metadata for
the creator.
Parameters
_value
T
copier?
(value) => TCopy
disposer?
(value) => void
_owner?
Owner
Returns
Lifetime<T, TCopy, Owner>
Overrides
Properties
_alive
protected_alive:boolean=true
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:72
_constructorStack
protected_constructorStack:string|undefined
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:73
_owner?
protectedreadonlyoptional_owner:Owner
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:87
_value
protectedreadonly_value:T
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:84
copier()?
protectedreadonlyoptionalcopier: (value) =>TCopy
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:85
Parameters
value
T | TCopy
Returns
TCopy
disposer()?
protectedreadonlyoptionaldisposer: (value) =>void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:86
Parameters
value
T | TCopy
Returns
void
Accessors
alive
Get Signature
get alive():
boolean
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:92
Returns
boolean
true if the object is alive
Implementation of
Overrides
dupable
Get Signature
get dupable():
boolean
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:111
Returns
boolean
owner
Get Signature
get owner():
Owner|undefined
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:107
Returns
Owner | undefined
value
Get Signature
get value():
T
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:102
The value this Lifetime protects. You must never retain the value - it may become invalid, leading to memory errors.
Throws
If the lifetime has been disposed already.
Returns
T
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
assertAlive()
protectedassertAlive():void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:182
Returns
void
consume()
Call Signature
consume<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:135
Call map with this lifetime, then dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
Call Signature
consume<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:138
Call map with this lifetime, then dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
dispose()
dispose():
void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:174
Dispose of value and perform cleanup.
Returns
void
Implementation of
Overrides
dup()
dup():
Lifetime<TCopy,TCopy,Owner>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:118
Create a new handle pointing to the same value.
Returns
Lifetime<TCopy, TCopy, Owner>
map()
Call Signature
map<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:151
Call map with this lifetime, returning the result.
Does not dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
Call Signature
map<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:152
Call map with this lifetime, returning the result.
Does not dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
tap()
Call Signature
tap(
fn):this
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:164
Call fn with this lifetime, then return this. Does not dispose the
lifetime. Useful for imperative operations within an expression, like when
you're building up objects, or to add logging in the middle of a call chain.
Parameters
fn
(lifetime) => void
Returns
this
this
Call Signature
tap(
fn):QuickJSHandle
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:165
Call fn with this lifetime, then return this. Does not dispose the
lifetime. Useful for imperative operations within an expression, like when
you're building up objects, or to add logging in the middle of a call chain.
Parameters
fn
(lifetime) => void
Returns
this