/** * `@lensmcp/react-instrumentation/babel-plugin` * * JSX identity transform. For every `` / `
` in dev: * * * → * * * Plus opt-outs: * - File-level comment `// @lensmcp-ignore` skips the whole file. * - Element-level `data-lensmcp-ignore` skips that one element. * - Element-level leading `// @lensmcp-ignore` comment skips it. * * The transform is dev-only: pass `production: true` (or omit it and * rely on the `NODE_ENV` check) to make the plugin a no-op. * * Usage in `vite.config.ts`: * import lensmcpBabel from '@lensmcp/react-instrumentation/babel-plugin'; * react({ babel: { plugins: [lensmcpBabel] } }) */ import type { PluginObj, PluginPass, types as t } from '@babel/core'; export interface LensmcpBabelOptions { /** Skip the transform entirely. Default: `process.env.NODE_ENV === 'production'`. */ production?: boolean; /** When true, also inject `data-agent-source`. Default: true. */ includeSource?: boolean; /** Root path used to make `data-agent-source` relative. Default: cwd. */ rootDir?: string; /** Rewrite useEffect/useMemo/useCallback → traced*. Default: true. */ autoWrapHooks?: boolean; /** Wrap `createRoot(x).render()` with `` + installFlowFetch. Default: true. */ autoWrapRoot?: boolean; /** Wrap JSX interaction handlers (onClick/onSubmit/…) with `withFlow` so a * user interaction starts a correlated flow. Default: true. */ autoFlowHandlers?: boolean; /** Which JSX `on*` attributes start a flow. Default: the intent set below. */ flowEvents?: string[]; } interface State extends PluginPass { opts: LensmcpBabelOptions; fileIgnored?: boolean; relativePath?: string; /** traced* helper names this module needs imported. */ needHelpers?: Set; /** A root render was wrapped → also import LensmcpRoot + installFlowFetch. */ needRoot?: boolean; hookIndex?: number; /** Which `on*` handlers to auto-wrap with `withFlow`. */ flowEvents?: Set; /** Local variables holding a `createRoot(...)` result (for `root.render(...)`). */ rootVars?: Set; } interface BabelApi { types: typeof t; } export default function lensmcpBabelPlugin(api: BabelApi): PluginObj; export {};