Skip to content
1 min read · 186 words

Function: createAdkShim()

ts
function createAdkShim<TBundle>(
  resolveFn: AdkResolverFn<TBundle>,
): AdkShim<TBundle>;

Defined in: src/shims/index.ts:337

Construct a new AdkShim around a resolver.

Type Parameters

Type ParameterDefault typeDescription
TBundle extends object@nhtio/adkThe shape of the bundle this shim wraps. Defaults to AdkNamespace.

Parameters

ParameterTypeDescription
resolveFnAdkResolverFn<TBundle>The resolver this shim wraps. See AdkResolverFn and the module-level @example fences for the supported shapes (URL dynamic-import, same-graph passthrough, Worker handshake).

Returns

AdkShim<TBundle>

A new, independently-memoized AdkShim.

Remarks

Every call returns an independent shim with its own private memoization state — nothing is shared between instances, and constructing one never invokes resolveFn eagerly (resolution happens lazily, on first AdkShim.resolve call). Use this directly when you want a scoped, non-ambient binding (e.g. one shim per loaded plugin version); use registerAdkResolver / adk instead for the "one shared binding used across many files" ergonomics the docs app's flagship agent needs.

Example

Composing a battery into the resolved shape (the "battery-intersection" recipe):

ts
type MyBundle = AdkNamespace &
  typeof import("@nhtio/adk/batteries/context/thrift");
const shim = createAdkShim<MyBundle>(() => loadMyPrecompiledBundle());
const { subtractToFit } = await shim.resolve();