/** * Scope Tracker - Handles variable scoping and import tracking * * Tracks useGT/getGT variable assignments across nested scopes * Manages variable shadowing and GT component imports */ import { GT_ALL_FUNCTIONS, GT_CALLBACK_FUNCTIONS } from '../utils/constants/gt/constants'; /** * Information about a scope */ export interface ScopeInfo { /** The scope ID */ id: number; /** The parent scope ID */ parentId: number; /** The depth of the scope */ depth: number; } /** * Variable type represents which group the variable belongs to */ export type VariableType = 'generaltranslation' | 'react' | 'other'; /** * Information about a scoped variable assignment */ export interface ScopedVariable { /** The scope ID */ scopeId: number; /** The canonical name of the variable (useGT, getGT, T, etc.) */ canonicalName: string | GT_ALL_FUNCTIONS; /** The variable name (t, translationFunction, etc.) */ aliasName: string; /** Whether the variable is a translation function * @deprecated */ isTranslationFunction: boolean; type: VariableType; /** The identifier for the variable */ identifier: number; } export interface ScopedGTFunction extends ScopedVariable { /** The canonical name of the GT function (useGT, getGT, etc.) */ canonicalName: GT_ALL_FUNCTIONS; /** The type of GT function */ type: 'generaltranslation'; } type SerializedScopeTracker = { nextScopeId: number; currentScope: number; scopeStack: number[]; scopeInfo: Record; scopedVariables: Record; namespaceImports: string[]; }; /** * Tracks scope hierarchy and variable assignments within scopes */ export declare class ScopeTracker { /** Next scope ID to assign */ private nextScopeId; /** Current scope being processed */ private currentScope; /** Stack to track scope nesting for proper exit handling */ private scopeStack; /** Information about each scope */ private scopeInfo; /** Variables tracked per scope */ private scopedVariables; /** Namespace imports (e.g., GT from 'gt-next') */ private namespaceImports; /** * Enter a new scope and return the new scope ID */ enterScope(): number; /** * Exit the current scope and return to parent (with aggressive cleanup) */ exitScope(): void; /** * Track a variable assignment in the current scope */ trackVariable(aliasName: string, canonicalName: string, isTranslationFunction: boolean, type: VariableType, identifier: number): void; /** * Track a translation function variable */ trackTranslationVariable(aliasName: string, canonicalName: GT_ALL_FUNCTIONS, identifier: number): void; /** * Track a translation callback function variable * const useGT_callback = useGT() * @param aliasName - The alias name of callback variable * @param canonicalName - The canonical name of the callback function * @param identifier - The identifier of the callback function * TODO: canonicalName might have to be shifted to the name of the RValue eg useGT in t = useGT() so you can properly map back to the original function */ trackTranslationCallbackVariable(aliasName: string, canonicalName: GT_CALLBACK_FUNCTIONS, identifier: number): void; /** * Track react variable */ trackReactVariable(variableName: string, assignedValue: string, identifier: number): void; /** * Track a non-translation variable (convenience method) */ trackRegularVariable(variableName: string, assignedValue: string): void; /** * Find if a variable is accessible in the current scope */ getVariable(variableName: string): ScopedVariable | undefined; /** * Get the translation variable info if it exists in current scope */ getTranslationVariable(variableName: string): ScopedGTFunction | undefined; private isScopedGTFunction; /** * Add a namespace import (e.g., GT from 'gt-next') */ addNamespaceImport(name: string): void; /** * Check if a namespace import exists */ hasNamespaceImport(name: string): boolean; /** * Get scope info for debugging */ getScopeInfo(scopeId: number): ScopeInfo | undefined; /** * Helper convert to string */ serialize(): SerializedScopeTracker; /** * Helper to repopulate */ unserialize(input: SerializedScopeTracker): void; } export {}; //# sourceMappingURL=ScopeTracker.d.ts.map