import * as types from '@babel/types'; import { ComponentStructure } from '@teleporthq/teleport-types'; /** * Shared AST lookups for the plugins that edit the generated AI chat * component. Both of them splice statements around its state hooks, and both * must agree on exactly which declaration is which — a second, subtly * different matcher is how one plugin ends up silently doing nothing. */ /** State key holding the chat transcript (`AI_CHAT_MESSAGES_STATE_KEY`). */ export declare const CHAT_MESSAGES_STATE_KEY = "chatMessages"; /** State key holding the id of the conversation being appended to. */ export declare const CHAT_CONVERSATION_ID_STATE_KEY = "chatConversationId"; export declare const isChatComponent: (componentName: string) => boolean; /** The `jsx-component` chunk, when it is the declaration these plugins expect. */ export declare const findJsxComponentChunk: (chunks: ComponentStructure['chunks']) => types.VariableDeclaration | null; export declare const findComponentBody: (chunkContent: types.VariableDeclaration) => types.BlockStatement | null; export interface StateHookMatch { /** Position of the declaration in the component body. */ index: number; declarator: types.VariableDeclarator; setterName: string; } /** * `const [, set] = useState()` — the declaration * `createStateHookAST` emits, with exactly one argument. * * The single-argument requirement is deliberate: it is what makes wrapping the * initializer safe, and what makes a second plugin's wrap visible to the first * (a wrapped call still has exactly one argument). */ export declare const findStateHook: (body: types.BlockStatement, stateKey: string) => StateHookMatch | null; /** * The `const x = identifier(...)` declarator anywhere inside `body`, so a later * plugin can wrap that call in place. * * Used to hand the session-restore call to the localization plugin, which runs * after the persistence plugin and has to wrap whatever produces a * `chatMessages` value — the `useState` initializer AND the restored transcript. */ export declare const findCallInitDeclarator: (body: types.BlockStatement, identifier: string) => types.VariableDeclarator | null; /** Whether the component body already calls `identifier(...)` anywhere. */ export declare const bodyCallsFunction: (body: types.BlockStatement, identifier: string) => boolean; //# sourceMappingURL=ast-utils.d.ts.map