/** * DevTools Hooks Bridge * * This module provides a set of no-op function stubs that `x-x.ts` (the core * component system) and other core modules (`atom.ts`, `events.ts`) call * instead of directly importing devtools modules. * * When devtools code is never imported (i.e. production), these remain as * empty no-ops and the bundler can tree-shake the entire devtools directory. * * When devtools IS imported (dev mode), the devtools modules call the * `installDevToolsHooks()` function to replace these stubs with real * implementations, wiring up registry, logging, and perf tracking. * * This breaks the static import chain: * x-x.ts ──✕──> devtools/registry.ts * atom.ts ──✕──> devtools/logStore.ts * events.ts ──✕──> devtools/logStore.ts * x-x.ts ──✕──> devtools/perfStore.ts * * Instead: * x-x.ts / atom.ts / events.ts ────> devtoolsHooks.ts (tiny, no-op stubs) * mates-devtools package ────> installDevToolsHooks() (fills in real impls) */ export interface DevToolsHooks { /** Register a component when it mounts */ registerComponent: (component: any, viewFn: Function) => void; /** Unregister a component when it unmounts */ unregisterComponent: (component: any, viewFn: Function | null) => void; /** Notify devtools that a component re-rendered */ notifyRender: (component: any) => void; /** Get display name for a component */ getComponentName: (component: any) => string; /** Log a component mount */ logComponentMount: (name: string) => void; /** Log a component render with duration */ logComponentRender: (name: string, durationMs: number) => void; /** Log a component unmount */ logComponentUnmount: (name: string) => void; /** Log an atom set call */ logAtomSet: (name: string, value: unknown) => void; /** Log an atom update call */ logAtomUpdate: (name: string) => void; /** Log an event trigger */ logEventTrigger: (name: string, data: unknown) => void; /** Log a cleanup event trigger */ logCleanupEventTrigger: (name: string, data: unknown) => void; /** Log an outgoing fetch request */ logFetchRequest: (method: string, url: string, payload?: string) => void; /** Log a successful fetch response */ logFetchResponse: (method: string, url: string, status: number, durationMs: number) => void; /** Log a failed fetch request */ logFetchError: (method: string, url: string, error: string, durationMs: number) => void; /** Record a render timing for the perf tab */ recordRender: (componentName: string, instanceId: number, durationMs: number) => void; } /** Register a component when it mounts (no-op until devtools is loaded) */ export declare function dtRegisterComponent(component: any, viewFn: Function): void; /** Unregister a component when it unmounts (no-op until devtools is loaded) */ export declare function dtUnregisterComponent(component: any, viewFn: Function | null): void; /** Notify devtools that a component re-rendered (no-op until devtools is loaded) */ export declare function dtNotifyRender(component: any): void; /** Get display name for a component (returns "Anonymous" until devtools is loaded) */ export declare function dtGetComponentName(component: any): string; /** Log a component mount (no-op until devtools is loaded) */ export declare function dtLogComponentMount(name: string): void; /** Log a component render with duration (no-op until devtools is loaded) */ export declare function dtLogComponentRender(name: string, durationMs: number): void; /** Log a component unmount (no-op until devtools is loaded) */ export declare function dtLogComponentUnmount(name: string): void; /** Log an atom set call (no-op until devtools is loaded) */ export declare function dtLogAtomSet(name: string, value: unknown): void; /** Log an atom update call (no-op until devtools is loaded) */ export declare function dtLogAtomUpdate(name: string): void; /** Log an event trigger (no-op until devtools is loaded) */ export declare function dtLogEventTrigger(name: string, data: unknown): void; /** Log a cleanup event trigger (no-op until devtools is loaded) */ export declare function dtLogCleanupEventTrigger(name: string, data: unknown): void; /** Log an outgoing fetch request (no-op until devtools is loaded) */ export declare function dtLogFetchRequest(method: string, url: string, payload?: string): void; /** Log a successful fetch response (no-op until devtools is loaded) */ export declare function dtLogFetchResponse(method: string, url: string, status: number, durationMs: number): void; /** Log a failed fetch request (no-op until devtools is loaded) */ export declare function dtLogFetchError(method: string, url: string, error: string, durationMs: number): void; /** Record a render timing for the perf tab (no-op until devtools is loaded) */ export declare function dtRecordRender(componentName: string, instanceId: number, durationMs: number): void; /** * Replace the no-op stubs with real devtools implementations. * * Called once when the mates-devtools package is first imported. This is what * bridges the gap: devtools code calls this to wire itself into the * component lifecycle without x-x.ts / atom.ts / events.ts needing a static * import on any devtools module. */ export declare function installDevToolsHooks(real: Partial): void; /** * Returns true if devtools hooks have been installed (i.e. devtools is active). * Can be used as a fast gate before doing devtools-only work. */ export declare function isDevToolsInstalled(): boolean; //# sourceMappingURL=devtoolsHooks.d.ts.map