@intlayer/chokidar 7.5.0 → 7.5.2-canary.0

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 (89) hide show
  1. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -1
  2. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +1 -1
  3. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +1 -1
  4. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -1
  5. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -2
  6. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +2 -2
  7. package/dist/cjs/cleanRemovedContentDeclaration.cjs +67 -0
  8. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -0
  9. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -1
  10. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +1 -1
  11. package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
  12. package/dist/cjs/createType/createType.cjs +1 -1
  13. package/dist/cjs/fetchDistantDictionaries.cjs +1 -1
  14. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +2 -2
  15. package/dist/cjs/handleContentDeclarationFileChange.cjs +8 -3
  16. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  17. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +8 -3
  18. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  19. package/dist/cjs/index.cjs +5 -5
  20. package/dist/cjs/listGitFiles.cjs +1 -1
  21. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
  22. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
  23. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -1
  24. package/dist/cjs/prepareIntlayer.cjs +2 -2
  25. package/dist/cjs/transformFiles/transformFiles.cjs +3 -3
  26. package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
  27. package/dist/cjs/utils/formatter.cjs +1 -1
  28. package/dist/cjs/watcher.cjs +12 -3
  29. package/dist/cjs/watcher.cjs.map +1 -1
  30. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -1
  31. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -1
  32. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  33. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +7 -2
  34. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  35. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -1
  36. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +1 -1
  37. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +1 -1
  38. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -1
  39. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +2 -2
  40. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +2 -2
  41. package/dist/esm/cleanRemovedContentDeclaration.mjs +66 -0
  42. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -0
  43. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -1
  44. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +1 -1
  45. package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
  46. package/dist/esm/createType/createType.mjs +1 -1
  47. package/dist/esm/fetchDistantDictionaries.mjs +1 -1
  48. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +2 -2
  49. package/dist/esm/handleContentDeclarationFileChange.mjs +8 -3
  50. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  51. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +8 -3
  52. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  53. package/dist/esm/index.mjs +5 -5
  54. package/dist/esm/listGitFiles.mjs +1 -1
  55. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
  56. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +1 -1
  57. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -1
  58. package/dist/esm/prepareIntlayer.mjs +2 -2
  59. package/dist/esm/transformFiles/transformFiles.mjs +3 -3
  60. package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
  61. package/dist/esm/utils/formatter.mjs +1 -1
  62. package/dist/esm/watcher.mjs +12 -3
  63. package/dist/esm/watcher.mjs.map +1 -1
  64. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -1
  65. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -1
  66. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  67. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +7 -2
  68. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  69. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  70. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  71. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  72. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  73. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  74. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  75. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  76. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  77. package/dist/types/cleanRemovedContentDeclaration.d.ts +7 -0
  78. package/dist/types/cleanRemovedContentDeclaration.d.ts.map +1 -0
  79. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  80. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  81. package/dist/types/formatDictionary.d.ts +15 -15
  82. package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -1
  83. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts.map +1 -1
  84. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
  85. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  86. package/dist/types/transformFiles/transformFiles.d.ts.map +1 -1
  87. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  88. package/dist/types/watcher.d.ts.map +1 -1
  89. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"transformFiles.mjs","names":["dictionary: Dictionary","multilingualContent: Record<string, TranslationNode>","extractedContent: Record<string, string>","replacements: TsReplacement[]","sourceFile: SourceFile","extractedContent: Record<string, string> | null","error: any"],"sources":["../../../src/transformFiles/transformFiles.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path';\nimport {\n ANSIColors,\n camelCaseToKebabCase,\n colorizePath,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { Node, Project, type SourceFile, SyntaxKind } from 'ts-morph';\nimport { writeContentDeclaration } from '../writeContentDeclaration';\nimport { detectFormatCommand } from '../writeContentDeclaration/detectFormatCommand';\nimport { extractDictionaryKey } from './extractDictionaryKey';\n\n// ==========================================\n// 1. Shared Utilities (exported for reuse in babel plugin)\n// ==========================================\n\n/**\n * Attributes that should be extracted for localization\n */\nexport const ATTRIBUTES_TO_EXTRACT = [\n 'title',\n 'placeholder',\n 'alt',\n 'aria-label',\n 'label',\n];\n\n/**\n * Default function to determine if a string should be extracted for localization\n */\nexport const shouldExtract = (text: string): boolean => {\n const trimmed = text.trim();\n if (!trimmed) return false;\n if (!trimmed.includes(' ')) return false;\n // Starts with Capital letter\n if (!/^[A-Z]/.test(trimmed)) return false;\n // Filter out template logic identifiers (simple check)\n if (trimmed.startsWith('{') || trimmed.startsWith('v-')) return false;\n return true;\n};\n\n/**\n * Generate a unique key from text for use as a dictionary key\n */\nexport const generateKey = (\n text: string,\n existingKeys: Set<string>\n): string => {\n const maxWords = 5;\n let key = text\n .replace(/\\s+/g, ' ')\n .replace(/_+/g, ' ')\n .replace(/-+/g, ' ')\n .replace(/[^a-zA-Z0-9 ]/g, '')\n .trim()\n .split(' ')\n .filter(Boolean)\n .slice(0, maxWords)\n .map((word, index) =>\n index === 0\n ? word.toLowerCase()\n : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n\n if (!key) key = 'content';\n if (existingKeys.has(key)) {\n let i = 1;\n while (existingKeys.has(`${key}${i}`)) i++;\n key = `${key}${i}`;\n }\n return key;\n};\n\n/**\n * Translation node structure used in multilingual dictionaries\n */\ntype TranslationNode = {\n nodeType: 'translation';\n translation: Record<string, string>;\n};\n\nconst writeContentHelper = async (\n extractedContent: Record<string, string>,\n componentKey: string,\n filePath: string,\n configuration: IntlayerConfig,\n outputDir?: string\n) => {\n const { defaultLocale } = configuration.internationalization;\n const { baseDir } = configuration.content;\n\n const isPerLocaleFile = configuration?.dictionary?.locale;\n\n const dirName = outputDir ? resolve(outputDir) : dirname(filePath);\n const ext = extname(filePath);\n const baseName = basename(filePath, ext);\n const contentBaseName = baseName.charAt(0).toLowerCase() + baseName.slice(1);\n\n const contentFilePath = join(dirName, `${contentBaseName}.content.ts`);\n const relativeContentFilePath = relative(baseDir, contentFilePath);\n\n let dictionary: Dictionary;\n\n if (isPerLocaleFile) {\n // Per-locale format: simple string content with locale property\n dictionary = {\n key: componentKey,\n content: extractedContent,\n locale: defaultLocale,\n filePath: relativeContentFilePath,\n };\n } else {\n // Multilingual format: content wrapped in translation nodes, no locale property\n const multilingualContent: Record<string, TranslationNode> = {};\n for (const [key, value] of Object.entries(extractedContent)) {\n multilingualContent[key] = {\n nodeType: 'translation',\n translation: {\n [defaultLocale]: value,\n },\n };\n }\n\n dictionary = {\n key: componentKey,\n content: multilingualContent,\n filePath: relativeContentFilePath,\n };\n }\n\n const relativeDir = relative(baseDir, dirName);\n await writeContentDeclaration(dictionary, configuration, {\n newDictionariesPath: relativeDir,\n });\n\n return contentFilePath;\n};\n\ntype TsReplacement = {\n node: Node;\n key: string;\n type: 'jsx-text' | 'jsx-attribute' | 'string-literal';\n};\n\nconst extractTsContent = (\n sourceFile: SourceFile,\n existingKeys: Set<string>\n): {\n extractedContent: Record<string, string>;\n replacements: TsReplacement[];\n} => {\n const extractedContent: Record<string, string> = {};\n const replacements: TsReplacement[] = [];\n\n sourceFile.forEachDescendant((node) => {\n // 1. JSX Text\n if (Node.isJsxText(node)) {\n const text = node.getText();\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.replace(/\\s+/g, ' ').trim();\n replacements.push({ node, key, type: 'jsx-text' });\n }\n }\n\n // 2. JSX Attributes\n else if (Node.isJsxAttribute(node)) {\n const name = node.getNameNode().getText();\n if (ATTRIBUTES_TO_EXTRACT.includes(name)) {\n const initializer = node.getInitializer();\n if (Node.isStringLiteral(initializer)) {\n const text = initializer.getLiteralValue();\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n replacements.push({ node, key, type: 'jsx-attribute' });\n }\n }\n }\n }\n\n // 3. String Literals (Variables, Arrays, etc.)\n else if (Node.isStringLiteral(node)) {\n const text = node.getLiteralValue();\n if (shouldExtract(text)) {\n const parent = node.getParent();\n\n // Skip if inside ImportDeclaration\n if (\n parent?.getKindName() === 'ImportDeclaration' ||\n parent?.getKindName() === 'ImportSpecifier' ||\n parent?.getKindName() === 'ModuleSpecifier'\n ) {\n return;\n }\n\n // Skip if it's a JSX Attribute value (handled above)\n if (Node.isJsxAttribute(parent)) return;\n\n // Skip console.log\n if (Node.isCallExpression(parent)) {\n const expression = parent.getExpression();\n if (expression.getText().includes('console.log')) return;\n }\n\n // Skip Object Keys: { key: \"value\" } -> \"key\" is PropertyAssignment name if not computed\n if (Node.isPropertyAssignment(parent)) {\n if (parent.getNameNode() === node) return; // It's the key\n }\n\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n replacements.push({ node, key, type: 'string-literal' });\n }\n }\n });\n\n return { extractedContent, replacements };\n};\n\n// ==========================================\n// 2. React (TS-Morph) Strategy\n// ==========================================\n\nconst processReactFile = async (\n filePath: string,\n componentKey: string,\n packageName: string,\n project: Project,\n save: boolean = true\n) => {\n let sourceFile: SourceFile;\n try {\n sourceFile = project.addSourceFileAtPath(filePath);\n } catch {\n sourceFile = project.getSourceFileOrThrow(filePath);\n }\n\n const existingKeys = new Set<string>();\n const { extractedContent, replacements } = extractTsContent(\n sourceFile,\n existingKeys\n );\n\n if (Object.keys(extractedContent).length === 0) return null;\n\n for (const { node, key, type } of replacements) {\n if (type === 'jsx-text' && Node.isJsxText(node)) {\n node.replaceWithText(`{content.${key}}`);\n } else if (type === 'jsx-attribute' && Node.isJsxAttribute(node)) {\n node.setInitializer(`{content.${key}.value}`);\n } else if (type === 'string-literal' && Node.isStringLiteral(node)) {\n // For React/JS variables, we usually want the value\n node.replaceWithText(`content.${key}.value`);\n }\n }\n\n // Inject hook\n const importDecl = sourceFile.getImportDeclaration(\n (d) => d.getModuleSpecifierValue() === packageName\n );\n if (!importDecl) {\n sourceFile.addImportDeclaration({\n namedImports: ['useIntlayer'],\n moduleSpecifier: packageName,\n });\n } else if (\n !importDecl.getNamedImports().some((n) => n.getName() === 'useIntlayer')\n ) {\n importDecl.addNamedImport('useIntlayer');\n }\n\n // Insert hook at start of component\n sourceFile.getFunctions().forEach((f) => {\n f.getBody()\n ?.asKind(SyntaxKind.Block)\n ?.insertStatements(0, `const content = useIntlayer(\"${componentKey}\");`);\n });\n\n // Also handle const/arrow components\n sourceFile.getVariableDeclarations().forEach((v) => {\n const init = v.getInitializer();\n if (Node.isArrowFunction(init) || Node.isFunctionExpression(init)) {\n const body = init.getBody();\n if (Node.isBlock(body)) {\n // Heuristic: check if it returns JSX or uses hooks\n if (\n body.getText().includes('return') ||\n body.getText().includes('use')\n ) {\n body.insertStatements(\n 0,\n `const content = useIntlayer(\"${componentKey}\");`\n );\n }\n }\n }\n });\n\n if (save) {\n await sourceFile.save();\n }\n return extractedContent;\n};\n\n// ==========================================\n// 5. Main Dispatcher\n// ==========================================\n\nexport type PackageName =\n | 'next-intlayer'\n | 'react-intlayer'\n | 'vue-intlayer'\n | 'svelte-intlayer'\n | 'preact-intlayer'\n | 'solid-intlayer'\n | 'angular-intlayer'\n | 'express-intlayer';\n\nexport type ExtractIntlayerOptions = {\n configOptions?: GetConfigurationOptions;\n outputDir?: string;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extractIntlayer = async (\n filePath: string,\n packageName: PackageName,\n options?: ExtractIntlayerOptions,\n project?: Project\n) => {\n const saveComponent = !options?.declarationOnly;\n const writeContent = !options?.codeOnly;\n\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n const { baseDir } = configuration.content;\n\n // Setup Project for TS/React files if needed\n const _project =\n project || new Project({ skipAddingFilesFromTsConfig: true });\n\n const baseName = extractDictionaryKey(\n filePath,\n (await fs.readFile(filePath)).toString()\n );\n const componentKey = camelCaseToKebabCase(baseName);\n const ext = extname(filePath);\n\n let extractedContent: Record<string, string> | null = null;\n\n if (ext === '.vue') {\n try {\n const { processVueFile } = (await import(\n '@intlayer/vue-transformer'\n )) as any;\n extractedContent = await processVueFile(\n filePath,\n componentKey,\n packageName,\n {\n generateKey,\n shouldExtract,\n extractTsContent,\n },\n saveComponent\n );\n } catch (error: any) {\n if (\n error.code === 'ERR_MODULE_NOT_FOUND' ||\n error.message?.includes('Cannot find module')\n ) {\n throw new Error(\n `Please install ${colorizePath('@intlayer/vue-transformer', ANSIColors.YELLOW)} to process Vue files.`\n );\n }\n throw error;\n }\n } else if (ext === '.svelte') {\n try {\n const { processSvelteFile } = (await import(\n '@intlayer/svelte-transformer'\n )) as any;\n extractedContent = await processSvelteFile(\n filePath,\n componentKey,\n packageName,\n {\n generateKey,\n shouldExtract,\n extractTsContent,\n },\n saveComponent\n );\n } catch (error: any) {\n if (\n error.code === 'ERR_MODULE_NOT_FOUND' ||\n error.message?.includes('Cannot find module')\n ) {\n throw new Error(\n `Please install ${colorizePath('@intlayer/svelte-transformer', ANSIColors.YELLOW)} to process Svelte files.`\n );\n }\n throw error;\n }\n } else if (['.tsx', '.jsx', '.ts', '.js'].includes(ext)) {\n extractedContent = await processReactFile(\n filePath,\n componentKey,\n packageName,\n _project,\n saveComponent\n );\n }\n\n if (!extractedContent) {\n appLogger(`No extractable text found in ${baseName}`);\n return;\n }\n\n // Shared Write Logic\n if (writeContent) {\n const contentFilePath = await writeContentHelper(\n extractedContent,\n componentKey,\n filePath,\n configuration,\n options?.outputDir\n );\n\n const relativeContentFilePath = relative(\n configuration.content.baseDir,\n contentFilePath\n );\n appLogger(`Created content file: ${colorizePath(relativeContentFilePath)}`);\n }\n\n // Optional: Format\n if (saveComponent) {\n try {\n const formatCommand = detectFormatCommand(configuration);\n if (formatCommand) {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'ignore', // Silent\n cwd: baseDir,\n });\n }\n } catch {\n // Ignore format errors\n }\n\n appLogger(\n `Updated component: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n};\n\nexport const transformFiles = async (\n filePaths: string[],\n packageName: PackageName,\n options?: ExtractIntlayerOptions\n) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n });\n\n for (const filePath of filePaths) {\n try {\n await extractIntlayer(filePath, packageName, options, project);\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }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Y,UACrB,KAAI;AACF,QAAM,gBAAgB,UAAU,aAAa,SAAS,QAAQ;UACvD,OAAO;AACd,YAAU,uBAAuB,SAAS,IAAK,MAAgB,UAAU"}
1
+ {"version":3,"file":"transformFiles.mjs","names":["dictionary: Dictionary","multilingualContent: Record<string, TranslationNode>","extractedContent: Record<string, string>","replacements: TsReplacement[]","sourceFile: SourceFile","extractedContent: Record<string, string> | null","error: any"],"sources":["../../../src/transformFiles/transformFiles.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path';\nimport {\n ANSIColors,\n camelCaseToKebabCase,\n colorizePath,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { Node, Project, type SourceFile, SyntaxKind } from 'ts-morph';\nimport { writeContentDeclaration } from '../writeContentDeclaration';\nimport { detectFormatCommand } from '../writeContentDeclaration/detectFormatCommand';\nimport { extractDictionaryKey } from './extractDictionaryKey';\n\n// ==========================================\n// 1. Shared Utilities (exported for reuse in babel plugin)\n// ==========================================\n\n/**\n * Attributes that should be extracted for localization\n */\nexport const ATTRIBUTES_TO_EXTRACT = [\n 'title',\n 'placeholder',\n 'alt',\n 'aria-label',\n 'label',\n];\n\n/**\n * Default function to determine if a string should be extracted for localization\n */\nexport const shouldExtract = (text: string): boolean => {\n const trimmed = text.trim();\n if (!trimmed) return false;\n if (!trimmed.includes(' ')) return false;\n // Starts with Capital letter\n if (!/^[A-Z]/.test(trimmed)) return false;\n // Filter out template logic identifiers (simple check)\n if (trimmed.startsWith('{') || trimmed.startsWith('v-')) return false;\n return true;\n};\n\n/**\n * Generate a unique key from text for use as a dictionary key\n */\nexport const generateKey = (\n text: string,\n existingKeys: Set<string>\n): string => {\n const maxWords = 5;\n let key = text\n .replace(/\\s+/g, ' ')\n .replace(/_+/g, ' ')\n .replace(/-+/g, ' ')\n .replace(/[^a-zA-Z0-9 ]/g, '')\n .trim()\n .split(' ')\n .filter(Boolean)\n .slice(0, maxWords)\n .map((word, index) =>\n index === 0\n ? word.toLowerCase()\n : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n\n if (!key) key = 'content';\n if (existingKeys.has(key)) {\n let i = 1;\n while (existingKeys.has(`${key}${i}`)) i++;\n key = `${key}${i}`;\n }\n return key;\n};\n\n/**\n * Translation node structure used in multilingual dictionaries\n */\ntype TranslationNode = {\n nodeType: 'translation';\n translation: Record<string, string>;\n};\n\nconst writeContentHelper = async (\n extractedContent: Record<string, string>,\n componentKey: string,\n filePath: string,\n configuration: IntlayerConfig,\n outputDir?: string\n) => {\n const { defaultLocale } = configuration.internationalization;\n const { baseDir, fileExtensions } = configuration.content;\n\n const isPerLocaleFile = configuration?.dictionary?.locale;\n\n const dirName = outputDir ? resolve(outputDir) : dirname(filePath);\n const ext = extname(filePath);\n const baseName = basename(filePath, ext);\n const contentBaseName = baseName.charAt(0).toLowerCase() + baseName.slice(1);\n\n const contentFilePath = join(\n dirName,\n `${contentBaseName}.${fileExtensions[0]}`\n );\n const relativeContentFilePath = relative(baseDir, contentFilePath);\n\n let dictionary: Dictionary;\n\n if (isPerLocaleFile) {\n // Per-locale format: simple string content with locale property\n dictionary = {\n key: componentKey,\n content: extractedContent,\n locale: defaultLocale,\n filePath: relativeContentFilePath,\n };\n } else {\n // Multilingual format: content wrapped in translation nodes, no locale property\n const multilingualContent: Record<string, TranslationNode> = {};\n for (const [key, value] of Object.entries(extractedContent)) {\n multilingualContent[key] = {\n nodeType: 'translation',\n translation: {\n [defaultLocale]: value,\n },\n };\n }\n\n dictionary = {\n key: componentKey,\n content: multilingualContent,\n filePath: relativeContentFilePath,\n };\n }\n\n const relativeDir = relative(baseDir, dirName);\n await writeContentDeclaration(dictionary, configuration, {\n newDictionariesPath: relativeDir,\n });\n\n return contentFilePath;\n};\n\ntype TsReplacement = {\n node: Node;\n key: string;\n type: 'jsx-text' | 'jsx-attribute' | 'string-literal';\n};\n\nconst extractTsContent = (\n sourceFile: SourceFile,\n existingKeys: Set<string>\n): {\n extractedContent: Record<string, string>;\n replacements: TsReplacement[];\n} => {\n const extractedContent: Record<string, string> = {};\n const replacements: TsReplacement[] = [];\n\n sourceFile.forEachDescendant((node) => {\n // 1. JSX Text\n if (Node.isJsxText(node)) {\n const text = node.getText();\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.replace(/\\s+/g, ' ').trim();\n replacements.push({ node, key, type: 'jsx-text' });\n }\n }\n\n // 2. JSX Attributes\n else if (Node.isJsxAttribute(node)) {\n const name = node.getNameNode().getText();\n if (ATTRIBUTES_TO_EXTRACT.includes(name)) {\n const initializer = node.getInitializer();\n if (Node.isStringLiteral(initializer)) {\n const text = initializer.getLiteralValue();\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n replacements.push({ node, key, type: 'jsx-attribute' });\n }\n }\n }\n }\n\n // 3. String Literals (Variables, Arrays, etc.)\n else if (Node.isStringLiteral(node)) {\n const text = node.getLiteralValue();\n if (shouldExtract(text)) {\n const parent = node.getParent();\n\n // Skip if inside ImportDeclaration\n if (\n parent?.getKindName() === 'ImportDeclaration' ||\n parent?.getKindName() === 'ImportSpecifier' ||\n parent?.getKindName() === 'ModuleSpecifier'\n ) {\n return;\n }\n\n // Skip if it's a JSX Attribute value (handled above)\n if (Node.isJsxAttribute(parent)) return;\n\n // Skip console.log\n if (Node.isCallExpression(parent)) {\n const expression = parent.getExpression();\n if (expression.getText().includes('console.log')) return;\n }\n\n // Skip Object Keys: { key: \"value\" } -> \"key\" is PropertyAssignment name if not computed\n if (Node.isPropertyAssignment(parent)) {\n if (parent.getNameNode() === node) return; // It's the key\n }\n\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n replacements.push({ node, key, type: 'string-literal' });\n }\n }\n });\n\n return { extractedContent, replacements };\n};\n\n// ==========================================\n// 2. React (TS-Morph) Strategy\n// ==========================================\n\nconst processReactFile = async (\n filePath: string,\n componentKey: string,\n packageName: string,\n project: Project,\n save: boolean = true\n) => {\n let sourceFile: SourceFile;\n try {\n sourceFile = project.addSourceFileAtPath(filePath);\n } catch {\n sourceFile = project.getSourceFileOrThrow(filePath);\n }\n\n const existingKeys = new Set<string>();\n const { extractedContent, replacements } = extractTsContent(\n sourceFile,\n existingKeys\n );\n\n if (Object.keys(extractedContent).length === 0) return null;\n\n for (const { node, key, type } of replacements) {\n if (type === 'jsx-text' && Node.isJsxText(node)) {\n node.replaceWithText(`{content.${key}}`);\n } else if (type === 'jsx-attribute' && Node.isJsxAttribute(node)) {\n node.setInitializer(`{content.${key}.value}`);\n } else if (type === 'string-literal' && Node.isStringLiteral(node)) {\n // For React/JS variables, we usually want the value\n node.replaceWithText(`content.${key}.value`);\n }\n }\n\n // Inject hook\n const importDecl = sourceFile.getImportDeclaration(\n (d) => d.getModuleSpecifierValue() === packageName\n );\n if (!importDecl) {\n sourceFile.addImportDeclaration({\n namedImports: ['useIntlayer'],\n moduleSpecifier: packageName,\n });\n } else if (\n !importDecl.getNamedImports().some((n) => n.getName() === 'useIntlayer')\n ) {\n importDecl.addNamedImport('useIntlayer');\n }\n\n // Insert hook at start of component\n sourceFile.getFunctions().forEach((f) => {\n f.getBody()\n ?.asKind(SyntaxKind.Block)\n ?.insertStatements(0, `const content = useIntlayer(\"${componentKey}\");`);\n });\n\n // Also handle const/arrow components\n sourceFile.getVariableDeclarations().forEach((v) => {\n const init = v.getInitializer();\n if (Node.isArrowFunction(init) || Node.isFunctionExpression(init)) {\n const body = init.getBody();\n if (Node.isBlock(body)) {\n // Heuristic: check if it returns JSX or uses hooks\n if (\n body.getText().includes('return') ||\n body.getText().includes('use')\n ) {\n body.insertStatements(\n 0,\n `const content = useIntlayer(\"${componentKey}\");`\n );\n }\n }\n }\n });\n\n if (save) {\n await sourceFile.save();\n }\n return extractedContent;\n};\n\n// ==========================================\n// 5. Main Dispatcher\n// ==========================================\n\nexport type PackageName =\n | 'next-intlayer'\n | 'react-intlayer'\n | 'vue-intlayer'\n | 'svelte-intlayer'\n | 'preact-intlayer'\n | 'solid-intlayer'\n | 'angular-intlayer'\n | 'express-intlayer';\n\nexport type ExtractIntlayerOptions = {\n configOptions?: GetConfigurationOptions;\n outputDir?: string;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extractIntlayer = async (\n filePath: string,\n packageName: PackageName,\n options?: ExtractIntlayerOptions,\n project?: Project\n) => {\n const saveComponent = !options?.declarationOnly;\n const writeContent = !options?.codeOnly;\n\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n const { baseDir } = configuration.content;\n\n // Setup Project for TS/React files if needed\n const _project =\n project || new Project({ skipAddingFilesFromTsConfig: true });\n\n const baseName = extractDictionaryKey(\n filePath,\n (await fs.readFile(filePath)).toString()\n );\n const componentKey = camelCaseToKebabCase(baseName);\n const ext = extname(filePath);\n\n let extractedContent: Record<string, string> | null = null;\n\n if (ext === '.vue') {\n try {\n const { processVueFile } = (await import(\n '@intlayer/vue-transformer'\n )) as any;\n extractedContent = await processVueFile(\n filePath,\n componentKey,\n packageName,\n {\n generateKey,\n shouldExtract,\n extractTsContent,\n },\n saveComponent\n );\n } catch (error: any) {\n if (\n error.code === 'ERR_MODULE_NOT_FOUND' ||\n error.message?.includes('Cannot find module')\n ) {\n throw new Error(\n `Please install ${colorizePath('@intlayer/vue-transformer', ANSIColors.YELLOW)} to process Vue files.`\n );\n }\n throw error;\n }\n } else if (ext === '.svelte') {\n try {\n const { processSvelteFile } = (await import(\n '@intlayer/svelte-transformer'\n )) as any;\n extractedContent = await processSvelteFile(\n filePath,\n componentKey,\n packageName,\n {\n generateKey,\n shouldExtract,\n extractTsContent,\n },\n saveComponent\n );\n } catch (error: any) {\n if (\n error.code === 'ERR_MODULE_NOT_FOUND' ||\n error.message?.includes('Cannot find module')\n ) {\n throw new Error(\n `Please install ${colorizePath('@intlayer/svelte-transformer', ANSIColors.YELLOW)} to process Svelte files.`\n );\n }\n throw error;\n }\n } else if (['.tsx', '.jsx', '.ts', '.js'].includes(ext)) {\n extractedContent = await processReactFile(\n filePath,\n componentKey,\n packageName,\n _project,\n saveComponent\n );\n }\n\n if (!extractedContent) {\n appLogger(`No extractable text found in ${baseName}`);\n return;\n }\n\n // Shared Write Logic\n if (writeContent) {\n const contentFilePath = await writeContentHelper(\n extractedContent,\n componentKey,\n filePath,\n configuration,\n options?.outputDir\n );\n\n const relativeContentFilePath = relative(\n configuration.content.baseDir,\n contentFilePath\n );\n appLogger(`Created content file: ${colorizePath(relativeContentFilePath)}`);\n }\n\n // Optional: Format\n if (saveComponent) {\n try {\n const formatCommand = detectFormatCommand(configuration);\n if (formatCommand) {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'ignore', // Silent\n cwd: baseDir,\n });\n }\n } catch {\n // Ignore format errors\n }\n\n appLogger(\n `Updated component: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n};\n\nexport const transformFiles = async (\n filePaths: string[],\n packageName: PackageName,\n options?: ExtractIntlayerOptions\n) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const project = new Project({\n skipAddingFilesFromTsConfig: true,\n });\n\n for (const filePath of filePaths) {\n try {\n await extractIntlayer(filePath, packageName, options, project);\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,iBAAiB,SAA0B;CACtD,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,KAAI,CAAC,QAAQ,SAAS,IAAI,CAAE,QAAO;AAEnC,KAAI,CAAC,SAAS,KAAK,QAAQ,CAAE,QAAO;AAEpC,K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M,EAAE,sBAAuB,MAAM,OACnC;AAEF,qBAAmB,MAAM,kBACvB,UACA,cACA,aACA;GACE;GACA;GACA;GACD,EACD,cACD;UACMA,OAAY;AACnB,MACE,MAAM,SAAS,0BACf,MAAM,SAAS,SAAS,qBAAqB,CAE7C,OAAM,IAAI,MACR,kBAAkB,aAAa,gCAAgC,WAAW,OAAO,CAAC,2BACnF;AAEH,QAAM;;UAEC;EAAC;EAAQ;EAAQ;EAAO;EAAM,CAAC,SAAS,IAAI,CACrD,oBAAmB,MAAM,iBACvB,UACA,cACA,aACA,UACA,cACD;AAGH,KAAI,CAAC,kBAAkB;AACrB,YAAU,gCAAgC,WAAW;AACrD;;AAIF,KAAI,cAAc;EAChB,MAAM,kBAAkB,MAAM,mBAC5B,kBACA,cACA,UACA,eACA,SAAS,UACV;AAMD,YAAU,yBAAyB,aAJH,SAC9B,cAAc,QAAQ,SACtB,gBACD,CACuE,GAAG;;AAI7E,KAAI,eAAe;AACjB,MAAI;GACF,MAAM,gBAAgB,oBAAoB,cAAc;AACxD,OAAI,cACF,UAAS,cAAc,QAAQ,YAAY,SAAS,EAAE;IACpD,OAAO;IACP,KAAK;IACN,CAAC;UAEE;AAIR,YACE,sBAAsB,aAAa,SAAS,SAAS,SAAS,CAAC,GAChE;;;AAIL,MAAa,iBAAiB,OAC5B,WACA,aACA,YACG;CAEH,MAAM,YAAY,aADI,iBAAiB,SAAS,cAAc,CACjB;CAE7C,MAAM,UAAU,IAAI,QAAQ,EAC1B,6BAA6B,MAC9B,CAAC;AAEF,MAAK,MAAM,YAAY,UACrB,KAAI;AACF,QAAM,gBAAgB,UAAU,aAAa,SAAS,QAAQ;UACvD,OAAO;AACd,YAAU,uBAAuB,SAAS,IAAK,MAAgB,UAAU"}
@@ -1,5 +1,5 @@
1
- import { ANSIColors, colorize, colorizePath } from "@intlayer/config";
2
1
  import { relative } from "node:path";
2
+ import { ANSIColors, colorize, colorizePath } from "@intlayer/config";
3
3
  import configuration from "@intlayer/config/built";
4
4
  import { getLocaleName } from "@intlayer/core";
5
5
  import { Locales } from "@intlayer/types";
@@ -2,8 +2,10 @@ import { handleAdditionalContentDeclarationFile } from "./handleAdditionalConten
2
2
  import { handleContentDeclarationFileChange } from "./handleContentDeclarationFileChange.mjs";
3
3
  import { handleUnlinkedContentDeclarationFile } from "./handleUnlinkedContentDeclarationFile.mjs";
4
4
  import { prepareIntlayer } from "./prepareIntlayer.mjs";
5
- import { getAppLogger, getConfiguration } from "@intlayer/config";
5
+ import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
6
+ import { readFile } from "node:fs/promises";
6
7
  import { basename } from "node:path";
8
+ import { getAppLogger, getConfiguration } from "@intlayer/config";
7
9
  import { watch as watch$1 } from "chokidar";
8
10
 
9
11
  //#region src/watcher.ts
@@ -12,8 +14,7 @@ const recentlyAddedFiles = /* @__PURE__ */ new Set();
12
14
  const watch = (options) => {
13
15
  const configuration = options?.configuration ?? getConfiguration(options?.configOptions);
14
16
  const appLogger = getAppLogger(configuration);
15
- const { watch: isWatchMode, watchedFilesPatternWithPath } = configuration.content;
16
- /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */
17
+ const { watch: isWatchMode, watchedFilesPatternWithPath, fileExtensions } = configuration.content;
17
18
  return watch$1(watchedFilesPatternWithPath, {
18
19
  persistent: isWatchMode,
19
20
  ignoreInitial: true,
@@ -31,6 +32,14 @@ const watch = (options) => {
31
32
  }).on("add", async (filePath) => {
32
33
  const fileName = basename(filePath);
33
34
  recentlyAddedFiles.add(fileName);
35
+ if (await readFile(filePath, "utf-8") === "") {
36
+ const extensionPattern = fileExtensions.map((ext) => ext.replace(/\./g, "\\.")).join("|");
37
+ await writeContentDeclaration({
38
+ key: fileName.replace(/* @__PURE__ */ new RegExp(`(${extensionPattern})$`), ""),
39
+ content: {},
40
+ filePath
41
+ }, configuration);
42
+ }
34
43
  await handleAdditionalContentDeclarationFile(filePath, configuration);
35
44
  setTimeout(() => recentlyAddedFiles.delete(fileName), 1e3);
36
45
  }).on("change", async (filePath) => await handleContentDeclarationFileChange(filePath, configuration)).on("unlink", async (filePath) => {
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.mjs","names":["chokidarWatch"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions'. */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\n\nconst recentlyAddedFiles = new Set<string>();\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n awaitWriteFinish: {\n stabilityThreshold: 1000,\n pollInterval: 100,\n },\n ignored: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n recentlyAddedFiles.add(fileName);\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlinkedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\n })\n .on('error', async (error) => {\n appLogger(`Watcher error: ${error}`, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!options?.skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n if (configuration.content.watch || options?.persistent) {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Watching Intlayer content declarations');\n // Start watching (assuming watch is also async)\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAM,qCAAqB,IAAI,KAAa;AAS5C,MAAa,SAAS,YAA2B;CAC/C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;CACpE,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EAAE,OAAO,aAAa,gCAC1B,cAAc;;AAGhB,QAAOA,QAAc,6BAA6B;EAChD,YAAY;EACZ,eAAe;EACf,kBAAkB;GAChB,oBAAoB;GACpB,cAAc;GACf;EACD,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,GAAG;EACJ,CAAC,CACC,GAAG,OAAO,OAAO,aAAa;EAC7B,MAAM,WAAW,SAAS,SAAS;AACnC,qBAAmB,IAAI,SAAS;AAEhC,QAAM,uCAAuC,UAAU,cAAc;AAErE,mBAAiB,mBAAmB,OAAO,SAAS,EAAE,IAAK;GAC3D,CACD,GACC,UACA,OAAO,aACL,MAAM,mCAAmC,UAAU,cAAc,CACpE,CACA,GAAG,UAAU,OAAO,aAAa;AAChC,aAAW,YAAY;GACrB,MAAM,WAAW,SAAS,SAAS;AAEnC,OAAI,mBAAmB,IAAI,SAAS,CAElC;AAGF,SAAM,qCAAqC,UAAU,cAAc;KAClE,IAAI;GACP,CACD,GAAG,SAAS,OAAO,UAAU;AAC5B,YAAU,kBAAkB,SAAS,EACnC,OAAO,SACR,CAAC;AAEF,YAAU,qBAAqB;AAE/B,QAAM,gBAAgB,cAAc;GACpC;;AAGN,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,EAAE;CAC9C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;AAEpE,KAAI,CAAC,SAAS,YACZ,OAAM,gBAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;AAG1D,KAAI,cAAc,QAAQ,SAAS,SAAS,YAAY;AAGtD,EAFkB,aAAa,cAAc,CAEnC,yCAAyC;AAEnD,QAAM;GAAE,GAAG;GAAM;GAAe,CAAC"}
1
+ {"version":3,"file":"watcher.mjs","names":["chokidarWatch"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions'. */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport { writeContentDeclaration } from './writeContentDeclaration';\n\nconst recentlyAddedFiles = new Set<string>();\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n watchedFilesPatternWithPath,\n fileExtensions,\n } = configuration.content;\n\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n awaitWriteFinish: {\n stabilityThreshold: 1000,\n pollInterval: 100,\n },\n ignored: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n recentlyAddedFiles.add(fileName);\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const isEmpty = fileContent === '';\n\n // Fill template content declaration file if it is empty\n if (isEmpty) {\n // Extract name from filename by removing any configured extension\n // e.g., \"example.content.ts\" -> \"example\" or \"example.i18n.json\" -> \"example\"\n const extensionPattern = fileExtensions\n .map((ext) => ext.replace(/\\./g, '\\\\.'))\n .join('|');\n const name = fileName.replace(new RegExp(`(${extensionPattern})$`), '');\n\n await writeContentDeclaration(\n {\n key: name,\n content: {},\n filePath,\n },\n configuration\n );\n }\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlinkedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\n })\n .on('error', async (error) => {\n appLogger(`Watcher error: ${error}`, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!options?.skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n if (configuration.content.watch || options?.persistent) {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Watching Intlayer content declarations');\n // Start watching (assuming watch is also async)\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAM,qCAAqB,IAAI,KAAa;AAS5C,MAAa,SAAS,YAA2B;CAC/C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;CACpE,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EACJ,OAAO,aACP,6BACA,mBACE,cAAc;AAElB,QAAOA,QAAc,6BAA6B;EAChD,YAAY;EACZ,eAAe;EACf,kBAAkB;GAChB,oBAAoB;GACpB,cAAc;GACf;EACD,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,GAAG;EACJ,CAAC,CACC,GAAG,OAAO,OAAO,aAAa;EAC7B,MAAM,WAAW,SAAS,SAAS;AACnC,qBAAmB,IAAI,SAAS;AAOhC,MALoB,MAAM,SAAS,UAAU,QAAQ,KAErB,IAGnB;GAGX,MAAM,mBAAmB,eACtB,KAAK,QAAQ,IAAI,QAAQ,OAAO,MAAM,CAAC,CACvC,KAAK,IAAI;AAGZ,SAAM,wBACJ;IACE,KAJS,SAAS,wBAAQ,IAAI,OAAO,IAAI,iBAAiB,IAAI,EAAE,GAAG;IAKnE,SAAS,EAAE;IACX;IACD,EACD,cACD;;AAGH,QAAM,uCAAuC,UAAU,cAAc;AAErE,mBAAiB,mBAAmB,OAAO,SAAS,EAAE,IAAK;GAC3D,CACD,GACC,UACA,OAAO,aACL,MAAM,mCAAmC,UAAU,cAAc,CACpE,CACA,GAAG,UAAU,OAAO,aAAa;AAChC,aAAW,YAAY;GACrB,MAAM,WAAW,SAAS,SAAS;AAEnC,OAAI,mBAAmB,IAAI,SAAS,CAElC;AAGF,SAAM,qCAAqC,UAAU,cAAc;KAClE,IAAI;GACP,CACD,GAAG,SAAS,OAAO,UAAU;AAC5B,YAAU,kBAAkB,SAAS,EACnC,OAAO,SACR,CAAC;AAEF,YAAU,qBAAqB;AAE/B,QAAM,gBAAgB,cAAc;GACpC;;AAGN,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,EAAE;CAC9C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;AAEpE,KAAI,CAAC,SAAS,YACZ,OAAM,gBAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;AAG1D,KAAI,cAAc,QAAQ,SAAS,SAAS,YAAY;AAGtD,EAFkB,aAAa,cAAc,CAEnC,yCAAyC;AAEnD,QAAM;GAAE,GAAG;GAAM;GAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
- import { colorizePath, x } from "@intlayer/config";
3
2
  import { dirname, join } from "node:path";
3
+ import { colorizePath, x } from "@intlayer/config";
4
4
  import { deepTransformNode } from "@intlayer/core";
5
5
  import { NodeType } from "@intlayer/types";
6
6
 
@@ -3,8 +3,8 @@ import { processContentDeclarationContent } from "./processContentDeclarationCon
3
3
  import { writeJSFile } from "./writeJSFile.mjs";
4
4
  import { mkdir, rm, writeFile } from "node:fs/promises";
5
5
  import { dirname, extname, join, resolve } from "node:path";
6
- import { getFilteredLocalesDictionary, getPerLocaleDictionary } from "@intlayer/core";
7
6
  import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
7
+ import { getFilteredLocalesDictionary, getPerLocaleDictionary } from "@intlayer/core";
8
8
  import { isDeepStrictEqual } from "node:util";
9
9
 
10
10
  //#region src/writeContentDeclaration/writeContentDeclaration.ts
@@ -1 +1 @@
1
- {"version":3,"file":"writeContentDeclaration.mjs","names":["pluginFormatResult: any","result: Dictionary","extension"],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\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 live: dictionary.live,\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 { content } = configuration;\n const { baseDir } = content;\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.content.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 );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\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 );\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): 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 const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\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.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,2BAA2B,OAC/B,YACA,eACA,eACG;;;;CAIH,MAAM,sBACJ,MAAM,iCAAiC,WAAW;CAEpD,IAAI,UAAU,oBAAoB;;;;AAMlC,KAAI,WAAW,OACb,WAAU,uBACR,qBACA,WAAW,OACZ,CAAC;UACO,WACT,WAAU,6BACR,qBACA,WACD,CAAC;CAGJ,IAAIA,qBAA0B;EAC5B,GAAG;EACH;EACD;;;;AAMD,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CACpD,KAAI,OAAO,cAAc;EAC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AW,SACZ;AACD,QAAM,yBACJ,UACA,6BACA,cACD;AAED,SAAO;GAAE,QAAQ;GAAW,MAAM;GAAU;;CAI9C,MAAM,yBAAyB,KAC7B,2BACA,GAAG,WAAW,IAAI,eACnB;AAED,OAAM,yBACJ,wBACA,6BACA,cACD;AAED,QAAO;EACL,QAAQ;EACR,MAAM;EACP;;AAGH,MAAM,2BAA2B,OAC/B,kBACA,YACA,kBACkB;AAKlB,OAAM,MAHM,QAAQ,iBAAiB,EAGpB,EAAE,WAAW,MAAM,CAAC;CAErC,MAAM,YAAY,QAAQ,iBAAiB;AAK3C,KAAI,CAJuB,cAAc,QAAQ,eAAe,KAC7D,gBAAc,QAAQC,YAAU,CAClC,CAEuB,SAAS,UAAU,CACzC,OAAM,IAAI,MACR,2BAA2B,UAAU,UAAU,mBAChD;AAGH,KAAI,cAAc,SAAS;AAIzB,QAAM,UAAU,kBAAkB,GAHX,KAAK,UAAU,YAAY,MAAM,EAAE,CAGN,IAAI;AAExD;;AAGF,OAAM,YAAY,kBAAkB,YAAY,cAAc;AAI9D,KAAI;AAKF,QAAM,GAJe,KACnB,cAAc,QAAQ,UACtB,yBACD,EACsB,EAAE,WAAW,MAAM,CAAC;SACrC"}
1
+ {"version":3,"file":"writeContentDeclaration.mjs","names":["pluginFormatResult: any","result: Dictionary","extension"],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\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 live: dictionary.live,\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 { content } = configuration;\n const { baseDir } = content;\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.content.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 );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\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 );\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): 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 const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\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.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n await rm(sentinelPath, { recursive: true });\n } catch {}\n};\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,2BAA2B,OAC/B,YACA,eACA,eACG;;;;CAIH,MAAM,sBACJ,MAAM,iCAAiC,WAAW;CAEpD,IAAI,UAAU,oBAAoB;;;;AAMlC,KAAI,WAAW,OACb,WAAU,uBACR,qBACA,WAAW,OACZ,CAAC;UACO,WACT,WAAU,6BACR,qBACA,WACD,CAAC;CAGJ,IAAIA,qBAA0B;EAC5B,GAAG;EACH;EACD;;;;AAMD,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CACpD,KAAI,OAAO,cAAc;EACvB,MAAM,kBAAkB,MAAM,OAAO,eAAe;GAClD,YAAY;GACZ;GACD,CAAC;AAEF,MAAI,gBACF,sBAAqB;;AAQ3B,KAAI,EAFF,mBAAmB,WAAW,mBAAmB,KAE1B,QAAO;CAEhC,IAAIC,SAAqB;EACvB,KAAK,WAAW;EAChB,IAAI,WAAW;EACf,OAAO,WAAW;EAClB,aAAa,WAAW;EACxB,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,UAAU,WAAW;EACrB,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB;EACD;AAUD,KAFe,uBAFb,WAAW,WAAW,QAAQ,WAAW,SAAS,GAA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ClC,CAEuB,SAAS,UAAU,CACzC,OAAM,IAAI,MACR,2BAA2B,UAAU,UAAU,mBAChD;AAGH,KAAI,cAAc,SAAS;AAIzB,QAAM,UAAU,kBAAkB,GAHX,KAAK,UAAU,YAAY,MAAM,EAAE,CAGN,IAAI;AAExD;;AAGF,OAAM,YAAY,kBAAkB,YAAY,cAAc;AAI9D,KAAI;AAKF,QAAM,GAJe,KACnB,cAAc,QAAQ,UACtB,yBACD,EACsB,EAAE,WAAW,MAAM,CAAC;SACrC"}
@@ -4,8 +4,8 @@ import { getFormatFromExtension } from "../utils/getFormatFromExtension.mjs";
4
4
  import { detectFormatCommand } from "./detectFormatCommand.mjs";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile, writeFile } from "node:fs/promises";
7
- import { getAppLogger, logger } from "@intlayer/config";
8
7
  import { extname } from "node:path";
8
+ import { getAppLogger, logger } from "@intlayer/config";
9
9
  import { execSync } from "node:child_process";
10
10
 
11
11
  //#region src/writeContentDeclaration/writeJSFile.ts
@@ -37,7 +37,12 @@ const writeJSFile = async (filePath, dictionary, configuration) => {
37
37
  live: mergedDictionary.live
38
38
  }).filter(([, value]) => value !== void 0))), "utf-8");
39
39
  }
40
- const finalCode = await transformJSFile(await readFile(filePath, "utf-8"), dictionary);
40
+ let fileContent = await readFile(filePath, "utf-8");
41
+ if (fileContent === "") {
42
+ const format = getFormatFromExtension(extname(filePath));
43
+ fileContent = await getContentDeclarationFileTemplate(mergedDictionary.key, format);
44
+ }
45
+ const finalCode = await transformJSFile(fileContent, dictionary);
41
46
  try {
42
47
  await writeFile(filePath, finalCode, "utf-8");
43
48
  logger(`Successfully updated ${filePath}`, {
@@ -1 +1 @@
1
- {"version":3,"file":"writeJSFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { getAppLogger, logger } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { detectFormatCommand } from './detectFormatCommand';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const mergedDictionary = {\n ...configuration.dictionary,\n ...dictionary,\n };\n\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n const format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format,\n // Filter out undefined values\n Object.fromEntries(\n Object.entries({\n id: mergedDictionary.id,\n locale: mergedDictionary.locale,\n filled: mergedDictionary.filled,\n fill: mergedDictionary.fill,\n description: mergedDictionary.description,\n title: mergedDictionary.title,\n tags: mergedDictionary.tags,\n version: mergedDictionary.version,\n priority: mergedDictionary.priority,\n live: mergedDictionary.live,\n }).filter(([, value]) => value !== undefined)\n )\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAa,cAAc,OACzB,UACA,YACA,kBACkB;CAClB,MAAM,mBAAmB;EACvB,GAAG,cAAc;EACjB,GAAG;EACJ;CAED,MAAM,YAAY,aAAa,cAAc;AAG7C,KAAI,CAAC,WAAW,SAAS,EAAE;EAGzB,MAAM,SAAS,uBAFO,QAAQ,SAAS,CAEa;AAEpD,YAAU,oCAAoC,EAC5C,WAAW,MACZ,CAAC;AAqBF,QAAM,UAAU,UApBC,MAAM,kCACrB,iBAAiB,KACjB,QAEA,OAAO,YACL,OAAO,QAAQ;GACb,IAAI,iBAAiB;GACrB,QAAQ,iBAAiB;GACzB,QAAQ,iBAAiB;GACzB,MAAM,iBAAiB;GACvB,aAAa,iBAAiB;GAC9B,OAAO,iBAAiB;GACxB,MAAM,iBAAiB;GACvB,SAAS,iBAAiB;GAC1B,UAAU,iBAAiB;GAC3B,MAAM,iBAAiB;GACxB,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC9C,CACF,EAEmC,QAAQ;;CAK9C,MAAM,YAAY,MAAM,gBAFJ,MAAM,SAAS,UAAU,QAAQ,EAEA,WAAW;AAGhE,KAAI;AACF,QAAM,UAAU,UAAU,WAAW,QAAQ;AAC7C,SAAO,wBAAwB,YAAY;GACzC,OAAO;GACP,WAAW;GACZ,CAAC;UACK,OAAO;EACd,MAAM,MAAM;AACZ,SAAO,iCAAiC,YAAY,EAClD,OAAO,SACR,CAAC;AACF,QAAM,IAAI,MAAM,gCAAgC,SAAS,IAAI,IAAI,UAAU;;CAG7E,MAAM,gBAAgB,oBAAoB,cAAc;AAExD,KAAI,cACF,KAAI;AACF,WAAS,cAAc,QAAQ,YAAY,SAAS,EAAE;GACpD,OAAO;GACP,KAAK,cAAc,QAAQ;GAC5B,CAAC;UACK,OAAO;AACd,UAAQ,MAAM,MAAM"}
1
+ {"version":3,"file":"writeJSFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { getAppLogger, logger } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { detectFormatCommand } from './detectFormatCommand';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const mergedDictionary = {\n ...configuration.dictionary,\n ...dictionary,\n };\n\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n const format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format,\n // Filter out undefined values\n Object.fromEntries(\n Object.entries({\n id: mergedDictionary.id,\n locale: mergedDictionary.locale,\n filled: mergedDictionary.filled,\n fill: mergedDictionary.fill,\n description: mergedDictionary.description,\n title: mergedDictionary.title,\n tags: mergedDictionary.tags,\n version: mergedDictionary.version,\n priority: mergedDictionary.priority,\n live: mergedDictionary.live,\n }).filter(([, value]) => value !== undefined)\n )\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n let fileContent = await readFile(filePath, 'utf-8');\n\n if (fileContent === '') {\n const format = getFormatFromExtension(extname(filePath) as Extension);\n\n fileContent = await getContentDeclarationFileTemplate(\n mergedDictionary.key,\n format\n );\n }\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n\n const formatCommand = detectFormatCommand(configuration);\n\n if (formatCommand) {\n try {\n execSync(formatCommand.replace('{{file}}', filePath), {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n });\n } catch (error) {\n console.error(error);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAa,cAAc,OACzB,UACA,YACA,kBACkB;CAClB,MAAM,mBAAmB;EACvB,GAAG,cAAc;EACjB,GAAG;EACJ;CAED,MAAM,YAAY,aAAa,cAAc;AAG7C,KAAI,CAAC,WAAW,SAAS,EAAE;EAGzB,MAAM,SAAS,uBAFO,QAAQ,SAAS,CAEa;AAEpD,YAAU,oCAAoC,EAC5C,WAAW,MACZ,CAAC;AAqBF,QAAM,UAAU,UApBC,MAAM,kCACrB,iBAAiB,KACjB,QAEA,OAAO,YACL,OAAO,QAAQ;GACb,IAAI,iBAAiB;GACrB,QAAQ,iBAAiB;GACzB,QAAQ,iBAAiB;GACzB,MAAM,iBAAiB;GACvB,aAAa,iBAAiB;GAC9B,OAAO,iBAAiB;GACxB,MAAM,iBAAiB;GACvB,SAAS,iBAAiB;GAC1B,UAAU,iBAAiB;GAC3B,MAAM,iBAAiB;GACxB,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC9C,CACF,EAEmC,QAAQ;;CAG9C,IAAI,cAAc,MAAM,SAAS,UAAU,QAAQ;AAEnD,KAAI,gBAAgB,IAAI;EACtB,MAAM,SAAS,uBAAuB,QAAQ,SAAS,CAAc;AAErE,gBAAc,MAAM,kCAClB,iBAAiB,KACjB,OACD;;CAGH,MAAM,YAAY,MAAM,gBAAgB,aAAa,WAAW;AAGhE,KAAI;AACF,QAAM,UAAU,UAAU,WAAW,QAAQ;AAC7C,SAAO,wBAAwB,YAAY;GACzC,OAAO;GACP,WAAW;GACZ,CAAC;UACK,OAAO;EACd,MAAM,MAAM;AACZ,SAAO,iCAAiC,YAAY,EAClD,OAAO,SACR,CAAC;AACF,QAAM,IAAI,MAAM,gCAAgC,SAAS,IAAI,IAAI,UAAU;;CAG7E,MAAM,gBAAgB,oBAAoB,cAAc;AAExD,KAAI,cACF,KAAI;AACF,WAAS,cAAc,QAAQ,YAAY,SAAS,EAAE;GACpD,OAAO;GACP,KAAK,cAAc,QAAQ;GAC5B,CAAC;UACK,OAAO;AACd,UAAQ,MAAM,MAAM"}
@@ -1,14 +1,14 @@
1
1
  import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
2
2
  import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
3
3
  import { LocalizedDictionaryOutput } from "./writeDynamicDictionary.js";
4
- import * as _intlayer_types13 from "@intlayer/types";
4
+ import * as _intlayer_types0 from "@intlayer/types";
5
5
  import { Dictionary } from "@intlayer/types";
6
6
 
7
7
  //#region src/buildIntlayerDictionary/buildIntlayerDictionary.d.ts
8
8
  /**
9
9
  * This function transpile the bundled code to to make dictionaries as JSON files
10
10
  */
11
- declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?: _intlayer_types13.IntlayerConfig, formats?: ("cjs" | "esm")[], importOtherDictionaries?: boolean) => Promise<{
11
+ declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?: _intlayer_types0.IntlayerConfig, formats?: ("cjs" | "esm")[], importOtherDictionaries?: boolean) => Promise<{
12
12
  unmergedDictionaries: UnmergedDictionaryOutput;
13
13
  mergedDictionaries: MergedDictionaryOutput;
14
14
  dynamicDictionaries: LocalizedDictionaryOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAca,4CACe,8BAAU,iBAAA,CACpC,mFAE8B;wBAFI;EAFvB,kBAsEZ,wBAAA;EArE2B,mBAAA,2BAAA;EAAU,iBACpC,2BAAA;CAAkC,CAAA"}
1
+ {"version":3,"file":"buildIntlayerDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAca,4CACe,8BAAU,gBAAA,CACpC,mFAE8B;wBAFI;EAFvB,kBAsEZ,wBAAA;EArE2B,mBAAA,2BAAA;EAAU,iBACpC,2BAAA;CAAkC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
2
- import * as _intlayer_types17 from "@intlayer/types";
2
+ import * as _intlayer_types1 from "@intlayer/types";
3
3
  import { Dictionary, Locale } from "@intlayer/types";
4
4
 
5
5
  //#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
@@ -12,7 +12,7 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
12
12
  /**
13
13
  * This function generates the content of the dictionary list file
14
14
  */
15
- declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types17.IntlayerConfig) => string;
15
+ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types1.IntlayerConfig) => string;
16
16
  /**
17
17
  * Write the localized dictionaries to the dictionariesDir
18
18
  * @param mergedDictionaries - The merged dictionaries
@@ -29,7 +29,7 @@ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: L
29
29
  * // { key: 'home', content: { ... } },
30
30
  * ```
31
31
  */
32
- declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types17.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
32
+ declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types1.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
33
33
  //#endregion
34
34
  export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
35
35
  //# sourceMappingURL=writeDynamicDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KAcY,gBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,yBAAA,GAA4B,OAAH,CACnC,MADmC,CAC5B,MAD4B,EACpB,gBADoB,CAAA,CAAA;AAC5B,KAGG,yBAAA,GAA4B,MAH/B,CAAA,MAAA,EAKP,yBALO,CAAA;;;;AADsC,cAYlC,4BAZkC,EAAA,CAAA,gCAAA,EAaX,yBAbW,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EAac,iBAAA,CAE3D,cAf6C,EAAA,GAAA,MAAA;AAI/C;AAQA;AAsDA;;;;;;;;;;;;;;cAAa,6CACS,wCAAsB,iBAAA,CAC1C,gDAEC,QAAQ"}
1
+ {"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":[],"mappings":";;;;;KAcY,gBAAA;;cAEE;AAFd,CAAA;AAKY,KAAA,yBAAA,GAA4B,OAAH,CACnC,MADmC,CAC5B,MAD4B,EACpB,gBADoB,CAAA,CAAA;AAC5B,KAGG,yBAAA,GAA4B,MAH/B,CAAA,MAAA,EAKP,yBALO,CAAA;;;;AADsC,cAYlC,4BAZkC,EAAA,CAAA,gCAAA,EAaX,yBAbW,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EAac,gBAAA,CAE3D,cAf6C,EAAA,GAAA,MAAA;AAI/C;AAQA;AAsDA;;;;;;;;;;;;;;cAAa,6CACS,wCAAsB,gBAAA,CAC1C,gDAEC,QAAQ"}
@@ -1,11 +1,11 @@
1
1
  import { LocalizedDictionaryOutput, LocalizedDictionaryResult } from "./writeDynamicDictionary.js";
2
- import * as _intlayer_types15 from "@intlayer/types";
2
+ import * as _intlayer_types21 from "@intlayer/types";
3
3
 
4
4
  //#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
5
5
  /**
6
6
  * This function generates the content of the dictionary list file
7
7
  */
8
- declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types15.IntlayerConfig) => string;
8
+ declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types21.IntlayerConfig) => string;
9
9
  /**
10
10
  * Write the localized dictionaries to the dictionariesDir
11
11
  * @param mergedDictionaries - The merged dictionaries
@@ -22,7 +22,7 @@ declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: Loc
22
22
  * // { key: 'home', content: { ... } },
23
23
  * ```
24
24
  */
25
- declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?: _intlayer_types15.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
25
+ declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?: _intlayer_types21.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
26
26
  //#endregion
27
27
  export { generateDictionaryEntryPoint, writeFetchDictionary };
28
28
  //# sourceMappingURL=writeFetchDictionary.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
2
- import * as _intlayer_types19 from "@intlayer/types";
2
+ import * as _intlayer_types20 from "@intlayer/types";
3
3
  import { Dictionary } from "@intlayer/types";
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?: _intlayer_types19.IntlayerConfig) => Promise<MergedDictionaryOutput>;
27
+ declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types20.IntlayerConfig) => Promise<MergedDictionaryOutput>;
28
28
  //#endregion
29
29
  export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
30
30
  //# sourceMappingURL=writeMergedDictionary.d.ts.map
@@ -1,4 +1,4 @@
1
- import * as _intlayer_types14 from "@intlayer/types";
1
+ import * as _intlayer_types0 from "@intlayer/types";
2
2
  import { Dictionary } from "@intlayer/types";
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?: _intlayer_types14.IntlayerConfig) => Promise<RemoteDictionaryOutput>;
26
+ declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types0.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"],"sourcesContent":[],"mappings":";;;;KAcY,sBAAA;;gBAEI;AAFhB,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,4CACS,8BAAU,iBAAA,CAC9B,mBACC,QAAQ"}
1
+ {"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":[],"mappings":";;;;KAcY,sBAAA;;gBAEI;AAFhB,CAAA;AAKY,KAAA,sBAAA,GAAyB,MAAe,CAAA,MAAA,EAAA,sBAAT,CAAA;AAkB3C;;;;;;;;;;;;;;;;cAAa,4CACS,8BAAU,gBAAA,CAC9B,mBACC,QAAQ"}
@@ -0,0 +1,7 @@
1
+ import { IntlayerConfig } from "@intlayer/types";
2
+
3
+ //#region src/cleanRemovedContentDeclaration.d.ts
4
+ declare const cleanRemovedContentDeclaration: (filePath: string, key: string, configuration: IntlayerConfig) => Promise<string[]>;
5
+ //#endregion
6
+ export { cleanRemovedContentDeclaration };
7
+ //# sourceMappingURL=cleanRemovedContentDeclaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanRemovedContentDeclaration.d.ts","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":[],"mappings":";;;cAUa,+EAGI,mBACd"}
@@ -1,10 +1,10 @@
1
- import * as _intlayer_types20 from "@intlayer/types";
1
+ import * as _intlayer_types19 from "@intlayer/types";
2
2
 
3
3
  //#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts
4
4
  /**
5
5
  * This function generates a list of dictionaries in the main directory
6
6
  */
7
- declare const createDictionaryEntryPoint: (configuration?: _intlayer_types20.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<void>;
7
+ declare const createDictionaryEntryPoint: (configuration?: _intlayer_types19.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<void>;
8
8
  //#endregion
9
9
  export { createDictionaryEntryPoint };
10
10
  //# sourceMappingURL=createDictionaryEntryPoint.d.ts.map
@@ -1,10 +1,10 @@
1
- import * as _intlayer_types21 from "@intlayer/types";
1
+ import * as _intlayer_types18 from "@intlayer/types";
2
2
 
3
3
  //#region src/createDictionaryEntryPoint/generateDictionaryListContent.d.ts
4
4
  /**
5
5
  * This function generates the content of the dictionary list file
6
6
  */
7
- declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types21.IntlayerConfig) => string;
7
+ declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types18.IntlayerConfig) => string;
8
8
  //#endregion
9
9
  export { generateDictionaryListContent };
10
10
  //# sourceMappingURL=generateDictionaryListContent.d.ts.map
@@ -1,4 +1,4 @@
1
- import * as _intlayer_types0 from "@intlayer/types";
1
+ import * as _intlayer_types4 from "@intlayer/types";
2
2
  import { Dictionary } from "@intlayer/types";
3
3
  import * as _intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
4
4
 
@@ -9,45 +9,45 @@ declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
9
9
  format: string;
10
10
  content: _intlayer_core_messageFormat0.JsonValue;
11
11
  $schema?: string;
12
- id?: _intlayer_types0.DictionaryId;
12
+ id?: _intlayer_types4.DictionaryId;
13
13
  projectIds?: string[];
14
- localId?: _intlayer_types0.LocalDictionaryId;
15
- localIds?: _intlayer_types0.LocalDictionaryId[];
16
- key: _intlayer_types0.DictionaryKey;
14
+ localId?: _intlayer_types4.LocalDictionaryId;
15
+ localIds?: _intlayer_types4.LocalDictionaryId[];
16
+ key: _intlayer_types4.DictionaryKey;
17
17
  title?: string;
18
18
  description?: string;
19
19
  versions?: string[];
20
20
  version?: string;
21
21
  filePath?: string;
22
22
  tags?: string[];
23
- locale?: _intlayer_types0.LocalesValues;
24
- fill?: _intlayer_types0.Fill;
23
+ locale?: _intlayer_types4.LocalesValues;
24
+ fill?: _intlayer_types4.Fill;
25
25
  filled?: true;
26
26
  priority?: number;
27
27
  live?: boolean;
28
- location?: _intlayer_types0.DictionaryLocation;
28
+ location?: _intlayer_types4.DictionaryLocation;
29
29
  };
30
30
  declare const formatDictionariesOutput: (dictionaries: Dictionary[]) => (Dictionary | {
31
31
  format: string;
32
32
  content: _intlayer_core_messageFormat0.JsonValue;
33
33
  $schema?: string;
34
- id?: _intlayer_types0.DictionaryId;
34
+ id?: _intlayer_types4.DictionaryId;
35
35
  projectIds?: string[];
36
- localId?: _intlayer_types0.LocalDictionaryId;
37
- localIds?: _intlayer_types0.LocalDictionaryId[];
38
- key: _intlayer_types0.DictionaryKey;
36
+ localId?: _intlayer_types4.LocalDictionaryId;
37
+ localIds?: _intlayer_types4.LocalDictionaryId[];
38
+ key: _intlayer_types4.DictionaryKey;
39
39
  title?: string;
40
40
  description?: string;
41
41
  versions?: string[];
42
42
  version?: string;
43
43
  filePath?: string;
44
44
  tags?: string[];
45
- locale?: _intlayer_types0.LocalesValues;
46
- fill?: _intlayer_types0.Fill;
45
+ locale?: _intlayer_types4.LocalesValues;
46
+ fill?: _intlayer_types4.Fill;
47
47
  filled?: true;
48
48
  priority?: number;
49
49
  live?: boolean;
50
- location?: _intlayer_types0.DictionaryLocation;
50
+ location?: _intlayer_types4.DictionaryLocation;
51
51
  })[];
52
52
  //#endregion
53
53
  export { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"handleContentDeclarationFileChange.d.ts","names":[],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":[],"mappings":";;;cAUa,+DAEH,mBAAc"}
1
+ {"version":3,"file":"handleContentDeclarationFileChange.d.ts","names":[],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":[],"mappings":";;;cAWa,+DAEH,mBAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"handleUnlinkedContentDeclarationFile.d.ts","names":[],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":[],"mappings":";;;cAUa,iEAEH,mBAAc"}
1
+ {"version":3,"file":"handleUnlinkedContentDeclarationFile.d.ts","names":[],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":[],"mappings":";;;cAWa,iEAEH,mBAAc"}
@@ -1,11 +1,11 @@
1
1
  import { DictionariesStatus } from "./loadDictionaries.js";
2
- import * as _intlayer_types22 from "@intlayer/types";
2
+ import * as _intlayer_types3 from "@intlayer/types";
3
3
  import { Dictionary } from "@intlayer/types";
4
4
  import { DictionaryAPI } from "@intlayer/backend";
5
5
 
6
6
  //#region src/loadDictionaries/loadRemoteDictionaries.d.ts
7
7
  declare const formatDistantDictionaries: (dictionaries: (DictionaryAPI | Dictionary)[]) => Dictionary[];
8
- declare const loadRemoteDictionaries: (configuration?: _intlayer_types22.IntlayerConfig, onStatusUpdate?: (status: DictionariesStatus[]) => void, options?: {
8
+ declare const loadRemoteDictionaries: (configuration?: _intlayer_types3.IntlayerConfig, onStatusUpdate?: (status: DictionariesStatus[]) => void, options?: {
9
9
  onStartRemoteCheck?: () => void;
10
10
  onStopRemoteCheck?: () => void;
11
11
  onError?: (error: Error) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":[],"mappings":";;;;;;cAUa,2CACI,gBAAgB,kBAC9B;cAOU,yCAsIZ,iBAAA,CArIC,0CAC0B,sCAVK;;EADpB,iBAAA,CAAA,EAAA,GAAA,GAAA,IAOR;EANY,OAAA,CAAA,EAAA,CAAA,KAAA,EAcK,KAdL,EAAA,GAAA,IAAA;CAAgB,EAAA,GAgB9B,OAhB8B,CAgBtB,UAhBsB,EAAA,CAAA"}
1
+ {"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":[],"mappings":";;;;;;cAUa,2CACI,gBAAgB,kBAC9B;cAOU,yCAsIZ,gBAAA,CArIC,0CAC0B,sCAVK;;EADpB,iBAAA,CAAA,EAAA,GAAA,GAAA,IAOR;EANY,OAAA,CAAA,EAAA,CAAA,KAAA,EAcK,KAdL,EAAA,GAAA,IAAA;CAAgB,EAAA,GAgB9B,OAhB8B,CAgBtB,UAhBsB,EAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"transformFiles.d.ts","names":[],"sources":["../../../src/transformFiles/transformFiles.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwBA;AAWa,cAXA,qBAoBZ,EAAA,MAAA,EAAA;AAKD;AA6QA;AAUA;AAOa,cA5SA,aA8aZ,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,OAAA;;;;AA9HkB,cAlSN,WAkSM,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,YAAA,EAhSH,GAgSG,CAAA,MAAA,CAAA,EAAA,GAAA,MAAA;AAAA,KArBP,WAAA,GAqBO,eAAA,GAAA,gBAAA,GAAA,cAAA,GAAA,iBAAA,GAAA,iBAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,kBAAA;AAgIN,KA3ID,sBAAA,GA8JX;EAjBc,aAAA,CAAA,EA5IG,uBA4IH;EACH,SAAA,CAAA,EAAA,MAAA;EAAsB,QAAA,CAAA,EAAA,OAAA;EAAA,eAAA,CAAA,EAAA,OAAA;;cAvIrB,iDAEE,uBACH,kCACA,YAAO;cAgIN,mDAEE,uBACH,2BAAsB"}
1
+ {"version":3,"file":"transformFiles.d.ts","names":[],"sources":["../../../src/transformFiles/transformFiles.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwBA;AAWa,cAXA,qBAoBZ,EAAA,MAAA,EAAA;AAKD;AAgRA;AAUA;AAOa,cA/SA,aAibZ,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,OAAA;;;;AA9HkB,cArSN,WAqSM,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,YAAA,EAnSH,GAmSG,CAAA,MAAA,CAAA,EAAA,GAAA,MAAA;AAAA,KArBP,WAAA,GAqBO,eAAA,GAAA,gBAAA,GAAA,cAAA,GAAA,iBAAA,GAAA,iBAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,kBAAA;AAgIN,KA3ID,sBAAA,GA8JX;EAjBc,aAAA,CAAA,EA5IG,uBA4IH;EACH,SAAA,CAAA,EAAA,MAAA;EAAsB,QAAA,CAAA,EAAA,OAAA;EAAA,eAAA,CAAA,EAAA,OAAA;;cAvIrB,iDAEE,uBACH,kCACA,YAAO;cAgIN,mDAEE,uBACH,2BAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatFromExtension.d.ts","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":[],"mappings":";KAAY,MAAA;AAAA,KACA,SAAA,GADM,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,QAAA;AACN,cAYC,sBAZQ,EAAA,CAAA,SAAA,EAY6B,SAZ7B,EAAA,GAYyC,MAZzC;AAYR,cAkBA,sBAlBqC,EAAA,CAAA,MAAY,EAkBf,MAF9C,EAAA,GAEuD,SAFvD"}
1
+ {"version":3,"file":"getFormatFromExtension.d.ts","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":[],"mappings":";KAAY,MAAA;AAAA,KACA,SAAA,GADM,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,QAAA;AACN,cAYC,sBAZQ,EAAA,CAAA,SAAA,EAY6B,SAZ7B,EAAA,GAYyC,MAZzC;AAYR,cAkBA,sBAlBqC,EAAA,CAAA,MAAA,EAkBH,MAF9C,EAAA,GAEuD,SAFvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"sourcesContent":[],"mappings":";;;;;;KAgBK,YAAA,GAAe;kBACF;EADb,aAAA,CAAA,EAEa,uBAFD;EAAG,WAAA,CAAA,EAAA,OAAA;CACF;AACA,cAKL,KALK,EAAA,CAAA,OAAA,CAAA,EAKc,YALd,EAAA,GAK0B,SAAA,CAAA,SAL1B;AAAuB,cAiE5B,qBAjE4B,EAAA,CAAA,OAAA,CAAA,EAiEa,YAjEb,EAAA,GAiEyB,OAjEzB,CAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"sourcesContent":[],"mappings":";;;;;;KAkBK,YAAA,GAAe;kBACF;EADb,aAAA,CAAA,EAEa,uBAFD;EAAG,WAAA,CAAA,EAAA,OAAA;CACF;AACA,cAKL,KALK,EAAA,CAAA,OAAA,CAAA,EAKc,YALd,EAAA,GAK0B,SAAA,CAAA,SAL1B;AAAuB,cA0F5B,qBA1F4B,EAAA,CAAA,OAAA,CAAA,EA0Fa,YA1Fb,EAAA,GA0FyB,OA1FzB,CAAA,IAAA,CAAA"}