Interface: AdkShim<TBundle>
Defined in: src/shims/index.ts:259
A memoizing handle over a lazily-resolved bundle, returned by createAdkShim. See the module-level remarks for the full GC-safety contract and the rationale for each accessor.
Type Parameters
| Type Parameter | Description |
|---|---|
TBundle extends object | The shape of the wrapped bundle. Must extend object — only objects are valid WeakRef targets, and this shim's memoization relies on WeakRef where available. |
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
proxy | readonly | TBundle | A Proxy<TBundle> that delegates every property read to the resolved bundle. Reading a property before anything has resolved (or after the memo has been collected) throws E_SHIM_NOT_RESOLVED naming the exact property that was touched, instead of returning undefined — the failure points at the call site instead of surfacing as a confusing "cannot call undefined" a few frames later. Remarks Bound function properties: reading a method off proxy returns it pre-bound to the resolved bundle, so const { foo } = shim.proxy; foo() behaves the same as shim.get().foo() — you can destructure without losing this. This is the direct replacement for the hand-rolled export let Foo: typeof AdkModule.Foo holder pattern: one proxy stands in for an entire bundle's worth of individually-declared holders, populated the same way (assign real values once resolved) but without the drift risk of hand-maintaining one let per symbol. | src/shims/index.ts:309 |
resolved | readonly | boolean | true when the bundle is currently dereferenceable (resolved, and — where WeakRef is available — not yet garbage collected). Live: re-evaluated on every read, so this can flip from true back to false between two reads with no code in between, if the collector runs. | src/shims/index.ts:293 |
Methods
get()
get(): TBundle;Defined in: src/shims/index.ts:287
Synchronously read the currently resolved bundle.
Returns
TBundle
The resolved bundle.
Remarks
For code that has already await-ed resolve at least once (directly, or transitively via something that did) and now wants to read the bundle without paying for another await. There is no synchronous equivalent of running an async resolver — if nothing is resolved yet (or the memo was garbage collected), this throws rather than blocking or returning a stale value.
Throws
E_SHIM_NOT_RESOLVED if there is no currently dereferenceable bundle.
resolve()
resolve(): Promise<TBundle>;Defined in: src/shims/index.ts:273
Resolve the bundle, awaiting the underlying AdkResolverFn if necessary.
Returns
Promise<TBundle>
A promise settling with the resolved bundle.
Remarks
Single-flight: if a resolution is already in progress, concurrent callers share that one in-flight promise rather than triggering a second resolver invocation. Already-resolved calls (including after re-resolving following a garbage-collected memo) return the cached bundle via an already-settled promise without touching the resolver at all.
Throws
E_SHIM_RESOLUTION_FAILED if the resolver rejects or throws. The memo is cleared on this path, so a subsequent call re-invokes the resolver.