{"version":3,"file":"utils-DOz9GTVx.mjs","names":["JS_TO_TS_EXTENSION_MAP: Readonly<Record<string, readonly string[]>>","cached: { value: T } | null","content: string","parsed: unknown","resolvedPaths: Record<string, readonly string[]>"],"sources":["../src/utils/path.ts","../src/utils/alias-resolver.ts","../src/utils/cached-fn.ts","../src/utils/swc-span.ts","../src/utils/tsconfig.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { dirname, join, normalize, resolve } from \"node:path\";\n\n/**\n * File extensions to try when resolving module specifiers.\n * Ordered to match TypeScript's module resolution order.\n * @see https://www.typescriptlang.org/docs/handbook/module-resolution.html\n */\nexport const MODULE_EXTENSION_CANDIDATES = [\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".mjs\", \".cjs\", \".jsx\"] as const;\n\n/**\n * Mapping from JS extensions to their corresponding TS extensions.\n * Used for ESM-style imports where .js is written but .ts is the actual source.\n */\nconst JS_TO_TS_EXTENSION_MAP: Readonly<Record<string, readonly string[]>> = {\n  \".js\": [\".ts\", \".tsx\"],\n  \".mjs\": [\".mts\"],\n  \".cjs\": [\".cts\"],\n  \".jsx\": [\".tsx\"],\n};\n\n/**\n * Result of parsing a JS extension from a specifier.\n */\nexport type JsExtensionInfo = {\n  /** The specifier without the JS extension */\n  readonly base: string;\n  /** The JS extension found (e.g., \".js\", \".mjs\") */\n  readonly jsExtension: string;\n  /** The corresponding TS extensions to try (e.g., [\".ts\", \".tsx\"] for \".js\") */\n  readonly tsExtensions: readonly string[];\n};\n\n/**\n * Parse a JS extension from a specifier for ESM-style import resolution.\n * Returns the base path (without extension), the JS extension, and corresponding TS extensions.\n *\n * @param specifier - The import specifier to parse\n * @returns Object with base, jsExtension, and tsExtensions, or null if no JS extension found\n *\n * @example\n * parseJsExtension(\"./foo.js\") // { base: \"./foo\", jsExtension: \".js\", tsExtensions: [\".ts\", \".tsx\"] }\n * parseJsExtension(\"./foo.mjs\") // { base: \"./foo\", jsExtension: \".mjs\", tsExtensions: [\".mts\"] }\n * parseJsExtension(\"./foo\") // null\n * parseJsExtension(\"./foo.ts\") // null\n */\nexport const parseJsExtension = (specifier: string): JsExtensionInfo | null => {\n  for (const [ext, tsExts] of Object.entries(JS_TO_TS_EXTENSION_MAP)) {\n    if (specifier.endsWith(ext)) {\n      return {\n        base: specifier.slice(0, -ext.length),\n        jsExtension: ext,\n        tsExtensions: tsExts,\n      };\n    }\n  }\n  return null;\n};\n\n/**\n * Normalize path to use forward slashes (cross-platform).\n * Ensures consistent path handling across platforms.\n */\nexport const normalizePath = (value: string): string => normalize(value).replace(/\\\\/g, \"/\");\n\n/**\n * Resolve a relative import specifier to an absolute file path.\n * Tries the specifier as-is, with extensions, and as a directory with index files.\n *\n * @param from - Absolute path to the importing file\n * @param specifier - Relative module specifier (must start with '.')\n * @returns Absolute POSIX path to the resolved file, or null if not found\n */\nexport const resolveRelativeImportWithExistenceCheck = ({\n  filePath,\n  specifier,\n}: {\n  filePath: string;\n  specifier: string;\n}): string | null => {\n  // Handle ESM-style imports with JS extensions (e.g., \"./foo.js\" -> \"./foo.ts\")\n  const jsExtInfo = parseJsExtension(specifier);\n  if (jsExtInfo) {\n    const baseWithoutExt = resolve(dirname(filePath), jsExtInfo.base);\n\n    // Try corresponding TS extensions first\n    for (const ext of jsExtInfo.tsExtensions) {\n      const candidate = `${baseWithoutExt}${ext}`;\n      if (existsSync(candidate)) {\n        return normalizePath(candidate);\n      }\n    }\n\n    // Fall back to actual JS file if it exists\n    const jsCandidate = `${baseWithoutExt}${jsExtInfo.jsExtension}`;\n    if (existsSync(jsCandidate)) {\n      try {\n        const stat = statSync(jsCandidate);\n        if (stat.isFile()) {\n          return normalizePath(jsCandidate);\n        }\n      } catch {\n        // Ignore stat errors\n      }\n    }\n\n    return null;\n  }\n\n  const base = resolve(dirname(filePath), specifier);\n\n  // Try with extensions first (most common case)\n  // This handles cases like \"./constants\" resolving to \"./constants.ts\"\n  // even when a \"./constants\" directory exists\n  for (const ext of MODULE_EXTENSION_CANDIDATES) {\n    const candidate = `${base}${ext}`;\n    if (existsSync(candidate)) {\n      return normalizePath(candidate);\n    }\n  }\n\n  // Try as directory with index files\n  for (const ext of MODULE_EXTENSION_CANDIDATES) {\n    const candidate = join(base, `index${ext}`);\n    if (existsSync(candidate)) {\n      return normalizePath(candidate);\n    }\n  }\n\n  // Try exact path last (only if it's a file, not directory)\n  if (existsSync(base)) {\n    try {\n      const stat = statSync(base);\n      if (stat.isFile()) {\n        return normalizePath(base);\n      }\n    } catch {\n      // Ignore stat errors\n    }\n  }\n\n  return null;\n};\n\n/**\n * Resolve a relative import specifier to an absolute file path.\n * Tries the specifier as-is, with extensions, and as a directory with index files.\n *\n * @param from - Absolute path to the importing file\n * @param specifier - Relative module specifier (must start with '.')\n * @returns Absolute POSIX path to the resolved file, or null if not found\n */\nexport const resolveRelativeImportWithReferences = <_>({\n  filePath,\n  specifier,\n  references,\n}: {\n  filePath: string;\n  specifier: string;\n  references: Map<string, _> | Set<string>;\n}): string | null => {\n  // Handle ESM-style imports with JS extensions (e.g., \"./foo.js\" -> \"./foo.ts\")\n  const jsExtInfo = parseJsExtension(specifier);\n  if (jsExtInfo) {\n    const baseWithoutExt = resolve(dirname(filePath), jsExtInfo.base);\n\n    // Try corresponding TS extensions first\n    for (const ext of jsExtInfo.tsExtensions) {\n      const candidate = `${baseWithoutExt}${ext}`;\n      if (references.has(candidate)) {\n        return normalizePath(candidate);\n      }\n    }\n\n    // Fall back to actual JS file if it exists in references\n    const jsCandidate = `${baseWithoutExt}${jsExtInfo.jsExtension}`;\n    if (references.has(jsCandidate)) {\n      return normalizePath(jsCandidate);\n    }\n\n    return null;\n  }\n\n  const base = resolve(dirname(filePath), specifier);\n\n  // Try exact path first\n  if (references.has(base)) {\n    return normalizePath(base);\n  }\n\n  // Try with extensions\n  for (const ext of MODULE_EXTENSION_CANDIDATES) {\n    const candidate = `${base}${ext}`;\n    if (references.has(candidate)) {\n      return normalizePath(candidate);\n    }\n  }\n\n  // Try as directory with index files\n  for (const ext of MODULE_EXTENSION_CANDIDATES) {\n    const candidate = join(base, `index${ext}`);\n    if (references.has(candidate)) {\n      return normalizePath(candidate);\n    }\n  }\n\n  return null;\n};\n\n/**\n * Check if a module specifier is relative (starts with '.' or '..')\n */\nexport const isRelativeSpecifier = (specifier: string): boolean => specifier.startsWith(\"./\") || specifier.startsWith(\"../\");\n\n/**\n * Check if a module specifier is external (package name, not relative)\n */\nexport const isExternalSpecifier = (specifier: string): boolean => !isRelativeSpecifier(specifier);\n","import { existsSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { MODULE_EXTENSION_CANDIDATES, normalizePath, parseJsExtension } from \"./path\";\nimport type { TsconfigPathsConfig } from \"./tsconfig\";\n\n/**\n * Alias resolver interface for resolving path aliases to file paths.\n */\nexport type AliasResolver = {\n  /**\n   * Resolve an alias specifier to an absolute file path.\n   * Returns null if the specifier doesn't match any alias pattern\n   * or if the resolved file doesn't exist.\n   */\n  readonly resolve: (specifier: string) => string | null;\n};\n\n/**\n * Match a specifier against a tsconfig path pattern.\n * Returns the captured wildcard portion or null if no match.\n *\n * Pattern rules:\n * - Exact match: \"@/utils\" matches \"@/utils\" exactly, captures \"\"\n * - Wildcard: \"@/*\" matches \"@/foo\", captures \"foo\"\n * - Wildcard with suffix: \"*.js\" matches \"foo.js\", captures \"foo\"\n */\nconst matchPattern = (specifier: string, pattern: string): string | null => {\n  const starIndex = pattern.indexOf(\"*\");\n\n  if (starIndex === -1) {\n    // Exact match - no wildcard\n    return specifier === pattern ? \"\" : null;\n  }\n\n  const prefix = pattern.slice(0, starIndex);\n  const suffix = pattern.slice(starIndex + 1);\n\n  if (!specifier.startsWith(prefix)) {\n    return null;\n  }\n\n  if (suffix && !specifier.endsWith(suffix)) {\n    return null;\n  }\n\n  // Extract the wildcard capture\n  const captured = specifier.slice(prefix.length, suffix ? specifier.length - suffix.length : undefined);\n\n  return captured;\n};\n\n/**\n * Apply a captured wildcard to a target path.\n */\nconst applyCapture = (target: string, captured: string): string => {\n  const starIndex = target.indexOf(\"*\");\n  if (starIndex === -1) {\n    return target;\n  }\n  return target.slice(0, starIndex) + captured + target.slice(starIndex + 1);\n};\n\n/**\n * Try to resolve a path to an actual file, applying extension resolution.\n * Handles ESM-style imports with JS extensions.\n */\nconst resolveToFile = (basePath: string): string | null => {\n  // Handle ESM-style JS extension imports\n  const jsExtInfo = parseJsExtension(basePath);\n  if (jsExtInfo) {\n    const baseWithoutExt = basePath.slice(0, -jsExtInfo.jsExtension.length);\n\n    // Try corresponding TS extensions first\n    for (const ext of jsExtInfo.tsExtensions) {\n      const candidate = `${baseWithoutExt}${ext}`;\n      if (existsSync(candidate)) {\n        try {\n          const stat = statSync(candidate);\n          if (stat.isFile()) {\n            return normalizePath(candidate);\n          }\n        } catch {\n          // Ignore stat errors\n        }\n      }\n    }\n\n    // Fall back to actual JS file\n    if (existsSync(basePath)) {\n      try {\n        const stat = statSync(basePath);\n        if (stat.isFile()) {\n          return normalizePath(basePath);\n        }\n      } catch {\n        // Ignore stat errors\n      }\n    }\n\n    return null;\n  }\n\n  // Try exact path first (for paths with explicit extension)\n  if (existsSync(basePath)) {\n    try {\n      const stat = statSync(basePath);\n      if (stat.isFile()) {\n        return normalizePath(basePath);\n      }\n    } catch {\n      // Ignore stat errors\n    }\n  }\n\n  // Try with extensions\n  for (const ext of MODULE_EXTENSION_CANDIDATES) {\n    const candidate = `${basePath}${ext}`;\n    if (existsSync(candidate)) {\n      try {\n        const stat = statSync(candidate);\n        if (stat.isFile()) {\n          return normalizePath(candidate);\n        }\n      } catch {\n        // Ignore stat errors\n      }\n    }\n  }\n\n  // Try as directory with index files\n  for (const ext of MODULE_EXTENSION_CANDIDATES) {\n    const candidate = join(basePath, `index${ext}`);\n    if (existsSync(candidate)) {\n      try {\n        const stat = statSync(candidate);\n        if (stat.isFile()) {\n          return normalizePath(candidate);\n        }\n      } catch {\n        // Ignore stat errors\n      }\n    }\n  }\n\n  return null;\n};\n\n/**\n * Create an alias resolver from tsconfig paths configuration.\n *\n * Resolution behavior:\n * 1. Try each pattern in order (first match wins per TS spec)\n * 2. For each matched pattern, try all target paths in order\n * 3. For each target, apply extension resolution\n * 4. Return first found file, or null if none found\n */\nexport const createAliasResolver = (config: TsconfigPathsConfig): AliasResolver => {\n  const { paths } = config;\n  const patterns = Object.keys(paths);\n\n  return {\n    resolve: (specifier: string): string | null => {\n      // Try each pattern in order (first match wins per TS spec)\n      for (const pattern of patterns) {\n        const captured = matchPattern(specifier, pattern);\n        if (captured === null) {\n          continue;\n        }\n\n        const targets = paths[pattern];\n        if (!targets) {\n          continue;\n        }\n\n        // Try each target path in order\n        for (const target of targets) {\n          const resolvedTarget = applyCapture(target, captured);\n          const result = resolveToFile(resolvedTarget);\n          if (result) {\n            return result;\n          }\n        }\n      }\n\n      return null;\n    },\n  };\n};\n","export const cachedFn = <T>(fn: () => T) => {\n  let cached: { value: T } | null = null;\n\n  const ensure = () => (cached ??= { value: fn() }).value;\n  ensure.clear = () => {\n    cached = null;\n  };\n\n  return ensure;\n};\n","/**\n * SWC span position converter: UTF-8 byte offsets → UTF-16 code unit indices.\n *\n * SWC (Rust-based) returns span positions as UTF-8 byte offsets.\n * JavaScript strings use UTF-16 code units for indexing.\n * For ASCII-only content these are identical, but for multi-byte\n * characters the positions diverge.\n */\n\nexport type SwcSpanConverter = {\n  /** UTF-8 byte length of the source string */\n  readonly byteLength: number;\n  /** Convert a UTF-8 byte offset (within the source) to a UTF-16 code unit index */\n  readonly byteOffsetToCharIndex: (byteOffset: number) => number;\n};\n\n/**\n * Create a converter that maps UTF-8 byte offsets to UTF-16 char indices\n * for the given source string.\n *\n * Includes a fast path for ASCII-only sources (zero allocation).\n */\nexport const createSwcSpanConverter = (source: string): SwcSpanConverter => {\n  const byteLength = Buffer.byteLength(source, \"utf8\");\n\n  // Fast path: ASCII-only — byte offsets equal char indices\n  if (byteLength === source.length) {\n    return {\n      byteLength,\n      byteOffsetToCharIndex: (byteOffset: number) => byteOffset,\n    };\n  }\n\n  // Build lookup table: byteOffset → charIndex\n  const byteToChar = new Uint32Array(byteLength + 1);\n  let bytePos = 0;\n\n  for (let charIdx = 0; charIdx < source.length; charIdx++) {\n    const codePoint = source.codePointAt(charIdx);\n    if (codePoint === undefined) break;\n    const bytesForCodePoint = codePoint <= 0x7f ? 1 : codePoint <= 0x7ff ? 2 : codePoint <= 0xffff ? 3 : 4;\n\n    for (let b = 0; b < bytesForCodePoint; b++) {\n      byteToChar[bytePos + b] = charIdx;\n    }\n    bytePos += bytesForCodePoint;\n\n    // Astral code points use a surrogate pair (2 UTF-16 code units)\n    if (codePoint > 0xffff) {\n      charIdx++;\n    }\n  }\n\n  // Sentinel: end-of-string\n  byteToChar[byteLength] = source.length;\n\n  return {\n    byteLength,\n    byteOffsetToCharIndex: (byteOffset: number) => byteToChar[byteOffset] ?? source.length,\n  };\n};\n","import { readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\n\n/**\n * Parsed tsconfig.json paths configuration.\n * All paths are resolved to absolute paths.\n */\nexport type TsconfigPathsConfig = {\n  /** Absolute base URL for path resolution */\n  readonly baseUrl: string;\n  /** Path mappings with absolute paths */\n  readonly paths: Readonly<Record<string, readonly string[]>>;\n};\n\n/**\n * Error types for tsconfig reading.\n */\nexport type TsconfigReadError = {\n  readonly code: \"TSCONFIG_READ_FAILED\" | \"TSCONFIG_PARSE_FAILED\" | \"TSCONFIG_INVALID\";\n  readonly message: string;\n};\n\n/**\n * Strip JSON comments and trailing commas for parsing.\n * Handles both line comments (//) and block comments.\n */\nconst stripJsonComments = (json: string): string => {\n  return (\n    json\n      // Remove block comments\n      .replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\")\n      // Remove line comments\n      .replace(/\\/\\/.*/g, \"\")\n      // Remove trailing commas before } or ]\n      .replace(/,(\\s*[}\\]])/g, \"$1\")\n  );\n};\n\n/**\n * Read and parse tsconfig.json to extract paths configuration.\n * Currently does not support `extends` - reads only the specified file.\n *\n * @param tsconfigPath - Absolute path to tsconfig.json\n * @returns Parsed paths configuration or null if no paths defined\n */\nexport const readTsconfigPaths = (tsconfigPath: string): Result<TsconfigPathsConfig | null, TsconfigReadError> => {\n  // Read file\n  let content: string;\n  try {\n    content = readFileSync(tsconfigPath, \"utf-8\");\n  } catch (error) {\n    return err({\n      code: \"TSCONFIG_READ_FAILED\",\n      message: `Failed to read tsconfig.json: ${error instanceof Error ? error.message : String(error)}`,\n    });\n  }\n\n  // Parse JSON (with comment stripping)\n  let parsed: unknown;\n  try {\n    const cleaned = stripJsonComments(content);\n    parsed = JSON.parse(cleaned);\n  } catch (error) {\n    return err({\n      code: \"TSCONFIG_PARSE_FAILED\",\n      message: `Failed to parse tsconfig.json: ${error instanceof Error ? error.message : String(error)}`,\n    });\n  }\n\n  // Validate structure\n  if (typeof parsed !== \"object\" || parsed === null) {\n    return err({\n      code: \"TSCONFIG_INVALID\",\n      message: \"tsconfig.json must be an object\",\n    });\n  }\n\n  const config = parsed as Record<string, unknown>;\n  const compilerOptions = config.compilerOptions as Record<string, unknown> | undefined;\n\n  // Return null if no paths defined\n  if (!compilerOptions?.paths) {\n    return ok(null);\n  }\n\n  // Resolve baseUrl\n  const tsconfigDir = dirname(tsconfigPath);\n  const baseUrl = typeof compilerOptions.baseUrl === \"string\" ? resolve(tsconfigDir, compilerOptions.baseUrl) : tsconfigDir;\n\n  // Resolve paths to absolute paths\n  const rawPaths = compilerOptions.paths as Record<string, string[]>;\n  const resolvedPaths: Record<string, readonly string[]> = {};\n\n  for (const [pattern, targets] of Object.entries(rawPaths)) {\n    if (Array.isArray(targets)) {\n      resolvedPaths[pattern] = targets.map((target) => resolve(baseUrl, target));\n    }\n  }\n\n  return ok({\n    baseUrl,\n    paths: resolvedPaths,\n  });\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,8BAA8B;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAO;CAAQ;CAAQ;CAAO;;;;;AAMzG,M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