@intlayer/chokidar 8.4.3 → 8.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +3 -2
  2. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  3. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +4 -5
  4. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  5. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +3 -2
  6. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  7. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +4 -5
  8. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  9. package/dist/types/build.d.ts +1 -1
  10. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +1 -1
  11. package/dist/types/buildIntlayerDictionary/index.d.ts +1 -1
  12. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +1 -1
  13. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +7 -7
  14. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  15. package/dist/types/{buildIntlayerDictionary-_xrGjSmw.d.ts → buildIntlayerDictionary-C-LWgPIL.d.ts} +2 -2
  16. package/dist/types/{buildIntlayerDictionary-_xrGjSmw.d.ts.map → buildIntlayerDictionary-C-LWgPIL.d.ts.map} +1 -1
  17. package/dist/types/{writeDynamicDictionary-DO8f3FYl.d.ts → writeDynamicDictionary-BE0mF2zZ.d.ts} +7 -6
  18. package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts.map +1 -0
  19. package/package.json +8 -8
  20. package/dist/types/writeDynamicDictionary-DO8f3FYl.d.ts.map +0 -1
@@ -1,5 +1,6 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeFileIfChanged.cjs`),n=require(`../writeJsonIfChanged.cjs`);let r=require(`node:fs/promises`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/config/defaultValues`),s=require(`@intlayer/core/plugins`);const c=`json`,l=`utils/loadContent`,u=(e,t,n,r=`esm`)=>{let i=Object.keys(t).sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` '${e}': () => loadContent('${n}', '${e}')`).join(`,
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeFileIfChanged.cjs`),n=require(`../writeJsonIfChanged.cjs`);let r=require(`node:fs/promises`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/config/defaultValues`),s=require(`@intlayer/core/plugins`);const c=`json`,l=`_loadjson`,u=(e,t,n,r=`esm`)=>{let i=Object.keys(t).sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` '${e}': () => loadContent('${n}', '${e}')`).join(`,
2
2
  `),a=e;return a+=`const content = {\n${i}\n};\n\n`,r===`esm`&&(a+=`export default content;
3
3
  `),r===`cjs`&&(a+=`module.exports = content;
4
- `),a},d=e=>e===`esm`?`export const loadContent = (key, locale) =>\n import(\`../${c}/\${key}_\${locale}.json\`, { with: { type: 'json' } }).then(\n (mod) => mod.default\n );\n`:`const loadContent = (key, locale) =>\n Promise.resolve(require(\`../${c}/\${locale}_\${key}.json\`));\nmodule.exports = { loadContent };\n`,f=(e,t,n=`esm`)=>{let r=n===`cjs`?`cjs`:`mjs`;return u(n===`esm`?`import { loadContent } from './${l}.${r}';\n\n`:`const { loadContent } = require('./${l}.${r}');\n\n`,e,t,n)},p=async(u,p,m=o.OUTPUT_FORMAT)=>{let{locales:h,defaultLocale:g}=p.internationalization,{dynamicDictionariesDir:_}=p.system,v=(0,i.resolve)(_,c);await(0,r.mkdir)(v,{recursive:!0}),await(0,r.mkdir)((0,i.resolve)(_,`utils`),{recursive:!0}),await e.parallelize(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t.writeFileIfChanged((0,i.resolve)(_,`${l}.${n}`),d(e)).catch(e=>{console.error(`Error creating dynamic ${(0,a.colorizePath)((0,i.resolve)(_,`${l}.${n}`))}:`,e)})});let y={};return await e.parallelize(Object.entries(u).sort(([e],[t])=>String(e).localeCompare(String(t))),async([r,o])=>{if(r===`undefined`)return;let c={};await e.parallelize(h,async e=>{let t=(0,s.getPerLocaleDictionary)(o.dictionary,e,g),a=(0,i.resolve)(v,`${r}_${e}.json`);await n.writeJsonIfChanged(a,t).catch(t=>{console.error(`Error creating localized ${r}_${e}.json:`,t)}),c[e]={dictionaryPath:a,dictionary:t}}),y[r]=c,await e.parallelize(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`,o=f(c,r,e);await t.writeFileIfChanged((0,i.resolve)(_,`${r}.${n}`),o).catch(e=>{console.error(`Error creating dynamic ${(0,a.colorizePath)((0,i.resolve)(_,`${r}.${n}`))}:`,e)})})}),y};exports.buildEntryPointContent=u,exports.generateDictionaryEntryPoint=f,exports.generateDynamicLoadContentModule=d,exports.writeDynamicDictionary=p;
4
+ `),a},d=(e,t)=>{let n=`const loadContent = (key) => ({\n${[...t].sort((e,t)=>String(e).localeCompare(String(t))).map(t=>e===`esm`?` '${t}': () => import(\`./${c}/\${key}/${t}.json\`).then(m => m.default)`:` '${t}': () => Promise.resolve(require(\`./${c}/\${key}/${t}.json\`))`).join(`,
5
+ `)}\n});\n`;return e===`esm`?`${n}\nexport { loadContent };\n`:`${n}\nmodule.exports = { loadContent };\n`},f=(e,t=`esm`)=>{let n=t===`cjs`?`cjs`:`mjs`;return t===`esm`?`import { loadContent } from './${l}.${n}';\n\nconst content = loadContent('${e}');\n\nexport default content;\n`:`const { loadContent } = require('./${l}.${n}');\n\nmodule.exports = loadContent('${e}');\n`},p=async(u,p,m=o.OUTPUT_FORMAT)=>{let{locales:h,defaultLocale:g}=p.internationalization,{dynamicDictionariesDir:_}=p.system,v=(0,i.resolve)(_,c);await(0,r.mkdir)(v,{recursive:!0}),await e.parallelize(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t.writeFileIfChanged((0,i.resolve)(_,`${l}.${n}`),d(e,h)).catch(e=>{console.error(`Error creating dynamic ${(0,a.colorizePath)((0,i.resolve)(_,`${l}.${n}`))}:`,e)})});let y={};return await e.parallelize(Object.entries(u).sort(([e],[t])=>String(e).localeCompare(String(t))),async([o,c])=>{if(o===`undefined`)return;let l={},u=(0,i.resolve)(v,o);await(0,r.mkdir)(u,{recursive:!0}),await e.parallelize(h,async e=>{let t=(0,s.getPerLocaleDictionary)(c.dictionary,e,g),r=(0,i.resolve)(u,`${e}.json`);await n.writeJsonIfChanged(r,t).catch(t=>{console.error(`Error creating localized ${o}/${e}.json:`,t)}),l[e]={dictionaryPath:r,dictionary:t}}),y[o]=l,await e.parallelize(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`,r=f(o,e);await t.writeFileIfChanged((0,i.resolve)(_,`${o}.${n}`),r).catch(e=>{console.error(`Error creating dynamic ${(0,a.colorizePath)((0,i.resolve)(_,`${o}.${n}`))}:`,e)})})}),y};exports.buildEntryPointContent=u,exports.generateDictionaryEntryPoint=f,exports.generateDynamicLoadContentModule=d,exports.writeDynamicDictionary=p;
5
6
  //# sourceMappingURL=writeDynamicDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.cjs","names":["OUTPUT_FORMAT","parallelize","writeFileIfChanged","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } 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 = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = 'utils/loadContent';\n\n/**\n * Assembles the entry point file content from a pre-built preamble (import/require line),\n * the locale→path record, the dictionary key, and the output format.\n * Shared by all dictionary entry point generators.\n */\nexport const buildEntryPointContent = (\n preamble: string,\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const formattedDictionaryMap: string = Object.keys(\n localizedDictionariesPathsRecord\n )\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`)\n .join(',\\n');\n\n let content = preamble;\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n\\n`;\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Generates the content of the shared `_loadContent` module written once per\n * output directory. All dictionary entry points import from this file.\n */\nexport const generateDynamicLoadContentModule = (\n format: 'cjs' | 'esm'\n): string => {\n if (format === 'esm') {\n return (\n `export const loadContent = (key, locale) =>\\n` +\n ` import(\\`../${DICTIONARIES_SUBDIR}/\\${key}_\\${locale}.json\\`, { with: { type: 'json' } }).then(\\n` +\n ` (mod) => mod.default\\n` +\n ` );\\n`\n );\n }\n return (\n `const loadContent = (key, locale) =>\\n` +\n ` Promise.resolve(require(\\`../${DICTIONARIES_SUBDIR}/\\${locale}_\\${key}.json\\`));\\n` +\n `module.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n * `loadContent` is imported from the shared `_loadContent` module.\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const preamble =\n format === 'esm'\n ? `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n`\n : `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n`;\n\n return buildEntryPointContent(\n preamble,\n localizedDictionariesPathsRecord,\n key,\n format\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: MergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n // Create output folders\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n\n // Write the shared loadContent module once per format\n const utilsDir = resolve(dynamicDictionariesDir, 'utils');\n await mkdir(utilsDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateDynamicLoadContentModule(format)\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\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 await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n // Flat structure: dictionaries/locale_key.json\n const resultFilePath = resolve(dictDir, `${key}_${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(\n localizedDictionariesPathsRecord,\n key,\n format\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"4YA2BA,MAAM,EAAsB,OACtB,EAAsB,oBAOf,GACX,EACA,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAiC,OAAO,KAC5C,EACD,CACE,MAAM,EAAG,IAAM,OAAO,EAAE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GAAI,CAAC,KAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CACD,MAAO,CAAC,EAAK,KAAqB,CAChC,GAAI,IAAQ,YAAa,OAEzB,IAAM,EAA8D,EAAE,CAEtE,MAAMA,EAAAA,YAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,GAAA,EAAA,EAAA,wBACJ,EAAgB,WAChB,EACA,EACD,CAGK,GAAA,EAAA,EAAA,SAAyB,EAAS,GAAG,EAAI,GAAG,EAAO,OAAO,CAEhE,MAAME,EAAAA,mBAAmB,EAAgB,EAAoB,CAAC,MAC3D,GAAQ,CACP,QAAQ,MACN,4BAA4B,EAAI,GAAG,EAAO,QAC1C,EACD,EAEJ,CAED,EAAiC,GAAU,CACzC,eAAgB,EAChB,WAAY,EACb,EACD,CAEF,EAAwB,GAAO,EAE/B,MAAMF,EAAAA,YAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAMC,EAAAA,oBAAAA,EAAAA,EAAAA,SACI,EAAwB,GAAG,EAAI,GAAG,IAAY,CACtD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,2BAAA,EAAA,EAAA,eAAA,EAAA,EAAA,SAA+C,EAAwB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC/F,EACD,EACD,EACF,EAEL,CAEM"}
1
+ {"version":3,"file":"writeDynamicDictionary.cjs","names":["OUTPUT_FORMAT","parallelize","writeFileIfChanged","writeJsonIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } 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 = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Assembles the entry point file content from a pre-built preamble (import/require line),\n * the locale→path record, the dictionary key, and the output format.\n * Shared by all dictionary entry point generators.\n */\nexport const buildEntryPointContent = (\n preamble: string,\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const formattedDictionaryMap: string = Object.keys(\n localizedDictionariesPathsRecord\n )\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`)\n .join(',\\n');\n\n let content = preamble;\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n\\n`;\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Generates the content of the shared `loadContent` module written once per\n * output directory. Locales are baked in so each dynamic import has only one\n * variable (`key`), making it statically analyzable by Vite/Rollup.\n */\nexport const generateDynamicLoadContentModule = (\n format: 'cjs' | 'esm',\n locales: string[]\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 format === 'esm'\n ? ` '${locale}': () => import(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`).then(m => m.default)`\n : ` '${locale}': () => Promise.resolve(require(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`))`\n )\n .join(',\\n');\n\n const body = `const loadContent = (key) => ({\\n${localeEntries}\\n});\\n`;\n\n if (format === 'esm') return `${body}\\nexport { loadContent };\\n`;\n return `${body}\\nmodule.exports = { loadContent };\\n`;\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n * `loadContent` is imported from the shared module and called with the key.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\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: MergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\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 await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateDynamicLoadContentModule(format, locales)\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\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 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, format);\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"4YA2BA,MAAM,EAAsB,OACtB,EAAsB,YAOf,GACX,EACA,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAiC,OAAO,KAC5C,EACD,CACE,MAAM,EAAG,IAAM,OAAO,EAAE,CAAC,cAAc,OAAO,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f3.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeFileIfChanged.cjs`),n=require(`./writeDynamicDictionary.cjs`);let r=require(`node:fs/promises`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/config/utils`),s=require(`@intlayer/config/defaultValues`);const c=`utils/loadContent`,l=(e,t,n)=>e===`esm`?`export const loadContent = async (key, locale) => {
2
- try {
3
- const res = await fetch(\`${t}/dictionaries/\${key}/\${locale}\`);\n return await res.json();\n } catch (_error) {\n const m = await import(\`${n}/json/\${key}_\${locale}.json\`, { with: { type: 'json' } });\n return m.default || m;\n }\n};\n`:`const loadContent = async (key, locale) => {
4
- try {
5
- const res = await fetch(\`${t}/dictionaries/\${key}/\${locale}\`);\n return await res.json();\n } catch (_error) {\n return Promise.resolve(require(\`${n}/dictionaries/\${locale}_\${key}.json\`));\n }\n};\nmodule.exports = { loadContent };\n`,u=(e,t,r=`esm`)=>{let i=r===`cjs`?`cjs`:`mjs`;return n.buildEntryPointContent(r===`esm`?`import { loadContent } from './${c}.${i}';\n\n`:`const { loadContent } = require('./${c}.${i}');\n\n`,e,t,r)},d=async(n,d,f=s.OUTPUT_FORMAT)=>{let{fetchDictionariesDir:p,dynamicDictionariesDir:m}=d.system,{liveSyncURL:h}=d.editor,g=(0,o.normalizePath)((0,i.relative)((0,i.resolve)(p,`utils`),m));return g.startsWith(`.`)||(g=`./${g}`),await(0,r.mkdir)((0,i.resolve)(p),{recursive:!0}),await(0,r.mkdir)((0,i.resolve)(p,`utils`),{recursive:!0}),await e.parallelize(f,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t.writeFileIfChanged((0,i.resolve)(p,`${c}.${n}`),l(e,h,g)).catch(e=>{console.error(`Error creating fetch ${(0,a.colorizePath)((0,i.resolve)(p,`${c}.${n}`))}:`,e)})}),await e.parallelize(Object.entries(n),async([n,r])=>{n!==`undefined`&&await e.parallelize(f,async e=>{let o=e===`cjs`?`cjs`:`mjs`,s=u(r,n,e);await t.writeFileIfChanged((0,i.resolve)(p,`${n}.${o}`),s).catch(e=>{console.error(`Error creating fetch ${(0,a.colorizePath)((0,i.resolve)(p,`${n}.${o}`))}:`,e)})})}),{}};exports.generateDictionaryEntryPoint=u,exports.generateFetchLoadContentModule=l,exports.writeFetchDictionary=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../utils/parallelize.cjs`),t=require(`../writeFileIfChanged.cjs`);let n=require(`node:fs/promises`),r=require(`node:path`),i=require(`@intlayer/config/logger`),a=require(`@intlayer/config/utils`),o=require(`@intlayer/config/defaultValues`);const s=`_loadjson`,c=(e,t,n)=>{let r=[...n].sort((e,t)=>String(e).localeCompare(String(t))),i=e===`cjs`?`cjs`:`mjs`,a=`const loadContent = (key) => {
2
+ const dynContent = loadContentDyn(key);
3
+ return {\n${r.map(e=>` '${e}': async () => {\n try {\n const res = await fetch(\`\${configuration.editor.liveSyncURL}/dictionaries/\${key}/${e}\`);\n return await res.json();\n } catch {\n return dynContent['${e}']();\n }\n }`).join(`,
4
+ `)}\n };\n};\n`;return e===`esm`?`import { configuration } from 'intlayer';\nimport { loadContent as loadContentDyn } from '${t}/${s}.${i}';\n\n${a}\nexport { loadContent };\n`:`const { configuration } = require('intlayer');\nconst { loadContent: loadContentDyn } = require('${t}/${s}.${i}');\n\n${a}\nmodule.exports = { loadContent };\n`},l=(e,t=`esm`)=>{let n=t===`cjs`?`cjs`:`mjs`;return t===`esm`?`import { loadContent } from './${s}.${n}';\n\nconst content = loadContent('${e}');\n\nexport default content;\n`:`const { loadContent } = require('./${s}.${n}');\n\nmodule.exports = loadContent('${e}');\n`},u=async(u,d,f=o.OUTPUT_FORMAT)=>{let{fetchDictionariesDir:p,dynamicDictionariesDir:m}=d.system,{locales:h}=d.internationalization,g=(0,a.normalizePath)((0,r.relative)(p,m));return g.startsWith(`.`)||(g=`./${g}`),await(0,n.mkdir)((0,r.resolve)(p),{recursive:!0}),await e.parallelize(f,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t.writeFileIfChanged((0,r.resolve)(p,`${s}.${n}`),c(e,g,h)).catch(e=>{console.error(`Error creating fetch ${(0,i.colorizePath)((0,r.resolve)(p,`${s}.${n}`))}:`,e)})}),await e.parallelize(Object.entries(u),async([n])=>{n!==`undefined`&&await e.parallelize(f,async e=>{let a=e===`cjs`?`cjs`:`mjs`,o=l(n,e);await t.writeFileIfChanged((0,r.resolve)(p,`${n}.${a}`),o).catch(e=>{console.error(`Error creating fetch ${(0,i.colorizePath)((0,r.resolve)(p,`${n}.${a}`))}:`,e)})})}),{}};exports.generateDictionaryEntryPoint=l,exports.generateFetchLoadContentModule=c,exports.writeFetchDictionary=u;
6
5
  //# sourceMappingURL=writeFetchDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.cjs","names":["buildEntryPointContent","OUTPUT_FORMAT","parallelize","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport {\n buildEntryPointContent,\n type LocalizedDictionaryOutput,\n type LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = 'utils/loadContent';\n\n/**\n * Generates the content of the shared `_loadContent` module for fetch dictionaries,\n * written once per output directory. liveSyncURL and relativePrefix are baked in\n * as string literals since they are config-level constants for the whole build.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n liveSyncURL: string,\n relativePrefix: string\n): string => {\n if (format === 'esm') {\n return (\n `export const loadContent = async (key, locale) => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`${liveSyncURL}/dictionaries/\\${key}/\\${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch (_error) {\\n` +\n ` const m = await import(\\`${relativePrefix}/${DICTIONARIES_SUBDIR}/\\${key}_\\${locale}.json\\`, { with: { type: 'json' } });\\n` +\n ` return m.default || m;\\n` +\n ` }\\n` +\n `};\\n`\n );\n }\n return (\n `const loadContent = async (key, locale) => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`${liveSyncURL}/dictionaries/\\${key}/\\${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch (_error) {\\n` +\n ` return Promise.resolve(require(\\`${relativePrefix}/dictionaries/\\${locale}_\\${key}.json\\`));\\n` +\n ` }\\n` +\n `};\\n` +\n `module.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n * `loadContent` is imported from the shared `_loadContent` module.\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const preamble =\n format === 'esm'\n ? `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n`\n : `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n`;\n\n return buildEntryPointContent(\n preamble,\n localizedDictionariesPathsRecord,\n key,\n format\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/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n // Compute relative path from the utils/ subdir (where loadContent lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(resolve(fetchDictionariesDir, 'utils'), dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n const utilsDir = resolve(fetchDictionariesDir, 'utils');\n await mkdir(utilsDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, liveSyncURL, relativePrefix)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localizedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n key,\n format\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"+YA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A,YAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAMC,EAAAA,oBAAAA,EAAAA,EAAAA,SACI,EAAsB,GAAG,EAAI,GAAG,IAAY,CACpD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,yBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,SAA6C,EAAsB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC3F,EACD,EACD,EACF,EAEL,CA3B0D,EAAE"}
1
+ {"version":3,"file":"writeFetchDictionary.cjs","names":["OUTPUT_FORMAT","parallelize","writeFileIfChanged"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Generates the content of the shared `loadContent` module for fetch dictionaries.\n * - `configuration` is imported at runtime from \"intlayer\" (liveSyncURL not baked in).\n * - Fallback delegates to the dynamic dictionary's `_loadjson` module.\n * - Locales are baked in so each entry is a static function referencing one locale.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n relativePrefix: string,\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = sortedLocales\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${configuration.editor.liveSyncURL}/dictionaries/\\${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n const body =\n `const loadContent = (key) => {\\n` +\n ` const dynContent = loadContentDyn(key);\\n` +\n ` return {\\n${localeEntries}\\n };\\n` +\n `};\\n`;\n\n if (format === 'esm') {\n return (\n `import { configuration } from 'intlayer';\\n` +\n `import { loadContent as loadContentDyn } from '${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `${body}\\nexport { loadContent };\\n`\n );\n }\n return (\n `const { configuration } = require('intlayer');\\n` +\n `const { loadContent: loadContentDyn } = require('${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `${body}\\nmodule.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\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/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir (where _loadjson lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, relativePrefix, locales)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, format);\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n });\n\n return resultDictionariesPaths;\n};\n"],"mappings":"qWAUA,MAAM,EAAsB,YAQf,GACX,EACA,EACA,IACW,CACX,IAAM,EAAgB,CAAC,GAAG,EAAQ,CAAC,MAAM,EAAG,IAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CACK,EAAY,IAAW,MAAQ,MAAQ,MAgBvC,EACJ;;cAfoB,EACnB,IACE,GACC,MAAM,EAAO,yHAEgF,EAAO,gFAGxE,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,EAAO,CAEzD,MAAMC,EAAAA,oBAAAA,EAAAA,EAAAA,SACI,EAAsB,GAAG,EAAI,GAAG,IAAY,CACpD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,yBAAA,EAAA,EAAA,eAAA,EAAA,EAAA,SAA6C,EAAsB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC3F,EACD,EACD,EACF,EACF,CApByD,EAAE"}
@@ -1,5 +1,6 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{writeJsonIfChanged as n}from"../writeJsonIfChanged.mjs";import{mkdir as r}from"node:fs/promises";import{resolve as i}from"node:path";import{colorizePath as a}from"@intlayer/config/logger";import{OUTPUT_FORMAT as o}from"@intlayer/config/defaultValues";import{getPerLocaleDictionary as s}from"@intlayer/core/plugins";const c=`json`,l=`utils/loadContent`,u=(e,t,n,r=`esm`)=>{let i=Object.keys(t).sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` '${e}': () => loadContent('${n}', '${e}')`).join(`,
1
+ import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{writeJsonIfChanged as n}from"../writeJsonIfChanged.mjs";import{mkdir as r}from"node:fs/promises";import{resolve as i}from"node:path";import{colorizePath as a}from"@intlayer/config/logger";import{OUTPUT_FORMAT as o}from"@intlayer/config/defaultValues";import{getPerLocaleDictionary as s}from"@intlayer/core/plugins";const c=`json`,l=`_loadjson`,u=(e,t,n,r=`esm`)=>{let i=Object.keys(t).sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` '${e}': () => loadContent('${n}', '${e}')`).join(`,
2
2
  `),a=e;return a+=`const content = {\n${i}\n};\n\n`,r===`esm`&&(a+=`export default content;
3
3
  `),r===`cjs`&&(a+=`module.exports = content;
4
- `),a},d=e=>e===`esm`?`export const loadContent = (key, locale) =>\n import(\`../${c}/\${key}_\${locale}.json\`, { with: { type: 'json' } }).then(\n (mod) => mod.default\n );\n`:`const loadContent = (key, locale) =>\n Promise.resolve(require(\`../${c}/\${locale}_\${key}.json\`));\nmodule.exports = { loadContent };\n`,f=(e,t,n=`esm`)=>{let r=n===`cjs`?`cjs`:`mjs`;return u(n===`esm`?`import { loadContent } from './${l}.${r}';\n\n`:`const { loadContent } = require('./${l}.${r}');\n\n`,e,t,n)},p=async(u,p,m=o)=>{let{locales:h,defaultLocale:g}=p.internationalization,{dynamicDictionariesDir:_}=p.system,v=i(_,c);await r(v,{recursive:!0}),await r(i(_,`utils`),{recursive:!0}),await e(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t(i(_,`${l}.${n}`),d(e)).catch(e=>{console.error(`Error creating dynamic ${a(i(_,`${l}.${n}`))}:`,e)})});let y={};return await e(Object.entries(u).sort(([e],[t])=>String(e).localeCompare(String(t))),async([r,o])=>{if(r===`undefined`)return;let c={};await e(h,async e=>{let t=s(o.dictionary,e,g),a=i(v,`${r}_${e}.json`);await n(a,t).catch(t=>{console.error(`Error creating localized ${r}_${e}.json:`,t)}),c[e]={dictionaryPath:a,dictionary:t}}),y[r]=c,await e(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`,o=f(c,r,e);await t(i(_,`${r}.${n}`),o).catch(e=>{console.error(`Error creating dynamic ${a(i(_,`${r}.${n}`))}:`,e)})})}),y};export{u as buildEntryPointContent,f as generateDictionaryEntryPoint,d as generateDynamicLoadContentModule,p as writeDynamicDictionary};
4
+ `),a},d=(e,t)=>{let n=`const loadContent = (key) => ({\n${[...t].sort((e,t)=>String(e).localeCompare(String(t))).map(t=>e===`esm`?` '${t}': () => import(\`./${c}/\${key}/${t}.json\`).then(m => m.default)`:` '${t}': () => Promise.resolve(require(\`./${c}/\${key}/${t}.json\`))`).join(`,
5
+ `)}\n});\n`;return e===`esm`?`${n}\nexport { loadContent };\n`:`${n}\nmodule.exports = { loadContent };\n`},f=(e,t=`esm`)=>{let n=t===`cjs`?`cjs`:`mjs`;return t===`esm`?`import { loadContent } from './${l}.${n}';\n\nconst content = loadContent('${e}');\n\nexport default content;\n`:`const { loadContent } = require('./${l}.${n}');\n\nmodule.exports = loadContent('${e}');\n`},p=async(u,p,m=o)=>{let{locales:h,defaultLocale:g}=p.internationalization,{dynamicDictionariesDir:_}=p.system,v=i(_,c);await r(v,{recursive:!0}),await e(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t(i(_,`${l}.${n}`),d(e,h)).catch(e=>{console.error(`Error creating dynamic ${a(i(_,`${l}.${n}`))}:`,e)})});let y={};return await e(Object.entries(u).sort(([e],[t])=>String(e).localeCompare(String(t))),async([o,c])=>{if(o===`undefined`)return;let l={},u=i(v,o);await r(u,{recursive:!0}),await e(h,async e=>{let t=s(c.dictionary,e,g),r=i(u,`${e}.json`);await n(r,t).catch(t=>{console.error(`Error creating localized ${o}/${e}.json:`,t)}),l[e]={dictionaryPath:r,dictionary:t}}),y[o]=l,await e(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`,r=f(o,e);await t(i(_,`${o}.${n}`),r).catch(e=>{console.error(`Error creating dynamic ${a(i(_,`${o}.${n}`))}:`,e)})})}),y};export{u as buildEntryPointContent,f as generateDictionaryEntryPoint,d as generateDynamicLoadContentModule,p as writeDynamicDictionary};
5
6
  //# sourceMappingURL=writeDynamicDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } 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 = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = 'utils/loadContent';\n\n/**\n * Assembles the entry point file content from a pre-built preamble (import/require line),\n * the locale→path record, the dictionary key, and the output format.\n * Shared by all dictionary entry point generators.\n */\nexport const buildEntryPointContent = (\n preamble: string,\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const formattedDictionaryMap: string = Object.keys(\n localizedDictionariesPathsRecord\n )\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`)\n .join(',\\n');\n\n let content = preamble;\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n\\n`;\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Generates the content of the shared `_loadContent` module written once per\n * output directory. All dictionary entry points import from this file.\n */\nexport const generateDynamicLoadContentModule = (\n format: 'cjs' | 'esm'\n): string => {\n if (format === 'esm') {\n return (\n `export const loadContent = (key, locale) =>\\n` +\n ` import(\\`../${DICTIONARIES_SUBDIR}/\\${key}_\\${locale}.json\\`, { with: { type: 'json' } }).then(\\n` +\n ` (mod) => mod.default\\n` +\n ` );\\n`\n );\n }\n return (\n `const loadContent = (key, locale) =>\\n` +\n ` Promise.resolve(require(\\`../${DICTIONARIES_SUBDIR}/\\${locale}_\\${key}.json\\`));\\n` +\n `module.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n * `loadContent` is imported from the shared `_loadContent` module.\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const preamble =\n format === 'esm'\n ? `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n`\n : `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n`;\n\n return buildEntryPointContent(\n preamble,\n localizedDictionariesPathsRecord,\n key,\n format\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: MergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n // Create output folders\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n\n // Write the shared loadContent module once per format\n const utilsDir = resolve(dynamicDictionariesDir, 'utils');\n await mkdir(utilsDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateDynamicLoadContentModule(format)\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\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 await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n // Flat structure: dictionaries/locale_key.json\n const resultFilePath = resolve(dictDir, `${key}_${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(\n localizedDictionariesPathsRecord,\n key,\n format\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"wbA2BA,MAAM,EAAsB,OACtB,EAAsB,oBAOf,GACX,EACA,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAiC,OAAO,KAC5C,EACD,CACE,MAAM,EAAG,IAAM,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAClD,IAAK,GAAW,MAAM,EAAO,wBAAwB,EAAI,MAAM,EAAO,IAAI,CAC1E,KAAK;EAAM,CAEV,EAAU,EAKd,MAJA,IAAW,sBAAsB,E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G,EAAO,OAAO,CAEhE,MAAM,EAAmB,EAAgB,EAAoB,CAAC,MAC3D,GAAQ,CACP,QAAQ,MACN,4BAA4B,EAAI,GAAG,EAAO,QAC1C,EACD,EAEJ,CAED,EAAiC,GAAU,CACzC,eAAgB,EAChB,WAAY,EACb,EACD,CAEF,EAAwB,GAAO,EAE/B,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAM,EACJ,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CACtD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,0BAA0B,EAAa,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC/F,EACD,EACD,EACF,EAEL,CAEM"}
1
+ {"version":3,"file":"writeDynamicDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } 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 = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Assembles the entry point file content from a pre-built preamble (import/require line),\n * the locale→path record, the dictionary key, and the output format.\n * Shared by all dictionary entry point generators.\n */\nexport const buildEntryPointContent = (\n preamble: string,\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const formattedDictionaryMap: string = Object.keys(\n localizedDictionariesPathsRecord\n )\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`)\n .join(',\\n');\n\n let content = preamble;\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n\\n`;\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Generates the content of the shared `loadContent` module written once per\n * output directory. Locales are baked in so each dynamic import has only one\n * variable (`key`), making it statically analyzable by Vite/Rollup.\n */\nexport const generateDynamicLoadContentModule = (\n format: 'cjs' | 'esm',\n locales: string[]\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 format === 'esm'\n ? ` '${locale}': () => import(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`).then(m => m.default)`\n : ` '${locale}': () => Promise.resolve(require(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`))`\n )\n .join(',\\n');\n\n const body = `const loadContent = (key) => ({\\n${localeEntries}\\n});\\n`;\n\n if (format === 'esm') return `${body}\\nexport { loadContent };\\n`;\n return `${body}\\nmodule.exports = { loadContent };\\n`;\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n * `loadContent` is imported from the shared module and called with the key.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\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: MergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\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 await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateDynamicLoadContentModule(format, locales)\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\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 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, format);\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"wbA2BA,MAAM,EAAsB,OACtB,EAAsB,YAOf,GACX,EACA,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAiC,OAAO,KAC5C,EACD,CACE,MAAM,EAAG,IAAM,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAClD,IAAK,GAAW,MAAM,EAAO,wBAAwB,EAAI,MAAM,EAAO,IAAI,CAC1E,KAAK;EAAM,CAEV,EAAU,EAKd,MAJA,IAAW,sBAAsB,EAAuB,UACpD,IAAW,QAAO,GAAW;GAC7B,IAAW,QAAO,GAAW;GAE1B,GAQI,GACX,EACA,IACW,CAaX,IAAM,EAAO,oCAZS,CAAC,GAAG,EAAQ,CAAC,MAAM,EAAG,IAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CAGE,IAAK,GACJ,IAAW,MACP,MAAM,EAAO,sBAAsB,EAAoB,WAAW,EAAO,+BACzE,MA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GAAG,EAAO,OAAO,CAExD,MAAM,EAAmB,EAAgB,EAAoB,CAAC,MAC3D,GAAQ,CACP,QAAQ,MACN,4BAA4B,EAAI,GAAG,EAAO,QAC1C,EACD,EAEJ,CAED,EAAiC,GAAU,CACzC,eAAgB,EAChB,WAAY,EACb,EACD,CAEF,EAAwB,GAAO,EAE/B,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EAA6B,EAAK,EAAO,CAEzD,MAAM,EACJ,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CACtD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,0BAA0B,EAAa,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC/F,EACD,EACD,EACF,EAEL,CAEM"}
@@ -1,6 +1,5 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{buildEntryPointContent as n}from"./writeDynamicDictionary.mjs";import{mkdir as r}from"node:fs/promises";import{relative as i,resolve as a}from"node:path";import{colorizePath as o}from"@intlayer/config/logger";import{normalizePath as s}from"@intlayer/config/utils";import{OUTPUT_FORMAT as c}from"@intlayer/config/defaultValues";const l=`utils/loadContent`,u=(e,t,n)=>e===`esm`?`export const loadContent = async (key, locale) => {
2
- try {
3
- const res = await fetch(\`${t}/dictionaries/\${key}/\${locale}\`);\n return await res.json();\n } catch (_error) {\n const m = await import(\`${n}/json/\${key}_\${locale}.json\`, { with: { type: 'json' } });\n return m.default || m;\n }\n};\n`:`const loadContent = async (key, locale) => {
4
- try {
5
- const res = await fetch(\`${t}/dictionaries/\${key}/\${locale}\`);\n return await res.json();\n } catch (_error) {\n return Promise.resolve(require(\`${n}/dictionaries/\${locale}_\${key}.json\`));\n }\n};\nmodule.exports = { loadContent };\n`,d=(e,t,r=`esm`)=>{let i=r===`cjs`?`cjs`:`mjs`;return n(r===`esm`?`import { loadContent } from './${l}.${i}';\n\n`:`const { loadContent } = require('./${l}.${i}');\n\n`,e,t,r)},f=async(n,f,p=c)=>{let{fetchDictionariesDir:m,dynamicDictionariesDir:h}=f.system,{liveSyncURL:g}=f.editor,_=s(i(a(m,`utils`),h));return _.startsWith(`.`)||(_=`./${_}`),await r(a(m),{recursive:!0}),await r(a(m,`utils`),{recursive:!0}),await e(p,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t(a(m,`${l}.${n}`),u(e,g,_)).catch(e=>{console.error(`Error creating fetch ${o(a(m,`${l}.${n}`))}:`,e)})}),await e(Object.entries(n),async([n,r])=>{n!==`undefined`&&await e(p,async e=>{let i=e===`cjs`?`cjs`:`mjs`,s=d(r,n,e);await t(a(m,`${n}.${i}`),s).catch(e=>{console.error(`Error creating fetch ${o(a(m,`${n}.${i}`))}:`,e)})})}),{}};export{d as generateDictionaryEntryPoint,u as generateFetchLoadContentModule,f as writeFetchDictionary};
1
+ import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{mkdir as n}from"node:fs/promises";import{relative as r,resolve as i}from"node:path";import{colorizePath as a}from"@intlayer/config/logger";import{normalizePath as o}from"@intlayer/config/utils";import{OUTPUT_FORMAT as s}from"@intlayer/config/defaultValues";const c=`_loadjson`,l=(e,t,n)=>{let r=[...n].sort((e,t)=>String(e).localeCompare(String(t))),i=e===`cjs`?`cjs`:`mjs`,a=`const loadContent = (key) => {
2
+ const dynContent = loadContentDyn(key);
3
+ return {\n${r.map(e=>` '${e}': async () => {\n try {\n const res = await fetch(\`\${configuration.editor.liveSyncURL}/dictionaries/\${key}/${e}\`);\n return await res.json();\n } catch {\n return dynContent['${e}']();\n }\n }`).join(`,
4
+ `)}\n };\n};\n`;return e===`esm`?`import { configuration } from 'intlayer';\nimport { loadContent as loadContentDyn } from '${t}/${c}.${i}';\n\n${a}\nexport { loadContent };\n`:`const { configuration } = require('intlayer');\nconst { loadContent: loadContentDyn } = require('${t}/${c}.${i}');\n\n${a}\nmodule.exports = { loadContent };\n`},u=(e,t=`esm`)=>{let n=t===`cjs`?`cjs`:`mjs`;return t===`esm`?`import { loadContent } from './${c}.${n}';\n\nconst content = loadContent('${e}');\n\nexport default content;\n`:`const { loadContent } = require('./${c}.${n}');\n\nmodule.exports = loadContent('${e}');\n`},d=async(d,f,p=s)=>{let{fetchDictionariesDir:m,dynamicDictionariesDir:h}=f.system,{locales:g}=f.internationalization,_=o(r(m,h));return _.startsWith(`.`)||(_=`./${_}`),await n(i(m),{recursive:!0}),await e(p,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t(i(m,`${c}.${n}`),l(e,_,g)).catch(e=>{console.error(`Error creating fetch ${a(i(m,`${c}.${n}`))}:`,e)})}),await e(Object.entries(d),async([n])=>{n!==`undefined`&&await e(p,async e=>{let r=e===`cjs`?`cjs`:`mjs`,o=u(n,e);await t(i(m,`${n}.${r}`),o).catch(e=>{console.error(`Error creating fetch ${a(i(m,`${n}.${r}`))}:`,e)})})}),{}};export{u as generateDictionaryEntryPoint,l as generateFetchLoadContentModule,d as writeFetchDictionary};
6
5
  //# sourceMappingURL=writeFetchDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport {\n buildEntryPointContent,\n type LocalizedDictionaryOutput,\n type LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = 'utils/loadContent';\n\n/**\n * Generates the content of the shared `_loadContent` module for fetch dictionaries,\n * written once per output directory. liveSyncURL and relativePrefix are baked in\n * as string literals since they are config-level constants for the whole build.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n liveSyncURL: string,\n relativePrefix: string\n): string => {\n if (format === 'esm') {\n return (\n `export const loadContent = async (key, locale) => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`${liveSyncURL}/dictionaries/\\${key}/\\${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch (_error) {\\n` +\n ` const m = await import(\\`${relativePrefix}/${DICTIONARIES_SUBDIR}/\\${key}_\\${locale}.json\\`, { with: { type: 'json' } });\\n` +\n ` return m.default || m;\\n` +\n ` }\\n` +\n `};\\n`\n );\n }\n return (\n `const loadContent = async (key, locale) => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`${liveSyncURL}/dictionaries/\\${key}/\\${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch (_error) {\\n` +\n ` return Promise.resolve(require(\\`${relativePrefix}/dictionaries/\\${locale}_\\${key}.json\\`));\\n` +\n ` }\\n` +\n `};\\n` +\n `module.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n * `loadContent` is imported from the shared `_loadContent` module.\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const preamble =\n format === 'esm'\n ? `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n`\n : `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n`;\n\n return buildEntryPointContent(\n preamble,\n localizedDictionariesPathsRecord,\n key,\n format\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/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n // Compute relative path from the utils/ subdir (where loadContent lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(resolve(fetchDictionariesDir, 'utils'), dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n const utilsDir = resolve(fetchDictionariesDir, 'utils');\n await mkdir(utilsDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, liveSyncURL, relativePrefix)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localizedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n key,\n format\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"ocAcA,MACM,EAAsB,oBAOf,GACX,EACA,EACA,IAEI,IAAW,MAEX;;gCAEiC,EAAY,yHAGb,EAAe,sGAOjD;;gCAEiC,EAAY,iIAGL,EAAe,0FAW9C,GACX,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAY,IAAW,MAAQ,MAAQ,MAM7C,OAAO,EAJL,IAAW,MACP,kCAAkC,EAAoB,GAAG,EAAU,QACnE,sCAAsC,EAAoB,GAAG,EAAU,SAI3E,EACA,EACA,EACD,EAmBU,EAAuB,MAClC,EACA,EACA,EAA6B,IACU,CACvC,GAAM,CAAE,uBAAsB,0BAA2B,EAAc,OACjE,CAAE,eAAgB,EAAc,OAGlC,EAAiB,EACnB,EAAS,EAAQ,EAAsB,QAAQ,CAAE,EAAuB,CACzE,CAqDD,OApDK,EAAe,WAAW,IAAI,GACjC,EAAiB,KAAK,KAIxB,MAAM,EAAM,EAAQ,EAAqB,CAAE,CAAE,UAAW,GAAM,CAAC,CAI/D,MAAM,EADW,EAAQ,EAAsB,QAAQ,CACjC,CAAE,UAAW,GAAM,CAAC,CAC1C,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MAC7C,MAAM,EACJ,EAAQ,EAAsB,GAAG,EAAoB,GAAG,IAAY,CACpE,EAA+B,EAAQ,EAAa,EAAe,CACpE,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,wBAAwB,EAAa,EAAQ,EAAsB,GAAG,EAAoB,GAAG,IAAY,CAAC,CAAC,GAC3G,EACD,EACD,EACF,CAKF,MAAM,EACJ,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAsC,CAC7C,IAAQ,aAEZ,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAM,EACJ,EAAQ,EAAsB,GAAG,EAAI,GAAG,IAAY,CACpD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,wBAAwB,EAAa,EAAQ,EAAsB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC3F,EACD,EACD,EACF,EAEL,CA3B0D,EAAE"}
1
+ {"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Generates the content of the shared `loadContent` module for fetch dictionaries.\n * - `configuration` is imported at runtime from \"intlayer\" (liveSyncURL not baked in).\n * - Fallback delegates to the dynamic dictionary's `_loadjson` module.\n * - Locales are baked in so each entry is a static function referencing one locale.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n relativePrefix: string,\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = sortedLocales\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${configuration.editor.liveSyncURL}/dictionaries/\\${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n const body =\n `const loadContent = (key) => {\\n` +\n ` const dynContent = loadContentDyn(key);\\n` +\n ` return {\\n${localeEntries}\\n };\\n` +\n `};\\n`;\n\n if (format === 'esm') {\n return (\n `import { configuration } from 'intlayer';\\n` +\n `import { loadContent as loadContentDyn } from '${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `${body}\\nexport { loadContent };\\n`\n );\n }\n return (\n `const { configuration } = require('intlayer');\\n` +\n `const { loadContent: loadContentDyn } = require('${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `${body}\\nmodule.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\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/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir (where _loadjson lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, relativePrefix, locales)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, format);\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n });\n\n return resultDictionariesPaths;\n};\n"],"mappings":"8XAUA,MAAM,EAAsB,YAQf,GACX,EACA,EACA,IACW,CACX,IAAM,EAAgB,CAAC,GAAG,EAAQ,CAAC,MAAM,EAAG,IAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CACK,EAAY,IAAW,MAAQ,MAAQ,MAgBvC,EACJ;;cAfoB,EACnB,IACE,GACC,MAAM,EAAO,yHAEgF,EAAO,gFAGxE,EAAO,mBAGtC,CACA,KAAK;EAAM,CAKiB,cAU/B,OAPI,IAAW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EACD,EACD,EACF,EACF,CApByD,EAAE"}
@@ -1,4 +1,4 @@
1
- import { n as buildDictionary, t as BuildDictionariesOptions } from "./buildIntlayerDictionary-_xrGjSmw.js";
1
+ import { n as buildDictionary, t as BuildDictionariesOptions } from "./buildIntlayerDictionary-C-LWgPIL.js";
2
2
  import { t as processContentDeclaration } from "./processContentDeclaration-CAvrHaIT.js";
3
3
  import { cleanOutputDir } from "./cleanOutputDir.js";
4
4
  import { n as createDictionaryEntryPoint, t as CreateDictionaryEntryPointOptions } from "./createDictionaryEntryPoint-Bc5lHSiY.js";
@@ -1,2 +1,2 @@
1
- import { n as buildDictionary, t as BuildDictionariesOptions } from "../buildIntlayerDictionary-_xrGjSmw.js";
1
+ import { n as buildDictionary, t as BuildDictionariesOptions } from "../buildIntlayerDictionary-C-LWgPIL.js";
2
2
  export { BuildDictionariesOptions, buildDictionary };
@@ -1,3 +1,3 @@
1
- import { n as buildDictionary, t as BuildDictionariesOptions } from "../buildIntlayerDictionary-_xrGjSmw.js";
1
+ import { n as buildDictionary, t as BuildDictionariesOptions } from "../buildIntlayerDictionary-C-LWgPIL.js";
2
2
  import { t as processContentDeclaration } from "../processContentDeclaration-CAvrHaIT.js";
3
3
  export { BuildDictionariesOptions, buildDictionary, processContentDeclaration };
@@ -1,2 +1,2 @@
1
- import { a as generateDictionaryEntryPoint, i as buildEntryPointContent, n as LocalizedDictionaryOutput, o as generateDynamicLoadContentModule, r as LocalizedDictionaryResult, s as writeDynamicDictionary, t as DictionaryResult } from "../writeDynamicDictionary-DO8f3FYl.js";
1
+ import { a as generateDictionaryEntryPoint, i as buildEntryPointContent, n as LocalizedDictionaryOutput, o as generateDynamicLoadContentModule, r as LocalizedDictionaryResult, s as writeDynamicDictionary, t as DictionaryResult } from "../writeDynamicDictionary-BE0mF2zZ.js";
2
2
  export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, buildEntryPointContent, generateDictionaryEntryPoint, generateDynamicLoadContentModule, writeDynamicDictionary };
@@ -1,18 +1,18 @@
1
- import { n as LocalizedDictionaryOutput, r as LocalizedDictionaryResult } from "../writeDynamicDictionary-DO8f3FYl.js";
1
+ import { n as LocalizedDictionaryOutput } from "../writeDynamicDictionary-BE0mF2zZ.js";
2
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
3
 
4
4
  //#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
5
5
  /**
6
- * Generates the content of the shared `_loadContent` module for fetch dictionaries,
7
- * written once per output directory. liveSyncURL and relativePrefix are baked in
8
- * as string literals since they are config-level constants for the whole build.
6
+ * Generates the content of the shared `loadContent` module for fetch dictionaries.
7
+ * - `configuration` is imported at runtime from "intlayer" (liveSyncURL not baked in).
8
+ * - Fallback delegates to the dynamic dictionary's `_loadjson` module.
9
+ * - Locales are baked in so each entry is a static function referencing one locale.
9
10
  */
10
- declare const generateFetchLoadContentModule: (format: "cjs" | "esm", liveSyncURL: string, relativePrefix: string) => string;
11
+ declare const generateFetchLoadContentModule: (format: "cjs" | "esm", relativePrefix: string, locales: string[]) => string;
11
12
  /**
12
13
  * Generates the content of a fetch dictionary entry point file.
13
- * `loadContent` is imported from the shared `_loadContent` module.
14
14
  */
15
- declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, key: string, format?: "cjs" | "esm") => string;
15
+ declare const generateDictionaryEntryPoint: (key: string, format?: "cjs" | "esm") => string;
16
16
  /**
17
17
  * Write the localized dictionaries to the dictionariesDir
18
18
  * @param mergedDictionaries - The merged dictionaries
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;;AAsBA;cAAa,8BAAA,GACX,MAAA,iBACA,WAAA,UACA,cAAA;;;;;cAgCW,4BAAA,GACX,gCAAA,EAAkC,yBAAA,EAClC,GAAA,UACA,MAAA;;;AAHF;;;;;;;;;;AAmCA;;;;cAAa,oBAAA,GACX,mBAAA,EAAqB,yBAAA,EACrB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
1
+ {"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;;AAkBA;;cAAa,8BAAA,GACX,MAAA,iBACA,cAAA,UACA,OAAA;;;;cA4CW,4BAAA,GACX,GAAA,UACA,MAAA;;;AAFF;;;;;AAkCA;;;;;;;;;cAAa,oBAAA,GACX,mBAAA,EAAqB,yBAAA,EACrB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
@@ -1,6 +1,6 @@
1
1
  import { t as UnmergedDictionaryOutput } from "./writeUnmergedDictionary-Cxx51isz.js";
2
2
  import { t as MergedDictionaryOutput } from "./writeMergedDictionary-CMeghcRI.js";
3
- import { n as LocalizedDictionaryOutput } from "./writeDynamicDictionary-DO8f3FYl.js";
3
+ import { n as LocalizedDictionaryOutput } from "./writeDynamicDictionary-BE0mF2zZ.js";
4
4
  import { IntlayerConfig } from "@intlayer/types/config";
5
5
  import { Dictionary } from "@intlayer/types/dictionary";
6
6
  import { OUTPUT_FORMAT } from "@intlayer/config/defaultValues";
@@ -22,4 +22,4 @@ declare const buildDictionary: (localDictionariesEntries: Dictionary[], configur
22
22
  }>;
23
23
  //#endregion
24
24
  export { buildDictionary as n, BuildDictionariesOptions as t };
25
- //# sourceMappingURL=buildIntlayerDictionary-_xrGjSmw.d.ts.map
25
+ //# sourceMappingURL=buildIntlayerDictionary-C-LWgPIL.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary-_xrGjSmw.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;;KAYY,wBAAA,GAA2B,OAAA;EACrC,OAAA,SAAgB,aAAA;EAChB,uBAAA;EACA,GAAA;AAAA;;;;cAYW,eAAA,GACX,wBAAA,EAA0B,UAAA,IAC1B,aAAA,EAAe,cAAA,EACf,OAAA,GAAU,wBAAA,KAAwB,OAAA;wBAAA,wBAAA"}
1
+ {"version":3,"file":"buildIntlayerDictionary-C-LWgPIL.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;;KAYY,wBAAA,GAA2B,OAAA;EACrC,OAAA,SAAgB,aAAA;EAChB,uBAAA;EACA,GAAA;AAAA;;;;cAYW,eAAA,GACX,wBAAA,EAA0B,UAAA,IAC1B,aAAA,EAAe,cAAA,EACf,OAAA,GAAU,wBAAA,KAAwB,OAAA;wBAAA,wBAAA"}
@@ -17,15 +17,16 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
17
17
  */
18
18
  declare const buildEntryPointContent: (preamble: string, localizedDictionariesPathsRecord: LocalizedDictionaryResult, key: string, format?: "cjs" | "esm") => string;
19
19
  /**
20
- * Generates the content of the shared `_loadContent` module written once per
21
- * output directory. All dictionary entry points import from this file.
20
+ * Generates the content of the shared `loadContent` module written once per
21
+ * output directory. Locales are baked in so each dynamic import has only one
22
+ * variable (`key`), making it statically analyzable by Vite/Rollup.
22
23
  */
23
- declare const generateDynamicLoadContentModule: (format: "cjs" | "esm") => string;
24
+ declare const generateDynamicLoadContentModule: (format: "cjs" | "esm", locales: string[]) => string;
24
25
  /**
25
26
  * Generates the content of a dictionary entry point file.
26
- * `loadContent` is imported from the shared `_loadContent` module.
27
+ * `loadContent` is imported from the shared module and called with the key.
27
28
  */
28
- declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, key: string, format?: "cjs" | "esm") => string;
29
+ declare const generateDictionaryEntryPoint: (key: string, format?: "cjs" | "esm") => string;
29
30
  /**
30
31
  * Write the localized dictionaries to the dictionariesDir
31
32
  * @param mergedDictionaries - The merged dictionaries
@@ -45,4 +46,4 @@ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: L
45
46
  declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration: IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
46
47
  //#endregion
47
48
  export { generateDictionaryEntryPoint as a, buildEntryPointContent as i, LocalizedDictionaryOutput as n, generateDynamicLoadContentModule as o, LocalizedDictionaryResult as r, writeDynamicDictionary as s, DictionaryResult as t };
48
- //# sourceMappingURL=writeDynamicDictionary-DO8f3FYl.d.ts.map
49
+ //# sourceMappingURL=writeDynamicDictionary-BE0mF2zZ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeDynamicDictionary-BE0mF2zZ.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;;KAaY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;;;cAWW,sBAAA,GACX,QAAA,UACA,gCAAA,EAAkC,yBAAA,EAClC,GAAA,UACA,MAAA;;;;;;cAsBW,gCAAA,GACX,MAAA,iBACA,OAAA;;;;;cAwBW,4BAAA,GACX,GAAA,UACA,MAAA;;;;AAnEF;;;;;AAaA;;;;;;;;cAsFa,sBAAA,GACX,kBAAA,EAAoB,sBAAA,EACpB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/chokidar",
3
- "version": "8.4.3",
3
+ "version": "8.4.4",
4
4
  "private": false,
5
5
  "description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
6
6
  "keywords": [
@@ -110,13 +110,13 @@
110
110
  },
111
111
  "dependencies": {
112
112
  "@babel/parser": "7.29.0",
113
- "@intlayer/api": "8.4.3",
114
- "@intlayer/config": "8.4.3",
115
- "@intlayer/core": "8.4.3",
116
- "@intlayer/dictionaries-entry": "8.4.3",
117
- "@intlayer/remote-dictionaries-entry": "8.4.3",
118
- "@intlayer/types": "8.4.3",
119
- "@intlayer/unmerged-dictionaries-entry": "8.4.3",
113
+ "@intlayer/api": "8.4.4",
114
+ "@intlayer/config": "8.4.4",
115
+ "@intlayer/core": "8.4.4",
116
+ "@intlayer/dictionaries-entry": "8.4.4",
117
+ "@intlayer/remote-dictionaries-entry": "8.4.4",
118
+ "@intlayer/types": "8.4.4",
119
+ "@intlayer/unmerged-dictionaries-entry": "8.4.4",
120
120
  "chokidar": "3.6.0",
121
121
  "defu": "6.1.4",
122
122
  "fast-glob": "3.3.3",
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeDynamicDictionary-DO8f3FYl.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;;KAaY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;;;cAWW,sBAAA,GACX,QAAA,UACA,gCAAA,EAAkC,yBAAA,EAClC,GAAA,UACA,MAAA;;;;;cAqBW,gCAAA,GACX,MAAA;;;;;cAqBW,4BAAA,GACX,gCAAA,EAAkC,yBAAA,EAClC,GAAA,UACA,MAAA;;;;;AA/DF;;;;;AAaA;;;;;;;cAkFa,sBAAA,GACX,kBAAA,EAAoB,sBAAA,EACpB,aAAA,EAAe,cAAA,EACf,OAAA,yBACC,OAAA,CAAQ,yBAAA"}