/** * Provides a mechanism for 'instrumentation' hooks to be applied to a Casium * application at runtime. * * Uses global state at `window[INSTRUMENTATION_KEY]` to allow * `withStateManager` and `onMessage` to by used both inside the main * application bundle (for example, to provide custom integration that is * internal to the application) or outside (for example, to implement external * tools such as the Casium Developer Tools). */ import { Container, GenericObject } from './core'; import ExecContext from './runtime/exec_context'; import StateManager from './runtime/state_manager'; export declare type StateManagerCallback = (stateMgr: StateManager) => void; export declare type OnMessageCallback = (msg: Message) => void; export declare type Message = { context: ExecContext; container: Container; msg: GenericObject | null; prev: GenericObject | null; next: GenericObject; path: (string | symbol)[]; cmds: any[]; subs: any[]; }; export declare const INSTRUMENTATION_KEY = "__CASIUM_INSTRUMENTATION__"; declare global { interface Window { [INSTRUMENTATION_KEY]: { stateManager?: StateManager; withStateManager: StateManagerCallback[]; onMessage: OnMessageCallback[]; }; } } /** * Executes `callback` with the root Execution Context's State Manager instance. * If the root Execution Context has not been initialized yet, execution of * `callback` is deferred until it is. */ export declare const withStateManager: (callback: StateManagerCallback) => void; /** * Executes `callback` whenever an Execution Context dispatches a Message. * * @note Any Messages that were dispatched *before* `callback` is registered * will *not* be applied. To ensure that all messages are captured, ensure that * `onMessage` is called *before* defining the root Container. */ export declare const onMessage: (callback: OnMessageCallback) => void; /** * To be called by an Execution Context whenever it dispatches a Message. * * @note This function is *not* intended to be used by consumers; it should only * be called from within an Execution Context. */ export declare const notify: (msg: Message) => false | void; /** * To be called by the root Execution Context when it is initialized. Processes * all pending `withStateManager` hooks. * * @note This function is *not* intended to be used by consumers; it should only * be called from within an Execution Context. */ export declare const intercept: (stateMgr: StateManager) => StateManager;