import z$1 from "zod"; //#region packages/common/src/canonical-id/canonical-id.d.ts type CanonicalId = string & { readonly __brand: "CanonicalId"; }; declare const CanonicalIdSchema: z$1.ZodType; /** * Options for creating a canonical ID. */ type CreateCanonicalIdOptions = { /** * Base directory for relative path computation. * When provided, the canonical ID will use a relative path from baseDir. * When undefined, an absolute path is required and used as-is. */ readonly baseDir?: string; }; /** * Create a canonical ID from a file path and AST path. * * @param filePath - The file path (absolute, or relative if baseDir is provided) * @param astPath - The AST path identifying the definition within the file * @param options - Optional configuration including baseDir for relative path support * @returns A canonical ID in the format "{path}::{astPath}" */ declare const createCanonicalId: (filePath: string, astPath: string, options?: CreateCanonicalIdOptions) => CanonicalId; /** * Check if a canonical ID uses a relative path. * Relative canonical IDs do not start with '/'. * * @param canonicalId - The canonical ID to check * @returns true if the canonical ID uses a relative path */ declare const isRelativeCanonicalId: (canonicalId: CanonicalId | string) => boolean; /** * Parse a canonical ID into its components. * @param canonicalId - The canonical ID to parse (e.g., "/app/src/user.ts::userFragment") * @returns An object with filePath and astPath */ declare const parseCanonicalId: (canonicalId: CanonicalId | string) => { filePath: string; astPath: string; }; /** * Validation result for canonical ID format. */ type CanonicalIdValidationResult = { readonly isValid: true; } | { readonly isValid: false; readonly reason: string; }; /** * Validate a canonical ID format. * A valid canonical ID has format: "{filePath}::{astPath}" * where both filePath and astPath are non-empty. * * @param canonicalId - The canonical ID to validate * @returns Validation result with isValid boolean and optional error reason */ declare const validateCanonicalId: (canonicalId: string) => CanonicalIdValidationResult; //#endregion //#region packages/common/src/canonical-id/path-tracker.d.ts /** * Scope frame for tracking AST path segments */ type ScopeFrame = { /** Name segment (e.g., "MyComponent", "useQuery", "arrow#1") */ readonly nameSegment: string; /** Kind of scope */ readonly kind: "function" | "class" | "variable" | "property" | "method" | "expression"; /** Occurrence index for disambiguation */ readonly occurrence: number; }; /** * Opaque handle for scope tracking */ type ScopeHandle = { readonly __brand: "ScopeHandle"; readonly depth: number; }; /** * Canonical path tracker interface */ interface CanonicalPathTracker { /** * Enter a new scope during traversal * @param options Scope information * @returns Handle to use when exiting the scope */ enterScope(options: { segment: string; kind: ScopeFrame["kind"]; stableKey?: string; }): ScopeHandle; /** * Exit a scope during traversal * @param handle Handle returned from enterScope */ exitScope(handle: ScopeHandle): void; /** * Register a definition discovered during traversal * @returns Definition metadata including astPath and canonical ID information */ registerDefinition(): { astPath: string; isTopLevel: boolean; exportBinding?: string; }; /** * Resolve a canonical ID from an astPath * @param astPath AST path string * @returns Canonical ID */ resolveCanonicalId(astPath: string): CanonicalId; /** * Register an export binding * @param local Local variable name * @param exported Exported name */ registerExportBinding(local: string, exported: string): void; /** * Get current scope depth * @returns Current depth (0 = top level) */ currentDepth(): number; } /** * Create a canonical path tracker * * @param options Configuration options * @returns Tracker instance * * @example * ```typescript * // In a Babel plugin * const tracker = createCanonicalTracker({ filePath: state.filename }); * * const visitor = { * FunctionDeclaration: { * enter(path) { * const handle = tracker.enterScope({ * segment: path.node.id.name, * kind: 'function' * }); * }, * exit(path) { * tracker.exitScope(handle); * } * } * }; * ``` */ declare const createCanonicalTracker: (options: { filePath: string; /** * Base directory for relative path computation in canonical IDs. * When provided, canonical IDs will use relative paths from baseDir. */ baseDir?: string; getExportName?: (localName: string) => string | undefined; }) => CanonicalPathTracker; /** * Helper to create occurrence tracker (for backward compatibility) */ declare const createOccurrenceTracker: () => { getNextOccurrence: (key: string) => number; }; /** * Helper to create path tracker (for backward compatibility) */ declare const createPathTracker: () => { ensureUniquePath: (basePath: string) => string; }; /** * Build AST path from scope stack (for backward compatibility) */ declare const buildAstPath: (stack: readonly ScopeFrame[]) => string; //#endregion export { createCanonicalTracker as a, CanonicalId as c, CreateCanonicalIdOptions as d, createCanonicalId as f, validateCanonicalId as h, buildAstPath as i, CanonicalIdSchema as l, parseCanonicalId as m, ScopeFrame as n, createOccurrenceTracker as o, isRelativeCanonicalId as p, ScopeHandle as r, createPathTracker as s, CanonicalPathTracker as t, CanonicalIdValidationResult as u }; //# sourceMappingURL=index-KB_f9ZJF.d.mts.map