@intlayer/chokidar 8.4.2 → 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.
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +5 -4
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/init/index.cjs +1 -1
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +3 -3
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/logConfigDetails.cjs +2 -2
- package/dist/cjs/logConfigDetails.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +1 -1
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +1 -1
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs +1 -1
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +5 -4
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +4 -4
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/init/index.mjs +1 -1
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +1 -1
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/logConfigDetails.mjs +2 -2
- package/dist/esm/logConfigDetails.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +1 -1
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +1 -1
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/writeConfiguration/index.mjs +1 -1
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/types/build.d.ts +1 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +1 -1
- package/dist/types/buildIntlayerDictionary/index.d.ts +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +15 -8
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/{buildIntlayerDictionary-BGj5jDFy.d.ts → buildIntlayerDictionary-C-LWgPIL.d.ts} +7 -6
- package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts.map +1 -0
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +0 -1
- package/dist/types/utils/formatter.d.ts.map +1 -1
- package/dist/types/writeConfiguration/index.d.ts.map +1 -1
- package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts +49 -0
- package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts.map +1 -0
- package/dist/types/{writeMergedDictionary-C4EvgXbL.d.ts → writeMergedDictionary-CMeghcRI.d.ts} +3 -3
- package/dist/types/writeMergedDictionary-CMeghcRI.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/types/buildIntlayerDictionary-BGj5jDFy.d.ts.map +0 -1
- package/dist/types/writeDynamicDictionary-DE3SJg-g.d.ts +0 -36
- package/dist/types/writeDynamicDictionary-DE3SJg-g.d.ts.map +0 -1
- package/dist/types/writeMergedDictionary-C4EvgXbL.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createDictionaryEntryPoint as e}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{buildDictionary as t}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{runOnce as n}from"./utils/runOnce.mjs";import{createModuleAugmentation as r}from"./createType/createModuleAugmentation.mjs";import{createTypes as i}from"./createType/createType.mjs";import{listDictionariesWithStats as a}from"./listDictionariesPath.mjs";import{loadDictionaries as o}from"./loadDictionaries/loadDictionaries.mjs";import{writeRemoteDictionary as s}from"./buildIntlayerDictionary/writeRemoteDictionary.mjs";import{cleanOutputDir as c}from"./cleanOutputDir.mjs";import{isCachedConfigurationUpToDate as l,writeConfiguration as u}from"./writeConfiguration/index.mjs";import{stat as d}from"node:fs/promises";import{join as f}from"node:path";import{
|
|
1
|
+
import{createDictionaryEntryPoint as e}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{buildDictionary as t}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{runOnce as n}from"./utils/runOnce.mjs";import{createModuleAugmentation as r}from"./createType/createModuleAugmentation.mjs";import{createTypes as i}from"./createType/createType.mjs";import{listDictionariesWithStats as a}from"./listDictionariesPath.mjs";import{loadDictionaries as o}from"./loadDictionaries/loadDictionaries.mjs";import{writeRemoteDictionary as s}from"./buildIntlayerDictionary/writeRemoteDictionary.mjs";import{cleanOutputDir as c}from"./cleanOutputDir.mjs";import{isCachedConfigurationUpToDate as l,writeConfiguration as u}from"./writeConfiguration/index.mjs";import{stat as d}from"node:fs/promises";import{join as f}from"node:path";import{colorize as p,getAppLogger as m}from"@intlayer/config/logger";import{cacheDisk as h}from"@intlayer/config/utils";import*as g from"@intlayer/config/colors";import _ from"@intlayer/config/package.json"with{type:"json"};const v={clean:!1,env:`prod`,format:[`cjs`,`esm`],cacheTimeoutMs:1e3*60*60},y=async(y,b)=>{let x=m(y),S=f(y.system.cacheDir,`intlayer-prepared.lock`),C=h(y,[`intlayer-version`]),w=await C.get(),T=!!(w&&w===_.version),E=await l(y),D=await a(y),O=!1;try{let e=await d(S);O=D.some(t=>t.stats.mtime.getTime()>e.mtime.getTime())}catch{}let k=(await Promise.all(y.plugins??[])).some(e=>!!e.loadDictionaries),{clean:A,format:j,forceRun:M,onIsCached:N,cacheTimeoutMs:P,env:F}={...v,forceRun:!T||!E||O||k,...b??{}};await n(S,async()=>{(A||!T)&&await c(y),await C.set(_.version);let n=Date.now();x([`Preparing Intlayer`,p(`(v${_.version})`,g.GREY_DARK)]),await u(y);let a=Date.now();x([`Configuration written`,p(`(${a-n}ms)`,g.GREY_DARK)],{isVerbose:!0});let l=await o(D.map(e=>e.path),y),d=Date.now();x([`Content loaded`,p([l.remoteDictionaries.length+l.pluginDictionaries.length>0?[`(Total: ${d-a}ms`,l.localDictionaries.length>0?` - Local: ${l.time.localDictionaries}ms`:``,l.remoteDictionaries.length>0?` - Remote: ${l.time.remoteDictionaries}ms`:``,l.pluginDictionaries.length>0?` - Plugin: ${l.time.pluginDictionaries}ms`:``,`)`].join(``):`(${d-a}ms)`].join(``),g.GREY_DARK)],{isVerbose:!0});let f=await t([...l.localDictionaries,...l.remoteDictionaries,...l.pluginDictionaries],y,{formats:j,importOtherDictionaries:!1,env:F});await s(l.remoteDictionaries,y),await i(Object.values(f?.mergedDictionaries??{}).map(e=>e.dictionary),y),await e(y);let m=Date.now();x([`Dictionaries built`,p(`(${m-n}ms)`,g.GREY_DARK)]),await r(y),x([`Module augmentation built`,p(`(${Date.now()-m}ms)`,g.GREY_DARK)],{isVerbose:!0});for await(let e of y.plugins??[]){let{unmergedDictionaries:t,mergedDictionaries:n}=f;await e.afterBuild?.({dictionaries:{unmergedDictionaries:t,mergedDictionaries:n},configuration:y})}x([`Done`,p(`${Date.now()-n}ms`,g.GREEN)],{level:`info`,isVerbose:!0})},{forceRun:M,onIsCached:N,cacheTimeoutMs:P})};export{y as prepareIntlayer};
|
|
2
2
|
//# sourceMappingURL=prepareIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n env?: 'prod' | 'dev';\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n env: 'prod',\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion && intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const resolvedPlugins = await Promise.all(configuration.plugins ?? []);\n const hasPluginLoadDictionaries = resolvedPlugins.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs, env } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n if (clean || !isCorrectVersion) {\n await cleanOutputDir(configuration);\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n { formats: format, importOtherDictionaries: false, env }\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n env?: 'prod' | 'dev';\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n env: 'prod',\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion && intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const resolvedPlugins = await Promise.all(configuration.plugins ?? []);\n const hasPluginLoadDictionaries = resolvedPlugins.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs, env } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n if (clean || !isCorrectVersion) {\n await cleanOutputDir(configuration);\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n { formats: format, importOtherDictionaries: false, env }\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{
|
|
1
|
+
import{relative as e}from"node:path";import{colorize as t,colorizePath as n}from"@intlayer/config/logger";import*as r from"@intlayer/config/colors";import i from"@intlayer/config/built";import{getLocaleName as a}from"@intlayer/core/localization";import{ENGLISH as o}from"@intlayer/types/locales";const s=(t,r)=>[t].flat().map(t=>t.startsWith(`/`)?e(i.system.baseDir,t):t).map(e=>r===!1?e:n(e,r)).join(`, `),c=(e,n=r.GREEN)=>[e].flat().map(e=>`${a(e,o)} (${e})`).map(e=>n===!1?e:t(e,n)).join(`, `);export{c as formatLocale,s as formatPath};
|
|
2
2
|
//# sourceMappingURL=formatter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.mjs","names":[],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport
|
|
1
|
+
{"version":3,"file":"formatter.mjs","names":[],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizePath } from '@intlayer/config/logger';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const formatPath = (\n path: string | string[],\n color?: ANSIColors | false\n) =>\n [path]\n .flat()\n .map((path) =>\n path.startsWith('/') ? relative(configuration.system.baseDir, path) : path\n )\n .map((relativePath) =>\n color === false ? relativePath : colorizePath(relativePath, color)\n )\n .join(`, `);\n\nexport const formatLocale = (\n locale: LocalesValues | LocalesValues[],\n color: ANSIColors | false = ANSIColors.GREEN\n) =>\n [locale]\n .flat()\n .map((locale) => `${getLocaleName(locale, ENGLISH)} (${locale})`)\n .map((text) => (color === false ? text : colorize(text, color)))\n .join(`, `);\n"],"mappings":"wSAQA,MAAa,GACX,EACA,IAEA,CAAC,EAAK,CACH,MAAM,CACN,IAAK,GACJ,EAAK,WAAW,IAAI,CAAG,EAAS,EAAc,OAAO,QAAS,EAAK,CAAG,EACvE,CACA,IAAK,GACJ,IAAU,GAAQ,EAAe,EAAa,EAAc,EAAM,CACnE,CACA,KAAK,KAAK,CAEF,GACX,EACA,EAA4B,EAAW,QAEvC,CAAC,EAAO,CACL,MAAM,CACN,IAAK,GAAW,GAAG,EAAc,EAAQ,EAAQ,CAAC,IAAI,EAAO,GAAG,CAChE,IAAK,GAAU,IAAU,GAAQ,EAAO,EAAS,EAAM,EAAM,CAAE,CAC/D,KAAK,KAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{writeJsonIfChanged as e}from"../writeJsonIfChanged.mjs";import{mkdir as t,readFile as n}from"node:fs/promises";import{join as r}from"node:path";import{isDeepStrictEqual as i}from"node:util";const a=async e=>{let t=await n(r(e.system.configDir,`configuration.json`),`utf8`);return JSON.parse(t)},o=async e=>{
|
|
1
|
+
import{writeJsonIfChanged as e}from"../writeJsonIfChanged.mjs";import{mkdir as t,readFile as n}from"node:fs/promises";import{join as r}from"node:path";import{isDeepStrictEqual as i}from"node:util";const a=async e=>{let t=await n(r(e.system.configDir,`configuration.json`),`utf8`);return JSON.parse(t)},o=async e=>{let t=s(e);return i(await a(e),t)},s=e=>JSON.parse(JSON.stringify({internationalization:{locales:e.internationalization.locales,defaultLocale:e.internationalization.defaultLocale},editor:e.editor,log:e.log,routing:e.routing,metadata:e.metadata})),c=async n=>{let{system:i}=n,{configDir:a}=i;await t(a,{recursive:!0}),await e(r(a,`configuration.json`),s(n))};export{o as isCachedConfigurationUpToDate,c as writeConfiguration};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst getCachedConfiguration = async (configuration: IntlayerConfig) => {\n const configFilePath = join(\n configuration.system.configDir,\n 'configuration.json'\n );\n\n const configurationContent = await readFile(configFilePath, 'utf8');\n return JSON.parse(configurationContent);\n};\n\nexport const isCachedConfigurationUpToDate = async (\n configuration: IntlayerConfig\n): Promise<boolean | null> => {\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst getCachedConfiguration = async (configuration: IntlayerConfig) => {\n const configFilePath = join(\n configuration.system.configDir,\n 'configuration.json'\n );\n\n const configurationContent = await readFile(configFilePath, 'utf8');\n return JSON.parse(configurationContent);\n};\n\nexport const isCachedConfigurationUpToDate = async (\n configuration: IntlayerConfig\n): Promise<boolean | null> => {\n const cleanedConfiguration = cleanConfiguration(configuration);\n const cachedConfiguration = await getCachedConfiguration(configuration);\n\n const isSimilar = isDeepStrictEqual(\n cachedConfiguration,\n cleanedConfiguration\n );\n\n return isSimilar;\n};\n\nconst cleanConfiguration = (configuration: IntlayerConfig): IntlayerConfig => {\n const parsedConfiguration = JSON.parse(\n JSON.stringify({\n internationalization: {\n locales: configuration.internationalization.locales,\n defaultLocale: configuration.internationalization.defaultLocale,\n },\n editor: configuration.editor,\n log: configuration.log,\n routing: configuration.routing,\n metadata: configuration.metadata,\n } as CustomIntlayerConfig)\n );\n\n return parsedConfiguration;\n};\n\nexport const writeConfiguration = async (configuration: IntlayerConfig) => {\n const { system } = configuration;\n const { configDir } = system;\n\n // Ensure target directory exists\n // configDir is expected to be the directory where configuration.json will live\n await mkdir(configDir, { recursive: true });\n\n const configFilePath = join(configDir, 'configuration.json');\n\n const cleanedConfiguration = cleanConfiguration(configuration);\n\n await writeJsonIfChanged(configFilePath, cleanedConfiguration);\n};\n"],"mappings":"qMASA,MAAM,EAAyB,KAAO,IAAkC,CAMtE,IAAM,EAAuB,MAAM,EALZ,EACrB,EAAc,OAAO,UACrB,qBACD,CAE2D,OAAO,CACnE,OAAO,KAAK,MAAM,EAAqB,EAG5B,EAAgC,KAC3C,IAC4B,CAC5B,IAAM,EAAuB,EAAmB,EAAc,CAQ9D,OALkB,EAFU,MAAM,EAAuB,EAAc,CAIrE,EACD,EAKG,EAAsB,GACE,KAAK,MAC/B,KAAK,UAAU,CACb,qBAAsB,CACpB,QAAS,EAAc,qBAAqB,QAC5C,cAAe,EAAc,qBAAqB,cACnD,CACD,OAAQ,EAAc,OACtB,IAAK,EAAc,IACnB,QAAS,EAAc,QACvB,SAAU,EAAc,SACzB,CAAyB,CAC3B,CAKU,EAAqB,KAAO,IAAkC,CACzE,GAAM,CAAE,UAAW,EACb,CAAE,aAAc,EAItB,MAAM,EAAM,EAAW,CAAE,UAAW,GAAM,CAAC,CAM3C,MAAM,EAJiB,EAAK,EAAW,qBAAqB,CAE/B,EAAmB,EAAc,CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getFormatFromExtension as e}from"../utils/getFormatFromExtension.mjs";import{detectFormatCommand as t}from"../detectFormatCommand.mjs";import{processContentDeclarationContent as n}from"./processContentDeclarationContent.mjs";import{transformJSONFile as r}from"./transformJSONFile.mjs";import{writeJSFile as i}from"./writeJSFile.mjs";import{mkdir as a,readFile as o,rename as s,rm as c,writeFile as l}from"node:fs/promises";import{basename as u,dirname as d,extname as f,join as p,resolve as m}from"node:path";import{
|
|
1
|
+
import{getFormatFromExtension as e}from"../utils/getFormatFromExtension.mjs";import{detectFormatCommand as t}from"../detectFormatCommand.mjs";import{processContentDeclarationContent as n}from"./processContentDeclarationContent.mjs";import{transformJSONFile as r}from"./transformJSONFile.mjs";import{writeJSFile as i}from"./writeJSFile.mjs";import{mkdir as a,readFile as o,rename as s,rm as c,writeFile as l}from"node:fs/promises";import{basename as u,dirname as d,extname as f,join as p,resolve as m}from"node:path";import{getUnmergedDictionaries as h}from"@intlayer/unmerged-dictionaries-entry";import{existsSync as g}from"node:fs";import{COMPILER_NO_METADATA as _}from"@intlayer/config/defaultValues";import{getFilteredLocalesDictionary as v,getPerLocaleDictionary as y}from"@intlayer/core/plugins";import{execSync as b}from"node:child_process";import{isDeepStrictEqual as x}from"node:util";const S=async(t,r,i)=>{let a=await n(t),o=a.content;t.locale?o=y(a,t.locale).content:i&&(o=v(a,i).content);let s={...t,content:o};for await(let e of r.plugins??[])if(e.formatOutput){let t=await e.formatOutput?.({dictionary:s,configuration:r});t&&(s=t)}if(!(s.content&&s.key))return s;let c={key:t.key,id:t.id,title:t.title,description:t.description,tags:t.tags,locale:t.locale,fill:t.fill,filled:t.filled,priority:t.priority,importMode:t.importMode,version:t.version,content:o};return e(t.filePath?f(t.filePath):`.json`)===`json`&&s.content&&s.key&&(c={$schema:`https://intlayer.org/schema.json`,...c}),c},C={newDictionariesPath:`intlayer-dictionaries`},w=async(e,t,n)=>{let{system:r,compiler:i}=t,{baseDir:a}=r,o=i?.noMetadata??_,{newDictionariesPath:s,localeList:c}={...C,...n},l=p(a,s),u=h(t)[e.key]?.find(t=>t.localId===e.localId),d=await S(e,t,c);if(u?.filePath){let n=x(u,e),r=m(t.system.baseDir,u.filePath);return n?{status:`up-to-date`,path:r}:(await T(r,d,t,o),{status:`updated`,path:r})}if(e.filePath){let n=m(t.system.baseDir,e.filePath);return await T(n,d,t,o),{status:`created`,path:n}}let f=p(l,`${e.key}.content.json`);return await T(f,d,t,o),{status:`imported`,path:f}},T=async(e,n,m,h)=>{await a(d(e),{recursive:!0});let _=f(e);if([`.json`,`.jsonc`,`.json5`].includes(_)){let i=`{}`;if(g(e))try{i=await o(e,`utf-8`)}catch{}let d=r(i,n,h),f=m.system?.tempDir;f&&await a(f,{recursive:!0});let _=`${u(e)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`,v=f?p(f,_):`${e}.${_}`;try{await l(v,d,`utf-8`),await s(v,e)}catch(e){try{await c(v,{force:!0})}catch{}throw e}let y=t(m);if(y)try{b(y.replace(`{{file}}`,e),{stdio:`inherit`,cwd:m.system.baseDir})}catch(e){console.error(e)}return}await i(e,n,m,h);try{await c(p(m.system.cacheDir,`intlayer-prepared.lock`),{recursive:!0})}catch{}};export{w as writeContentDeclaration};
|
|
2
2
|
//# sourceMappingURL=writeContentDeclaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport { DefaultValues } from '@intlayer/config/client';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} 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 type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { detectFormatCommand } from '../detectFormatCommand';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { transformJSONFile } from './transformJSONFile';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n importMode: dictionary.importMode,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { system, compiler } = configuration;\n const { baseDir } = system;\n\n const noMetadata =\n compiler?.noMetadata ?? DefaultValues.Compiler.COMPILER_NO_METADATA;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.system.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration,\n noMetadata\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(configuration.system.baseDir, dictionary.filePath);\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration,\n noMetadata\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration,\n noMetadata\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n noMetadata?: boolean\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n\n // Handle JSON, JSONC, and JSON5 via the AST transformer\n if (['.json', '.jsonc', '.json5'].includes(extension)) {\n let fileContent = '{}';\n\n if (existsSync(absoluteFilePath)) {\n try {\n fileContent = await readFile(absoluteFilePath, 'utf-8');\n } catch {\n // ignore read errors, start with empty object\n }\n }\n\n const transformedContent = transformJSONFile(\n fileContent,\n dictionary,\n noMetadata\n );\n\n // We use standard writeFile because transformedContent is already a string\n const tempDir = configuration.system?.tempDir;\n if (tempDir) {\n await mkdir(tempDir, { recursive: true });\n }\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n try {\n await writeFile(tempPath, transformedContent, 'utf-8');\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', absoluteFilePath), {\n stdio: 'inherit',\n cwd: configuration.system.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration, noMetadata);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":"+2BAyBA,MAAM,EAA2B,MAC/B,EACA,EACA,IACG,CAIH,IAAM,EACJ,MAAM,EAAiC,EAAW,CAEhD,EAAU,EAAoB,QAM9B,EAAW,OACb,EAAU,EACR,EACA,EAAW,OACZ,CAAC,QACO,IACT,EAAU,EACR,EACA,EACD,CAAC,SAGJ,IAAI,EAA0B,CAC5B,GAAG,EACH,UACD,CAMD,UAAW,IAAM,KAAU,EAAc,SAAW,EAAE,CACpD,GAAI,EAAO,aAAc,CACvB,IAAM,EAAkB,MAAM,EAAO,eAAe,CAClD,WAAY,EACZ,gBACD,CAAC,CAEE,IACF,EAAqB,GAQ3B,GAAI,EAFF,EAAmB,SAAW,EAAmB,KAE1B,OAAO,EAEhC,IAAI,EAAqB,CACvB,IAAK,EAAW,IAChB,GAAI,EAAW,GACf,MAAO,EAAW,MAClB,YAAa,EAAW,YACxB,KAAM,EAAW,KACjB,OAAQ,EAAW,OACnB,KAAM,EAAW,KACjB,OAAQ,EAAW,OACnB,SAAU,EAAW,SACrB,WAAY,EAAW,WACvB,QAAS,EAAW,QACpB,UACD,CAqBD,OAbe,EAFb,EAAW,SAAW,EAAQ,EAAW,SAAS,CAAG,QAEP,GAGnC,QACX,EAAmB,SACnB,EAAmB,MAEnB,EAAS,CACP,QAAS,mCACT,GAAG,EACJ,EAGI,GASH,EAAiB,CACrB,oBAAqB,wBACtB,CAEY,EAA0B,MACrC,EACA,EACA,IACwD,CACxD,GAAM,CAAE,SAAQ,YAAa,EACvB,CAAE,WAAY,EAEd,EACJ,GAAU,YAAc,EAAc,SAAS,qBAC3C,CAAE,sBAAqB,cAAe,CAC1C,GAAG,EACH,GAAG,EACJ,CAEK,EAA4B,EAAK,EAAS,EAAoB,CAO9D,EAL6B,EAAwB,EAAc,CAEvE,EAAW,MAGoC,KAC9C,GAAO,EAAG,UAAY,EAAW,QACnC,CAEK,EAA8B,MAAM,EACxC,EACA,EACA,EACD,CAED,GAAI,GAAoB,SAAU,CAEhC,IAAM,EAAgB,EAAkB,EAAoB,EAAW,CAEjE,EAAW,EACf,EAAc,OAAO,QACrB,EAAmB,SACpB,CAiBD,OAdI,EACK,CACL,OAAQ,aACR,KAAM,EACP,EAGH,MAAM,EACJ,EACA,EACA,EACA,EACD,CAEM,CAAE,OAAQ,UAAW,KAAM,EAAU,EAG9C,GAAI,EAAW,SAAU,CACvB,IAAM,EAAW,EAAQ,EAAc,OAAO,QAAS,EAAW,SAAS,CAS3E,OAPA,MAAM,EACJ,EACA,EACA,EACA,EACD,CAEM,CAAE,OAAQ,UAAW,KAAM,EAAU,CAI9C,IAAM,EAAyB,EAC7B,EACA,GAAG,EAAW,IAAI,eACnB,CASD,OAPA,MAAM,EACJ,EACA,EACA,EACA,EACD,CAEM,CACL,OAAQ,WACR,KAAM,EACP,EAGG,EAA2B,MAC/B,EACA,EACA,EACA,IACkB,CAKlB,MAAM,EAHM,EAAQ,EAAiB,CAGpB,CAAE,UAAW,GAAM,CAAC,CAErC,IAAM,EAAY,EAAQ,EAAiB,CAG3C,GAAI,CAAC,QAAS,SAAU,SAAS,CAAC,SAAS,EAAU,CAAE,CACrD,IAAI,EAAc,KAElB,GAAI,EAAW,EAAiB,CAC9B,GAAI,CACF,EAAc,MAAM,EAAS,EAAkB,QAAQ,MACjD,EAKV,IAAM,EAAqB,EACzB,EACA,EACA,EACD,CAGK,EAAU,EAAc,QAAQ,QAClC,GACF,MAAM,EAAM,EAAS,CAAE,UAAW,GAAM,CAAC,CAG3C,IAAM,EAAe,GAAG,EAAS,EAAiB,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC,MAClG,EAAW,EACb,EAAK,EAAS,EAAa,CAC3B,GAAG,EAAiB,GAAG,IAC3B,GAAI,CACF,MAAM,EAAU,EAAU,EAAoB,QAAQ,CACtD,MAAM,EAAO,EAAU,EAAiB,OACjC,EAAO,CACd,GAAI,CACF,MAAM,EAAG,EAAU,CAAE,MAAO,GAAM,CAAC,MAC7B,EAGR,MAAM,EAGR,IAAM,EAAgB,EAAoB,EAAc,CAExD,GAAI,EACF,GAAI,CACF,EAAS,EAAc,QAAQ,WAAY,EAAiB,CAAE,CAC5D,MAAO,UACP,IAAK,EAAc,OAAO,QAC3B,CAAC,OACK,EAAO,CACd,QAAQ,MAAM,EAAM,CAIxB,OAGF,MAAM,EAAY,EAAkB,EAAY,EAAe,EAAW,CAI1E,GAAI,CAKF,MAAM,EAJe,EACnB,EAAc,OAAO,SACrB,yBACD,CACsB,CAAE,UAAW,GAAM,CAAC,MACrC"}
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport { COMPILER_NO_METADATA } from '@intlayer/config/defaultValues';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} 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 type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { detectFormatCommand } from '../detectFormatCommand';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { transformJSONFile } from './transformJSONFile';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n id: dictionary.id,\n title: dictionary.title,\n description: dictionary.description,\n tags: dictionary.tags,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n priority: dictionary.priority,\n importMode: dictionary.importMode,\n version: dictionary.version,\n content,\n };\n\n /**\n * Add $schema to JSON dictionaries\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { system, compiler } = configuration;\n const { baseDir } = system;\n\n const noMetadata = compiler?.noMetadata ?? COMPILER_NO_METADATA;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = isDeepStrictEqual(existingDictionary, dictionary);\n\n const filePath = resolve(\n configuration.system.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration,\n noMetadata\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(configuration.system.baseDir, dictionary.filePath);\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration,\n noMetadata\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration,\n noMetadata\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n noMetadata?: boolean\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n\n // Handle JSON, JSONC, and JSON5 via the AST transformer\n if (['.json', '.jsonc', '.json5'].includes(extension)) {\n let fileContent = '{}';\n\n if (existsSync(absoluteFilePath)) {\n try {\n fileContent = await readFile(absoluteFilePath, 'utf-8');\n } catch {\n // ignore read errors, start with empty object\n }\n }\n\n const transformedContent = transformJSONFile(\n fileContent,\n dictionary,\n noMetadata\n );\n\n // We use standard writeFile because transformedContent is already a string\n const tempDir = configuration.system?.tempDir;\n if (tempDir) {\n await mkdir(tempDir, { recursive: true });\n }\n\n const tempFileName = `${basename(absoluteFilePath)}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;\n const tempPath = tempDir\n ? join(tempDir, tempFileName)\n : `${absoluteFilePath}.${tempFileName}`;\n try {\n await writeFile(tempPath, transformedContent, 'utf-8');\n await rename(tempPath, absoluteFilePath);\n } catch (error) {\n try {\n await rm(tempPath, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', absoluteFilePath), {\n stdio: 'inherit',\n cwd: configuration.system.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration, noMetadata);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":"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"}
|
package/dist/types/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as buildDictionary, t as BuildDictionariesOptions } from "./buildIntlayerDictionary-
|
|
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-
|
|
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-
|
|
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
|
|
2
|
-
export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
|
|
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
|
+
export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, buildEntryPointContent, generateDictionaryEntryPoint, generateDynamicLoadContentModule, writeDynamicDictionary };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { n as LocalizedDictionaryOutput
|
|
2
|
-
import
|
|
1
|
+
import { n as LocalizedDictionaryOutput } from "../writeDynamicDictionary-BE0mF2zZ.js";
|
|
2
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
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.
|
|
7
10
|
*/
|
|
8
|
-
declare const
|
|
11
|
+
declare const generateFetchLoadContentModule: (format: "cjs" | "esm", relativePrefix: string, locales: string[]) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Generates the content of a fetch dictionary entry point file.
|
|
14
|
+
*/
|
|
15
|
+
declare const generateDictionaryEntryPoint: (key: string, format?: "cjs" | "esm") => string;
|
|
9
16
|
/**
|
|
10
17
|
* Write the localized dictionaries to the dictionariesDir
|
|
11
18
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -18,11 +25,11 @@ declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: Loc
|
|
|
18
25
|
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
19
26
|
* console.log(finalDictionaries);
|
|
20
27
|
*
|
|
21
|
-
* // .intlayer/
|
|
22
|
-
* //
|
|
28
|
+
* // .intlayer/fetch_dictionary/home.mjs
|
|
29
|
+
* // .intlayer/fetch_dictionary/home.cjs
|
|
23
30
|
* ```
|
|
24
31
|
*/
|
|
25
|
-
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration
|
|
32
|
+
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration: IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
26
33
|
//#endregion
|
|
27
|
-
export { generateDictionaryEntryPoint, writeFetchDictionary };
|
|
34
|
+
export { generateDictionaryEntryPoint, generateFetchLoadContentModule, writeFetchDictionary };
|
|
28
35
|
//# sourceMappingURL=writeFetchDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":"
|
|
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,2 +1,2 @@
|
|
|
1
|
-
import { n as MergedDictionaryResult, r as writeMergedDictionaries, t as MergedDictionaryOutput } from "../writeMergedDictionary-
|
|
1
|
+
import { n as MergedDictionaryResult, r as writeMergedDictionaries, t as MergedDictionaryOutput } from "../writeMergedDictionary-CMeghcRI.js";
|
|
2
2
|
export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeRemoteDictionary.d.ts
|
|
@@ -23,7 +23,7 @@ type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;
|
|
|
23
23
|
* // { key: 'home', content: { ... } },
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration
|
|
26
|
+
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration: IntlayerConfig) => Promise<RemoteDictionaryOutput>;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { RemoteDictionaryOutput, RemoteDictionaryResult, writeRemoteDictionary };
|
|
29
29
|
//# sourceMappingURL=writeRemoteDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"mappings":";;;;KAeY,sBAAA;EACV,cAAA;EACA,YAAA,EAAc,UAAA;AAAA;AAAA,KAGJ,sBAAA,GAAyB,MAAA,SAAe,sBAAA
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"mappings":";;;;KAeY,sBAAA;EACV,cAAA;EACA,YAAA,EAAc,UAAA;AAAA;AAAA,KAGJ,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;AAApD;;;;;AAkBA;;;;;cAAa,qBAAA,GACX,kBAAA,EAAoB,UAAA,IACpB,aAAA,EAAe,cAAA,KACd,OAAA,CAAQ,sBAAA"}
|
package/dist/types/{buildIntlayerDictionary-BGj5jDFy.d.ts → buildIntlayerDictionary-C-LWgPIL.d.ts}
RENAMED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { t as UnmergedDictionaryOutput } from "./writeUnmergedDictionary-Cxx51isz.js";
|
|
2
|
-
import { t as MergedDictionaryOutput } from "./writeMergedDictionary-
|
|
3
|
-
import { n as LocalizedDictionaryOutput } from "./writeDynamicDictionary-
|
|
4
|
-
import
|
|
2
|
+
import { t as MergedDictionaryOutput } from "./writeMergedDictionary-CMeghcRI.js";
|
|
3
|
+
import { n as LocalizedDictionaryOutput } from "./writeDynamicDictionary-BE0mF2zZ.js";
|
|
4
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
5
5
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
|
+
import { OUTPUT_FORMAT } from "@intlayer/config/defaultValues";
|
|
6
7
|
|
|
7
8
|
//#region src/buildIntlayerDictionary/buildIntlayerDictionary.d.ts
|
|
8
9
|
type BuildDictionariesOptions = Partial<{
|
|
9
|
-
formats:
|
|
10
|
+
formats: typeof OUTPUT_FORMAT;
|
|
10
11
|
importOtherDictionaries: boolean;
|
|
11
12
|
env: 'prod' | 'dev';
|
|
12
13
|
}>;
|
|
13
14
|
/**
|
|
14
15
|
* This function transpile the bundled code to to make dictionaries as JSON files
|
|
15
16
|
*/
|
|
16
|
-
declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration
|
|
17
|
+
declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration: IntlayerConfig, options?: BuildDictionariesOptions) => Promise<{
|
|
17
18
|
unmergedDictionaries: UnmergedDictionaryOutput;
|
|
18
19
|
mergedDictionaries: MergedDictionaryOutput;
|
|
19
20
|
dynamicDictionaries: LocalizedDictionaryOutput;
|
|
@@ -21,4 +22,4 @@ declare const buildDictionary: (localDictionariesEntries: Dictionary[], configur
|
|
|
21
22
|
}>;
|
|
22
23
|
//#endregion
|
|
23
24
|
export { buildDictionary as n, BuildDictionariesOptions as t };
|
|
24
|
-
//# sourceMappingURL=buildIntlayerDictionary-
|
|
25
|
+
//# sourceMappingURL=buildIntlayerDictionary-C-LWgPIL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;AA6JA;;cAAa,YAAA,GAAsB,OAAA,aAAe,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.d.ts","names":[],"sources":["../../src/prepareIntlayer.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.d.ts","names":[],"sources":["../../src/prepareIntlayer.ts"],"mappings":";;;KAoBK,sBAAA;EACH,KAAA;EACA,GAAA;EACA,MAAA;EACA,QAAA;EACA,cAAA;EACA,UAAA,gBAA0B,OAAA;AAAA;AAAA,cAUf,eAAA,GACX,aAAA,EAAe,cAAA,EACf,OAAA,GAAU,sBAAA,KAAsB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../../../src/utils/formatter.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../../../src/utils/formatter.ts"],"mappings":";;;cAQa,UAAA,GACX,IAAA,qBACA,KAAA,GAAQ,UAAA;AAAA,cAYG,YAAA,GACX,MAAA,EAAQ,aAAA,GAAgB,aAAA,IACxB,KAAA,GAAO,UAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"mappings":";;;cAmBa,6BAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"mappings":";;;cAmBa,6BAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,cA6BU,kBAAA,GAA4B,aAAA,EAAe,cAAA,KAAc,OAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { t as MergedDictionaryOutput } from "./writeMergedDictionary-CMeghcRI.js";
|
|
2
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
+
import { Locale } from "@intlayer/types/allLocales";
|
|
5
|
+
|
|
6
|
+
//#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
|
|
7
|
+
type DictionaryResult = {
|
|
8
|
+
dictionaryPath: string;
|
|
9
|
+
dictionary: Dictionary;
|
|
10
|
+
};
|
|
11
|
+
type LocalizedDictionaryResult = Partial<Record<Locale, DictionaryResult>>;
|
|
12
|
+
type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Assembles the entry point file content from a pre-built preamble (import/require line),
|
|
15
|
+
* the locale→path record, the dictionary key, and the output format.
|
|
16
|
+
* Shared by all dictionary entry point generators.
|
|
17
|
+
*/
|
|
18
|
+
declare const buildEntryPointContent: (preamble: string, localizedDictionariesPathsRecord: LocalizedDictionaryResult, key: string, format?: "cjs" | "esm") => string;
|
|
19
|
+
/**
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
declare const generateDynamicLoadContentModule: (format: "cjs" | "esm", locales: string[]) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Generates the content of a dictionary entry point file.
|
|
27
|
+
* `loadContent` is imported from the shared module and called with the key.
|
|
28
|
+
*/
|
|
29
|
+
declare const generateDictionaryEntryPoint: (key: string, format?: "cjs" | "esm") => string;
|
|
30
|
+
/**
|
|
31
|
+
* Write the localized dictionaries to the dictionariesDir
|
|
32
|
+
* @param mergedDictionaries - The merged dictionaries
|
|
33
|
+
* @param configuration - The configuration
|
|
34
|
+
* @returns The final dictionaries
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
39
|
+
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
40
|
+
* console.log(finalDictionaries);
|
|
41
|
+
*
|
|
42
|
+
* // .intlayer/dynamic_dictionary/dictionaries/en_home.json
|
|
43
|
+
* // .intlayer/dynamic_dictionary/dictionaries/fr_home.json
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration: IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { generateDictionaryEntryPoint as a, buildEntryPointContent as i, LocalizedDictionaryOutput as n, generateDynamicLoadContentModule as o, LocalizedDictionaryResult as r, writeDynamicDictionary as s, DictionaryResult as t };
|
|
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/dist/types/{writeMergedDictionary-C4EvgXbL.d.ts → writeMergedDictionary-CMeghcRI.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as UnmergedDictionaryOutput } from "./writeUnmergedDictionary-Cxx51isz.js";
|
|
2
|
-
import
|
|
2
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeMergedDictionary.d.ts
|
|
@@ -24,7 +24,7 @@ type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
|
|
|
24
24
|
* // { key: 'home', content: { ... } },
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration
|
|
27
|
+
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration: IntlayerConfig) => Promise<MergedDictionaryOutput>;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MergedDictionaryResult as n, writeMergedDictionaries as r, MergedDictionaryOutput as t };
|
|
30
|
-
//# sourceMappingURL=writeMergedDictionary-
|
|
30
|
+
//# sourceMappingURL=writeMergedDictionary-CMeghcRI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary-CMeghcRI.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KAaY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;AAApD;;;;;AAkBA;;;;;cAAa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,EAAe,cAAA,KACd,OAAA,CAAQ,sBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.4.
|
|
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.
|
|
114
|
-
"@intlayer/config": "8.4.
|
|
115
|
-
"@intlayer/core": "8.4.
|
|
116
|
-
"@intlayer/dictionaries-entry": "8.4.
|
|
117
|
-
"@intlayer/remote-dictionaries-entry": "8.4.
|
|
118
|
-
"@intlayer/types": "8.4.
|
|
119
|
-
"@intlayer/unmerged-dictionaries-entry": "8.4.
|
|
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":"buildIntlayerDictionary-BGj5jDFy.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"mappings":";;;;;;;KAYY,wBAAA,GAA2B,OAAA;EACrC,OAAA;EACA,uBAAA;EACA,GAAA;AAAA;AAHF;;;AAAA,cAea,eAAA,GACX,wBAAA,EAA0B,UAAA,IAC1B,aAAA,GADoC,uBAAA,CACpC,cAAA,EACA,OAAA,GAAU,wBAAA,KAAwB,OAAA;wBAAA,wBAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { t as MergedDictionaryOutput } from "./writeMergedDictionary-C4EvgXbL.js";
|
|
2
|
-
import * as _intlayer_types_config0 from "@intlayer/types/config";
|
|
3
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
-
import { Locale } from "@intlayer/types/allLocales";
|
|
5
|
-
|
|
6
|
-
//#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
|
|
7
|
-
type DictionaryResult = {
|
|
8
|
-
dictionaryPath: string;
|
|
9
|
-
dictionary: Dictionary;
|
|
10
|
-
};
|
|
11
|
-
type LocalizedDictionaryResult = Partial<Record<Locale, DictionaryResult>>;
|
|
12
|
-
type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
13
|
-
/**
|
|
14
|
-
* This function generates the content of the dictionary list file
|
|
15
|
-
*/
|
|
16
|
-
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types_config0.IntlayerConfig) => string;
|
|
17
|
-
/**
|
|
18
|
-
* Write the localized dictionaries to the dictionariesDir
|
|
19
|
-
* @param mergedDictionaries - The merged dictionaries
|
|
20
|
-
* @param configuration - The configuration
|
|
21
|
-
* @returns The final dictionaries
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
26
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
27
|
-
* console.log(finalDictionaries);
|
|
28
|
-
*
|
|
29
|
-
* // .intlayer/dynamic_dictionaries/home.json
|
|
30
|
-
* // { key: 'home', content: { ... } },
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types_config0.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { writeDynamicDictionary as a, generateDictionaryEntryPoint as i, LocalizedDictionaryOutput as n, LocalizedDictionaryResult as r, DictionaryResult as t };
|
|
36
|
-
//# sourceMappingURL=writeDynamicDictionary-DE3SJg-g.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeDynamicDictionary-DE3SJg-g.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;;;;cAMW,4BAAA,GACX,gCAAA,EAAkC,yBAAA,EAClC,MAAA,kBACA,aAAA,GAF2D,uBAAA,CAE3D,cAAA;;;AAfF;;;;;;;;;;;;;;cAkEa,sBAAA,GACX,kBAAA,EAAoB,sBAAA,EACpB,aAAA,GAD0C,uBAAA,CAC1C,cAAA,EACA,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary-C4EvgXbL.d.ts","names":[],"sources":["../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KAaY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,GAD6C,uBAAA,CAC7C,cAAA,KACC,OAAA,CAAQ,sBAAA"}
|