Skip to content

lib-registry

Registry of renderer-side resolvers that populate the lib argument injected into every evalInObsidian callback.

A provider package (e.g. obsidian-dev-utils) registers a resolver via registerLibResolver from its per-worker test setup (setupFiles), like the context resolvers in context-provider.ts — registration must happen in the worker because the namespace bootstrap is generated per-worker. Each resolver is a self-contained function that runs inside the Obsidian renderer and returns an object; the harness serializes it into the bootstrap and Object.assigns every resolver’s result into the single lib bag.

FunctionDescription
registerLibResolverRegisters a renderer-side resolver whose result is merged into the lib argument of every evalInObsidian callback. Call from a provider’s per-worker test setup (setupFiles), like the context resolvers. Registration is idempotent by source text: registering a resolver whose toString() matches an already-registered one is a no-op, so a setup module evaluated more than once does not merge the same library twice.
TypeDescription
LibResolverA self-contained function, evaluated inside the Obsidian renderer, that returns an object whose own enumerable properties are merged (via Object.assign) into the injected lib bag. It is serialized via toString() and must not close over any module scope (imports are unavailable in the serialized renderer closure); read a renderer global instead (e.g. a value a fixture plugin published on window). Returning null/undefined is tolerated at runtime (Object.assign ignores it).