{"version":3,"sources":["../../src/scripts/collect-translations.ts","../../src/scripts/placeholder-type.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport type { IntlConfig } from './intl-config'\nimport {\n  resolvePlaceholderType,\n  type DiagnosticLevel,\n  type DiagnosticReporter,\n  type NumericKind\n} from './placeholder-type'\n\nexport interface IntlDiagnostic {\n  level: DiagnosticLevel,\n  message: string,\n}\n\nexport interface FuncParam {\n  name: string,\n  typing: string,\n  numeric?: NumericKind,\n}\n\nexport type TranslationEntry =\n  { type: 'text', value: string }\n  | { type: 'func', params: FuncParam[], value: string }\n\nexport type LocaleCatalog = Record<string, Record<string, TranslationEntry>>\n\nexport interface CollectedTranslations {\n  catalog: LocaleCatalog,\n  diagnostics: IntlDiagnostic[],\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction errorMessage(error: unknown): string {\n  return error instanceof Error ? error.message : String(error)\n}\n\nfunction isPrefix(value: string): boolean {\n  return value.split('.').every(part => /^[A-Za-z_][A-Za-z0-9_]*$/.test(part))\n}\n\nexport function describeTranslationEntry(entry: TranslationEntry): string {\n  if (entry.type === 'text') return 'string'\n  const params = entry.params.map(param => `${param.name}: ${param.typing}`).join(', ')\n  return `(${params}) => string`\n}\n\nfunction collectArbPaths(locations: readonly string[], diagnostics: IntlDiagnostic[]): string[] {\n  const files: string[] = []\n  const seenFiles = new Set<string>()\n  const seenDirectories = new Set<string>()\n\n  const addFile = (filePath: string): void => {\n    try {\n      const real = fs.realpathSync(filePath)\n      if (seenFiles.has(real)) return\n      seenFiles.add(real)\n      files.push(real)\n    } catch (error) {\n      diagnostics.push({\n        level: 'error',\n        message: `Failed to read ${filePath}: ${errorMessage(error)}`,\n      })\n    }\n  }\n\n  const walk = (directory: string): void => {\n    let realDirectory = directory\n    try {\n      realDirectory = fs.realpathSync(directory)\n    } catch (error) {\n      diagnostics.push({\n        level: 'error',\n        message: `Failed to read ${directory}: ${errorMessage(error)}`,\n      })\n      return\n    }\n    if (seenDirectories.has(realDirectory)) return\n    seenDirectories.add(realDirectory)\n\n    let entries: fs.Dirent[]\n    try {\n      entries = fs.readdirSync(realDirectory, { withFileTypes: true })\n    } catch (error) {\n      diagnostics.push({\n        level: 'error',\n        message: `Failed to read ${directory}: ${errorMessage(error)}`,\n      })\n      return\n    }\n\n    for (const entry of entries) {\n      const fullPath = path.join(realDirectory, entry.name)\n      let stat: fs.Stats\n      try {\n        stat = fs.statSync(fullPath)\n      } catch (error) {\n        diagnostics.push({\n          level: 'error',\n          message: `Failed to read ${fullPath}: ${errorMessage(error)}`,\n        })\n        continue\n      }\n      if (stat.isDirectory()) {\n        walk(fullPath)\n      } else if (stat.isFile() && entry.name.endsWith('.arb')) {\n        addFile(fullPath)\n      }\n    }\n  }\n\n  for (const location of locations) {\n    const resolved = path.resolve(location)\n    if (!fs.existsSync(resolved)) {\n      diagnostics.push({\n        level: 'error',\n        message: `Path does not exist: ${location}`,\n      })\n      continue\n    }\n\n    const stat = fs.statSync(resolved)\n    if (stat.isDirectory()) {\n      walk(resolved)\n    } else if (stat.isFile()) {\n      if (!resolved.endsWith('.arb')) {\n        diagnostics.push({\n          level: 'error',\n          message: `Expected an .arb file: ${location}`,\n        })\n        continue\n      }\n      addFile(resolved)\n    } else {\n      diagnostics.push({\n        level: 'error',\n        message: `Unsupported path: ${location}`,\n      })\n    }\n  }\n\n  files.sort((left, right) => left.localeCompare(right))\n  return files\n}\n\nfunction readArbObject(filePath: string, diagnostics: IntlDiagnostic[]): Record<string, unknown> | undefined {\n  try {\n    const parsed: unknown = JSON.parse(fs.readFileSync(filePath, 'utf-8'))\n    if (!isRecord(parsed)) {\n      diagnostics.push({\n        level: 'error',\n        message: `File ${filePath} must contain a JSON object.`,\n      })\n      return undefined\n    }\n    return parsed\n  } catch (error) {\n    diagnostics.push({\n      level: 'error',\n      message: `Failed to read ${filePath}: ${errorMessage(error)}`,\n    })\n    return undefined\n  }\n}\n\nfunction buildEntry(\n  key: string,\n  value: string,\n  meta: unknown,\n  filePath: string,\n  diagnostics: IntlDiagnostic[]\n): TranslationEntry | undefined {\n  const report: DiagnosticReporter = (level, message) => {\n    diagnostics.push({ level, message })\n  }\n\n  if (meta !== undefined && !isRecord(meta)) {\n    diagnostics.push({\n      level: 'error',\n      message: `Metadata for \"${key}\" in ${filePath} must be an object.`,\n    })\n    return undefined\n  }\n\n  if (meta === undefined || meta.placeholders === undefined) {\n    return { type: 'text', value }\n  }\n\n  if (!isRecord(meta.placeholders)) {\n    diagnostics.push({\n      level: 'error',\n      message: `Placeholders for \"${key}\" in ${filePath} must be an object.`,\n    })\n    return undefined\n  }\n\n  const params: FuncParam[] = []\n  for (const [name, definition] of Object.entries(meta.placeholders)) {\n    if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n      diagnostics.push({\n        level: 'error',\n        message: `Placeholder \"${name}\" of \"${key}\" in ${filePath} is not a valid identifier.`,\n      })\n      return undefined\n    }\n\n    if (definition !== undefined && !isRecord(definition)) {\n      diagnostics.push({\n        level: 'warning',\n        message: `Placeholder \"${name}\" of \"${key}\" in ${filePath} must be an object. Interpreting its type as string.`,\n      })\n      params.push({ name, typing: 'string' })\n      continue\n    }\n\n    if (isRecord(definition) && definition.type !== undefined && typeof definition.type !== 'string') {\n      diagnostics.push({\n        level: 'warning',\n        message: `Type of placeholder \"${name}\" of \"${key}\" in ${filePath} must be a string. Interpreting it as string.`,\n      })\n      params.push({ name, typing: 'string' })\n      continue\n    }\n\n    const rawType = isRecord(definition) && typeof definition.type === 'string'\n      ? definition.type\n      : undefined\n\n    params.push({\n      name,\n      ...resolvePlaceholderType(rawType, name, report, { key, filePath }),\n    })\n  }\n\n  return { type: 'func', params, value }\n}\n\nfunction readTranslationFile(\n  filePath: string,\n  config: Pick<IntlConfig, 'supportedLocales'>,\n  catalog: LocaleCatalog,\n  diagnostics: IntlDiagnostic[]\n): void {\n  const content = readArbObject(filePath, diagnostics)\n  if (!content) return\n\n  const localeValue = content['@@locale']\n  if (typeof localeValue !== 'string' || localeValue.length === 0) {\n    diagnostics.push({\n      level: 'error',\n      message: `File ${filePath} must set @@locale to one of: ${config.supportedLocales.join(', ')}.`,\n    })\n    return\n  }\n  if (!config.supportedLocales.includes(localeValue)) {\n    diagnostics.push({\n      level: 'error',\n      message: `Locale \"${localeValue}\" in ${filePath} is not listed in supportedLocales.`,\n    })\n    return\n  }\n\n  let prefix = ''\n  if (Object.prototype.hasOwnProperty.call(content, '@@prefix')) {\n    const prefixValue = content['@@prefix']\n    if (typeof prefixValue !== 'string' || !isPrefix(prefixValue)) {\n      diagnostics.push({\n        level: 'error',\n        message: `File ${filePath} has an invalid @@prefix. Use a dotted identifier such as \"test\" or \"time.relative\".`,\n      })\n      return\n    }\n    prefix = prefixValue\n  }\n\n  if (!catalog[localeValue]) catalog[localeValue] = {}\n\n  for (const [key, value] of Object.entries(content)) {\n    if (key.startsWith('@')) continue\n    if (typeof value !== 'string') {\n      diagnostics.push({\n        level: 'error',\n        message: `Key \"${key}\" in ${filePath} must be a string.`,\n      })\n      continue\n    }\n\n    const flatKey = prefix ? `${prefix}.${key}` : key\n    if (catalog[localeValue][flatKey]) {\n      diagnostics.push({\n        level: 'warning',\n        message: `Key \"${flatKey}\" for locale \"${localeValue}\" is defined more than once. The definition in ${filePath} was ignored.`,\n      })\n      continue\n    }\n\n    const entry = buildEntry(key, value, content[`@${key}`], filePath, diagnostics)\n    if (entry) catalog[localeValue][flatKey] = entry\n  }\n}\n\nfunction flagInconsistencies(\n  catalog: LocaleCatalog,\n  supportedLocales: readonly string[],\n  diagnostics: IntlDiagnostic[]\n): void {\n  const presentLocales = supportedLocales.filter(locale => catalog[locale] !== undefined)\n\n  for (const locale of supportedLocales) {\n    if (catalog[locale] === undefined) {\n      diagnostics.push({\n        level: 'warning',\n        message: `Supported locale \"${locale}\" has no .arb file.`,\n      })\n    }\n  }\n\n  const keys = new Set<string>()\n  for (const locale of presentLocales) {\n    for (const key of Object.keys(catalog[locale])) keys.add(key)\n  }\n\n  for (const key of [...keys].sort((left, right) => left.localeCompare(right))) {\n    const defined = presentLocales.filter(locale => catalog[locale][key] !== undefined)\n    const missing = presentLocales.filter(locale => catalog[locale][key] === undefined)\n    if (missing.length > 0) {\n      diagnostics.push({\n        level: 'warning',\n        message: `Key \"${key}\" is missing for ${missing.map(locale => `\"${locale}\"`).join(', ')}. It is defined for ${defined.map(locale => `\"${locale}\"`).join(', ')}.`,\n      })\n    }\n\n    const baseLocale = defined[0]\n    const baseSignature = describeTranslationEntry(catalog[baseLocale][key])\n    for (const locale of defined.slice(1)) {\n      const signature = describeTranslationEntry(catalog[locale][key])\n      if (signature === baseSignature) continue\n      diagnostics.push({\n        level: 'warning',\n        message: `Key \"${key}\" has inconsistent typing. \"${baseLocale}\" is ${baseSignature}, \"${locale}\" is ${signature}.`,\n      })\n    }\n  }\n}\n\nexport function collectTranslations(\n  locations: readonly string[],\n  config: Pick<IntlConfig, 'supportedLocales'>\n): CollectedTranslations {\n  const diagnostics: IntlDiagnostic[] = []\n  const catalog: LocaleCatalog = {}\n\n  if (locations.length === 0) {\n    diagnostics.push({\n      level: 'error',\n      message: 'Provide at least one .arb file or directory.',\n    })\n    return { catalog, diagnostics }\n  }\n\n  const files = collectArbPaths(locations, diagnostics)\n  if (files.length === 0 && !diagnostics.some(item => item.level === 'error')) {\n    diagnostics.push({\n      level: 'error',\n      message: 'No .arb files were found in the given paths.',\n    })\n  }\n\n  for (const filePath of files) {\n    readTranslationFile(filePath, config, catalog, diagnostics)\n  }\n\n  flagInconsistencies(catalog, config.supportedLocales, diagnostics)\n\n  return { catalog, diagnostics }\n}\n","export type DiagnosticLevel = 'warning' | 'error'\n\nexport type DiagnosticReporter = (level: DiagnosticLevel, message: string) => void\n\nexport type NumericKind = 'int' | 'float'\n\nexport interface ResolvedPlaceholderType {\n  typing: string,\n  numeric?: NumericKind,\n}\n\nconst SUPPORTED_TYPES = ['string', 'int', 'float'] as const\n\ntype SupportedType = typeof SUPPORTED_TYPES[number]\n\nfunction toFunctionType(typeName: SupportedType): ResolvedPlaceholderType {\n  if (typeName === 'int') return { typing: 'number', numeric: 'int' }\n  if (typeName === 'float') return { typing: 'number', numeric: 'float' }\n  return { typing: 'string' }\n}\n\nfunction isSupportedType(typeName: string): typeName is SupportedType {\n  return (SUPPORTED_TYPES as readonly string[]).includes(typeName)\n}\n\nexport interface PlaceholderTypeContext {\n  key: string,\n  filePath: string,\n}\n\nexport function resolvePlaceholderType(\n  rawType: string | undefined,\n  variableName: string,\n  report: DiagnosticReporter,\n  context: PlaceholderTypeContext\n): ResolvedPlaceholderType {\n  const location = `variable [${variableName}] of [${context.key}] in file ${context.filePath}`\n  const typing = rawType?.trim() ?? ''\n\n  if (!typing) {\n    report('warning', `Placeholder [${variableName}] of [${context.key}] in file ${context.filePath} has no type. Interpreting it as string.`)\n    return { typing: 'string' }\n  }\n\n  if (!isSupportedType(typing)) {\n    report('error', `Type \"${typing}\" for ${location} is not supported. Only string, int, and float are supported.`)\n    return { typing: 'string' }\n  }\n\n  return toFunctionType(typing)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;;;ACUjB,IAAM,kBAAkB,CAAC,UAAU,OAAO,OAAO;AAIjD,SAAS,eAAe,UAAkD;AACxE,MAAI,aAAa,MAAO,QAAO,EAAE,QAAQ,UAAU,SAAS,MAAM;AAClE,MAAI,aAAa,QAAS,QAAO,EAAE,QAAQ,UAAU,SAAS,QAAQ;AACtE,SAAO,EAAE,QAAQ,SAAS;AAC5B;AAEA,SAAS,gBAAgB,UAA6C;AACpE,SAAQ,gBAAsC,SAAS,QAAQ;AACjE;AAOO,SAAS,uBACd,SACA,cACA,QACA,SACyB;AACzB,QAAM,WAAW,aAAa,YAAY,SAAS,QAAQ,GAAG,aAAa,QAAQ,QAAQ;AAC3F,QAAM,SAAS,SAAS,KA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