/** * Component instance management and lifecycle hooks. * * Manages the current component context during setup and provides * lifecycle hook registration (onMounted, onUnmounted, onCreated, onUpdated). */ import type { ComponentSetupContext, MountContext } from './component-types.js'; /** * Get the devtools instance id assigned to a ctx, or `null` if none * was minted (no hook was installed when the ctx was first set as * current). Used by `notifyComponent*` to tag events with the same * id reactivity events reference via `ownerComponentId`. * * @internal */ export declare function getInstanceId(ctx: ComponentSetupContext | null | undefined): number | null; /** * Get the parent component's instance id by following `ctx.parent` * — the same field the DI system uses for `inject()` traversal * (set by the renderer at the point of component setup). Returns * `null` for roots. * * @internal */ export declare function getParentInstanceId(ctx: ComponentSetupContext | null | undefined): number | null; /** * Returns the setup context of the currently executing component, or `null` if called outside setup. * * Use this to access the component context (props, emit, etc.) from composable functions * or lifecycle hooks that run during component setup. * * @example * ```ts * function useMyComposable() { * const ctx = getCurrentInstance(); * if (!ctx) throw new Error('Must be called during component setup'); * ctx.onMounted(({ el }) => console.log('Mounted to', el)); * } * ``` */ export declare function getCurrentInstance(): ComponentSetupContext | null; export declare function setCurrentInstance(ctx: ComponentSetupContext | null): ComponentSetupContext | null; /** * Register a callback to run after the component is mounted to the DOM. * Must be called during component setup. * * @param fn - Callback receiving a {@link MountContext} with the component's root element. * * @example * ```ts * const MyComponent = component(() => { * onMounted(({ el }) => { * console.log('Mounted to', el); * }); * return () =>
Hello
; * }); * ``` */ export declare function onMounted(fn: (ctx: MountContext) => void): void; /** * Register a callback to run when the component is unmounted from the DOM. * Must be called during component setup. Use for cleanup (event listeners, timers, subscriptions). * * @param fn - Callback receiving a {@link MountContext} with the component's root element. * * @example * ```ts * const MyComponent = component(() => { * const timer = setInterval(() => tick(), 1000); * onUnmounted(() => clearInterval(timer)); * return () =>
Tick
; * }); * ``` */ export declare function onUnmounted(fn: (ctx: MountContext) => void): void; /** * Register a callback to run immediately after component setup completes, * before the first render. Must be called during component setup. * * @example * ```ts * const MyComponent = component(() => { * onCreated(() => console.log('Setup done, about to render')); * return () =>
Hello
; * }); * ``` */ export declare function onCreated(fn: () => void): void; /** * Register a callback to run after every reactive re-render of the component. * Must be called during component setup. * * @example * ```ts * const Counter = component(() => { * const state = signal({ count: 0 }); * onUpdated(() => console.log('Re-rendered with count:', state.count)); * return () => ; * }); * ``` */ export declare function onUpdated(fn: () => void): void; //# sourceMappingURL=component-lifecycle.d.ts.map