{"version":3,"file":"writeDynamicDictionary.cjs","names":["DYNAMIC_DICTIONARIES_JSON_SUBDIR","DYNAMIC_ENTRY_LOADER_MAP_IDENTIFIER","QUALIFIER_DYNAMIC_TYPES_KEY","OUTPUT_FORMAT","resolve","mkdir","parallelize","getPerLocaleDictionary","writeJsonIfChanged","writeFileIfChanged","colorizePath","COMPOSITE_ID_SEPARATOR","reconstructQualifiedEntry"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport {\n  DYNAMIC_DICTIONARIES_JSON_SUBDIR,\n  DYNAMIC_ENTRY_LOADER_MAP_IDENTIFIER,\n  OUTPUT_FORMAT,\n} from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n  COMPOSITE_ID_SEPARATOR,\n  QUALIFIER_DYNAMIC_TYPES_KEY,\n  reconstructQualifiedEntry,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type {\n  Dictionary,\n  DictionaryQualifierType,\n  QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { PlainMergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n  dictionaryPath: string;\n  dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n  Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n  string,\n  LocalizedDictionaryResult\n>;\n\nconst DICTIONARIES_SUBDIR = DYNAMIC_DICTIONARIES_JSON_SUBDIR;\n\n/**\n * Escapes a value interpolated into a single-quoted literal of a generated\n * loader module, so keys or segments containing `'` or `\\` cannot break the\n * emitted JavaScript.\n */\nconst escapeJsLiteral = (value: string): string =>\n  value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n\n/** Loader expression for one `(key, locale)` per-locale chunk. */\nconst buildPerLocaleLoader = (\n  key: string,\n  locale: string,\n  format: 'cjs' | 'esm'\n): string => {\n  const path = `./${DICTIONARIES_SUBDIR}/${key}/${locale}.json`;\n\n  return format === 'esm'\n    ? `import('${path}').then(m => m.default)`\n    : `Promise.resolve(require('${path}'))`;\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n *\n * When the dictionary references other dictionaries through `nest()`, the\n * loader for a locale resolves the referenced dictionaries alongside it and\n * attaches them as `nestedDictionaries`. The nest targets then travel in the\n * same lazy chunk as their consumer, and `getNesting` resolves them from that\n * local reference instead of the global registry — which the build\n * optimization strips.\n *\n * @param key - The dictionary key.\n * @param locales - Locales to emit a loader for.\n * @param format - Output module format.\n * @param nestedKeys - Keys referenced through `nest()`, transitively.\n */\nexport const generateDictionaryEntryPoint = (\n  key: string,\n  locales: string[],\n  format: 'cjs' | 'esm' = 'esm',\n  nestedKeys: string[] = []\n): string => {\n  const sortedLocales = [...locales].sort((a, b) =>\n    String(a).localeCompare(String(b))\n  );\n  const sortedNestedKeys = [...nestedKeys].sort((a, b) => a.localeCompare(b));\n\n  const safeKey = escapeJsLiteral(key);\n\n  const localeEntries = sortedLocales\n    .map((locale) => {\n      const safeLocale = escapeJsLiteral(locale);\n      const ownLoader = buildPerLocaleLoader(safeKey, safeLocale, format);\n\n      if (sortedNestedKeys.length === 0) {\n        return `  '${safeLocale}': () => ${ownLoader}`;\n      }\n\n      const nestedLoaders = sortedNestedKeys\n        .map((nestedKey) =>\n          buildPerLocaleLoader(escapeJsLiteral(nestedKey), safeLocale, format)\n        )\n        .join(',\\n      ');\n\n      const attachedEntries = sortedNestedKeys\n        .map(\n          (nestedKey, index) =>\n            `'${escapeJsLiteral(nestedKey)}': _nested[${index}]`\n        )\n        .join(', ');\n\n      return (\n        `  '${safeLocale}': () => Promise.all([\\n` +\n        `      ${ownLoader},\\n` +\n        `      ${nestedLoaders}\\n` +\n        `    ]).then(([_dictionary, ..._nested]) => ({\\n` +\n        `      ..._dictionary,\\n` +\n        `      nestedDictionaries: { ${attachedEntries} }\\n` +\n        `    }))`\n      );\n    })\n    .join(',\\n');\n\n  if (format === 'esm') {\n    return (\n      `const ${DYNAMIC_ENTRY_LOADER_MAP_IDENTIFIER} = {\\n${localeEntries}\\n};\\n\\n` +\n      `export default ${DYNAMIC_ENTRY_LOADER_MAP_IDENTIFIER};\\n`\n    );\n  }\n  return `module.exports = {\\n${localeEntries}\\n};\\n`;\n};\n\n/**\n * A nested loader tree: one level per declared dimension, leaves are loader\n * expression strings.\n */\ntype LoaderTree = { [segment: string]: LoaderTree | string };\n\n/**\n * One entry of a qualified loader map.\n *\n * `treeSegments` is where the entry lives in the loader tree (its composite id\n * segments); `chunkSegments` is the chunk path it loads. They differ when the\n * entry aliases another entry with identical content (e.g. array-variant\n * fan-out): the alias keeps its own tree position but points at the canonical\n * entry's chunk, so equal content is emitted — and downloaded — only once.\n */\nexport type QualifiedEntrySegments = {\n  treeSegments: string[];\n  chunkSegments: string[];\n};\n\nconst buildLoaderExpression = (\n  key: string,\n  chunkSegments: string[],\n  locale: string,\n  format: 'cjs' | 'esm'\n): string => {\n  const path = escapeJsLiteral(\n    `./${DICTIONARIES_SUBDIR}/${key}/${chunkSegments.join('/')}/${locale}.json`\n  );\n\n  return format === 'esm'\n    ? `() => import('${path}').then(m => m.default)`\n    : `() => Promise.resolve(require('${path}'))`;\n};\n\nconst buildLoaderTree = (\n  key: string,\n  entries: QualifiedEntrySegments[],\n  locale: string,\n  format: 'cjs' | 'esm'\n): LoaderTree => {\n  const root: LoaderTree = {};\n\n  for (const { treeSegments, chunkSegments } of entries) {\n    let node = root;\n\n    treeSegments.forEach((segment, index) => {\n      if (index === treeSegments.length - 1) {\n        node[segment] = buildLoaderExpression(\n          key,\n          chunkSegments,\n          locale,\n          format\n        );\n        return;\n      }\n\n      node[segment] = (node[segment] as LoaderTree | undefined) ?? {};\n      node = node[segment] as LoaderTree;\n    });\n  }\n\n  return root;\n};\n\nconst serializeLoaderTree = (tree: LoaderTree, indentLevel: number): string => {\n  const pad = '  '.repeat(indentLevel);\n  const innerPad = '  '.repeat(indentLevel + 1);\n\n  const lines = Object.keys(tree)\n    .sort((a, b) => a.localeCompare(b))\n    .map((segment) => {\n      const value = tree[segment]!;\n      const serialized =\n        typeof value === 'string'\n          ? value\n          : serializeLoaderTree(value, indentLevel + 1);\n\n      return `${innerPad}'${escapeJsLiteral(segment)}': ${serialized}`;\n    });\n\n  return `{\\n${lines.join(',\\n')}\\n${pad}}`;\n};\n\n/**\n * Generates the entry point of a qualified dictionary (collection / variant,\n * possibly combined). Under each locale the loader map nests one\n * level per declared dimension (canonical order) and carries a marker listing\n * those dimensions so the runtime can walk the tree.\n *\n * One static `import()` is emitted per leaf `(locale, …segments)` chunk, which\n * keeps the output compatible with bundlers that reject template-literal\n * dynamic imports (Turbopack). Entries whose content is identical share one\n * chunk: their leaves point at the canonical entry's import path.\n */\nexport const generateQualifiedDictionaryEntryPoint = (\n  key: string,\n  qualifierTypes: DictionaryQualifierType[],\n  entries: QualifiedEntrySegments[],\n  locales: string[],\n  format: 'cjs' | 'esm' = 'esm'\n): string => {\n  const sortedLocales = [...locales].sort((a, b) =>\n    String(a).localeCompare(String(b))\n  );\n\n  const localeEntries = sortedLocales\n    .map((locale) => {\n      const tree = buildLoaderTree(key, entries, locale, format);\n      return `  '${escapeJsLiteral(locale)}': ${serializeLoaderTree(tree, 1)}`;\n    })\n    .join(',\\n');\n\n  const marker = `  '${QUALIFIER_DYNAMIC_TYPES_KEY}': ${JSON.stringify(qualifierTypes)}`;\n\n  if (format === 'esm') {\n    return (\n      `const ${DYNAMIC_ENTRY_LOADER_MAP_IDENTIFIER} = {\\n${marker},\\n${localeEntries}\\n};\\n\\n` +\n      `export default ${DYNAMIC_ENTRY_LOADER_MAP_IDENTIFIER};\\n`\n    );\n  }\n  return `module.exports = {\\n${marker},\\n${localeEntries}\\n};\\n`;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionary/dictionaries/en_home.json\n * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json\n * ```\n */\nexport const writeDynamicDictionary = async (\n  mergedDictionaries: PlainMergedDictionaryOutput,\n  configuration: IntlayerConfig,\n  formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT,\n  nestedDictionaryGraph: Map<string, Set<string>> = new Map()\n): Promise<LocalizedDictionaryOutput> => {\n  const { locales, defaultLocale } = configuration.internationalization;\n  const { dynamicDictionariesDir } = configuration.system;\n\n  const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n  await mkdir(dictDir, { recursive: true });\n\n  const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n  // Merge dictionaries with the same key and write to dictionariesDir\n  await parallelize(\n    Object.entries(mergedDictionaries).sort(([a], [b]) =>\n      String(a).localeCompare(String(b))\n    ),\n    async ([key, dictionaryEntry]) => {\n      if (key === 'undefined') return;\n\n      const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n      const keyDir = resolve(dictDir, key);\n      assertPathWithin(keyDir, dictDir);\n      await mkdir(keyDir, { recursive: true });\n\n      await parallelize(locales, async (locale) => {\n        const localizedDictionary = getPerLocaleDictionary(\n          dictionaryEntry.dictionary,\n          locale,\n          defaultLocale\n        );\n\n        // Directory structure: json/key/locale.json\n        const resultFilePath = resolve(keyDir, `${locale}.json`);\n\n        await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n          (err) => {\n            console.error(\n              `Error creating localized ${key}/${locale}.json:`,\n              err\n            );\n          }\n        );\n\n        localizedDictionariesPathsRecord[locale] = {\n          dictionaryPath: resultFilePath,\n          dictionary: localizedDictionary,\n        };\n      });\n\n      resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n      await parallelize(formats, async (format) => {\n        const extension = format === 'cjs' ? 'cjs' : 'mjs';\n        const content = generateDictionaryEntryPoint(key, locales, format, [\n          ...(nestedDictionaryGraph.get(key) ?? []),\n        ]);\n\n        const dynEntryPath = resolve(\n          dynamicDictionariesDir,\n          `${key}.${extension}`\n        );\n        assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n        await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n          console.error(\n            `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n            err\n          );\n        });\n      });\n    }\n  );\n\n  return resultDictionariesPaths;\n};\n\nexport type QualifiedMergedDictionaryResult = {\n  dictionaryPath: string;\n  dictionary: QualifiedDictionaryGroup;\n};\n\nexport type QualifiedMergedDictionaryOutput = Record<\n  string,\n  QualifiedMergedDictionaryResult\n>;\n\n/**\n * Writes the dynamic chunks and entry points of qualified dictionaries\n * (collections, variants — possibly combined) in\n * `importMode: 'dynamic'`.\n *\n * Each entry is reduced to one per-locale chunk written to a path nested by\n * dimension — `json/{key}/{seg1}/{seg2}/{locale}.json` — and a single\n * `{key}.{ext}` entry point exposes the matching nested loader tree, so the\n * entry point is discovered and aggregated exactly like a plain dynamic one.\n */\nexport const writeDynamicQualifiedDictionaries = async (\n  qualifiedDictionaries: QualifiedMergedDictionaryOutput,\n  configuration: IntlayerConfig,\n  formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<void> => {\n  const { locales, defaultLocale } = configuration.internationalization;\n  const { dynamicDictionariesDir } = configuration.system;\n\n  const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n  await mkdir(dictDir, { recursive: true });\n\n  await parallelize(\n    Object.entries(qualifiedDictionaries).sort(([a], [b]) =>\n      String(a).localeCompare(String(b))\n    ),\n    async ([key, { dictionary: group }]) => {\n      if (key === 'undefined') return;\n\n      const entryIds = Object.keys(group.content);\n\n      const keyDir = resolve(dictDir, key);\n      assertPathWithin(keyDir, dictDir);\n\n      // Entries with identical content (e.g. array-variant fan-out) share one\n      // chunk: only the first entry per content identity writes files; the\n      // others become aliases whose loaders point at the canonical chunk path.\n      const canonicalSegmentsByContent = new Map<string, string[]>();\n      const entries: QualifiedEntrySegments[] = [];\n      const canonicalEntryIds: string[] = [];\n\n      for (const entryId of entryIds) {\n        const treeSegments = entryId.split(COMPOSITE_ID_SEPARATOR);\n        const contentIdentity = JSON.stringify(group.content[entryId]);\n        const canonicalSegments =\n          canonicalSegmentsByContent.get(contentIdentity);\n\n        if (canonicalSegments) {\n          entries.push({ treeSegments, chunkSegments: canonicalSegments });\n          continue;\n        }\n\n        canonicalSegmentsByContent.set(contentIdentity, treeSegments);\n        entries.push({ treeSegments, chunkSegments: treeSegments });\n        canonicalEntryIds.push(entryId);\n      }\n\n      await parallelize(canonicalEntryIds, async (entryId) => {\n        // Rebuild a resolvable dictionary from the content node + composite id\n        // so per-locale extraction sees the same `{ key, content }` shape.\n        const entry = reconstructQualifiedEntry(group, entryId);\n\n        const segments = entryId.split(COMPOSITE_ID_SEPARATOR);\n\n        const entryDir = resolve(keyDir, ...segments);\n        assertPathWithin(entryDir, keyDir);\n        await mkdir(entryDir, { recursive: true });\n\n        await parallelize(locales, async (locale) => {\n          const localizedDictionary = getPerLocaleDictionary(\n            entry,\n            locale,\n            defaultLocale\n          );\n\n          // Directory structure: json/key/<…segments>/locale.json\n          const resultFilePath = resolve(entryDir, `${locale}.json`);\n\n          await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n            (err) => {\n              console.error(\n                `Error creating localized ${key}/${segments.join('/')}/${locale}.json:`,\n                err\n              );\n            }\n          );\n        });\n      });\n\n      await parallelize(formats, async (format) => {\n        const extension = format === 'cjs' ? 'cjs' : 'mjs';\n        const content = generateQualifiedDictionaryEntryPoint(\n          key,\n          group.qualifierTypes,\n          entries,\n          locales,\n          format\n        );\n\n        const dynEntryPath = resolve(\n          dynamicDictionariesDir,\n          `${key}.${extension}`\n        );\n        assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n        await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n          console.error(\n            `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n            err\n          );\n        });\n      });\n    }\n  );\n};\n"],"mappings":";;;;;;;;;;;;;AAyCA,MAAM,sBAAsBA;;;;;;AAO5B,MAAM,mBAAmB,UACvB,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,KAAK;;AAGlD,MAAM,wBACJ,KACA,QACA,WACW;CACX,MAAM,OAAO,KAAK,oBAAoB,GAAG,IAAI,GAAG,OAAO;CAEvD,OAAO,WAAW,QACd,WAAW,KAAK,2BAChB,4BAA4B,KAAK;AACvC;;;;;;;;;;;;;;;;AAiBA,MAAa,gCACX,KACA,SACA,SAAwB,OACxB,aAAuB,CAAC,MACb;CACX,MAAM,gBAAgB,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,MAC1C,OAAO,CAAC,CAAC,CAAC,cAAc,OAAO,CAAC,CAAC,CACnC;CACA,MAAM,mBAAmB,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;CAE1E,MAAM,UAAU,gBAAgB,GAAG;CAEnC,MAAM,gBAAgB,cACnB,KAAK,WAAW;EACf,MAAM,aAAa,gBAAgB,MAAM;EACzC,MAAM,YAAY,qBAAqB,SAAS,YAAY,MAAM;EAElE,IAAI,iBAAiB,WAAW,GAC9B,OAAO,MAAM,WAAW,WAAW;EAgBrC,OACE,MAAM,WAAW,gCACR,UAAU,WAfC,iBACnB,KAAK,cACJ,qBAAqB,gBAAgB,SAAS,GAAG,YAAY,MAAM,CACrE,CAAC,CACA,KA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