Skip to content

typescript-lib-state

Provides access to the process-wide shared-state bag of the generic, non-Obsidian part of the library.

The bag lives on globalThis under a Symbol.for key, so every copy of this module loaded in one realm shares it, whichever version it is. It holds what must exist once per realm: the debuggers, the debug instance and the shared abort controller. Obsidian-specific state stays in @mnaoumov/obsidian-lib, under its legacy __obsidianDevUtils global.

The slot is a cross-version wire format: its key and the TypescriptLibStateSlot shape only ever change additively.

Interface Description
TypescriptLibStateSlot The shared-state slot stored on globalThis.
Function Description
getTypescriptLibState Retrieves or creates a shared-state ValueWrapper for a given key.
getTypescriptLibStateSlot Retrieves or creates the shared-state slot.
resetTypescriptLibState Clears the shared-state bag. Intended for test isolation: call it before each test so accumulated state does not leak between tests.
Variable Description
TYPESCRIPT_LIB_STATE_KEY The key of the global slot holding the TypescriptLibStateSlot.
TYPESCRIPT_LIB_STATE_VERSION The version of the TypescriptLibStateSlot shape this copy writes.